@arcgis/core 5.1.0-next.73 → 5.1.0-next.75

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 (373) hide show
  1. package/Viewpoint.js +1 -1
  2. package/applications/Urban/editingSessionUtils.d.ts +95 -0
  3. package/applications/Urban/editingSessionUtils.js +2 -0
  4. package/arcade/ArcadePortal.js +1 -1
  5. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  6. package/arcade/functions/aiServices.js +1 -1
  7. package/arcade/functions/featuresetbase.js +1 -1
  8. package/arcade/functions/geomasync.js +1 -1
  9. package/arcade/functions/knowledgegraph.js +1 -1
  10. package/arcade/functions/string.js +1 -1
  11. package/arcade/languageUtils.js +1 -1
  12. package/arcade/portalUtils.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/{d17fcfc502f0e0fa6523.js → 003476e950bd27a2f884.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{8a664451845a47048859.js → 0539b5d015157c1d34a0.js} +1 -1
  16. package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +2 -0
  17. package/assets/esri/core/workers/chunks/{5a4d7ba6dc1d4b41d80d.js → 07eff82916681fcff069.js} +1 -1
  18. package/assets/esri/core/workers/chunks/09630888267cde87654f.js +1 -0
  19. package/assets/esri/core/workers/chunks/{8a14e3db28c403b046cf.js → 0d2bc1be5802681666a4.js} +1 -1
  20. package/assets/esri/core/workers/chunks/0eed2b1b06355ab89013.js +1 -0
  21. package/assets/esri/core/workers/chunks/0fa207c68dfd7ddee160.js +1 -0
  22. package/assets/esri/core/workers/chunks/146424b5717d0a645ee1.js +1 -0
  23. package/assets/esri/core/workers/chunks/{cfe246adb5e6cb6f0cfc.js → 14eb2cc8e2ad6d8d03fd.js} +1 -1
  24. package/assets/esri/core/workers/chunks/1765dfeac20e34ce25b7.js +1 -0
  25. package/assets/esri/core/workers/chunks/176dd195f77b98cb0b0f.js +1 -0
  26. package/assets/esri/core/workers/chunks/18f77ee3552d92962f15.js +1 -0
  27. package/assets/esri/core/workers/chunks/1906416c84bab369bbd6.js +1 -0
  28. package/assets/esri/core/workers/chunks/1a87e9bbd85ba29b1514.js +1 -0
  29. package/assets/esri/core/workers/chunks/{b98c24229463029504e8.js → 1f6b7626f333809837ef.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{b54b7cc6b23a70fed700.js → 1f8ccf96069ac3a40c3d.js} +1 -1
  31. package/assets/esri/core/workers/chunks/1ff3c15a51c4dc991806.js +1 -0
  32. package/assets/esri/core/workers/chunks/{cdf6ad970dc1893dac58.js → 24646a1176ce34039155.js} +1 -1
  33. package/assets/esri/core/workers/chunks/2a2e97918524e0f436d7.js +1 -0
  34. package/assets/esri/core/workers/chunks/2b0b398180ed98c2c84c.js +1 -0
  35. package/assets/esri/core/workers/chunks/{03894992558d063d0d5e.js → 312036c89a6a09bb06c2.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{80ace1c7203c5059525d.js → 330b47ac0759c3c35cc5.js} +1 -1
  37. package/assets/esri/core/workers/chunks/34b6b5dd415c68f0b0d1.js +1 -0
  38. package/assets/esri/core/workers/chunks/{422824e407b550170c8c.js → 34ea3ed78041437a8fc8.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{93ceb74ac88ef460fe5f.js → 359d3acb3953e64e5a78.js} +1 -1
  40. package/assets/esri/core/workers/chunks/384c235d36f32769e32b.js +1 -0
  41. package/assets/esri/core/workers/chunks/3a183259805638c25363.js +1 -0
  42. package/assets/esri/core/workers/chunks/{0839da55707f7c4cf780.js → 3b9100c59a8050f4834e.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{deaca3cd202851ecf9c2.js → 3cce9dad8ee0e4971d50.js} +1 -1
  44. package/assets/esri/core/workers/chunks/3efbb684c0409955186d.js +1 -0
  45. package/assets/esri/core/workers/chunks/40d251b6b42a41d68bd2.js +1 -0
  46. package/assets/esri/core/workers/chunks/42336e0d1ef88737b078.js +1 -0
  47. package/assets/esri/core/workers/chunks/452c01cecbbd1e370098.js +1 -0
  48. package/assets/esri/core/workers/chunks/47656ec12401e53f4bd3.js +1 -0
  49. package/assets/esri/core/workers/chunks/47b3a5213539548ff3a6.js +1 -0
  50. package/assets/esri/core/workers/chunks/{260d4571722cb1ff1366.js → 484d6c1b0fe1633515b7.js} +1 -1
  51. package/assets/esri/core/workers/chunks/4a23b27bfbcfa08fd9a7.js +1 -0
  52. package/assets/esri/core/workers/chunks/4c97cc922eece3a91b6b.js +1 -0
  53. package/assets/esri/core/workers/chunks/52b3a11c962810bc6dbe.js +1 -0
  54. package/assets/esri/core/workers/chunks/53750e85f3128993a43a.js +1 -0
  55. package/assets/esri/core/workers/chunks/{f207b3be0714cc50030a.js → 537fe2522dff1e6ce03b.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{656d6963e8f837fbf28f.js → 54023458195549f66215.js} +1 -1
  57. package/assets/esri/core/workers/chunks/55fd201ca5e10c6e4761.js +1 -0
  58. package/assets/esri/core/workers/chunks/56941e8bbd2d49bf2656.js +1 -0
  59. package/assets/esri/core/workers/chunks/{faad127dc07e54e7f6d1.js → 5abe34bb0110694f7b42.js} +1 -1
  60. package/assets/esri/core/workers/chunks/5d8e944b192aad4cf986.js +1 -0
  61. package/assets/esri/core/workers/chunks/{a78bc340a794fd332667.js → 5e1b847b116d21908a54.js} +1 -1
  62. package/assets/esri/core/workers/chunks/5ed8d8b5336c81fbcda3.js +1 -0
  63. package/assets/esri/core/workers/chunks/60915a3708a34da1977e.js +1 -0
  64. package/assets/esri/core/workers/chunks/6124141ac642e4ce1454.js +1 -0
  65. package/assets/esri/core/workers/chunks/61c523dd9d8027922465.js +1 -0
  66. package/assets/esri/core/workers/chunks/65c61171e6c6be5c5c2f.js +1 -0
  67. package/assets/esri/core/workers/chunks/6a3d207308b29651f397.js +1 -0
  68. package/assets/esri/core/workers/chunks/{b6cadb8a579241adcb86.js → 6b66fc32451433129a88.js} +1 -1
  69. package/assets/esri/core/workers/chunks/6c35583707f5c339ee99.js +1 -0
  70. package/assets/esri/core/workers/chunks/6f7aaba26773fe416ac2.js +1 -0
  71. package/assets/esri/core/workers/chunks/702e8468836863abd81b.js +1 -0
  72. package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +1 -0
  73. package/assets/esri/core/workers/chunks/{9f4b97204def91567e3c.js → 7595ceba529ed01c7590.js} +1 -1
  74. package/assets/esri/core/workers/chunks/75d5ea0da181f9e7425f.js +1312 -0
  75. package/assets/esri/core/workers/chunks/{af75e91b88e747aa76ac.js → 7601278ebced0c0c31cf.js} +1 -1
  76. package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +1 -0
  77. package/assets/esri/core/workers/chunks/{1661684357912726a72a.js → 77dd719516138afb1a2a.js} +1 -1
  78. package/assets/esri/core/workers/chunks/7b6c8be59ed87e386aa4.js +1 -0
  79. package/assets/esri/core/workers/chunks/7c820c5f6f05480d5050.js +1 -0
  80. package/assets/esri/core/workers/chunks/{ce2aa75e084ee56f5e29.js → 7f55eef696e9ed717bfc.js} +1 -1
  81. package/assets/esri/core/workers/chunks/80f4f686ce403cb2693f.js +1 -0
  82. package/assets/esri/core/workers/chunks/852f4cd514008fee5a55.js +1 -0
  83. package/assets/esri/core/workers/chunks/85aac8539996372f1ee8.js +1 -0
  84. package/assets/esri/core/workers/chunks/{50d5d6654ada9f28345d.js → 85e65ced3312bf9cf162.js} +1 -1
  85. package/assets/esri/core/workers/chunks/8a3bff0f58483c1665f9.js +1 -0
  86. package/assets/esri/core/workers/chunks/8b046e28f879079caada.js +1 -0
  87. package/assets/esri/core/workers/chunks/8d738e9acc2f222235ea.js +1 -0
  88. package/assets/esri/core/workers/chunks/{b9848bdbaf3d9ac93d54.js → 8f4cd30ce23e41c1a42c.js} +1 -1
  89. package/assets/esri/core/workers/chunks/9103eb0b9078019d3a26.js +1 -0
  90. package/assets/esri/core/workers/chunks/915e2711d3a2cfa402b2.js +1 -0
  91. package/assets/esri/core/workers/chunks/91f9e0e3662d4bf9f163.js +1 -0
  92. package/assets/esri/core/workers/chunks/983f6c8727fd9484718e.js +1 -0
  93. package/assets/esri/core/workers/chunks/99c161fecae710b53b40.js +1 -0
  94. package/assets/esri/core/workers/chunks/99d298d0039c536fcf3e.js +1 -0
  95. package/assets/esri/core/workers/chunks/9a5ef33d99a8f89956ff.js +1 -0
  96. package/assets/esri/core/workers/chunks/9d10db72e342fe63c981.js +1 -0
  97. package/assets/esri/core/workers/chunks/{bef27a25fbc4a6e19ec0.js → 9d6491f996eeb0c646ed.js} +1 -1
  98. package/assets/esri/core/workers/chunks/a015c2f54eb91e43a1f4.js +1 -0
  99. package/assets/esri/core/workers/chunks/a242ec19a7508de436da.js +1 -0
  100. package/assets/esri/core/workers/chunks/a320998f18922a35899f.js +1 -0
  101. package/assets/esri/core/workers/chunks/a7f9f478bd1493fc3c76.js +1 -0
  102. package/assets/esri/core/workers/chunks/aac6a57edd7494125204.js +1 -0
  103. package/assets/esri/core/workers/chunks/b73c146d3e550eaf07eb.js +1 -0
  104. package/assets/esri/core/workers/chunks/b7af0e6b9aadbcaf6a0b.js +1 -0
  105. package/assets/esri/core/workers/chunks/b803e7b0d489bb628d72.js +1 -0
  106. package/assets/esri/core/workers/chunks/b858adff7043683fe41c.js +1 -0
  107. package/assets/esri/core/workers/chunks/baeb96aef03d4c566af7.js +1 -0
  108. package/assets/esri/core/workers/chunks/bc75ab48f4c7609ef09d.js +1 -0
  109. package/assets/esri/core/workers/chunks/bc78937986854e500b8e.js +1 -0
  110. package/assets/esri/core/workers/chunks/{6ef3b8d67b498d655a99.js → bcb021a167580bb1619f.js} +1 -1
  111. package/assets/esri/core/workers/chunks/bd10d21545bca9a49de0.js +1 -0
  112. package/assets/esri/core/workers/chunks/bec3ee5ea945e1e07a35.js +1 -0
  113. package/assets/esri/core/workers/chunks/{5c663d5f98bdfa29151b.js → bf8f603848bad4a7deb4.js} +1 -1
  114. package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +2 -0
  115. package/assets/esri/core/workers/chunks/c31ee5617c61a933cb0e.js +1 -0
  116. package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +1 -0
  117. package/assets/esri/core/workers/chunks/ce7ef7c4ca14d66d96f6.js +1 -0
  118. package/assets/esri/core/workers/chunks/{f5c57ff48ca505ed701d.js → cf14b3a44705dacefac4.js} +1 -1
  119. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +1 -0
  120. package/assets/esri/core/workers/chunks/{06df187a116709f69952.js → d35c475f004367e333eb.js} +1 -1
  121. package/assets/esri/core/workers/chunks/d3b086eb9aa8c7d09048.js +1 -0
  122. package/assets/esri/core/workers/chunks/d55cef8199b8246fea3f.js +1 -0
  123. package/assets/esri/core/workers/chunks/d82da31dc702b8fd6a07.js +1 -0
  124. package/assets/esri/core/workers/chunks/d8decaee2c780e1b5e35.js +1 -0
  125. package/assets/esri/core/workers/chunks/{41809c16544ec25120fa.js → d95ffd990b3a7df69e1e.js} +1 -1
  126. package/assets/esri/core/workers/chunks/dc54d4a9fe1691862356.js +1 -0
  127. package/assets/esri/core/workers/chunks/dd4f431511edd975a53b.js +1 -0
  128. package/assets/esri/core/workers/chunks/dda2cb5c073d1e65f14f.js +1 -0
  129. package/assets/esri/core/workers/chunks/e18badd11f360cc2912b.js +1 -0
  130. package/assets/esri/core/workers/chunks/{e25a684eb9f025bdcc01.js → e262c4864dc06c43b380.js} +1 -1
  131. package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +1 -0
  132. package/assets/esri/core/workers/chunks/{99101789035f1787c630.js → e785f76c1a75cb1d1e1f.js} +1 -1
  133. package/assets/esri/core/workers/chunks/e9c5c295b6bf10e942a4.js +1 -0
  134. package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +1 -0
  135. package/assets/esri/core/workers/chunks/{873c1b705ac3d4e6c384.js → ea97619a4470f1540b99.js} +1 -1
  136. package/assets/esri/core/workers/chunks/eaab5ac049622986e3bc.js +1 -0
  137. package/assets/esri/core/workers/chunks/edee616b6f1b5be8fd39.js +1 -0
  138. package/assets/esri/core/workers/chunks/ef0085aa743b33cb549f.js +1 -0
  139. package/assets/esri/core/workers/chunks/f0250cecb243b32cdba7.js +1 -0
  140. package/assets/esri/core/workers/chunks/f518835b2dc89a48cfb1.js +1 -0
  141. package/assets/esri/core/workers/chunks/f590b60fca607d66001a.js +1 -0
  142. package/assets/esri/core/workers/chunks/{f6d047358d14328f3622.js → f60292d97bcdbf19165b.js} +1 -1
  143. package/assets/esri/core/workers/chunks/f6c8e93ca2987e83f925.js +1 -0
  144. package/assets/esri/core/workers/chunks/fb5a2205f05afc396119.js +1 -0
  145. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -0
  146. package/assets/esri/themes/dark/main.css +1 -1
  147. package/assets/esri/themes/light/main.css +1 -1
  148. package/assets/esri/themes/light/view.css +1 -1
  149. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  150. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  151. package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
  152. package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
  153. package/chunks/MultiPathImpl.js +1 -1
  154. package/chunks/Point2D.js +1 -1
  155. package/chunks/SpatialReference.js +1 -1
  156. package/chunks/aiServices.js +1 -1
  157. package/chunks/geometryEngineBase.js +1 -1
  158. package/chunks/languageUtils.js +1 -1
  159. package/config.js +1 -1
  160. package/core/has.js +1 -1
  161. package/core/workers/registry.js +1 -1
  162. package/form/elements/AttachmentElement.d.ts +15 -16
  163. package/form/elements/FieldElement.js +1 -1
  164. package/form/elements/GroupElement.d.ts +3 -2
  165. package/form/elements/inputs/attachments/AttachmentInput.d.ts +7 -9
  166. package/form/elements/inputs/attachments/AudioInput.d.ts +6 -8
  167. package/form/elements/inputs/attachments/DocumentInput.d.ts +5 -7
  168. package/form/elements/inputs/attachments/ImageInput.d.ts +6 -8
  169. package/form/elements/inputs/attachments/Input.d.ts +2 -6
  170. package/form/elements/inputs/attachments/SignatureInput.d.ts +5 -7
  171. package/form/elements/inputs/attachments/VideoInput.d.ts +6 -8
  172. package/form/elements/inputs/attachments/types.d.ts +3 -3
  173. package/geometry/FlatGeometry.js +1 -1
  174. package/geometry/geometryEngine.js +1 -1
  175. package/geometry/geometryEngineJSON.js +1 -1
  176. package/geometry/operators/projectOperator.d.ts +5 -4
  177. package/geometry/operators/projectOperator.js +1 -1
  178. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  179. package/geometry/support/normalizeUtils.js +1 -1
  180. package/geometry/support/normalizeUtilsCommon.js +1 -1
  181. package/graphic/ImageryGraphicOrigin.js +1 -1
  182. package/graphic/ImageryTileGraphicOrigin.js +1 -1
  183. package/graphic/WCSGraphicOrigin.js +1 -1
  184. package/identity/IdentityManagerBase.js +1 -1
  185. package/kernel.js +1 -1
  186. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  187. package/layers/IntegratedMeshLayer.js +1 -1
  188. package/layers/mixins/ArcGISImageService.js +1 -1
  189. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  190. package/layers/support/SymbolLayerDrawing.d.ts +18 -4
  191. package/package.json +4 -4
  192. package/popup/Features.d.ts +9 -9
  193. package/popup/Features.js +1 -1
  194. package/popup/actionUtils.js +1 -1
  195. package/popup/actions.js +1 -1
  196. package/portal/Portal.js +1 -1
  197. package/portal/PortalQueryParams.js +1 -1
  198. package/rest/print.js +1 -1
  199. package/support/revision.js +1 -1
  200. package/symbols/cim/CIMSymbolHelper.js +1 -1
  201. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  202. package/symbols/support/previewCIMSymbol.js +1 -1
  203. package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
  204. package/views/2d/engine/webgl/TextureManager.js +1 -1
  205. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  206. package/views/2d/layers/MediaLayerView2D.js +1 -1
  207. package/views/2d/layers/TileLayerView2D.js +1 -1
  208. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  209. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  210. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  211. package/views/3d/analysis/Dimension/DimensionController.js +1 -1
  212. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  213. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  214. package/views/3d/camera/intersectionUtils.js +1 -1
  215. package/views/3d/input/SceneInputManager.js +1 -1
  216. package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
  217. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  218. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  219. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
  220. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  221. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  222. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  223. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  224. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  225. package/views/3d/state/GoToOperation.js +1 -1
  226. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  227. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  228. package/views/3d/support/cameraScaleUtils.js +2 -0
  229. package/views/3d/support/cameraUtils.js +1 -1
  230. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  231. package/views/3d/support/renderInfoUtils/line.js +1 -1
  232. package/views/3d/support/viewpointUtils.js +1 -1
  233. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  234. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +13 -12
  235. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  236. package/views/3d/webgl.js +1 -1
  237. package/views/SceneView.d.ts +1 -0
  238. package/views/VideoView.js +1 -1
  239. package/views/draw/DrawGraphicTool.js +1 -1
  240. package/views/draw/DrawTool.js +1 -1
  241. package/views/draw/support/Box.js +1 -1
  242. package/views/draw/support/Reshape.js +1 -1
  243. package/views/draw/support/editingSessionUtils.js +2 -0
  244. package/views/draw/support/managers/MeasurementManager.js +1 -1
  245. package/views/interactive/SegmentLabels.js +1 -1
  246. package/views/interactive/sketch/SketchTooltipOptions.d.ts +9 -1
  247. package/views/interactive/snapping/SelfSnappingEngine.js +1 -1
  248. package/views/support/GeometryWorker.js +2 -0
  249. package/views/support/GeometryWorkerHandle.js +2 -0
  250. package/views/support/Scheduler.js +1 -1
  251. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  252. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  253. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  254. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  255. package/widgets/Editor/EditorViewModel.js +1 -1
  256. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  257. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  258. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  259. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  260. package/widgets/Editor/support/SketchController.js +1 -1
  261. package/widgets/Editor/workflowUtils.js +1 -1
  262. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -3
  263. package/widgets/FeatureTable/Grid/GridViewModel.d.ts +2 -11
  264. package/widgets/FeatureTable/support/types.d.ts +2 -1
  265. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +28 -0
  266. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
  267. package/widgets/OrientedImageryViewer.d.ts +27 -0
  268. package/widgets/Sketch/SketchViewModel.d.ts +10 -2
  269. package/widgets/Sketch/SketchViewModel.js +1 -1
  270. package/widgets/Sketch/support/ResponsiveToolbar/MeasuredContentGroup.js +1 -1
  271. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  272. package/widgets/Sketch.js +1 -1
  273. package/assets/esri/core/workers/chunks/00bae4b7e179336e0362.js +0 -1
  274. package/assets/esri/core/workers/chunks/027c3ea756db68e51f0a.js +0 -1
  275. package/assets/esri/core/workers/chunks/041c372e98a6fba90b36.js +0 -1
  276. package/assets/esri/core/workers/chunks/0783890816bac45277b9.js +0 -1
  277. package/assets/esri/core/workers/chunks/07aac6245a0d1adbb2d4.js +0 -1
  278. package/assets/esri/core/workers/chunks/0c00e5e4bd18467bcecd.js +0 -1
  279. package/assets/esri/core/workers/chunks/0dad0bca8d58b2c63d22.js +0 -1
  280. package/assets/esri/core/workers/chunks/0ef93722524620023f69.js +0 -1
  281. package/assets/esri/core/workers/chunks/1286f41f245ef22b3a26.js +0 -1
  282. package/assets/esri/core/workers/chunks/12e575a6d2b008b8fc2b.js +0 -1
  283. package/assets/esri/core/workers/chunks/161d60fdac2013c15543.js +0 -1
  284. package/assets/esri/core/workers/chunks/168de44a789d1cecc1f8.js +0 -1
  285. package/assets/esri/core/workers/chunks/1d9d7915cf7449e5d468.js +0 -1
  286. package/assets/esri/core/workers/chunks/235cb82952a18ff8d206.js +0 -1
  287. package/assets/esri/core/workers/chunks/266ba61b72a278d93a26.js +0 -1
  288. package/assets/esri/core/workers/chunks/27b80c386cebadcaca3c.js +0 -1
  289. package/assets/esri/core/workers/chunks/29d3890a5a43d934067a.js +0 -1
  290. package/assets/esri/core/workers/chunks/29e76256e3e867e80520.js +0 -1
  291. package/assets/esri/core/workers/chunks/2abf124e2956e4f76688.js +0 -1
  292. package/assets/esri/core/workers/chunks/2f17438d215bea3ce70f.js +0 -1
  293. package/assets/esri/core/workers/chunks/30f04dc001eaf838d64c.js +0 -1
  294. package/assets/esri/core/workers/chunks/356cb86606b8c674f947.js +0 -1
  295. package/assets/esri/core/workers/chunks/398e0dd2bc7e1ab84831.js +0 -1
  296. package/assets/esri/core/workers/chunks/3b1052aa30af3f6186cc.js +0 -1
  297. package/assets/esri/core/workers/chunks/3e87e3ad857d72f6ecbb.js +0 -1
  298. package/assets/esri/core/workers/chunks/42e483fde18f12da32a6.js +0 -1
  299. package/assets/esri/core/workers/chunks/43678e08a3d9d51c2a6d.js +0 -1
  300. package/assets/esri/core/workers/chunks/43ab44d37bc0ea97ef98.js +0 -1
  301. package/assets/esri/core/workers/chunks/47f2113357b2aa4f4f37.js +0 -1
  302. package/assets/esri/core/workers/chunks/488ed9584b527ec47be3.js +0 -1
  303. package/assets/esri/core/workers/chunks/4ad32580e0c0699fde1f.js +0 -1
  304. package/assets/esri/core/workers/chunks/54ed37ec9682ea739deb.js +0 -1
  305. package/assets/esri/core/workers/chunks/55369c5bd65bcaf78da1.js +0 -1
  306. package/assets/esri/core/workers/chunks/56fd3da911c2c4511e5d.js +0 -1
  307. package/assets/esri/core/workers/chunks/59592bb25f226865e88a.js +0 -1
  308. package/assets/esri/core/workers/chunks/5a83ea967ecde01d5622.js +0 -1
  309. package/assets/esri/core/workers/chunks/5b278b9980752ef495a2.js +0 -1
  310. package/assets/esri/core/workers/chunks/5d55b4449bcb24cd72b6.js +0 -1
  311. package/assets/esri/core/workers/chunks/5d8fe41a3c06ddb4094b.js +0 -1
  312. package/assets/esri/core/workers/chunks/5e59ff96aecdf2adcb3b.js +0 -1
  313. package/assets/esri/core/workers/chunks/608d707fd9d9f9088473.js +0 -1
  314. package/assets/esri/core/workers/chunks/6a21c9a4aeebe806ea39.js +0 -1
  315. package/assets/esri/core/workers/chunks/6c7ff968bd4fc816442d.js +0 -1
  316. package/assets/esri/core/workers/chunks/6d11ec355e5474b2968b.js +0 -1
  317. package/assets/esri/core/workers/chunks/6ea8b0d68881d16a2432.js +0 -1
  318. package/assets/esri/core/workers/chunks/7027d93dc5a4595d70c6.js +0 -1
  319. package/assets/esri/core/workers/chunks/70b35b2446558d5280e3.js +0 -1
  320. package/assets/esri/core/workers/chunks/7349cb45a93e6916f115.js +0 -1
  321. package/assets/esri/core/workers/chunks/74be994d789c57031631.js +0 -1
  322. package/assets/esri/core/workers/chunks/76edaeaf8fe344bb77a8.js +0 -1
  323. package/assets/esri/core/workers/chunks/76fe5b821d6b54db5721.js +0 -1
  324. package/assets/esri/core/workers/chunks/770880ad43f252962017.js +0 -1
  325. package/assets/esri/core/workers/chunks/7951d93f5f15aa76f49c.js +0 -1
  326. package/assets/esri/core/workers/chunks/7a56c836c89a8b978800.js +0 -1
  327. package/assets/esri/core/workers/chunks/81750c5177d8d52a3e05.js +0 -1
  328. package/assets/esri/core/workers/chunks/81d30c9062ad0120a863.js +0 -1
  329. package/assets/esri/core/workers/chunks/84772b023d04e415f17f.js +0 -1
  330. package/assets/esri/core/workers/chunks/88c5f7c712c6b89b5109.js +0 -1
  331. package/assets/esri/core/workers/chunks/88e469b82d2594f23649.js +0 -1
  332. package/assets/esri/core/workers/chunks/8a8242e7cc7e6a9e7876.js +0 -1
  333. package/assets/esri/core/workers/chunks/9444ed8ea117861ae89b.js +0 -1
  334. package/assets/esri/core/workers/chunks/9a38fd68b02b617c45d3.js +0 -1
  335. package/assets/esri/core/workers/chunks/9eb4ae556950e1d0124d.js +0 -2
  336. package/assets/esri/core/workers/chunks/a11f05ddd8314b648f76.js +0 -1
  337. package/assets/esri/core/workers/chunks/a37c28e3c4a2be9fd1d5.js +0 -1
  338. package/assets/esri/core/workers/chunks/a8d7f59927bdad564141.js +0 -1
  339. package/assets/esri/core/workers/chunks/a94bd20551c1179c7ec5.js +0 -1
  340. package/assets/esri/core/workers/chunks/abe22ae8ee0dcc9efbb7.js +0 -1
  341. package/assets/esri/core/workers/chunks/af5db0372d526e592fcc.js +0 -1
  342. package/assets/esri/core/workers/chunks/b702279c48f3009f6dd8.js +0 -1
  343. package/assets/esri/core/workers/chunks/bc53ce9a643f82d516c2.js +0 -1
  344. package/assets/esri/core/workers/chunks/bc887bd62579dba81e2b.js +0 -1
  345. package/assets/esri/core/workers/chunks/be1d6a571f76933dfbb0.js +0 -1
  346. package/assets/esri/core/workers/chunks/bfcdc5c315131aae34d8.js +0 -1
  347. package/assets/esri/core/workers/chunks/c0f624a2ca0d07ef8f8c.js +0 -1
  348. package/assets/esri/core/workers/chunks/c327fe276238af60fda4.js +0 -1
  349. package/assets/esri/core/workers/chunks/c3381b9a36299210ee47.js +0 -1
  350. package/assets/esri/core/workers/chunks/cb5e4b9b4a59c2622eb5.js +0 -1
  351. package/assets/esri/core/workers/chunks/d201a5dff18a5bb467ab.js +0 -1
  352. package/assets/esri/core/workers/chunks/d21fdd67477800101f3b.js +0 -1
  353. package/assets/esri/core/workers/chunks/d65b1234867f7d773d50.js +0 -2
  354. package/assets/esri/core/workers/chunks/d8d7331600d93bbca2b4.js +0 -1
  355. package/assets/esri/core/workers/chunks/db588bf3256e95c977b7.js +0 -1
  356. package/assets/esri/core/workers/chunks/dfdd474fddcd1d6091ce.js +0 -1
  357. package/assets/esri/core/workers/chunks/e1bc9ad767e08dc18bbc.js +0 -1
  358. package/assets/esri/core/workers/chunks/e235ea4293d5d463acfb.js +0 -1
  359. package/assets/esri/core/workers/chunks/e272411e2c9378aa8496.js +0 -1312
  360. package/assets/esri/core/workers/chunks/e43486113aaf72ac4dc1.js +0 -1
  361. package/assets/esri/core/workers/chunks/ea4c3393c5757e309a71.js +0 -1
  362. package/assets/esri/core/workers/chunks/ed216ddeb7f59f510bd0.js +0 -1
  363. package/assets/esri/core/workers/chunks/ef8886dff54063928bcb.js +0 -1
  364. package/assets/esri/core/workers/chunks/f43a63094190d2074cd0.js +0 -1
  365. package/assets/esri/core/workers/chunks/f5223ffb3be548c9b0a1.js +0 -1
  366. package/assets/esri/core/workers/chunks/fa160a2a5dc9f5a7c34b.js +0 -1
  367. package/geometry/support/triangulationUtilsDeprecated.js +0 -2
  368. package/views/3d/layers/graphics/extrudeUtilsDeprecated.js +0 -2
  369. package/views/3d/support/renderInfoUtils/polygonDeprecated.js +0 -2
  370. package/views/support/MeasurementWorker.js +0 -2
  371. package/views/support/MeasurementWorkerHandle.js +0 -2
  372. /package/assets/esri/core/workers/chunks/{9eb4ae556950e1d0124d.js.LICENSE.txt → 07aca5ecad659d55e795.js.LICENSE.txt} +0 -0
  373. /package/assets/esri/core/workers/chunks/{d65b1234867f7d773d50.js.LICENSE.txt → bfe575da727ce7c8d331.js.LICENSE.txt} +0 -0
@@ -1,7 +1,7 @@
1
1
  import type Input from "./Input.js";
2
2
  import type { InputMethod } from "../../../../portal/jsonTypes.js";
3
3
 
4
- /** @internal */
4
+ /** @since 5.1 */
5
5
  export interface VideoInputProperties extends Partial<Pick<VideoInput, "inputMethod" | "maxDuration">> {}
6
6
 
7
7
  /**
@@ -11,8 +11,7 @@ export interface VideoInputProperties extends Partial<Pick<VideoInput, "inputMet
11
11
  * >
12
12
  * > This class is not yet fully supported within the SDK and is not intended for use in development. Support will be added in an upcoming release.
13
13
  *
14
- * @internal
15
- * @since 4.31
14
+ * @since 5.1
16
15
  * @see [VideoInput](https://developers.arcgis.com/javascript/latest/references/core/form/elements/inputs/attachments/VideoInput/)
17
16
  * @example
18
17
  * // Creates a new VideoInput for an attachment element within a form
@@ -22,26 +21,25 @@ export interface VideoInputProperties extends Partial<Pick<VideoInput, "inputMet
22
21
  * });
23
22
  */
24
23
  export default class VideoInput extends Input {
25
- /** @internal */
24
+ /** @since 5.1 */
26
25
  constructor(properties?: VideoInputProperties);
27
26
  /**
28
27
  * The supported input methods used to attach a video.
29
28
  *
30
29
  * @default "any"
31
- * @internal
30
+ * @since 5.1
32
31
  */
33
32
  accessor inputMethod: InputMethod;
34
33
  /**
35
34
  * Defines the maximum length of an attachment for this element in seconds. If not specified, there is no maximum length.
36
35
  *
37
- * @internal
36
+ * @since 5.1
38
37
  */
39
38
  accessor maxDuration: number | null | undefined;
40
39
  /**
41
40
  * The input type identifier. Valid value of this property is "video"
42
41
  *
43
- * @internal
44
- * @since 5.0
42
+ * @since 5.1
45
43
  */
46
44
  get type(): "video";
47
45
  }
@@ -5,11 +5,11 @@ import type ImageInput from "./ImageInput.js";
5
5
  import type SignatureInput from "./SignatureInput.js";
6
6
  import type VideoInput from "./VideoInput.js";
7
7
 
8
- /** @internal */
8
+ /** @since 5.1 */
9
9
  export type AttachmentInputUnion = AttachmentInput | AudioInput | DocumentInput | ImageInput | SignatureInput | VideoInput;
10
10
 
11
- /** @internal */
11
+ /** @since 5.1 */
12
12
  export type AttachmentInputType = AttachmentInputUnion["type"];
13
13
 
14
- /** @internal */
14
+ /** @since 5.1 */
15
15
  export type NestableAttachmentInputUnion = Exclude<AttachmentInputUnion, AttachmentInput>;
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__addDisposableResource as t,__disposeResources as e}from"tslib";import{baseTypedSubArrayMemory as r}from"../core/memoryEstimations.js";import s from"./SpatialReference.js";import{empty as n,expandWithExtent as i}from"./support/aaBoundingBox.js";import{empty as a,expandExtentInPlace as o}from"./support/aaBoundingRect.js";import{isPoint as u,isMultipoint as h,isPolyline as l,isGeometryWithM as c,isGeometryWithZ as g}from"./support/jsonTypeUtils.js";import{equals as f}from"./support/spatialReferenceUtils.js";import{interpolateCircle as m}from"./support/curves/circleUtils.js";import{deriveCircleFromCircularArc as p}from"./support/curves/circularArcUtils.js";import{curveExtent as x}from"./support/curves/curveExtent.js";import{getEndpoint as v,isCurvedGeometry as d,isEllipticArc7 as y,isEllipticArc4 as C,isCircularArc as M,isBezierCurve as E}from"./support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as O}from"./support/curves/ellipticArc4Utils.js";import{deriveEllipse as S,interpolateEllipse as F}from"./support/curves/ellipticArc7Utils.js";import P from"../layers/graphics/OptimizedGeometry.js";class _{constructor({type:t,spatialReference:e,vertexCount:r,vertexXY:s,vertexZ:n,vertexM:i,partCount:a,partOffsets:o,partFlags:u,segmentFlags:h,segmentIndices:l,segmentParams:c,segmentCountArc:g,segmentCountBezier:f}){this.segmentCountArc=0,this.segmentCountBezier=0,this.type=t,this.spatialReference=e,this.vertexCount=r,this.vertexXY=s,this.vertexZ=n,this.vertexM=i,this.partCount=a,this.partOffsets=o,this.partFlags=u,this.segmentFlags=h,this.segmentIndices=l,this.segmentParams=c,this.segmentCountArc=g,this.segmentCountBezier=f}get segmentParamCount(){return 10*this.segmentCountArc+4*this.segmentCountBezier}get segmentCountLine(){const{segmentCount:t,segmentCountArc:e,segmentCountBezier:r}=this;return t&&t-e-r}get segmentCount(){return"polyline"===this.type?this.vertexCount-this.partCount:"polygon"===this.type?this.vertexCount:0}get hasZ(){return null!=this.vertexZ}get hasM(){return null!=this.vertexM}hasCurves(){return null!=this.segmentFlags}isMultipart(){return"polyline"===this.type||"polygon"===this.type}get usedMemory(){function t(t){return t?r+t.byteLength:0}return t(this.vertexXY)+t(this.vertexZ)+t(this.vertexM)+t(this.partOffsets)+t(this.partFlags)+t(this.segmentFlags)+t(this.segmentIndices)+t(this.segmentParams)}clone(){const{type:t,vertexCount:e,partCount:r,hasZ:s,hasM:n,segmentCountArc:i,segmentCountBezier:a}=this,o=U(t,e,r,s,n,this.hasCurves(),i,a);o.spatialReference=this.spatialReference;const{vertexXY:u,vertexZ:h,vertexM:l}=this;if(o.vertexXY.set(u.subarray(0,2*e),0),o.vertexZ?.set(h.subarray(0,e),0),o.vertexM?.set(l.subarray(0,e),0),this.isMultipart()){const{partOffsets:t,partFlags:e}=this;o.partFlags.set(e.subarray(0,r+1)),o.partOffsets.set(t.subarray(0,r+1))}if(this.hasCurves()){const{segmentFlags:t,segmentIndices:r,segmentParams:s,segmentParamCount:n}=this;o.segmentFlags.set(t.subarray(0,e),0),o.segmentIndices.set(r.subarray(0,e),0),o.segmentParams.set(s.subarray(0,n),0)}return o}equals(t){return this.equalsWithinTolerance(t,0)}equalsWithinTolerance(t,e){if(null==t)return!1;if(this===t)return!0;if(!f(this.spatialReference,t.spatialReference))return!1;if(this.vertexCount!==t.vertexCount||this.partCount!==t.partCount)return!1;if(this.hasZ!==t.hasZ||this.hasM!==t.hasM)return!1;if(this.hasCurves()!==t.hasCurves()||this.segmentCountArc!==t.segmentCountArc||this.segmentCountBezier!==t.segmentCountBezier)return!1;const r=0===e?(t,e)=>t!==e||isNaN(t)!==isNaN(e):(t,r)=>Math.abs(t-r)>e||isNaN(t)!==isNaN(r);for(let s=0;s<this.vertexCount;++s)if(r(this.vertexXY[2*s],t.vertexXY[2*s])||r(this.vertexXY[2*s+1],t.vertexXY[2*s+1]))return!1;if(this.hasZ)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexZ[s],t.vertexZ[s]))return!1;if(this.hasM)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexM[s],t.vertexM[s]))return!1;for(let s=0;s<this.partCount;++s)if(this.partFlags[s]!==t.partFlags[s]||this.partOffsets[s]!==t.partOffsets[s])return!1;if(this.hasCurves()){for(let e=0;e<this.vertexCount;++e)if(this.segmentFlags[e]!==t.segmentFlags[e]||this.segmentIndices[e]!==t.segmentIndices[e])return!1;for(let e=0;e<this.segmentParamCount;++e)if(r(this.segmentParams[e],t.segmentParams[e]))return!1}return!0}get parts(){return this.isMultipart()?new Z(this):[][Symbol.iterator]()}}class Z{constructor(t){this.geometry=t,this.value=new A(t)}get done(){return this.value.index>=this.geometry.partCount}next(){return++this.value.index,this}[Symbol.iterator](){return this}}class A{constructor(t){this.geometry=t,this.index=-1,this._readVertex=j(t),this._segments=new R(this)}get segments(){return this._segments.reset(),this._segments}get startVertex(){return this._readVertex(this.geometry.partOffsets[this.index])}get vertexCount(){const t=this.geometry.partOffsets;return t[this.index+1]-t[this.index]}}class R{constructor(t){this._part=t,this._partStart=0,this._partEnd=0,this._isPolygon="polygon"===t.geometry.type,this.value=new V(t.geometry)}get done(){return this.value.indexOfStartVertex>this._partEnd}next(){++this.value.indexOfStartVertex;const t=this.value.indexOfStartVertex>=this._partEnd;return this.value.indexOfEndVertex=t&&this._isPolygon?this._partStart:this.value.indexOfStartVertex+1,this}[Symbol.iterator](){return this}reset(){const{index:t}=this._part,e=this._part.geometry.partOffsets;this._partStart=e[t],this._partEnd=e[t+1]-(this._isPolygon?1:2),this.value.indexOfStartVertex=this._partStart-1}}class V{constructor(t){this.geometry=t,this.indexOfStartVertex=-1,this.indexOfEndVertex=-1,this._readVertex=j(t)}get xStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex]}get yStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex+1]}get zStart(){return this.geometry.vertexZ[this.indexOfStartVertex]}get mStart(){return this.geometry.vertexM[this.indexOfStartVertex]}get xEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex]}get yEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex+1]}get zEnd(){return this.geometry.vertexZ[this.indexOfEndVertex]}get mEnd(){return this.geometry.vertexM[this.indexOfEndVertex]}get start(){return this._readVertex(this.indexOfStartVertex)}get end(){return this._readVertex(this.indexOfEndVertex)}get curve(){const t=this.geometry.segmentFlags?.[this.indexOfStartVertex]??1;if(1===t)return this.end;const e=this.geometry.segmentParams;let r=this.geometry.segmentIndices[this.indexOfStartVertex];if(2===t){const t=e[r++],s=e[r++],n=e[r++],i=e[r++];return{b:[this.end,[t,s],[n,i]]}}const s=e[r++],n=e[r++],i=e[r++],a=e[r++],o=e[r++],u=e[r++];r++,r++;const h=e[r++],l=e[r++];if(!Boolean(4&s)&&1===i)return{c:[this.end,[h,l]]};const c=2&s?0:1,g=1&s?0:1;return{a:[this.end,[o,u],c,g,a,n,i]}}}function Y(r){let s;const{vertexCount:n,vertexXY:i,vertexZ:o,vertexM:u}=r,h=z(r);if(r.hasCurves()){const n={stack:[],error:void 0,hasError:!1};try{t(n,new k(r,["vertexZ","vertexM"]),!1);const e=a();for(const t of r.parts){let r=t.startVertex;for(const{curve:s}of t.segments)x(e,r,s),r=v(s)}const[i,o,u,l]=e;s={xmin:i,ymin:o,xmax:u,ymax:l,spatialReference:h}}catch(l){n.error=l,n.hasError=!0}finally{e(n)}}else{let t,e,r,a;t=e=1/0,r=a=-1/0;for(let s=0;s<n;++s){const n=i[2*s],o=i[2*s+1];t=Math.min(t,n),r=Math.max(r,n),e=Math.min(e,o),a=Math.max(a,o)}s={xmin:t,ymin:e,xmax:r,ymax:a,spatialReference:h}}if(o){let t=1/0,e=-1/0;for(const r of o)t=Math.min(t,r),e=Math.max(e,r);s.zmin=t,s.zmax=e}if(u){let t=1/0,e=-1/0;for(const r of u)t=Math.min(t,r),e=Math.max(e,r);s.mmin=t,s.mmax=e}return s}function b(r,s){const n={stack:[],error:void 0,hasError:!1};try{s??=a();t(n,new k(r,["vertexZ","vertexM","spatialReference"]),!1);return o(s,Y(r)),s}catch(i){n.error=i,n.hasError=!0}finally{e(n)}}function w(r,s){const a={stack:[],error:void 0,hasError:!1};try{s??=n();t(a,new k(r,["vertexM","spatialReference"]),!1);return i(s,Y(r)),s}catch(o){a.error=o,a.hasError=!0}finally{e(a)}}function I(t){let e,r,s;if(u(t)){s="point";const{x:n,y:i,z:a,m:o}=t,u=[n,i];null!=a&&u.push(a),null!=o&&u.push(o),r=[[u]],e=1}else h(t)?(s="multipoint",r=[t.points],e=t.points.length):l(t)?(s="polyline",r=t.curvePaths??t.paths,e=r.reduce((t,e)=>t+e.length,0)):(s="polygon",r=t.curveRings??t.rings,e=r.reduce((t,e)=>(0===e.length||(t+=e.length,W(e[0],v(e.at(-1)))&&--t),t),0));const n=U(s,e,s.includes("point")?0:r.length,g(t),c(t),d(t)),{hasZ:i,hasM:a,vertexXY:o,vertexZ:f,vertexM:m}=n;function p(t){o[2*O]=t[0],o[2*O+1]=t[1],i&&(f[O]=t[2]),a&&(m[O]=t[x]),++O}n.spatialReference=t.spatialReference??void 0;const x=n.hasZ?3:2;let O=0;if(!n.isMultipart()){if(!i&&!a){for(const[t,e]of r[0])o[2*O]=t,o[2*O+1]=e,++O;return n}for(const t of r[0])p(t);return n}const S="polygon"===s,{partOffsets:F}=n;let P=0;if(!n.hasCurves()){for(const t of r){if(F[P++]=O,0===t.length)continue;let e=t.length;if(S&&W(t[0],t.at(-1))&&--e,i||a)for(let r=0;r<e;++r)p(t[r]);else for(let r=0;r<e;++r){const[e,s]=t[r];o[2*O]=e,o[2*O+1]=s,++O}}return F[P]=O,n}function _(t){const e=Z+t;if(e<=(n.segmentParams?.length??0))return;let r=e*K;r=20*Math.ceil(r/20);const s=n.segmentParams;n.segmentParams=new Float64Array(r),null!=s&&n.segmentParams.set(s)}let Z=0;for(const u of r){if(n.partOffsets[P++]=O,0===u.length)continue;const t=u[0];let e=t;for(let r=1;r<u.length;++r){const t=u[r];p(e);const s=O-1;y(t)?(_(10),++n.segmentCountArc,Z=D(e,t,n,s,Z),e=t.a[0]):C(t)?(_(10),++n.segmentCountArc,Z=q(e,t,n,s,Z),e=t.a[0]):M(t)?(_(10),++n.segmentCountArc,Z=G(e,t,n,s,Z),e=t.c[0]):E(t)?(_(4),++n.segmentCountBezier,Z=H(e,t,n,s,Z),e=t.b[0]):e=t}S&&W(t,e)||p(e)}return n.partOffsets[P]=O,n}function X(t){const e=j(t),{vertexCount:r,partCount:s,hasZ:n,hasM:i}=t,a=z(t);if("point"===t.type){const[e,r]=t.vertexXY,s=t.vertexZ?.[0],n=t.vertexM?.[0];return{x:e,y:r,z:s,m:n,spatialReference:a}}let o=0;if("multipoint"===t.type){const t=[];for(;o<r;)t.push(e(o++));return{points:t,spatialReference:a,hasZ:n,hasM:i}}const u="polygon"===t.type;if(!t.hasCurves()){const r=new Array;for(let n=0;n<s;++n){const s=t.partOffsets[n+1],i=new Array;for(;o<s;)i.push(e(o++));u&&i.length>0&&i.push(i[0]),r.push(i)}return u?{rings:r,hasZ:n,hasM:i,spatialReference:a}:{paths:r,hasZ:n,hasM:i,spatialReference:a}}const h=new Array;for(const{segments:l,startVertex:c}of t.parts){const t=[c];for(const{curve:e}of l)t.push(e);h.push(t)}return u?{rings:[],curveRings:h,hasZ:n,hasM:i,spatialReference:a}:{paths:[],curvePaths:h,hasZ:n,hasM:i,spatialReference:a}}function B(t,{lengths:e,coords:r,hasZ:s,hasM:n},i){const a=t.includes("point")?0:e.length,o="polygon"===t,u="point"===t?1:e.reduce((t,e)=>t+e,0)-(o?a:0);s??=!1,n??=!1;const h=U(t,u,a,s,n,!1,0,0);if(h.spatialReference=i??void 0,!h.isMultipart()){for(let t=0,e=0;t<u;++t)h.vertexXY[2*t]=r[e++],h.vertexXY[2*t+1]=r[e++],s&&(h.vertexZ[t]=r[e++]),n&&(h.vertexM[t]=r[e++]);return h}const l=2+Number(s)+Number(n);let c=0,g=0;h.partOffsets[0]=0;for(const f of e){const t=h.partOffsets[g],e=t+f-Number(o);h.partOffsets[++g]=e;for(let i=t;i<e;++i)h.vertexXY[2*i]=r[c++],h.vertexXY[2*i+1]=r[c++],s&&(h.vertexZ[i]=r[c++]),n&&(h.vertexM[i]=r[c++]);o&&(c+=l)}return h}function L({type:t,vertexCount:e,vertexXY:r,vertexZ:s,vertexM:n,partCount:i,partOffsets:a,hasZ:o,hasM:u}){const h=new P([],[],o,u);i=Math.max(i,1);const l="polygon"===t;let c=0;for(let g=0;g<i;++g){const t=a?.[g+1]??e,i=h.coords.length;for(let e=c;e<t;++e)h.coords.push(r[2*e],r[2*e+1]),o&&h.coords.push(s[e]),u&&h.coords.push(n[e]);if(l){const t=c;h.coords.push(r[2*t],r[2*t+1]),o&&h.coords.push(s[t]),u&&h.coords.push(n[t])}h.lengths.push((h.coords.length-i)/h.stride),c=t}return"point"===t&&(h.lengths.length=0),h}function N(t,e){return"getSpatialReference"in t&&(e=T(t.getSpatialReference()),t=t.getGeometry()),new _({...t.toFlatGeometry(),spatialReference:e})}function T(t){if(null==t)return;const e=t.getText()||void 0,r=t.isCustomWkid()?0:t.getOldID();if(r<=0)return{wkt:e};let s=t.getLatestID();(s<=0||s===r)&&(s=void 0);const n=t.getVCS();if(null==n)return{wkid:r,latestWkid:s,wkt:e};const i=n.isCustomWkid()?0:n.getOldID();if(i<=0)return{wkt:e};let a=t.getLatestVerticalID();return(a<=0||a===i)&&(a=void 0),{wkid:r,wkt:e,latestWkid:s,vcsWkid:i,latestVcsWkid:a}}class k{constructor(t,e){this.target=t,this.keys=e,this.oldValues=e.map(e=>t[e]);for(const r of e)t[r]=void 0}[Symbol.dispose](){this.keys.map((t,e)=>{this.target[t]=this.oldValues[e]})}}function z({spatialReference:t}){return t instanceof s?t.toJSON():t}function j({vertexXY:t,vertexZ:e,vertexM:r}){return e?r?s=>[t[2*s],t[2*s+1],e[s],r[s]]:r=>[t[2*r],t[2*r+1],e[r]]:r?e=>[t[2*e],t[2*e+1],r[e]]:e=>[t[2*e],t[2*e+1]]}function W(t,e){return t.every((t,r)=>t===e[r])}function U(t,e,r,s,n,i,a,o){a??=0,o??=0;const u=new _({type:t,vertexCount:e,vertexXY:null,vertexZ:void 0,vertexM:void 0,partCount:r,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:a,segmentCountBezier:o});let h=2*Float64Array.BYTES_PER_ELEMENT*e;s&&(h+=Float64Array.BYTES_PER_ELEMENT*e),n&&(h+=Float64Array.BYTES_PER_ELEMENT*e),u.isMultipart()&&(h+=(r+1)*Int32Array.BYTES_PER_ELEMENT,h+=(r+1)*Int8Array.BYTES_PER_ELEMENT),i&&(h+=e*Int8Array.BYTES_PER_ELEMENT,h+=e*Int32Array.BYTES_PER_ELEMENT,h+=u.segmentParamCount*Float64Array.BYTES_PER_ELEMENT);const l=new ArrayBuffer(h);let c=0;return u.vertexXY=new Float64Array(l,c,2*e),c+=u.vertexXY.byteLength,s&&(u.vertexZ=new Float64Array(l,c,e),c+=u.vertexZ.byteLength),n&&(u.vertexM=new Float64Array(l,c,e),c+=u.vertexM.byteLength),i&&(u.segmentParams=new Float64Array(l,c,u.segmentParamCount),c+=u.segmentParams.byteLength,u.segmentIndices=new Int32Array(l,c,e),u.segmentIndices.fill(Q),c+=u.segmentIndices.byteLength),u.isMultipart()&&(u.partOffsets=new Int32Array(l,c,r+1),c+=u.partOffsets.byteLength,u.partFlags=new Int8Array(l,c,r+1),c+=u.partFlags.byteLength,"polygon"===u.type&&u.partFlags.subarray(0,r).fill(1)),i&&(u.segmentFlags=new Int8Array(l,c,e),u.segmentFlags.fill(1),c+=u.segmentFlags.byteLength),u}function D(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const[o,[u,h],l,c,g,f,m]=e.a;let p=4;c||(p|=1),l||(p|=2);const x=S(t,e),[v,d]=F(x,.5);return n[a++]=p,n[a++]=f,n[a++]=m,n[a++]=g,n[a++]=u,n[a++]=h,n[a++]=x.u2-x.u1,n[a++]=x.u1,n[a++]=v,n[a++]=d,a}function q(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const o=O(t,e);return J(o,4,...m(o,.5),n,a)}function G(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;return J(p(t,e),0,...e.c[1],n,a)}function J(t,e,r,s,n,i){const{cx:a,cy:o,thetaStart:u,thetaEnd:h,radius:l}=t;u>h||(e|=1);return Math.abs(h-u)<=Math.PI||(e|=2),n[i++]=e,n[i++]=l,n[i++]=1,n[i++]=0,n[i++]=a,n[i++]=o,n[i++]=h-u,n[i++]=u,n[i++]=r,n[i++]=s,i}function H(t,{b:[e,[r,s],[n,i]]},{segmentFlags:a,segmentIndices:o,segmentParams:u},h,l){return a[h]=2,o[h]=l,u[l++]=r,u[l++]=s,u[l++]=n,u[l++]=i,l}const K=1.61803,Q=-1;export{_ as FlatGeometry,U as allocateFlatGeometry,X as convertFlatToGeometryJSON,L as convertFlatToOptimizedGeometry,I as convertGeometryToFlat,N as convertGeometryxToFlat,B as convertOptimizedGeometryToFlat,w as getBoundingBox,b as getBoundingRect,Y as getExtentJSON,H as writeBezierCurveSegment,G as writeCircularArcSegment,q as writeEllipticArc4Segment,D as writeEllipticArc7Segment};
2
+ import{__addDisposableResource as t,__disposeResources as e}from"tslib";import{baseTypedSubArrayMemory as r}from"../core/memoryEstimations.js";import s from"./SpatialReference.js";import{empty as n,expandWithExtent as i}from"./support/aaBoundingBox.js";import{empty as a,expandExtentInPlace as o}from"./support/aaBoundingRect.js";import{isPoint as u,isMultipoint as h,isPolyline as l,isGeometryWithM as c,isGeometryWithZ as g}from"./support/jsonTypeUtils.js";import{equals as f}from"./support/spatialReferenceUtils.js";import{interpolateCircle as m}from"./support/curves/circleUtils.js";import{deriveCircleFromCircularArc as p}from"./support/curves/circularArcUtils.js";import{curveExtent as x}from"./support/curves/curveExtent.js";import{getEndpoint as v,isCurvedGeometry as d,isEllipticArc7 as y,isEllipticArc4 as C,isCircularArc as M,isBezierCurve as E}from"./support/curves/curveUtils.js";import{deriveCircleFromEllipticArc4 as O}from"./support/curves/ellipticArc4Utils.js";import{deriveEllipse as S,interpolateEllipse as P}from"./support/curves/ellipticArc7Utils.js";import _ from"../layers/graphics/OptimizedGeometry.js";class A{constructor({type:t,spatialReference:e,vertexCount:r,vertexXY:s,vertexZ:n,vertexM:i,partCount:a,partOffsets:o,partFlags:u,segmentFlags:h,segmentIndices:l,segmentParams:c,segmentCountArc:g,segmentCountBezier:f}){this.segmentCountArc=0,this.segmentCountBezier=0,this.type=t,this.spatialReference=e,this.vertexCount=r,this.vertexXY=s,this.vertexZ=n,this.vertexM=i,this.partCount=a,this.partOffsets=o,this.partFlags=u,this.segmentFlags=h,this.segmentIndices=l,this.segmentParams=c,this.segmentCountArc=g,this.segmentCountBezier=f}get segmentParamCount(){return 10*this.segmentCountArc+4*this.segmentCountBezier}get segmentCountLine(){const{segmentCount:t,segmentCountArc:e,segmentCountBezier:r}=this;return t&&t-e-r}get segmentCount(){return"polyline"===this.type?this.vertexCount-this.partCount:"polygon"===this.type?this.vertexCount:0}get hasZ(){return null!=this.vertexZ}get hasM(){return null!=this.vertexM}hasCurves(){return this.segmentCountArc+this.segmentCountBezier>0}isMultipart(){return"polyline"===this.type||"polygon"===this.type}get usedMemory(){function t(t){return t?r+t.byteLength:0}return t(this.vertexXY)+t(this.vertexZ)+t(this.vertexM)+t(this.partOffsets)+t(this.partFlags)+t(this.segmentFlags)+t(this.segmentIndices)+t(this.segmentParams)}clone(){const{type:t,vertexCount:e,partCount:r,hasZ:s,hasM:n,segmentCountArc:i,segmentCountBezier:a}=this,o=U(t,e,r,s,n,this.hasCurves(),i,a);o.spatialReference=this.spatialReference;const{vertexXY:u,vertexZ:h,vertexM:l}=this;if(o.vertexXY.set(u.subarray(0,2*e),0),o.vertexZ?.set(h.subarray(0,e),0),o.vertexM?.set(l.subarray(0,e),0),this.isMultipart()){const{partOffsets:t,partFlags:e}=this;o.partFlags.set(e.subarray(0,r+1)),o.partOffsets.set(t.subarray(0,r+1))}if(this.hasCurves()){const{segmentFlags:t,segmentIndices:r,segmentParams:s,segmentParamCount:n}=this;o.segmentFlags.set(t.subarray(0,e),0),o.segmentIndices.set(r.subarray(0,e),0),o.segmentParams.set(s.subarray(0,n),0)}return o}equals(t){return this.equalsWithinTolerance(t,0)}equalsWithinTolerance(t,e){if(null==t)return!1;if(this===t)return!0;if(!f(this.spatialReference,t.spatialReference))return!1;if(this.vertexCount!==t.vertexCount||this.partCount!==t.partCount)return!1;if(this.hasZ!==t.hasZ||this.hasM!==t.hasM)return!1;if(this.hasCurves()!==t.hasCurves()||this.segmentCountArc!==t.segmentCountArc||this.segmentCountBezier!==t.segmentCountBezier)return!1;const r=0===e?(t,e)=>t!==e||isNaN(t)!==isNaN(e):(t,r)=>Math.abs(t-r)>e||isNaN(t)!==isNaN(r);for(let s=0;s<this.vertexCount;++s)if(r(this.vertexXY[2*s],t.vertexXY[2*s])||r(this.vertexXY[2*s+1],t.vertexXY[2*s+1]))return!1;if(this.hasZ)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexZ[s],t.vertexZ[s]))return!1;if(this.hasM)for(let s=0;s<this.vertexCount;++s)if(r(this.vertexM[s],t.vertexM[s]))return!1;for(let s=0;s<this.partCount;++s)if(this.partFlags[s]!==t.partFlags[s]||this.partOffsets[s]!==t.partOffsets[s])return!1;if(this.hasCurves()){for(let e=0;e<this.vertexCount;++e)if(this.segmentFlags[e]!==t.segmentFlags[e]||this.segmentIndices[e]!==t.segmentIndices[e])return!1;for(let e=0;e<this.segmentParamCount;++e)if(r(this.segmentParams[e],t.segmentParams[e]))return!1}return!0}get parts(){return this.isMultipart()?new F(this):[][Symbol.iterator]()}}class F{constructor(t){this.geometry=t,this.value=new Z(t)}get done(){return this.value.index>=this.geometry.partCount}next(){return++this.value.index,this}[Symbol.iterator](){return this}}class Z{constructor(t){this.geometry=t,this.index=-1,this._readVertex=j(t),this._segments=new R(this)}get segments(){return this._segments.reset(),this._segments}get startVertex(){return this._readVertex(this.geometry.partOffsets[this.index])}get vertexCount(){const t=this.geometry.partOffsets;return t[this.index+1]-t[this.index]}}class R{constructor(t){this._part=t,this._partStart=0,this._partEnd=0,this._isPolygon="polygon"===t.geometry.type,this.value=new V(t.geometry)}get done(){return this.value.indexOfStartVertex>this._partEnd}next(){++this.value.indexOfStartVertex;const t=this.value.indexOfStartVertex>=this._partEnd;return this.value.indexOfEndVertex=t&&this._isPolygon?this._partStart:this.value.indexOfStartVertex+1,this}[Symbol.iterator](){return this}reset(){const{index:t}=this._part,e=this._part.geometry.partOffsets;this._partStart=e[t],this._partEnd=e[t+1]-(this._isPolygon?1:2),this.value.indexOfStartVertex=this._partStart-1}}class V{constructor(t){this.geometry=t,this.indexOfStartVertex=-1,this.indexOfEndVertex=-1,this._readVertex=j(t)}get xStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex]}get yStart(){return this.geometry.vertexXY[2*this.indexOfStartVertex+1]}get zStart(){return this.geometry.vertexZ[this.indexOfStartVertex]}get mStart(){return this.geometry.vertexM[this.indexOfStartVertex]}get xEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex]}get yEnd(){return this.geometry.vertexXY[2*this.indexOfEndVertex+1]}get zEnd(){return this.geometry.vertexZ[this.indexOfEndVertex]}get mEnd(){return this.geometry.vertexM[this.indexOfEndVertex]}get start(){return this._readVertex(this.indexOfStartVertex)}get end(){return this._readVertex(this.indexOfEndVertex)}get curve(){const t=this.geometry.segmentFlags?.[this.indexOfStartVertex]??1;if(1===t)return this.end;const e=this.geometry.segmentParams;let r=this.geometry.segmentIndices[this.indexOfStartVertex];if(2===t){const t=e[r++],s=e[r++],n=e[r++],i=e[r++];return{b:[this.end,[t,s],[n,i]]}}const s=e[r++],n=e[r++],i=e[r++],a=e[r++],o=e[r++],u=e[r++];r++,r++;const h=e[r++],l=e[r++];if(!Boolean(4&s)&&1===i)return{c:[this.end,[h,l]]};const c=2&s?0:1,g=1&s?0:1;return{a:[this.end,[o,u],c,g,a,n,i]}}}function Y(r){let s;const{vertexCount:n,vertexXY:i,vertexZ:o,vertexM:u}=r,h=k(r);if(r.hasCurves()){const n={stack:[],error:void 0,hasError:!1};try{t(n,new z(r,["vertexZ","vertexM"]),!1);const e=a();for(const t of r.parts){let r=t.startVertex;for(const{curve:s}of t.segments)x(e,r,s),r=v(s)}const[i,o,u,l]=e;s={xmin:i,ymin:o,xmax:u,ymax:l,spatialReference:h}}catch(l){n.error=l,n.hasError=!0}finally{e(n)}}else{let t,e,r,a;t=e=1/0,r=a=-1/0;for(let s=0;s<n;++s){const n=i[2*s],o=i[2*s+1];t=Math.min(t,n),r=Math.max(r,n),e=Math.min(e,o),a=Math.max(a,o)}s={xmin:t,ymin:e,xmax:r,ymax:a,spatialReference:h}}if(o){let t=1/0,e=-1/0;for(const r of o)t=Math.min(t,r),e=Math.max(e,r);s.zmin=t,s.zmax=e}if(u){let t=1/0,e=-1/0;for(const r of u)t=Math.min(t,r),e=Math.max(e,r);s.mmin=t,s.mmax=e}return s}function b(r,s){const n={stack:[],error:void 0,hasError:!1};try{s??=a();t(n,new z(r,["vertexZ","vertexM","spatialReference"]),!1);return o(s,Y(r)),s}catch(i){n.error=i,n.hasError=!0}finally{e(n)}}function w(r,s){const a={stack:[],error:void 0,hasError:!1};try{s??=n();t(a,new z(r,["vertexM","spatialReference"]),!1);return i(s,Y(r)),s}catch(o){a.error=o,a.hasError=!0}finally{e(a)}}function I(t){let e,r,s;if(u(t)){s="point";const{x:n,y:i,z:a,m:o}=t,u=[n,i];null!=a&&u.push(a),null!=o&&u.push(o),r=[[u]],e=1}else h(t)?(s="multipoint",r=[t.points],e=t.points.length):l(t)?(s="polyline",r=t.curvePaths??t.paths,e=r.reduce((t,e)=>t+e.length,0)):(s="polygon",r=t.curveRings??t.rings,e=r.reduce((t,e)=>(0===e.length||(t+=e.length,W(e[0],v(e.at(-1)))&&--t),t),0));const n=U(s,e,s.includes("point")?0:r.length,g(t),c(t),d(t)),{hasZ:i,hasM:a,vertexXY:o,vertexZ:f,vertexM:m}=n;function p(t){o[2*O]=t[0],o[2*O+1]=t[1],i&&(f[O]=t[2]),a&&(m[O]=t[x]),++O}n.spatialReference=t.spatialReference??void 0;const x=n.hasZ?3:2;let O=0;if(!n.isMultipart()){if(!i&&!a){for(const[t,e]of r[0])o[2*O]=t,o[2*O+1]=e,++O;return n}for(const t of r[0])p(t);return n}const S="polygon"===s,{partOffsets:P}=n;let _=0;if(!d(t)){for(const t of r){if(P[_++]=O,0===t.length)continue;let e=t.length;if(S&&W(t[0],t.at(-1))&&--e,i||a)for(let r=0;r<e;++r)p(t[r]);else for(let r=0;r<e;++r){const[e,s]=t[r];o[2*O]=e,o[2*O+1]=s,++O}}return P[_]=O,n}function A(t){const e=F+t;if(e<=(n.segmentParams?.length??0))return;let r=e*K;r=20*Math.ceil(r/20);const s=n.segmentParams;n.segmentParams=new Float64Array(r),null!=s&&n.segmentParams.set(s)}let F=0;for(const u of r){if(n.partOffsets[_++]=O,0===u.length)continue;const t=u[0];let e=t;for(let r=1;r<u.length;++r){const t=u[r];p(e);const s=O-1;y(t)?(A(10),++n.segmentCountArc,F=D(e,t,n,s,F),e=t.a[0]):C(t)?(A(10),++n.segmentCountArc,F=q(e,t,n,s,F),e=t.a[0]):M(t)?(A(10),++n.segmentCountArc,F=G(e,t,n,s,F),e=t.c[0]):E(t)?(A(4),++n.segmentCountBezier,F=H(e,t,n,s,F),e=t.b[0]):e=t}S&&W(t,e)||p(e)}return n.partOffsets[_]=O,n}function X(t){const e=j(t),{vertexCount:r,partCount:s,hasZ:n,hasM:i}=t,a=k(t);if("point"===t.type){const[e,r]=t.vertexXY,s=t.vertexZ?.[0],n=t.vertexM?.[0];return{x:e,y:r,z:s,m:n,spatialReference:a}}let o=0;if("multipoint"===t.type){const t=[];for(;o<r;)t.push(e(o++));return{points:t,spatialReference:a,hasZ:n,hasM:i}}const u="polygon"===t.type;if(!t.hasCurves()){const r=new Array;for(let n=0;n<s;++n){const s=t.partOffsets[n+1],i=new Array;for(;o<s;)i.push(e(o++));u&&i.length>0&&i.push(i[0]),r.push(i)}return u?{rings:r,hasZ:n,hasM:i,spatialReference:a}:{paths:r,hasZ:n,hasM:i,spatialReference:a}}const h=new Array;for(const{segments:l,startVertex:c}of t.parts){const t=[c];for(const{curve:e}of l)t.push(e);h.push(t)}return u?{rings:[],curveRings:h,hasZ:n,hasM:i,spatialReference:a}:{paths:[],curvePaths:h,hasZ:n,hasM:i,spatialReference:a}}function B(t,{lengths:e,coords:r,hasZ:s,hasM:n},i){const a=t.includes("point")?0:e.length,o="polygon"===t,u="point"===t?1:e.reduce((t,e)=>t+e,0)-(o?a:0);s??=!1,n??=!1;const h=U(t,u,a,s,n,!1,0,0);if(h.spatialReference=i??void 0,!h.isMultipart()){for(let t=0,e=0;t<u;++t)h.vertexXY[2*t]=r[e++],h.vertexXY[2*t+1]=r[e++],s&&(h.vertexZ[t]=r[e++]),n&&(h.vertexM[t]=r[e++]);return h}const l=2+Number(s)+Number(n);let c=0,g=0;h.partOffsets[0]=0;for(const f of e){const t=h.partOffsets[g],e=t+f-Number(o);h.partOffsets[++g]=e;for(let i=t;i<e;++i)h.vertexXY[2*i]=r[c++],h.vertexXY[2*i+1]=r[c++],s&&(h.vertexZ[i]=r[c++]),n&&(h.vertexM[i]=r[c++]);o&&(c+=l)}return h}function L({type:t,vertexCount:e,vertexXY:r,vertexZ:s,vertexM:n,partCount:i,partOffsets:a,hasZ:o,hasM:u}){const h=new _([],[],o,u);i=Math.max(i,1);const l="polygon"===t;let c=0;for(let g=0;g<i;++g){const t=a?.[g+1]??e,i=h.coords.length;for(let e=c;e<t;++e)h.coords.push(r[2*e],r[2*e+1]),o&&h.coords.push(s[e]),u&&h.coords.push(n[e]);if(l){const t=c;h.coords.push(r[2*t],r[2*t+1]),o&&h.coords.push(s[t]),u&&h.coords.push(n[t])}h.lengths.push((h.coords.length-i)/h.stride),c=t}return"point"===t&&(h.lengths.length=0),h}function N(t,e){return"getSpatialReference"in t&&(e=T(t.getSpatialReference()),t=t.getGeometry()),new A({...t.toFlatGeometry(),spatialReference:e})}function T(t){if(null==t)return;const e=t.getText()||void 0,r=t.isCustomWkid()?0:t.getOldID();if(r<=0)return{wkt:e};let s=t.getLatestID();(s<=0||s===r)&&(s=void 0);const n=t.getVCS();if(null==n)return{wkid:r,latestWkid:s,wkt:e};const i=n.isCustomWkid()?0:n.getOldID();if(i<=0)return{wkt:e};let a=t.getLatestVerticalID();return(a<=0||a===i)&&(a=void 0),{wkid:r,wkt:e,latestWkid:s,vcsWkid:i,latestVcsWkid:a}}class z{constructor(t,e){this.target=t,this.keys=e,this.oldValues=e.map(e=>t[e]);for(const r of e)t[r]=void 0}[Symbol.dispose](){this.keys.map((t,e)=>{this.target[t]=this.oldValues[e]})}}function k({spatialReference:t}){return t instanceof s?t.toJSON():t}function j({vertexXY:t,vertexZ:e,vertexM:r}){return e?r?s=>[t[2*s],t[2*s+1],e[s],r[s]]:r=>[t[2*r],t[2*r+1],e[r]]:r?e=>[t[2*e],t[2*e+1],r[e]]:e=>[t[2*e],t[2*e+1]]}function W(t,e){return t.every((t,r)=>t===e[r])}function U(t,e,r,s,n,i,a,o){a??=0,o??=0;const u=new A({type:t,vertexCount:e,vertexXY:null,vertexZ:void 0,vertexM:void 0,partCount:r,partOffsets:void 0,partFlags:void 0,segmentFlags:void 0,segmentIndices:void 0,segmentParams:void 0,segmentCountArc:a,segmentCountBezier:o});let h=2*Float64Array.BYTES_PER_ELEMENT*e;s&&(h+=Float64Array.BYTES_PER_ELEMENT*e),n&&(h+=Float64Array.BYTES_PER_ELEMENT*e),u.isMultipart()&&(h+=(r+1)*Int32Array.BYTES_PER_ELEMENT,h+=(r+1)*Int8Array.BYTES_PER_ELEMENT),i&&(h+=e*Int8Array.BYTES_PER_ELEMENT,h+=e*Int32Array.BYTES_PER_ELEMENT,h+=u.segmentParamCount*Float64Array.BYTES_PER_ELEMENT);const l=new ArrayBuffer(h);let c=0;return u.vertexXY=new Float64Array(l,c,2*e),c+=u.vertexXY.byteLength,s&&(u.vertexZ=new Float64Array(l,c,e),c+=u.vertexZ.byteLength),n&&(u.vertexM=new Float64Array(l,c,e),c+=u.vertexM.byteLength),i&&(u.segmentParams=new Float64Array(l,c,u.segmentParamCount),c+=u.segmentParams.byteLength,u.segmentIndices=new Int32Array(l,c,e),u.segmentIndices.fill(Q),c+=u.segmentIndices.byteLength),u.isMultipart()&&(u.partOffsets=new Int32Array(l,c,r+1),c+=u.partOffsets.byteLength,u.partFlags=new Int8Array(l,c,r+1),c+=u.partFlags.byteLength,"polygon"===u.type&&u.partFlags.subarray(0,r).fill(1)),i&&(u.segmentFlags=new Int8Array(l,c,e),u.segmentFlags.fill(1),c+=u.segmentFlags.byteLength),u}function D(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const[o,[u,h],l,c,g,f,m]=e.a;let p=4;c||(p|=1),l||(p|=2);const x=S(t,e),[v,d]=P(x,.5);return n[a++]=p,n[a++]=f,n[a++]=m,n[a++]=g,n[a++]=u,n[a++]=h,n[a++]=x.u2-x.u1,n[a++]=x.u1,n[a++]=v,n[a++]=d,a}function q(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;const o=O(t,e);return J(o,4,...m(o,.5),n,a)}function G(t,e,{segmentFlags:r,segmentIndices:s,segmentParams:n},i,a){r[i]=4,s[i]=a;return J(p(t,e),0,...e.c[1],n,a)}function J(t,e,r,s,n,i){const{cx:a,cy:o,thetaStart:u,thetaEnd:h,radius:l}=t;u>h||(e|=1);return Math.abs(h-u)<=Math.PI||(e|=2),n[i++]=e,n[i++]=l,n[i++]=1,n[i++]=0,n[i++]=a,n[i++]=o,n[i++]=h-u,n[i++]=u,n[i++]=r,n[i++]=s,i}function H(t,{b:[e,[r,s],[n,i]]},{segmentFlags:a,segmentIndices:o,segmentParams:u},h,l){return a[h]=2,o[h]=l,u[l++]=r,u[l++]=s,u[l++]=n,u[l++]=i,l}const K=1.61803,Q=-1;export{A as FlatGeometry,U as allocateFlatGeometry,X as convertFlatToGeometryJSON,L as convertFlatToOptimizedGeometry,I as convertGeometryToFlat,N as convertGeometryxToFlat,B as convertOptimizedGeometryToFlat,w as getBoundingBox,b as getBoundingRect,Y as getExtentJSON,H as writeBezierCurveSegment,G as writeCircularArcSegment,q as writeEllipticArc4Segment,D as writeEllipticArc7Segment};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{deprecatedModule as e}from"../core/deprecate.js";import n from"../core/Logger.js";import{ensureClass as r}from"../core/accessorSupport/ensureType.js";import{assertNotMesh as t}from"./asserts.js";import{G as o}from"../chunks/geometryEngineBase.js";import i from"./SpatialReference.js";import{hydratedAdapter as u}from"./geometryAdapters/hydrated.js";function c(e){const n=Array.isArray(e)?e[0].spatialReference:e.spatialReference;return n?r(i,n):i.WGS84}function f(e){return o.extendedSpatialReferenceInfo(e)}function s(e,n){return t(e),o.clip(u,c(e),e,n)}function a(e,n){return t(e),o.cut(u,c(e),e,n)}function l(e,n){return t(e),t(n),o.contains(u,c(e),e,n)}function p(e,n){return t(e),t(n),o.crosses(u,c(e),e,n)}function m(e,n,r){return t(e),t(n),o.distance(u,c(e),e,n,r)}function g(e,n){return t(e),t(n),o.equals(u,c(e),e,n)}function d(e,n){return t(e),t(n),o.intersects(u,c(e),e,n)}function h(e,n){return t(e),t(n),o.touches(u,c(e),e,n)}function w(e,n){return t(e),t(n),o.within(u,c(e),e,n)}function y(e,n){return t(e),t(n),o.disjoint(u,c(e),e,n)}function R(e,n){return t(e),t(n),o.overlaps(u,c(e),e,n)}function x(e,n,r){return t(e),t(n),o.relate(u,c(e),e,n,r)}function S(e){return t(e),o.isSimple(u,c(e),e)}function j(e){return t(e),o.simplify(u,c(e),e)}function A(e,n=!1){return o.convexHull(u,c(e),e,n)}function E(e,n){return t(n),o.difference(u,c(e),e,n)}function L(e,n){return t(n),o.symmetricDifference(u,c(e),e,n)}function T(e,n){return t(n),o.intersect(u,c(e),e,n)}function D(e){return o.union(u,c(e),e)}function O(e,n,r,t,i,f){return o.offset(u,c(e),e,n,r,t,i,f)}function v(e,n,r,t=!1){return o.buffer(u,c(e),e,n,r,t)}function G(e,n,r,t,i,f){return o.geodesicBuffer(u,c(e),e,n,r,t,i,f)}function J(e,n,r=!0){return t(e),o.nearestCoordinate(u,c(e),e,n,r)}function N(e,n){return t(e),o.nearestVertex(u,c(e),e,n)}function V(e,n,r,i){return t(e),o.nearestVertices(u,c(e),e,n,r,i)}function z(e){return"xmin"in e?"center"in e?e.center:null:"x"in e?e:"extent"in e?e.extent?.center??null:null}function B(e,n,r){if(null==e)throw new U;const t=e.spatialReference;if(null==(r=r??z(e)))throw new U;const i=e.constructor.fromJSON(o.rotate(e,n,r));return i.spatialReference=t,i}function H(e,n){if(null==e)throw new U;const r=e.spatialReference;if(null==(n=n??z(e)))throw new U;const t=e.constructor.fromJSON(o.flipHorizontal(e,n));return t.spatialReference=r,t}function I(e,n){if(null==e)throw new U;const r=e.spatialReference;if(null==(n=n??z(e)))throw new U;const t=e.constructor.fromJSON(o.flipVertical(e,n));return t.spatialReference=r,t}function P(e,n,r,i){return t(e),o.generalize(u,c(e),e,n,r,i)}function b(e,n,r){return t(e),o.densify(u,c(e),e,n,r)}function k(e,n,r,i=0){return t(e),o.geodesicDensify(u,c(e),e,n,r,i)}function q(e,n){return t(e),o.planarArea(u,c(e),e,n)}function C(e,n){return t(e),o.planarLength(u,c(e),e,n)}function W(e,n,r){return t(e),o.geodesicArea(u,c(e),e,n,r)}function F(e,n,r){return t(e),o.geodesicLength(u,c(e),e,n,r)}function K(e,n){return o.intersectLinesToPoints(u,c(e),e,n)}function M(e,n){o.changeDefaultSpatialReferenceTolerance(e,n)}function Q(e){o.clearDefaultSpatialReferenceTolerance(e)}e(n.getLogger("esri.geometry.geometryEngine"),"esri.geometry.geometryEngine",{see:"https://arcg.is/1PiGTm1",version:"4.32",warnOnce:!0});class U extends Error{constructor(){super("Illegal Argument Exception")}}export{v as buffer,M as changeDefaultSpatialReferenceTolerance,Q as clearDefaultSpatialReferenceTolerance,s as clip,l as contains,A as convexHull,p as crosses,a as cut,b as densify,E as difference,y as disjoint,m as distance,g as equals,f as extendedSpatialReferenceInfo,H as flipHorizontal,I as flipVertical,P as generalize,W as geodesicArea,G as geodesicBuffer,k as geodesicDensify,F as geodesicLength,T as intersect,K as intersectLinesToPoints,d as intersects,S as isSimple,J as nearestCoordinate,N as nearestVertex,V as nearestVertices,O as offset,R as overlaps,q as planarArea,C as planarLength,x as relate,B as rotate,j as simplify,L as symmetricDifference,h as touches,D as union,w as within};
2
+ import{deprecatedModule as e}from"../core/deprecate.js";import n from"../core/Logger.js";import{ensureClass as r}from"../core/accessorSupport/ensureType.js";import{assertNotMesh as t}from"./asserts.js";import{g as o}from"../chunks/geometryEngineBase.js";import i from"./SpatialReference.js";import{hydratedAdapter as u}from"./geometryAdapters/hydrated.js";function c(e){const n=Array.isArray(e)?e[0].spatialReference:e.spatialReference;return n?r(i,n):i.WGS84}function f(e){return o.extendedSpatialReferenceInfo(e)}function s(e,n){return t(e),o.clip(u,c(e),e,n)}function a(e,n){return t(e),o.cut(u,c(e),e,n)}function l(e,n){return t(e),t(n),o.contains(u,c(e),e,n)}function p(e,n){return t(e),t(n),o.crosses(u,c(e),e,n)}function m(e,n,r){return t(e),t(n),o.distance(u,c(e),e,n,r)}function g(e,n){return t(e),t(n),o.equals(u,c(e),e,n)}function d(e,n){return t(e),t(n),o.intersects(u,c(e),e,n)}function h(e,n){return t(e),t(n),o.touches(u,c(e),e,n)}function w(e,n){return t(e),t(n),o.within(u,c(e),e,n)}function y(e,n){return t(e),t(n),o.disjoint(u,c(e),e,n)}function R(e,n){return t(e),t(n),o.overlaps(u,c(e),e,n)}function x(e,n,r){return t(e),t(n),o.relate(u,c(e),e,n,r)}function S(e){return t(e),o.isSimple(u,c(e),e)}function j(e){return t(e),o.simplify(u,c(e),e)}function A(e,n=!1){return o.convexHull(u,c(e),e,n)}function E(e,n){return t(n),o.difference(u,c(e),e,n)}function L(e,n){return t(n),o.symmetricDifference(u,c(e),e,n)}function T(e,n){return t(n),o.intersect(u,c(e),e,n)}function D(e){return o.union(u,c(e),e)}function O(e,n,r,t,i,f){return o.offset(u,c(e),e,n,r,t,i,f)}function v(e,n,r,t=!1){return o.buffer(u,c(e),e,n,r,t)}function J(e,n,r,t,i,f){return o.geodesicBuffer(u,c(e),e,n,r,t,i,f)}function N(e,n,r=!0){return t(e),o.nearestCoordinate(u,c(e),e,n,r)}function V(e,n){return t(e),o.nearestVertex(u,c(e),e,n)}function z(e,n,r,i){return t(e),o.nearestVertices(u,c(e),e,n,r,i)}function B(e){return"xmin"in e?"center"in e?e.center:null:"x"in e?e:"extent"in e?e.extent?.center??null:null}function G(e,n,r){if(null==e)throw new U;const t=e.spatialReference;if(null==(r=r??B(e)))throw new U;const i=e.constructor.fromJSON(o.rotate(e,n,r));return i.spatialReference=t,i}function H(e,n){if(null==e)throw new U;const r=e.spatialReference;if(null==(n=n??B(e)))throw new U;const t=e.constructor.fromJSON(o.flipHorizontal(e,n));return t.spatialReference=r,t}function I(e,n){if(null==e)throw new U;const r=e.spatialReference;if(null==(n=n??B(e)))throw new U;const t=e.constructor.fromJSON(o.flipVertical(e,n));return t.spatialReference=r,t}function P(e,n,r,i){return t(e),o.generalize(u,c(e),e,n,r,i)}function b(e,n,r){return t(e),o.densify(u,c(e),e,n,r)}function k(e,n,r,i=0){return t(e),o.geodesicDensify(u,c(e),e,n,r,i)}function q(e,n){return t(e),o.planarArea(u,c(e),e,n)}function C(e,n){return t(e),o.planarLength(u,c(e),e,n)}function W(e,n,r){return t(e),o.geodesicArea(u,c(e),e,n,r)}function F(e,n,r){return t(e),o.geodesicLength(u,c(e),e,n,r)}function K(e,n){return o.intersectLinesToPoints(u,c(e),e,n)}function M(e,n){o.changeDefaultSpatialReferenceTolerance(e,n)}function Q(e){o.clearDefaultSpatialReferenceTolerance(e)}e(n.getLogger("esri.geometry.geometryEngine"),"esri.geometry.geometryEngine",{see:"https://arcg.is/1PiGTm1",version:"4.32",warnOnce:!0});class U extends Error{constructor(){super("Illegal Argument Exception")}}export{v as buffer,M as changeDefaultSpatialReferenceTolerance,Q as clearDefaultSpatialReferenceTolerance,s as clip,l as contains,A as convexHull,p as crosses,a as cut,b as densify,E as difference,y as disjoint,m as distance,g as equals,f as extendedSpatialReferenceInfo,H as flipHorizontal,I as flipVertical,P as generalize,W as geodesicArea,J as geodesicBuffer,k as geodesicDensify,F as geodesicLength,T as intersect,K as intersectLinesToPoints,d as intersects,S as isSimple,N as nearestCoordinate,V as nearestVertex,z as nearestVertices,O as offset,R as overlaps,q as planarArea,C as planarLength,x as relate,G as rotate,j as simplify,L as symmetricDifference,h as touches,D as union,w as within};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{G as n}from"../chunks/geometryEngineBase.js";import{jsonAdapter as e}from"./geometryAdapters/json.js";function r(e){return n.extendedSpatialReferenceInfo(e)}function t(r,t,u){return n.clip(e,r,t,u)}function u(r,t,u){return n.cut(e,r,t,u)}function i(r,t,u){return n.contains(e,r,t,u)}function o(r,t,u){return n.crosses(e,r,t,u)}function c(r,t,u,i){return n.distance(e,r,t,u,i)}function f(r,t,u){return n.equals(e,r,t,u)}function l(r,t,u){return n.intersects(e,r,t,u)}function a(r,t,u){return n.touches(e,r,t,u)}function s(r,t,u){return n.within(e,r,t,u)}function p(r,t,u){return n.disjoint(e,r,t,u)}function g(r,t,u){return n.overlaps(e,r,t,u)}function m(r,t,u,i){return n.relate(e,r,t,u,i)}function d(r,t){return n.isSimple(e,r,t)}function h(r,t){return n.simplify(e,r,t)}function w(r,t,u=!1){return n.convexHull(e,r,t,u)}function x(r,t,u){return n.difference(e,r,t,u)}function E(r,t,u){return n.symmetricDifference(e,r,t,u)}function y(r,t,u){return n.intersect(e,r,t,u)}function A(r,t,u=null){return n.union(e,r,t,u)}function R(r,t,u,i,o,c,f){return n.offset(e,r,t,u,i,o,c,f)}function j(r,t,u,i,o=!1){return n.buffer(e,r,t,u,i,o)}function D(r,t,u,i,o,c,f){return n.geodesicBuffer(e,r,t,u,i,o,c,f)}function I(r,t,u,i=!0){return n.nearestCoordinate(e,r,t,u,i)}function S(r,t,u){return n.nearestVertex(e,r,t,u)}function L(r,t,u,i,o){return n.nearestVertices(e,r,t,u,i,o)}function T(e,r,t,u){if(null==r||null==u)throw new Error("Illegal Argument Exception");const i=n.rotate(r,t,u);return i.spatialReference=e,i}function V(e,r,t){if(null==r||null==t)throw new Error("Illegal Argument Exception");const u=n.flipHorizontal(r,t);return u.spatialReference=e,u}function v(e,r,t){if(null==r||null==t)throw new Error("Illegal Argument Exception");const u=n.flipVertical(r,t);return u.spatialReference=e,u}function z(r,t,u,i,o){return n.generalize(e,r,t,u,i,o)}function B(r,t,u,i){return n.densify(e,r,t,u,i)}function H(r,t,u,i,o=0){return n.geodesicDensify(e,r,t,u,i,o)}function b(r,t,u){return n.planarArea(e,r,t,u)}function k(r,t,u){return n.planarLength(e,r,t,u)}function q(r,t,u,i){return n.geodesicArea(e,r,t,u,i)}function C(r,t,u,i){return n.geodesicLength(e,r,t,u,i)}function G(r,t,u){return null==t||null==u?[]:n.intersectLinesToPoints(e,r,t,u)}function P(e,r){n.changeDefaultSpatialReferenceTolerance(e,r)}function F(e){n.clearDefaultSpatialReferenceTolerance(e)}export{j as buffer,P as changeDefaultSpatialReferenceTolerance,F as clearDefaultSpatialReferenceTolerance,t as clip,i as contains,w as convexHull,o as crosses,u as cut,B as densify,x as difference,p as disjoint,c as distance,f as equals,r as extendedSpatialReferenceInfo,V as flipHorizontal,v as flipVertical,z as generalize,q as geodesicArea,D as geodesicBuffer,H as geodesicDensify,C as geodesicLength,y as intersect,G as intersectLinesToPoints,l as intersects,d as isSimple,I as nearestCoordinate,S as nearestVertex,L as nearestVertices,R as offset,g as overlaps,b as planarArea,k as planarLength,m as relate,T as rotate,h as simplify,E as symmetricDifference,a as touches,A as union,s as within};
2
+ import{g as n}from"../chunks/geometryEngineBase.js";import{jsonAdapter as e}from"./geometryAdapters/json.js";function r(e){return n.extendedSpatialReferenceInfo(e)}function t(r,t,u){return n.clip(e,r,t,u)}function u(r,t,u){return n.cut(e,r,t,u)}function i(r,t,u){return n.contains(e,r,t,u)}function o(r,t,u){return n.crosses(e,r,t,u)}function c(r,t,u,i){return n.distance(e,r,t,u,i)}function f(r,t,u){return n.equals(e,r,t,u)}function l(r,t,u){return n.intersects(e,r,t,u)}function a(r,t,u){return n.touches(e,r,t,u)}function s(r,t,u){return n.within(e,r,t,u)}function p(r,t,u){return n.disjoint(e,r,t,u)}function g(r,t,u){return n.overlaps(e,r,t,u)}function m(r,t,u,i){return n.relate(e,r,t,u,i)}function d(r,t){return n.isSimple(e,r,t)}function h(r,t){return n.simplify(e,r,t)}function w(r,t,u=!1){return n.convexHull(e,r,t,u)}function x(r,t,u){return n.difference(e,r,t,u)}function E(r,t,u){return n.symmetricDifference(e,r,t,u)}function y(r,t,u){return n.intersect(e,r,t,u)}function A(r,t,u=null){return n.union(e,r,t,u)}function R(r,t,u,i,o,c,f){return n.offset(e,r,t,u,i,o,c,f)}function j(r,t,u,i,o=!1){return n.buffer(e,r,t,u,i,o)}function D(r,t,u,i,o,c,f){return n.geodesicBuffer(e,r,t,u,i,o,c,f)}function I(r,t,u,i=!0){return n.nearestCoordinate(e,r,t,u,i)}function S(r,t,u){return n.nearestVertex(e,r,t,u)}function L(r,t,u,i,o){return n.nearestVertices(e,r,t,u,i,o)}function T(e,r,t,u){if(null==r||null==u)throw new Error("Illegal Argument Exception");const i=n.rotate(r,t,u);return i.spatialReference=e,i}function V(e,r,t){if(null==r||null==t)throw new Error("Illegal Argument Exception");const u=n.flipHorizontal(r,t);return u.spatialReference=e,u}function v(e,r,t){if(null==r||null==t)throw new Error("Illegal Argument Exception");const u=n.flipVertical(r,t);return u.spatialReference=e,u}function z(r,t,u,i,o){return n.generalize(e,r,t,u,i,o)}function B(r,t,u,i){return n.densify(e,r,t,u,i)}function H(r,t,u,i,o=0){return n.geodesicDensify(e,r,t,u,i,o)}function b(r,t,u){return n.planarArea(e,r,t,u)}function k(r,t,u){return n.planarLength(e,r,t,u)}function q(r,t,u,i){return n.geodesicArea(e,r,t,u,i)}function C(r,t,u,i){return n.geodesicLength(e,r,t,u,i)}function P(r,t,u){return null==t||null==u?[]:n.intersectLinesToPoints(e,r,t,u)}function F(e,r){n.changeDefaultSpatialReferenceTolerance(e,r)}function G(e){n.clearDefaultSpatialReferenceTolerance(e)}export{j as buffer,F as changeDefaultSpatialReferenceTolerance,G as clearDefaultSpatialReferenceTolerance,t as clip,i as contains,w as convexHull,o as crosses,u as cut,B as densify,x as difference,p as disjoint,c as distance,f as equals,r as extendedSpatialReferenceInfo,V as flipHorizontal,v as flipVertical,z as generalize,q as geodesicArea,D as geodesicBuffer,H as geodesicDensify,C as geodesicLength,y as intersect,P as intersectLinesToPoints,l as intersects,d as isSimple,I as nearestCoordinate,S as nearestVertex,L as nearestVertices,R as offset,g as overlaps,b as planarArea,k as planarLength,m as relate,T as rotate,h as simplify,E as symmetricDifference,a as touches,A as union,s as within};
@@ -21,10 +21,11 @@
21
21
  * >
