@arcgis/core 4.23.0-next.20220124 → 4.23.0-next.20220126

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 (217) hide show
  1. package/Graphic.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/00c5bb5eecb0e89266df.js +1 -0
  4. package/assets/esri/core/workers/chunks/021a37e2b191298e80b7.js +1 -0
  5. package/assets/esri/core/workers/chunks/1370c92c40fd6271553c.js +1 -0
  6. package/assets/esri/core/workers/chunks/1fbcc8424452d0256bd6.js +1 -0
  7. package/assets/esri/core/workers/chunks/{fe864d01e72aa24574b6.js → 23b15e7c2f96d260e16c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{b2ae5fc4f787ea568b88.js → 2460f3b6ada6ae900dec.js} +1 -1
  9. package/assets/esri/core/workers/chunks/2792ca40f1e92849247c.js +1 -0
  10. package/assets/esri/core/workers/chunks/2a96f1bba9ce6883e5e0.js +1 -0
  11. package/assets/esri/core/workers/chunks/2e899ef5881b4ec6fa55.js +1 -0
  12. package/assets/esri/core/workers/chunks/3231ee3e090bb4cac3fc.js +1 -0
  13. package/assets/esri/core/workers/chunks/{0c3e3a5baf54bd5e210c.js → 36e250278b5622ccf068.js} +1 -1
  14. package/assets/esri/core/workers/chunks/395ba088d4864588ff66.js +1 -0
  15. package/assets/esri/core/workers/chunks/3cc77692b2eee27b9c9e.js +1 -0
  16. package/assets/esri/core/workers/chunks/3f343f792fd9f44d6f25.js +1 -0
  17. package/assets/esri/core/workers/chunks/422537fc3df707bb62c9.js +1 -0
  18. package/assets/esri/core/workers/chunks/{625d2663daa8e0cf64b0.js → 434b16731c6a81f868ef.js} +1 -1
  19. package/assets/esri/core/workers/chunks/4385a268c2a64281d1c1.js +1 -0
  20. package/assets/esri/core/workers/chunks/{44b01d42d4ec72913229.js → 438f0b5ae5c53ae4f06a.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{4d539878bfbd7c549e60.js → 46b4bb66a54bbd8e2e57.js} +1 -1
  22. package/assets/esri/core/workers/chunks/4c76146014dc15143ba3.js +1 -0
  23. package/assets/esri/core/workers/chunks/5d991b74d958005c26c4.js +1 -0
  24. package/assets/esri/core/workers/chunks/5dfe1f8d520025e2118b.js +1 -0
  25. package/assets/esri/core/workers/chunks/601e697dc7414bda128a.js +1 -0
  26. package/assets/esri/core/workers/chunks/{9cdaba126ac7fa5f33f0.js → 6cd5e4380d29b9a3c344.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{a7b1b75643ed31489495.js → 6f50a9647f026a8d4729.js} +1 -1
  28. package/assets/esri/core/workers/chunks/7d661129a0d8c466eeec.js +1 -0
  29. package/assets/esri/core/workers/chunks/{64276aacaafa4c8a15bd.js → 7dcf52d3db3903c8eb9f.js} +1 -1
  30. package/assets/esri/core/workers/chunks/8070972c0efb78523b68.js +1 -0
  31. package/assets/esri/core/workers/chunks/94515fb3ef38067eeadd.js +1 -0
  32. package/assets/esri/core/workers/chunks/97a28641b3b2fd31bea2.js +1 -0
  33. package/assets/esri/core/workers/chunks/{d1454155ee1b8a421cbb.js → 97ec9eef0048760fa260.js} +1 -1
  34. package/assets/esri/core/workers/chunks/98986e6601b0366376b4.js +1 -0
  35. package/assets/esri/core/workers/chunks/9cdcf9309d6feda70185.js +1 -0
  36. package/assets/esri/core/workers/chunks/aa04b90b82bf70caaae4.js +1 -0
  37. package/assets/esri/core/workers/chunks/aace7e1fef256bb961c9.js +1 -0
  38. package/assets/esri/core/workers/chunks/{c080114a69fa95b88d22.js → af5694b4d278cf1db2d9.js} +1 -1
  39. package/assets/esri/core/workers/chunks/afbb4f802ca5774f0326.js +1 -0
  40. package/assets/esri/core/workers/chunks/b2c5f92e3d7606297ca9.js +1 -0
  41. package/assets/esri/core/workers/chunks/b2d2de935487257c568b.js +1 -0
  42. package/assets/esri/core/workers/chunks/b2ebe4f6d100e15b512d.js +1 -0
  43. package/assets/esri/core/workers/chunks/b8316c6469a543029bc6.js +1 -0
  44. package/assets/esri/core/workers/chunks/{4c9084a04948b6924749.js → ba5eb394f098968c22d2.js} +1 -1
  45. package/assets/esri/core/workers/chunks/bf0a65b4be31959f921d.js +1 -0
  46. package/assets/esri/core/workers/chunks/c890c7fca27170e3341f.js +1 -0
  47. package/assets/esri/core/workers/chunks/c976785f2391c77d8a30.js +1 -0
  48. package/assets/esri/core/workers/chunks/{d39b7983b68d6e5b404d.js → cdbc005eebec1503b99d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/e4b84ca8ddfd48dd79b1.js +1 -0
  50. package/assets/esri/core/workers/chunks/e4e2036373166c1d5cf5.js +1 -0
  51. package/assets/esri/core/workers/chunks/e4f93c55eaefab4192b5.js +1 -0
  52. package/assets/esri/core/workers/chunks/e6165e17fbb07bfc40a1.js +1 -0
  53. package/assets/esri/core/workers/chunks/e9e5196b44b6923be1a3.js +1 -0
  54. package/assets/esri/core/workers/chunks/{f678293de9a6d8f5b5db.js → ec89466f76d0ba22525e.js} +1 -1
  55. package/assets/esri/core/workers/chunks/ee45618c45806ab654cb.js +1 -0
  56. package/assets/esri/core/workers/chunks/f4baa5ea2e42b1317941.js +1 -0
  57. package/assets/esri/core/workers/chunks/f760a3e030b0f358a92a.js +1 -0
  58. package/assets/esri/core/workers/chunks/face43cf5abcd2f5bd9d.js +1 -0
  59. package/assets/esri/themes/base/_mixins.scss +4 -1
  60. package/assets/esri/themes/base/icons/style.scss +11 -2
  61. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +13 -10
  62. package/assets/esri/themes/base/widgets/_CoordinateConversion.scss +4 -2
  63. package/assets/esri/themes/base/widgets/_Directions.scss +5 -3
  64. package/assets/esri/themes/base/widgets/_Editor.scss +5 -2
  65. package/assets/esri/themes/base/widgets/_ElevationProfile.scss +6 -4
  66. package/assets/esri/themes/base/widgets/_ItemList.scss +1 -1
  67. package/assets/esri/themes/base/widgets/_LayerList.scss +13 -9
  68. package/assets/esri/themes/base/widgets/_Popup.scss +4 -2
  69. package/assets/esri/themes/base/widgets/_Print.scss +24 -11
  70. package/assets/esri/themes/base/widgets/_Search.scss +4 -2
  71. package/assets/esri/themes/base/widgets/_TableList.scss +9 -7
  72. package/assets/esri/themes/base/widgets/_Weather.scss +12 -0
  73. package/assets/esri/themes/base/widgets/_Widget.scss +18 -9
  74. package/assets/esri/themes/dark/main.css +1 -1
  75. package/assets/esri/themes/dark-blue/main.css +1 -1
  76. package/assets/esri/themes/dark-green/main.css +1 -1
  77. package/assets/esri/themes/dark-purple/main.css +1 -1
  78. package/assets/esri/themes/dark-red/main.css +1 -1
  79. package/assets/esri/themes/light/main.css +1 -1
  80. package/assets/esri/themes/light/view.css +1 -1
  81. package/assets/esri/themes/light-blue/main.css +1 -1
  82. package/assets/esri/themes/light-green/main.css +1 -1
  83. package/assets/esri/themes/light-purple/main.css +1 -1
  84. package/assets/esri/themes/light-red/main.css +1 -1
  85. package/assets/esri/widgets/Weather/t9n/Weather.json +1 -1
  86. package/assets/esri/widgets/Weather/t9n/Weather_en.json +1 -1
  87. package/chunks/ComponentShader.glsl.js +19 -19
  88. package/chunks/Terrain.glsl.js +11 -11
  89. package/chunks/WaterSurface.glsl.js +21 -21
  90. package/chunks/pe.js +1 -1
  91. package/chunks/vec3.js +1 -1
  92. package/core/accessorSupport/read.js +1 -1
  93. package/core/accessorSupport/write.js +1 -1
  94. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  95. package/geometry/pe.js +1 -1
  96. package/geometry/support/axisAngleDegrees.js +1 -1
  97. package/interfaces.d.ts +36 -2
  98. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  99. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  100. package/package.json +2 -2
  101. package/popup/content/AttachmentsContent.js +1 -1
  102. package/popup/content/support/mediaInfoTypes.js +1 -1
  103. package/support/revision.js +1 -1
  104. package/symbols/LabelSymbol3D.js +1 -1
  105. package/symbols/PointSymbol3D.js +1 -1
  106. package/symbols/cim/CIMSymbolHelper.js +1 -1
  107. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  108. package/symbols/cim/cimAnalyzer.js +1 -1
  109. package/symbols/support/Symbol3DVerticalOffset.js +1 -1
  110. package/symbols/support/previewCIMSymbol.js +1 -1
  111. package/symbols/support/previewSymbol2D.js +1 -1
  112. package/symbols/support/previewSymbol3D.js +1 -1
  113. package/symbols/support/previewWebStyleSymbol.js +1 -1
  114. package/symbols/support/svgUtils.js +1 -1
  115. package/symbols.js +1 -1
  116. package/views/2d/engine/webgl/brushes/raster/BrushRasterBitmap.js +1 -1
  117. package/views/2d/engine/webgl/mesh/templates/WGLFillTemplate.js +1 -1
  118. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  119. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  120. package/views/3d/environment/CloudsComposition.js +1 -1
  121. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  122. package/views/3d/environment/Fog.js +1 -1
  123. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  124. package/views/3d/environment/weather.js +1 -1
  125. package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateMeshAdapter.js +1 -1
  126. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  127. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  128. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  129. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  130. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  131. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  132. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  133. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  134. package/views/3d/terrain/OverlayRenderer.js +1 -1
  135. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +21 -13
  136. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +2 -2
  137. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  138. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  139. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  140. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  141. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  142. package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
  143. package/views/interactive/dragEventPipeline.js +1 -1
  144. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  145. package/views/webgl/Program.js +1 -1
  146. package/views/webgl/rasterUtils.js +1 -1
  147. package/widgets/Attachments.js +1 -1
  148. package/widgets/FeatureForm/InputField.js +1 -1
  149. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  150. package/widgets/Popup/PopupViewModel.js +1 -1
  151. package/widgets/Popup/actionUtils.js +1 -1
  152. package/widgets/Slice/SliceViewModel.js +1 -1
  153. package/widgets/Slider/SliderViewModel.js +1 -1
  154. package/widgets/Slider.js +1 -1
  155. package/widgets/Weather/WeatherViewModel.js +1 -1
  156. package/widgets/Weather/css.js +1 -1
  157. package/widgets/Weather.js +1 -1
  158. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  159. package/widgets/support/InteractiveToolViewModel.js +1 -1
  160. package/assets/components/assets/calcite-icon/checkSquareF16.json +0 -1
  161. package/assets/components/assets/calcite-icon/checkSquareF24.json +0 -1
  162. package/assets/components/assets/calcite-icon/checkSquareF32.json +0 -1
  163. package/assets/components/assets/calcite-icon/lineSolid4.json +0 -1
  164. package/assets/components/assets/calcite-icon/squareF16.json +0 -1
  165. package/assets/components/assets/calcite-icon/squareF24.json +0 -1
  166. package/assets/components/assets/calcite-icon/squareF32.json +0 -1
  167. package/assets/components/assets/calcite-icon/xHexagon16.json +0 -1
  168. package/assets/components/assets/calcite-icon/xHexagon24.json +0 -1
  169. package/assets/components/assets/calcite-icon/xHexagon32.json +0 -1
  170. package/assets/components/assets/calcite-icon/xHexagonF16.json +0 -1
  171. package/assets/components/assets/calcite-icon/xHexagonF24.json +0 -1
  172. package/assets/components/assets/calcite-icon/xHexagonF32.json +0 -1
  173. package/assets/components/assets/calcite-icon/xOctagonF16.json +0 -1
  174. package/assets/components/assets/calcite-icon/xOctagonF24.json +0 -1
  175. package/assets/components/assets/calcite-icon/xOctagonF32.json +0 -1
  176. package/assets/esri/core/workers/chunks/09da224052976e290828.js +0 -1
  177. package/assets/esri/core/workers/chunks/0bf079e752ab79468478.js +0 -1
  178. package/assets/esri/core/workers/chunks/20411bb8e04703962ce6.js +0 -1
  179. package/assets/esri/core/workers/chunks/23745a5ab47c840dc452.js +0 -1
  180. package/assets/esri/core/workers/chunks/2416f8bf8bbd2ec786ab.js +0 -1
  181. package/assets/esri/core/workers/chunks/2e445a8735ea2adb641a.js +0 -1
  182. package/assets/esri/core/workers/chunks/32f8c4af7e70ebdcb19e.js +0 -1
  183. package/assets/esri/core/workers/chunks/390d9021169e65c10eb8.js +0 -1
  184. package/assets/esri/core/workers/chunks/3a9740dccda6a733313c.js +0 -1
  185. package/assets/esri/core/workers/chunks/43cdff2418325e163420.js +0 -1
  186. package/assets/esri/core/workers/chunks/5538639a49c7cc2eca63.js +0 -1
  187. package/assets/esri/core/workers/chunks/60371c0f750cde87656d.js +0 -1
  188. package/assets/esri/core/workers/chunks/67162b3e2cc1b5dc6818.js +0 -1
  189. package/assets/esri/core/workers/chunks/739e579150bf466d43ae.js +0 -1
  190. package/assets/esri/core/workers/chunks/74df1f3e1e2e524a89d2.js +0 -1
  191. package/assets/esri/core/workers/chunks/76eef4799f6c5fff7e2d.js +0 -1
  192. package/assets/esri/core/workers/chunks/7baf6b1f3f050aa67ae4.js +0 -1
  193. package/assets/esri/core/workers/chunks/8967288145f8fbd20e7d.js +0 -1
  194. package/assets/esri/core/workers/chunks/99a777693e4539f0b03b.js +0 -1
  195. package/assets/esri/core/workers/chunks/9cb2ae42a8e328b1d98d.js +0 -1
  196. package/assets/esri/core/workers/chunks/9d3c58a0ef634d95b7bd.js +0 -1
  197. package/assets/esri/core/workers/chunks/a6ff3db3493543df81bc.js +0 -1
  198. package/assets/esri/core/workers/chunks/a8c13529367c037cdd94.js +0 -1
  199. package/assets/esri/core/workers/chunks/a96afc176041f698c7a1.js +0 -1
  200. package/assets/esri/core/workers/chunks/ac8dca61ade28c542ae2.js +0 -1
  201. package/assets/esri/core/workers/chunks/afa6912454f2a5ffadce.js +0 -1
  202. package/assets/esri/core/workers/chunks/b2beb6e1fd2ee6503830.js +0 -1
  203. package/assets/esri/core/workers/chunks/bab1cfd0a901181622af.js +0 -1
  204. package/assets/esri/core/workers/chunks/be2b7cce79fd41627931.js +0 -1
  205. package/assets/esri/core/workers/chunks/c13dfdd548dcb1bdb294.js +0 -1
  206. package/assets/esri/core/workers/chunks/c6bd943fe8fd13bb4806.js +0 -1
  207. package/assets/esri/core/workers/chunks/c6f94b92e866b881d9b9.js +0 -1
  208. package/assets/esri/core/workers/chunks/cd7d83d127e085d52584.js +0 -1
  209. package/assets/esri/core/workers/chunks/d52108864136c5a8a618.js +0 -1
  210. package/assets/esri/core/workers/chunks/da1c2873bdbc0956dca0.js +0 -1
  211. package/assets/esri/core/workers/chunks/de03439ca2c9782bf325.js +0 -1
  212. package/assets/esri/core/workers/chunks/e079cb1d53aca15b7df2.js +0 -1
  213. package/assets/esri/core/workers/chunks/e6df9839b551569fbc62.js +0 -1
  214. package/assets/esri/core/workers/chunks/e97e986120aaadad7d4c.js +0 -1
  215. package/assets/esri/core/workers/chunks/f8e7755240a94b499e1f.js +0 -1
  216. package/assets/esri/core/workers/chunks/fd3e5d823dc7917f4b8f.js +0 -1
  217. package/views/3d/layers/graphics/IGraphics3DFeatureProcessor.js +0 -4
package/interfaces.d.ts CHANGED
@@ -2209,7 +2209,7 @@ declare namespace __esri {
2209
2209
  */
2210
2210
  domain: CodedValueDomain | RangeDomain;
2211
2211
  /**
2212
- * Indicates whether the field can be edited.
2212
+ * A Boolean determining whether users can edit this form element.
2213
2213
  *
2214
2214
  * @default true
2215
2215
  *
@@ -2292,7 +2292,7 @@ declare namespace __esri {
2292
2292
  */
2293
2293
  domain?: (CodedValueDomainProperties & { type: "coded-value" }) | (RangeDomainProperties & { type: "range" });
2294
2294
  /**
2295
- * Indicates whether the field can be edited.
2295
+ * A Boolean determining whether users can edit this form element.
2296
2296
  *
2297
2297
  * @default true
2298
2298
  *
@@ -25473,6 +25473,8 @@ declare namespace __esri {
25473
25473
  /**
25474
25474
  * A string value indicating how to display an attachment.
25475
25475
  *
25476
+ * @default "auto"
25477
+ *
25476
25478
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-AttachmentsContent.html#displayType)
25477
25479
  */
25478
25480
  displayType: "auto" | "preview" | "list";
@@ -25514,6 +25516,8 @@ declare namespace __esri {
25514
25516
  /**
25515
25517
  * A string value indicating how to display an attachment.
25516
25518
  *
25519
+ * @default "auto"
25520
+ *
25517
25521
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-AttachmentsContent.html#displayType)
25518
25522
  */
25519
25523
  displayType?: "auto" | "preview" | "list";
@@ -91050,6 +91054,24 @@ declare namespace __esri {
91050
91054
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#draggableSegmentsEnabled)
91051
91055
  */
91052
91056
  draggableSegmentsEnabled: boolean;
91057
+ /**
91058
+ * TODO
91059
+ *
91060
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#effectiveMax)
91061
+ */
91062
+ effectiveMax: number;
91063
+ /**
91064
+ * TODO
91065
+ *
91066
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#effectiveMin)
91067
+ */
91068
+ effectiveMin: number;
91069
+ /**
91070
+ * TODO
91071
+ *
91072
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#effectiveSegmentElements)
91073
+ */
91074
+ readonly effectiveSegmentElements: Collection<HTMLElement>;
91053
91075
  /**
91054
91076
  * A function that provides the developer with access to the input elements when [rangeLabelInputsEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#rangeLabelInputsEnabled) and/or [labelInputsEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#labelInputsEnabled) are set to `true`.
91055
91077
  *
@@ -91273,6 +91295,18 @@ declare namespace __esri {
91273
91295
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#draggableSegmentsEnabled)
91274
91296
  */
91275
91297
  draggableSegmentsEnabled?: boolean;
91298
+ /**
91299
+ * TODO
91300
+ *
91301
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#effectiveMax)
91302
+ */
91303
+ effectiveMax?: number;
91304
+ /**
91305
+ * TODO
91306
+ *
91307
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#effectiveMin)
91308
+ */
91309
+ effectiveMin?: number;
91276
91310
  /**
91277
91311
  * A function that provides the developer with access to the input elements when [rangeLabelInputsEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#rangeLabelInputsEnabled) and/or [labelInputsEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Slider.html#labelInputsEnabled) are set to `true`.
91278
91312
  *
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import r from"../../../core/Error.js";import{JSONSupport as i}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{isSome as n,isNone as s,unwrap as a}from"../../../core/maybe.js";import{EsriPromiseMixin as l}from"../../../core/Promise.js";import{onAbort as c}from"../../../core/promiseUtils.js";import{property as f}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as u}from"../arcgisLayerUrl.js";import{url as m}from"../commonProperties.js";import d from"../RasterStorageInfo.js";import p from"../TileInfo.js";import{getRasterId as x,getBlock as g,putBlock as y,deleteBlock as I,decreaseRefCount as w}from"./RawBlockCache.js";import{decode as R}from"../rasterFormats/RasterCodec.js";import{mosaic as k,approximateTransform as v}from"../rasterFunctions/pixelUtils.js";import{load as b,getWorldWidth as T,projectPoint as M,snapPyramid as S,snapExtent as B,getWorldWrapCount as C,projectExtent as P,getProjectionOffsetGrid as W,getRasterDatasetAlignmentInfo as _,projectResolution as H}from"../rasterFunctions/rasterProjectionHelper.js";import{uvComponentToVector as j}from"../rasterFunctions/vectorFieldUtils.js";import F from"../../../geometry/Extent.js";import E from"../../../geometry/Point.js";const A=8;let L=class extends(l(i)){constructor(){super(...arguments),this.rasterJobHandler=null,this.datasetName=null,this.datasetFormat=null,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=b();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:p.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=T(e.spatialReference);return n(t)&&e.extent.width>=t/2}set url(e){this._set("url",u(e,o.getLogger(this.declaredClass)))}async open(e){throw new r("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,r,i={}){const o=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,r,o);return this.fetchPixels(n,o.size[0],o.size[1],i)}async identify(e,t={}){t=this._getRequestOptionsWithSliceId(t);const{spatialReference:r,extent:i}=this.rasterInfo,{datumTransformation:o}=t;let a=M(e,r,o);if(!i.intersects(a))return{location:a,value:null};if(n(this.rasterInfo.transform)){const e=this.rasterInfo.transform.inverseTransform(a);if(!this.rasterInfo.nativeExtent.intersects(e))return{location:e,value:null};a=e}let l=0;if(t.srcResolution){l=S(t.srcResolution,this.rasterInfo,this.ioConfig.sampling).pyramidLevel}else if(l=await this.computeBestPyramidLevelForLocation(e,t),null==l)return{location:a,value:null};const c=this.identifyPixelLocation(a,l,null);if(null===c)return{location:a,value:null};const{row:f,col:h,rowOffset:u,colOffset:m}=c,d=x(this.url,t.sliceId),p=`${l}/${f}/${h}`;let I=g(d,null,p);s(I)&&(I=this.fetchRawTile(l,f,h,t),y(d,null,p,I));const w=await I;if(s(w)||!w.pixels||0===w.pixels.length)return{location:a,value:null};const R=u*this.rasterInfo.storageInfo.blockHeight+m,k=!w.mask||w.mask[R]?w.pixels.map((e=>e[R])):null,v=this.rasterInfo.dataType;if(("vector-magdir"===v||"vector-uv"===v)&&(null==k?void 0:k.length)>1){return{location:a,value:k,magdirValue:"vector-magdir"===v?[k[0],k[1]]:j([k[0],k[1]]),pyramidLevel:l}}return{location:a,value:k,pyramidLevel:l}}async fetchPixels(e,t,r,i={}){if(e=B(e),(i=this._getRequestOptionsWithSliceId(i)).requestRawData)return this._fetchPixels(e,t,r,i);const o=T(e.spatialReference),n=C(e);if(s(o)||0===n||1===n&&this._isGlobalWrappableSource)return this._fetchPixels(e,t,r,i);if(n>=3)return{extent:e,pixelBlock:null};const a=[],{xmin:l,xmax:c}=e,f=Math.round(o/(c-l)*t),h=f-Math.round((o/2-l)/(c-l)*t);let u=0;const m=[];for(let s=0;s<=n;s++){const d=new F({xmin:0===s?l:-o/2,xmax:s===n?c-o*s:o/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===s?f-h:s===n?t-u:f;u+=p,m.push(p);const x=i.disableWrapAround&&s>0?null:this._fetchPixels(d,p,r,i);a.push(x)}const d=(await Promise.all(a)).map((e=>null==e?void 0:e.pixelBlock));let p=null;const x={width:t,height:r};p=this.rasterJobHandler?await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:m},i):k(d,x,{blockWidths:m});return{extent:e,srcExtent:P(e,this.rasterInfo.spatialReference,i.datumTransformation),pixelBlock:p}}async fetchRawPixels(e,t,r,i={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,r,i),{nativeExtent:s,nativePixelSize:a,storageInfo:l}=this.rasterInfo,c=2**e,f=a.x*c,h=a.y*c,u=new F({xmin:s.xmin+f*t.x,xmax:s.xmin+f*(t.x+r.width-1),ymin:s.ymax-h*(t.y+r.height-1),ymax:s.ymax-h*t.y,spatialReference:s.spatialReference});if(!o)return{extent:u,srcExtent:u,pixelBlock:null};const{pixelBlocks:m}=o;if(1===m.length&&n(m[0])&&m[0].width===r.width&&m[0].height===r.height)return{extent:u,srcExtent:u,pixelBlock:o.pixelBlocks[0]};const d=e>0?l.pyramidBlockWidth:l.blockWidth,p=e>0?l.pyramidBlockHeight:l.blockHeight,x={width:Math.ceil(r.width/d)*d,height:Math.ceil(r.height/p)*p},g={x:t.x%d,y:t.y%p};let y;return y=this.rasterJobHandler?await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:m,srcMosaicSize:r,destDimension:r,clipOffset:g,clipSize:r,coefs:null,sampleSpacing:null,interpolation:i.interpolation,alignmentInfo:null,blockWidths:null},i):k(m,x,{clipOffset:g,clipSize:r}),{extent:u,srcExtent:u,pixelBlock:y}}fetchRawTile(e,t,i,o){throw new r("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return P(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?R(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,r,i){var o,n;const{customFetchParameters:s}=this.ioConfig,{range:a,query:l,headers:c}=r;i=null!=(o=null!=(n=i)?n:r.retryCount)?o:this.ioConfig.retryCount;const f=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...r,query:{...l,...s},headers:{...c,...f}})}catch(h){if(i>0)return i--,this.request(e,r,i);throw h}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;if(!n(t))return null;if(!n(e)||0===e.length)return null;let r=0;const i=e[0].variableName;for(let o=0;o<t.variables.length;o++){const n=t.variables[o],s=n.dimensions;if(n.name!==i){r+=s.map((e=>this._getDimensionValuesCount(e))).reduce(((e,t)=>e+t));break}const a=s.map((e=>this._getDimensionValuesCount(e))),l=s.length;for(let t=0;t<l;t++){const i=e.filter((e=>e.dimensionName===s[t].name))[0];if(null==i)return null;const o=Array.isArray(i.values[0])?i.values[0][0]:i.values[0],n=this._getIndexFromDimensions(o,s[t]);if(-1===n)return null;a.shift(),r+=t===l-1?n:n*a.reduce(((e,t)=>e+t))}}return r}getTileExtentFromTileInfo(e,t,r,i){const o=i.lodAt(e);return this.getTileExtent({x:o.resolution,y:o.resolution},t,r,i.origin,i.spatialReference,i.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:r,pixelSize:i}=this.rasterInfo;if(!e.tileInfo){const o=[],n=e.maximumPyramidLevel||0;let s=Math.max(i.x,i.y),a=1/.0254*96*s;for(let e=0;e<=n;e++)o.push({level:n-e,resolution:s,scale:a}),s*=2,a*=2;const l=new E({x:r.xmin,y:r.ymax,spatialReference:t});e.tileInfo=new p({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:o}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,r=512,i){const{width:o,height:n,nativeExtent:s,pixelSize:a,spatialReference:l}=e,c=new E({x:s.xmin,y:s.ymax,spatialReference:l});null==i&&(i=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const f=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[a],i);e.storageInfo=new d({blockWidth:t,blockHeight:r,pyramidBlockWidth:t,pyramidBlockHeight:r,origin:c,firstPyramidLevel:1,maximumPyramidLevel:i,blockBoundary:f})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,r,i,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let r=0;r<n;r++)e*=s,t*=s,o.push({x:e,y:t})}const a=[],{x:l,y:c}=i;for(let f=0;f<o.length;f++){const{x:i,y:n}=o[f];a.push({minCol:Math.floor((e.xmin-l+.1*i)/t/i),maxCol:Math.floor((e.xmax-l-.1*i)/t/i),minRow:Math.floor((c-e.ymax+.1*n)/r/n),maxRow:Math.floor((c-e.ymin-.1*n)/r/n)})}return a}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:r,pyramidScalingFactor:i}=this.rasterInfo.storageInfo;if(0===e)return t;if(n(r)&&r.length)return r[e-1];const o=i**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,r){const{spatialReference:i,nativeExtent:o}=this.rasterInfo,{blockWidth:n,blockHeight:s,maximumPyramidLevel:a,origin:l}=this.rasterInfo.storageInfo,c=M(e,i,r);if(!o.intersects(c))return null;if(t<0||t>a)return null;const f=this.getPyramidPixelSize(t),{x:h,y:u}=f,m=(l.y-c.y)/u/s,d=(c.x-l.x)/h/n,p=Math.min(s-1,Math.floor((m-Math.floor(m))*s)),x=Math.min(n-1,Math.floor((d-Math.floor(d))*n));return{pyramidLevel:t,row:Math.floor(m),col:Math.floor(d),rowOffset:p,colOffset:x,srcLocation:c}}getTileExtent(e,t,r,i,o,n){const[s,a]=n,l=i.x+r*s*e.x,c=l+s*e.x,f=i.y-t*a*e.y,h=f-a*e.y;return new F({xmin:l,xmax:c,ymin:h,ymax:f,spatialReference:o})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,r){const i=this.rasterInfo.storageInfo.blockBoundary[e];return!i||i.maxRow<t||i.maxCol<r||i.minRow>t||i.minCol>r}async _fetchPixels(e,t,r,i={}){let o=C(e);if(o>=2)return{extent:e,pixelBlock:null};const s=this._getSourceDataInfo(e,t,r,i),{pyramidLevel:l,pyramidResolution:c,srcResolution:f,srcExtent:h,srcWidth:u,srcHeight:m}=s;if(0===u||0===m)return{extent:e,srcExtent:h,pixelBlock:null};const d=a(this.rasterInfo.transform);"gcs-shift"===(null==d?void 0:d.type)&&(o=C(s.srcExtent,!0));const p=this.rasterInfo.storageInfo,x={x:Math.floor((h.xmin-p.origin.x)/c.x+.1),y:Math.floor((p.origin.y-h.ymax)/c.y+.1)},g=await this._fetchRawTiles(l,x,{width:u,height:m,wrapCount:o},i);if(!g)return{extent:e,srcExtent:h,pixelBlock:null};const y=l>0?p.pyramidBlockWidth:p.blockWidth,I=l>0?p.pyramidBlockHeight:p.blockHeight,w=y===u&&I===m&&x.x%y==0&&x.y%I==0,R=new E({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/r,spatialReference:e.spatialReference}),b=!e.spatialReference.equals(this.rasterInfo.spatialReference),{datumTransformation:M}=i;if(!b&&w&&1===g.pixelBlocks.length&&y===t&&I===r&&f.x===R.x&&f.y===R.y)return{extent:e,srcExtent:h,pixelBlock:g.pixelBlocks[0]};const S=n(T(e.spatialReference))&&n(T(h.spatialReference)),B=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:g.extent,pixelSize:R.toJSON(),datumTransformation:M,rasterTransform:d,hasWrapAround:o>0||S,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy},i):W({projectedExtent:e,srcBufferExtent:g.extent,pixelSize:R,datumTransformation:M,rasterTransform:d,hasWrapAround:o>0||S,isAdaptive:!1});let P;const _=!i.requestRawData,H={rows:B.spacing[0],cols:B.spacing[1]},j=a(this._getRasterTileAlignmentInfo(l,g.extent.xmin)),{pixelBlocks:F,mosaicSize:A,isPartiallyFilled:L}=g;if(this.rasterJobHandler)P=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:F,srcMosaicSize:A,destDimension:_?{width:t,height:r}:null,coefs:_?B.coefficients:null,sampleSpacing:_?H:null,interpolation:i.interpolation,alignmentInfo:j,blockWidths:null},i);else{const e=k(F,A,{alignmentInfo:j});P=_?v(e,{width:t,height:r},B.coefficients,H,i.interpolation):e}return i.requestRawData?{srcExtent:h,pixelBlock:P,transformGrid:B,extent:e,isPartiallyFilled:L}:{srcExtent:h,extent:e,pixelBlock:P}}async _fetchRawTiles(e,t,r,i){const{origin:o,blockBoundary:s}=this.rasterInfo.storageInfo,{blockWidth:a,blockHeight:l}=this.getBlockWidthHeight(e);let{x:c,y:f}=t,{width:h,height:u,wrapCount:m}=r;const d=this._getRasterTileAlignmentInfo(e,0);i.buffer&&(c-=i.buffer.cols,f-=i.buffer.rows,h+=2*i.buffer.cols,u+=2*i.buffer.rows);let p=0,x=0,g=0;if(m&&n(d)){({worldColumnCountFromOrigin:x,originColumnOffset:g,rightPadding:p}=d);x*d.blockWidth-p>=c+h&&(p=0)}const y=Math.floor(c/a),I=Math.floor(f/l),w=Math.floor((c+h+p-1)/a),R=Math.floor((f+u+p-1)/l),k=s[e];if(!k)return null;const{minRow:v,minCol:b,maxCol:T,maxRow:M}=k;if(0===m&&(R<v||w<b||I>M||y>T))return null;const S=new Array;let B=!1;const C=null==this.ioConfig.allowPartialFill?i.allowPartialFill:this.ioConfig.allowPartialFill;for(let F=I;F<=R;F++)for(let t=y;t<=w;t++){let r=t;if(!i.disableWrapAround&&m&&n(d)&&x<=t&&(r=t-x-g),F>=v&&r>=b&&M>=F&&T>=r){const t=this._fetchRawTile(e,F,r,i);C?S.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{B=!0,e(null)}))}))):S.push(t)}else S.push(null)}if(0===S.length)return null;const P=await Promise.all(S),W={height:(R-I+1)*l,width:(w-y+1)*a},{spatialReference:_}=this.rasterInfo,H=this.getPyramidPixelSize(e),{x:j,y:E}=H;return{extent:new F({xmin:o.x+y*a*j,xmax:o.x+(w+1)*a*j,ymin:o.y-(R+1)*l*E,ymax:o.y-I*l*E,spatialReference:_}),pixelBlocks:P,mosaicSize:W,isPartiallyFilled:B}}_fetchRawTile(e,t,r,i){const o=this.rasterInfo.storageInfo.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:a,maxCol:l,maxRow:f}=o;if(t<n||r<a||t>f||r>l)return Promise.resolve(null);const h=x(this.url,i.sliceId),u=`${e}/${t}/${r}`;let m=g(h,i.registryId,u);if(s(m)){const o=new AbortController;m=this.fetchRawTile(e,t,r,{...i,signal:o.signal}),y(h,i.registryId,u,m,o),m.catch((()=>I(h,i.registryId,u)))}return i.signal&&c(i,(()=>{w(h,i.registryId,u)})),m}_getIndexFromDimensions(e,t){const{extent:r,interval:i,unit:o,values:n}=t;if(null!=n&&n.length)return Array.isArray(n[0])?n.findIndex((t=>t[0]<=e&&t[1]>=e)):n.indexOf(e);if(e>r[1])return-1;const s=r[0];let a=-1;if("ISO8601"===o){var l;switch((null==(l=t.intervalUnit)?void 0:l.toLowerCase())||"seconds"){case"seconds":a=Math.round((e-s)/1e3/i);break;case"minutes":a=Math.round((e-s)/6e4/i);break;case"hours":a=Math.round((e-s)/36e5/i);break;case"days":a=Math.round((e-s)/864e5/i);break;case"years":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/i);break;case"decades":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/i)}return a}return Math.round((e-s)/i)}_getDimensionValuesCount(e){const{extent:t,interval:r,unit:i,values:o}=e;let n=(null==o?void 0:o.length)||0;if(n)return n;const s=t[0];if(0===n&&"ISO8601"===i){var a;switch((null==(a=e.intervalUnit)?void 0:a.toLowerCase())||"seconds"){case"seconds":n=Math.round((t[1]-t[0])/1e3/r);break;case"minutes":n=Math.round((t[1]-t[0])/6e4/r);break;case"hours":n=Math.round((t[1]-t[0])/36e5/r);break;case"days":n=Math.round((t[1]-t[0])/864e5/r);break;case"years":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/r);break;case"decades":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/10/r)}return n}return Math.round((t[1]-t[0])/r)}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=_(this.rasterInfo)),n(this._rasterTileAlighmentInfo.pyramidsInfo)?{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}:null}_getSourceDataInfo(e,t,r,i={}){const o={datumTransformation:i.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0};i.srcResolution&&(o.srcResolution=i.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:a,pyramidLevel:l}=o,c=s/t,f=a/r,h=l<n&&c*f>=16;if(h||l===n&&(c>A||f>A)||(0===s||0===a)){const s=new E({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/r,spatialReference:e.spatialReference});let a=H(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const u=!a||i.srcResolution&&a.x+a.y<i.srcResolution.x+i.srcResolution.y;if(h&&i.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,f))/Math.LN2)-1;if(n-l+3>=e){const t=2**e;a={x:i.srcResolution.x*t,y:i.srcResolution.y*t}}}a&&(o.srcResolution=a,this._updateSourceDataInfo(e,o))}return(o.srcWidth/t>A||o.srcHeight/r>A)&&(o.srcWidth=0,o.srcHeight=0),o}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const r=this.rasterInfo.spatialReference,{srcResolution:i,datumTransformation:o}=t,{pyramidLevel:n,pyramidResolution:s,excessiveReading:l}=S(i,this.rasterInfo,this.ioConfig.sampling);if(l)return;let c=t.srcExtent||P(e,r,o);if(null==c)return;const f=a(this.rasterInfo.transform);f&&(c=f.inverseTransform(c)),t.srcExtent=c;const h=Math.ceil((c.xmax-c.xmin)/s.x-.1),u=Math.ceil((c.ymax-c.ymin)/s.y-.1);t.pyramidLevel=n,t.pyramidResolution=s,t.srcWidth=h,t.srcHeight=u}_getRequestOptionsWithSliceId(e){return n(this.rasterInfo.multidimensionalInfo)&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}};e([f()],L.prototype,"_rasterTileAlighmentInfo",void 0),e([f({readOnly:!0})],L.prototype,"_isGlobalWrappableSource",null),e([f(m)],L.prototype,"url",null),e([f({type:String,json:{write:!0}})],L.prototype,"datasetName",void 0),e([f({type:String,json:{write:!0}})],L.prototype,"datasetFormat",void 0),e([f()],L.prototype,"rasterInfo",void 0),e([f()],L.prototype,"ioConfig",void 0),e([f()],L.prototype,"sourceJSON",void 0),L=e([h("esri.layers.support.rasterDatasets.BaseRaster")],L);const D=L;export{D as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import r from"../../../core/Error.js";import{JSONSupport as i}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{isSome as n,isNone as s,unwrap as a}from"../../../core/maybe.js";import{EsriPromiseMixin as l}from"../../../core/Promise.js";import{onAbort as c}from"../../../core/promiseUtils.js";import{property as f}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as u}from"../arcgisLayerUrl.js";import{url as m}from"../commonProperties.js";import d from"../RasterStorageInfo.js";import p from"../TileInfo.js";import{getRasterId as x,getBlock as g,putBlock as y,deleteBlock as I,decreaseRefCount as w}from"./RawBlockCache.js";import{decode as R}from"../rasterFormats/RasterCodec.js";import{mosaic as k,approximateTransform as v}from"../rasterFunctions/pixelUtils.js";import{load as b,getWorldWidth as T,projectPoint as M,snapPyramid as S,snapExtent as B,getWorldWrapCount as C,projectExtent as P,getProjectionOffsetGrid as W,getRasterDatasetAlignmentInfo as _,projectResolution as H}from"../rasterFunctions/rasterProjectionHelper.js";import{uvComponentToVector as j}from"../rasterFunctions/vectorFieldUtils.js";import F from"../../../geometry/Extent.js";import E from"../../../geometry/Point.js";const A=8;let L=class extends(l(i)){constructor(){super(...arguments),this.rasterJobHandler=null,this.datasetName=null,this.datasetFormat=null,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=b();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:p.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=T(e.spatialReference);return n(t)&&e.extent.width>=t/2}set url(e){this._set("url",u(e,o.getLogger(this.declaredClass)))}async open(e){throw new r("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,r,i={}){const o=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,r,o);return this.fetchPixels(n,o.size[0],o.size[1],i)}async identify(e,t={}){t=this._getRequestOptionsWithSliceId(t);const{spatialReference:r,extent:i}=this.rasterInfo,{datumTransformation:o}=t;let a=M(e,r,o);if(!i.intersects(a))return{location:a,value:null};if(n(this.rasterInfo.transform)){const e=this.rasterInfo.transform.inverseTransform(a);if(!this.rasterInfo.nativeExtent.intersects(e))return{location:e,value:null};a=e}let l=0;if(t.srcResolution){l=S(t.srcResolution,this.rasterInfo,this.ioConfig.sampling).pyramidLevel}else if(l=await this.computeBestPyramidLevelForLocation(e,t),null==l)return{location:a,value:null};const c=this.identifyPixelLocation(a,l,null);if(null===c)return{location:a,value:null};const{row:f,col:h,rowOffset:u,colOffset:m}=c,d=x(this.url,t.sliceId),p=`${l}/${f}/${h}`;let I=g(d,null,p);s(I)&&(I=this.fetchRawTile(l,f,h,t),y(d,null,p,I));const w=await I;if(s(w)||!w.pixels||0===w.pixels.length)return{location:a,value:null};const R=u*this.rasterInfo.storageInfo.blockHeight+m,k=!w.mask||w.mask[R]?w.pixels.map((e=>e[R])):null,v=this.rasterInfo.dataType;if(("vector-magdir"===v||"vector-uv"===v)&&(null==k?void 0:k.length)>1){return{location:a,value:k,magdirValue:"vector-magdir"===v?[k[0],k[1]]:j([k[0],k[1]]),pyramidLevel:l}}return{location:a,value:k,pyramidLevel:l}}async fetchPixels(e,t,r,i={}){if(e=B(e),(i=this._getRequestOptionsWithSliceId(i)).requestRawData)return this._fetchPixels(e,t,r,i);const o=T(e.spatialReference),n=C(e);if(s(o)||0===n||1===n&&this._isGlobalWrappableSource)return this._fetchPixels(e,t,r,i);if(n>=3)return{extent:e,pixelBlock:null};const a=[],{xmin:l,xmax:c}=e,f=Math.round(o/(c-l)*t),h=f-Math.round((o/2-l)/(c-l)*t);let u=0;const m=[];for(let s=0;s<=n;s++){const d=new F({xmin:0===s?l:-o/2,xmax:s===n?c-o*s:o/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===s?f-h:s===n?t-u:f;u+=p,m.push(p);const x=i.disableWrapAround&&s>0?null:this._fetchPixels(d,p,r,i);a.push(x)}const d=(await Promise.all(a)).map((e=>null==e?void 0:e.pixelBlock));let p=null;const x={width:t,height:r};p=this.rasterJobHandler?await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:m},i):k(d,x,{blockWidths:m});return{extent:e,srcExtent:P(e,this.rasterInfo.spatialReference,i.datumTransformation),pixelBlock:p}}async fetchRawPixels(e,t,r,i={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,r,i),{nativeExtent:s,nativePixelSize:a,storageInfo:l}=this.rasterInfo,c=2**e,f=a.x*c,h=a.y*c,u=new F({xmin:s.xmin+f*t.x,xmax:s.xmin+f*(t.x+r.width-1),ymin:s.ymax-h*(t.y+r.height-1),ymax:s.ymax-h*t.y,spatialReference:s.spatialReference});if(!o)return{extent:u,srcExtent:u,pixelBlock:null};const{pixelBlocks:m}=o;if(1===m.length&&n(m[0])&&m[0].width===r.width&&m[0].height===r.height)return{extent:u,srcExtent:u,pixelBlock:o.pixelBlocks[0]};const d=e>0?l.pyramidBlockWidth:l.blockWidth,p=e>0?l.pyramidBlockHeight:l.blockHeight,x={width:Math.ceil(r.width/d)*d,height:Math.ceil(r.height/p)*p},g={x:t.x%d,y:t.y%p};let y;return y=this.rasterJobHandler?await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:m,srcMosaicSize:r,destDimension:r,clipOffset:g,clipSize:r,coefs:null,sampleSpacing:null,interpolation:i.interpolation,alignmentInfo:null,blockWidths:null},i):k(m,x,{clipOffset:g,clipSize:r}),{extent:u,srcExtent:u,pixelBlock:y}}fetchRawTile(e,t,i,o){throw new r("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return P(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?R(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,r,i){var o,n;const{customFetchParameters:s}=this.ioConfig,{range:a,query:l,headers:c}=r;i=null!=(o=null!=(n=i)?n:r.retryCount)?o:this.ioConfig.retryCount;const f=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...r,query:{...l,...s},headers:{...c,...f}})}catch(h){if(i>0)return i--,this.request(e,r,i);throw h}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;if(!n(t))return null;if(!n(e)||0===e.length)return null;let r=0;const i=e[0].variableName;for(let o=0;o<t.variables.length;o++){const n=t.variables[o],s=n.dimensions;if(n.name!==i){r+=s.map((e=>this._getDimensionValuesCount(e))).reduce(((e,t)=>e+t));break}const a=s.map((e=>this._getDimensionValuesCount(e))),l=s.length;for(let t=0;t<l;t++){const i=e.filter((e=>e.dimensionName===s[t].name))[0];if(null==i)return null;const o=Array.isArray(i.values[0])?i.values[0][0]:i.values[0],n=this._getIndexFromDimensions(o,s[t]);if(-1===n)return null;a.shift(),r+=t===l-1?n:n*a.reduce(((e,t)=>e+t))}}return r}getTileExtentFromTileInfo(e,t,r,i){const o=i.lodAt(e);return this.getTileExtent({x:o.resolution,y:o.resolution},t,r,i.origin,i.spatialReference,i.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:r,pixelSize:i}=this.rasterInfo;if(!e.tileInfo){const o=[],n=e.maximumPyramidLevel||0;let s=Math.max(i.x,i.y),a=1/.0254*96*s;for(let e=0;e<=n;e++)o.push({level:n-e,resolution:s,scale:a}),s*=2,a*=2;const l=new E({x:r.xmin,y:r.ymax,spatialReference:t});e.tileInfo=new p({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:o}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,r=512,i){const{width:o,height:n,nativeExtent:s,pixelSize:a,spatialReference:l}=e,c=new E({x:s.xmin,y:s.ymax,spatialReference:l});null==i&&(i=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const f=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[a],i);e.storageInfo=new d({blockWidth:t,blockHeight:r,pyramidBlockWidth:t,pyramidBlockHeight:r,origin:c,firstPyramidLevel:1,maximumPyramidLevel:i,blockBoundary:f})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,r,i,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let r=0;r<n;r++)e*=s,t*=s,o.push({x:e,y:t})}const a=[],{x:l,y:c}=i;for(let f=0;f<o.length;f++){const{x:i,y:n}=o[f];a.push({minCol:Math.floor((e.xmin-l+.1*i)/t/i),maxCol:Math.floor((e.xmax-l-.1*i)/t/i),minRow:Math.floor((c-e.ymax+.1*n)/r/n),maxRow:Math.floor((c-e.ymin-.1*n)/r/n)})}return a}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:r,pyramidScalingFactor:i}=this.rasterInfo.storageInfo;if(0===e)return t;if(n(r)&&r.length)return r[e-1];const o=i**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,r){const{spatialReference:i,nativeExtent:o}=this.rasterInfo,{blockWidth:n,blockHeight:s,maximumPyramidLevel:a,origin:l}=this.rasterInfo.storageInfo,c=M(e,i,r);if(!o.intersects(c))return null;if(t<0||t>a)return null;const f=this.getPyramidPixelSize(t),{x:h,y:u}=f,m=(l.y-c.y)/u/s,d=(c.x-l.x)/h/n,p=Math.min(s-1,Math.floor((m-Math.floor(m))*s)),x=Math.min(n-1,Math.floor((d-Math.floor(d))*n));return{pyramidLevel:t,row:Math.floor(m),col:Math.floor(d),rowOffset:p,colOffset:x,srcLocation:c}}getTileExtent(e,t,r,i,o,n){const[s,a]=n,l=i.x+r*s*e.x,c=l+s*e.x,f=i.y-t*a*e.y,h=f-a*e.y;return new F({xmin:l,xmax:c,ymin:h,ymax:f,spatialReference:o})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,r){const i=this.rasterInfo.storageInfo.blockBoundary[e];return!i||i.maxRow<t||i.maxCol<r||i.minRow>t||i.minCol>r}async _fetchPixels(e,t,r,i={}){let o=C(e);if(o>=2)return{extent:e,pixelBlock:null};const s=this._getSourceDataInfo(e,t,r,i),{pyramidLevel:l,pyramidResolution:c,srcResolution:f,srcExtent:h,srcWidth:u,srcHeight:m}=s;if(0===u||0===m)return{extent:e,srcExtent:h,pixelBlock:null};const d=a(this.rasterInfo.transform),p="gcs-shift"===(null==d?void 0:d.type),x=n(T(e.spatialReference));!p&&x||(o=C(s.srcExtent,p));const g=this.rasterInfo.storageInfo,y={x:Math.floor((h.xmin-g.origin.x)/c.x+.1),y:Math.floor((g.origin.y-h.ymax)/c.y+.1)},I=await this._fetchRawTiles(l,y,{width:u,height:m,wrapCount:o},i);if(!I)return{extent:e,srcExtent:h,pixelBlock:null};const w=l>0?g.pyramidBlockWidth:g.blockWidth,R=l>0?g.pyramidBlockHeight:g.blockHeight,b=w===u&&R===m&&y.x%w==0&&y.y%R==0,M=new E({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/r,spatialReference:e.spatialReference}),S=!e.spatialReference.equals(this.rasterInfo.spatialReference),{datumTransformation:B}=i;if(!S&&b&&1===I.pixelBlocks.length&&w===t&&R===r&&f.x===M.x&&f.y===M.y)return{extent:e,srcExtent:h,pixelBlock:I.pixelBlocks[0]};const P=x&&n(T(h.spatialReference)),_=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:I.extent,pixelSize:M.toJSON(),datumTransformation:B,rasterTransform:d,hasWrapAround:o>0||P,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy},i):W({projectedExtent:e,srcBufferExtent:I.extent,pixelSize:M,datumTransformation:B,rasterTransform:d,hasWrapAround:o>0||P,isAdaptive:!1});let H;const j=!i.requestRawData,F={rows:_.spacing[0],cols:_.spacing[1]},A=a(this._getRasterTileAlignmentInfo(l,I.extent.xmin)),{pixelBlocks:L,mosaicSize:D,isPartiallyFilled:z}=I;if(this.rasterJobHandler)H=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:L,srcMosaicSize:D,destDimension:j?{width:t,height:r}:null,coefs:j?_.coefficients:null,sampleSpacing:j?F:null,interpolation:i.interpolation,alignmentInfo:A,blockWidths:null},i);else{const e=k(L,D,{alignmentInfo:A});H=j?v(e,{width:t,height:r},_.coefficients,F,i.interpolation):e}return i.requestRawData?{srcExtent:h,pixelBlock:H,transformGrid:_,extent:e,isPartiallyFilled:z}:{srcExtent:h,extent:e,pixelBlock:H}}async _fetchRawTiles(e,t,r,i){const{origin:o,blockBoundary:s}=this.rasterInfo.storageInfo,{blockWidth:a,blockHeight:l}=this.getBlockWidthHeight(e);let{x:c,y:f}=t,{width:h,height:u,wrapCount:m}=r;const d=this._getRasterTileAlignmentInfo(e,0);i.buffer&&(c-=i.buffer.cols,f-=i.buffer.rows,h+=2*i.buffer.cols,u+=2*i.buffer.rows);let p=0,x=0,g=0;if(m&&n(d)){({worldColumnCountFromOrigin:x,originColumnOffset:g,rightPadding:p}=d);x*d.blockWidth-p>=c+h&&(p=0)}const y=Math.floor(c/a),I=Math.floor(f/l),w=Math.floor((c+h+p-1)/a),R=Math.floor((f+u+p-1)/l),k=s[e];if(!k)return null;const{minRow:v,minCol:b,maxCol:T,maxRow:M}=k;if(0===m&&(R<v||w<b||I>M||y>T))return null;const S=new Array;let B=!1;const C=null==this.ioConfig.allowPartialFill?i.allowPartialFill:this.ioConfig.allowPartialFill;for(let F=I;F<=R;F++)for(let t=y;t<=w;t++){let r=t;if(!i.disableWrapAround&&m&&n(d)&&x<=t&&(r=t-x-g),F>=v&&r>=b&&M>=F&&T>=r){const t=this._fetchRawTile(e,F,r,i);C?S.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{B=!0,e(null)}))}))):S.push(t)}else S.push(null)}if(0===S.length)return null;const P=await Promise.all(S),W={height:(R-I+1)*l,width:(w-y+1)*a},{spatialReference:_}=this.rasterInfo,H=this.getPyramidPixelSize(e),{x:j,y:E}=H;return{extent:new F({xmin:o.x+y*a*j,xmax:o.x+(w+1)*a*j,ymin:o.y-(R+1)*l*E,ymax:o.y-I*l*E,spatialReference:_}),pixelBlocks:P,mosaicSize:W,isPartiallyFilled:B}}_fetchRawTile(e,t,r,i){const o=this.rasterInfo.storageInfo.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:a,maxCol:l,maxRow:f}=o;if(t<n||r<a||t>f||r>l)return Promise.resolve(null);const h=x(this.url,i.sliceId),u=`${e}/${t}/${r}`;let m=g(h,i.registryId,u);if(s(m)){const o=new AbortController;m=this.fetchRawTile(e,t,r,{...i,signal:o.signal}),y(h,i.registryId,u,m,o),m.catch((()=>I(h,i.registryId,u)))}return i.signal&&c(i,(()=>{w(h,i.registryId,u)})),m}_getIndexFromDimensions(e,t){const{extent:r,interval:i,unit:o,values:n}=t;if(null!=n&&n.length)return Array.isArray(n[0])?n.findIndex((t=>t[0]<=e&&t[1]>=e)):n.indexOf(e);if(e>r[1])return-1;const s=r[0];let a=-1;if("ISO8601"===o){var l;switch((null==(l=t.intervalUnit)?void 0:l.toLowerCase())||"seconds"){case"seconds":a=Math.round((e-s)/1e3/i);break;case"minutes":a=Math.round((e-s)/6e4/i);break;case"hours":a=Math.round((e-s)/36e5/i);break;case"days":a=Math.round((e-s)/864e5/i);break;case"years":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/i);break;case"decades":a=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/i)}return a}return Math.round((e-s)/i)}_getDimensionValuesCount(e){const{extent:t,interval:r,unit:i,values:o}=e;let n=(null==o?void 0:o.length)||0;if(n)return n;const s=t[0];if(0===n&&"ISO8601"===i){var a;switch((null==(a=e.intervalUnit)?void 0:a.toLowerCase())||"seconds"){case"seconds":n=Math.round((t[1]-t[0])/1e3/r);break;case"minutes":n=Math.round((t[1]-t[0])/6e4/r);break;case"hours":n=Math.round((t[1]-t[0])/36e5/r);break;case"days":n=Math.round((t[1]-t[0])/864e5/r);break;case"years":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/r);break;case"decades":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(s).getUTCFullYear())/10/r)}return n}return Math.round((t[1]-t[0])/r)}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=_(this.rasterInfo)),n(this._rasterTileAlighmentInfo.pyramidsInfo)?{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}:null}_getSourceDataInfo(e,t,r,i={}){const o={datumTransformation:i.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0};i.srcResolution&&(o.srcResolution=i.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:a,pyramidLevel:l}=o,c=s/t,f=a/r,h=l<n&&c*f>=16;if(h||l===n&&(c>A||f>A)||(0===s||0===a)){const s=new E({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/r,spatialReference:e.spatialReference});let a=H(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const u=!a||i.srcResolution&&a.x+a.y<i.srcResolution.x+i.srcResolution.y;if(h&&i.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,f))/Math.LN2)-1;if(n-l+3>=e){const t=2**e;a={x:i.srcResolution.x*t,y:i.srcResolution.y*t}}}a&&(o.srcResolution=a,this._updateSourceDataInfo(e,o))}return(o.srcWidth/t>A||o.srcHeight/r>A)&&(o.srcWidth=0,o.srcHeight=0),o}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const r=this.rasterInfo.spatialReference,{srcResolution:i,datumTransformation:o}=t,{pyramidLevel:n,pyramidResolution:s,excessiveReading:l}=S(i,this.rasterInfo,this.ioConfig.sampling);if(l)return;let c=t.srcExtent||P(e,r,o);if(null==c)return;const f=a(this.rasterInfo.transform);f&&(c=f.inverseTransform(c)),t.srcExtent=c;const h=Math.ceil((c.xmax-c.xmin)/s.x-.1),u=Math.ceil((c.ymax-c.ymin)/s.y-.1);t.pyramidLevel=n,t.pyramidResolution=s,t.srcWidth=h,t.srcHeight=u}_getRequestOptionsWithSliceId(e){return n(this.rasterInfo.multidimensionalInfo)&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}};e([f()],L.prototype,"_rasterTileAlighmentInfo",void 0),e([f({readOnly:!0})],L.prototype,"_isGlobalWrappableSource",null),e([f(m)],L.prototype,"url",null),e([f({type:String,json:{write:!0}})],L.prototype,"datasetName",void 0),e([f({type:String,json:{write:!0}})],L.prototype,"datasetFormat",void 0),e([f()],L.prototype,"rasterInfo",void 0),e([f()],L.prototype,"ioConfig",void 0),e([f()],L.prototype,"sourceJSON",void 0),L=e([h("esri.layers.support.rasterDatasets.BaseRaster")],L);const D=L;export{D as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import"../../../geometry.js";import e from"../../../core/Error.js";import{isNone as n,isSome as t}from"../../../core/maybe.js";import{getMetersPerUnitForSR as o}from"../../../core/unitUtils.js";import{canProjectWithoutEngine as i,isLoaded as r,load as a,getTransformation as s,project as l}from"../../../geometry/projection.js";import c from"../../../geometry/Extent.js";import x from"../../../geometry/Point.js";function f(e,n,t){return!i(e,n,t)}function m(n,t,o){const i=f(n,t,o);if(i&&!r())throw new e("rasterprojectionhelper-project","projection engine is not loaded");return i}const u=function(e,n,t){const o=(e[0]+e[4]+e[4*n.cols]+e[4*n.cols+4])/4,i=(e[1]+e[5]+e[4*n.rows+1]+e[4*n.rows+5])/4,r=(e[4*n.cols]-e[0]+e[4*n.cols+4]-e[4])/t[0]*.5,a=(e[4*n.cols+1]-e[1]+e[4*n.cols+5]-e[5])/t[1]*.5;return[0===r||isNaN(r)?0:Math.abs(o-e[2*n.rows+2])/Math.abs(r),0===a||isNaN(a)?0:Math.abs(i-e[2*n.rows+3])/Math.abs(a)]},p={3395:20037508.342789244,3410:17334193.943686873,3857:20037508.342788905,3975:17367530.445161372,4087:20037508.342789244,4088:20015108.787169147,6933:17367530.445161372,32662:20037508.342789244,53001:20015086.79602057,53002:10007543.39801029,53003:20015086.79602057,53004:20015086.79602057,53016:14152803.599503474,53017:17333573.624304302,53034:20015086.79602057,53079:20015114.352186374,53080:20015114.352186374,54001:20037508.342789244,54002:10018754.171394624,54003:20037508.342789244,54004:20037508.342789244,54016:14168658.027268292,54017:17367530.44516137,54034:20037508.342789244,54079:20037508.342789244,54080:20037508.342789244,54100:20037508.342789244,54101:20037508.342789244},h=32,y=4,d=y;async function g(){if(r())return null;await a()}function M(e,n,t){if(!m(e.spatialReference,n))return null;return t?s(n,e.spatialReference,e):s(e.spatialReference,n,e)}function w(e,t,o,i=null){if(e.spatialReference.equals(t))return e;m(e.spatialReference,t,i);const r=o.center,a=new c({xmin:r.x-e.x/2,xmax:r.x+e.x/2,ymin:r.y-e.y/2,ymax:r.y+e.y/2,spatialReference:e.spatialReference}),s=l(a,t,i);if(n(s))return null;return{x:s.xmax-s.xmin,y:s.ymax-s.ymin}}function R(e,n=.01){return o(e)?n/o(e):0}function b(e,n,o=null,i=!0){const r=e.spatialReference;if(r.equals(n))return e;m(r,n,o);const a=l(e,n,o);if(!i||!a)return a;const s=P(r,!0),c=P(n,!0),x=R(r);return x&&t(s)&&t(c)&&(a.x>0&&Math.abs(e.x-s[0])<x?a.x-=c[1]-c[0]:a.x<0&&Math.abs(e.x-s[1])<x&&(a.x+=c[1]-c[0])),a}function v(e,n,t=null){const o=e[0].spatialReference;return o.equals(n)?e:(m(o,n,t),l(e,n,t))}function N(e){const n=S(e[0].spatialReference);if(e.length<2||!t(n))return e[0];let{xmin:o,xmax:i,ymin:r,ymax:a}=e[0];for(let t=1;t<e.length;t++){const o=e[t];i=o.xmax+n*t,r=Math.min(r,o.ymin),a=Math.max(a,o.ymax)}return new c({xmin:o,xmax:i,ymin:r,ymax:a,spatialReference:e[0].spatialReference})}function z(e,t,o=null,i=!0){if(e.spatialReference.equals(t))return e;const r=W(e),a=S(e.spatialReference,!0),s=S(t);if(0===r||n(a)||n(s))return j(e,t,o,i);const l=e.clone().normalize();if(1===l.length&&e.xmax<a&&e.xmax-a/2>R(e.spatialReference)){const{xmin:n,xmax:t}=e;for(let o=0;o<=r;o++){const i=0===o?n:-a/2,s=o===r?t-a*o:a/2;l[o]=new c({xmin:i,xmax:s,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference})}}return N(l.map((e=>j(e,t,o,i))).filter((e=>!!e)))}function j(e,t,o=null,i=!0,r=!0){const a=e.spatialReference;if(a.equals(t))return e;m(a,t,o);const s=l(e,t,o);if(r&&t.isWebMercator&&s&&(s.ymax=Math.min(20037508.342787,s.ymax),s.ymin=Math.max(-20037508.342787,s.ymin),s.ymin>=s.ymax))return null;if(!i||!s)return s;const c=P(a,!0),f=P(t,!0);if(n(c)||n(f))return s;const u=R(a,.001),p=R(a,500),h=R(t,.001);if(Math.abs(s.xmin-f[0])<h&&Math.abs(s.xmax-f[1])<h){const n=Math.abs(e.xmin-c[0]),i=Math.abs(c[1]-e.xmax);if(n<u&&i>p){s.xmin=f[0];const n=[];n.push(new x(e.xmax,e.ymin,a)),n.push(new x(e.xmax,(e.ymin+e.ymax)/2,a)),n.push(new x(e.xmax,e.ymax,a));const i=n.map((e=>b(e,t,o))).filter((e=>!isNaN(null==e?void 0:e.x))).map((e=>e.x));s.xmax=Math.max.apply(null,i)}if(i<u&&n>p){s.xmax=f[1];const n=[];n.push(new x(e.xmin,e.ymin,a)),n.push(new x(e.xmin,(e.ymin+e.ymax)/2,a)),n.push(new x(e.xmin,e.ymax,a));const i=n.map((e=>b(e,t,o))).filter((e=>!isNaN(null==e?void 0:e.x))).map((e=>e.x));s.xmin=Math.min.apply(null,i)}}else{const e=R(t,.001);Math.abs(s.xmin-f[0])<e&&(s.xmin=f[0]),Math.abs(s.xmax-f[1])<e&&(s.xmax=f[1])}return s}function S(e,n=!1){const t=n?20037508.342787:20037508.342788905;return e.isWebMercator?2*t:e.wkid&&e.isGeographic?360:2*p[e.wkid]||null}function P(e,n=!1){if(e.isGeographic)return[-180,180];const o=S(e,n);return t(o)?[-o/2,o/2]:null}function C(e,n,t,o){let i=(e-n)/t;return i-Math.floor(i)!=0?i=Math.floor(i):o&&(i-=1),i}function W(e,n=!1){const o=S(e.spatialReference);if(!t(o))return 0;const i=n?0:-(o/2);return C(e.xmax,i,o,!0)-C(e.xmin,i,o,!1)}function T(e){const n=e.storageInfo.origin.x,o=S(e.spatialReference,!0);if(!t(o))return{originX:n,halfWorldWidth:null,pyramidsInfo:null};const i=o/2,{nativePixelSize:r,storageInfo:a,extent:s}=e,{maximumPyramidLevel:l,blockWidth:c,pyramidScalingFactor:x}=a;let f=r.x;const m=[],u=t(e.transform)&&"gcs-shift"===e.transform.type,p=n+(u?0:i),h=u?o-n:i-n;for(let t=0;t<=l;t++){const e=(s.xmax-n)/f/c,t=e-Math.floor(e)==0?e:Math.ceil(e),o=h/f/c,i=o-Math.floor(o)==0?o:Math.ceil(o),r=Math.floor(p/f/c),a=Math.round(p/f)%c,l=(c-Math.round(h/f)%c)%c;m.push({resolutionX:f,blockWidth:c,datsetColumnCount:t,worldColumnCountFromOrigin:i,leftMargin:a,rightPadding:l,originColumnOffset:r}),f*=x}return{originX:n,halfWorldWidth:i,pyramidsInfo:m,hasGCSSShiftTransform:u}}function G(e){const n=e.isAdaptive&&null==e.spacing,t=e.spacing||[h,h];let o=L(e),i={cols:o.size[0]+1,rows:o.size[1]+1},r=u(o.offsets,i,t);const a=(r[0]+r[1])/2,s=o.outofBoundPointCount>0&&o.outofBoundPointCount<o.offsets.length/2;return n&&(s||a>d)&&(o=L({...e,spacing:[y,y]}),i={cols:o.size[0]+1,rows:o.size[1]+1},r=u(o.offsets,i,t)),o.error=r,o.coefficients=k(o.offsets,i,s),o}function L(e){const{projectedExtent:n,srcBufferExtent:o,pixelSize:i,datumTransformation:r,rasterTransform:a}=e,s=n.spatialReference,l=o.spatialReference;m(s,l);const{xmin:c,ymin:f,xmax:u,ymax:p}=n,y=S(l),d=e.hasWrapAround||"gcs-shift"===(null==a?void 0:a.type),g=e.spacing||[h,h],M={x:g[0]*i.x,y:g[1]*i.y},w={cols:Math.ceil((u-c)/M.x-.1/g[0])+1,rows:Math.ceil((p-f)/M.y-.1/g[1])+1},R=M.x,b=M.y,N=[];let z,j=0;const P=[];for(let t=0;t<w.cols;t++)for(let e=0;e<w.rows;e++)P.push(new x({x:c+R*t,y:p-b*e,spatialReference:s}));const C=v(P,l,r);for(let x=0;x<w.cols;x++){const e=[];for(let n=0;n<w.rows;n++){var W;let i=C[x*w.rows+n];t(y)&&(null==(W=i)?void 0:W.x)>o.xmax&&(i.x-=y),a&&(i=a.inverseTransform(i)),e.push(i),x>0&&d&&i&&z[n]&&t(y)&&i.x<z[n].x&&(i.x+=y),i?(N.push((i.x-o.xmin)/(o.xmax-o.xmin)),N.push((o.ymax-i.y)/(o.ymax-o.ymin))):(N.push(NaN),N.push(NaN),j++)}z=e}return{offsets:N,error:null,coefficients:null,outofBoundPointCount:j,spacing:g,size:[w.cols-1,w.rows-1]}}function k(e,n,t){const{cols:o,rows:i}=n,r=new Float32Array((o-1)*(i-1)*2*6),a=new Float32Array([-0,-1,1,-1,1,-0,1,-0,-0]),s=new Float32Array([-1,1,0,0,-1,1,1,0,0]);for(let l=0;l<o-1;l++){for(let n=0;n<i-1;n++){let t=l*i*2+2*n;const c=e[t],x=e[t+1],f=e[t+2],m=e[t+3];t+=2*i;const u=e[t],p=e[t+1],h=e[t+2],y=e[t+3];let d=0,g=12*(n*(o-1)+l);for(let e=0;e<3;e++)r[g++]=a[d++]*c+a[d++]*f+a[d++]*h;d=0;for(let e=0;e<3;e++)r[g++]=a[d++]*x+a[d++]*m+a[d++]*y;d=0;for(let e=0;e<3;e++)r[g++]=s[d++]*c+s[d++]*u+s[d++]*h;d=0;for(let e=0;e<3;e++)r[g++]=s[d++]*x+s[d++]*p+s[d++]*y}if(t)for(let e=0;e<r.length;e++)isNaN(r[e])&&(r[e]=-1)}return r}function I(e){const n=e.clone().normalize();return 1===n.length?n[0]:N(n)}function q(e,n,o){const{storageInfo:i,pixelSize:r}=n;let a,s=!1;const{pyramidResolutions:l}=i;if(t(l)&&l.length){const t=(e.x+e.y)/2,i=l[l.length-1],c=(i.x+i.y)/2,f=(r.x+r.y)/2;if(t<=f)a=0;else if(t>=c)a=l.length,s=t/c>8;else{let e,n=f;for(let i=1;i<=l.length;i++){if(e=(l[i-1].x+l[i-1].y)/2,t<=e){t===e?a=i:"down"===o?(a=i-1,s=t/n>8):a="up"===o||t-n>e-t||t/n>2?i:i-1;break}n=e}}const m=0===a?r:l[a-1];return{pyramidLevel:a,pyramidResolution:new x({x:m.x,y:m.y,spatialReference:n.spatialReference}),excessiveReading:s}}const c=Math.log(e.x/r.x)/Math.LN2,f=Math.log(e.y/r.y)/Math.LN2,m=n.storageInfo.maximumPyramidLevel||0;a="down"===o?Math.floor(Math.min(c,f)):"up"===o?Math.ceil(Math.max(c,f)):Math.round((c+f)/2),a<0?a=0:a>m&&(s=a>m+3,a=m);const u=2**a;return{pyramidLevel:a,pyramidResolution:new x({x:u*n.nativePixelSize.x,y:u*n.nativePixelSize.y,spatialReference:n.spatialReference}),excessiveReading:s}}function A(e,n,t=512,i=!0){const{extent:r,spatialReference:a,pixelSize:s}=e,l=w(new x({x:s.x,y:s.y,spatialReference:a}),n,r);if(null==l)return{projectedPixelSize:null,scales:null,srcResolutions:null,isCustomTilingScheme:!1};const c=(l.x+l.y)/2,f=o(n),m=c*f*96*39.37,u=n.isGeographic?256/t*295828763.7958547:256/t*591657527.591555;let p="vector-magdir"===e.dataType||"vector-uv"===e.dataType;const h=z(r,n);p||i&&(n.isGeographic||n.isWebMercator)&&(p=h.xmin*h.xmax<0);let y,d=m;const g=1.001;if(p){d=u;const e=n.isGeographic?1341104507446289e-21:.29858214164761665,t=e*(96*f*39.37),o=n.isGeographic?4326:3857;y=w(new x({x:e,y:e,spatialReference:{wkid:o}}),a,h),y.x*=d/t,y.y*=d/t}else{y={x:s.x,y:s.y};const n=Math.ceil(Math.log(Math.min(e.width,e.height)/32)/Math.LN2);let t=0;for(;d<u*(g/2)&&t<n;)t++,d*=2,y.x*=2,y.y*=2;Math.max(d,u)/Math.min(d,u)<=g&&(d=u)}const M=[d],R=[{x:y.x,y:y.y}],b=70.5310735,v=Math.min(b,m)/g;for(;d>=v;)d/=2,y.x/=2,y.y/=2,M.push(d),R.push({x:y.x,y:y.y});return{projectedPixelSize:l,scales:M,srcResolutions:R,isCustomTilingScheme:!p}}export{A as computeProjectedScales,h as defaultGridSpacing,d as defaultProjectionToleranceInPixels,M as getDefaultDatumTransformationForDataset,G as getProjectionOffsetGrid,T as getRasterDatasetAlignmentInfo,S as getWorldWidth,W as getWorldWrapCount,g as load,y as minimumGridSpacing,z as projectExtent,b as projectPoint,w as projectResolution,f as requirePE,I as snapExtent,q as snapPyramid};
5
+ import"../../../geometry.js";import e from"../../../core/Error.js";import{isNone as t,isSome as n}from"../../../core/maybe.js";import{getMetersPerUnitForSR as o}from"../../../core/unitUtils.js";import{e as i,f as r,g as s,h as a,j as l}from"../../../chunks/pe.js";import{canProjectWithoutEngine as c,isLoaded as f,load as u,getTransformation as m,project as x}from"../../../geometry/projection.js";import h from"../../../geometry/Extent.js";import p from"../../../geometry/Point.js";function g(e,t,n){return!c(e,t,n)}function y(t,n,o){const i=g(t,n,o);if(i&&!f())throw new e("rasterprojectionhelper-project","projection engine is not loaded");return i}const d=function(e,t,n,o=0){if(1===n[0])return[0,0];let i=1,r=-1,s=1,a=-1;for(let g=0;g<e.length;g+=2)isNaN(e[g])||(i=i>e[g]?e[g]:i,r=r>e[g]?r:e[g],s=s>e[g+1]?e[g+1]:s,a=a>e[g+1]?a:e[g+1]);const{cols:l,rows:c}=t,f=(r-i)/l/n[0],u=(a-s)/c/n[1],m=2*o;let x=0,h=!1,p=[0,0];for(let g=0;g<l-3;g++){for(let t=0;t<c-3;t++){const n=g*c*2+2*t,o=(e[n]+e[n+4]+e[n+4*c]+e[n+4*c+4])/4,i=(e[n+1]+e[n+5]+e[n+4*c+1]+e[n+4*c+5])/4,r=Math.abs((o-e[n+2*c+2])/f),s=Math.abs((i-e[n+2*c+3])/u);if(r+s>x&&(x=r+s,p=[r,s]),m&&x>m){h=!0;break}}if(h)break}return p},M={3395:20037508.342789244,3410:17334193.943686873,3857:20037508.342788905,3975:17367530.445161372,4087:20037508.342789244,4088:20015108.787169147,6933:17367530.445161372,32662:20037508.342789244,53001:20015086.79602057,53002:10007543.39801029,53003:20015086.79602057,53004:20015086.79602057,53016:14152803.599503474,53017:17333573.624304302,53034:20015086.79602057,53079:20015114.352186374,53080:20015114.352186374,54001:20037508.342789244,54002:10018754.171394624,54003:20037508.342789244,54004:20037508.342789244,54016:14168658.027268292,54017:17367530.44516137,54034:20037508.342789244,54079:20037508.342789244,54080:20037508.342789244,54100:20037508.342789244,54101:20037508.342789244},R=32,w=4,P=w,S=new Map;async function b(){if(f())return null;await u()}function E(e,t,n){if(!y(e.spatialReference,t))return null;return n?m(t,e.spatialReference,e):m(e.spatialReference,t,e)}function N(e,n,o,i=null){if(e.spatialReference.equals(n))return e;y(e.spatialReference,n,i);const r=o.center,s=new h({xmin:r.x-e.x/2,xmax:r.x+e.x/2,ymin:r.y-e.y/2,ymax:r.y+e.y/2,spatialReference:e.spatialReference}),a=x(s,n,i);if(t(a))return null;return{x:a.xmax-a.xmin,y:a.ymax-a.ymin}}function G(e,t=.01){return o(e)?t/o(e):0}function v(e,t,o=null,i=!0){const r=e.spatialReference;if(r.equals(t))return e;y(r,t,o);const s=x(e,t,o);if(!i||!s)return s;const a=Y(r,!0),l=Y(t,!0),c=G(r);return c&&n(a)&&n(l)&&(s.x>0&&Math.abs(e.x-a[0])<c?s.x-=l[1]-l[0]:s.x<0&&Math.abs(e.x-a[1])<c&&(s.x+=l[1]-l[0])),s}function T(e){const{inSR:t,outSR:o,datumTransformation:i,preferPE:r}=e;if(t.equals(o)){const{points:t}=W(e,null);return t}if(t.isWebMercator&&o.isWGS84||t.isWGS84&&o.isWebMercator)return _(e);if(y(t,o,i)&&r){if(t.isGeographic)return C(e);const o=j(t);if(n(o))return C(e)}return k(e)}function k(e){const{points:t}=W(e,null),n=t.map((t=>new p(t[0],t[1],e.inSR)));return x(n,e.outSR,e.datumTransformation).map((e=>e?[e.x,e.y]:[NaN,NaN]))}function C(e){const{inSR:t,outSR:o,datumTransformation:l}=e,c=j(t),{points:f,mask:u}=W(e,c);if(!t.isGeographic){const e=t.wkid?i.coordsys(t.wkid):i.fromString(t.isGeographic?r.PE_TYPE_GEOGCS:r.PE_TYPE_PROJCS,t.wkt);s.projToGeog(e,f.length,f)}if(n(l)&&l.steps.length&&l.steps.forEach((e=>{const t=e.wkid?i.geogtran(e.wkid):i.fromString(r.PE_TYPE_GEOGTRAN,e.wkt);a.geogToGeog(t,f.length,f,null,e.isInverse?r.PE_TRANSFORM_2_TO_1:r.PE_TRANSFORM_1_TO_2)})),!o.isGeographic){const e=j(o,!0),t=n(e)&&e.isEnvelope?[e.bbox[1],e.bbox[3]]:[-90,90];O(f,t);const a=o.wkid?i.coordsys(o.wkid):i.fromString(o.isGeographic?r.PE_TYPE_GEOGCS:r.PE_TYPE_PROJCS,o.wkt);s.geogToProj(a,f.length,f)}let m=f;if(u&&f.length!==u.length){m=[];for(let e=0,t=0;e<u.length;e++)u[e]?m.push(f[t++]):m.push([NaN,NaN])}return m}function _(e){const{cols:t,rows:n,xres:o,yres:i,usePixelCenter:r,inSR:s,outSR:a}=e;let{xmin:l,ymax:c}=e;r&&(l+=o/2,c-=i/2);const f=[],u=[],m=Math.max(t,n);for(let g=0;g<m;g++){const e=l+o*Math.min(t,g),r=c-i*Math.min(n,g),m=x(new p({x:e,y:r,spatialReference:s}),a);g<=t&&f.push(m.x),g<=n&&u.push(m.y)}const h=[];for(let x=0;x<t;x++)for(let e=0;e<n;e++)h.push([f[x],u[e]]);return h}function j(e,t=!1){let n=e.wkid||e.wkt;if(!n||e.isGeographic)return null;if(n=String(n),S.has(n)){const e=S.get(n);return t?null==e?void 0:e.gcs:null==e?void 0:e.pcs}const o=e.wkid?i.coordsys(e.wkid):i.fromString(e.isGeographic?r.PE_TYPE_GEOGCS:r.PE_TYPE_PROJCS,e.wkt),s=z(o,G(e,1e-4)),a=z(o,0,!0);return S.set(n,{pcs:s,gcs:a}),t?a:s}function z(e,t=0,n=!1){const o=l.generate(e),i=n?e.horizonGcsGenerate():e.horizonPcsGenerate();if(null==i||!i.length)return null;let r=!1,s=i.find((e=>1===e.getInclusive()&&1===e.getKind()));if(!s){if(s=i.find((e=>1===e.getInclusive()&&0===e.getKind())),!s)return null;r=!0}const a=o.isPannableRectangle(),c=s.getCoord();if(r)return{isEnvelope:r,isPannable:a,vertices:c,coef:null,bbox:[c[0][0]-t,c[0][1]-t,c[1][0]+t,c[1][1]+t]};let f=0;const u=[];let[m,x]=c[0],[h,p]=c[0];for(let l=0,g=c.length;l<g;l++){f++,f===g&&(f=0);const[e,t]=c[l],[n,o]=c[f];if(o===t)u.push([e,n,t,o,2]);else{const i=(n-e)/(o-t||1e-4),r=e-i*t;t<o?u.push([i,r,t,o,0]):u.push([i,r,o,t,1])}m=m<e?m:e,x=x<t?x:t,h=h>e?h:e,p=p>t?p:t}return{isEnvelope:!1,isPannable:a,vertices:c,coef:u,bbox:[m,x,h,p]}}function W(e,t){const o=[],{cols:i,rows:r,xres:s,yres:a,usePixelCenter:l}=e;let{xmin:c,ymax:f}=e;if(l&&(c+=s/2,f-=a/2),!n(t)){for(let e=0;e<i;e++)for(let t=0;t<r;t++)o.push([c+s*e,f-a*t]);return{points:o}}const u=new Uint8Array(i*r);if(t.isEnvelope){const{bbox:[e,n,l,m]}=t;for(let x=0,h=0;x<i;x++){const i=c+s*x,p=t.isPannable||i>=e&&i<=l;for(let e=0;e<r;e++,h++){const t=f-a*e;p&&t>=n&&t<=m&&(o.push([i,t]),u[h]=1)}}return{points:o,mask:u}}const{coef:m}=t,x=[];for(let n=0;n<r;n++){const e=f-a*n,t=[],o=[];for(let n=0;n<m.length;n++){const[i,r,s,a,l]=m[n];if(e===s&&s===a)t.push(i),t.push(r),o.push(2),o.push(2);else if(e>=s&&e<=a){const n=i*e+r;t.push(n),o.push(l)}}let i=t;if(t.length>2){let e=2===o[0]?0:o[0],n=t[0];i=[];for(let r=1;r<o.length;r++)2===o[r]&&r!==o.length-1||(o[r]!==e&&(i.push(0===e?Math.min(n,t[r-1]):Math.max(n,t[r-1])),e=o[r],n=t[r]),r===o.length-1&&i.push(0===o[r]?Math.min(n,t[r]):Math.max(n,t[r])));i.sort(((e,t)=>e-t))}else t[0]>t[1]&&(i=[t[1],t[0]]);x.push(i)}for(let n=0,h=0;n<i;n++){const e=c+s*n;for(let t=0;t<r;t++,h++){const n=f-a*t,i=x[t];if(2===i.length)e>=i[0]&&e<=i[1]&&(o.push([e,n]),u[h]=1);else if(i.length>2){let t=!1;for(let n=0;n<i.length;n+=2)if(e>=i[n]&&e<=i[n+1]){t=!0;break}t&&(o.push([e,n]),u[h]=1)}}}return{points:o,mask:u}}function O(e,t){const[n,o]=t;for(let i=0;i<e.length;i++){const t=e[i][1];(t<n||t>o)&&(e[i]=[NaN,NaN])}}function A(e){const t=L(e[0].spatialReference);if(e.length<2||!n(t))return e[0];let{xmin:o,xmax:i,ymin:r,ymax:s}=e[0];for(let n=1;n<e.length;n++){const o=e[n];i=o.xmax+t*n,r=Math.min(r,o.ymin),s=Math.max(s,o.ymax)}return new h({xmin:o,xmax:i,ymin:r,ymax:s,spatialReference:e[0].spatialReference})}function I(e,n,o=null,i=!0){if(e.spatialReference.equals(n))return e;const r=q(e),s=L(e.spatialReference,!0),a=L(n);if(0===r||t(s)||t(a))return F(e,n,o,i);const l=e.clone().normalize();if(1===l.length&&e.xmax<s&&e.xmax-s/2>G(e.spatialReference)){const{xmin:t,xmax:n}=e;for(let o=0;o<=r;o++){const i=0===o?t:-s/2,a=o===r?n-s*o:s/2;l[o]=new h({xmin:i,xmax:a,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference})}}return A(l.map((e=>F(e,n,o,i))).filter((e=>!!e)))}function F(e,n,o=null,i=!0,r=!0){const s=e.spatialReference;if(s.equals(n))return e;y(s,n,o);const a=x(e,n,o);if(r&&n.isWebMercator&&a&&(a.ymax=Math.min(20037508.342787,a.ymax),a.ymin=Math.max(-20037508.342787,a.ymin),a.ymin>=a.ymax))return null;if(!i||!a)return a;const l=Y(s,!0),c=Y(n,!0);if(t(l)||t(c))return a;const f=G(s,.001),u=G(s,500),m=G(n,.001);if(Math.abs(a.xmin-c[0])<m&&Math.abs(a.xmax-c[1])<m){const t=Math.abs(e.xmin-l[0]),i=Math.abs(l[1]-e.xmax);if(t<f&&i>u){a.xmin=c[0];const t=[];t.push(new p(e.xmax,e.ymin,s)),t.push(new p(e.xmax,(e.ymin+e.ymax)/2,s)),t.push(new p(e.xmax,e.ymax,s));const i=t.map((e=>v(e,n,o))).filter((e=>!isNaN(null==e?void 0:e.x))).map((e=>e.x));a.xmax=Math.max.apply(null,i)}if(i<f&&t>u){a.xmax=c[1];const t=[];t.push(new p(e.xmin,e.ymin,s)),t.push(new p(e.xmin,(e.ymin+e.ymax)/2,s)),t.push(new p(e.xmin,e.ymax,s));const i=t.map((e=>v(e,n,o))).filter((e=>!isNaN(null==e?void 0:e.x))).map((e=>e.x));a.xmin=Math.min.apply(null,i)}}else{const e=G(n,.001);Math.abs(a.xmin-c[0])<e&&(a.xmin=c[0]),Math.abs(a.xmax-c[1])<e&&(a.xmax=c[1])}return a}function L(e,t=!1){const n=t?20037508.342787:20037508.342788905;return e.isWebMercator?2*n:e.wkid&&e.isGeographic?360:2*M[e.wkid]||null}function Y(e,t=!1){if(e.isGeographic)return[-180,180];const o=L(e,t);return n(o)?[-o/2,o/2]:null}function B(e,t,n,o){let i=(e-t)/n;return i-Math.floor(i)!=0?i=Math.floor(i):o&&(i-=1),i}function q(e,t=!1){const o=L(e.spatialReference);if(!n(o))return 0;const i=t?0:-(o/2),r=G(e.spatialReference),s=!t&&Math.abs(e.xmax-o/2)<r?o/2:e.xmax,a=!t&&Math.abs(e.xmin+o/2)<r?-o/2:e.xmin;return B(s,i,o,!0)-B(a,i,o,!1)}function J(e){const t=e.storageInfo.origin.x,o=L(e.spatialReference,!0);if(!n(o))return{originX:t,halfWorldWidth:null,pyramidsInfo:null};const i=o/2,{nativePixelSize:r,storageInfo:s,extent:a}=e,{maximumPyramidLevel:l,blockWidth:c,pyramidScalingFactor:f}=s;let u=r.x;const m=[],x=n(e.transform)&&"gcs-shift"===e.transform.type,h=t+(x?0:i),p=x?o-t:i-t;for(let n=0;n<=l;n++){const e=(a.xmax-t)/u/c,n=e-Math.floor(e)==0?e:Math.ceil(e),o=p/u/c,i=o-Math.floor(o)==0?o:Math.ceil(o),r=Math.floor(h/u/c),s=Math.round(h/u)%c,l=(c-Math.round(p/u)%c)%c;m.push({resolutionX:u,blockWidth:c,datsetColumnCount:n,worldColumnCountFromOrigin:i,leftMargin:s,rightPadding:l,originColumnOffset:r}),u*=f}return{originX:t,halfWorldWidth:i,pyramidsInfo:m,hasGCSSShiftTransform:x}}function X(e){const t=e.isAdaptive&&null==e.spacing;let o=e.spacing||[R,R],i=K(e),r={cols:i.size[0]+1,rows:i.size[1]+1};const s=i.outofBoundPointCount>0&&i.outofBoundPointCount<i.offsets.length/2;let a=i.outofBoundPointCount===i.offsets.length/2||t&&s?[0,0]:d(i.offsets,r,o,P);const l=(a[0]+a[1])/2;if(t&&(s||l>P)){const t=e.projectedExtent.spatialReference;g(t,e.srcBufferExtent.spatialReference,e.datumTransformation)&&(t.isGeographic||n(j(t))),o=[w,w],i=K({...e,spacing:o}),r={cols:i.size[0]+1,rows:i.size[1]+1},a=d(i.offsets,r,o,P)}return i.error=a,o[0]>1&&(i.coefficients=U(i.offsets,r,s)),i}function K(e){const{projectedExtent:t,srcBufferExtent:o,pixelSize:i,datumTransformation:r,rasterTransform:s}=e,a=t.spatialReference,l=o.spatialReference;y(a,l);const{xmin:c,ymin:f,xmax:u,ymax:m}=t,x=L(l),h=n(x)&&(e.hasWrapAround||"gcs-shift"===(null==s?void 0:s.type)),g=e.spacing||[R,R],d=g[0]*i.x,M=g[1]*i.y,P=1===g[0],S=Math.ceil((u-c)/d-.1/g[0])+(P?0:1),b=Math.ceil((m-f)/M-.1/g[1])+(P?0:1),E=T({cols:S,rows:b,xmin:c,ymax:m,xres:d,yres:M,inSR:a,outSR:l,datumTransformation:r,preferPE:g[0]<=w,usePixelCenter:P}),N=[];let v,k=0;const C=P?-1:NaN,{xmin:_,xmax:j,ymax:z,width:W,height:O}=o,A=G(l,500);for(let n=0;n<S;n++){const e=[];for(let t=0;t<b;t++){let o=E[n*b+t];if(h&&o[0]>j&&o[0]>x/2-A&&(o[0]-=x),!o||isNaN(o[0])||isNaN(o[1]))N.push(C),N.push(C),e.push(null),k++;else{if(s){const e=s.inverseTransform(new p({x:o[0],y:o[1],spatialReference:l}));o=[e.x,e.y]}e.push(o),n>0&&h&&v[t]&&o[0]<v[t][0]&&(o[0]+=x),N.push((o[0]-_)/W),N.push((z-o[1])/O)}}v=e}return{offsets:N,error:null,coefficients:null,outofBoundPointCount:k,spacing:g,size:P?[S,b]:[S-1,b-1]}}function U(e,t,n){const{cols:o,rows:i}=t,r=new Float32Array((o-1)*(i-1)*2*6),s=new Float32Array([-0,-1,1,-1,1,-0,1,-0,-0]),a=new Float32Array([-1,1,0,0,-1,1,1,0,0]);for(let l=0;l<o-1;l++){for(let t=0;t<i-1;t++){let n=l*i*2+2*t;const c=e[n],f=e[n+1],u=e[n+2],m=e[n+3];n+=2*i;const x=e[n],h=e[n+1],p=e[n+2],g=e[n+3];let y=0,d=12*(t*(o-1)+l);for(let e=0;e<3;e++)r[d++]=s[y++]*c+s[y++]*u+s[y++]*p;y=0;for(let e=0;e<3;e++)r[d++]=s[y++]*f+s[y++]*m+s[y++]*g;y=0;for(let e=0;e<3;e++)r[d++]=a[y++]*c+a[y++]*x+a[y++]*p;y=0;for(let e=0;e<3;e++)r[d++]=a[y++]*f+a[y++]*h+a[y++]*g}if(n)for(let e=0;e<r.length;e++)isNaN(r[e])&&(r[e]=-1)}return r}function D(e){const t=e.clone().normalize();return 1===t.length?t[0]:A(t)}function H(e,t,o){const{storageInfo:i,pixelSize:r}=t;let s,a=!1;const{pyramidResolutions:l}=i;if(n(l)&&l.length){const n=(e.x+e.y)/2,i=l[l.length-1],c=(i.x+i.y)/2,f=(r.x+r.y)/2;if(n<=f)s=0;else if(n>=c)s=l.length,a=n/c>8;else{let e,t=f;for(let i=1;i<=l.length;i++){if(e=(l[i-1].x+l[i-1].y)/2,n<=e){n===e?s=i:"down"===o?(s=i-1,a=n/t>8):s="up"===o||n-t>e-n||n/t>2?i:i-1;break}t=e}}const u=0===s?r:l[s-1];return{pyramidLevel:s,pyramidResolution:new p({x:u.x,y:u.y,spatialReference:t.spatialReference}),excessiveReading:a}}const c=Math.log(e.x/r.x)/Math.LN2,f=Math.log(e.y/r.y)/Math.LN2,u=t.storageInfo.maximumPyramidLevel||0;s="down"===o?Math.floor(Math.min(c,f)):"up"===o?Math.ceil(Math.max(c,f)):Math.round((c+f)/2),s<0?s=0:s>u&&(a=s>u+3,s=u);const m=2**s;return{pyramidLevel:s,pyramidResolution:new p({x:m*t.nativePixelSize.x,y:m*t.nativePixelSize.y,spatialReference:t.spatialReference}),excessiveReading:a}}function Q(e,t,n=512,i=!0){const{extent:r,spatialReference:s,pixelSize:a}=e,l=N(new p({x:a.x,y:a.y,spatialReference:s}),t,r);if(null==l)return{projectedPixelSize:null,scales:null,srcResolutions:null,isCustomTilingScheme:!1};const c=(l.x+l.y)/2,f=o(t),u=c*f*96*39.37,m=t.isGeographic?256/n*295828763.7958547:256/n*591657527.591555;let x="vector-magdir"===e.dataType||"vector-uv"===e.dataType;const h=I(r,t);x||i&&(t.isGeographic||t.isWebMercator)&&(x=h.xmin*h.xmax<0);let g,y=u;const d=1.001;if(x){y=m;const e=t.isGeographic?1341104507446289e-21:.29858214164761665,n=e*(96*f*39.37),o=t.isGeographic?4326:3857;g=N(new p({x:e,y:e,spatialReference:{wkid:o}}),s,h),g.x*=y/n,g.y*=y/n}else{g={x:a.x,y:a.y};const t=Math.ceil(Math.log(Math.min(e.width,e.height)/32)/Math.LN2);let n=0;for(;y<m*(d/2)&&n<t;)n++,y*=2,g.x*=2,g.y*=2;Math.max(y,m)/Math.min(y,m)<=d&&(y=m)}const M=[y],R=[{x:g.x,y:g.y}],w=70.5310735,P=Math.min(w,u)/d;for(;y>=P;)y/=2,g.x/=2,g.y/=2,M.push(y),R.push({x:g.x,y:g.y});return{projectedPixelSize:l,scales:M,srcResolutions:R,isCustomTilingScheme:!x}}export{Q as computeProjectedScales,R as defaultGridSpacing,P as defaultProjectionToleranceInPixels,E as getDefaultDatumTransformationForDataset,T as getProjectedGridPoints,X as getProjectionOffsetGrid,J as getRasterDatasetAlignmentInfo,L as getWorldWidth,q as getWorldWrapCount,b as load,w as minimumGridSpacing,I as projectExtent,v as projectPoint,N as projectResolution,g as requirePE,D as snapExtent,H as snapPyramid};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.23.0-next.20220124",
3
+ "version": "4.23.0-next.20220126",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@esri/arcgis-html-sanitizer": "~2.9.0",
29
29
  "@esri/calcite-colors": "~6.0.1",
30
- "@esri/calcite-components": "1.0.0-beta.74",
30
+ "@esri/calcite-components": "1.0.0-beta.75",
31
31
  "@popperjs/core": "~2.11.2",
32
32
  "focus-trap": "~6.7.2",
33
33
  "luxon": "~2.3.0",
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import r from"./Content.js";var s;let p=s=class extends r{constructor(t){super(t),this.description=null,this.displayType=null,this.title=null,this.type="attachments"}clone(){return new s({description:this.description,displayType:this.displayType,title:this.title})}};t([e({type:String,json:{write:!0}})],p.prototype,"description",void 0),t([e({type:["auto","preview","list"],json:{write:!0}})],p.prototype,"displayType",void 0),t([e({type:String,json:{write:!0}})],p.prototype,"title",void 0),t([e({type:["attachments"],readOnly:!0,json:{read:!1,write:!0}})],p.prototype,"type",void 0),p=s=t([o("esri.popup.content.AttachmentsContent")],p);const i=p;export{i as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import r from"./Content.js";var s;let p=s=class extends r{constructor(t){super(t),this.description=null,this.displayType="auto",this.title=null,this.type="attachments"}clone(){return new s({description:this.description,displayType:this.displayType,title:this.title})}};t([e({type:String,json:{write:!0}})],p.prototype,"description",void 0),t([e({type:["auto","preview","list"],json:{write:!0}})],p.prototype,"displayType",void 0),t([e({type:String,json:{write:!0}})],p.prototype,"title",void 0),t([e({type:["attachments"],readOnly:!0,json:{read:!1,write:!0}})],p.prototype,"type",void 0),p=s=t([o("esri.popup.content.AttachmentsContent")],p);const i=p;export{i as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import a from"../BarChartMediaInfo.js";import r from"../ColumnChartMediaInfo.js";import e from"../ImageMediaInfo.js";import o from"../LineChartMediaInfo.js";import i from"../PieChartMediaInfo.js";import t from"../mixins/MediaInfo.js";const m={base:t,key:"type",defaultKeyValue:"image",typeMap:{"bar-chart":a,"column-chart":r,"line-chart":o,"pie-chart":i,image:e}};export{m as default,m as types};
5
+ import a from"../BarChartMediaInfo.js";import r from"../ColumnChartMediaInfo.js";import o from"../ImageMediaInfo.js";import e from"../LineChartMediaInfo.js";import i from"../PieChartMediaInfo.js";import t from"../mixins/MediaInfo.js";const m={base:t,key:"type",defaultKeyValue:"image",typeMap:{"bar-chart":a,"column-chart":r,"line-chart":e,"pie-chart":i,image:o}};export{m as types};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- const b="20220124",c="7b2ac1e8f09dcfba456186b5eb5018fd2157106d";export{b as buildDate,c as commitHash};
5
+ const e="20220126",a="441cd5ba97312ea5729deea4a664c76d0b5d34be";export{e as buildDate,a as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import o from"../core/Collection.js";import{clone as r}from"../core/lang.js";import{property as e}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{enumeration as s}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import i from"./Symbol3D.js";import a from"./TextSymbol3DLayer.js";import{calloutProperty as p,hasVisibleCallout as c,hasVisibleVerticalOffset as m}from"./callouts/calloutUtils.js";import y from"./support/Symbol3DVerticalOffset.js";var n;const u=o.ofType({base:null,key:"type",typeMap:{text:a}});let f=n=class extends i{constructor(t){super(t),this.verticalOffset=null,this.callout=null,this.styleOrigin=null,this.symbolLayers=new u,this.type="label-3d"}supportsCallout(){return!0}hasVisibleCallout(){return c(this)}hasVisibleVerticalOffset(){return m(this)}clone(){return new n({styleOrigin:r(this.styleOrigin),symbolLayers:r(this.symbolLayers),thumbnail:r(this.thumbnail),callout:r(this.callout),verticalOffset:r(this.verticalOffset)})}static fromTextSymbol(t){return new n({symbolLayers:[a.fromTextSymbol(t)]})}};t([e({type:y,json:{write:!0}})],f.prototype,"verticalOffset",void 0),t([e(p)],f.prototype,"callout",void 0),t([e({json:{read:!1,write:!1}})],f.prototype,"styleOrigin",void 0),t([e({type:u})],f.prototype,"symbolLayers",void 0),t([s({LabelSymbol3D:"label-3d"},{readOnly:!0})],f.prototype,"type",void 0),f=n=t([l("esri.symbols.LabelSymbol3D")],f);const b=f;export{b as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import o from"../core/Collection.js";import{clone as r}from"../core/lang.js";import{property as e}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{enumeration as s}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import i from"./Symbol3D.js";import a from"./TextSymbol3DLayer.js";import{calloutProperty as p,hasVisibleCallout as c,hasVisibleVerticalOffset as m}from"./callouts/calloutUtils.js";import{Symbol3DVerticalOffset as y}from"./support/Symbol3DVerticalOffset.js";var n;const u=o.ofType({base:null,key:"type",typeMap:{text:a}});let f=n=class extends i{constructor(t){super(t),this.verticalOffset=null,this.callout=null,this.styleOrigin=null,this.symbolLayers=new u,this.type="label-3d"}supportsCallout(){return!0}hasVisibleCallout(){return c(this)}hasVisibleVerticalOffset(){return m(this)}clone(){return new n({styleOrigin:r(this.styleOrigin),symbolLayers:r(this.symbolLayers),thumbnail:r(this.thumbnail),callout:r(this.callout),verticalOffset:r(this.verticalOffset)})}static fromTextSymbol(t){return new n({symbolLayers:[a.fromTextSymbol(t)]})}};t([e({type:y,json:{write:!0}})],f.prototype,"verticalOffset",void 0),t([e(p)],f.prototype,"callout",void 0),t([e({json:{read:!1,write:!1}})],f.prototype,"styleOrigin",void 0),t([e({type:u})],f.prototype,"symbolLayers",void 0),t([s({LabelSymbol3D:"label-3d"},{readOnly:!0})],f.prototype,"type",void 0),f=n=t([l("esri.symbols.LabelSymbol3D")],f);const b=f;export{b as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Collection.js";import o from"../core/Error.js";import{clone as r}from"../core/lang.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{enumeration as l}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../core/accessorSupport/decorators/writer.js";import a from"./IconSymbol3DLayer.js";import m from"./ObjectSymbol3DLayer.js";import n from"./Symbol3D.js";import c from"./TextSymbol3DLayer.js";import{calloutProperty as p,hasVisibleCallout as b,hasVisibleVerticalOffset as u}from"./callouts/calloutUtils.js";import f from"./support/Symbol3DVerticalOffset.js";var S;const h=e.ofType({base:null,key:"type",typeMap:{icon:a,object:m,text:c}}),j=e.ofType({base:null,key:"type",typeMap:{icon:a,object:m}});let d=S=class extends n{constructor(t){super(t),this.verticalOffset=null,this.callout=null,this.symbolLayers=new h,this.type="point-3d"}writeSymbolLayers(t,e,r,s){const l=t.filter((t=>"text"!==t.type));if(s&&s.messages&&l.length<t.length){const e=t.find((t=>"text"===t.type));s.messages.push(new o("symbol-layer:unsupported","Symbol layers of type 'text' cannot be persisted in PointSymbol3D",{symbolLayer:e}))}e[r]=l.map((t=>t.write({},s))).toArray()}supportsCallout(){if((this.symbolLayers?this.symbolLayers.length:0)<1)return!1;for(const t of this.symbolLayers.items)switch(t.type){case"icon":case"text":case"object":continue;default:return!1}return!0}hasVisibleCallout(){return b(this)}hasVisibleVerticalOffset(){return u(this)}clone(){return new S({verticalOffset:r(this.verticalOffset),callout:r(this.callout),styleOrigin:r(this.styleOrigin),symbolLayers:r(this.symbolLayers),thumbnail:r(this.thumbnail)})}static fromSimpleMarkerSymbol(t){return new S({symbolLayers:[a.fromSimpleMarkerSymbol(t)]})}static fromPictureMarkerSymbol(t){return new S({symbolLayers:[a.fromPictureMarkerSymbol(t)]})}static fromCIMSymbol(t){var e,o;if("CIMPointSymbol"!==(null==(e=t.data)||null==(o=e.symbol)?void 0:o.type))return null;return t.data.symbol.callout?new S({symbolLayers:[a.fromCIMSymbol(t)],callout:{type:"line",size:.5,color:[0,0,0]},verticalOffset:{screenLength:40}}):new S({symbolLayers:[a.fromCIMSymbol(t)]})}static fromTextSymbol(t){return new S({symbolLayers:[c.fromTextSymbol(t)]})}};t([s({type:f,json:{write:!0}})],d.prototype,"verticalOffset",void 0),t([s(p)],d.prototype,"callout",void 0),t([s({type:h,json:{type:j,origins:{"web-scene":{type:j}}}})],d.prototype,"symbolLayers",void 0),t([y("web-scene","symbolLayers")],d.prototype,"writeSymbolLayers",null),t([l({PointSymbol3D:"point-3d"},{readOnly:!0})],d.prototype,"type",void 0),d=S=t([i("esri.symbols.PointSymbol3D")],d);const L=d;export{L as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import e from"../core/Collection.js";import o from"../core/Error.js";import{clone as r}from"../core/lang.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{enumeration as l}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{writer as y}from"../core/accessorSupport/decorators/writer.js";import a from"./IconSymbol3DLayer.js";import m from"./ObjectSymbol3DLayer.js";import n from"./Symbol3D.js";import c from"./TextSymbol3DLayer.js";import{calloutProperty as p,hasVisibleCallout as b,hasVisibleVerticalOffset as u}from"./callouts/calloutUtils.js";import{Symbol3DVerticalOffset as f}from"./support/Symbol3DVerticalOffset.js";var S;const h=e.ofType({base:null,key:"type",typeMap:{icon:a,object:m,text:c}}),j=e.ofType({base:null,key:"type",typeMap:{icon:a,object:m}});let d=S=class extends n{constructor(t){super(t),this.verticalOffset=null,this.callout=null,this.symbolLayers=new h,this.type="point-3d"}writeSymbolLayers(t,e,r,s){const l=t.filter((t=>"text"!==t.type));if(s&&s.messages&&l.length<t.length){const e=t.find((t=>"text"===t.type));s.messages.push(new o("symbol-layer:unsupported","Symbol layers of type 'text' cannot be persisted in PointSymbol3D",{symbolLayer:e}))}e[r]=l.map((t=>t.write({},s))).toArray()}supportsCallout(){if((this.symbolLayers?this.symbolLayers.length:0)<1)return!1;for(const t of this.symbolLayers.items)switch(t.type){case"icon":case"text":case"object":continue;default:return!1}return!0}hasVisibleCallout(){return b(this)}hasVisibleVerticalOffset(){return u(this)}clone(){return new S({verticalOffset:r(this.verticalOffset),callout:r(this.callout),styleOrigin:r(this.styleOrigin),symbolLayers:r(this.symbolLayers),thumbnail:r(this.thumbnail)})}static fromSimpleMarkerSymbol(t){return new S({symbolLayers:[a.fromSimpleMarkerSymbol(t)]})}static fromPictureMarkerSymbol(t){return new S({symbolLayers:[a.fromPictureMarkerSymbol(t)]})}static fromCIMSymbol(t){var e,o;if("CIMPointSymbol"!==(null==(e=t.data)||null==(o=e.symbol)?void 0:o.type))return null;return t.data.symbol.callout?new S({symbolLayers:[a.fromCIMSymbol(t)],callout:{type:"line",size:.5,color:[0,0,0]},verticalOffset:{screenLength:40}}):new S({symbolLayers:[a.fromCIMSymbol(t)]})}static fromTextSymbol(t){return new S({symbolLayers:[c.fromTextSymbol(t)]})}};t([s({type:f,json:{write:!0}})],d.prototype,"verticalOffset",void 0),t([s(p)],d.prototype,"callout",void 0),t([s({type:h,json:{type:j,origins:{"web-scene":{type:j}}}})],d.prototype,"symbolLayers",void 0),t([y("web-scene","symbolLayers")],d.prototype,"writeSymbolLayers",null),t([l({PointSymbol3D:"point-3d"},{readOnly:!0})],d.prototype,"type",void 0),d=S=t([i("esri.symbols.PointSymbol3D")],d);const L=d;export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import{bidiText as t}from"../../core/BidiText.js";import{packFloatRGBA as r}from"../../core/floatRGBA.js";import{clone as o}from"../../core/lang.js";import i from"../../core/Logger.js";import{nextPowerOfTwo as a}from"../../core/mathUtils.js";import{isSome as s}from"../../core/maybe.js";import{pt2px as n,px2pt as l}from"../../core/screenUtils.js";import{create as c,expandPointInPlace as m}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as f}from"../../geometry/support/boundsUtils.js";import{Placement as y}from"./CIMPlacements.js";import{lineGapType2LineHeight as h,horizontalAlignment2HAlign as u,verticalAlignment2VAlign as p,EnvDrawHelper as S,Transformation as M,CanvasDrawHelper as d}from"./CIMSymbolDrawHelper.js";import{LineCapStyle as b,LineJoinStyle as g,BlockProgression as C,FontEffects as I,FontEncoding as k,FontType as x,GlyphHinting as w,TextReadingDirection as P,VerticalGlyphOrientation as L,BillBoardMode as v,TextureFilter as F,ExtremityPlacement as T}from"./enums.js";import{getValue as z}from"./utils.js";import{C_INFINITY as D}from"../../views/2d/engine/vectorTiles/GeometryUtils.js";import{GLYPH_SIZE as G,MAGIC_LABEL_LINE_HEIGHT as A}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as N}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const E=Math.PI,O=E/2,R=4,j=10,V=96/72,B=Math.PI/180,X=i.getLogger("esri.symbols.cim.CIMSymbolHelper");function Y(e){if(!e||!e.type)return null;let t;switch(e.type){case"cim":return e.data;case"web-style":return e;case"simple-marker":t=$.fromSimpleMarker(e);break;case"picture-marker":t=$.fromPictureMarker(e);break;case"simple-line":t=$.fromSimpleLineSymbol(e);break;case"simple-fill":t=$.fromSimpleFillSymbol(e);break;case"picture-fill":t=$.fromPictureFillSymbol(e);break;case"text":t=$.fromTextSymbol(e)}return{type:"CIMSymbolReference",symbol:t}}function U(e,t){switch(t.type){case"CIMSymbolReference":return U(e,t.symbol);case"CIMPointSymbol":{const r={x:0,y:0};e.drawSymbol(t,r);break}case"CIMLineSymbol":{const r={paths:[[[0,0],[0,1]]]};e.drawSymbol(t,r);break}case"CIMPolygonSymbol":{const r={rings:[[[0,0],[0,1],[0,0]]]};e.drawSymbol(t,r);break}case"CIMTextSymbol":{const r={x:0,y:0};e.drawSymbol(t,r);break}case"CIMVectorMarker":{const r=new y;e.drawMarker(t,r);break}}return e.envelope()}function _(e){if(!e)return 0;switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAtExtremities":case"CIMMarkerPlacementAtMeasuredUnits":case"CIMMarkerPlacementAtRatioPositions":case"CIMMarkerPlacementOnLine":case"CIMMarkerPlacementOnVertices":return Math.abs(e.offset);default:return 0}}function H(e){if(!e)return 0;switch(e.type){case"CIMGeometricEffectArrow":return Math.abs(.5*e.width);case"CIMGeometricEffectBuffer":return Math.abs(e.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(e.length);case"CIMGeometricEffectJog":return Math.abs(.5*e.length);case"CIMGeometricEffectMove":return Math.max(Math.abs(z(e.offsetX)),Math.abs(z(e.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(e.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(e.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(e.fromWidth),Math.abs(e.toWidth));case"CIMGeometricEffectWave":return Math.abs(e.amplitude)}}function q(e){if(!e)return 0;let t=0;for(const r of e)t+=H(r);return t}class W{getSymbolInflateSize(e,t,r,o,i){return e||(e=[0,0,0,0]),t?this._getInflateSize(e,t,r,o,i):e}static safeSize(e){const t=Math.max(Math.abs(e[0]),Math.abs(e[2])),r=Math.max(Math.abs(e[1]),Math.abs(e[3]));return Math.sqrt(t*t+r*r)}_vectorMarkerBounds(e,t,r,o){let i=!0;const a=c();if(t&&t.markerGraphics)for(const s of t.markerGraphics){const t=[0,0,0,0];s.geometry&&(f(a,s.geometry),t[0]=0,t[1]=0,t[2]=0,t[3]=0,this.getSymbolInflateSize(t,s.symbol,r,0,o),a[0]+=t[0],a[1]+=t[1],a[2]+=t[2],a[3]+=t[3],i?(e[0]=a[0],e[1]=a[1],e[2]=a[2],e[3]=a[3],i=!1):(e[0]=Math.min(e[0],a[0]),e[1]=Math.min(e[1],a[1]),e[2]=Math.max(e[2],a[2]),e[3]=Math.max(e[3],a[3])))}return e}_getInflateSize(e,t,r,o,i){if(ne(t)){const a=this._getLayersInflateSize(e,t.symbolLayers,r,o,i),s=q(t.effects);return s>0&&(a[0]-=s,a[1]-=s,a[2]+=s,a[3]+=s),a}return this._getTextInflatedSize(e,t,i)}_getLayersInflateSize(e,t,r,o,i){let a=!0;if(!t)return e;for(const n of t){if(!n)continue;let t=[0,0,0,0];switch(n.type){case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const e=n;let r=e.width;e.capStyle===b.Square||e.joinStyle===g.Miter?r/=1.4142135623730951:r/=2,t[0]=-r,t[1]=-r,t[2]=r,t[3]=r;break}case"CIMCharacterMarker":case"CIMVectorMarker":case"CIMPictureMarker":{const e=n;if("CIMVectorMarker"===n.type){const e=n;if(t=this._vectorMarkerBounds(t,e,r,i),e.frame){const r=(e.frame.xmin+e.frame.xmax)/2,o=(e.frame.ymin+e.frame.ymax)/2;t[0]-=r,t[1]-=o,t[2]-=r,t[3]-=o;const i=e.size/(e.frame.ymax-e.frame.ymin);t[0]*=i,t[1]*=i,t[2]*=i,t[3]*=i}}else if("CIMPictureMarker"===n.type){const o=n,i=r.getResource(o.url);let a=1;s(i)&&i.height&&(a=i.width/i.height);const l=e.size/2,c=e.size*a*o.scaleX/2;t=[-c,-l,c,l]}else{const r=e.size/2;t=[-r,-r,r,r]}if(e.anchorPoint){let r,o;"Absolute"===e.anchorPointUnits?(r=e.anchorPoint.x,o=e.anchorPoint.y):(r=e.anchorPoint.x*(t[2]-t[0]),o=e.anchorPoint.y*(t[3]-t[1])),t[0]-=r,t[1]-=o,t[2]-=r,t[3]-=o}let a=z(e.rotation);if(e.rotateClockwise&&(a=-a),o&&(a-=o),a){const e=B*a,r=Math.cos(e),o=Math.sin(e),i=c([D,D,-D,-D]);m(i,[t[0]*r-t[1]*o,t[0]*o+t[1]*r]),m(i,[t[0]*r-t[3]*o,t[0]*o+t[3]*r]),m(i,[t[2]*r-t[1]*o,t[2]*o+t[1]*r]),m(i,[t[2]*r-t[3]*o,t[2]*o+t[3]*r]),t=i}let l=z(e.offsetX),f=z(e.offsetY);if(o){const e=B*o,t=Math.cos(e),r=Math.sin(e),i=l*r+f*t;l=l*t-f*r,f=i}t[0]+=l,t[1]+=f,t[2]+=l,t[3]+=f;const y=_(e.markerPlacement);y>0&&(t[0]-=y,t[1]-=y,t[2]+=y,t[3]+=y);break}}const l=q(n.effects);l>0&&(t[0]-=l,t[1]-=l,t[2]+=l,t[3]+=l),a?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],a=!1):(e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[2]),e[3]=Math.max(e[3],t[3]))}return e}_getTextInflatedSize(e,r,o){var i,a;const s=null!=(i=r.height)?i:j;if(e[0]=-s/2,e[1]=-s/2,e[2]=s/2,e[3]=s/2,!o)return e;const n=o.get(r);if(!n)return e;const{text:l,mosaicItem:c}=n;if(!c||0===c.glyphMosaicItems.length)return e;const m=h(r.lineGapType,null!=(a=r.lineGap)?a:0,s),f=t(l)[1],y=c.glyphMosaicItems,S=N(y,f,{scale:s/G,angle:z(r.angle),xOffset:z(r.offsetX),yOffset:z(r.offsetY),hAlign:u(r.horizontalAlignment),vAlign:p(r.verticalAlignment),maxLineWidth:512,lineHeight:A*Math.max(.25,Math.min(m||1,4)),decoration:r.font.decoration||"none",isCIM:!0}).boundsT;return e[0]=S.x-S.halfWidth,e[1]=-S.y-S.halfHeight,e[2]=S.x+S.halfWidth,e[3]=-S.y+S.halfHeight,e}}class ${static getEnvelope(e,t){const r=new S(t);if(Array.isArray(e)){let t;for(const o of e)t?t.union(U(r,o)):t=U(r,o);return t}return U(r,e)}static getTextureAnchor(e,t){const r=this.getEnvelope(e,t);if(!r)return[0,0,0];const o=(r.x+.5*r.width)*V,i=-(r.y+.5*r.height)*V,a=r.width*V+2,s=r.height*V+2;return[o/a,i/s,s]}static rasterize(e,t,r,o,i=!0){const a=r||this.getEnvelope(t,o);if(!a)return[null,0,0,0,0];const s=(a.x+.5*a.width)*V,n=(a.y+.5*a.height)*V;e.width=a.width*V,e.height=a.height*V,r||(e.width+=2,e.height+=2);const l=e.getContext("2d"),c=M.createScale(V,-V);c.translate(.5*e.width-s,.5*e.height+n);const m=new d(l,o,c);switch(t.type){case"CIMPointSymbol":{const e={type:"point",x:0,y:0};m.drawSymbol(t,e);break}case"CIMVectorMarker":{const e=new y;m.drawMarker(t,e);break}}const f=l.getImageData(0,0,e.width,e.height),h=new Uint8Array(f.data);if(i){let e;for(let t=0;t<h.length;t+=4)e=h[t+3]/255,h[t]=h[t]*e,h[t+1]=h[t+1]*e,h[t+2]=h[t+2]*e}return[h,e.width,e.height,-s/e.width,-n/e.height]}static fromTextSymbol(e){const{angle:r,color:o,font:i,haloColor:a,haloSize:s,horizontalAlignment:n,kerning:l,text:c,verticalAlignment:m,xoffset:f,yoffset:y}=e;let h,u,p,S,M;i&&(h=i.family,u=i.style,p=i.weight,S=i.size,M=i.decoration);let d=!1;if(c){d=t(c)[1]}return{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,anchorPointUnits:"Relative",dominantSizeAxis3D:"Y",size:10,billboardMode3D:"FaceNearPlane",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",angle:r,blockProgression:C.BTT,depth3D:1,extrapolateBaselines:!0,fontEffects:I.Normal,fontEncoding:k.Unicode,fontFamilyName:h||"Arial",fontStyleName:oe(u,p),fontType:x.Unspecified,haloSize:s,height:S,hinting:w.Default,horizontalAlignment:ee(null!=n?n:"center"),kerning:l,letterWidth:100,ligatures:!0,lineGapType:"Multiple",offsetX:z(f),offsetY:z(y),strikethrough:"line-through"===M,underline:"underline"===M,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:re(o)}]},haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:re(a)}]},shadowColor:[0,0,0,255],shadowOffsetX:1,shadowOffsetY:1,textCase:"Normal",textDirection:d?P.RTL:P.LTR,verticalAlignment:te(null!=m?m:"baseline"),verticalGlyphOrientation:L.Right,wordSpacing:100,billboardMode3D:v.FaceNearPlane},textString:c}],scaleSymbolsProportionally:!0,respectFrame:!0}],scaleX:1,angleAlignment:"Display"}}static fromPictureFillSymbol(e){const{height:t,outline:r,width:o,xoffset:i,xscale:a,yoffset:s,yscale:n}=e,l=[],c={type:"CIMPolygonSymbol",symbolLayers:l};if(r){const{cap:e,join:t,miterLimit:o,width:i}=r;l.push({type:"CIMSolidStroke",color:re(r.color),capStyle:Q(e),joinStyle:Z(t),miterLimit:o,width:i})}let m=e.url;"esriPFS"===e.type&&e.imageData&&(m=e.imageData);const f="angle"in e?e.angle:0,y=o*(a||1),h=t*(n||1);return l.push({type:"CIMPictureFill",invertBackfaceTexture:!1,scaleX:1,textureFilter:F.Picture,tintColor:null,url:m,height:h,width:y,offsetX:z(i),offsetY:z(s),rotation:z(-f),colorSubstitutions:null}),c}static fromSimpleFillSymbol(e){const{color:t,style:r,outline:i}=e,s=[],n={type:"CIMPolygonSymbol",symbolLayers:s};let l=null;if(i){const{cap:e,join:t,style:r}=i;"solid"!==r&&"none"!==r&&"esriSLSSolid"!==r&&"esriSLSNull"!==r&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:se(r,e),lineDashEnding:"NoConstraint",scaleDash:!0}]),s.push({type:"CIMSolidStroke",color:re(i.color),capStyle:Q(e),joinStyle:Z(t),miterLimit:i.miterLimit,width:i.width,effects:l})}if(r&&"solid"!==r&&"none"!==r&&"esriSFSSolid"!==r&&"esriSFSNull"!==r){const e={type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",color:re(t),capStyle:b.Butt,joinStyle:g.Miter,width:.75}]};let i=0;const n=a(Math.ceil(window.devicePixelRatio)),l=ce(r)?8*n:10*n;switch(r){case"vertical":case"esriSFSVertical":i=90;break;case"forward-diagonal":case"esriSFSForwardDiagonal":case"diagonal-cross":case"esriSFSDiagonalCross":i=-45;break;case"backward-diagonal":case"esriSFSBackwardDiagonal":i=45;break;case"cross":case"esriSFSCross":i=0}s.push({type:"CIMHatchFill",lineSymbol:e,offsetX:0,offsetY:0,rotation:i,separation:l}),"cross"===r||"esriSFSCross"===r?s.push({type:"CIMHatchFill",lineSymbol:o(e),offsetX:0,offsetY:0,rotation:90,separation:l}):"diagonal-cross"!==r&&"esriSFSDiagonalCross"!==r||s.push({type:"CIMHatchFill",lineSymbol:o(e),offsetX:0,offsetY:0,rotation:45,separation:l})}else!r||"solid"!==r&&"esriSFSSolid"!==r||s.push({type:"CIMSolidFill",enable:!0,color:re(t)});return n}static fromSimpleLineSymbol(e){const{cap:t,color:r,join:o,marker:i,miterLimit:a,style:s,width:n}=e;let l=null;"solid"!==s&&"none"!==s&&"esriSLSSolid"!==s&&"esriSLSNull"!==s&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:se(s,t),lineDashEnding:"NoConstraint",scaleDash:!0}]);const c=[];if(i){let e;switch(i.placement){case"begin-end":e=T.Both;break;case"begin":e=T.JustBegin;break;case"end":e=T.JustEnd;break;default:e=T.None}const t=$.fromSimpleMarker(i,n,r).symbolLayers[0];t.markerPlacement={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:e,offsetAlongLine:0},c.push(t)}return"none"!==s&&"esriSLSNull"!==s&&c.push({type:"CIMSolidStroke",color:re(r),capStyle:Q(t),joinStyle:Z(o),miterLimit:a,width:n,effects:l}),{type:"CIMLineSymbol",symbolLayers:c}}static fromPictureMarker(e){const{angle:t,height:r,width:o,xoffset:i,yoffset:a}=e;let s=e.url;return"esriPMS"===e.type&&e.imageData&&(s=e.imageData),{type:"CIMPointSymbol",symbolLayers:[{type:"CIMPictureMarker",invertBackfaceTexture:!1,scaleX:1,textureFilter:F.Picture,tintColor:null,url:s,size:r,width:o,offsetX:z(i),offsetY:z(a),rotation:z(-t)}]}}static fromSimpleMarker(e,t,r){var o;const{style:i}=e,a=null!=(o=e.color)?o:r;if("path"===i){const t=[];if("outline"in e&&e.outline){const r=e.outline;t.push({type:"CIMSolidStroke",enable:!0,width:n(Math.round(l(r.width))),color:re(r.color)})}t.push({type:"CIMSolidFill",enable:!0,color:re(a),path:e.path});const[r,o]=le("square");return{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:r,markerGraphics:[{type:"CIMMarkerGraphic",geometry:o,symbol:{type:"CIMPolygonSymbol",symbolLayers:t}}]}]}}const[s,c]=le(i);let m;if(c&&s){const r=[];if("outline"in e&&e.outline){const t=e.outline;r.push({type:"CIMSolidStroke",enable:!0,width:n(Math.round(l(t.width))),color:re(t.color)})}else!t||"line-marker"!==e.type||"cross"!==e.style&&"x"!==e.style||r.push({type:"CIMSolidStroke",enable:!0,width:t,color:re(a)});r.push({type:"CIMSolidFill",enable:!0,color:re(a)});const o={type:"CIMPolygonSymbol",symbolLayers:r};m={type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6*t),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:s,markerGraphics:[{type:"CIMMarkerGraphic",geometry:c,symbol:o}]}]}}return m}static fromCIMHatchFill(e){var t;const r=null!=(t=e.separation)?t:R,o=r/2,i=4;let a=this._getLineSymbolPeriod(e.lineSymbol)||i;for(;a<i;)a*=2;const s=a/2;return{type:"CIMVectorMarker",frame:{xmin:-s,xmax:s,ymin:-o,ymax:o},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[-s,0],[s,0]]]},symbol:e.lineSymbol}],size:r}}static _getLineSymbolPeriod(e){if(e){const t=this._getEffectsRepeat(e.effects);if(t)return t;if(e.symbolLayers)for(const r of e.symbolLayers){const e=this._getEffectsRepeat(r.effects);if(e)return e;if(r){const e=this._getPlacementRepeat(r.markerPlacement);if(e)return e}}}return 0}static _getEffectsRepeat(e){if(e)for(const t of e)if(t)switch(t.type){case"CIMGeometricEffectDashes":{const e=t.dashTemplate;if(e&&e.length){let t=0;for(const r of e)t+=r;return 1&e.length&&(t*=2),t}break}case"CIMGeometricEffectWave":return t.period;default:X.error(`unsupported geometric effect type ${t.type}`)}return 0}static _getPlacementRepeat(e){if(e)switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAlongLineVariableSize":{const t=e.placementTemplate;if(t&&t.length){let e=0;for(const r of t)e+=r;return 1&t.length&&(e*=2),e}break}}return 0}static fromCIMInsidePolygon(e){const t=e.markerPlacement,r={type:e.type,...e};let o,i,a,s;if(r.markerPlacement=null,r.anchorPoint=null,!0===t.shiftOddRows){i=t.stepX/2,a=t.stepY,s=2*t.stepY;o=[{x:-i,y:0},{x:i,y:0},{x:0,y:a},{x:0,y:-a}].map((e=>({type:"CIMMarkerGraphic",geometry:e,symbol:{type:"CIMPointSymbol",symbolLayers:[r]}})))}else i=t.stepX/2,a=t.stepY/2,s=t.stepY,o=[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:{type:"CIMPointSymbol",symbolLayers:[r]}}];return{type:"CIMVectorMarker",frame:{xmin:-i,xmax:i,ymin:-a,ymax:a},markerGraphics:o,size:s}}static getFillColor(e){if(!e)return null;switch(e.type){case"CIMPolygonSymbol":if(e.symbolLayers)for(const t of e.symbolLayers){const e=$.getFillColor(t);if(null!=e)return e}break;case"CIMTextSymbol":return $.getFillColor(e.symbol);case"CIMSolidFill":return e.color}}static getStrokeColor(e){if(e)switch(e.type){case"CIMPolygonSymbol":case"CIMLineSymbol":if(e.symbolLayers)for(const t of e.symbolLayers){const e=$.getStrokeColor(t);if(void 0!==e)return e}break;case"CIMTextSymbol":return $.getStrokeColor(e.symbol);case"CIMSolidStroke":return e.color}}static getStrokeWidth(e){if(e)switch(e.type){case"CIMPolygonSymbol":case"CIMLineSymbol":if(e.symbolLayers)for(const t of e.symbolLayers){const e=$.getStrokeWidth(t);if(void 0!==e)return e}break;case"CIMTextSymbol":return $.getStrokeWidth(e.symbol);case"CIMSolidStroke":case"CIMGradientStroke":case"CIMPictureStroke":return e.width}}static getSize(e){if(e)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":{let t=0;if(e.symbolLayers)for(const r of e.symbolLayers){const e=$.getSize(r);e>t&&(t=e)}return t}case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":return e.width;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":return e.size}}static getMarkerScaleRatio(e){if(e&&"CIMVectorMarker"===e.type)if(!1!==e.scaleSymbolsProportionally&&e.frame){const t=e.frame.ymax-e.frame.ymin;return e.size/t}return 1}}class J{static rasterizeSimpleFill(e,t,r){"solid"!==t&&"none"!==t&&"esriSFSSolid"!==t&&"esriSFSNull"!==t||console.error("Unexpected: style does not require rasterization");const o=a(Math.ceil(r)),i=ce(t)?8*o:16*o,s=2*o;e.width=i,e.height=i;const n=e.getContext("2d");n.strokeStyle="#FFFFFF",n.lineWidth=o,n.beginPath(),"vertical"!==t&&"cross"!==t&&"esriSFSCross"!==t&&"esriSFSVertical"!==t||(n.moveTo(i/2,-s),n.lineTo(i/2,i+s)),"horizontal"!==t&&"cross"!==t&&"esriSFSCross"!==t&&"esriSFSHorizontal"!==t||(n.moveTo(-s,i/2),n.lineTo(i+s,i/2)),"forward-diagonal"!==t&&"diagonal-cross"!==t&&"esriSFSDiagonalCross"!==t&&"esriSFSForwardDiagonal"!==t||(n.moveTo(-s,-s),n.lineTo(i+s,i+s),n.moveTo(i-s,-s),n.lineTo(i+s,s),n.moveTo(-s,i-s),n.lineTo(s,i+s)),"backward-diagonal"!==t&&"diagonal-cross"!==t&&"esriSFSBackwardDiagonal"!==t&&"esriSFSDiagonalCross"!==t||(n.moveTo(i+s,-s),n.lineTo(-s,i+s),n.moveTo(s,-s),n.lineTo(-s,s),n.moveTo(i+s,i-s),n.lineTo(i-s,i+s)),n.stroke();const l=n.getImageData(0,0,e.width,e.height),c=new Uint8Array(l.data);let m;for(let a=0;a<c.length;a+=4)m=c[a+3]/255,c[a]=c[a]*m,c[a+1]=c[a+1]*m,c[a+2]=c[a+2]*m;return[c,e.width,e.height]}static rasterizeSimpleLine(e,t){return this.rasterizeDash(e,t)}static rasterizeDash(e,t){const o="Butt"===t,i="Square"===t,a=!o&&!i;e.length%2==1&&(e=[...e,...e]);const s=15.5,n=2*s;let l=0;for(const r of e)l+=r;const c=Math.round(l*s),m=new Float32Array(c*n),f=.5*s;let y=0,h=0,u=.5,p=!0;for(const r of e){for(y=h,h+=r*s;u<=h;){let e=.5;for(;e<n;){const t=(e-.5)*c+u-.5,r=a?(e-s)*(e-s):Math.abs(e-s);m[t]=p?o?Math.max(Math.max(y+f-u,r),Math.max(u-h+f,r)):r:a?Math.min((u-y)*(u-y)+r,(u-h)*(u-h)+r):i?Math.min(Math.max(u-y,r),Math.max(h-u,r)):Math.min(Math.max(u-y+f,r),Math.max(h+f-u,r)),e++}u++}p=!p}const S=m.length,M=new Uint8Array(4*S);for(let d=0;d<S;++d){const e=(a?Math.sqrt(m[d]):m[d])/s;r(e,M,4*d)}return[M,c,n]}}class K{static findApplicableOverrides(e,t,r){if(e&&t){if(e.primitiveName){let o=!1;for(const t of r)if(t.primitiveName===e.primitiveName){o=!0;break}if(!o)for(const i of t)i.primitiveName===e.primitiveName&&r.push(i)}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const o of e.effects)K.findApplicableOverrides(o,t,r);if(e.symbolLayers)for(const o of e.symbolLayers)K.findApplicableOverrides(o,t,r);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":if(e.effects)for(const o of e.effects)K.findApplicableOverrides(o,t,r);if(e.markerPlacement&&K.findApplicableOverrides(e.markerPlacement,t,r),"CIMVectorMarker"===e.type){if(e.markerGraphics)for(const o of e.markerGraphics)K.findApplicableOverrides(o,t,r),K.findApplicableOverrides(o.symbol,t,r)}else"CIMCharacterMarker"===e.type?K.findApplicableOverrides(e.symbol,t,r):"CIMHatchFill"===e.type&&K.findApplicableOverrides(e.lineSymbol,t,r)}}}static findEffectOverrides(e,t,r){if(!t||!e)return;const o=e.length;for(let i=0;i<o;i++){const o=e[i],a=null==o?void 0:o.primitiveName;if(a){let e=!1;for(const t of r)if(t.primitiveName===a){e=!0;break}if(!e)for(const o of t)o.primitiveName===a&&r.push(o)}}}static applyOverrides(e,t,r,o){if(!t)return;const i=e=>e?e.charAt(0).toLowerCase()+e.substr(1):e;if(e.primitiveName)for(const a of t)if(a.primitiveName===e.primitiveName){const t=i(a.propertyName);if(o&&o.push({cim:e,nocapPropertyName:t,value:e[t]}),a.expression&&(a.value=K.toValue(a.propertyName,a.expression)),r){let t=!1;for(const o of r)o.primitiveName===e.primitiveName&&(t=!0);t||r.push(a)}e[t]=a.value}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const i of e.effects)K.applyOverrides(i,t,r,o);if(e.symbolLayers)for(const i of e.symbolLayers)K.applyOverrides(i,t,r,o);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if(e.effects)for(const i of e.effects)K.applyOverrides(i,t,r,o);if("CIMVectorMarker"===e.type&&e.markerGraphics)for(const i of e.markerGraphics)K.applyOverrides(i,t,r,o),K.applyOverrides(i.symbol,t,r,o)}}static restoreOverrides(e){for(const t of e)t.cim[t.nocapPropertyName]=t.value}static buildOverrideKey(e){let t="";for(const r of e)void 0!==r.value&&(t+=`${r.primitiveName}${r.propertyName}${JSON.stringify(r.value)}`);return t}static toValue(t,r){if("DashTemplate"===t)return r.split(" ").map((e=>Number(e)));if("Color"===t){const t=new e(r).toRgba();return t[3]*=255,t}return r}}const Q=e=>{if(!e)return b.Butt;switch(e){case"butt":return b.Butt;case"square":return b.Square;case"round":return b.Round}},Z=e=>{if(!e)return g.Miter;switch(e){case"miter":return g.Miter;case"round":return g.Round;case"bevel":return g.Bevel}},ee=e=>{if(!e)return"Center";switch(e){case"left":return"Left";case"right":return"Right";case"center":return"Center";case"justify":return"Justify"}},te=e=>{if(!e)return"Center";switch(e){case"baseline":return"Baseline";case"top":return"Top";case"middle":return"Center";case"bottom":return"Bottom"}},re=e=>{if(!e)return[0,0,0,0];const{r:t,g:r,b:o,a:i}=e;return[t,r,o,255*i]},oe=(e,t)=>{const r=ie(t),o=ae(e);return r&&o?`${r}-${o}`:`${r}${o}`},ie=e=>{if(!e)return"";switch(e.toLowerCase()){case"bold":case"bolder":return"bold"}return""},ae=e=>{if(!e)return"";switch(e.toLowerCase()){case"italic":case"oblique":return"italic"}return""},se=(e,t)=>{const r="butt"===t;switch(e){case"dash":case"esriSLSDash":return r?[4,3]:[3,4];case"dash-dot":case"esriSLSDashDot":return r?[4,3,1,3]:[3,4,0,4];case"dot":case"esriSLSDot":return r?[1,3]:[0,4];case"long-dash":case"esriSLSLongDash":return r?[8,3]:[7,4];case"long-dash-dot":case"esriSLSLongDashDot":return r?[8,3,1,3]:[7,4,0,4];case"long-dash-dot-dot":case"esriSLSDashDotDot":return r?[8,3,1,3,1,3]:[7,4,0,4,0,4];case"short-dash":case"esriSLSShortDash":return r?[4,1]:[3,2];case"short-dash-dot":case"esriSLSShortDashDot":return r?[4,1,1,1]:[3,2,0,2];case"short-dash-dot-dot":case"esriSLSShortDashDotDot":return r?[4,1,1,1,1,1]:[3,2,0,2,0,2];case"short-dot":case"esriSLSShortDot":return r?[1,1]:[0,2];case"solid":case"esriSLSSolid":case"none":return X.error("Unexpected: style does not require rasterization"),[0,0];default:return X.error(`Tried to rasterize SLS, but found an unexpected style: ${e}!`),[0,0]}};function ne(e){return void 0!==e.symbolLayers}const le=e=>{const t=100,r=50;let o,i;const a=e;if("circle"===a||"esriSMSCircle"===a){const e=.25;let t=Math.acos(1-e/r),a=Math.ceil(E/t/4);0===a&&(a=1),t=O/a,a*=4;const s=[];s.push([r,0]);for(let o=1;o<a;o++)s.push([r*Math.cos(o*t),-r*Math.sin(o*t)]);s.push([r,0]),o={rings:[s]},i={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("cross"===a||"esriSMSCross"===a){const e=0;o={rings:[[[e,r],[e,e],[r,e],[r,-e],[e,-e],[e,-r],[-e,-r],[-e,-e],[-r,-e],[-r,e],[-e,e],[-e,r],[e,r]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("diamond"===a||"esriSMSDiamond"===a)o={rings:[[[-r,0],[0,r],[r,0],[0,-r],[-r,0]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("square"===a||"esriSMSSquare"===a)o={rings:[[[-r,-r],[-r,r],[r,r],[r,-r],[-r,-r]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("x"===a||"esriSMSX"===a){const e=0;o={rings:[[[0,e],[r-e,r],[r,r-e],[e,0],[r,e-r],[r-e,-r],[0,-e],[e-r,-r],[-r,e-r],[-e,0],[-r,r-e],[e-r,r],[0,e]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("triangle"===a||"esriSMSTriangle"===a){const e=t*.5773502691896257,r=-e,a=2/3*t,s=a-t;o={rings:[[[r,s],[0,a],[e,s],[r,s]]]},i={xmin:r,ymin:s,xmax:e,ymax:a}}else"arrow"===a&&(o={rings:[[[-50,50],[50,0],[-50,-50],[-33,-20],[-33,20],[-50,50]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r});return[i,o]},ce=e=>"vertical"===e||"horizontal"===e||"cross"===e||"esriSFSCross"===e||"esriSFSVertical"===e||"esriSFSHorizontal"===e;export{W as CIMSimbolInflatedSizeHelper,$ as CIMSymbolHelper,K as OverrideHelper,J as SymbolHelper,se as slsDashToTemplateArray,Y as symbolToCIM};
5
+ import e from"../../Color.js";import{bidiText as t}from"../../core/BidiText.js";import{packFloatRGBA as r}from"../../core/floatRGBA.js";import{clone as o}from"../../core/lang.js";import i from"../../core/Logger.js";import{nextPowerOfTwo as a}from"../../core/mathUtils.js";import{isSome as s}from"../../core/maybe.js";import{pt2px as n,px2pt as l}from"../../core/screenUtils.js";import{create as c,expandPointInPlace as m}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as f}from"../../geometry/support/boundsUtils.js";import{Placement as y}from"./CIMPlacements.js";import{lineGapType2LineHeight as h,horizontalAlignment2HAlign as u,verticalAlignment2VAlign as p,EnvDrawHelper as S,Transformation as M,CanvasDrawHelper as d}from"./CIMSymbolDrawHelper.js";import{LineCapStyle as b,LineJoinStyle as g,BlockProgression as C,FontEffects as I,FontEncoding as k,FontType as x,GlyphHinting as w,TextReadingDirection as P,VerticalGlyphOrientation as L,BillBoardMode as v,TextureFilter as F,ExtremityPlacement as T}from"./enums.js";import{getValue as z}from"./utils.js";import{C_INFINITY as D}from"../../views/2d/engine/vectorTiles/GeometryUtils.js";import{GLYPH_SIZE as G,MAGIC_LABEL_LINE_HEIGHT as A}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as N}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const E=Math.PI,O=E/2,R=4,j=10,V=96/72,B=Math.PI/180,X=i.getLogger("esri.symbols.cim.CIMSymbolHelper");function Y(e){if(!e||!e.type)return null;let t;switch(e.type){case"cim":return e.data;case"web-style":return e;case"simple-marker":t=$.fromSimpleMarker(e);break;case"picture-marker":t=$.fromPictureMarker(e);break;case"simple-line":t=$.fromSimpleLineSymbol(e);break;case"simple-fill":t=$.fromSimpleFillSymbol(e);break;case"picture-fill":t=$.fromPictureFillSymbol(e);break;case"text":t=$.fromTextSymbol(e)}return{type:"CIMSymbolReference",symbol:t}}function U(e,t){switch(t.type){case"CIMSymbolReference":return U(e,t.symbol);case"CIMPointSymbol":{const r={x:0,y:0};e.drawSymbol(t,r);break}case"CIMLineSymbol":{const r={paths:[[[0,0],[0,1]]]};e.drawSymbol(t,r);break}case"CIMPolygonSymbol":{const r={rings:[[[0,0],[0,1],[0,0]]]};e.drawSymbol(t,r);break}case"CIMTextSymbol":{const r={x:0,y:0};e.drawSymbol(t,r);break}case"CIMVectorMarker":{const r=new y;e.drawMarker(t,r);break}}return e.envelope()}function _(e){if(!e)return 0;switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAtExtremities":case"CIMMarkerPlacementAtMeasuredUnits":case"CIMMarkerPlacementAtRatioPositions":case"CIMMarkerPlacementOnLine":case"CIMMarkerPlacementOnVertices":return Math.abs(e.offset);default:return 0}}function H(e){if(!e)return 0;switch(e.type){case"CIMGeometricEffectArrow":return Math.abs(.5*e.width);case"CIMGeometricEffectBuffer":return Math.abs(e.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(e.length);case"CIMGeometricEffectJog":return Math.abs(.5*e.length);case"CIMGeometricEffectMove":return Math.max(Math.abs(z(e.offsetX)),Math.abs(z(e.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(e.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(e.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(e.fromWidth),Math.abs(e.toWidth));case"CIMGeometricEffectWave":return Math.abs(e.amplitude)}}function q(e){if(!e)return 0;let t=0;for(const r of e)t+=H(r);return t}class W{getSymbolInflateSize(e,t,r,o,i){return e||(e=[0,0,0,0]),t?this._getInflateSize(e,t,r,o,i):e}static safeSize(e){const t=Math.max(Math.abs(e[0]),Math.abs(e[2])),r=Math.max(Math.abs(e[1]),Math.abs(e[3]));return Math.sqrt(t*t+r*r)}_vectorMarkerBounds(e,t,r,o){let i=!0;const a=c();if(t&&t.markerGraphics)for(const s of t.markerGraphics){const t=[0,0,0,0];s.geometry&&(f(a,s.geometry),t[0]=0,t[1]=0,t[2]=0,t[3]=0,this.getSymbolInflateSize(t,s.symbol,r,0,o),a[0]+=t[0],a[1]+=t[1],a[2]+=t[2],a[3]+=t[3],i?(e[0]=a[0],e[1]=a[1],e[2]=a[2],e[3]=a[3],i=!1):(e[0]=Math.min(e[0],a[0]),e[1]=Math.min(e[1],a[1]),e[2]=Math.max(e[2],a[2]),e[3]=Math.max(e[3],a[3])))}return e}_getInflateSize(e,t,r,o,i){if(ne(t)){const a=this._getLayersInflateSize(e,t.symbolLayers,r,o,i),s=q(t.effects);return s>0&&(a[0]-=s,a[1]-=s,a[2]+=s,a[3]+=s),a}return this._getTextInflatedSize(e,t,i)}_getLayersInflateSize(e,t,r,o,i){let a=!0;if(!t)return e;for(const n of t){if(!n)continue;let t=[0,0,0,0];switch(n.type){case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const e=n;let r=e.width;e.capStyle===b.Square||e.joinStyle===g.Miter?r/=1.4142135623730951:r/=2,t[0]=-r,t[1]=-r,t[2]=r,t[3]=r;break}case"CIMCharacterMarker":case"CIMVectorMarker":case"CIMPictureMarker":{const e=n;if("CIMVectorMarker"===n.type){const e=n;if(t=this._vectorMarkerBounds(t,e,r,i),e.frame){const r=(e.frame.xmin+e.frame.xmax)/2,o=(e.frame.ymin+e.frame.ymax)/2;t[0]-=r,t[1]-=o,t[2]-=r,t[3]-=o;const i=e.size/(e.frame.ymax-e.frame.ymin);t[0]*=i,t[1]*=i,t[2]*=i,t[3]*=i}}else if("CIMPictureMarker"===n.type){const o=n,i=r.getResource(o.url);let a=1;s(i)&&i.height&&(a=i.width/i.height);const l=e.size/2,c=e.size*a*o.scaleX/2;t=[-c,-l,c,l]}else{const r=e.size/2;t=[-r,-r,r,r]}if(e.anchorPoint){let r,o;"Absolute"===e.anchorPointUnits?(r=e.anchorPoint.x,o=e.anchorPoint.y):(r=e.anchorPoint.x*(t[2]-t[0]),o=e.anchorPoint.y*(t[3]-t[1])),t[0]-=r,t[1]-=o,t[2]-=r,t[3]-=o}let a=z(e.rotation);if(e.rotateClockwise&&(a=-a),o&&(a-=o),a){const e=B*a,r=Math.cos(e),o=Math.sin(e),i=c([D,D,-D,-D]);m(i,[t[0]*r-t[1]*o,t[0]*o+t[1]*r]),m(i,[t[0]*r-t[3]*o,t[0]*o+t[3]*r]),m(i,[t[2]*r-t[1]*o,t[2]*o+t[1]*r]),m(i,[t[2]*r-t[3]*o,t[2]*o+t[3]*r]),t=i}let l=z(e.offsetX),f=z(e.offsetY);if(o){const e=B*o,t=Math.cos(e),r=Math.sin(e),i=l*r+f*t;l=l*t-f*r,f=i}t[0]+=l,t[1]+=f,t[2]+=l,t[3]+=f;const y=_(e.markerPlacement);y>0&&(t[0]-=y,t[1]-=y,t[2]+=y,t[3]+=y);break}}const l=q(n.effects);l>0&&(t[0]-=l,t[1]-=l,t[2]+=l,t[3]+=l),a?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],a=!1):(e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[2]),e[3]=Math.max(e[3],t[3]))}return e}_getTextInflatedSize(e,r,o){var i,a;const s=null!=(i=r.height)?i:j;if(e[0]=-s/2,e[1]=-s/2,e[2]=s/2,e[3]=s/2,!o)return e;const n=o.get(r);if(!n)return e;const{text:l,mosaicItem:c}=n;if(!c||0===c.glyphMosaicItems.length)return e;const m=h(r.lineGapType,null!=(a=r.lineGap)?a:0,s),f=t(l)[1],y=c.glyphMosaicItems,S=N(y,f,{scale:s/G,angle:z(r.angle),xOffset:z(r.offsetX),yOffset:z(r.offsetY),hAlign:u(r.horizontalAlignment),vAlign:p(r.verticalAlignment),maxLineWidth:512,lineHeight:A*Math.max(.25,Math.min(m||1,4)),decoration:r.font.decoration||"none",isCIM:!0}).boundsT;return e[0]=S.x-S.halfWidth,e[1]=-S.y-S.halfHeight,e[2]=S.x+S.halfWidth,e[3]=-S.y+S.halfHeight,e}}class ${static getEnvelope(e,t){const r=new S(t);if(Array.isArray(e)){let t;for(const o of e)t?t.union(U(r,o)):t=U(r,o);return t}return U(r,e)}static getTextureAnchor(e,t){const r=this.getEnvelope(e,t);if(!r)return[0,0,0];const o=(r.x+.5*r.width)*V,i=-(r.y+.5*r.height)*V,a=r.width*V+2,s=r.height*V+2;return[o/a,i/s,s]}static rasterize(e,t,r,o,i=!0){const a=r||this.getEnvelope(t,o);if(!a)return[null,0,0,0,0];const s=(a.x+.5*a.width)*V,n=(a.y+.5*a.height)*V;e.width=a.width*V,e.height=a.height*V,r||(e.width+=2,e.height+=2);const l=e.getContext("2d"),c=M.createScale(V,-V);c.translate(.5*e.width-s,.5*e.height+n);const m=new d(l,o,c);switch(t.type){case"CIMPointSymbol":{const e={type:"point",x:0,y:0};m.drawSymbol(t,e);break}case"CIMVectorMarker":{const e=new y;m.drawMarker(t,e);break}}const f=l.getImageData(0,0,e.width,e.height),h=new Uint8Array(f.data);if(i){let e;for(let t=0;t<h.length;t+=4)e=h[t+3]/255,h[t]=h[t]*e,h[t+1]=h[t+1]*e,h[t+2]=h[t+2]*e}return[h,e.width,e.height,-s/e.width,-n/e.height]}static fromTextSymbol(e){const{angle:r,color:o,font:i,haloColor:a,haloSize:s,horizontalAlignment:n,kerning:l,text:c,verticalAlignment:m,xoffset:f,yoffset:y}=e;let h,u,p,S,M;i&&(h=i.family,u=i.style,p=i.weight,S=i.size,M=i.decoration);let d=!1;if(c){d=t(c)[1]}return{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,anchorPointUnits:"Relative",dominantSizeAxis3D:"Y",size:10,billboardMode3D:"FaceNearPlane",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",angle:r,blockProgression:C.BTT,depth3D:1,extrapolateBaselines:!0,fontEffects:I.Normal,fontEncoding:k.Unicode,fontFamilyName:h||"Arial",fontStyleName:oe(u,p),fontType:x.Unspecified,haloSize:s,height:S,hinting:w.Default,horizontalAlignment:ee(null!=n?n:"center"),kerning:l,letterWidth:100,ligatures:!0,lineGapType:"Multiple",offsetX:z(f),offsetY:z(y),strikethrough:"line-through"===M,underline:"underline"===M,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:re(o)}]},haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:re(a)}]},shadowColor:[0,0,0,255],shadowOffsetX:1,shadowOffsetY:1,textCase:"Normal",textDirection:d?P.RTL:P.LTR,verticalAlignment:te(null!=m?m:"baseline"),verticalGlyphOrientation:L.Right,wordSpacing:100,billboardMode3D:v.FaceNearPlane},textString:c}],scaleSymbolsProportionally:!0,respectFrame:!0}],scaleX:1,angleAlignment:"Display"}}static fromPictureFillSymbol(e){const{height:t,outline:r,width:o,xoffset:i,xscale:a,yoffset:s,yscale:n}=e,l=[],c={type:"CIMPolygonSymbol",symbolLayers:l};if(r){const{cap:e,join:t,miterLimit:o,width:i}=r;l.push({type:"CIMSolidStroke",color:re(r.color),capStyle:Q(e),joinStyle:Z(t),miterLimit:o,width:i})}let m=e.url;"esriPFS"===e.type&&e.imageData&&(m=e.imageData);const f="angle"in e?e.angle:0,y=o*(a||1),h=t*(n||1);return l.push({type:"CIMPictureFill",invertBackfaceTexture:!1,scaleX:1,textureFilter:F.Picture,tintColor:null,url:m,height:h,width:y,offsetX:z(i),offsetY:z(s),rotation:z(-f),colorSubstitutions:null}),c}static fromSimpleFillSymbol(e){const{color:t,style:r,outline:i}=e,s=[],n={type:"CIMPolygonSymbol",symbolLayers:s};let l=null;if(i){const{cap:e,join:t,style:r}=i;"solid"!==r&&"none"!==r&&"esriSLSSolid"!==r&&"esriSLSNull"!==r&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:se(r,e),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]),s.push({type:"CIMSolidStroke",color:re(i.color),capStyle:Q(e),joinStyle:Z(t),miterLimit:i.miterLimit,width:i.width,effects:l})}if(r&&"solid"!==r&&"none"!==r&&"esriSFSSolid"!==r&&"esriSFSNull"!==r){const e={type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",color:re(t),capStyle:b.Butt,joinStyle:g.Miter,width:.75}]};let i=0;const n=a(Math.ceil(window.devicePixelRatio)),l=ce(r)?8*n:10*n;switch(r){case"vertical":case"esriSFSVertical":i=90;break;case"forward-diagonal":case"esriSFSForwardDiagonal":case"diagonal-cross":case"esriSFSDiagonalCross":i=-45;break;case"backward-diagonal":case"esriSFSBackwardDiagonal":i=45;break;case"cross":case"esriSFSCross":i=0}s.push({type:"CIMHatchFill",lineSymbol:e,offsetX:0,offsetY:0,rotation:i,separation:l}),"cross"===r||"esriSFSCross"===r?s.push({type:"CIMHatchFill",lineSymbol:o(e),offsetX:0,offsetY:0,rotation:90,separation:l}):"diagonal-cross"!==r&&"esriSFSDiagonalCross"!==r||s.push({type:"CIMHatchFill",lineSymbol:o(e),offsetX:0,offsetY:0,rotation:45,separation:l})}else!r||"solid"!==r&&"esriSFSSolid"!==r||s.push({type:"CIMSolidFill",enable:!0,color:re(t)});return n}static fromSimpleLineSymbol(e){const{cap:t,color:r,join:o,marker:i,miterLimit:a,style:s,width:n}=e;let l=null;"solid"!==s&&"none"!==s&&"esriSLSSolid"!==s&&"esriSLSNull"!==s&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:se(s,t),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]);const c=[];if(i){let e;switch(i.placement){case"begin-end":e=T.Both;break;case"begin":e=T.JustBegin;break;case"end":e=T.JustEnd;break;default:e=T.None}const t=$.fromSimpleMarker(i,n,r).symbolLayers[0];t.markerPlacement={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:e,offsetAlongLine:0},c.push(t)}return"none"!==s&&"esriSLSNull"!==s&&c.push({type:"CIMSolidStroke",color:re(r),capStyle:Q(t),joinStyle:Z(o),miterLimit:a,width:n,effects:l}),{type:"CIMLineSymbol",symbolLayers:c}}static fromPictureMarker(e){const{angle:t,height:r,width:o,xoffset:i,yoffset:a}=e;let s=e.url;return"esriPMS"===e.type&&e.imageData&&(s=e.imageData),{type:"CIMPointSymbol",symbolLayers:[{type:"CIMPictureMarker",invertBackfaceTexture:!1,scaleX:1,textureFilter:F.Picture,tintColor:null,url:s,size:r,width:o,offsetX:z(i),offsetY:z(a),rotation:z(-t)}]}}static fromSimpleMarker(e,t,r){var o;const{style:i}=e,a=null!=(o=e.color)?o:r;if("path"===i){const t=[];if("outline"in e&&e.outline){const r=e.outline;t.push({type:"CIMSolidStroke",enable:!0,width:n(Math.round(l(r.width))),color:re(r.color)})}t.push({type:"CIMSolidFill",enable:!0,color:re(a),path:e.path});const[r,o]=le("square");return{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:r,markerGraphics:[{type:"CIMMarkerGraphic",geometry:o,symbol:{type:"CIMPolygonSymbol",symbolLayers:t}}]}]}}const[s,c]=le(i);let m;if(c&&s){const r=[];if("outline"in e&&e.outline){const t=e.outline;r.push({type:"CIMSolidStroke",enable:!0,width:t.width>.667?n(Math.round(l(t.width))):t.width,color:re(t.color)})}else!t||"line-marker"!==e.type||"cross"!==e.style&&"x"!==e.style||r.push({type:"CIMSolidStroke",enable:!0,width:t,color:re(a)});r.push({type:"CIMSolidFill",enable:!0,color:re(a)});const o={type:"CIMPolygonSymbol",symbolLayers:r};m={type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6*t),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:s,markerGraphics:[{type:"CIMMarkerGraphic",geometry:c,symbol:o}]}]}}return m}static fromCIMHatchFill(e){var t;const r=null!=(t=e.separation)?t:R,o=r/2,i=4;let a=this._getLineSymbolPeriod(e.lineSymbol)||i;for(;a<i;)a*=2;const s=a/2;return{type:"CIMVectorMarker",frame:{xmin:-s,xmax:s,ymin:-o,ymax:o},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[-s,0],[s,0]]]},symbol:e.lineSymbol}],size:r}}static _getLineSymbolPeriod(e){if(e){const t=this._getEffectsRepeat(e.effects);if(t)return t;if(e.symbolLayers)for(const r of e.symbolLayers){const e=this._getEffectsRepeat(r.effects);if(e)return e;if(r){const e=this._getPlacementRepeat(r.markerPlacement);if(e)return e}}}return 0}static _getEffectsRepeat(e){if(e)for(const t of e)if(t)switch(t.type){case"CIMGeometricEffectDashes":{const e=t.dashTemplate;if(e&&e.length){let t=0;for(const r of e)t+=r;return 1&e.length&&(t*=2),t}break}case"CIMGeometricEffectWave":return t.period;default:X.error(`unsupported geometric effect type ${t.type}`)}return 0}static _getPlacementRepeat(e){if(e)switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAlongLineVariableSize":{const t=e.placementTemplate;if(t&&t.length){let e=0;for(const r of t)e+=r;return 1&t.length&&(e*=2),e}break}}return 0}static fromCIMInsidePolygon(e){const t=e.markerPlacement,r={type:e.type,...e};let o,i,a,s;if(r.markerPlacement=null,r.anchorPoint=null,!0===t.shiftOddRows){i=t.stepX/2,a=t.stepY,s=2*t.stepY;o=[{x:-i,y:0},{x:i,y:0},{x:0,y:a},{x:0,y:-a}].map((e=>({type:"CIMMarkerGraphic",geometry:e,symbol:{type:"CIMPointSymbol",symbolLayers:[r]}})))}else i=t.stepX/2,a=t.stepY/2,s=t.stepY,o=[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:{type:"CIMPointSymbol",symbolLayers:[r]}}];return{type:"CIMVectorMarker",frame:{xmin:-i,xmax:i,ymin:-a,ymax:a},markerGraphics:o,size:s}}static getFillColor(e){if(!e)return null;switch(e.type){case"CIMPolygonSymbol":if(e.symbolLayers)for(const t of e.symbolLayers){const e=$.getFillColor(t);if(null!=e)return e}break;case"CIMTextSymbol":return $.getFillColor(e.symbol);case"CIMSolidFill":return e.color}}static getStrokeColor(e){if(e)switch(e.type){case"CIMPolygonSymbol":case"CIMLineSymbol":if(e.symbolLayers)for(const t of e.symbolLayers){const e=$.getStrokeColor(t);if(void 0!==e)return e}break;case"CIMTextSymbol":return $.getStrokeColor(e.symbol);case"CIMSolidStroke":return e.color}}static getStrokeWidth(e){if(e)switch(e.type){case"CIMPolygonSymbol":case"CIMLineSymbol":if(e.symbolLayers)for(const t of e.symbolLayers){const e=$.getStrokeWidth(t);if(void 0!==e)return e}break;case"CIMTextSymbol":return $.getStrokeWidth(e.symbol);case"CIMSolidStroke":case"CIMGradientStroke":case"CIMPictureStroke":return e.width}}static getSize(e){if(e)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":{let t=0;if(e.symbolLayers)for(const r of e.symbolLayers){const e=$.getSize(r);e>t&&(t=e)}return t}case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":return e.width;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":return e.size}}static getMarkerScaleRatio(e){if(e&&"CIMVectorMarker"===e.type)if(!1!==e.scaleSymbolsProportionally&&e.frame){const t=e.frame.ymax-e.frame.ymin;return e.size/t}return 1}}class J{static rasterizeSimpleFill(e,t,r){"solid"!==t&&"none"!==t&&"esriSFSSolid"!==t&&"esriSFSNull"!==t||console.error("Unexpected: style does not require rasterization");const o=a(Math.ceil(r)),i=ce(t)?8*o:16*o,s=2*o;e.width=i,e.height=i;const n=e.getContext("2d");n.strokeStyle="#FFFFFF",n.lineWidth=o,n.beginPath(),"vertical"!==t&&"cross"!==t&&"esriSFSCross"!==t&&"esriSFSVertical"!==t||(n.moveTo(i/2,-s),n.lineTo(i/2,i+s)),"horizontal"!==t&&"cross"!==t&&"esriSFSCross"!==t&&"esriSFSHorizontal"!==t||(n.moveTo(-s,i/2),n.lineTo(i+s,i/2)),"forward-diagonal"!==t&&"diagonal-cross"!==t&&"esriSFSDiagonalCross"!==t&&"esriSFSForwardDiagonal"!==t||(n.moveTo(-s,-s),n.lineTo(i+s,i+s),n.moveTo(i-s,-s),n.lineTo(i+s,s),n.moveTo(-s,i-s),n.lineTo(s,i+s)),"backward-diagonal"!==t&&"diagonal-cross"!==t&&"esriSFSBackwardDiagonal"!==t&&"esriSFSDiagonalCross"!==t||(n.moveTo(i+s,-s),n.lineTo(-s,i+s),n.moveTo(s,-s),n.lineTo(-s,s),n.moveTo(i+s,i-s),n.lineTo(i-s,i+s)),n.stroke();const l=n.getImageData(0,0,e.width,e.height),c=new Uint8Array(l.data);let m;for(let a=0;a<c.length;a+=4)m=c[a+3]/255,c[a]=c[a]*m,c[a+1]=c[a+1]*m,c[a+2]=c[a+2]*m;return[c,e.width,e.height]}static rasterizeSimpleLine(e,t){return this.rasterizeDash(e,t)}static rasterizeDash(e,t){const o="Butt"===t,i="Square"===t,a=!o&&!i;e.length%2==1&&(e=[...e,...e]);const s=15.5,n=2*s;let l=0;for(const r of e)l+=r;const c=Math.round(l*s),m=new Float32Array(c*n),f=.5*s;let y=0,h=0,u=.5,p=!0;for(const r of e){for(y=h,h+=r*s;u<=h;){let e=.5;for(;e<n;){const t=(e-.5)*c+u-.5,r=a?(e-s)*(e-s):Math.abs(e-s);m[t]=p?o?Math.max(Math.max(y+f-u,r),Math.max(u-h+f,r)):r:a?Math.min((u-y)*(u-y)+r,(u-h)*(u-h)+r):i?Math.min(Math.max(u-y,r),Math.max(h-u,r)):Math.min(Math.max(u-y+f,r),Math.max(h+f-u,r)),e++}u++}p=!p}const S=m.length,M=new Uint8Array(4*S);for(let d=0;d<S;++d){const e=(a?Math.sqrt(m[d]):m[d])/s;r(e,M,4*d)}return[M,c,n]}}class K{static findApplicableOverrides(e,t,r){if(e&&t){if(e.primitiveName){let o=!1;for(const t of r)if(t.primitiveName===e.primitiveName){o=!0;break}if(!o)for(const i of t)i.primitiveName===e.primitiveName&&r.push(i)}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const o of e.effects)K.findApplicableOverrides(o,t,r);if(e.symbolLayers)for(const o of e.symbolLayers)K.findApplicableOverrides(o,t,r);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":if(e.effects)for(const o of e.effects)K.findApplicableOverrides(o,t,r);if(e.markerPlacement&&K.findApplicableOverrides(e.markerPlacement,t,r),"CIMVectorMarker"===e.type){if(e.markerGraphics)for(const o of e.markerGraphics)K.findApplicableOverrides(o,t,r),K.findApplicableOverrides(o.symbol,t,r)}else"CIMCharacterMarker"===e.type?K.findApplicableOverrides(e.symbol,t,r):"CIMHatchFill"===e.type&&K.findApplicableOverrides(e.lineSymbol,t,r)}}}static findEffectOverrides(e,t,r){if(!t||!e)return;const o=e.length;for(let i=0;i<o;i++){const o=e[i],a=null==o?void 0:o.primitiveName;if(a){let e=!1;for(const t of r)if(t.primitiveName===a){e=!0;break}if(!e)for(const o of t)o.primitiveName===a&&r.push(o)}}}static applyOverrides(e,t,r,o){if(!t)return;const i=e=>e?e.charAt(0).toLowerCase()+e.substr(1):e;if(e.primitiveName)for(const a of t)if(a.primitiveName===e.primitiveName){const t=i(a.propertyName);if(o&&o.push({cim:e,nocapPropertyName:t,value:e[t]}),a.expression&&(a.value=K.toValue(a.propertyName,a.expression)),r){let t=!1;for(const o of r)o.primitiveName===e.primitiveName&&(t=!0);t||r.push(a)}e[t]=a.value}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const i of e.effects)K.applyOverrides(i,t,r,o);if(e.symbolLayers)for(const i of e.symbolLayers)K.applyOverrides(i,t,r,o);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if(e.effects)for(const i of e.effects)K.applyOverrides(i,t,r,o);if("CIMVectorMarker"===e.type&&e.markerGraphics)for(const i of e.markerGraphics)K.applyOverrides(i,t,r,o),K.applyOverrides(i.symbol,t,r,o)}}static restoreOverrides(e){for(const t of e)t.cim[t.nocapPropertyName]=t.value}static buildOverrideKey(e){let t="";for(const r of e)void 0!==r.value&&(t+=`${r.primitiveName}${r.propertyName}${JSON.stringify(r.value)}`);return t}static toValue(t,r){if("DashTemplate"===t)return r.split(" ").map((e=>Number(e)));if("Color"===t){const t=new e(r).toRgba();return t[3]*=255,t}return r}}const Q=e=>{if(!e)return b.Butt;switch(e){case"butt":return b.Butt;case"square":return b.Square;case"round":return b.Round}},Z=e=>{if(!e)return g.Miter;switch(e){case"miter":return g.Miter;case"round":return g.Round;case"bevel":return g.Bevel}},ee=e=>{if(!e)return"Center";switch(e){case"left":return"Left";case"right":return"Right";case"center":return"Center";case"justify":return"Justify"}},te=e=>{if(!e)return"Center";switch(e){case"baseline":return"Baseline";case"top":return"Top";case"middle":return"Center";case"bottom":return"Bottom"}},re=e=>{if(!e)return[0,0,0,0];const{r:t,g:r,b:o,a:i}=e;return[t,r,o,255*i]},oe=(e,t)=>{const r=ie(t),o=ae(e);return r&&o?`${r}-${o}`:`${r}${o}`},ie=e=>{if(!e)return"";switch(e.toLowerCase()){case"bold":case"bolder":return"bold"}return""},ae=e=>{if(!e)return"";switch(e.toLowerCase()){case"italic":case"oblique":return"italic"}return""},se=(e,t)=>{const r="butt"===t;switch(e){case"dash":case"esriSLSDash":return r?[4,3]:[3,4];case"dash-dot":case"esriSLSDashDot":return r?[4,3,1,3]:[3,4,0,4];case"dot":case"esriSLSDot":return r?[1,3]:[0,4];case"long-dash":case"esriSLSLongDash":return r?[8,3]:[7,4];case"long-dash-dot":case"esriSLSLongDashDot":return r?[8,3,1,3]:[7,4,0,4];case"long-dash-dot-dot":case"esriSLSDashDotDot":return r?[8,3,1,3,1,3]:[7,4,0,4,0,4];case"short-dash":case"esriSLSShortDash":return r?[4,1]:[3,2];case"short-dash-dot":case"esriSLSShortDashDot":return r?[4,1,1,1]:[3,2,0,2];case"short-dash-dot-dot":case"esriSLSShortDashDotDot":return r?[4,1,1,1,1,1]:[3,2,0,2,0,2];case"short-dot":case"esriSLSShortDot":return r?[1,1]:[0,2];case"solid":case"esriSLSSolid":case"none":return X.error("Unexpected: style does not require rasterization"),[0,0];default:return X.error(`Tried to rasterize SLS, but found an unexpected style: ${e}!`),[0,0]}};function ne(e){return void 0!==e.symbolLayers}const le=e=>{const t=100,r=50;let o,i;const a=e;if("circle"===a||"esriSMSCircle"===a){const e=.25;let t=Math.acos(1-e/r),a=Math.ceil(E/t/4);0===a&&(a=1),t=O/a,a*=4;const s=[];s.push([r,0]);for(let o=1;o<a;o++)s.push([r*Math.cos(o*t),-r*Math.sin(o*t)]);s.push([r,0]),o={rings:[s]},i={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("cross"===a||"esriSMSCross"===a){const e=0;o={rings:[[[e,r],[e,e],[r,e],[r,-e],[e,-e],[e,-r],[-e,-r],[-e,-e],[-r,-e],[-r,e],[-e,e],[-e,r],[e,r]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("diamond"===a||"esriSMSDiamond"===a)o={rings:[[[-r,0],[0,r],[r,0],[0,-r],[-r,0]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("square"===a||"esriSMSSquare"===a)o={rings:[[[-r,-r],[-r,r],[r,r],[r,-r],[-r,-r]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("x"===a||"esriSMSX"===a){const e=0;o={rings:[[[0,e],[r-e,r],[r,r-e],[e,0],[r,e-r],[r-e,-r],[0,-e],[e-r,-r],[-r,e-r],[-e,0],[-r,r-e],[e-r,r],[0,e]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("triangle"===a||"esriSMSTriangle"===a){const e=t*.5773502691896257,r=-e,a=2/3*t,s=a-t;o={rings:[[[r,s],[0,a],[e,s],[r,s]]]},i={xmin:r,ymin:s,xmax:e,ymax:a}}else"arrow"===a&&(o={rings:[[[-50,50],[50,0],[-50,-50],[-33,-20],[-33,20],[-50,50]]]},i={xmin:-r,ymin:-r,xmax:r,ymax:r});return[i,o]},ce=e=>"vertical"===e||"horizontal"===e||"cross"===e||"esriSFSCross"===e||"esriSFSVertical"===e||"esriSFSHorizontal"===e;export{W as CIMSimbolInflatedSizeHelper,$ as CIMSymbolHelper,K as OverrideHelper,J as SymbolHelper,se as slsDashToTemplateArray,Y as symbolToCIM};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import t from"../../request.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{pt2px as a}from"../../core/screenUtils.js";import{numericHash as i}from"../../core/string.js";import{getJsonType as s,isPolygon as o,isPolyline as n}from"../../geometry/support/jsonUtils.js";import{analyzeCIMSymbol as c,analyzeCIMResource as l}from"./cimAnalyzer.js";import m from"./CIMResourceManager.js";import h from"./Rasterizer.js";import{TextRasterizer as f}from"./TextRasterizer.js";import{createLabelOverrideFunction as g,evaluateValueOrFunction as y,colorToArray as u}from"./utils.js";import{scaleCIMMarker as p}from"../support/cimSymbolUtils.js";import d from"../support/Symbol3DAnchorPosition2D.js";var M;!function(e){e.Legend="legend",e.Preview="preview"}(M||(M={}));const C=(e,t,r)=>{if(e&&e.targetSize){let i;if(r){const t=Math.max(r.frame.xmax-r.frame.xmin,r.frame.ymax-r.frame.ymin);i=e.targetSize/a(t)}else i=e.targetSize/t.referenceSize;return i}return e&&e.scaleFactor?e.scaleFactor:1},I={fill:{legend:{frame:{xmax:15,xmin:0,ymax:15,ymin:0},geometry:{rings:[[[0,15],[15,7.5],[15,0],[0,0],[0,15]]]},canvasPaths:{rings:[[[0,15],[0,0],[15,7.5],[15,15],[0,15]]]}},preview:{frame:{xmax:100,xmin:0,ymax:100,ymin:0},geometry:{rings:[[[0,100],[100,100],[100,0],[0,0],[0,100]]]},canvasPaths:{rings:[[[0,100],[0,0],[100,0],[100,100],[0,100]]]}}},stroke:{legend:{frame:{xmax:24,xmin:0,ymax:2,ymin:-2},geometry:{paths:[[[0,0],[12,0],[24,0]]]},canvasPaths:{paths:[[[0,2],[12,2],[24,2]]]}},preview:{frame:{xmax:100,xmin:0,ymax:2,ymin:-2},geometry:{paths:[[[0,0],[50,0],[100,0]]]},canvasPaths:{paths:[[[0,2],[50,2],[100,2]]]}}}};class z{constructor(e,t){this._spatialReference=e,this._avoidSDF=t,this._resourceCache=new Map,this._pictureMarkerCache=new Map,this._textRasterizer=new f,this._cimResourceManager=new m,this._rasterizer=new h(this._cimResourceManager)}async rasterizeCIMSymbolAsync(e,t,r,a,i,o,n,c){a=a||(t?null!=t.centroid?"esriGeometryPolygon":s(t.geometry):null)||P(e);const l=await this.analyzeCIMSymbol(e,t?x(t.attributes):null,r,a,c);return this.rasterizeCIMSymbol(l,t,a,i,o,n)}async analyzeCIMSymbol(e,t,a,i,s){const o=[],n=t?{geometryType:i,spatialReference:this._spatialReference,fields:t}:null;let l;await c(e.data,n,this._cimResourceManager,o,this._avoidSDF),r(s);for(const r of o)"CIMPictureMarker"!==r.cim.type&&"CIMPictureFill"!==r.cim.type&&"CIMPictureStroke"!==r.cim.type||(l||(l=[]),l.push(this._fetchPictureMarkerResource(r,s))),a&&"text"===r.type&&"string"==typeof r.text&&r.text.indexOf("[")>-1&&(r.text=g(a,r.text,r.cim.textCase));return l&&await Promise.all(l),o}async _fetchPictureMarkerResource(e,r){const a=e.materialHash;if(!this._pictureMarkerCache.get(a)){const i=(await t(e.cim.url,{responseType:"image",signal:r&&r.signal})).data;this._pictureMarkerCache.set(a,i)}}rasterizeCIMSymbol(e,t,r,a,i,s){const o=[];for(const n of e){a&&"function"==typeof a.scaleFactor&&(a.scaleFactor=a.scaleFactor(t,i,s));const e=this._getRasterizedResource(n,t,r,a,i,s);if(!e)continue;let c=0,l=e.anchorX||0,m=e.anchorY||0,h=!1,f=0,g=0;if("esriGeometryPoint"===r){const e=C(a,n,null);if(f=y(n.offsetX,t,i,s)*e||0,g=y(n.offsetY,t,i,s)*e||0,"marker"===n.type)c=y(n.rotation,t,i,s)||0,h=!!n.rotateClockwise&&n.rotateClockwise;else if("text"===n.type){if(c=y(n.angle,t,i,s)||0,void 0!==n.horizontalAlignment)switch(n.horizontalAlignment){case"left":l=-.5;break;case"right":l=.5;break;default:l=0}if(void 0!==n.verticalAlignment)switch(n.verticalAlignment){case"top":m=.5;break;case"bottom":m=-.5;break;case"baseline":m=-.25;break;default:m=0}}}null!=e&&o.push({angle:c,rotateClockWise:h,anchorX:l,anchorY:m,offsetX:f,offsetY:g,rasterizedResource:e})}return this.getSymbolImage(o)}getSymbolImage(e){const t=document.createElement("canvas"),r=t.getContext("2d");let i=0,s=0,o=0,n=0;const c=[];for(let f=0;f<e.length;f++){const t=e[f],l=t.rasterizedResource;if(!l)continue;const m=l.size,h=t.offsetX,g=t.offsetY,y=t.anchorX,u=t.anchorY,p=t.rotateClockWise||!1;let d=t.angle,M=a(h)-m[0]*(.5+y),C=a(g)-m[1]*(.5+u),I=M+m[0],z=C+m[1];if(d){p&&(d=-d);const e=Math.sin(d*Math.PI/180),t=Math.cos(d*Math.PI/180),r=M*t-C*e,a=M*e+C*t,i=M*t-z*e,s=M*e+z*t,o=I*t-z*e,n=I*e+z*t,c=I*t-C*e,l=I*e+C*t;M=Math.min(r,i,o,c),C=Math.min(a,s,n,l),I=Math.max(r,i,o,c),z=Math.max(a,s,n,l)}i=M<i?M:i,s=C<s?C:s,o=I>o?I:o,n=z>n?z:n;const x=r.createImageData(l.size[0],l.size[1]);x.data.set(new Uint8ClampedArray(l.image.buffer));const P={offsetX:h,offsetY:g,rotateClockwise:p,angle:d,rasterizedImage:x,anchorX:y,anchorY:u};c.push(P)}t.width=o-i,t.height=n-s;const l=-i,m=n;for(let f=0;f<c.length;f++){const e=c[f],t=this._imageDataToCanvas(e.rasterizedImage),i=e.rasterizedImage.width,s=e.rasterizedImage.height,o=l-i*(.5+e.anchorX),n=m-s*(.5-e.anchorY);if(e.angle){const i=(360-e.angle)*Math.PI/180;r.save(),r.translate(a(e.offsetX),-a(e.offsetY)),r.translate(l,m),r.rotate(i),r.translate(-l,-m),r.drawImage(t,o,n),r.restore()}else r.drawImage(t,o+a(e.offsetX),n-a(e.offsetY))}const h=new d({x:l/t.width-.5,y:m/t.height-.5});return{imageData:0!==t.width&&0!==t.height?r.getImageData(0,0,t.width,t.height):r.createImageData(1,1),anchorPosition:h}}_imageDataToCanvas(e){this._imageDataCanvas||(this._imageDataCanvas=document.createElement("canvas"));const t=this._imageDataCanvas,r=t.getContext("2d");return t.width=e.width,t.height=e.height,r.putImageData(e,0,0),t}_imageTo32Array(t,r,a,i){this._imageDataCanvas||(this._imageDataCanvas=document.createElement("canvas"));const s=this._imageDataCanvas,o=s.getContext("2d");if(s.width=r,s.height=a,o.drawImage(t,0,0,r,a),i){o.save();const s=new e(i);o.fillStyle=s.toHex(),o.globalCompositeOperation="multiply",o.fillRect(0,0,r,a),o.globalCompositeOperation="destination-atop",o.drawImage(t,0,0,r,a),o.restore()}return new Uint32Array(o.getImageData(0,0,r,a).data.buffer)}_getRasterizedResource(e,t,r,a,s,o){let n,c,l,m,h=null,f=null;if("esriGeometryPolyline"===r||"esriGeometryPolygon"===r){const m=a&&a.style?a.style:M.Legend,g="esriGeometryPolyline"===r?I.stroke[m]:I.fill[m];if("line"===e.type){if("CIMSolidStroke"!==e.cim.type){if("CIMPictureStroke"===e.cim.type){const r=y(e.width,t,s,o),a=y(e.color,t,s,o),{image:i,width:n,height:c}=this._getPictureResource(e,r,a);return this._rasterizePictureResource(e,i,n,c,g,r)}return null}({analyzedCIM:n,hash:l}=w(e,t,s,o)),c=this._embedCIMLayerInVectorMarker(n,g)}else if("marker"===e.type){if("CIMPictureMarker"===e.cim.type)return null;if("CIMVectorMarker"!==e.cim.type)return null;e.cim.offsetX=y(e.offsetX,t,s,o),e.cim.offsetY=y(e.offsetY,t,s,o),e.cim.rotation=y(e.rotation,t,s,o),e.cim.markerPlacement=e.markerPlacement,({analyzedCIM:n}=w(e,t,s,o)),l=i(JSON.stringify(n)).toString(),c=this._embedCIMLayerInVectorMarker(n,g),h=y(e.size,t,s,o),f=e.path}else{if("text"===e.type)return null;if("fill"===e.type){if("CIMHatchFill"===e.cim.type||"CIMVectorMarker"===e.cim.type||"CIMPictureMarker"===e.cim.type||"CIMPictureFill"===e.cim.type){const r=e.cim.size||e.cim.height;let a,i,c;if("CIMPictureMarker"===e.cim.type||"CIMPictureFill"===e.cim.type)({image:a,width:i,height:c}=this._getPictureResource(e,r,y(e.color,t,s,o)));else{({analyzedCIM:n,hash:l}=w(e,t,s,o));const m=this._rasterizer.rasterizeJSONResource({cim:n,type:e.type,url:e.url,mosaicHash:l,size:r,path:f},1,this._avoidSDF);a=m.image,i=m.size[0],c=m.size[1]}return this._rasterizePictureResource(e,a,i,c,g,null)}if("CIMSolidFill"!==e.cim.type)return null;({analyzedCIM:n,hash:l}=w(e,t,s,o)),c=this._embedCIMLayerInVectorMarker(n,g)}}}else{if("text"===e.type)return m=this._rasterizeTextResource(e,t,a,s,o),m;({analyzedCIM:n,hash:l}=w(e,t,s,o));const r=C(a,e,null);if("CIMPictureMarker"===e.cim.type){const a=y(e.size,t,s,o)*r,{image:i,width:n,height:c}=this._getPictureResource(e,a,y(e.color,t,s,o));return m={image:i,size:[n,c],sdf:!1,simplePattern:!1,anchorX:e.anchorPoint?e.anchorPoint.x:0,anchorY:e.anchorPoint?e.anchorPoint.y:0},m}p(n,r,{preserveOutlineWidth:!1}),c=n}l+=r,a&&(l+=JSON.stringify(a));const g=this._resourceCache;return g.has(l)?g.get(l):(m=this._rasterizer.rasterizeJSONResource({cim:c,type:e.type,url:e.url,mosaicHash:l,size:h,path:f},window.devicePixelRatio||1,this._avoidSDF),g.set(l,m),m)}_rasterizeTextResource(e,t,r,a,i){const s=C(r,e,null),o=y(e.text,t,a,i);if(!o||0===o.length)return null;const n=y(e.fontName,t,a,i),c=y(e.style,t,a,i),l=y(e.weight,t,a,i),m=y(e.decoration,t,a,i),h=y(e.size,t,a,i)*s,f=y(e.horizontalAlignment,t,a,i),g=y(e.verticalAlignment,t,a,i),p=u(y(e.color,t,a,i)),d=u(y(e.outlineColor,t,a,i)),M={color:p,size:h,horizontalAlignment:f,verticalAlignment:g,font:{family:n,style:c,weight:l,decoration:m},halo:{size:y(e.outlineSize,t,a,i)||0,color:d,style:c},pixelRatio:1,premultiplyColors:!this._avoidSDF};return this._textRasterizer.rasterizeText(o,M)}_rasterizePictureResource(e,t,r,i,s,c){const l=document.createElement("canvas"),m=l.getContext("2d");l.height=a(Math.max(s.frame.ymax-s.frame.ymin,c)),l.width=a(s.frame.xmax-s.frame.xmin);const h=m.createImageData(r,i);h.data.set(new Uint8ClampedArray(t.buffer));const f=this._imageDataToCanvas(h),g=m.createPattern(f,"repeat"),y=Math.cos((-e.cim.rotation||0)*Math.PI/180),u=Math.sin((-e.cim.rotation||0)*Math.PI/180);g.setTransform({m11:y,m12:u,m21:-u,m22:y,m41:a(e.cim.offsetX)||0,m42:a(e.cim.offsetY)||0});const p=s.canvasPaths;let d,M,C;o(p)?(d=p.rings,m.fillStyle=g,M=m.fill,C=["evenodd"]):n(p)&&(d=p.paths,m.strokeStyle=g,m.lineWidth=c,M=m.stroke,d[0][0][1]=l.height/2,d[0][1][1]=l.height/2),m.beginPath();for(const o of d){const e=o?o.length:0;if(e>1){let t=o[0];m.moveTo(a(t[0]),a(t[1]));for(let r=1;r<e;++r)t=o[r],m.lineTo(a(t[0]),a(t[1]));m.closePath()}}M.apply(m,C);const I=m.getImageData(0,0,l.width,l.height),z=new Uint8Array(I.data);return{size:[l.width,l.height],image:new Uint32Array(z.buffer),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0}}_getPictureResource(e,t,r){const i=this._pictureMarkerCache.get(e.materialHash);if(!i)return null;const s=i.height/i.width,o=t?s>1?a(t):a(t)/s:i.width,n=t?s>1?a(t)*s:a(t):i.height;return{image:this._imageTo32Array(i,o,n,r),width:o,height:n}}_embedCIMLayerInVectorMarker(e,t){const r=o(t.geometry)?"CIMPolygonSymbol":"CIMLineSymbol",a=t.frame;return{type:"CIMVectorMarker",frame:a,size:a.ymax-a.ymin,markerGraphics:[{type:"CIMMarkerGraphic",geometry:t.geometry,symbol:{type:r,symbolLayers:[e]}}]}}}function x(e){return(e?Object.keys(e):[]).map((t=>({name:t,alias:t,type:"string"==typeof e[t]?"esriFieldTypeString":"esriFieldTypeDouble"})))}function P(e){if(!(e&&e.data&&e.data.symbol))return null;switch(e.data.symbol.type){case"CIMPointSymbol":case"CIMTextSymbol":return"esriGeometryPoint";case"CIMLineSymbol":return"esriGeometryPolyline";case"CIMPolygonSymbol":return"esriGeometryPolygon";default:return null}}function w(e,t,r,a){let i,s;if("function"==typeof e.materialHash){i=(0,e.materialHash)(t,r,a),s=l(e.cim,e.materialOverrides)}else i=e.materialHash,s=e.cim;return{analyzedCIM:s,hash:i}}export{z as CIMSymbolRasterizer,M as GeometryStyle};
5
+ import e from"../../Color.js";import t from"../../request.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{pt2px as a}from"../../core/screenUtils.js";import{numericHash as i}from"../../core/string.js";import{getJsonType as s,isPolygon as o,isPolyline as n}from"../../geometry/support/jsonUtils.js";import{analyzeCIMSymbol as c,analyzeCIMResource as l}from"./cimAnalyzer.js";import m from"./CIMResourceManager.js";import h from"./Rasterizer.js";import{TextRasterizer as f}from"./TextRasterizer.js";import{createLabelOverrideFunction as g,evaluateValueOrFunction as u,colorToArray as y}from"./utils.js";import{scaleCIMMarker as p}from"../support/cimSymbolUtils.js";import d from"../support/Symbol3DAnchorPosition2D.js";var M;!function(e){e.Legend="legend",e.Preview="preview"}(M||(M={}));const C=(e,t,r)=>{if(e&&e.targetSize){let i;if(r){const t=Math.max(r.frame.xmax-r.frame.xmin,r.frame.ymax-r.frame.ymin);i=e.targetSize/a(t)}else i=e.targetSize/t.referenceSize;return i}return e&&e.scaleFactor?e.scaleFactor:1},I={fill:{legend:{frame:{xmax:15,xmin:0,ymax:15,ymin:0},geometry:{rings:[[[0,15],[15,7.5],[15,0],[0,0],[0,15]]]},canvasPaths:{rings:[[[0,15],[0,0],[15,7.5],[15,15],[0,15]]]}},preview:{frame:{xmax:100,xmin:0,ymax:100,ymin:0},geometry:{rings:[[[0,100],[100,100],[100,0],[0,0],[0,100]]]},canvasPaths:{rings:[[[0,100],[0,0],[100,0],[100,100],[0,100]]]}}},stroke:{legend:{frame:{xmax:24,xmin:0,ymax:2,ymin:-2},geometry:{paths:[[[0,0],[12,0],[24,0]]]},canvasPaths:{paths:[[[0,2],[12,2],[24,2]]]}},preview:{frame:{xmax:100,xmin:0,ymax:2,ymin:-2},geometry:{paths:[[[0,0],[50,0],[100,0]]]},canvasPaths:{paths:[[[0,2],[50,2],[100,2]]]}}}};class z{constructor(e,t){this._spatialReference=e,this._avoidSDF=t,this._resourceCache=new Map,this._pictureMarkerCache=new Map,this._textRasterizer=new f,this._cimResourceManager=new m,this._rasterizer=new h(this._cimResourceManager)}async rasterizeCIMSymbolAsync(e,t,r,a,i,o,n,c){a=a||(t?null!=t.centroid?"esriGeometryPolygon":s(t.geometry):null)||x(e);const l=await this.analyzeCIMSymbol(e,t?P(t.attributes):null,r,a,c);return this.rasterizeCIMSymbol(l,t,a,i,o,n)}async analyzeCIMSymbol(e,t,a,i,s){const o=[],n=t?{geometryType:i,spatialReference:this._spatialReference,fields:t}:null;let l;await c(e.data,n,this._cimResourceManager,o,this._avoidSDF),r(s);for(const r of o)"CIMPictureMarker"!==r.cim.type&&"CIMPictureFill"!==r.cim.type&&"CIMPictureStroke"!==r.cim.type||(l||(l=[]),l.push(this._fetchPictureMarkerResource(r,s))),a&&"text"===r.type&&"string"==typeof r.text&&r.text.indexOf("[")>-1&&(r.text=g(a,r.text,r.cim.textCase));return l&&await Promise.all(l),o}async _fetchPictureMarkerResource(e,r){const a=e.materialHash;if(!this._pictureMarkerCache.get(a)){const i=(await t(e.cim.url,{responseType:"image",signal:r&&r.signal})).data;this._pictureMarkerCache.set(a,i)}}rasterizeCIMSymbol(e,t,r,a,i,s){const o=[];for(const n of e){a&&"function"==typeof a.scaleFactor&&(a.scaleFactor=a.scaleFactor(t,i,s));const e=this._getRasterizedResource(n,t,r,a,i,s);if(!e)continue;let c=0,l=e.anchorX||0,m=e.anchorY||0,h=!1,f=0,g=0;if("esriGeometryPoint"===r){const e=C(a,n,null);if(f=u(n.offsetX,t,i,s)*e||0,g=u(n.offsetY,t,i,s)*e||0,"marker"===n.type)c=u(n.rotation,t,i,s)||0,h=!!n.rotateClockwise&&n.rotateClockwise;else if("text"===n.type){if(c=u(n.angle,t,i,s)||0,void 0!==n.horizontalAlignment)switch(n.horizontalAlignment){case"left":l=-.5;break;case"right":l=.5;break;default:l=0}if(void 0!==n.verticalAlignment)switch(n.verticalAlignment){case"top":m=.5;break;case"bottom":m=-.5;break;case"baseline":m=-.25;break;default:m=0}}}null!=e&&o.push({angle:c,rotateClockWise:h,anchorX:l,anchorY:m,offsetX:f,offsetY:g,rasterizedResource:e})}return this.getSymbolImage(o)}getSymbolImage(e){const t=document.createElement("canvas"),r=t.getContext("2d");let i=0,s=0,o=0,n=0;const c=[];for(let f=0;f<e.length;f++){const t=e[f],l=t.rasterizedResource;if(!l)continue;const m=l.size,h=t.offsetX,g=t.offsetY,u=t.anchorX,y=t.anchorY,p=t.rotateClockWise||!1;let d=t.angle,M=a(h)-m[0]*(.5+u),C=a(g)-m[1]*(.5+y),I=M+m[0],z=C+m[1];if(d){p&&(d=-d);const e=Math.sin(d*Math.PI/180),t=Math.cos(d*Math.PI/180),r=M*t-C*e,a=M*e+C*t,i=M*t-z*e,s=M*e+z*t,o=I*t-z*e,n=I*e+z*t,c=I*t-C*e,l=I*e+C*t;M=Math.min(r,i,o,c),C=Math.min(a,s,n,l),I=Math.max(r,i,o,c),z=Math.max(a,s,n,l)}i=M<i?M:i,s=C<s?C:s,o=I>o?I:o,n=z>n?z:n;const P=r.createImageData(l.size[0],l.size[1]);P.data.set(new Uint8ClampedArray(l.image.buffer));const x={offsetX:h,offsetY:g,rotateClockwise:p,angle:d,rasterizedImage:P,anchorX:u,anchorY:y};c.push(x)}t.width=o-i,t.height=n-s;const l=-i,m=n;for(let f=0;f<c.length;f++){const e=c[f],t=this._imageDataToCanvas(e.rasterizedImage),i=e.rasterizedImage.width,s=e.rasterizedImage.height,o=l-i*(.5+e.anchorX),n=m-s*(.5-e.anchorY);if(e.angle){const i=(360-e.angle)*Math.PI/180;r.save(),r.translate(a(e.offsetX),-a(e.offsetY)),r.translate(l,m),r.rotate(i),r.translate(-l,-m),r.drawImage(t,o,n),r.restore()}else r.drawImage(t,o+a(e.offsetX),n-a(e.offsetY))}const h=new d({x:l/t.width-.5,y:m/t.height-.5});return{imageData:0!==t.width&&0!==t.height?r.getImageData(0,0,t.width,t.height):r.createImageData(1,1),anchorPosition:h}}_imageDataToCanvas(e){this._imageDataCanvas||(this._imageDataCanvas=document.createElement("canvas"));const t=this._imageDataCanvas,r=t.getContext("2d");return t.width=e.width,t.height=e.height,r.putImageData(e,0,0),t}_imageTo32Array(t,r,a,i){this._imageDataCanvas||(this._imageDataCanvas=document.createElement("canvas"));const s=this._imageDataCanvas,o=s.getContext("2d");if(s.width=r,s.height=a,o.drawImage(t,0,0,r,a),i){o.save();const s=new e(i);o.fillStyle=s.toHex(),o.globalCompositeOperation="multiply",o.fillRect(0,0,r,a),o.globalCompositeOperation="destination-atop",o.drawImage(t,0,0,r,a),o.restore()}return new Uint32Array(o.getImageData(0,0,r,a).data.buffer)}_getRasterizedResource(e,t,r,a,s,o){let n,c,l,m,h=null,f=null;if("esriGeometryPolyline"===r||"esriGeometryPolygon"===r){const m=a&&a.style?a.style:M.Legend,g="esriGeometryPolyline"===r?I.stroke[m]:I.fill[m];if("line"===e.type){if("CIMSolidStroke"!==e.cim.type){if("CIMPictureStroke"===e.cim.type){const r=u(e.width,t,s,o),a=u(e.color,t,s,o),{image:i,width:n,height:c}=this._getPictureResource(e,r,a);return this._rasterizePictureResource(e,i,n,c,g,r)}return null}({analyzedCIM:n,hash:l}=w(e,t,s,o)),c=this._embedCIMLayerInVectorMarker(n,g)}else if("marker"===e.type){if("CIMPictureMarker"===e.cim.type){const r=u(e.size,t,s,o),a=u(e.color,t,s,o),{image:i,width:n,height:c}=this._getPictureResource(e,r,a);return this._rasterizePictureResource(e,i,n,c,g,r)}if("CIMVectorMarker"!==e.cim.type)return null;e.cim.offsetX=u(e.offsetX,t,s,o),e.cim.offsetY=u(e.offsetY,t,s,o),e.cim.rotation=u(e.rotation,t,s,o),e.cim.markerPlacement=e.markerPlacement,({analyzedCIM:n}=w(e,t,s,o)),l=i(JSON.stringify(n)).toString(),c=this._embedCIMLayerInVectorMarker(n,g),h=u(e.size,t,s,o),f=e.path}else{if("text"===e.type)return null;if("fill"===e.type){if("CIMHatchFill"===e.cim.type||"CIMVectorMarker"===e.cim.type||"CIMPictureMarker"===e.cim.type||"CIMPictureFill"===e.cim.type){const r=e.cim.size||e.cim.height;let a,i,c;if("CIMPictureMarker"===e.cim.type||"CIMPictureFill"===e.cim.type)({image:a,width:i,height:c}=this._getPictureResource(e,r,u(e.color,t,s,o)));else{({analyzedCIM:n,hash:l}=w(e,t,s,o));const m=this._rasterizer.rasterizeJSONResource({cim:n,type:e.type,url:e.url,mosaicHash:l,size:r,path:f},1,this._avoidSDF);a=m.image,i=m.size[0],c=m.size[1]}return this._rasterizePictureResource(e,a,i,c,g,null)}if("CIMSolidFill"!==e.cim.type)return null;({analyzedCIM:n,hash:l}=w(e,t,s,o)),c=this._embedCIMLayerInVectorMarker(n,g)}}}else{if("text"===e.type)return m=this._rasterizeTextResource(e,t,a,s,o),m;({analyzedCIM:n,hash:l}=w(e,t,s,o));const r=C(a,e,null);if("CIMPictureMarker"===e.cim.type){const a=u(e.size,t,s,o)*r,{image:i,width:n,height:c}=this._getPictureResource(e,a,u(e.color,t,s,o));return m={image:i,size:[n,c],sdf:!1,simplePattern:!1,anchorX:e.anchorPoint?e.anchorPoint.x:0,anchorY:e.anchorPoint?e.anchorPoint.y:0},m}p(n,r,{preserveOutlineWidth:!1}),c=n}l+=r,a&&(l+=JSON.stringify(a));const g=this._resourceCache;return g.has(l)?g.get(l):(m=this._rasterizer.rasterizeJSONResource({cim:c,type:e.type,url:e.url,mosaicHash:l,size:h,path:f},window.devicePixelRatio||1,this._avoidSDF),g.set(l,m),m)}_rasterizeTextResource(e,t,r,a,i){const s=C(r,e,null),o=u(e.text,t,a,i);if(!o||0===o.length)return null;const n=u(e.fontName,t,a,i),c=u(e.style,t,a,i),l=u(e.weight,t,a,i),m=u(e.decoration,t,a,i),h=u(e.size,t,a,i)*s,f=u(e.horizontalAlignment,t,a,i),g=u(e.verticalAlignment,t,a,i),p=y(u(e.color,t,a,i)),d=y(u(e.outlineColor,t,a,i)),M={color:p,size:h,horizontalAlignment:f,verticalAlignment:g,font:{family:n,style:c,weight:l,decoration:m},halo:{size:u(e.outlineSize,t,a,i)||0,color:d,style:c},pixelRatio:1,premultiplyColors:!this._avoidSDF};return this._textRasterizer.rasterizeText(o,M)}_rasterizePictureResource(e,t,r,i,s,c){const l=document.createElement("canvas"),m=l.getContext("2d");l.height=a(Math.max(s.frame.ymax-s.frame.ymin,c)),l.width=a(s.frame.xmax-s.frame.xmin);const h=m.createImageData(r,i);h.data.set(new Uint8ClampedArray(t.buffer));const f=this._imageDataToCanvas(h),g=m.createPattern(f,"repeat"),u=Math.cos((-e.cim.rotation||0)*Math.PI/180),y=Math.sin((-e.cim.rotation||0)*Math.PI/180);g.setTransform({m11:u,m12:y,m21:-y,m22:u,m41:a(e.cim.offsetX)||0,m42:a(e.cim.offsetY)||0});const p=s.canvasPaths;let d,M,C;o(p)?(d=p.rings,m.fillStyle=g,M=m.fill,C=["evenodd"]):n(p)&&(d=p.paths,m.strokeStyle=g,m.lineWidth=c,M=m.stroke,d[0][0][1]=l.height/2,d[0][1][1]=l.height/2),m.beginPath();for(const o of d){const e=o?o.length:0;if(e>1){let t=o[0];m.moveTo(a(t[0]),a(t[1]));for(let r=1;r<e;++r)t=o[r],m.lineTo(a(t[0]),a(t[1]));m.closePath()}}M.apply(m,C);const I=m.getImageData(0,0,l.width,l.height),z=new Uint8Array(I.data);return{size:[l.width,l.height],image:new Uint32Array(z.buffer),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0}}_getPictureResource(e,t,r){const i=this._pictureMarkerCache.get(e.materialHash);if(!i)return null;const s=i.height/i.width,o=t?s>1?a(t):a(t)/s:i.width,n=t?s>1?a(t)*s:a(t):i.height;return{image:this._imageTo32Array(i,o,n,r),width:o,height:n}}_embedCIMLayerInVectorMarker(e,t){const r=o(t.geometry)?"CIMPolygonSymbol":"CIMLineSymbol",a=t.frame;return{type:"CIMVectorMarker",frame:a,size:a.ymax-a.ymin,markerGraphics:[{type:"CIMMarkerGraphic",geometry:t.geometry,symbol:{type:r,symbolLayers:[e]}}]}}}function P(e){return(e?Object.keys(e):[]).map((t=>({name:t,alias:t,type:"string"==typeof e[t]?"esriFieldTypeString":"esriFieldTypeDouble"})))}function x(e){if(!(e&&e.data&&e.data.symbol))return null;switch(e.data.symbol.type){case"CIMPointSymbol":case"CIMTextSymbol":return"esriGeometryPoint";case"CIMLineSymbol":return"esriGeometryPolyline";case"CIMPolygonSymbol":return"esriGeometryPolygon";default:return null}}function w(e,t,r,a){let i,s;if("function"==typeof e.materialHash){i=(0,e.materialHash)(t,r,a),s=l(e.cim,e.materialOverrides)}else i=e.materialHash,s=e.cim;return{analyzedCIM:s,hash:i}}export{z as CIMSymbolRasterizer,M as GeometryStyle};