22
22
  * > **Known Limitations**
23
23
  * >
24
- * > This operator currently only supports [equation-based geographic transformations](https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/geographic-coordinate-system-transformation.htm).
25
- * > The result geometry is not guaranteed to be simple. Apply the [simplifyOperator](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/simplifyOperator/) to ensure the result is topologically simple.
26
- * > Projecting an Extent may return an Extent with a larger area than the input.
27
- * > Vertical coordinate system projections are not supported.
24
+ * > * This operator currently only supports [equation-based geographic transformations](https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/geographic-coordinate-system-transformation.htm).
25
+ * > * Grid-based transformations are not supported.
26
+ * > * The result geometry is not guaranteed to be simple. Apply the [simplifyOperator](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/simplifyOperator/) to ensure the result is topologically simple.
27
+ * > * Projecting an Extent may return an Extent with a larger area than the input.
28
+ * > * Vertical coordinate system projections are not supported.
28
29
  *
29
30
  * > [!WARNING]
30
31
  * >
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{execute as o,executeMany as e,load as r,supportsCurves as t,isLoaded as n}from"./gx/operatorProject.js";import{applyZConversionAfterProjection as a}from"./support/projectionZScaling.js";let s,i,p,c,m,u;function f(){return!!s&&n()}async function l(){if(!f()){const[o,e]=await Promise.all([import("./support/apiConverter.js"),import("./support/projectionTransformation.js"),r()]);s=o.fromGeometry,i=o.fromSpatialReference,p=o.getSpatialReference,c=o.toGeometry,m=e.createProjectionTransformation,u=t()}}function j(e,r,t){const n=p(e),u=m(i(n),i(r),t),f=c(o(s(e),u),r);return!t?.zConversionDisabled&&f?.hasZ&&a([f],n,r),f}function d(o,r,t){const n=o.map(s),u=p(o),f=m(i(u),i(r),t),l=e(n,f).map(o=>c(o,r));return!t?.zConversionDisabled&&l&&a(l,u,r),l}export{j as execute,d as executeMany,f as isLoaded,l as load,u as supportsCurves};
2
+ import{load as o,supportsCurves as e,execute as r,executeMany as t,isLoaded as n}from"./gx/operatorProject.js";import{applyZConversionAfterProjection as a}from"./support/projectionZScaling.js";let s,i,p,c,m,u;function f(){return!!s&&n()}async function l(){if(!f()){const[r,t]=await Promise.all([import("./support/apiConverter.js"),import("./support/projectionTransformation.js"),o()]);s=r.fromGeometry,i=r.fromSpatialReference,p=r.getSpatialReference,c=r.toGeometry,m=t.createProjectionTransformation,u=e()}}function j(o,e,t){const n=p(o),u=m(i(n),i(e),t),f=c(r(s(o),u),e);return!t?.zConversionDisabled&&f?.hasZ&&a([f],n,e),f}function d(o,e,r){const n=o.map(s),u=p(o),f=m(i(u),i(e),r),l=t(n,f).map(o=>c(o,e));return!r?.zConversionDisabled&&l&&a(l,u,e),l}export{j as execute,d as executeMany,f as isLoaded,l as load,u as supportsCurves};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../core/Error.js";import{memoize as e}from"../../../core/memoize.js";import{fromJSON as s}from"../jsonUtils.js";import{interpolateCubicBezier as n}from"./bezierCurveUtils.js";import{deriveCircleFromCircularArc as i}from"./circularArcUtils.js";import{isCurvedGeometry as r,hasUnsupportedCurve as a,getCurves as o,getEndpoint as c,isCoordinate as h,isBezierCurve as u,isCircularArc as p,isEllipticArc4 as l,isEllipticArc7 as m,cloneCurve as d}from"./curveUtils.js";import{deriveCircleFromEllipticArc4 as f}from"./ellipticArc4Utils.js";import{deriveEllipse as S,interpolateEllipse as v}from"./ellipticArc7Utils.js";import{interpolateSegment as E,pointToSegmentDistance2 as g,distance2 as x}from"./mathUtils.js";const M={maxSegmentLength:0,maxDeviation:0,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1},P=100,k=1e-6,C=[0,0];function _(t){return{maxSegmentLength:t.maxSegmentLength??M.maxSegmentLength,maxDeviation:t.maxDeviation??M.maxDeviation,maxSegmentsPerCurve:t.maxSegmentsPerCurve??M.maxSegmentsPerCurve,minSegmentsPerCurve:Math.max(t.minSegmentsPerCurve??M.minSegmentsPerCurve,1)}}class y{constructor(t,e){this.curveStart=t,this.curveEnd=e,this.tStart=0,this.tEnd=0,this.tEndStack=[],this.arcEndStack=[]}get stackSize(){return this.tEndStack.length}initialize(t,e){this.tStart=0,this.arcStart=t,this.tEndStack.push(1),this.arcEndStack.push(e)}splitAt(t){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(t),this.arcEndStack.push(this.interpolate(t))}splitInHalf(){return this.splitAt((this.tStart+this.tEnd)/2)}pop(){this.tEnd=this.tEndStack.pop(),this.arcEnd=this.arcEndStack.pop()}next(){this.tStart=this.tEnd,this.arcStart=this.arcEnd}densify(t,{maxDeviation:e,maxSegmentLength:s,maxSegmentsPerCurve:n,minSegmentsPerCurve:i}){const r=s*s,a=e*e,o=1/n,c=this.interpolate(0),h=this.interpolate(1);x(this.curveStart,c)>k&&t.push(c),this.initialize(c,h);const u=1/i;for(let p=i-1;p>0;p--){const t=p*u;this.pop(),this.splitAt(t)}for(;this.stackSize>0;)this.pop(),this.tStart===this.tEnd||this.tEnd-this.tStart<o||(0===r||!isFinite(r)||x(this.arcStart,this.arcEnd)<r)&&(0===a||!isFinite(a)||this.getDeviation2()<a)?(t.push(this.arcEnd),this.next()):this.splitInHalf();return x(this.curveEnd,h)>k&&t.push([...this.curveEnd]),t}}class R extends y{constructor(t,e){const[s,n,i]=e.b;super(t,s),this._controlPointsStack=[],this._curveControlPoints=[n,i],this._arcControlPoints=[n,i],this._controlPointsStack.push(this._arcControlPoints)}splitAt(t){const{arcStart:e,arcEnd:s,tStart:n,tEnd:i}=this,[r,a]=this._arcControlPoints,o=(t-n)/(i-n),c=E([],e,r,o),h=E(C,r,a,o),u=E([],a,s,o),p=E([],c,h,o),l=E([],h,u,o),m=E([],p,l,o);this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this._controlPointsStack.push([l,u]),this.tEndStack.push(t),this.arcEndStack.push(m),this._arcControlPoints[0]=c,this._arcControlPoints[1]=p,this._controlPointsStack.push(this._arcControlPoints)}pop(){super.pop(),this._arcControlPoints=this._controlPointsStack.pop()}interpolate(t){const{curveStart:e,curveEnd:s}=this,[i,r]=this._curveControlPoints;return n(e,i,r,s,t)}getDeviation2(){const{arcStart:t,arcEnd:e}=this,[s,n]=this._arcControlPoints;return Math.max(g(s,t,e),g(n,t,e))}}class w extends y{constructor(t,e){const[s]=e.a;super(t,s),this._derivedEllipse=S(t,e)}pop(){super.pop(),this._tMid=(this.tStart+this.tEnd)/2,this._arcMid=this.interpolate(this._tMid)}splitInHalf(){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(this._tMid),this.arcEndStack.push(this._arcMid)}interpolate(t){return v(this._derivedEllipse,t)}getDeviation2(){return g(this._arcMid,this.arcStart,this.arcEnd)}}function b(t,e,s,{cx:n,cy:i,radius:r,thetaStart:a,thetaEnd:o,isInvalid:c},{maxDeviation:h,maxSegmentLength:u,maxSegmentsPerCurve:p,minSegmentsPerCurve:l}){if(c)return t.push([...s]),t;const m=2*r,d=[n+r*Math.cos(a),i+r*Math.sin(a)],f=[n+r*Math.cos(o),i+r*Math.sin(o)];x(e,d)>k&&t.push(d);const S=Math.abs(o-a),v=u>0&&u<m?2*Math.asin(u/m):S,E=h>0&&h<=r?2*Math.acos(1-h/r):S,g=Math.min(v,E),M=Math.min(p,Math.max(l,Math.ceil(Math.abs(S/g)))),P=1/M;for(let x=1;x<M;x++){const e=x*P,s=a*(1-e)+o*e;t.push([n+r*Math.cos(s),i+r*Math.sin(s)])}return t.push(f),x(s,f)>k&&t.push([...s]),t}function j(t,e,s,n){return new R(e,s).densify(t,n)}function Z(t,e,s,n){const r=i(e,s),[a]=s.c;return b(t,e,a,r,n)}function D(t,e,s,n){const i=f(e,s),[r]=s.a;return b(t,e,r,i,n)}function z(t,e,s,n){const[i,r,a,o,c,h,u]=s.a;return 0===h||0===u?(t.push([...i]),t):new w(e,s).densify(t,n)}function A(t,e,s,n){return h(s)?(t.push([...s]),t):u(s)?j(t,e,s,n):p(s)?Z(t,e,s,n):l(s)?D(t,e,s,n):z(t,e,s,n)}function L(t,e={}){if(!r(t))return t;const s=_(e),n=o(t),i=[];for(const r of n){const t=[];for(let e=0;e<r.length-1;e++){const n=e+1,i=[...c(r[e])];0===e&&t.push(i);A(t,i,r[n],s)}i.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},paths:i,spatialReference:t.spatialReference}:{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},rings:i,spatialReference:t.spatialReference}}const U=e(t=>({maxDeviation:0,maxSegmentLength:t*P,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1}));function T(t,e,s){if(!r(t))return t;const n=new Set(e),i=_(s),a=o(t),f=[];let S=!1;for(const r of a){const t=[];for(let e=0;e<r.length-1;e++){const s=e+1,a=[...c(r[e])];0===e&&t.push(a);const o=r[s];h(o)?t.push([...o]):u(o)&&!n.has("cubic-bezier")?j(t,a,o,i):p(o)&&!n.has("circular-arc")?Z(t,a,o,i):l(o)&&!n.has("elliptic-arc")?D(t,a,o,i):m(o)&&!n.has("elliptic-arc")?z(t,a,o,i):(t.push(d(o)),S=!0)}f.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},spatialReference:t.spatialReference,...S?{curvePaths:f}:{paths:f}}:{hasZ:t.hasZ,hasM:t.hasM,spatialReference:t.spatialReference,...S?{curveRings:f}:{rings:f}}}async function I(t,e,n){const i=new Set(e);return await J(t,i,n),t.map(t=>{if(!t||!r(t))return t;const n=t.spatialReference.xyTolerance;if(null==n)return t;const i=U(n);return s(T(t,e,i))})}async function J(e,s,n){let i=null;for(const o of e)if(o&&r(o)&&null==o.spatialReference.xyTolerance&&a(o,s)){const e=o.spatialReference;if(!e)throw new t("geometry:missing-spatial-reference","Geometry contains an unsupported curve type, but it cannot be densified because it has no spatial reference.");const s=N(e);if(n.has(s))o.spatialReference=n.get(s);else{i||(i=await import("../../operators/support/apiConverter.js"));const r=i.fromSpatialReference(e),a=r?.getTolerance();if(null==a)throw new t("geometry:missing-tolerance","Geometry contains an unsupported curve type, but it cannot be densified because the tolerance of its spatial reference is unknown. Set the `xyTolerance` property of the spatial reference.");const c=o.spatialReference.clone();c.read({xyTolerance:a}),o.spatialReference=c,n.set(s,c)}}}function N(t){if(null!=t.wkid)return`${t.wkid}`;if(null!=t.wkt)return t.wkt;const e="toJSON"in t&&"function"==typeof t.toJSON?t.toJSON():t;return JSON.stringify(e)}export{L as densifyCurvedGeometry,I as densifyUnsupportedCurves,U as getAutoDensifyOptions,N as getCacheKey,T as selectiveDensifyCurvedGeometryJSON};
2
+ import t from"../../../core/Error.js";import{memoize as e}from"../../../core/memoize.js";import{fromJSON as s}from"../jsonUtils.js";import{interpolateCubicBezier as n}from"./bezierCurveUtils.js";import{deriveCircleFromCircularArc as i}from"./circularArcUtils.js";import{isCurvedGeometry as r,getCurves as a,getEndpoint as o,isCoordinate as c,isBezierCurve as h,isCircularArc as u,isEllipticArc4 as p,hasUnsupportedCurve as l,isEllipticArc7 as m,cloneCurve as d}from"./curveUtils.js";import{deriveCircleFromEllipticArc4 as f}from"./ellipticArc4Utils.js";import{deriveEllipse as S,interpolateEllipse as v}from"./ellipticArc7Utils.js";import{interpolateSegment as E,pointToSegmentDistance2 as g,distance2 as x}from"./mathUtils.js";const M={maxSegmentLength:0,maxDeviation:0,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1},P=100,k=1e-6,C=[0,0];function _(t){return{maxSegmentLength:t.maxSegmentLength??M.maxSegmentLength,maxDeviation:t.maxDeviation??M.maxDeviation,maxSegmentsPerCurve:t.maxSegmentsPerCurve??M.maxSegmentsPerCurve,minSegmentsPerCurve:Math.max(t.minSegmentsPerCurve??M.minSegmentsPerCurve,1)}}class y{constructor(t,e){this.curveStart=t,this.curveEnd=e,this.tStart=0,this.tEnd=0,this.tEndStack=[],this.arcEndStack=[]}get stackSize(){return this.tEndStack.length}initialize(t,e){this.tStart=0,this.arcStart=t,this.tEndStack.push(1),this.arcEndStack.push(e)}splitAt(t){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(t),this.arcEndStack.push(this.interpolate(t))}splitInHalf(){return this.splitAt((this.tStart+this.tEnd)/2)}pop(){this.tEnd=this.tEndStack.pop(),this.arcEnd=this.arcEndStack.pop()}next(){this.tStart=this.tEnd,this.arcStart=this.arcEnd}densify(t,{maxDeviation:e,maxSegmentLength:s,maxSegmentsPerCurve:n,minSegmentsPerCurve:i}){const r=s*s,a=e*e,o=1/n,c=this.interpolate(0),h=this.interpolate(1);x(this.curveStart,c)>k&&t.push(c),this.initialize(c,h);const u=1/i;for(let p=i-1;p>0;p--){const t=p*u;this.pop(),this.splitAt(t)}for(;this.stackSize>0;)this.pop(),this.tStart===this.tEnd||this.tEnd-this.tStart<o||(0===r||!isFinite(r)||x(this.arcStart,this.arcEnd)<r)&&(0===a||!isFinite(a)||this.getDeviation2()<a)?(t.push(this.arcEnd),this.next()):this.splitInHalf();return x(this.curveEnd,h)>k&&t.push([...this.curveEnd]),t}}class R extends y{constructor(t,e){const[s,n,i]=e.b;super(t,s),this._controlPointsStack=[],this._curveControlPoints=[n,i],this._arcControlPoints=[n,i],this._controlPointsStack.push(this._arcControlPoints)}splitAt(t){const{arcStart:e,arcEnd:s,tStart:n,tEnd:i}=this,[r,a]=this._arcControlPoints,o=(t-n)/(i-n),c=E([],e,r,o),h=E(C,r,a,o),u=E([],a,s,o),p=E([],c,h,o),l=E([],h,u,o),m=E([],p,l,o);this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this._controlPointsStack.push([l,u]),this.tEndStack.push(t),this.arcEndStack.push(m),this._arcControlPoints[0]=c,this._arcControlPoints[1]=p,this._controlPointsStack.push(this._arcControlPoints)}pop(){super.pop(),this._arcControlPoints=this._controlPointsStack.pop()}interpolate(t){const{curveStart:e,curveEnd:s}=this,[i,r]=this._curveControlPoints;return n(e,i,r,s,t)}getDeviation2(){const{arcStart:t,arcEnd:e}=this,[s,n]=this._arcControlPoints;return Math.max(g(s,t,e),g(n,t,e))}}class w extends y{constructor(t,e){const[s]=e.a;super(t,s),this._derivedEllipse=S(t,e)}pop(){super.pop(),this._tMid=(this.tStart+this.tEnd)/2,this._arcMid=this.interpolate(this._tMid)}splitInHalf(){this.tEndStack.push(this.tEnd),this.arcEndStack.push(this.arcEnd),this.tEndStack.push(this._tMid),this.arcEndStack.push(this._arcMid)}interpolate(t){return v(this._derivedEllipse,t)}getDeviation2(){return g(this._arcMid,this.arcStart,this.arcEnd)}}function b(t,e,s,{cx:n,cy:i,radius:r,thetaStart:a,thetaEnd:o,isInvalid:c},{maxDeviation:h,maxSegmentLength:u,maxSegmentsPerCurve:p,minSegmentsPerCurve:l}){if(c)return t.push([...s]),t;const m=2*r,d=[n+r*Math.cos(a),i+r*Math.sin(a)],f=[n+r*Math.cos(o),i+r*Math.sin(o)];x(e,d)>k&&t.push(d);const S=Math.abs(o-a),v=u>0&&u<m?2*Math.asin(u/m):S,E=h>0&&h<=r?2*Math.acos(1-h/r):S,g=Math.min(v,E),M=Math.min(p,Math.max(l,Math.ceil(Math.abs(S/g)))),P=1/M;for(let x=1;x<M;x++){const e=x*P,s=a*(1-e)+o*e;t.push([n+r*Math.cos(s),i+r*Math.sin(s)])}return t.push(f),x(s,f)>k&&t.push([...s]),t}function j(t,e,s,n){return new R(e,s).densify(t,n)}function Z(t,e,s,n){const r=i(e,s),[a]=s.c;return b(t,e,a,r,n)}function D(t,e,s,n){const i=f(e,s),[r]=s.a;return b(t,e,r,i,n)}function z(t,e,s,n){const[i,r,a,o,c,h,u]=s.a;return 0===h||0===u?(t.push([...i]),t):new w(e,s).densify(t,n)}function A(t,e,s,n){return c(s)?(t.push([...s]),t):h(s)?j(t,e,s,n):u(s)?Z(t,e,s,n):p(s)?D(t,e,s,n):z(t,e,s,n)}function L(t,e={}){if(!r(t))return t;const s=_(e),n=a(t),i=[];for(const r of n){const t=[];for(let e=0;e<r.length-1;e++){const n=e+1,i=[...o(r[e])];0===e&&t.push(i);A(t,i,r[n],s)}i.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},paths:i,spatialReference:t.spatialReference}:{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},rings:i,spatialReference:t.spatialReference}}const U=e(t=>({maxDeviation:0,maxSegmentLength:t*P,maxSegmentsPerCurve:12e3,minSegmentsPerCurve:1}));function T(t,e,s){if(!r(t))return t;const n=new Set(e),i=_(s),l=a(t),f=[];let S=!1;for(const r of l){const t=[];for(let e=0;e<r.length-1;e++){const s=e+1,a=[...o(r[e])];0===e&&t.push(a);const l=r[s];c(l)?t.push([...l]):h(l)&&!n.has("cubic-bezier")?j(t,a,l,i):u(l)&&!n.has("circular-arc")?Z(t,a,l,i):p(l)&&!n.has("elliptic-arc")?D(t,a,l,i):m(l)&&!n.has("elliptic-arc")?z(t,a,l,i):(t.push(d(l)),S=!0)}f.push(t)}return"curvePaths"in t?{...void 0!==t.hasZ?{hasZ:t.hasZ}:{},...void 0!==t.hasM?{hasM:t.hasM}:{},spatialReference:t.spatialReference,...S?{curvePaths:f}:{paths:f}}:{hasZ:t.hasZ,hasM:t.hasM,spatialReference:t.spatialReference,...S?{curveRings:f}:{rings:f}}}async function I(t,e,n){const i=new Set(e);return await J(t,i,n),t.map(t=>{if(!t||!r(t))return t;const n=t.spatialReference.xyTolerance;if(null==n)return t;const i=U(n);return s(T(t,e,i))})}async function J(e,s,n){let i=null;for(const a of e)if(a&&r(a)&&null==a.spatialReference.xyTolerance&&l(a,s)){const e=a.spatialReference;if(!e)throw new t("geometry:missing-spatial-reference","Geometry contains an unsupported curve type, but it cannot be densified because it has no spatial reference.");const s=N(e);if(n.has(s))a.spatialReference=n.get(s);else{i||(i=await import("../../operators/support/apiConverter.js"));const r=i.fromSpatialReference(e),o=r?.getTolerance();if(null==o)throw new t("geometry:missing-tolerance","Geometry contains an unsupported curve type, but it cannot be densified because the tolerance of its spatial reference is unknown. Set the `xyTolerance` property of the spatial reference.");const c=a.spatialReference.clone();c.read({xyTolerance:o}),a.spatialReference=c,n.set(s,c)}}}function N(t){if(null!=t.wkid)return`${t.wkid}`;if(null!=t.wkt)return t.wkt;const e="toJSON"in t&&"function"==typeof t.toJSON?t.toJSON():t;return JSON.stringify(e)}export{L as densifyCurvedGeometry,I as densifyUnsupportedCurves,U as getAutoDensifyOptions,N as getCacheKey,T as selectiveDensifyCurvedGeometryJSON};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../config.js";import{Cyclical as e}from"../../core/Cyclical.js";import n from"../../core/Error.js";import o from"../../core/Logger.js";import s from"../Polygon.js";import r from"../Polyline.js";import i from"../SpatialReference.js";import{cutParams as l,offsetMagnitude as c,updatePolyGeometry as f,getGeometryParts as u}from"./normalizeUtilsCommon.js";import{getInfo as a}from"./spatialReferenceUtils.js";import{geographicToWebMercator as p,webMercatorToGeographic as h}from"./webMercatorUtils.js";import{cut as m}from"../../rest/geometryService/cut.js";import{simplify as g}from"../../rest/geometryService/simplify.js";const y=()=>o.getLogger("esri.geometry.support.normalizeUtils");function x(t){return"polygon"===t.type}function d(t){return"polygon"===t[0].type}function M(t){return"polyline"===t[0].type}function w(t){const e=[];let n=0,o=0;for(let s=0;s<t.length;s++){const r=t[s];let i=null;for(let t=0;t<r.length;t++)i=r[t],e.push(i),0===t?(n=i[0],o=n):(n=Math.min(n,i[0]),o=Math.max(o,i[0]));i&&e.push([(n+o)/2,0])}return e}function b(t,e){if(!(t instanceof r||t instanceof s)){const t="straightLineDensify: the input geometry is neither polyline nor polygon";throw y().error(t),new n("internal:geometry",t)}const o=u(t),i=[];for(const n of o){const t=[];i.push(t),t.push([n[0][0],n[0][1]]);for(let o=0;o<n.length-1;o++){const s=n[o][0],r=n[o][1],i=n[o+1][0],l=n[o+1][1],c=Math.sqrt((i-s)*(i-s)+(l-r)*(l-r)),f=(l-r)/c,u=(i-s)/c,a=c/e;if(a>1){for(let l=1;l<=a-1;l++){const n=l*e,o=u*n+s,i=f*n+r;t.push([o,i])}const n=(c+Math.floor(a-1)*e)/2,o=u*n+s,i=f*n+r;t.push([o,i])}t.push([i,l])}}return x(t)?new s({rings:i,spatialReference:t.spatialReference}):new r({paths:i,spatialReference:t.spatialReference})}function j(t,e,n){if(e){const e=b(t,1e6);t=h(e,!0)}return n&&(t=f(t,n)),t}function R(t,e,n){if(Array.isArray(t)){const o=t[0];if(o>e){const n=c(o,e);t[0]=o+n*(-2*e)}else if(o<n){const e=c(o,n);t[0]=o+e*(-2*n)}}else{const o=t.x;if(o>e){const n=c(o,e);t=t.clone().offset(n*(-2*e),0)}else if(o<n){const e=c(o,n);t=t.clone().offset(e*(-2*n),0)}}return t}function v(t,e){let n=-1;for(let o=0;o<e.cutIndexes.length;o++){const s=e.cutIndexes[o],r=e.geometries[o],i=u(r);for(let t=0;t<i.length;t++){const e=i[t];e.some(n=>{if(n[0]<180)return!0;{let n=0;for(let t=0;t<e.length;t++){const o=e[t][0];n=o>n?o:n}n=Number(n.toFixed(9));const o=-360*c(n,180);for(let s=0;s<e.length;s++){const e=r.getPoint(t,s);r.setPoint(t,s,e.clone().offset(o,0))}return!0}})}if(s===n){if(d(t))for(const e of u(r))t[s]=t[s].addRing(e);else if(M(t))for(const e of u(r))t[s]=t[s].addPath(e)}else n=s,t[s]=r}return t}async function P(e,n,o){if(!Array.isArray(e))return P([e],n);n&&"string"!=typeof n&&y().warn("normalizeCentralMeridian()","The url object is deprecated, use the url string instead");const i="string"==typeof n?n:n?.url??t.geometryServiceUrl;let u,h,x,d,M,w,b,z,L=0;const S=[],U=[];for(const t of e)if(null!=t)if(u||(u=t.spatialReference,h=a(u),x=u.isWebMercator,w=x?102100:4326,d=l[w].maxX,M=l[w].minX,b=l[w].plus180Line,z=l[w].minus180Line),h)if("mesh"===t.type)U.push(t);else if("point"===t.type)U.push(R(t.clone(),d,M));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map(t=>R(t,d,M)),U.push(e)}else if("extent"===t.type){const e=t.clone()._normalize(!1,!1,h);U.push(e.rings?new s(e):e)}else if(t.extent){const e=t.extent,n=c(e.xmin,M)*(2*d);let o=0===n?t.clone():f(t.clone(),n);e.offset(n,0);let{xmin:s,xmax:r}=e;s=Number(s.toFixed(9)),r=Number(r.toFixed(9)),e.intersects(b)&&r!==d?(L=r>L?r:L,o=j(o,x),S.push(o),U.push("cut")):e.intersects(z)&&s!==M?(L=r*(2*d)>L?r*(2*d):L,o=j(o,x,360),S.push(o),U.push("cut")):U.push(o)}else U.push(t.clone());else U.push(t);else U.push(t);let A=c(L,d),C=-90;const F=A,N=new r;for(;A>0;){const t=360*A-180;N.addPath([[t,C],[t,-1*C]]),C*=-1,A--}if(S.length>0&&F>0){const t=v(S,await m(i,S,N,o)),n=[],s=[];for(let o=0;o<U.length;o++){const r=U[o];if("cut"!==r)s.push(r);else{const r=t.shift(),i=e[o];null!=i&&"polygon"===i.type&&i.rings&&i.rings.length>1&&r.rings.length>=i.rings.length?(n.push(r),s.push("simplify")):s.push(x?p(r):r)}}if(!n.length)return s;const r=await g(i,n,o),l=[];for(let e=0;e<s.length;e++){const t=s[e];"simplify"!==t?l.push(t):l.push(x?p(r.shift()):r.shift())}return l}const W=[];for(let t=0;t<U.length;t++){const e=U[t];if("cut"!==e)W.push(e);else{const t=S.shift();W.push(!0===x?p(t):t)}}return W}function z(t){if(!t)return null;const e=t.extent;if(!e)return null;const n=t.spatialReference&&a(t.spatialReference);if(!n)return e;const[o,s]=n.valid,r=2*s,{width:i}=e;let l,{xmin:c,xmax:f}=e;if([c,f]=[f,c],"extent"===t.type||0===i||i<=s||i>r||c<o||f>s)return e;switch(t.type){case"polygon":if(!(t.rings.length>1))return e;l=w(t.rings);break;case"polyline":if(!(t.paths.length>1))return e;l=w(t.paths);break;case"multipoint":l=t.points}const u=e.clone();for(let a=0;a<l.length;a++){let t=l[a][0];t<0?(t+=s,f=Math.max(t,f)):(t-=s,c=Math.min(t,c))}return u.xmin=c,u.xmax=f,u.width<i?(u.xmin-=s,u.xmax-=s,u):e}function L(t,e,n){const o=a(n);if(null==o)return t;const[s,r]=o.valid,i=2*r;let l=0,c=0;e>r?l=Math.ceil(Math.abs(e-r)/i):e<s&&(l=-Math.ceil(Math.abs(e-s)/i)),t>r?c=Math.ceil(Math.abs(t-r)/i):t<s&&(c=-Math.ceil(Math.abs(t-s)/i));let f=t+(l-c)*i;const u=f-e;return u>r?f-=i:u<s&&(f+=i),f}function S(t,e){const n=U(e);return n?.normalize(t)??t}function U(t){const n=a(t);if(null==n)return null;const[o,s]=n.valid;return new e(o,s)}const A=U(i.WGS84),C=U(i.WebMercator);export{U as createSpatialReferenceCyclical,A as gcsCyclical,L as getClosestDenormalizedXToReference,z as getDenormalizedExtent,P as normalizeCentralMeridian,S as normalizeMapX,b as straightLineDensify,C as webMercatorCyclical};
2
+ import e from"../../config.js";import{Cyclical as t}from"../../core/Cyclical.js";import n from"../../core/Error.js";import o from"../../core/Logger.js";import r from"../Polygon.js";import s from"../Polyline.js";import i from"../SpatialReference.js";import{cutParams as l,offsetMagnitude as c,updatePolyGeometry as f,getGeometryParts as u}from"./normalizeUtilsCommon.js";import{getInfo as p}from"./spatialReferenceUtils.js";import{geographicToWebMercator as a,webMercatorToGeographic as h}from"./webMercatorUtils.js";import{isCurvedGeometry as m}from"./curves/curveUtils.js";import{densifyCurvedGeometry as g}from"./curves/densifyCurvedGeometry.js";import{cut as y}from"../../rest/geometryService/cut.js";import{simplify as x}from"../../rest/geometryService/simplify.js";const d=()=>o.getLogger("esri.geometry.support.normalizeUtils");function M(e){return"polygon"===e.type}function j(e){return"polygon"===e[0].type}function w(e){return"polyline"===e[0].type}function b(e){const t=[];let n=0,o=0;for(let r=0;r<e.length;r++){const s=e[r];let i=null;for(let e=0;e<s.length;e++)i=s[e],t.push(i),0===e?(n=i[0],o=n):(n=Math.min(n,i[0]),o=Math.max(o,i[0]));i&&t.push([(n+o)/2,0])}return t}function v(e,t){if(!(e instanceof s||e instanceof r)){const e="straightLineDensify: the input geometry is neither polyline nor polygon";throw d().error(e),new n("internal:geometry",e)}const o=u(e),i=[];for(const n of o){const e=[];i.push(e),e.push([n[0][0],n[0][1]]);for(let o=0;o<n.length-1;o++){const r=n[o][0],s=n[o][1],i=n[o+1][0],l=n[o+1][1],c=Math.sqrt((i-r)*(i-r)+(l-s)*(l-s)),f=(l-s)/c,u=(i-r)/c,p=c/t;if(p>1){for(let l=1;l<=p-1;l++){const n=l*t,o=u*n+r,i=f*n+s;e.push([o,i])}const n=(c+Math.floor(p-1)*t)/2,o=u*n+r,i=f*n+s;e.push([o,i])}e.push([i,l])}}return M(e)?new r({rings:i,spatialReference:e.spatialReference}):new s({paths:i,spatialReference:e.spatialReference})}function R(e,t,n){const o=1e6;if(t){const t=m(e)?g(e,{maxSegmentLength:o}):v(e,o);e=h(t,!0)}return n&&(e=f(e,n)),e}function L(e,t,n){if(Array.isArray(e)){const o=e[0];if(o>t){const n=c(o,t);e[0]=o+n*(-2*t)}else if(o<n){const t=c(o,n);e[0]=o+t*(-2*n)}}else{const o=e.x;if(o>t){const n=c(o,t);e=e.clone().offset(n*(-2*t),0)}else if(o<n){const t=c(o,n);e=e.clone().offset(t*(-2*n),0)}}return e}function P(e,t){let n=-1;for(let o=0;o<t.cutIndexes.length;o++){const r=t.cutIndexes[o],s=t.geometries[o],i=u(s);for(let e=0;e<i.length;e++){const t=i[e];t.some(n=>{if(n[0]<180)return!0;{let n=0;for(let e=0;e<t.length;e++){const o=t[e][0];n=o>n?o:n}n=Number(n.toFixed(9));const o=-360*c(n,180);for(let r=0;r<t.length;r++){const t=s.getPoint(e,r);s.setPoint(e,r,t.clone().offset(o,0))}return!0}})}if(r===n){if(j(e))for(const t of u(s))e[r]=e[r].addRing(t);else if(w(e))for(const t of u(s))e[r]=e[r].addPath(t)}else n=r,e[r]=s}return e}async function S(t,n,o){if(!Array.isArray(t))return S([t],n);n&&"string"!=typeof n&&d().warn("normalizeCentralMeridian()","The url object is deprecated, use the url string instead");const i="string"==typeof n?n:n?.url??e.geometryServiceUrl;let u,h,m,g,M,j,w,b,v=0;const U=[],z=[];for(const e of t)if(null!=e)if(u||(u=e.spatialReference,h=p(u),m=u.isWebMercator,j=m?102100:4326,g=l[j].maxX,M=l[j].minX,w=l[j].plus180Line,b=l[j].minus180Line),h)if("mesh"===e.type)z.push(e);else if("point"===e.type)z.push(L(e.clone(),g,M));else if("multipoint"===e.type){const t=e.clone();t.points=t.points.map(e=>L(e,g,M)),z.push(t)}else if("extent"===e.type){const t=e.clone()._normalize(!1,!1,h);z.push(t.rings?new r(t):t)}else if(e.extent){const t=e.extent,n=c(t.xmin,M)*(2*g);let o=0===n?e.clone():f(e.clone(),n);t.offset(n,0);let{xmin:r,xmax:s}=t;r=Number(r.toFixed(9)),s=Number(s.toFixed(9)),t.intersects(w)&&s!==g?(v=s>v?s:v,o=R(o,m),U.push(o),z.push("cut")):t.intersects(b)&&r!==M?(v=s*(2*g)>v?s*(2*g):v,o=R(o,m,360),U.push(o),z.push("cut")):z.push(o)}else z.push(e.clone());else z.push(e);else z.push(e);let A=c(v,g),C=-90;const F=A,N=new s;for(;A>0;){const e=360*A-180;N.addPath([[e,C],[e,-1*C]]),C*=-1,A--}if(U.length>0&&F>0){const e=P(U,await y(i,U,N,o)),n=[],r=[];for(let o=0;o<z.length;o++){const s=z[o];if("cut"!==s)r.push(s);else{const s=e.shift(),i=t[o];null!=i&&"polygon"===i.type&&i.rings&&i.rings.length>1&&s.rings.length>=i.rings.length?(n.push(s),r.push("simplify")):r.push(m?a(s):s)}}if(!n.length)return r;const s=await x(i,n,o),l=[];for(let t=0;t<r.length;t++){const e=r[t];"simplify"!==e?l.push(e):l.push(m?a(s.shift()):s.shift())}return l}const W=[];for(let e=0;e<z.length;e++){const t=z[e];if("cut"!==t)W.push(t);else{const e=U.shift();W.push(!0===m?a(e):e)}}return W}function U(e){if(!e)return null;const t=e.extent;if(!t)return null;const n=e.spatialReference&&p(e.spatialReference);if(!n)return t;const[o,r]=n.valid,s=2*r,{width:i}=t;let l,{xmin:c,xmax:f}=t;if([c,f]=[f,c],"extent"===e.type||0===i||i<=r||i>s||c<o||f>r)return t;switch(e.type){case"polygon":if(!(e.rings.length>1))return t;l=b(e.rings);break;case"polyline":if(!(e.paths.length>1))return t;l=b(e.paths);break;case"multipoint":l=e.points}const u=t.clone();for(let p=0;p<l.length;p++){let e=l[p][0];e<0?(e+=r,f=Math.max(e,f)):(e-=r,c=Math.min(e,c))}return u.xmin=c,u.xmax=f,u.width<i?(u.xmin-=r,u.xmax-=r,u):t}function z(e,t,n){const o=p(n);if(null==o)return e;const[r,s]=o.valid,i=2*s;let l=0,c=0;t>s?l=Math.ceil(Math.abs(t-s)/i):t<r&&(l=-Math.ceil(Math.abs(t-r)/i)),e>s?c=Math.ceil(Math.abs(e-s)/i):e<r&&(c=-Math.ceil(Math.abs(e-r)/i));let f=e+(l-c)*i;const u=f-t;return u>s?f-=i:u<r&&(f+=i),f}function A(e,t){const n=C(t);return n?.normalize(e)??e}function C(e){const n=p(e);if(null==n)return null;const[o,r]=n.valid;return new t(o,r)}const F=C(i.WGS84),N=C(i.WebMercator);export{C as createSpatialReferenceCyclical,F as gcsCyclical,z as getClosestDenormalizedXToReference,U as getDenormalizedExtent,S as normalizeCentralMeridian,A as normalizeMapX,v as straightLineDensify,N as webMercatorCyclical};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../Polyline.js";import n from"../SpatialReference.js";import{isPolygon as t}from"./jsonTypeUtils.js";const r={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new e({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:n.WebMercator}),minus180Line:new e({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:n.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new e({paths:[[[180,-180],[180,180]]],spatialReference:n.WGS84}),minus180Line:new e({paths:[[[-180,-180],[-180,180]]],spatialReference:n.WGS84})}};function i(e,n){return Math.ceil((e-n)/(2*n))}function s(e,n){const t=o(e);for(const r of t)for(const e of r)e[0]+=n;return e}function o(e){return t(e)?e.rings:e.paths}export{r as cutParams,o as getGeometryParts,i as offsetMagnitude,s as updatePolyGeometry};
2
+ import e from"../Polyline.js";import n from"../SpatialReference.js";import{isPolygon as t}from"./jsonTypeUtils.js";import{isCurvedGeometry as o,isCircularArc as r,isEllipticArc as i,isBezierCurve as s}from"./curves/curveUtils.js";const c={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new e({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:n.WebMercator}),minus180Line:new e({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:n.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new e({paths:[[[180,-180],[180,180]]],spatialReference:n.WGS84}),minus180Line:new e({paths:[[[-180,-180],[-180,180]]],spatialReference:n.WGS84})}};function f(e,n){return Math.ceil((e-n)/(2*n))}function a(e,n){if(o(e))for(const t of p(e))for(const e of t){if(r(e)){const[t,o]=e.c;t[0]+=n,o[0]+=n;continue}if(i(e)){const[t,o]=e.a;t[0]+=n,o[0]+=n;continue}if(s(e)){const[t,o,r]=e.b;t[0]+=n,o[0]+=n,r[0]+=n;continue}e[0]+=n}for(const t of u(e))for(const e of t)e[0]+=n;return e}function u(e){return t(e)?e.rings:e.paths}function p(e){return t(e)?e.curveRings:e.curvePaths}export{c as cutParams,p as getCurvedGeometryParts,u as getGeometryParts,f as offsetMagnitude,a as updatePolyGeometry};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{getSliceableContainerSymbol as r}from"./getSliceableContainer.js";import i from"./GraphicOrigin.js";import{isImageryGraphicOriginSymbol as t}from"./isImageryGraphicOrigin.js";var e;class s extends i{get[(e=t,r)](){return this.layer}constructor(r){super(),this[e]=!0,this.type="imagery",this.layer=r}get id(){return this.layer.id}}export{s as default};
2
+ import{idFieldsProviderSymbol as r}from"./getIdFieldsProvider.js";import{popupProviderSymbol as e}from"./getPopupProvider.js";import{getSliceableContainerSymbol as t}from"./getSliceableContainer.js";import i from"./GraphicOrigin.js";import{isImageryGraphicOriginSymbol as s}from"./isImageryGraphicOrigin.js";var o;class a extends i{get[(o=s,e)](){return this.layer}get[r](){return this.layer}get[t](){return this.layer}constructor(r){super(),this[o]=!0,this.type="imagery",this.layer=r}get id(){return this.layer.id}}export{a as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{getSliceableContainerSymbol as r}from"./getSliceableContainer.js";import i from"./GraphicOrigin.js";import{isImageryTileGraphicOriginSymbol as e}from"./isImageryTileGraphicOrigin.js";var t;class s extends i{get[(t=e,r)](){return this.layer}constructor(r){super(),this[t]=!0,this.type="imagery-tile",this.layer=r}get id(){return this.layer.id}}export{s as default};
2
+ import{popupProviderSymbol as r}from"./getPopupProvider.js";import{getSliceableContainerSymbol as e}from"./getSliceableContainer.js";import t from"./GraphicOrigin.js";import{isImageryTileGraphicOriginSymbol as i}from"./isImageryTileGraphicOrigin.js";var s;class a extends t{get[(s=i,r)](){return this.layer}get[e](){return this.layer}constructor(r){super(),this[s]=!0,this.type="imagery-tile",this.layer=r}get id(){return this.layer.id}}export{a as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{getSliceableContainerSymbol as r}from"./getSliceableContainer.js";import t from"./GraphicOrigin.js";import{isWCSGraphicOriginSymbol as i}from"./isWCSGraphicOrigin.js";var e;class s extends t{get[(e=i,r)](){return this.layer}constructor(r){super(),this[e]=!0,this.type="wcs",this.layer=r}get id(){return this.layer.id}}export{s as default};
2
+ import{popupProviderSymbol as r}from"./getPopupProvider.js";import{getSliceableContainerSymbol as t}from"./getSliceableContainer.js";import e from"./GraphicOrigin.js";import{isWCSGraphicOriginSymbol as i}from"./isWCSGraphicOrigin.js";var s;class o extends e{get[(s=i,r)](){return this.layer}get[t](){return this.layer}constructor(r){super(),this[s]=!0,this.type="wcs",this.layer=r}get id(){return this.layer.id}}export{o as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../config.js";import t from"../request.js";import r from"../core/Error.js";import{Evented as s}from"../core/Evented.js";import{on as i}from"../core/events.js";import{fixJson as n}from"../core/lang.js";import{getDeepValue as o}from"../core/object.js";import{onAbort as a,isAborted as h}from"../core/promiseUtils.js";import{urlToObject as l,hasSameOrigin as c,Url as d,queryToObject as u,base64UrlEncode as p,objectToQuery as _,normalize as f,getProxyRule as g,makeAbsolute as m,addQueryParameters as v}from"../core/urlUtils.js";import S from"./Credential.js";import w from"./IdentityModal.js";import I from"./OAuthCredential.js";import k from"./OAuthInfo.js";import A from"./ServerInfo.js";import{isSecureProxyService as U,normalizeArcGISOnlineOrgDomain as y}from"../portal/support/urlUtils.js";const P={},x=e=>{const t=new d(e.owningSystemUrl).host,r=new d(e.server).host,s=/.+\.arcgis\.com$/i;return s.test(t)&&s.test(r)},O=(e,t)=>!!(x(e)&&t&&t.some(t=>t.test(e.server)));let T=null,R=null;try{T=window.localStorage,R=window.sessionStorage}catch{}class C extends s{constructor(){super(),this._portalConfig=globalThis.esriGeowConfig,this.serverInfos=[],this.oAuthInfos=[],this.credentials=[],this._soReqs=[],this._xoReqs=[],this._portals=[],this._defaultOAuthInfo=null,this._defaultTokenValidity=60,this.dialog=null,this.tokenValidity=null,this.normalizeWebTierAuth=!1,this._appOrigin="null"!==window.origin?window.origin:window.location.origin,this._appUrlObj=l(window.location.href),this._busy=null,this._rejectOnPersistedPageShow=!1,this._oAuthLocationParams=null,this._gwTokenUrl="/sharing/rest/generateToken",this._agsRest="/rest/services",this._agsPortal=/\/sharing(\/|$)/i,this._agsAdmin=/(https?:\/\/[^/]+\/[^/]+)\/admin\/?(\/.*)?$/i,this._adminSvcs=/\/rest\/admin\/services(\/|$)/i,this._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],this._legacyFed=[],this._regexSDirUrl=/http.+\/rest\/services\/?/gi,this._regexServerType=/(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MissionServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer|VideoServer|3DTilesServer)).*/gi,this._gwUser=/http.+\/users\/([^/]+).*/i,this._gwItem=/http.+\/items\/([^/]+).*/i,this._gwGroup=/http.+\/groups\/([^/]+).*/i,this._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,this._createDefaultOAuthInfo=!0,this._hasTestedIfAppIsOnPortal=!1,this._getPlatformSelfError=null,this._getOAuthLocationParams(),window.addEventListener("pageshow",e=>{this._pageShowHandler(e)})}registerServers(e){const t=this.serverInfos;t?(e=e.filter(e=>!this.findServerInfo(e.server)),this.serverInfos=t.concat(e)):this.serverInfos=e,e.forEach(e=>{e.owningSystemUrl&&this._portals.push(e.owningSystemUrl),e.hasPortal&&this._portals.push(e.server)})}registerOAuthInfos(e){const t=this.oAuthInfos;if(t){for(const r of e){const e=this.findOAuthInfo(r.portalUrl);e&&t.splice(t.indexOf(e),1)}this.oAuthInfos=t.concat(e)}else this.oAuthInfos=e}registerToken(e){e={...e};const t=this._sanitizeUrl(e.server),r=this._isServerRsrc(t);let s,i=this.findServerInfo(t),n=!0;i||(i=new A,i.server=this._getServerInstanceRoot(t),r?i.hasServer=!0:(i.tokenServiceUrl=this._getTokenSvcUrl(t),i.hasPortal=!0),this.registerServers([i])),s=this._findCredential(t),s?(delete e.server,Object.assign(s,e),n=!1):(s=new S({userId:e.userId,server:i.server??void 0,token:e.token,expires:e.expires,ssl:e.ssl,scope:r?"server":"portal"}),s.resources=[t],this.credentials.push(s)),s.emitTokenChange(!1),n||s.refreshServerTokens()}toJSON(){return n({serverInfos:this.serverInfos.map(e=>e.toJSON()),oAuthInfos:this.oAuthInfos.map(e=>e.toJSON()),credentials:this.credentials.map(e=>e.toJSON())})}initialize(e){if(!e)return;"string"==typeof e&&(e=JSON.parse(e));const t=e.serverInfos,r=e.oAuthInfos,s=e.credentials;if(t){const e=[];t.forEach(t=>{t.server&&t.tokenServiceUrl&&e.push(t.declaredClass?t:new A(t))}),e.length&&this.registerServers(e)}if(r){const e=[];r.forEach(t=>{t.appId&&e.push(t.declaredClass?t:new k(t))}),e.length&&this.registerOAuthInfos(e)}s&&s.forEach(e=>{e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new S(e)).emitTokenChange(),this.credentials.push(e))})}findServerInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.serverInfos)if(this._hasSameServerInstance(r.server,e)){t=r;break}return t}findOAuthInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.oAuthInfos)if(this._hasSameServerInstance(r.portalUrl,e)){t=r;break}return t}findCredential(e,t){if(!e)return;let r;e=this._sanitizeUrl(e);const s=this._isServerRsrc(e)?"server":"portal";if(t){for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&t===i.userId&&i.scope===s){r=i;break}}else for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&-1!==this._getIdenticalSvcIdx(e,i)&&i.scope===s){r=i;break}return r}getCredential(e,t){let s,i=!1,n=!0;t&&(i=!(!t.token&&!t.credential),s=t.error,n=!1!==t.prompt),t={...t},e=this._sanitizeUrl(e);const o=new AbortController,l=Promise.withResolvers();if(t.signal&&a(t.signal,()=>{o.abort()}),a(o,()=>{l.reject(new r("identity-manager:user-aborted","ABORTED"))}),h(o))return l.promise;t.signal=o.signal;const d=this._isAdminResource(e),u=i?this.findCredential(e):null;let p;if(u&&498===s?.details?.httpStatus)u.destroy();else if(u)return p=new r("identity-manager:not-authorized","You are currently signed in as: '"+u.userId+"'. You do not have access to this resource: "+e,{error:s}),l.reject(p),l.promise;const _=this._findCredential(e,t);if(_)return l.resolve(_),l.promise;let f=this.findServerInfo(e);if(f)!f.hasPortal&&f.server&&f.owningSystemUrl&&this._hasSameServerInstance(f.server,f.owningSystemUrl)&&(f.hasPortal=!0),!f.hasServer&&this._isServerRsrc(e)&&(f._restInfoPms=this._getTokenSvcUrl(e),f.hasServer=!0);else{const t=this._getTokenSvcUrl(e);if(!t)return p=new r("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),l.reject(p),l.promise;f=new A,f.server=this._getServerInstanceRoot(e),"string"==typeof t?(f.tokenServiceUrl=t,f.hasPortal=!0):(f._restInfoPms=t,f.hasServer=!0),this.registerServers([f])}return f.hasPortal&&void 0===f._selfReq&&(n||c(f.tokenServiceUrl,this._appOrigin)||this._gwDomains.some(e=>e.tokenServiceUrl===f.tokenServiceUrl))&&(f._selfReq={owningTenant:t?.owningTenant,selfDfd:this._getPortalSelf(f.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,f,t,l,d)}getResourceName(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""}generateToken(e,s,i){const n=this._rePortalTokenSvc.test(e.tokenServiceUrl),o=new d(this._appOrigin),a=e.shortLivedTokenValidity;let h,l,u,p,_,f,g,m;s&&(m=this.tokenValidity||a||this._defaultTokenValidity,m>a&&a>0&&(m=a)),i&&(h=i.isAdmin,l=i.serverUrl,u=i.token,f=i.signal,g=i.ssl,e.customParameters=i.customParameters),h?p=e.adminTokenServiceUrl:(p=e.tokenServiceUrl,_=new d(p.toLowerCase()),e.webTierAuth&&i?.serverUrl&&!g&&"http"===o.scheme&&(c(o.uri,p,!0)||"https"===_.scheme&&o.host===_.host&&"7080"===o.port&&"7443"===_.port)&&(p=p.replace(/^https:/i,"http:").replace(/:7443/i,":7080")));const v={query:{request:"getToken",username:s?.username,password:s?.password,serverUrl:l,token:u,expiration:m,referer:h||n?this._appOrigin:null,client:h?"referer":null,f:"json",...e.customParameters},method:"post",authMode:"anonymous",useProxy:this._useProxy(e,i),signal:f};n||(v.withCredentials=!1);return t(p,v).then(t=>{const i=t.data;if(!i?.token)return new r("identity-manager:authentication-failed","Unable to generate token");const n=e.server;return P[n]||(P[n]={}),s&&(P[n][s.username]=s.password),i.validity=m,i})}isBusy(){return!!this._busy}async checkSignInStatus(e){return(await this.checkAppAccess(e,"")).credential}checkAppAccess(e,s,i){let n=!1;return this.getCredential(e,{prompt:!1}).then(o=>{let a;const h={f:"json"};if("portal"===o.scope)if(s&&(this._doPortalSignIn(e)||i?.force))a=o.server+"/sharing/rest/oauth2/validateAppAccess",h.client_id=s;else{if(!o.token)return{credential:o};a=o.server+"/sharing/rest"}else{if(!o.token)return{credential:o};a=o.server+"/rest/services"}return o.token&&(h.token=o.token),t(a,{query:h,authMode:"anonymous"}).then(e=>{if(!1===e.data.valid)throw new r("identity-manager:not-authorized",`You are currently signed in as: '${o.userId}'.`,e.data);return n=!!e.data.viewOnlyUserTypeApp,{credential:o}}).catch(e=>{if("identity-manager:not-authorized"===e.name)throw e;const t=e.details?.httpStatus;if(498===t)throw o.destroy(),new r("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new r("identity-manager:invalid-request","Bad request");return{credential:o}})}).then(e=>({credential:e.credential,viewOnly:n}))}setOAuthResponseHash(e){e&&(e.startsWith("#")&&(e=e.slice(1)),this._processOAuthPopupParams(u(e)))}setOAuthRedirectionHandler(e){this._oAuthRedirectFunc=e}setProtocolErrorHandler(e){this._protocolFunc=e}signIn(e,t,s={}){const i=Promise.withResolvers(),n=()=>{l?.remove(),c?.remove(),this.dialog?.destroy(),this.dialog=l=c=null},o=()=>{n(),this._oAuthDfd=null,i.reject(new r("identity-manager:user-aborted","ABORTED"))};s.signal&&a(s.signal,()=>{o()});const h=new w({open:!0,resource:this.getResourceName(e),server:t.server});this.dialog=h,this.emit("dialog-create");let l=h.on("cancel",o),c=h.on("submit",e=>{this.generateToken(t,e,{isAdmin:s.isAdmin,signal:s.signal}).then(r=>{n();const o=new S({userId:e.username,server:t.server??void 0,token:r.token,expires:null!=r.expires?Number(r.expires):null,ssl:!!r.ssl,isAdmin:s.isAdmin,validity:r.validity});i.resolve(o)}).catch(e=>{h.error=e,h.signingIn=!1})});return i.promise}oAuthSignIn(e,t,s,i){this._oAuthDfd=Promise.withResolvers();const n=this._oAuthDfd;let o;i?.signal&&a(i.signal,()=>{const e=this._oAuthDfd&&this._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():this.dialog&&d()}),n.resUrl_=e,n.sinfo_=t,n.oinfo_=s;const h=s._oAuthCred;if(h.storage&&("authorization-code"===s.flowType||"auto"===s.flowType&&t.currentVersion>=8.4)){let e=crypto.getRandomValues(new Uint8Array(32));o=p(e),h.codeVerifier=o,e=crypto.getRandomValues(new Uint8Array(32)),h.stateUID=p(e),h.save()||(h.codeVerifier=o=null)}else h.codeVerifier=null;let l,c;this._getCodeChallenge(o).then(r=>{const n=!i||!1!==i.oAuthPopupConfirmation;if(!s.popup||!n)return void this._doOAuthSignIn(e,t,s,r);const o=new w({oAuthPrompt:!0,server:t.server,open:!0});this.dialog=o,this.emit("dialog-create"),l=o.on("cancel",d),c=o.on("submit",()=>{u(),this._doOAuthSignIn(e,t,s,r)})});const d=()=>{u(),this._oAuthDfd=null,n.reject(new r("identity-manager:user-aborted","ABORTED"))},u=()=>{l?.remove(),c?.remove(),this.dialog?.destroy(),this.dialog=null};return n.promise}async refreshToken(e){const t=this.findServerInfo(e.server),r=t?.owningSystemUrl,s=!!r&&"server"===e.scope,i=s&&O(t,this._legacyFed),n=t.webTierAuth,o=n&&this.normalizeWebTierAuth,a=P[e.server],h=a?.[e.userId];let l,c=e.resources&&e.resources[0],d=s?this.findServerInfo(r):null,u={username:e.userId,password:h};if(n&&!o)return;s&&!d&&this.serverInfos.some(e=>(this._isIdProvider(r,e.server)&&(d=e),!!d));const p=d?this.findCredential(d.server,e.userId):null;if(!s||p){if(!i){if(s)l={serverUrl:c,token:p?.token,ssl:p?.ssl};else if(o)u=null,l={ssl:e.ssl};else{if(!h){let r;return c&&(c=this._sanitizeUrl(c),e._enqueued=1,r=this._enqueue(c,t,null,null,e.isAdmin,e),r.then(()=>{e._enqueued=0,e.refreshServerTokens()}).catch(()=>{e._enqueued=0})),r}e.isAdmin&&(l={isAdmin:!0})}return this.generateToken(s?d:t,s?null:u,l).then(t=>{e.token=t.token,e.expires=null!=t.expires?Number(t.expires):null,e.creationTime=Date.now(),e.validity=t.validity,e.emitTokenChange(),e.refreshServerTokens()}).catch(()=>{})}p?.refreshToken()}}refreshServerTokens(e){"portal"===e.scope&&this.credentials.forEach(t=>{const r=this.findServerInfo(t.server),s=r?.owningSystemUrl;t!==e&&t.userId===e.userId&&s&&"server"===t.scope&&(this._hasSameServerInstance(e.server,s)||this._isIdProvider(s,e.server))&&(O(r,this._legacyFed)?(t.token=e.token,t.expires=e.expires,t.creationTime=e.creationTime,t.validity=e.validity,t.emitTokenChange()):t.refreshToken())})}destroyCredentials(){if(this.credentials){this.credentials.slice().forEach(e=>{e.destroy()})}this.emit("credentials-destroy")}enablePostMessageAuth(e="https://www.arcgis.com/sharing/rest"){this._postMessageAuthHandle&&this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=i(window,"message",t=>{if((t.origin===this._appOrigin||t.origin.endsWith(".arcgis.com"))&&"arcgis:auth:requestCredential"===t.data?.type){const r=t.source;this.getCredential(e).then(e=>{r.postMessage({type:"arcgis:auth:credential",credential:{expires:e.expires,server:e.server,ssl:e.ssl,token:e.token,userId:e.userId}},t.origin)}).catch(e=>{r.postMessage({type:"arcgis:auth:error",error:{name:e.name,message:e.message}},t.origin)})}})}disablePostMessageAuth(){this._postMessageAuthHandle&&(this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=null)}_getOAuthLocationParams(){let e=window.location.hash;if(e){e.startsWith("#")&&(e=e.slice(1));const t=u(e);let r=!1;if(t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username"))try{t.state=JSON.parse(t.state),t.state.portalUrl&&(this._oAuthLocationParams=t,r=!0)}catch{}else if(t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0,t.state)))try{t.state=JSON.parse(t.state)}catch{}r&&(window.location.hash=t.state?.hash||"")}let t=window.location.search;if(t){t.startsWith("?")&&(t=t.slice(1));const e=u(t);let r=!1;if(e.code&&e.state)try{e.state=JSON.parse(e.state),e.state.portalUrl&&e.state.uid&&(this._oAuthLocationParams=e,r=!0)}catch{}else if(e.error&&e.error_description&&(console.log("IdentityManager OAuth Error: ",e.error," - ",e.error_description),"access_denied"===e.error&&(r=!0,e.state)))try{e.state=JSON.parse(e.state)}catch{}if(r){const t={...e};["code","error","error_description","message_code","persist","state"].forEach(e=>{delete t[e]});const r=_(t),s=window.location.pathname+(r?`?${r}`:"")+(e.state?.hash||"");window.history.replaceState(window.history.state,"",s)}}}_getOAuthToken(e,r,s,i,n){return e=e.replace(/^http:/i,"https:"),t(`${e}/sharing/rest/oauth2/token`,{authMode:"anonymous",method:"post",query:i&&n?{grant_type:"authorization_code",code:r,redirect_uri:i,client_id:s,code_verifier:n}:{grant_type:"refresh_token",refresh_token:r,client_id:s}}).then(e=>e.data)}async _getCodeChallenge(e){if(e&&globalThis.isSecureContext){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return p(new Uint8Array(r))}return null}_pageShowHandler(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){const e=new r("identity-manager:user-aborted","ABORTED");this._errbackFunc(e)}}_findCredential(e,t){let r,s,i,n,o=-1;const a=t?.token,h=t?.resource,l=this._isServerRsrc(e)?"server":"portal",c=this.credentials.filter(t=>this._hasSameServerInstance(t.server,e)&&t.scope===l);if(e=h||e,c.length)if(1===c.length){if(r=c[0],i=this.findServerInfo(r.server),s=i?.owningSystemUrl,n=s?this.findCredential(s,r.userId):void 0,o=this._getIdenticalSvcIdx(e,r),!a)return-1===o&&r.resources.push(e),this._addResource(e,n),r;-1!==o&&(r.resources.splice(o,1),this._removeResource(e,n))}else{let t,r;if(c.some(a=>(r=this._getIdenticalSvcIdx(e,a),-1!==r&&(t=a,i=this.findServerInfo(t.server),s=i?.owningSystemUrl,n=s?this.findCredential(s,t.userId):void 0,o=r,!0))),a)t&&(t.resources.splice(o,1),this._removeResource(e,n));else if(t)return this._addResource(e,n),t}}_findOAuthInfo(e){let t=this.findOAuthInfo(e);if(!t)for(const r of this.oAuthInfos)if(this._isIdProvider(r.portalUrl,e)){t=r;break}return t}_addResource(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)}_removeResource(e,t){let r=-1;t&&(r=this._getIdenticalSvcIdx(e,t),r>-1&&t.resources.splice(r,1))}_useProxy(e,t){return t?.isAdmin&&!c(e.adminTokenServiceUrl,this._appOrigin)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!c(e.tokenServiceUrl,this._appOrigin)}_getOrigin(e){const t=new d(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")}_getServerInstanceRoot(e){const t=e.toLowerCase();let r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1!==r||U(t)||(r=t.indexOf("/sharing")),-1===r&&t.endsWith("/")&&(r=t.length-1),r>-1?e.slice(0,r):e}_hasSameServerInstance(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=y(e),t=y(t),(e=e.slice(Math.max(0,e.indexOf(":"))))===(t=t.slice(Math.max(0,t.indexOf(":"))))}_sanitizeUrl(t){const r=(e.request.proxyUrl||"").toLowerCase(),s=r?t.toLowerCase().indexOf(r+"?"):-1;return-1!==s&&(t=t.slice(s+r.length+1)),t=f(t),l(t).path}_isRESTService(e){return e.includes(this._agsRest)}_isAdminResource(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)}_isServerRsrc(e){return this._isRESTService(e)||this._isAdminResource(e)}_isIdenticalService(e,t){let r=!1;if(this._isRESTService(e)&&this._isRESTService(t)){const s=this._getSuffix(e).toLowerCase(),i=this._getSuffix(t).toLowerCase();if(r=s===i,!r){const e=/(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;r=s.replaceAll(e,"$1")===i.replaceAll(e,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r}_isPortalDomain(t){const r=new d(t.toLowerCase()),s=this._portalConfig;let i=this._gwDomains.some(e=>e.regex.test(r.uri));return!i&&s&&(i=this._hasSameServerInstance(this._getServerInstanceRoot(s.restBaseUrl),r.uri)),i||e.portalUrl&&(i=c(r,e.portalUrl,!0)),i||(i=this._portals.some(e=>this._hasSameServerInstance(e,r.uri))),i=i||this._agsPortal.test(r.path),i}_isIdProvider(e,t){let r=-1,s=-1;this._gwDomains.forEach((i,n)=>{-1===r&&i.regex.test(e)&&(r=n),-1===s&&i.regex.test(t)&&(s=n)});let i=!1;if(r>-1&&s>-1&&(0===r||4===r?0!==s&&4!==s||(i=!0):1===r?1!==s&&2!==s||(i=!0):2===r?2===s&&(i=!0):3===r&&3===s&&(i=!0)),!i){const r=this.findServerInfo(t),s=r?.owningSystemUrl;s&&x(r)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(i=!0)}return i}_getIdenticalSvcIdx(e,t){let r=-1;for(let s=0;s<t.resources.length;s++){const i=t.resources[s];if(this._isIdenticalService(e,i)){r=s;break}}return r}_getSuffix(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")}_getTokenSvcUrl(e){let r,s,i;if(this._isRESTService(e)||this._isAdminResource(e)){const i=this._getServerInstanceRoot(e);return r=i+"/admin/generateToken",s=t(e=i+"/rest/info",{query:{f:"json"}}).then(e=>e.data),{adminUrl:r,promise:s}}if(this._isPortalDomain(e)){let t="";if(this._gwDomains.some(r=>(r.regex.test(e)&&(t=r.tokenServiceUrl),!!t)),t||this._portals.some(r=>(this._hasSameServerInstance(r,e)&&(t=r+this._gwTokenUrl),!!t)),t||(i=e.toLowerCase().indexOf("/sharing"),-1!==i&&(t=e.slice(0,i)+this._gwTokenUrl)),t||(t=this._getOrigin(e)+this._gwTokenUrl),t){const r=new d(e).port;/^http:\/\//i.test(e)&&"7080"===r&&(t=t.replace(/:7080/i,":7443")),t=t.replace(/http:/i,"https:")}return t}}_processOAuthResponseParams(e,t,r){const s=t._oAuthCred;if(e.code){const i=s.codeVerifier;return s.codeVerifier=null,s.stateUID=null,s.save(),this._getOAuthToken(r.server,e.code,t.appId,this._getRedirectURI(t,!0),i).then(i=>{const n=new S({userId:i.username,server:r.server??void 0,token:i.access_token,expires:Date.now()+1e3*i.expires_in,ssl:i.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=n.userId,s.storage=i.persist?T:R,s.refreshToken=i.refresh_token,s.token=null,s.expires=i.refresh_token_expires_in?Date.now()+1e3*i.refresh_token_expires_in:null,s.userId=n.userId,s.ssl=n.ssl,s.save(),n})}const i=new S({userId:e.username,server:r.server??void 0,token:e.access_token,expires:Date.now()+1e3*Number(e.expires_in),ssl:"true"===e.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=i.userId,s.storage=e.persist?T:R,s.refreshToken=null,s.token=i.token,s.expires=i.expires,s.userId=i.userId,s.ssl=i.ssl,s.save(),Promise.resolve(i)}_processOAuthPopupParams(e){const t=this._oAuthDfd;if(this._oAuthDfd=null,t)if(clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle?.remove(),e.error){const s="access_denied"===e.error,i=new r(s?"identity-manager:user-aborted":"identity-manager:authentication-failed",s?"ABORTED":"OAuth: "+e.error+" - "+e.error_description);t.reject(i)}else this._processOAuthResponseParams(e,t.oinfo_,t.sinfo_).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)})}_setOAuthResponseQueryString(e){e&&(e.startsWith("?")&&(e=e.slice(1)),this._processOAuthPopupParams(u(e)))}async _exchangeToken(e,r,s){return(await t(`${e}/sharing/rest/oauth2/exchangeToken`,{authMode:"anonymous",method:"post",query:{f:"json",client_id:r,token:s}})).data.token}async _getPlatformSelf(e,r){if(this._getPlatformSelfError&&Date.now()-this._getPlatformSelfError[1]<1e3)throw this._getPlatformSelfError[0];e=e.replace(/^http:/i,"https:");try{const s=await t(`${e}/sharing/rest/oauth2/platformSelf`,{authMode:"anonymous",headers:{"X-Esri-Auth-Client-Id":r,"X-Esri-Auth-Redirect-Uri":window.location.href.replace(/#.*$/,"")},method:"post",query:{f:"json",expiration:30},withCredentials:!0});return this._getPlatformSelfError=null,s.data}catch(s){throw"OAUTH_0066"===s.details?.messageCode&&(this._getPlatformSelfError=[s,Date.now()]),s}}_getPortalSelf(e,r){let s;if(this._gwDomains.some(t=>(t.regex.test(e)&&(s=t.customBaseUrl),!!s)),s)return Promise.resolve({allSSL:!0,currentVersion:"8.4",customBaseUrl:s,portalMode:"multitenant",supportsOAuth:!0});this._appOrigin.startsWith("https:")?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(r)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080"));return t(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then(e=>e.data)}_doPortalSignIn(e){const t=this._portalConfig,r=window.location.href,s=this.findServerInfo(e);return!(!t&&!this._isPortalDomain(r)||!(s?s.hasPortal||s.owningSystemUrl&&this._isPortalDomain(s.owningSystemUrl):this._isPortalDomain(e))||!(this._isIdProvider(r,e)||t&&(this._hasSameServerInstance(this._getServerInstanceRoot(t.restBaseUrl),e)||this._isIdProvider(t.restBaseUrl,e))||c(r,e,!0)))}_checkProtocol(e,t,s,i){let n=!0;const o=i?t.adminTokenServiceUrl:t.tokenServiceUrl;if(o.trim().toLowerCase().startsWith("https:")&&!this._appOrigin.startsWith("https:")&&g(o)&&(n=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}),!n)){s(new r("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))}return n}_enqueue(e,t,r,s,i,n){return s||(s=Promise.withResolvers()),s.resUrl_=e,s.sinfo_=t,s.options_=r,s.admin_=i,s.refresh_=n,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(s)):this._xoReqs.push(s):this._doSignIn(s),s.promise}_doSignIn(e){this._busy=e,this._rejectOnPersistedPageShow=!1;const t=t=>{const r=e.options_?.resource,s=e.resUrl_,i=e.refresh_;let n=!1;this.credentials.includes(t)||(i&&this.credentials.includes(i)?(i.userId=t.userId,i.token=t.token,i.expires=t.expires,i.validity=t.validity,i.ssl=t.ssl,i.creationTime=t.creationTime,n=!0,t=i):this.credentials.push(t)),t.resources||(t.resources=[]),t.resources.includes(r||s)||t.resources.push(r||s),t.scope=this._isServerRsrc(s)?"server":"portal",t.emitTokenChange();const o=this._soReqs,a={};this._soReqs=[],o.forEach(e=>{if(!this._isIdenticalService(s,e.resUrl_)){const r=this._getSuffix(e.resUrl_);a[r]||(a[r]=!0,t.resources.push(e.resUrl_))}}),e.resolve(t),o.forEach(e=>{this._hasSameServerInstance(this._getServerInstanceRoot(s),e.resUrl_)?e.resolve(t):this._soReqs.push(e)}),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,n||this.emit("credential-create",{credential:t}),this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},s=t=>{e.reject(t),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},n=(o,h,l,d)=>{const u=e.sinfo_,p=!e.options_||!1!==e.options_.prompt,_=u.hasPortal&&this._findOAuthInfo(e.resUrl_);let f,g;if(o)t(new S({userId:o,server:u.server??void 0,token:l??void 0,expires:null!=d?Number(d):null,ssl:!!h}));else if(window!==window.parent&&this._appUrlObj.query?.["arcgis-auth-origin"]&&this._appUrlObj.query?.["arcgis-auth-portal"]&&this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]),e.resUrl_)){window.parent.postMessage({type:"arcgis:auth:requestCredential"},this._appUrlObj.query["arcgis-auth-origin"]);const n=i(window,"message",e=>{e.source===window.parent&&e.data&&("arcgis:auth:credential"===e.data.type?(n.remove(),e.data.credential.expires<Date.now()?s(new r("identity-manager:credential-request-failed","Parent application's token has expired.")):t(new S(e.data.credential))):"arcgis:auth:error"===e.data.type&&(n.remove(),"tokenExpiredError"===e.data.error.name?s(new r("identity-manager:credential-request-failed","Parent application's token has expired.")):s(r.fromJSON(e.data.error))))});a(e.options_?.signal,()=>{n.remove()})}else if(_){let i=_._oAuthCred;if(!i){const e=new I(_,T),t=new I(_,R);e.isValid()&&t.isValid()?e.expires>t.expires?(i=e,t.destroy()):(i=t,e.destroy()):i=e.isValid()?e:t,_._oAuthCred=i}if(i.isValid()){f=new S({userId:i.userId??void 0,server:u.server??void 0,token:i.token??void 0,expires:i.expires,ssl:i.ssl??void 0,_oAuthCred:i});const r=_.appId!==i.appId&&this._doPortalSignIn(e.resUrl_);r||i.refreshToken?(e._pendingDfd=i.refreshToken?this._getOAuthToken(u.server,i.refreshToken,i.appId).then(e=>(f.expires=Date.now()+1e3*e.expires_in,f.token=e.access_token,f)):Promise.resolve(f),e._pendingDfd.then(e=>r?this._exchangeToken(e.server,_.appId,e.token).then(t=>(e.token=t,e)).catch(()=>e):e).then(e=>{t(e)}).catch(e=>{const t=e.details?.httpStatus;t>0&&404!==t?(i.destroy(),n()):s(e)})):t(f)}else if(this._oAuthLocationParams&&this._hasSameServerInstance(_.portalUrl,this._oAuthLocationParams.state.portalUrl)&&(this._oAuthLocationParams.access_token||this._oAuthLocationParams.code&&this._oAuthLocationParams.state.uid===i.stateUID&&i.codeVerifier)){const r=this._oAuthLocationParams;this._oAuthLocationParams=null,e._pendingDfd=this._processOAuthResponseParams(r,_,u).then(e=>{t(e)}).catch(s)}else{const i=()=>{p?e._pendingDfd=this.oAuthSignIn(e.resUrl_,u,_,e.options_).then(t,s):(g=new r("identity-manager:not-authenticated","User is not signed in."),s(g))};this._doPortalSignIn(e.resUrl_)?e._pendingDfd=this._getPlatformSelf(u.server,_.appId).then(e=>{c(e.portalUrl,this._appOrigin,!0)?(f=new S({userId:e.username,server:u.server??void 0,expires:Date.now()+1e3*e.expires_in,token:e.token}),t(f)):i()}).catch(i):i()}}else if(p){if(this._checkProtocol(e.resUrl_,u,s,e.admin_)){let r=e.options_;e.admin_&&(r=r||{},r.isAdmin=!0),e._pendingDfd=this.signIn(e.resUrl_,u,r).then(t,s)}}else g=new r("identity-manager:not-authenticated","User is not signed in."),s(g)},h=()=>{const r=e.sinfo_,i=r.owningSystemUrl,n=e.options_;let o,a,h,l;if(n&&(o=n.token,a=n.error,h=n.prompt),l=this._findCredential(i,{token:o,resource:e.resUrl_}),!l)for(const e of this.credentials)if(this._isIdProvider(i,e.server)){l=e;break}if(l){const i=this.findCredential(e.resUrl_,l.userId);if(i)t(i);else if(O(r,this._legacyFed)){const e=l.toJSON();e.server=r.server,e.resources=null,t(new S(e))}else{(e._pendingDfd=this.generateToken(this.findServerInfo(l.server),null,{serverUrl:e.resUrl_,token:l.token,signal:e.options_.signal,ssl:l.ssl})).then(s=>{t(new S({userId:l?.userId,server:r.server??void 0,token:s.token,expires:null!=s.expires?Number(s.expires):null,ssl:!!s.ssl,isAdmin:e.admin_,validity:s.validity}))},s)}}else{this._busy=null,o&&(e.options_.token=null);(e._pendingDfd=this.getCredential(i.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:r.owningTenant,signal:e.options_.signal,token:o,error:a,prompt:h})).then(()=>{this._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)},t=>{e.resUrl_=e.sinfo_=e.refresh_=null,e.reject(t)})}};this._errbackFunc=s;const l=e.sinfo_.owningSystemUrl,d=this._isServerRsrc(e.resUrl_),u=e.sinfo_._restInfoPms;u?u.promise.then(t=>{const r=e.sinfo_;if(r._restInfoPms){r.adminTokenServiceUrl=r._restInfoPms.adminUrl,r._restInfoPms=null,r.tokenServiceUrl=(o("authInfo.tokenServicesUrl",t)||o("authInfo.tokenServiceUrl",t)||o("tokenServiceUrl",t))??null,r.shortLivedTokenValidity=o("authInfo.shortLivedTokenValidity",t)??null,r.currentVersion=t.currentVersion,r.owningTenant=t.owningTenant;const e=r.owningSystemUrl=t.owningSystemUrl;e&&this._portals.push(e)}d&&r.owningSystemUrl?h():n()},()=>{e.sinfo_._restInfoPms=null;const t=new r("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");s(t)}):d&&l?h():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then(t=>{const r={};let s,i,n,o;return t&&(s=t.user?.username,r.username=s,r.allSSL=t.allSSL,i=t.supportsOAuth,o=parseFloat(t.currentVersion),"multitenant"===t.portalMode&&(n=t.customBaseUrl),e.sinfo_.currentVersion=o),e.sinfo_.webTierAuth=!!s,s&&this.normalizeWebTierAuth?this.generateToken(e.sinfo_,null,{ssl:r.allSSL}).catch(()=>null).then(e=>(r.portalToken=e?.token,r.tokenExpiration=e?.expires,r)):!s&&i&&o>=4.4&&!this._findOAuthInfo(e.resUrl_)?this._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:n,owningTenant:e.sinfo_._selfReq.owningTenant}).catch(()=>null).then(()=>r):r}).catch(()=>null).then(t=>{e.sinfo_._selfReq=null,t?n(t.username,t.allSSL,t.portalToken,t.tokenExpiration):n()}):n()}_generateOAuthInfo(e){let r,s=null,i=e.portalUrl;const n=e.customBaseUrl,o=e.owningTenant,a=!this._defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(a){s=this._appUrlObj.path;const e=s.search(/\/(apps|home)\//);s=e>-1?s.slice(0,e):null}return a&&s?(this._hasTestedIfAppIsOnPortal=!0,r=t(s+"/sharing/rest",{query:{f:"json"}}).then(()=>{this._defaultOAuthInfo=new k({appId:"arcgisonline",popupCallbackUrl:s+"/home/oauth-callback.html"})})):r=Promise.resolve(),r.then(()=>{if(this._defaultOAuthInfo)return i=i.replace(/^http:/i,"https:"),t(i+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:o,client_id:this._defaultOAuthInfo.appId,redirect_uri:m(this._defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then(e=>{if(e.data.valid){const t=this._defaultOAuthInfo.clone();e.data.urlKey&&n?t.portalUrl="https://"+e.data.urlKey.toLowerCase()+"."+n:t.portalUrl=i,t.popup=window!==window.top||!(c(i,this._appOrigin)||this._gwDomains.some(e=>e.regex.test(i)&&e.regex.test(this._appOrigin))),this.oAuthInfos.push(t)}})})}_doOAuthSignIn(e,t,s,n){const o=s._oAuthCred,a={portalUrl:s.portalUrl};!s.popup&&s.preserveUrlHash&&window.location.hash&&(a.hash=window.location.hash),o.stateUID&&(a.uid=o.stateUID);const h={client_id:s.appId,response_type:o.codeVerifier?"code":"token",state:JSON.stringify(a),expiration:s.expiration,locale:s.locale,redirect_uri:this._getRedirectURI(s,!!o.codeVerifier)};s.forceLogin&&(h.force_login=!0),s.forceUserId&&s.userId&&(h.prepopulatedusername=s.userId),!s.popup&&this._doPortalSignIn(e)&&(h.redirectToUserOrgUrl=!0),o.codeVerifier&&(h.code_challenge=n||o.codeVerifier,h.code_challenge_method=n?"S256":"plain");const l=s.portalUrl.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize",c=l+"?"+_(h);if(s.popup){const e=window.open(c,"esriJSAPIOAuth",s.popupWindowFeatures);if(e)e.focus(),this._oAuthDfd.oAuthWin_=e,this._oAuthIntervalId=setInterval(()=>{if(e.closed){clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle.remove();const e=this._oAuthDfd;if(e){const t=new r("identity-manager:user-aborted","ABORTED");e.reject(t)}}},500),this._oAuthOnPopupHandle=i(window,["arcgis:auth:hash","arcgis:auth:location:search"],e=>{"arcgis:auth:hash"===e.type?this.setOAuthResponseHash(e.detail):this._setOAuthResponseQueryString(e.detail)});else{const e=new r("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(e)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:h,authorizeUrl:l,resourceUrl:e,serverInfo:t,oAuthInfo:s}):window.location.href=c}_getRedirectURI(e,t){const r=window.location.href.replace(/#.*$/,"");if(e.popup)return m(e.popupCallbackUrl);if(t){const e=l(r);return e.query&&["code","error","error_description","message_code","persist","state"].forEach(t=>{delete e.query[t]}),v(e.path,e.query)}return r}}C.prototype.declaredClass="esri.identity.IdentityManagerBase";export{C as IdentityManagerBase};
2
+ import e from"../config.js";import t from"../request.js";import r from"../core/Error.js";import{Evented as s}from"../core/Evented.js";import{on as i}from"../core/events.js";import{fixJson as n}from"../core/lang.js";import{getDeepValue as o}from"../core/object.js";import{onAbort as a,isAborted as h}from"../core/promiseUtils.js";import{urlToObject as l,hasSameOrigin as c,Url as d,queryToObject as u,base64UrlEncode as p,objectToQuery as _,normalize as f,getProxyRule as g,makeAbsolute as m,changeDomain as v,addQueryParameters as S}from"../core/urlUtils.js";import w from"./Credential.js";import I from"./IdentityModal.js";import k from"./OAuthCredential.js";import A from"./OAuthInfo.js";import U from"./ServerInfo.js";import{isSecureProxyService as y,normalizeArcGISOnlineOrgDomain as P,parseKnownArcGISOnlineDomain as x}from"../portal/support/urlUtils.js";const O={},T=e=>{const t=new d(e.owningSystemUrl).host,r=new d(e.server).host,s=/.+\.arcgis\.com$/i;return s.test(t)&&s.test(r)},R=(e,t)=>!!(T(e)&&t&&t.some(t=>t.test(e.server)));let C=null,D=null;try{C=window.localStorage,D=window.sessionStorage}catch{}class b extends s{constructor(){super(),this._portalConfig=globalThis.esriGeowConfig,this.serverInfos=[],this.oAuthInfos=[],this.credentials=[],this._soReqs=[],this._xoReqs=[],this._portals=[],this._defaultOAuthInfo=null,this._defaultTokenValidity=60,this.dialog=null,this.tokenValidity=null,this.normalizeWebTierAuth=!1,this._appOrigin="null"!==window.origin?window.origin:window.location.origin,this._appUrlObj=l(window.location.href),this._busy=null,this._rejectOnPersistedPageShow=!1,this._oAuthLocationParams=null,this._gwTokenUrl="/sharing/rest/generateToken",this._agsRest="/rest/services",this._agsPortal=/\/sharing(\/|$)/i,this._agsAdmin=/(https?:\/\/[^/]+\/[^/]+)\/admin\/?(\/.*)?$/i,this._adminSvcs=/\/rest\/admin\/services(\/|$)/i,this._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],this._legacyFed=[],this._regexSDirUrl=/http.+\/rest\/services\/?/gi,this._regexServerType=/(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MissionServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer|VideoServer|3DTilesServer)).*/gi,this._gwUser=/http.+\/users\/([^/]+).*/i,this._gwItem=/http.+\/items\/([^/]+).*/i,this._gwGroup=/http.+\/groups\/([^/]+).*/i,this._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,this._createDefaultOAuthInfo=!0,this._hasTestedIfAppIsOnPortal=!1,this._getPlatformSelfError=null,this._getOAuthLocationParams(),window.addEventListener("pageshow",e=>{this._pageShowHandler(e)})}registerServers(e){const t=this.serverInfos;t?(e=e.filter(e=>!this.findServerInfo(e.server)),this.serverInfos=t.concat(e)):this.serverInfos=e,e.forEach(e=>{e.owningSystemUrl&&this._portals.push(e.owningSystemUrl),e.hasPortal&&this._portals.push(e.server)})}registerOAuthInfos(e){const t=this.oAuthInfos;if(t){for(const r of e){const e=this.findOAuthInfo(r.portalUrl);e&&t.splice(t.indexOf(e),1)}this.oAuthInfos=t.concat(e)}else this.oAuthInfos=e}registerToken(e){e={...e};const t=this._sanitizeUrl(e.server),r=this._isServerRsrc(t);let s,i=this.findServerInfo(t),n=!0;i||(i=new U,i.server=this._getServerInstanceRoot(t),r?i.hasServer=!0:(i.tokenServiceUrl=this._getTokenSvcUrl(t),i.hasPortal=!0),this.registerServers([i])),s=this._findCredential(t),s?(delete e.server,Object.assign(s,e),n=!1):(s=new w({userId:e.userId,server:i.server??void 0,token:e.token,expires:e.expires,ssl:e.ssl,scope:r?"server":"portal"}),s.resources=[t],this.credentials.push(s)),s.emitTokenChange(!1),n||s.refreshServerTokens()}toJSON(){return n({serverInfos:this.serverInfos.map(e=>e.toJSON()),oAuthInfos:this.oAuthInfos.map(e=>e.toJSON()),credentials:this.credentials.map(e=>e.toJSON())})}initialize(e){if(!e)return;"string"==typeof e&&(e=JSON.parse(e));const t=e.serverInfos,r=e.oAuthInfos,s=e.credentials;if(t){const e=[];t.forEach(t=>{t.server&&t.tokenServiceUrl&&e.push(t.declaredClass?t:new U(t))}),e.length&&this.registerServers(e)}if(r){const e=[];r.forEach(t=>{t.appId&&e.push(t.declaredClass?t:new A(t))}),e.length&&this.registerOAuthInfos(e)}s&&s.forEach(e=>{e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new w(e)).emitTokenChange(),this.credentials.push(e))})}findServerInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.serverInfos)if(this._hasSameServerInstance(r.server,e)){t=r;break}return t}findOAuthInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.oAuthInfos)if(this._hasSameServerInstance(r.portalUrl,e)){t=r;break}return t}findCredential(e,t){if(!e)return;let r;e=this._sanitizeUrl(e);const s=this._isServerRsrc(e)?"server":"portal";if(t){for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&t===i.userId&&i.scope===s){r=i;break}}else for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&-1!==this._getIdenticalSvcIdx(e,i)&&i.scope===s){r=i;break}return r}getCredential(e,t){let s,i=!1,n=!0;t&&(i=!(!t.token&&!t.credential),s=t.error,n=!1!==t.prompt),t={...t},e=this._sanitizeUrl(e);const o=new AbortController,l=Promise.withResolvers();if(t.signal&&a(t.signal,()=>{o.abort()}),a(o,()=>{l.reject(new r("identity-manager:user-aborted","ABORTED"))}),h(o))return l.promise;t.signal=o.signal;const d=this._isAdminResource(e),u=i?this.findCredential(e):null;let p;if(u&&498===s?.details?.httpStatus)u.destroy();else if(u)return p=new r("identity-manager:not-authorized","You are currently signed in as: '"+u.userId+"'. You do not have access to this resource: "+e,{error:s}),l.reject(p),l.promise;const _=this._findCredential(e,t);if(_)return l.resolve(_),l.promise;let f=this.findServerInfo(e);if(f)!f.hasPortal&&f.server&&f.owningSystemUrl&&this._hasSameServerInstance(f.server,f.owningSystemUrl)&&(f.hasPortal=!0),!f.hasServer&&this._isServerRsrc(e)&&(f._restInfoPms=this._getTokenSvcUrl(e),f.hasServer=!0);else{const t=this._getTokenSvcUrl(e);if(!t)return p=new r("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),l.reject(p),l.promise;f=new U,f.server=this._getServerInstanceRoot(e),"string"==typeof t?(f.tokenServiceUrl=t,f.hasPortal=!0):(f._restInfoPms=t,f.hasServer=!0),this.registerServers([f])}return f.hasPortal&&void 0===f._selfReq&&(n||c(f.tokenServiceUrl,this._appOrigin)||this._gwDomains.some(e=>e.tokenServiceUrl===f.tokenServiceUrl))&&(f._selfReq={owningTenant:t?.owningTenant,selfDfd:this._getPortalSelf(f.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,f,t,l,d)}getResourceName(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""}generateToken(e,s,i){const n=this._rePortalTokenSvc.test(e.tokenServiceUrl),o=new d(this._appOrigin),a=e.shortLivedTokenValidity;let h,l,u,p,_,f,g,m;s&&(m=this.tokenValidity||a||this._defaultTokenValidity,m>a&&a>0&&(m=a)),i&&(h=i.isAdmin,l=i.serverUrl,u=i.token,f=i.signal,g=i.ssl,e.customParameters=i.customParameters),h?p=e.adminTokenServiceUrl:(p=e.tokenServiceUrl,_=new d(p.toLowerCase()),e.webTierAuth&&i?.serverUrl&&!g&&"http"===o.scheme&&(c(o.uri,p,!0)||"https"===_.scheme&&o.host===_.host&&"7080"===o.port&&"7443"===_.port)&&(p=p.replace(/^https:/i,"http:").replace(/:7443/i,":7080")));const v={query:{request:"getToken",username:s?.username,password:s?.password,serverUrl:l,token:u,expiration:m,referer:h||n?this._appOrigin:null,client:h?"referer":null,f:"json",...e.customParameters},method:"post",authMode:"anonymous",useProxy:this._useProxy(e,i),signal:f};n||(v.withCredentials=!1);return t(p,v).then(t=>{const i=t.data;if(!i?.token)return new r("identity-manager:authentication-failed","Unable to generate token");const n=e.server;return O[n]||(O[n]={}),s&&(O[n][s.username]=s.password),i.validity=m,i})}isBusy(){return!!this._busy}async checkSignInStatus(e){return(await this.checkAppAccess(e,"")).credential}checkAppAccess(e,s,i){let n=!1;return this.getCredential(e,{prompt:!1}).then(o=>{let a;const h={f:"json"};if("portal"===o.scope)if(s&&(this._doPortalSignIn(e)||i?.force))a=o.server+"/sharing/rest/oauth2/validateAppAccess",h.client_id=s;else{if(!o.token)return{credential:o};a=o.server+"/sharing/rest"}else{if(!o.token)return{credential:o};a=o.server+"/rest/services"}return o.token&&(h.token=o.token),t(a,{query:h,authMode:"anonymous"}).then(e=>{if(!1===e.data.valid)throw new r("identity-manager:not-authorized",`You are currently signed in as: '${o.userId}'.`,e.data);return n=!!e.data.viewOnlyUserTypeApp,{credential:o}}).catch(e=>{if("identity-manager:not-authorized"===e.name)throw e;const t=e.details?.httpStatus;if(498===t)throw o.destroy(),new r("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new r("identity-manager:invalid-request","Bad request");return{credential:o}})}).then(e=>({credential:e.credential,viewOnly:n}))}setOAuthResponseHash(e){e&&(e.startsWith("#")&&(e=e.slice(1)),this._processOAuthPopupParams(u(e)))}setOAuthRedirectionHandler(e){this._oAuthRedirectFunc=e}setProtocolErrorHandler(e){this._protocolFunc=e}signIn(e,t,s={}){const i=Promise.withResolvers(),n=()=>{l?.remove(),c?.remove(),this.dialog?.destroy(),this.dialog=l=c=null},o=()=>{n(),this._oAuthDfd=null,i.reject(new r("identity-manager:user-aborted","ABORTED"))};s.signal&&a(s.signal,()=>{o()});const h=new I({open:!0,resource:this.getResourceName(e),server:t.server});this.dialog=h,this.emit("dialog-create");let l=h.on("cancel",o),c=h.on("submit",e=>{this.generateToken(t,e,{isAdmin:s.isAdmin,signal:s.signal}).then(r=>{n();const o=new w({userId:e.username,server:t.server??void 0,token:r.token,expires:null!=r.expires?Number(r.expires):null,ssl:!!r.ssl,isAdmin:s.isAdmin,validity:r.validity});i.resolve(o)}).catch(e=>{h.error=e,h.signingIn=!1})});return i.promise}oAuthSignIn(e,t,s,i){this._oAuthDfd=Promise.withResolvers();const n=this._oAuthDfd;let o;i?.signal&&a(i.signal,()=>{const e=this._oAuthDfd&&this._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():this.dialog&&d()}),n.resUrl_=e,n.sinfo_=t,n.oinfo_=s;const h=s._oAuthCred;if(h.storage&&("authorization-code"===s.flowType||"auto"===s.flowType&&t.currentVersion>=8.4)){let e=crypto.getRandomValues(new Uint8Array(32));o=p(e),h.codeVerifier=o,e=crypto.getRandomValues(new Uint8Array(32)),h.stateUID=p(e),h.save()||(h.codeVerifier=o=null)}else h.codeVerifier=null;let l,c;this._getCodeChallenge(o).then(r=>{const n=!i||!1!==i.oAuthPopupConfirmation;if(!s.popup||!n)return void this._doOAuthSignIn(e,t,s,r);const o=new I({oAuthPrompt:!0,server:t.server,open:!0});this.dialog=o,this.emit("dialog-create"),l=o.on("cancel",d),c=o.on("submit",()=>{u(),this._doOAuthSignIn(e,t,s,r)})});const d=()=>{u(),this._oAuthDfd=null,n.reject(new r("identity-manager:user-aborted","ABORTED"))},u=()=>{l?.remove(),c?.remove(),this.dialog?.destroy(),this.dialog=null};return n.promise}async refreshToken(e){const t=this.findServerInfo(e.server),r=t?.owningSystemUrl,s=!!r&&"server"===e.scope,i=s&&R(t,this._legacyFed),n=t.webTierAuth,o=n&&this.normalizeWebTierAuth,a=O[e.server],h=a?.[e.userId];let l,c=e.resources&&e.resources[0],d=s?this.findServerInfo(r):null,u={username:e.userId,password:h};if(n&&!o)return;s&&!d&&this.serverInfos.some(e=>(this._isIdProvider(r,e.server)&&(d=e),!!d));const p=d?this.findCredential(d.server,e.userId):null;if(!s||p){if(!i){if(s)l={serverUrl:c,token:p?.token,ssl:p?.ssl};else if(o)u=null,l={ssl:e.ssl};else{if(!h){let r;return c&&(c=this._sanitizeUrl(c),e._enqueued=1,r=this._enqueue(c,t,null,null,e.isAdmin,e),r.then(()=>{e._enqueued=0,e.refreshServerTokens()}).catch(()=>{e._enqueued=0})),r}e.isAdmin&&(l={isAdmin:!0})}return this.generateToken(s?d:t,s?null:u,l).then(t=>{e.token=t.token,e.expires=null!=t.expires?Number(t.expires):null,e.creationTime=Date.now(),e.validity=t.validity,e.emitTokenChange(),e.refreshServerTokens()}).catch(()=>{})}p?.refreshToken()}}refreshServerTokens(e){"portal"===e.scope&&this.credentials.forEach(t=>{const r=this.findServerInfo(t.server),s=r?.owningSystemUrl;t!==e&&t.userId===e.userId&&s&&"server"===t.scope&&(this._hasSameServerInstance(e.server,s)||this._isIdProvider(s,e.server))&&(R(r,this._legacyFed)?(t.token=e.token,t.expires=e.expires,t.creationTime=e.creationTime,t.validity=e.validity,t.emitTokenChange()):t.refreshToken())})}destroyCredentials(){if(this.credentials){this.credentials.slice().forEach(e=>{e.destroy()})}this.emit("credentials-destroy")}enablePostMessageAuth(e="https://www.arcgis.com/sharing/rest"){this._postMessageAuthHandle&&this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=i(window,"message",t=>{if((t.origin===this._appOrigin||t.origin.endsWith(".arcgis.com"))&&"arcgis:auth:requestCredential"===t.data?.type){const r=t.source;this.getCredential(e).then(e=>{r.postMessage({type:"arcgis:auth:credential",credential:{expires:e.expires,server:e.server,ssl:e.ssl,token:e.token,userId:e.userId}},t.origin)}).catch(e=>{r.postMessage({type:"arcgis:auth:error",error:{name:e.name,message:e.message}},t.origin)})}})}disablePostMessageAuth(){this._postMessageAuthHandle&&(this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=null)}_getOAuthLocationParams(){let e=window.location.hash;if(e){e.startsWith("#")&&(e=e.slice(1));const t=u(e);let r=!1;if(t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username"))try{t.state=JSON.parse(t.state),t.state.portalUrl&&(this._oAuthLocationParams=t,r=!0)}catch{}else if(t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0,t.state)))try{t.state=JSON.parse(t.state)}catch{}r&&(window.location.hash=t.state?.hash||"")}let t=window.location.search;if(t){t.startsWith("?")&&(t=t.slice(1));const e=u(t);let r=!1;if(e.code&&e.state)try{e.state=JSON.parse(e.state),e.state.portalUrl&&e.state.uid&&(this._oAuthLocationParams=e,r=!0)}catch{}else if(e.error&&e.error_description&&(console.log("IdentityManager OAuth Error: ",e.error," - ",e.error_description),"access_denied"===e.error&&(r=!0,e.state)))try{e.state=JSON.parse(e.state)}catch{}if(r){const t={...e};["code","error","error_description","message_code","persist","state"].forEach(e=>{delete t[e]});const r=_(t),s=window.location.pathname+(r?`?${r}`:"")+(e.state?.hash||"");window.history.replaceState(window.history.state,"",s)}}}_getOAuthToken(e,r,s,i,n){return e=e.replace(/^http:/i,"https:"),t(`${e}/sharing/rest/oauth2/token`,{authMode:"anonymous",method:"post",query:i&&n?{grant_type:"authorization_code",code:r,redirect_uri:i,client_id:s,code_verifier:n}:{grant_type:"refresh_token",refresh_token:r,client_id:s}}).then(e=>e.data)}async _getCodeChallenge(e){if(e&&globalThis.isSecureContext){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return p(new Uint8Array(r))}return null}_pageShowHandler(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){const e=new r("identity-manager:user-aborted","ABORTED");this._errbackFunc(e)}}_findCredential(e,t){let r,s,i,n,o=-1;const a=t?.token,h=t?.resource,l=this._isServerRsrc(e)?"server":"portal",c=this.credentials.filter(t=>this._hasSameServerInstance(t.server,e)&&t.scope===l);if(e=h||e,c.length)if(1===c.length){if(r=c[0],i=this.findServerInfo(r.server),s=i?.owningSystemUrl,n=s?this.findCredential(s,r.userId):void 0,o=this._getIdenticalSvcIdx(e,r),!a)return-1===o&&r.resources.push(e),this._addResource(e,n),r;-1!==o&&(r.resources.splice(o,1),this._removeResource(e,n))}else{let t,r;if(c.some(a=>(r=this._getIdenticalSvcIdx(e,a),-1!==r&&(t=a,i=this.findServerInfo(t.server),s=i?.owningSystemUrl,n=s?this.findCredential(s,t.userId):void 0,o=r,!0))),a)t&&(t.resources.splice(o,1),this._removeResource(e,n));else if(t)return this._addResource(e,n),t}}_findOAuthInfo(e){let t=this.findOAuthInfo(e);if(!t)for(const r of this.oAuthInfos)if(this._isIdProvider(r.portalUrl,e)){t=r;break}return t}_addResource(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)}_removeResource(e,t){let r=-1;t&&(r=this._getIdenticalSvcIdx(e,t),r>-1&&t.resources.splice(r,1))}_useProxy(e,t){return t?.isAdmin&&!c(e.adminTokenServiceUrl,this._appOrigin)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!c(e.tokenServiceUrl,this._appOrigin)}_getOrigin(e){const t=new d(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")}_getServerInstanceRoot(e){const t=e.toLowerCase();let r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1!==r||y(t)||(r=t.indexOf("/sharing")),-1===r&&t.endsWith("/")&&(r=t.length-1),r>-1?e.slice(0,r):e}_hasSameServerInstance(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=P(e),t=P(t),(e=e.slice(Math.max(0,e.indexOf(":"))))===(t=t.slice(Math.max(0,t.indexOf(":"))))}_sanitizeUrl(t){const r=(e.request.proxyUrl||"").toLowerCase(),s=r?t.toLowerCase().indexOf(r+"?"):-1;return-1!==s&&(t=t.slice(s+r.length+1)),t=f(t),l(t).path}_isRESTService(e){return e.includes(this._agsRest)}_isAdminResource(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)}_isServerRsrc(e){return this._isRESTService(e)||this._isAdminResource(e)}_isIdenticalService(e,t){let r=!1;if(this._isRESTService(e)&&this._isRESTService(t)){const s=this._getSuffix(e).toLowerCase(),i=this._getSuffix(t).toLowerCase();if(r=s===i,!r){const e=/(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;r=s.replaceAll(e,"$1")===i.replaceAll(e,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r}_isPortalDomain(t){const r=new d(t.toLowerCase()),s=this._portalConfig;let i=this._gwDomains.some(e=>e.regex.test(r.uri));return!i&&s&&(i=this._hasSameServerInstance(this._getServerInstanceRoot(s.restBaseUrl),r.uri)),i||e.portalUrl&&(i=c(r,e.portalUrl,!0)),i||(i=this._portals.some(e=>this._hasSameServerInstance(e,r.uri))),i=i||this._agsPortal.test(r.path),i}_isIdProvider(e,t){let r=-1,s=-1;this._gwDomains.forEach((i,n)=>{-1===r&&i.regex.test(e)&&(r=n),-1===s&&i.regex.test(t)&&(s=n)});let i=!1;if(r>-1&&s>-1&&(0===r||4===r?0!==s&&4!==s||(i=!0):1===r?1!==s&&2!==s||(i=!0):2===r?2===s&&(i=!0):3===r&&3===s&&(i=!0)),!i){const r=this.findServerInfo(t),s=r?.owningSystemUrl;s&&T(r)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(i=!0)}return i}_getIdenticalSvcIdx(e,t){let r=-1;for(let s=0;s<t.resources.length;s++){const i=t.resources[s];if(this._isIdenticalService(e,i)){r=s;break}}return r}_getSuffix(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")}_getTokenSvcUrl(e){let r,s,i;if(this._isRESTService(e)||this._isAdminResource(e)){const i=this._getServerInstanceRoot(e);return r=i+"/admin/generateToken",s=t(e=i+"/rest/info",{query:{f:"json"}}).then(e=>e.data),{adminUrl:r,promise:s}}if(this._isPortalDomain(e)){let t="";if(this._gwDomains.some(r=>(r.regex.test(e)&&(t=r.tokenServiceUrl),!!t)),t||this._portals.some(r=>(this._hasSameServerInstance(r,e)&&(t=r+this._gwTokenUrl),!!t)),t||(i=e.toLowerCase().indexOf("/sharing"),-1!==i&&(t=e.slice(0,i)+this._gwTokenUrl)),t||(t=this._getOrigin(e)+this._gwTokenUrl),t){const r=new d(e).port;/^http:\/\//i.test(e)&&"7080"===r&&(t=t.replace(/:7080/i,":7443")),t=t.replace(/http:/i,"https:")}return t}}_processOAuthResponseParams(e,t,r){const s=t._oAuthCred;if(e.code){const i=s.codeVerifier;return s.codeVerifier=null,s.stateUID=null,s.save(),this._getOAuthToken(r.server,e.code,t.appId,this._getRedirectURI(t,!0),i).then(i=>{const n=new w({userId:i.username,server:r.server??void 0,token:i.access_token,expires:Date.now()+1e3*i.expires_in,ssl:i.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=n.userId,s.storage=i.persist?C:D,s.refreshToken=i.refresh_token,s.token=null,s.expires=i.refresh_token_expires_in?Date.now()+1e3*i.refresh_token_expires_in:null,s.userId=n.userId,s.ssl=n.ssl,s.save(),n})}const i=new w({userId:e.username,server:r.server??void 0,token:e.access_token,expires:Date.now()+1e3*Number(e.expires_in),ssl:"true"===e.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=i.userId,s.storage=e.persist?C:D,s.refreshToken=null,s.token=i.token,s.expires=i.expires,s.userId=i.userId,s.ssl=i.ssl,s.save(),Promise.resolve(i)}_processOAuthPopupParams(e){const t=this._oAuthDfd;if(this._oAuthDfd=null,t)if(clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle?.remove(),e.error){const s="access_denied"===e.error,i=new r(s?"identity-manager:user-aborted":"identity-manager:authentication-failed",s?"ABORTED":"OAuth: "+e.error+" - "+e.error_description);t.reject(i)}else this._processOAuthResponseParams(e,t.oinfo_,t.sinfo_).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)})}_setOAuthResponseQueryString(e){e&&(e.startsWith("?")&&(e=e.slice(1)),this._processOAuthPopupParams(u(e)))}async _exchangeToken(e,r,s){return(await t(`${e}/sharing/rest/oauth2/exchangeToken`,{authMode:"anonymous",method:"post",query:{f:"json",client_id:r,token:s}})).data.token}async _getPlatformSelf(e,r){if(this._getPlatformSelfError&&Date.now()-this._getPlatformSelfError[1]<1e3)throw this._getPlatformSelfError[0];e=e.replace(/^http:/i,"https:");try{const s=await t(`${e}/sharing/rest/oauth2/platformSelf`,{authMode:"anonymous",headers:{"X-Esri-Auth-Client-Id":r,"X-Esri-Auth-Redirect-Uri":window.location.href.replace(/#.*$/,"")},method:"post",query:{f:"json",expiration:30},withCredentials:!0});return this._getPlatformSelfError=null,s.data}catch(s){throw"OAUTH_0066"===s.details?.messageCode&&(this._getPlatformSelfError=[s,Date.now()]),s}}_getPortalSelf(e,r){let s;if(this._gwDomains.some(t=>(t.regex.test(e)&&(s=t.customBaseUrl),!!s)),s)return Promise.resolve({allSSL:!0,currentVersion:"8.4",customBaseUrl:s,portalMode:"multitenant",supportsOAuth:!0});this._appOrigin.startsWith("https:")?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(r)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080"));return t(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then(e=>e.data)}_doPortalSignIn(e){const t=this._portalConfig,r=window.location.href,s=this.findServerInfo(e);return!(!t&&!this._isPortalDomain(r)||!(s?s.hasPortal||s.owningSystemUrl&&this._isPortalDomain(s.owningSystemUrl):this._isPortalDomain(e))||!(this._isIdProvider(r,e)||t&&(this._hasSameServerInstance(this._getServerInstanceRoot(t.restBaseUrl),e)||this._isIdProvider(t.restBaseUrl,e))||c(r,e,!0)))}_checkProtocol(e,t,s,i){let n=!0;const o=i?t.adminTokenServiceUrl:t.tokenServiceUrl;if(o.trim().toLowerCase().startsWith("https:")&&!this._appOrigin.startsWith("https:")&&g(o)&&(n=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}),!n)){s(new r("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))}return n}_enqueue(e,t,r,s,i,n){return s||(s=Promise.withResolvers()),s.resUrl_=e,s.sinfo_=t,s.options_=r,s.admin_=i,s.refresh_=n,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(s)):this._xoReqs.push(s):this._doSignIn(s),s.promise}_doSignIn(e){this._busy=e,this._rejectOnPersistedPageShow=!1;const t=t=>{const r=e.options_?.resource,s=e.resUrl_,i=e.refresh_;let n=!1;this.credentials.includes(t)||(i&&this.credentials.includes(i)?(i.userId=t.userId,i.token=t.token,i.expires=t.expires,i.validity=t.validity,i.ssl=t.ssl,i.creationTime=t.creationTime,n=!0,t=i):this.credentials.push(t)),t.resources||(t.resources=[]),t.resources.includes(r||s)||t.resources.push(r||s),t.scope=this._isServerRsrc(s)?"server":"portal",t.emitTokenChange();const o=this._soReqs,a={};this._soReqs=[],o.forEach(e=>{if(!this._isIdenticalService(s,e.resUrl_)){const r=this._getSuffix(e.resUrl_);a[r]||(a[r]=!0,t.resources.push(e.resUrl_))}}),e.resolve(t),o.forEach(e=>{this._hasSameServerInstance(this._getServerInstanceRoot(s),e.resUrl_)?e.resolve(t):this._soReqs.push(e)}),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,n||this.emit("credential-create",{credential:t}),this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},s=t=>{e.reject(t),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},n=(o,h,l,d)=>{const u=e.sinfo_,p=!e.options_||!1!==e.options_.prompt,_=u.hasPortal&&this._findOAuthInfo(e.resUrl_);let f,g;if(o)t(new w({userId:o,server:u.server??void 0,token:l??void 0,expires:null!=d?Number(d):null,ssl:!!h}));else if(window!==window.parent&&this._appUrlObj.query?.["arcgis-auth-origin"]&&this._appUrlObj.query?.["arcgis-auth-portal"]&&this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]),e.resUrl_)){window.parent.postMessage({type:"arcgis:auth:requestCredential"},this._appUrlObj.query["arcgis-auth-origin"]);const n=i(window,"message",e=>{e.source===window.parent&&e.data&&("arcgis:auth:credential"===e.data.type?(n.remove(),e.data.credential.expires<Date.now()?s(new r("identity-manager:credential-request-failed","Parent application's token has expired.")):t(new w(e.data.credential))):"arcgis:auth:error"===e.data.type&&(n.remove(),"tokenExpiredError"===e.data.error.name?s(new r("identity-manager:credential-request-failed","Parent application's token has expired.")):s(r.fromJSON(e.data.error))))});a(e.options_?.signal,()=>{n.remove()})}else if(_){let i=_._oAuthCred;if(!i){const e=new k(_,C),t=new k(_,D);e.isValid()&&t.isValid()?e.expires>t.expires?(i=e,t.destroy()):(i=t,e.destroy()):i=e.isValid()?e:t,_._oAuthCred=i}if(i.isValid()){f=new w({userId:i.userId??void 0,server:u.server??void 0,token:i.token??void 0,expires:i.expires,ssl:i.ssl??void 0,_oAuthCred:i});const r=_.appId!==i.appId&&this._doPortalSignIn(e.resUrl_);r||i.refreshToken?(e._pendingDfd=i.refreshToken?this._getOAuthToken(u.server,i.refreshToken,i.appId).then(e=>(f.expires=Date.now()+1e3*e.expires_in,f.token=e.access_token,f)):Promise.resolve(f),e._pendingDfd.then(e=>r?this._exchangeToken(e.server,_.appId,e.token).then(t=>(e.token=t,e)).catch(()=>e):e).then(e=>{t(e)}).catch(e=>{const t=e.details?.httpStatus;t>0&&404!==t?(i.destroy(),n()):s(e)})):t(f)}else if(this._oAuthLocationParams&&this._hasSameServerInstance(_.portalUrl,this._oAuthLocationParams.state.portalUrl)&&(this._oAuthLocationParams.access_token||this._oAuthLocationParams.code&&this._oAuthLocationParams.state.uid===i.stateUID&&i.codeVerifier)){const r=this._oAuthLocationParams;this._oAuthLocationParams=null,e._pendingDfd=this._processOAuthResponseParams(r,_,u).then(e=>{t(e)}).catch(s)}else{const i=()=>{p?e._pendingDfd=this.oAuthSignIn(e.resUrl_,u,_,e.options_).then(t,s):(g=new r("identity-manager:not-authenticated","User is not signed in."),s(g))};this._doPortalSignIn(e.resUrl_)?e._pendingDfd=this._getPlatformSelf(u.server,_.appId).then(e=>{c(e.portalUrl,this._appOrigin,!0)?(f=new w({userId:e.username,server:u.server??void 0,expires:Date.now()+1e3*e.expires_in,token:e.token}),t(f)):i()}).catch(i):i()}}else if(p){if(this._checkProtocol(e.resUrl_,u,s,e.admin_)){let r=e.options_;e.admin_&&(r=r||{},r.isAdmin=!0),e._pendingDfd=this.signIn(e.resUrl_,u,r).then(t,s)}}else g=new r("identity-manager:not-authenticated","User is not signed in."),s(g)},h=()=>{const r=e.sinfo_,i=r.owningSystemUrl,n=e.options_;let o,a,h,l;if(n&&(o=n.token,a=n.error,h=n.prompt),l=this._findCredential(i,{token:o,resource:e.resUrl_}),!l)for(const e of this.credentials)if(this._isIdProvider(i,e.server)){l=e;break}if(l){const i=this.findCredential(e.resUrl_,l.userId);if(i)t(i);else if(R(r,this._legacyFed)){const e=l.toJSON();e.server=r.server,e.resources=null,t(new w(e))}else{(e._pendingDfd=this.generateToken(this.findServerInfo(l.server),null,{serverUrl:e.resUrl_,token:l.token,signal:e.options_.signal,ssl:l.ssl})).then(s=>{t(new w({userId:l?.userId,server:r.server??void 0,token:s.token,expires:null!=s.expires?Number(s.expires):null,ssl:!!s.ssl,isAdmin:e.admin_,validity:s.validity}))},s)}}else{this._busy=null,o&&(e.options_.token=null);(e._pendingDfd=this.getCredential(i.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:r.owningTenant,signal:e.options_.signal,token:o,error:a,prompt:h})).then(()=>{this._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)},t=>{e.resUrl_=e.sinfo_=e.refresh_=null,e.reject(t)})}};this._errbackFunc=s;const l=e.sinfo_.owningSystemUrl,d=this._isServerRsrc(e.resUrl_),u=e.sinfo_._restInfoPms;u?u.promise.then(t=>{const r=e.sinfo_;if(r._restInfoPms){r.adminTokenServiceUrl=r._restInfoPms.adminUrl,r._restInfoPms=null,r.tokenServiceUrl=(o("authInfo.tokenServicesUrl",t)||o("authInfo.tokenServiceUrl",t)||o("tokenServiceUrl",t))??null,r.shortLivedTokenValidity=o("authInfo.shortLivedTokenValidity",t)??null,r.currentVersion=t.currentVersion,r.owningTenant=t.owningTenant;const e=r.owningSystemUrl=t.owningSystemUrl;e&&this._portals.push(e)}d&&r.owningSystemUrl?h():n()},()=>{e.sinfo_._restInfoPms=null;const t=new r("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");s(t)}):d&&l?h():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then(t=>{const r={};let s,i,n,o;return t&&(s=t.user?.username,r.username=s,r.allSSL=t.allSSL,i=t.supportsOAuth,o=parseFloat(t.currentVersion),"multitenant"===t.portalMode&&(n=t.customBaseUrl),e.sinfo_.currentVersion=o),e.sinfo_.webTierAuth=!!s,s&&this.normalizeWebTierAuth?this.generateToken(e.sinfo_,null,{ssl:r.allSSL}).catch(()=>null).then(e=>(r.portalToken=e?.token,r.tokenExpiration=e?.expires,r)):!s&&i&&o>=4.4&&!this._findOAuthInfo(e.resUrl_)?this._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:n,owningTenant:e.sinfo_._selfReq.owningTenant}).catch(()=>null).then(()=>r):r}).catch(()=>null).then(t=>{e.sinfo_._selfReq=null,t?n(t.username,t.allSSL,t.portalToken,t.tokenExpiration):n()}):n()}_generateOAuthInfo(e){let r,s=null,i=e.portalUrl;const n=e.customBaseUrl,o=e.owningTenant,a=!this._defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(a){s=this._appUrlObj.path;const e=s.search(/\/(apps|home)\//);s=e>-1?s.slice(0,e):null}return a&&s?(this._hasTestedIfAppIsOnPortal=!0,r=t(s+"/sharing/rest",{query:{f:"json"}}).then(()=>{this._defaultOAuthInfo=new A({appId:"arcgisonline",popupCallbackUrl:s+"/home/oauth-callback.html"})})):r=Promise.resolve(),r.then(()=>{if(this._defaultOAuthInfo)return i=i.replace(/^http:/i,"https:"),t(i+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:o,client_id:this._defaultOAuthInfo.appId,redirect_uri:m(this._defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then(e=>{if(e.data.valid){const t=this._defaultOAuthInfo.clone();e.data.urlKey&&n?t.portalUrl="https://"+e.data.urlKey.toLowerCase()+"."+n:t.portalUrl=i,t.popup=window!==window.top||!(c(i,this._appOrigin)||this._gwDomains.some(e=>e.regex.test(i)&&e.regex.test(this._appOrigin))),this.oAuthInfos.push(t)}})})}_doOAuthSignIn(e,t,s,n){const o=s._oAuthCred,a={portalUrl:s.portalUrl};!s.popup&&s.preserveUrlHash&&window.location.hash&&(a.hash=window.location.hash),o.stateUID&&(a.uid=o.stateUID);const h={client_id:s.appId,response_type:o.codeVerifier?"code":"token",state:JSON.stringify(a),expiration:s.expiration,locale:s.locale,redirect_uri:this._getRedirectURI(s,!!o.codeVerifier)};s.forceLogin&&(h.force_login=!0),s.forceUserId&&s.userId&&(h.prepopulatedusername=s.userId),!s.popup&&this._doPortalSignIn(e)&&(h.redirectToUserOrgUrl=!0),o.codeVerifier&&(h.code_challenge=n||o.codeVerifier,h.code_challenge_method=n?"S256":"plain");const l=this._getAuthorizeUrl(s.portalUrl),c=l+"?"+_(h);if(s.popup){const e=window.open(c,"esriJSAPIOAuth",s.popupWindowFeatures);if(e)e.focus(),this._oAuthDfd.oAuthWin_=e,this._oAuthIntervalId=setInterval(()=>{if(e.closed){clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle.remove();const e=this._oAuthDfd;if(e){const t=new r("identity-manager:user-aborted","ABORTED");e.reject(t)}}},500),this._oAuthOnPopupHandle=i(window,["arcgis:auth:hash","arcgis:auth:location:search"],e=>{"arcgis:auth:hash"===e.type?this.setOAuthResponseHash(e.detail):this._setOAuthResponseQueryString(e.detail)});else{const e=new r("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(e)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:h,authorizeUrl:l,resourceUrl:e,serverInfo:t,oAuthInfo:s}):window.location.href=c}_getAuthorizeUrl(e){let t=e.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize";const r=x(t);if(r?.portalHostname){const{customBaseUrl:e,portalHostname:s,urlKey:i}=r;let n=null;if("www.arcgis.com"===s||"devext.arcgis.com"===s&&(n="logindevext.arcgis.com"),n){t=v(t,i?`${i}.${e}`:s,i?`${i}.${n}`:n)}}return t}_getRedirectURI(e,t){const r=window.location.href.replace(/#.*$/,"");if(e.popup)return m(e.popupCallbackUrl);if(t){const e=l(r);return e.query&&["code","error","error_description","message_code","persist","state"].forEach(t=>{delete e.query[t]}),S(e.path,e.query)}return r}}b.prototype.declaredClass="esri.identity.IdentityManagerBase";export{b as IdentityManagerBase};
package/kernel.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.1";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.1.0-next.73",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
2
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.1";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.1.0-next.75",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import r from"../core/Error.js";import has from"../core/has.js";import i from"../core/Logger.js";import{MultiOriginJSONSupportMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as a}from"../core/promiseUtils.js";import{on as n,sync as l}from"../core/reactiveUtils.js";import{property as p,subclass as m}from"../core/accessorSupport/decorators.js";import{persistable as c}from"../core/accessorSupport/decorators/persistable.js";import d from"../geometry/Extent.js";import u from"../geometry/SpatialReference.js";import h from"./Layer.js";import{APIKeyMixin as f}from"./mixins/APIKeyMixin.js";import{ArcGISService as y}from"./mixins/ArcGISService.js";import{CustomParametersMixin as g}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as S}from"./mixins/OperationalLayer.js";import{PortalLayer as _}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as j}from"./mixins/ScaleRangeLayer.js";import{elevationInfo as v,url as T}from"./support/commonProperties.js";import w from"./support/SceneModifications.js";import{default3DTilesSpatialReference as b,default3DTilesFullExtent as L,initFullExtent as x}from"./support/tiles3DUtils.js";import P from"../portal/Portal.js";import{logInvalidElevationInfoWarning as I,elevationModeRequiredMessage as k,featureExpressionUnsupportedMessage as R}from"../support/elevationInfoUtils.js";import{f as D}from"../chunks/persistableUrlUtils.js";import{isBasemap as U}from"../support/userTypeGuards/isBasemap.js";import{initialize as E,switchMeshModificationPolygonVCSSync as O}from"../views/3d/layers/Lyr3DWorker.js";import{toWasmModification as M,fromWasmModification as q}from"../views/3d/layers/SceneLayerWorkerHandle.js";import{reader as A}from"../core/accessorSupport/decorators/reader.js";let G=class extends(y(S(_(j(s(g(f(o(h))))))))){readModifications(e,t,o){this._modificationsSource={url:D(e,o),context:o}}initialize(){this.addHandles(n(()=>this.modifications,"after-changes",()=>this.modifications=this.modifications,l))}constructor(e){super(e),this.operationalLayerType="IntegratedMesh3DTilesLayer",this.modifications=null,this._modificationsSource=null,this.spatialReference=b,this.fullExtent=L,this.url=null,this.type="integrated-mesh-3dtiles",this.path=null,this.minScale=0,this.maxScale=0,this._rootTilesetJSON=null,this._rootTileset=null,this._key=null,this._session=null,this._rootRequestPromise=null,this.queryElevationCallback=null}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}async load(e){return this.addResolvingPromise(this._doLoad(e)),this}get rootTilesetJSON(){return this._rootTilesetJSON}get rootTileset(){return this._rootTileset}get key(){return this._key}get session(){return this._session}_findSessionParameter(e){const t=[e];for(;t?.length>0;){const e=t.pop();if(!e)return;for(const[r,i]of Object.entries(e)){if("uri"===r)try{const e=new URL("https://tmp"+i).searchParams.get("session");if(e)return e}catch(o){}"object"==typeof i&&null!==i&&t.push(i)}}return null}async requestRootAndSession(e){const o=(e,t)=>new r("3dtiles-init:"+e,t);return this._rootRequestPromise||(this._rootRequestPromise=new Promise((r,s)=>{this.url||s(o("url-missing","Layer url missing")),this._key=this.customParameters?this.customParameters.key:null;new Promise((e,r)=>{if(this.replacesTerrain&&!this._key){const i=this.portalItem?.portal||this.parent?.portalItem?.portal||P.getDefault();i.signIn().then(()=>{i.g3dTilesEnabled?t(i.restUrl+"/portals/self/modules/g3dtiles",{responseType:"json",query:{f:"json"}}).then(t=>{this._key=t.data.keyString,e()},()=>r(o("g3dtiles-key-error","Error fetching Google 3D Tiles key from portal"))):r(o("g3dTilesEnabled-false","Google 3D Tiles are not enabled on Portal "+i.url))},()=>r(o("sign-in-failed","Error signing in to Portal")))}else e()}).then(()=>{t(this.url,{query:this._key?{key:this._key,token:this.apiKey}:{token:this.apiKey},responseType:"array-buffer",signal:e}).then(e=>{try{this._rootTilesetJSON=JSON.parse((new TextDecoder).decode(e.data))}catch(t){return void s(o("root-parse-failed","Error parsing root tile, details: "+t))}this._rootTilesetJSON?(this._session=this._findSessionParameter(this._rootTilesetJSON),this._rootTileset=e.data,this.fullExtent=x(this._rootTilesetJSON),r(),this._rootRequestPromise=null):s(o("root-is-null","Root tile is null."))},e=>{a(e),s(o("root-load-failed","Error loading root tile")),this._rootRequestPromise=null,i.getLogger("IntegratedMesh3DTilesLayer").error("Layer loading failed",e)})},e=>s(e))})),this._rootRequestPromise}async _doLoad(e){const t=null!=e?e.signal:null;if(this.isUsedAsGroundLayer&&!has("enable-feature:basemap-groundlayers"))throw new r("3dtiles-init:not-supported-in-groundlayers","Layer is not supported in basemap.");try{await this.loadFromPortal({supportedTypes:["3DTiles Service"],validateItem:e=>{if(e.typeKeywords?.includes("IntegratedMesh"))return!0;throw new r("portal:invalid-layer-item-type","Invalid layer item, expected '${expectedType}' ",{expectedType:"3DTiles Service containing IntegratedMesh"})}},e)}catch(o){a(o)}if(null!=this._modificationsSource){const t=await w.fromUrl(this._modificationsSource.url,this.spatialReference,e);if(t&&t.length>0){await E();try{const e=M(null,t.toArray(),this.spatialReference),o=O({modifications:e,inVCS:115700});o.success&&o.modifications&&q(o.modifications,t)}catch(s){i.getLogger(this).error("convert-mesh-modification-z-error","Error when converting:",s)}null!=this._modificationsSource&&this.setAtOrigin("modifications",t,this._modificationsSource.context.origin),this._modificationsSource=null}}await this.requestRootAndSession(t)}async beforeSave(){if(null==this._modificationsSource){const{modifications:e}=this;return void(e&&e.length>0&&await E())}await this.load().then(()=>{},()=>{})}get hasAttributionData(){return!1}_validateElevationInfo(e){const t="Integrated mesh 3d tiles layers";I(i.getLogger(this),k(t,"absolute-height",e)),I(i.getLogger(this),R(t,e))}get replacesTerrain(){return!!has("enable-feature:basemap-groundlayers")&&this.hasGoogleUrl&&this.isUsedAsGroundLayer}get isUsedAsGroundLayer(){return U(this.parent)}get hasGoogleUrl(){return!!this.url?.match(/.+\.googleapis.com/)}};e([p({type:["IntegratedMesh3DTilesLayer"]})],G.prototype,"operationalLayerType",void 0),e([p({type:w,clonable:e=>e?.clone()??null}),c({origins:["web-scene","portal-item"],type:"resource",prefix:"modifications"})],G.prototype,"modifications",void 0),e([A(["web-scene","portal-item"],"modifications")],G.prototype,"readModifications",null),e([p({type:u})],G.prototype,"spatialReference",void 0),e([p({type:d})],G.prototype,"fullExtent",void 0),e([p(v)],G.prototype,"elevationInfo",null),e([p({type:["show","hide"]})],G.prototype,"listMode",void 0),e([p(T)],G.prototype,"url",void 0),e([p({readOnly:!0})],G.prototype,"type",void 0),e([p({type:String,json:{origins:{"web-scene":{read:!0,write:!0},"portal-item":{read:!0,write:!0}},read:!1}})],G.prototype,"path",void 0),e([p({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],G.prototype,"minScale",void 0),e([p({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],G.prototype,"maxScale",void 0),e([p({readOnly:!0})],G.prototype,"hasAttributionData",null),e([p()],G.prototype,"replacesTerrain",null),e([p()],G.prototype,"isUsedAsGroundLayer",null),e([p()],G.prototype,"hasGoogleUrl",null),G=e([m("esri.layers.IntegratedMesh3DTilesLayer")],G);const N=G;export{N as default};
2
+ import{__decorate as e}from"tslib";import t from"../request.js";import{ClonableMixin as o}from"../core/Clonable.js";import r from"../core/Error.js";import has from"../core/has.js";import i from"../core/Logger.js";import{MultiOriginJSONSupportMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as a}from"../core/promiseUtils.js";import{on as n,sync as l}from"../core/reactiveUtils.js";import{property as p,subclass as m}from"../core/accessorSupport/decorators.js";import{persistable as c}from"../core/accessorSupport/decorators/persistable.js";import d from"../geometry/Extent.js";import u from"../geometry/SpatialReference.js";import h from"./Layer.js";import{APIKeyMixin as f}from"./mixins/APIKeyMixin.js";import{ArcGISService as y}from"./mixins/ArcGISService.js";import{CustomParametersMixin as g}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as S}from"./mixins/OperationalLayer.js";import{PortalLayer as _}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as v}from"./mixins/ScaleRangeLayer.js";import{elevationInfo as j,url as T}from"./support/commonProperties.js";import w from"./support/SceneModifications.js";import{default3DTilesSpatialReference as b,default3DTilesFullExtent as L,initFullExtent as x}from"./support/tiles3DUtils.js";import P from"../portal/Portal.js";import{logInvalidElevationInfoWarning as I,elevationModeRequiredMessage as k,featureExpressionUnsupportedMessage as R}from"../support/elevationInfoUtils.js";import{f as D}from"../chunks/persistableUrlUtils.js";import{isBasemap as U}from"../support/userTypeGuards/isBasemap.js";import{initialize as E,switchMeshModificationPolygonVCSSync as O}from"../views/3d/layers/Lyr3DWorker.js";import{toWasmModification as M,fromWasmModification as q}from"../views/3d/layers/SceneLayerWorkerHandle.js";import{reader as A}from"../core/accessorSupport/decorators/reader.js";let G=class extends(y(S(_(v(s(g(f(o(h))))))))){readModifications(e,t,o){this._modificationsSource={url:D(e,o),context:o}}initialize(){this.addHandles(n(()=>this.modifications,"after-changes",()=>this.modifications=this.modifications,l))}constructor(e){super(e),this.operationalLayerType="IntegratedMesh3DTilesLayer",this.modifications=null,this._modificationsSource=null,this.spatialReference=b,this.fullExtent=L,this.url=null,this.type="integrated-mesh-3dtiles",this.path=null,this.minScale=0,this.maxScale=0,this._rootTilesetJSON=null,this._rootTileset=null,this._key=null,this._session=null,this._rootRequestPromise=null,this.queryElevationCallback=null}set elevationInfo(e){null!=e&&"absolute-height"!==e.mode||this._set("elevationInfo",e),this._validateElevationInfo(e)}async load(e){return this.addResolvingPromise(this._doLoad(e)),this}get rootTilesetJSON(){return this._rootTilesetJSON}get rootTileset(){return this._rootTileset}get key(){return this._key}get session(){return this._session}_findSessionParameter(e){const t=[e];for(;t?.length>0;){const e=t.pop();if(!e)return;for(const[r,i]of Object.entries(e)){if("uri"===r)try{const e=new URL("https://tmp"+i).searchParams.get("session");if(e)return e}catch(o){}"object"==typeof i&&null!==i&&t.push(i)}}return null}async requestRootAndSession(e){const o=(e,t)=>new r("3dtiles-init:"+e,t);return this._rootRequestPromise||(this._rootRequestPromise=new Promise((r,s)=>{this.url||s(o("url-missing","Layer url missing")),this._key=this.customParameters?this.customParameters.key:null;new Promise((e,r)=>{if(this.replacesTerrain&&!this._key){const i=this.portalItem?.portal||this.parent?.portalItem?.portal||P.getDefault();i.signIn().then(()=>{i.g3dTilesEnabled?t(i.restUrl+"/portals/self/modules/g3dtiles",{responseType:"json",query:{f:"json"}}).then(t=>{this._key=t.data.keyString,e()},()=>r(o("g3dtiles-key-error","Error fetching Google 3D Tiles key from portal"))):r(o("g3dTilesEnabled-false","Google 3D Tiles are not enabled on Portal "+i.url))},()=>r(o("sign-in-failed","Error signing in to Portal")))}else e()}).then(()=>{t(this.url,{query:this._key?{key:this._key,token:this.apiKey}:{token:this.apiKey},responseType:"array-buffer",signal:e}).then(e=>{try{this._rootTilesetJSON=JSON.parse((new TextDecoder).decode(e.data))}catch(t){return void s(o("root-parse-failed","Error parsing root tile, details: "+t))}this._rootTilesetJSON?(this._session=this._findSessionParameter(this._rootTilesetJSON),this._rootTileset=e.data,this.fullExtent=x(this._rootTilesetJSON),r(),this._rootRequestPromise=null):s(o("root-is-null","Root tile is null."))},e=>{a(e),s(o("root-load-failed","Error loading root tile")),this._rootRequestPromise=null,i.getLogger("IntegratedMesh3DTilesLayer").error("Layer loading failed",e)})},e=>s(e))})),this._rootRequestPromise}async _doLoad(e){const t=null!=e?e.signal:null;if(this.isUsedAsGroundLayer&&!has("enable-feature:basemap-groundlayers"))throw new r("3dtiles-init:not-supported-in-groundlayers","Layer is not supported in basemap.");try{await this.loadFromPortal({supportedTypes:["3DTiles Service"],validateItem:e=>{if(e.typeKeywords?.includes("IntegratedMesh"))return!0;throw new r("portal:invalid-layer-item-type","Invalid layer item, expected '${expectedType}' ",{expectedType:"3DTiles Service containing IntegratedMesh"})}},e)}catch(o){a(o)}if(null!=this._modificationsSource){const t=await w.fromUrl(this._modificationsSource.url,this.spatialReference,e);if(t&&t.length>0){await E();try{const e=M(null,t.toArray(),this.spatialReference),o=O({modifications:e,inVCS:115700});o.success&&o.modifications&&q(o.modifications,t)}catch(s){i.getLogger(this).error("convert-mesh-modification-z-error","Error when converting:",s)}null!=this._modificationsSource&&this.setAtOrigin("modifications",t,this._modificationsSource.context.origin),this._modificationsSource=null}}await this.requestRootAndSession(t)}async beforeSave(){if(null==this._modificationsSource){const{modifications:e}=this;return void(e&&e.length>0&&await E())}await this.load().then(()=>{},()=>{})}get hasAttributionData(){return!1}_validateElevationInfo(e){const t="Integrated mesh 3d tiles layers";I(i.getLogger(this),k(t,"absolute-height",e)),I(i.getLogger(this),R(t,e))}get replacesTerrain(){return!!has("enable-feature:basemap-groundlayers")&&this.hasGoogleUrl&&this.isUsedAsGroundLayer}get isUsedAsGroundLayer(){return U(this.parent)}get hasGoogleUrl(){return!!this.url?.match(/.+\.googleapis.com/)}};e([p({type:["IntegratedMesh3DTilesLayer"]})],G.prototype,"operationalLayerType",void 0),e([p({type:w,clonable:e=>e?.clone()??null}),c({origins:["web-scene","portal-item"],type:"resource",prefix:"modifications"})],G.prototype,"modifications",void 0),e([p({clonable:e=>e?{...e}:null})],G.prototype,"_modificationsSource",void 0),e([A(["web-scene","portal-item"],"modifications")],G.prototype,"readModifications",null),e([p({type:u})],G.prototype,"spatialReference",void 0),e([p({type:d})],G.prototype,"fullExtent",void 0),e([p(j)],G.prototype,"elevationInfo",null),e([p({type:["show","hide"]})],G.prototype,"listMode",void 0),e([p(T)],G.prototype,"url",void 0),e([p({readOnly:!0})],G.prototype,"type",void 0),e([p({type:String,json:{origins:{"web-scene":{read:!0,write:!0},"portal-item":{read:!0,write:!0}},read:!1}})],G.prototype,"path",void 0),e([p({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],G.prototype,"minScale",void 0),e([p({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],G.prototype,"maxScale",void 0),e([p({readOnly:!0})],G.prototype,"hasAttributionData",null),e([p()],G.prototype,"replacesTerrain",null),e([p()],G.prototype,"isUsedAsGroundLayer",null),e([p()],G.prototype,"hasGoogleUrl",null),G=e([m("esri.layers.IntegratedMesh3DTilesLayer")],G);const N=G;export{N as default};