@arcgis/core 6.0.0-next.12 → 6.0.0-next.14

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 (207) hide show
  1. package/arcade/containerUtils.js +1 -1
  2. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  3. package/arcade/functions/feature.js +1 -1
  4. package/arcade/functions/featuresetstring.js +1 -1
  5. package/arcade/functions/geomasync.js +1 -1
  6. package/arcade/functions/portal.js +1 -1
  7. package/arcade/functions/string.js +1 -1
  8. package/arcgisGlobal.d.ts +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/{5566f14afb63065e438f.js → 0050916e462e3c9e0627.js} +1 -1
  11. package/assets/esri/core/workers/chunks/02c5d027bdaee67869cf.js +1 -0
  12. package/assets/esri/core/workers/chunks/09bd5df07eab80ae7b15.js +1 -0
  13. package/assets/esri/core/workers/chunks/0da6abe3ceabfe78f7a0.js +1 -0
  14. package/assets/esri/core/workers/chunks/0f617980c7dd9ad0444f.js +1 -0
  15. package/assets/esri/core/workers/chunks/{10445313d0d57b34511b.js → 2145a512d269d64036b0.js} +1 -1
  16. package/assets/esri/core/workers/chunks/21ddb26526bcb2b122c3.js +1 -0
  17. package/assets/esri/core/workers/chunks/22e8c0aad2fe75943865.js +1 -0
  18. package/assets/esri/core/workers/chunks/25f19fc929f25ddd628c.js +1 -0
  19. package/assets/esri/core/workers/chunks/28b74bc77f7c13080074.js +1 -0
  20. package/assets/esri/core/workers/chunks/{2ef5237e4c876d6a4ee0.js → 2bd4ee083ca4ad221f8b.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{f4f9d08b2df856e3b694.js → 2eae542fe7f0f6576ac1.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{2aeb5cc32284dd3e4d22.js → 33e4ff228a8c81b99022.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{42323093827adffe56d3.js → 3418877328f4f0830300.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{8dc1c3042267618fd710.js → 34cbaf844730ac2d92c2.js} +2 -2
  25. package/assets/esri/core/workers/chunks/{96c50a0dda0f1503ef92.js → 3c301a689c7853c9fa67.js} +2 -2
  26. package/assets/esri/core/workers/chunks/{02253bdffbd580af22d8.js → 3ff6d1ed3c0f1285f3e7.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{67e4b5651fd7ff7d8cf0.js → 4ac1d3e49e242e373a92.js} +1 -1
  28. package/assets/esri/core/workers/chunks/4df6cb1bee5d0720a43e.js +1 -0
  29. package/assets/esri/core/workers/chunks/{8d0c2de92770a1567536.js → 4e6f40cbdb8c508e6df1.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{dc486a3595b6d57018bb.js → 5bfea0c55aca826de536.js} +1 -1
  31. package/assets/esri/core/workers/chunks/601e1d020b8115497944.js +1 -0
  32. package/assets/esri/core/workers/chunks/62d6e101e9bd9557a410.js +1 -0
  33. package/assets/esri/core/workers/chunks/{2686fe5b62dd0be699c0.js → 634523cc7757da9020e4.js} +1 -1
  34. package/assets/esri/core/workers/chunks/67ebc5a3d46b254b725c.js +1 -0
  35. package/assets/esri/core/workers/chunks/{6e62581d933e7298d1f6.js → 6f4e6022a52de0c54aab.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{a518ae5683367eeda74c.js → 70d3055f15d8b0cf4074.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{1b946714ca4a1a7359d4.js → 76ab353d80d786777161.js} +2 -2
  38. package/assets/esri/core/workers/chunks/{45800373650fbc8262e6.js → 7d11710e1586a3d75887.js} +1 -1
  39. package/assets/esri/core/workers/chunks/7f8e327acad48c9e75ea.js +1 -0
  40. package/assets/esri/core/workers/chunks/8052da8be251c3ff2176.js +1 -0
  41. package/assets/esri/core/workers/chunks/{f6e62d2d279a328cbed7.js → 90bdf86f553e2742d67c.js} +1 -1
  42. package/assets/esri/core/workers/chunks/91ebb2ccab1889eb7e81.js +1 -0
  43. package/assets/esri/core/workers/chunks/{3d9d7d3a40b51eb7ee3d.js → 953ba13299e7aa92c1a0.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{f46d9a19f79d4a4bd354.js → 9e1a3b6a08c96dcefdde.js} +1 -1
  45. package/assets/esri/core/workers/chunks/9f0a973a0dd28953ce25.js +1 -0
  46. package/assets/esri/core/workers/chunks/a2ad3e620c98e2b2eb06.js +1 -0
  47. package/assets/esri/core/workers/chunks/a34b3d2e11a777e1ff3f.js +1 -0
  48. package/assets/esri/core/workers/chunks/{140f2eeb11e39ab15734.js → aa36c3a9bbaa086e3757.js} +1 -1
  49. package/assets/esri/core/workers/chunks/aadfe34a99c9ec7a0e11.js +1 -0
  50. package/assets/esri/core/workers/chunks/b49df4ebd4be1181b0f9.js +2 -0
  51. package/assets/esri/core/workers/chunks/{68d8ae42ab71d01a70a5.js → b557824bc1fa163d72a3.js} +2 -2
  52. package/assets/esri/core/workers/chunks/b8337492e2b753aefac4.js +1 -0
  53. package/assets/esri/core/workers/chunks/bc915fb182d463d804e6.js +1 -0
  54. package/assets/esri/core/workers/chunks/{58032aab28a20a327f6c.js → d03b82e962c70a3fd377.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{992f102992c2bed7b34e.js → d5d0fe8e198ff5a902ee.js} +1 -1
  56. package/assets/esri/core/workers/chunks/e2190361247f35b02b32.js +1 -0
  57. package/assets/esri/core/workers/chunks/e2f42aec02bff33b25dd.js +1 -0
  58. package/assets/esri/core/workers/chunks/ead49b513e070951a964.js +1 -0
  59. package/assets/esri/core/workers/chunks/ebc1a2ef3aed8aa29424.js +1 -0
  60. package/assets/esri/core/workers/chunks/ed6e9d7f71bfd2691717.js +1 -0
  61. package/assets/esri/core/workers/chunks/ee6679ef9efa1504e7eb.js +1 -0
  62. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  63. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  64. package/chunks/BlendWeights.glsl.js +10 -10
  65. package/chunks/Blur.glsl.js +2 -2
  66. package/chunks/EdgeDetect.glsl.js +24 -19
  67. package/chunks/HUDMaterial.glsl.js +11 -1
  68. package/chunks/HighlightApply.glsl.js +4 -5
  69. package/chunks/HighlightBlur.glsl.js +5 -5
  70. package/chunks/HighlightDownsample.glsl.js +2 -2
  71. package/chunks/HighlightSharpApply.glsl.js +61 -0
  72. package/chunks/lyr3DMain.js +1 -1
  73. package/chunks/lyr3DWorker.js +2 -2
  74. package/chunks/portal.js +1 -1
  75. package/config.js +1 -1
  76. package/geometry/operators/simplifyOGCOperator.d.ts +10 -4
  77. package/geometry/support/TileClipper.js +1 -1
  78. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  79. package/geometry/support/curves/mathUtils.js +1 -1
  80. package/interfaces.d.ts +1 -1
  81. package/kernel.js +1 -1
  82. package/layers/CSVLayer.d.ts +1 -1
  83. package/layers/CatalogLayer.d.ts +1 -1
  84. package/layers/FeatureLayer.d.ts +1 -1
  85. package/layers/GeoJSONLayer.d.ts +1 -1
  86. package/layers/ParquetLayer.d.ts +1 -1
  87. package/layers/SceneLayer.d.ts +4 -5
  88. package/layers/SceneLayer.js +1 -1
  89. package/layers/SketchLayer.d.ts +4 -2
  90. package/layers/SubtypeGroupLayer.d.ts +1 -1
  91. package/layers/WFSLayer.d.ts +1 -1
  92. package/layers/buildingSublayers/BuildingComponentSublayer.d.ts +1 -1
  93. package/layers/catalog/CatalogFootprintLayer.d.ts +1 -1
  94. package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
  95. package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
  96. package/layers/geospatialPDF/projectionToWKTUtils.js +2 -2
  97. package/layers/graphics/sources/GeoJSONSource.js +1 -1
  98. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  99. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  100. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  101. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  102. package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +1 -1
  103. package/layers/mixins/ArcGISImageService.d.ts +1 -1
  104. package/layers/raster/datasets/TIFFRaster.js +1 -1
  105. package/layers/raster/datasets/pixelReader.js +1 -1
  106. package/layers/raster/functions/clipUtils.js +1 -1
  107. package/layers/support/FeatureFilter.d.ts +1 -1
  108. package/layers/support/SubtypeSublayer.d.ts +1 -1
  109. package/layers/support/{TimeSeriesCalculation.d.ts → TimeSeriesCalculationMethod.d.ts} +6 -6
  110. package/layers/support/{TimeSeriesCalculation.js → TimeSeriesCalculationMethod.js} +1 -1
  111. package/layers/support/TimeSeriesInfo.d.ts +5 -5
  112. package/layers/support/TimeSeriesInfo.js +1 -1
  113. package/layers/support/fieldUtils.js +1 -1
  114. package/layers/support/timeSeriesUtils.d.ts +6 -2
  115. package/layers/support/timeSeriesUtils.js +1 -1
  116. package/package.json +4 -4
  117. package/portal/schemas/definitions.js +1 -1
  118. package/smartMapping/renderers/support/timeSeriesUtils.js +1 -1
  119. package/smartMapping/statistics/support/timeSeriesUtils.js +1 -1
  120. package/symbols/cim/cimAnalyzer.js +1 -1
  121. package/symbols/cim/types.d.ts +1 -1
  122. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  123. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/projection.js +1 -1
  124. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  125. package/views/3d/analysis/LineOfSight/LineOfSightObserverPlugin.js +1 -1
  126. package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
  127. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  128. package/views/3d/webgl-engine/core/shaderLibrary/HighlightCellGridScreenSpacePass.glsl.js +20 -6
  129. package/views/3d/webgl-engine/core/shaderLibrary/raster/Projection.glsl.js +2 -2
  130. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  131. package/views/3d/webgl-engine/effects/highlight/HighlightApply.glsl.js +1 -1
  132. package/views/3d/webgl-engine/effects/highlight/HighlightCellGridScreenSpacePassParameters.js +2 -0
  133. package/views/3d/webgl-engine/effects/highlight/HighlightDownsample.glsl.js +1 -1
  134. package/views/3d/webgl-engine/effects/highlight/HighlightPassParameters.js +1 -1
  135. package/views/3d/webgl-engine/effects/highlight/HighlightSharpApply.glsl.js +2 -0
  136. package/views/3d/webgl-engine/effects/highlight/HighlightSharpApplyTechnique.js +2 -0
  137. package/views/3d/webgl-engine/effects/smaa/BlendWeights.glsl.js +1 -1
  138. package/views/3d/webgl-engine/effects/smaa/Blur.glsl.js +1 -1
  139. package/views/3d/webgl-engine/effects/smaa/EdgeDetect.glsl.js +1 -1
  140. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  141. package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
  142. package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
  143. package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
  144. package/views/3d/webgl-engine/effects/smaa/SMAAPassParameters.js +1 -1
  145. package/views/3d/webgl-engine/effects/smaa/SMAATechniqueConfiguration.js +2 -0
  146. package/views/3d/webgl-engine/lib/Compositor.js +1 -1
  147. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  148. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  149. package/views/draw/DrawTool.js +1 -1
  150. package/views/draw/plugins/MultipointPlugin.js +1 -1
  151. package/views/draw/support/PluginContext.js +1 -1
  152. package/views/draw/support/managers/TooltipManager.js +1 -1
  153. package/views/draw/support/types.d.ts +5 -2
  154. package/views/layers/FeatureLikeLayerView.d.ts +1 -1
  155. package/views/layers/PointCloudLayerView.d.ts +1 -1
  156. package/views/layers/SceneLayerView.d.ts +1 -1
  157. package/views/support/HighlightDefaults.js +1 -1
  158. package/webdoc/applicationProperties/SearchLayerField.d.ts +7 -1
  159. package/webdoc/applicationProperties/SearchLayerField.js +1 -1
  160. package/webdoc/applicationProperties/SearchTableField.d.ts +7 -1
  161. package/webdoc/applicationProperties/SearchTableField.js +1 -1
  162. package/webdoc/applicationProperties/searchMode.js +2 -0
  163. package/widgets/BatchAttributeForm/attachmentUtils.d.ts +10 -0
  164. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  165. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +2 -0
  166. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  167. package/widgets/BatchAttributeForm/inputs/types.d.ts +10 -1
  168. package/widgets/BatchAttributeForm.js +1 -1
  169. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  170. package/widgets/Search/LayerSearchSource.d.ts +23 -1
  171. package/widgets/Search/LayerSearchSource.js +1 -1
  172. package/widgets/Search/support/layerSearchUtils.js +1 -1
  173. package/widgets/Search/types.d.ts +7 -0
  174. package/widgets/support/forms/formUtils.js +1 -1
  175. package/widgets/support/forms/types.d.ts +1 -1
  176. package/assets/esri/core/workers/chunks/0dc66b03ff55d0ea5a09.js +0 -1
  177. package/assets/esri/core/workers/chunks/175c268e64ccd01f8c25.js +0 -1
  178. package/assets/esri/core/workers/chunks/216e6065b224309e1051.js +0 -1
  179. package/assets/esri/core/workers/chunks/2a1ec30f9ad305763f81.js +0 -2
  180. package/assets/esri/core/workers/chunks/37d6a264a3f1d8072aa0.js +0 -1
  181. package/assets/esri/core/workers/chunks/3df5500a85345577480a.js +0 -1
  182. package/assets/esri/core/workers/chunks/3f7d583b676b23b3fadb.js +0 -1
  183. package/assets/esri/core/workers/chunks/4503b20ca6a80fb63d72.js +0 -1
  184. package/assets/esri/core/workers/chunks/4a640548032355e57acd.js +0 -1
  185. package/assets/esri/core/workers/chunks/4debf2d9c3465250ef7a.js +0 -1
  186. package/assets/esri/core/workers/chunks/53be85d04cd2da4f391d.js +0 -1
  187. package/assets/esri/core/workers/chunks/54778dec1598818d93cb.js +0 -1
  188. package/assets/esri/core/workers/chunks/567a65f4203f6e81f4b4.js +0 -1
  189. package/assets/esri/core/workers/chunks/5982c6a8459c1237b298.js +0 -1
  190. package/assets/esri/core/workers/chunks/74b5c00f93cfc0d59029.js +0 -1
  191. package/assets/esri/core/workers/chunks/78472a57c2ba146fec65.js +0 -1
  192. package/assets/esri/core/workers/chunks/7c2c8f786a30267a5f05.js +0 -1
  193. package/assets/esri/core/workers/chunks/88e54449261ef94e390d.js +0 -1
  194. package/assets/esri/core/workers/chunks/917f53833b853898facc.js +0 -1
  195. package/assets/esri/core/workers/chunks/9e142551163acf752618.js +0 -1
  196. package/assets/esri/core/workers/chunks/aaba33611753c6aada68.js +0 -1
  197. package/assets/esri/core/workers/chunks/af75747b06d79446a855.js +0 -1
  198. package/assets/esri/core/workers/chunks/b5fdcc80d5973b6e26d1.js +0 -1
  199. package/assets/esri/core/workers/chunks/d6ad4390df576198e45b.js +0 -1
  200. package/assets/esri/core/workers/chunks/dba280c370df13196711.js +0 -1
  201. package/assets/esri/core/workers/chunks/f1f90adae13b04898008.js +0 -1
  202. package/assets/esri/core/workers/chunks/f47c7065da3b5001245f.js +0 -1
  203. /package/assets/esri/core/workers/chunks/{1b946714ca4a1a7359d4.js.LICENSE.txt → 34cbaf844730ac2d92c2.js.LICENSE.txt} +0 -0
  204. /package/assets/esri/core/workers/chunks/{96c50a0dda0f1503ef92.js.LICENSE.txt → 3c301a689c7853c9fa67.js.LICENSE.txt} +0 -0
  205. /package/assets/esri/core/workers/chunks/{8dc1c3042267618fd710.js.LICENSE.txt → 76ab353d80d786777161.js.LICENSE.txt} +0 -0
  206. /package/assets/esri/core/workers/chunks/{2a1ec30f9ad305763f81.js.LICENSE.txt → b49df4ebd4be1181b0f9.js.LICENSE.txt} +0 -0
  207. /package/assets/esri/core/workers/chunks/{68d8ae42ab71d01a70a5.js.LICENSE.txt → b557824bc1fa163d72a3.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../Graphic.js";import n from"../PopupTemplate.js";import{ClonableMixin as r}from"../core/Clonable.js";import i from"../core/Collection.js";import a from"../core/Error.js";import{abortHandle as o}from"../core/handleUtils.js";import s from"../core/Logger.js";import{destroyMaybe as c}from"../core/maybe.js";import{MultiOriginJSONSupportMixin as l}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as u,throwIfAborted as d,isAbortError as f,throwIfNotAbortError as p}from"../core/promiseUtils.js";import{whenOnce as m}from"../core/reactiveUtils.js";import{property as h,subclass as g}from"../core/accessorSupport/decorators.js";import{getProperties as _}from"../core/accessorSupport/utils.js";import v from"../geometry/Point.js";import{projectAsync as y}from"../geometry/projectionUtils.js";import b from"../graphic/SceneGraphicOrigin.js";import x from"./Layer.js";import{NoModelError as ee,MultipleModelsError as S}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as C}from"./mixins/APIKeyMixin.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{CustomParametersMixin as te}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as ne}from"./mixins/EditBusLayer.js";import{OperationalLayer as re}from"./mixins/OperationalLayer.js";import{PortalLayer as ie}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as ae}from"./mixins/ScaleRangeLayer.js";import{SceneService as oe}from"./mixins/SceneService.js";import{useViewTimeProperty as se}from"./mixins/TemporalLayer.js";import{isHostedAgolService as T}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as ce}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as le}from"./support/capabilities.js";import{elevationInfo as E,labelsVisible as D,legendEnabled as O,popupEnabled as k,attributeTableTemplate as A,screenSizePerspectiveEnabled as j,timeInfo as M}from"./support/commonProperties.js";import{getFieldDomain as N,computeEffectiveEditingEnabled as P,getGlobalIdToObjectIdMap as F}from"./support/featureLayerUtils.js";import I from"./support/FeatureReductionSelection.js";import{defineFieldProperties as L}from"./support/fieldProperties.js";import R from"./support/FieldsIndex.js";import{fixRendererFields as z,fixTimeInfoFields as B,unpackFieldNames as V}from"./support/fieldUtils.js";import{I3SNodePageDefinition as H,I3SMaterialDefinition as U,I3STextureSetDefinition as W,I3SGeometryDefinition as ue}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as de,isFileSupported as fe}from"./support/infoFor3D.js";import pe from"./support/LabelClass.js";import{reader as G}from"./support/labelingInfo.js";import me from"./support/LayerFloorInfo.js";import{layersLoaderMap as he}from"./support/layersLoader.js";import{getMeshTransformForMetersToSpatialReference as ge}from"./support/meshSpatialReferenceScaleUtils.js";import{RangeInfo as _e}from"./support/RangeInfo.js";import ve from"./support/SceneFilter.js";import{cacheIsOutOfSync as K}from"./support/sceneLayerCacheUtils.js";import{fetchStatistics as ye}from"./support/sceneLayerStatistics.js";import{SceneServiceTimeInfo as be}from"./support/SceneServiceTimeInfo.js";import xe from"./support/TimeInfo.js";import{loadStyleRenderer as Se}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as Ce}from"../renderers/support/typeUtils.js";import we from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as q,elevationModeUnsupportedMessage as Te,featureExpressionUnsupportedMessage as Ee}from"../support/elevationInfoUtils.js";import{createPopupTemplate as De}from"../support/popupUtils.js";import{extractZipFiles as Oe}from"../support/zipUtils.js";import J from"../time/TimeExtent.js";import ke from"../time/TimeInterval.js";import{queryAttributesFromCachedAttributesId as Ae}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as je,getFetchPopupTemplate as Me}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as Ne}from"../webdoc/support/opacityUtils.js";import{reader as Y}from"../core/accessorSupport/decorators/reader.js";const X=new Set([`3DObject`,`Point`]),Z=L();let Q=class extends ne(oe(w(re(ie(ae(l(te(C(r(x)))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType=`ArcGISSceneServiceLayer`,this.type=`scene`,this.fields=null,this.graphicOrigin=new b(this),this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new i,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.attributeTableTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0,this.serviceTimeInfo=null}normalizeCtorArgs(e,t){return typeof e==`string`?{url:e,...t}:e}destroy(){this._set(`renderer`,null),this.associatedLayer=c(this.associatedLayer)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){let n=this.getField(e)?.domain??null;return this.associatedLayer?N(this.associatedLayer,e,t,n):n}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new R(this.fields)}readNodePages(e,t,n){return t.layerType===`Point`&&(e=t.pointNodePages),typeof e!=`object`||!e?null:H.fromJSON(e,n)}set elevationInfo(e){this._set(`elevationInfo`,e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return this.associatedLayer!=null&&P(this.associatedLayer)}get geometryType(){return Pe[this.profile]||`mesh`}set renderer(e){z(e,this.fieldsIndex),this._set(`renderer`,e)}readCachedDrawingInfo(e){return(typeof e!=`object`||!e)&&(e={}),e.color??(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e??=le;let{query:t,queryRelated:n,editing:{supportsGlobalId:r,supportsRollbackOnFailure:i,supportsUploadWithItemId:a,supportsGeometryUpdate:o,supportsReturnServiceEditsInSourceSpatialReference:s},data:{supportsZ:c,supportsM:l,isVersioned:u,supportsAttachment:d},operations:{supportsEditing:f,supportsAdd:p,supportsUpdate:m,supportsDelete:h,supportsQuery:g,supportsQueryAttachments:_,supportsAsyncConvert3D:v},attachment:y}=e,b=e.operations.supportsChangeTracking,x=!!this.associatedLayer?.infoFor3D;return{query:t,queryRelated:n,editing:{supportsGlobalId:r,supportsReturnServiceEditsInSourceSpatialReference:s,supportsRollbackOnFailure:i,supportsGeometryUpdate:x&&o,supportsUploadWithItemId:a},data:{supportsAttachment:d,supportsZ:c,supportsM:l,isVersioned:u,queryFormats:e.data.queryFormats,sourceFormats:e.data.sourceFormats},operations:{supportsQuery:g,supportsQueryAttachments:_,supportsEditing:f&&b,supportsAdd:x&&p&&b,supportsDelete:x&&h&&b,supportsUpdate:m&&b,supportsAsyncConvert3D:v},attachment:y}}get editingEnabled(){return this._isOverridden(`editingEnabled`)?this._get(`editingEnabled`):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome(`editingEnabled`,e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some(t=>(t.type===`esriFieldTypeOID`&&(e=t.name),!!e)),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some(t=>(t.type===`esriFieldTypeGlobalID`&&(e=t.name),!!e)),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){let n=t.store.profile;return n!=null&&$[n]?$[n]:(s.getLogger(this).error(`Unknown or missing profile`,{profile:n,layer:this}),`mesh-pyramids`)}get useViewTime(){return this.associatedLayer?.useViewTime??!0}set useViewTime(e){this._override(`useViewTime`,e)}get timeInfo(){let e=this.associatedLayer?.timeInfo;if(e==null)return null;let t=e.clone();return B(t,this.fieldsIndex),t}set timeInfo(e){B(e,this.fieldsIndex),this._override(`timeInfo`,e)}get timeExtent(){return this.associatedLayer?.timeExtent}set timeExtent(e){this._override(`timeExtent`,e)}get timeOffset(){return this.associatedLayer?.timeOffset}set timeOffset(e){this._override(`timeOffset`,e)}get datesInUnknownTimezone(){return this.associatedLayer?.datesInUnknownTimezone??!1}set datesInUnknownTimezone(e){this._override(`datesInUnknownTimezone`,e)}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){let t=e?.signal;await this.loadFromPortal({supportedTypes:[`Scene Service`]},e).catch(u),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await this.loadTimeInfoFromService(e),await Se(this,{origin:`service`},t),z(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){this.filter!=null&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){s.getLogger(this).error(`#_loadFilterGeometries()`,this,`Failed to load filter geometries. Geometry filter will not be applied for this layer.`,{error:e}),this.filter=null}}createQuery(){let e=new we;return this.geometryType===`mesh`?this.capabilities.query.supportsReturnMesh&&(e.returnGeometry=!0):(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||`1=1`,e.sqlFormat=`standard`,e.outFields=[`*`],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryExtent(e||this.createQuery(),t))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryFeatureCount(e||this.createQuery(),t))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryFeatures(e||this.createQuery(),t)).then(e=>{if(e?.features)for(let t of e.features)t.layer=this,t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}async queryModels(e,t){let[n,{queryModels:r}]=await Promise.all([this._getAssociatedLayerForQuery(),import(`./scene/modelQuerySupport.js`)]);return r(this,n,e,t)}async queryModel(e,t){let[n,{queryModel:r}]=await Promise.all([this._getAssociatedLayerForQuery(),import(`./scene/modelQuerySupport.js`)]);return r(this,n,e,t)}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new a(`scenelayer:query-not-available`,`SceneLayer queries are not available without an associated feature layer`,{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new a(`scenelayer:query-not-available`,`SceneLayer queries are not available without an associated feature layer`,{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){let n=V(this.fieldsIndex,await je(this,Me(this)));return Ae(this.parsedUrl?.path??``,this.attributeStorageInfo??[],e,t,n,this.apiKey,this.customParameters)}async queryCachedFeature(e,n){let r=await this.queryCachedAttributes(e,[n]);if(!r||r.length===0)throw new a(`scenelayer:feature-not-in-cached-data`,`Feature not found in cached data`);let i=new t;return i.attributes=r[0],i.layer=this,i.sourceLayer=this,i.origin=this.graphicOrigin,i}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryObjectIds(e||this.createQuery(),t))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryAttachments(e,t))}getFieldUsageInfo(e){let t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(s.getLogger(this).error(`#getFieldUsageInfo()`,`Unavailable until layer is loaded`),t)}createPopupTemplate(e){return De(this,e)}_getAssociatedLayerForQuery(){let e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new a(`scenelayer:query-not-available`,`SceneLayer queries are not available without an associated feature layer`,{layer:this});try{await this.associatedLayer.load()}catch(e){throw new a(`scenelayer:query-not-available`,`SceneLayer associated feature layer could not be loaded`,{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return this.statisticsInfo!=null&&this.statisticsInfo.some(t=>t.name===e)}async queryCachedStatistics(e,t){return await this.load(t),await this.fetchStatistics(e,t)}async saveAs(e,t){return this._debouncedSaveOperations(1,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:`scene`},e)}async save(){return this._debouncedSaveOperations(0,{getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:`scene`})}async applyEdits(e,t){let{applyEdits:n}=await import(`./graphics/editingSupport.js`),r=t;await this.load();let i=this.associatedLayer;if(!i)throw new a(`${this.type}-layer:not-editable`,`Service is not editable`);await i.load();let{globalIdField:o}=i,s=!!i.infoFor3D,c=r?.globalIdUsed??!0;if(s&&o==null)throw new a(`${this.type}-layer:not-editable`,`Valid globalIdField expected on editable SceneLayer`);if(s&&!c)throw new a(`${this.type}-layer:globalid-required`,`globalIdUsed must not be false for SceneLayer editing as globalIds are required.`);return T(i.url)&&s&&e.deleteFeatures!=null&&o!=null&&(r={...r,globalIdToObjectId:await F(i,e.deleteFeatures,o)}),n(this,i.source,e,r)}async uploadAssets(e,t){if(await this.load(),this.associatedLayer==null)throw new a(`${this.type}-layer:not-editable`,`Service is not editable`);return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}async convertMesh(e,t){t??={};let n=e=>{throw s.getLogger(this).error(`.convertMesh()`,e.message),e};await this.load(t),this.infoFor3D||n(new a(`invalid:layer`,`SceneLayer has no capability for mesh conversion`));let r=await this.extractAndFilterFiles(e);d(t);let i=r.reduce((e,t)=>de(this.infoFor3D,t)?e+1:e,0);i===0&&n(new ee),i>1&&n(new S);let o=this.spatialReference,c=t.origin,l=await y(c??t.defaultOrigin??new v({x:0,y:0,z:0,spatialReference:o}),o,t),u=o.isGeographic?`local`:`georeferenced`,{createWithExternalSource:f}=await import(`../geometry/support/meshUtils.js`);d(t);let p=f(l,{type:`client`,files:r},{vertexSpace:u,transform:ge(o),unitConversionDisabled:!0}),[m]=await this.uploadAssets([p],{...t,useAssetOrigin:!c});return m}async extractAndFilterFiles(e){await this.load();let t=this.infoFor3D;return t?(await Oe(e)).filter(e=>fe(t,e)):e}validateLayer(e){if(e.layerType&&!X.has(e.layerType))throw new a(`scenelayer:layer-type-not-supported`,`SceneLayer does not support this layer type`,{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new a(`layer:service-version-not-supported`,`Service version is not supported.`,{serviceVersion:this.version.versionString,supportedVersions:`1.x, 2.x`});if(this.version.major>2)throw new a(`layer:service-version-too-new`,`Service version is too new.`,{serviceVersion:this.version.versionString,supportedVersions:`1.x, 2.x`});t(this.normalReferenceFrame,this.spatialReference);function t(e,t){let n=!1,r=!1;if(e==null)n=!0,r=!0;else{let i=t&&t.isGeographic;switch(e){case`east-north-up`:case`earth-centered`:n=!0,r=i;break;case`vertex-reference-frame`:n=!0,r=!i;break;default:n=!1}}if(!n)throw new a(`scenelayer:unsupported-normal-reference-frame`,`Normal reference frame is invalid.`);if(!r)throw new a(`scenelayer:incompatible-normal-reference-frame`,`Normal reference frame is incompatible with layer spatial reference.`)}}get isUsedAsGroundLayer(){return!1}_getTypeKeywords(){let e=[];if(this.profile===`points`)e.push(`Point`);else if(this.profile===`mesh-pyramids`)e.push(`3DObject`);else throw new a(`scenelayer:unknown-profile`,`SceneLayer:save() encountered an unknown SceneLayer profile: `+this.profile);return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(let e of this.fields){let t=!!this.attributeStorageInfo?.some(t=>t.name===e.name),n=!!this.associatedLayer?.fields?.some(t=>t&&e.name===t.name),r={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||n,supportsLayerQuery:n};this._fieldUsageInfo[e.name]=r}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPropertyOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(let t of this.associatedLayer.fields){let n=this.getField(t.name);n?(!n.domain&&t.domain&&(n.domain=t.domain.clone()),n.editable=t.editable,n.nullable=t.nullable,n.length=t.length):(e||=this.fields?this.fields.slice():[],e.push(t.clone()))}e&&this._set(`fields`,e)}_applyAssociatedLayerPropertyOverrides(){if(!this.associatedLayer)return;let e=[`popupTemplate`,`popupEnabled`,`attributeTableTemplate`],t=_(this);for(let n=0;n<e.length;n++){let r=e[n],i=this.originIdOf(r),a=this.associatedLayer.originIdOf(r);i<a&&(a===2||a===3)&&t.setAtOrigin(r,this.associatedLayer[r],a)}}_applyAssociatedLayerExtentOverride(){let e=this.associatedLayer?.getAtOrigin(`fullExtent`,`service`);this.associatedLayer?.infoFor3D!=null&&e&&T(this.associatedLayer?.url)&&K(this)&&_(this).setAtOrigin(`fullExtent`,e.clone(),2)}_applyAssociatedLayerPrivileges(){let e=this.associatedLayer;e&&(this._set(`userHasEditingPrivileges`,e.userHasEditingPrivileges),this._set(`userHasFullEditingPrivileges`,e.userHasFullEditingPrivileges),this._set(`userHasUpdateItemPrivileges`,e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if([`mesh-pyramids`,`points`].includes(this.profile))try{let{serverUrl:t,layerId:n,portalItem:r}=await ce(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),i=await he.FeatureLayer();this.associatedLayer=new i({url:t,customParameters:this.customParameters,apiKey:this.apiKey,layerId:n,portalItem:r}),await this.associatedLayer.load()}catch(e){f(e)||this._logWarningOnPopupEnabled().catch(()=>{})}}async _logWarningOnPopupEnabled(){let e=new AbortController;this.addHandles(o(e));try{await m(()=>this.popupEnabled&&this.popupTemplate!=null,e.signal)}catch(e){p(e);return}let t=`this SceneLayer: ${this.title}`;this.attributeStorageInfo==null?s.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${t}`):s.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${t}`)}_validateElevationInfo(){let e=this.elevationInfo;this.profile===`mesh-pyramids`&&q(s.getLogger(this),Te(`Mesh scene layers`,`relative-to-scene`,e)),q(s.getLogger(this),Ee(`Scene layers`,e))}async fetchStatistics(e,t){return await ye({fieldName:e,statisticsInfo:this.statisticsInfo,errorContext:`scenelayer`,fieldsIndex:this.fieldsIndex,path:this.parsedUrl?.path??``,customParameters:this.customParameters,apiKey:this.apiKey,signal:t?.signal})}async loadTimeInfoFromService(e){let{serviceTimeInfo:t}=this;if(t==null)return;let{startTimeField:n,endTimeField:r}=t;if(n==null&&r==null||K({associatedLayer:this.associatedLayer,serviceUpdateTimeStamp:this.serviceUpdateTimeStamp}))return;let i=async t=>{let r=null;try{r=(await this.fetchStatistics(t,e))?.stats}catch{}if(r==null)return null;let{minTimeStr:i,min:a,maxTimeStr:o,max:s}=r,c=t===n?i??a:o??s;return c==null?null:new Date(c)},[a,o]=await Promise.all([i(n),i(r)]);if(n!=null&&a==null||r!=null&&o==null)return;let s=new J({start:a,end:o});this.setAtOrigin(`timeInfo`,new xe({endField:r,startField:n,fullTimeExtent:s}),`service`)}};e([h({types:{key:`type`,base:null,typeMap:{selection:I}},json:{origins:{"web-scene":{name:`layerDefinition.featureReduction`,write:{allowNull:!0}},"portal-item":{name:`layerDefinition.featureReduction`,write:{allowNull:!0}}}}})],Q.prototype,`featureReduction`,void 0),e([h({type:[_e],json:{read:!1,origins:{"web-scene":{name:`layerDefinition.rangeInfos`,write:!0},"portal-item":{name:`layerDefinition.rangeInfos`,write:!0}}},clonable:!1})],Q.prototype,`rangeInfos`,void 0),e([h({json:{read:!1}})],Q.prototype,`associatedLayer`,void 0),e([h({type:[`show`,`hide`]})],Q.prototype,`listMode`,void 0),e([h({type:[`ArcGISSceneServiceLayer`]})],Q.prototype,`operationalLayerType`,void 0),e([h({json:{read:!1},readOnly:!0})],Q.prototype,`type`,void 0),e([h({...Z.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`fields`,void 0),e([h()],Q.prototype,`types`,null),e([h()],Q.prototype,`typeIdField`,null),e([h()],Q.prototype,`templates`,null),e([h()],Q.prototype,`formTemplate`,null),e([h({readOnly:!0})],Q.prototype,`graphicOrigin`,void 0),e([h({readOnly:!0,clonable:!1})],Q.prototype,`fieldsIndex`,null),e([h({type:me,json:{read:{source:`layerDefinition.floorInfo`},write:{target:`layerDefinition.floorInfo`}}})],Q.prototype,`floorInfo`,void 0),e([h(Z.outFields)],Q.prototype,`outFields`,void 0),e([h({type:H,readOnly:!0,json:{read:!1},clonable:!1})],Q.prototype,`nodePages`,void 0),e([Y(`service`,`nodePages`,[`nodePages`,`pointNodePages`])],Q.prototype,`readNodePages`,null),e([h({type:[U],readOnly:!0,clonable:!1})],Q.prototype,`materialDefinitions`,void 0),e([h({type:[W],readOnly:!0,clonable:!1})],Q.prototype,`textureSetDefinitions`,void 0),e([h({type:[ue],readOnly:!0,clonable:!1})],Q.prototype,`geometryDefinitions`,void 0),e([h({readOnly:!0})],Q.prototype,`serviceUpdateTimeStamp`,void 0),e([h({readOnly:!0})],Q.prototype,`attributeStorageInfo`,void 0),e([h({readOnly:!0})],Q.prototype,`statisticsInfo`,void 0),e([h({type:i.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:`layerDefinition.excludeObjectIds`,write:{enabled:!0}}})],Q.prototype,`excludeObjectIds`,void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:`layerDefinition.definitionExpression`,write:{enabled:!0,allowNull:!0}}})],Q.prototype,`definitionExpression`,void 0),e([h({type:ve,json:{name:`layerDefinition.polygonFilter`,write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Q.prototype,`filter`,void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Q.prototype,`path`,void 0),e([h(E)],Q.prototype,`elevationInfo`,null),e([h({readOnly:!0,json:{read:!1}})],Q.prototype,`effectiveCapabilities`,null),e([h({readOnly:!0})],Q.prototype,`effectiveEditingEnabled`,null),e([h({type:String})],Q.prototype,`geometryType`,null),e([h(D)],Q.prototype,`labelsVisible`,void 0),e([h({type:[pe],json:{origins:{service:{name:`drawingInfo.labelingInfo`,read:{reader:G},write:!1}},name:`layerDefinition.drawingInfo.labelingInfo`,read:{reader:G},write:!0}})],Q.prototype,`labelingInfo`,void 0),e([h(O)],Q.prototype,`legendEnabled`,void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:[`opacity`,`layerDefinition.drawingInfo.transparency`],reader(e,t){if(typeof e==`number`&&e>=0&&e<=1)return e;let n=t.layerDefinition?.drawingInfo?.transparency;return n===void 0?void 0:Ne(n)}}},"portal-item":{write:!0},service:{read:!1}}}})],Q.prototype,`opacity`,void 0),e([h({type:[`Low`,`High`],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`priority`,void 0),e([h({type:[`Labels`],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`semantic`,void 0),e([h({types:Ce,json:{origins:{service:{read:{source:`drawingInfo.renderer`}}},name:`layerDefinition.drawingInfo.renderer`,write:!0},value:null})],Q.prototype,`renderer`,null),e([h({json:{read:!1}})],Q.prototype,`cachedDrawingInfo`,void 0),e([Y(`service`,`cachedDrawingInfo`)],Q.prototype,`readCachedDrawingInfo`,null),e([h({readOnly:!0,json:{read:!1}})],Q.prototype,`capabilities`,null),e([h({type:Boolean,json:{read:!1}})],Q.prototype,`editingEnabled`,null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Q.prototype,`infoFor3D`,null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Q.prototype,`relationships`,null),e([h(k)],Q.prototype,`popupEnabled`,void 0),e([h({type:n,json:{name:`popupInfo`,write:!0}})],Q.prototype,`popupTemplate`,void 0),e([h({readOnly:!0,json:{read:!1}})],Q.prototype,`defaultPopupTemplate`,null),e([h(A)],Q.prototype,`attributeTableTemplate`,void 0),e([h({type:String,json:{read:!1}})],Q.prototype,`objectIdField`,void 0),e([Y(`service`,`objectIdField`,[`objectIdField`,`fields`])],Q.prototype,`readObjectIdField`,null),e([h({type:String,json:{read:!1}})],Q.prototype,`globalIdField`,void 0),e([Y(`service`,`globalIdField`,[`globalIdField`,`fields`])],Q.prototype,`readGlobalIdField`,null),e([h({readOnly:!0,type:String,json:{read:!1}})],Q.prototype,`displayField`,null),e([h({type:String,json:{read:!1}})],Q.prototype,`profile`,void 0),e([Y(`service`,`profile`,[`store.profile`])],Q.prototype,`readProfile`,null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:`store.normalReferenceFrame`}}},read:!1}})],Q.prototype,`normalReferenceFrame`,void 0),e([h(j)],Q.prototype,`screenSizePerspectiveEnabled`,void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`serviceItemId`,void 0),e([h(se)],Q.prototype,`useViewTime`,null),e([h(M({disableServiceOrigin:!0,webDocumentOrigin:`web-scene`}))],Q.prototype,`timeInfo`,null),e([h({type:J,json:{read:!1,write:!1}})],Q.prototype,`timeExtent`,null),e([h({type:ke,json:{read:!1,write:!1}})],Q.prototype,`timeOffset`,null),e([h({type:Boolean,nonNullable:!0,json:{read:!1,write:!1}})],Q.prototype,`datesInUnknownTimezone`,null),e([h({type:be,readOnly:!0,json:{read:{source:`timeInfo`}},clonable:!1})],Q.prototype,`serviceTimeInfo`,void 0),e([h()],Q.prototype,`isUsedAsGroundLayer`,null),Q=e([g(`esri.layers.SceneLayer`)],Q);const $={"mesh-pyramids":`mesh-pyramids`,meshpyramids:`mesh-pyramids`,"features-meshes":`mesh-pyramids`,points:`points`,"features-points":`points`,lines:`lines`,"features-lines":`lines`,polygons:`polygons`,"features-polygons":`polygons`},Pe={"mesh-pyramids":`mesh`,points:`point`},Fe=Q;export{Fe as default};
2
+ import{__decorate as e}from"tslib";import t from"../Graphic.js";import n from"../PopupTemplate.js";import{ClonableMixin as r}from"../core/Clonable.js";import i from"../core/Collection.js";import a from"../core/Error.js";import{abortHandle as o}from"../core/handleUtils.js";import s from"../core/Logger.js";import{destroyMaybe as c}from"../core/maybe.js";import{MultiOriginJSONSupportMixin as l}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as u,throwIfAborted as d,isAbortError as f,throwIfNotAbortError as p}from"../core/promiseUtils.js";import{whenOnce as m}from"../core/reactiveUtils.js";import{property as h,subclass as g}from"../core/accessorSupport/decorators.js";import{getProperties as _}from"../core/accessorSupport/utils.js";import v from"../geometry/Point.js";import{projectAsync as y}from"../geometry/projectionUtils.js";import b from"../graphic/SceneGraphicOrigin.js";import x from"./Layer.js";import{NoModelError as ee,MultipleModelsError as S}from"./graphics/sources/support/uploadAssetErrors.js";import{APIKeyMixin as C}from"./mixins/APIKeyMixin.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{CustomParametersMixin as te}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as ne}from"./mixins/EditBusLayer.js";import{OperationalLayer as re}from"./mixins/OperationalLayer.js";import{PortalLayer as ie}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as ae}from"./mixins/ScaleRangeLayer.js";import{SceneService as oe}from"./mixins/SceneService.js";import{useViewTimeProperty as se}from"./mixins/TemporalLayer.js";import{isHostedAgolService as T}from"./support/arcgisLayerUrl.js";import{findAssociatedFeatureService as ce}from"./support/associatedFeatureServiceUtils.js";import{zeroCapabilities as le}from"./support/capabilities.js";import{elevationInfo as E,labelsVisible as D,legendEnabled as O,popupEnabled as k,attributeTableTemplate as A,screenSizePerspectiveEnabled as j,timeInfo as M}from"./support/commonProperties.js";import{getFieldDomain as N,computeEffectiveEditingEnabled as P,getGlobalIdToObjectIdMap as F}from"./support/featureLayerUtils.js";import I from"./support/FeatureReductionSelection.js";import{defineFieldProperties as L}from"./support/fieldProperties.js";import R from"./support/FieldsIndex.js";import{fixRendererFields as z,fixTimeInfoFields as B,unpackFieldNames as V}from"./support/fieldUtils.js";import{I3SNodePageDefinition as H,I3SMaterialDefinition as U,I3STextureSetDefinition as W,I3SGeometryDefinition as ue}from"./support/I3SLayerDefinitions.js";import{isFileEditFormat as de,isFileSupported as fe}from"./support/infoFor3D.js";import pe from"./support/LabelClass.js";import{reader as G}from"./support/labelingInfo.js";import me from"./support/LayerFloorInfo.js";import{layersLoaderMap as he}from"./support/layersLoader.js";import{getMeshTransformForMetersToSpatialReference as ge}from"./support/meshSpatialReferenceScaleUtils.js";import{RangeInfo as _e}from"./support/RangeInfo.js";import ve from"./support/SceneFilter.js";import{cacheIsOutOfSync as K}from"./support/sceneLayerCacheUtils.js";import{fetchStatistics as ye}from"./support/sceneLayerStatistics.js";import{SceneServiceTimeInfo as be}from"./support/SceneServiceTimeInfo.js";import xe from"./support/TimeInfo.js";import{loadStyleRenderer as Se}from"../renderers/support/styleUtils.js";import{webSceneRendererTypes as Ce}from"../renderers/support/typeUtils.js";import we from"../rest/support/Query.js";import{logInvalidElevationInfoWarning as q,elevationModeUnsupportedMessage as Te,featureExpressionUnsupportedMessage as Ee}from"../support/elevationInfoUtils.js";import{createPopupTemplate as De}from"../support/popupUtils.js";import{extractZipFiles as Oe}from"../support/zipUtils.js";import J from"../time/TimeExtent.js";import ke from"../time/TimeInterval.js";import{queryAttributesFromCachedAttributesId as Ae}from"../views/3d/layers/i3s/I3SUtil.js";import{getRequiredFields as je,getFetchPopupTemplate as Me}from"../views/layers/support/popupUtils.js";import{transparencyToOpacity as Ne}from"../webdoc/support/opacityUtils.js";import{reader as Y}from"../core/accessorSupport/decorators/reader.js";const X=new Set([`3DObject`,`Point`]),Z=L();let Q=class extends ne(oe(w(re(ie(ae(l(te(C(r(x)))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType=`ArcGISSceneServiceLayer`,this.type=`scene`,this.fields=null,this.graphicOrigin=new b(this),this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new i,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.attributeTableTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0,this.serviceItemId=void 0,this.serviceTimeInfo=null}normalizeCtorArgs(e,t){return typeof e==`string`?{url:e,...t}:e}destroy(){this._set(`renderer`,null),this.associatedLayer=c(this.associatedLayer)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){let n=this.getField(e)?.domain??null;return this.associatedLayer?N(this.associatedLayer,e,t,n):n}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new R(this.fields)}readNodePages(e,t,n){return t.layerType===`Point`&&(e=t.pointNodePages),typeof e!=`object`||!e?null:H.fromJSON(e,n)}set elevationInfo(e){this._set(`elevationInfo`,e),this.loaded&&this._validateElevationInfo()}get effectiveCapabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.effectiveCapabilities)}get effectiveEditingEnabled(){return this.associatedLayer!=null&&P(this.associatedLayer)}get geometryType(){return Pe[this.profile]||`mesh`}set renderer(e){z(e,this.fieldsIndex),this._set(`renderer`,e)}readCachedDrawingInfo(e){return(typeof e!=`object`||!e)&&(e={}),e.color??(e.color=!1),e}get capabilities(){return this._capabilitiesFromAssociatedFeatureLayer(this.associatedLayer?.capabilities)}_capabilitiesFromAssociatedFeatureLayer(e){e??=le;let{query:t,queryRelated:n,editing:{supportsGlobalId:r,supportsRollbackOnFailure:i,supportsUploadWithItemId:a,supportsGeometryUpdate:o,supportsReturnServiceEditsInSourceSpatialReference:s},data:{supportsZ:c,supportsM:l,isVersioned:u,supportsAttachment:d},operations:{supportsEditing:f,supportsAdd:p,supportsUpdate:m,supportsDelete:h,supportsQuery:g,supportsQueryAttachments:_,supportsAsyncConvert3D:v},attachment:y}=e,b=e.operations.supportsChangeTracking,x=!!this.associatedLayer?.infoFor3D;return{query:t,queryRelated:n,editing:{supportsGlobalId:r,supportsReturnServiceEditsInSourceSpatialReference:s,supportsRollbackOnFailure:i,supportsGeometryUpdate:x&&o,supportsUploadWithItemId:a},data:{supportsAttachment:d,supportsZ:c,supportsM:l,isVersioned:u,queryFormats:e.data.queryFormats,sourceFormats:e.data.sourceFormats},operations:{supportsQuery:g,supportsQueryAttachments:_,supportsEditing:f&&b,supportsAdd:x&&p&&b,supportsDelete:x&&h&&b,supportsUpdate:m&&b,supportsAsyncConvert3D:v},attachment:y}}get editingEnabled(){return this._isOverridden(`editingEnabled`)?this._get(`editingEnabled`):this.associatedLayer?.editingEnabled??!1}set editingEnabled(e){this._overrideIfSome(`editingEnabled`,e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get relationships(){return this.associatedLayer?.relationships}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some(t=>(t.type===`esriFieldTypeOID`&&(e=t.name),!!e)),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some(t=>(t.type===`esriFieldTypeGlobalID`&&(e=t.name),!!e)),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){let n=t.store.profile;return n!=null&&$[n]?$[n]:(s.getLogger(this).error(`Unknown or missing profile`,{profile:n,layer:this}),`mesh-pyramids`)}get useViewTime(){return this.associatedLayer?.useViewTime??!0}set useViewTime(e){this._override(`useViewTime`,e)}get timeInfo(){let e=this.associatedLayer?.timeInfo;if(e==null)return null;let t=e.clone();return B(t,this.fieldsIndex),t}set timeInfo(e){B(e,this.fieldsIndex),this._override(`timeInfo`,e)}get timeExtent(){return this.associatedLayer?.timeExtent}set timeExtent(e){this._override(`timeExtent`,e)}get timeOffset(){return this.associatedLayer?.timeOffset}set timeOffset(e){this._override(`timeOffset`,e)}get datesInUnknownTimezone(){return this.associatedLayer?.datesInUnknownTimezone??!1}set datesInUnknownTimezone(e){this._override(`datesInUnknownTimezone`,e)}load(e){return this.addResolvingPromise(this._load(e)),Promise.resolve(this)}async _load(e){let t=e?.signal;await this.loadFromPortal({supportedTypes:[`Scene Service`]},e).catch(u),await this._fetchService(t),await Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]),this._validateElevationInfo(),this._applyAssociatedLayerOverrides(),this._populateFieldUsageInfo(),await this.loadTimeInfoFromService(e),await Se(this,{origin:`service`},t),z(this.renderer,this.fieldsIndex),await this.finishLoadEditablePortalLayer(e)}async beforeSave(){this.filter!=null&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){s.getLogger(this).error(`#_loadFilterGeometries()`,this,`Failed to load filter geometries. Geometry filter will not be applied for this layer.`,{error:e}),this.filter=null}}createQuery(){let e=new we;this.geometryType===`mesh`?this.capabilities.query.supportsReturnMesh&&(e.returnGeometry=!0):(e.returnGeometry=!0,e.returnZ=!0);let{timeOffset:t,timeExtent:n}=this;return e.timeExtent=t!=null&&n!=null?n.offset(-t.value,t.unit):n||null,e.where=this.definitionExpression||`1=1`,e.sqlFormat=`standard`,e.outFields=[`*`],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryExtent(e||this.createQuery(),t))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryFeatureCount(e||this.createQuery(),t))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryFeatures(e||this.createQuery(),t)).then(e=>{if(e?.features)for(let t of e.features)t.layer=this,t.sourceLayer=this,t.origin=this.graphicOrigin;return e})}async queryModels(e,t){let[n,{queryModels:r}]=await Promise.all([this._getAssociatedLayerForQuery(),import(`./scene/modelQuerySupport.js`)]);return r(this,n,e,t)}async queryModel(e,t){let[n,{queryModel:r}]=await Promise.all([this._getAssociatedLayerForQuery(),import(`./scene/modelQuerySupport.js`)]);return r(this,n,e,t)}async queryRelatedFeatures(e,t){if(await this.load(),!this.associatedLayer)throw new a(`scenelayer:query-not-available`,`SceneLayer queries are not available without an associated feature layer`,{layer:this});return this.associatedLayer.queryRelatedFeatures(e,t)}async queryRelatedFeaturesCount(e,t){if(await this.load(),!this.associatedLayer)throw new a(`scenelayer:query-not-available`,`SceneLayer queries are not available without an associated feature layer`,{layer:this});return this.associatedLayer.queryRelatedFeaturesCount(e,t)}async queryCachedAttributes(e,t){let n=V(this.fieldsIndex,await je(this,Me(this)));return Ae(this.parsedUrl?.path??``,this.attributeStorageInfo??[],e,t,n,this.apiKey,this.customParameters)}async queryCachedFeature(e,n){let r=await this.queryCachedAttributes(e,[n]);if(!r||r.length===0)throw new a(`scenelayer:feature-not-in-cached-data`,`Feature not found in cached data`);let i=new t;return i.attributes=r[0],i.layer=this,i.sourceLayer=this,i.origin=this.graphicOrigin,i}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryObjectIds(e||this.createQuery(),t))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then(n=>n.queryAttachments(e,t))}getFieldUsageInfo(e){let t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(s.getLogger(this).error(`#getFieldUsageInfo()`,`Unavailable until layer is loaded`),t)}createPopupTemplate(e){return De(this,e)}_getAssociatedLayerForQuery(){let e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new a(`scenelayer:query-not-available`,`SceneLayer queries are not available without an associated feature layer`,{layer:this});try{await this.associatedLayer.load()}catch(e){throw new a(`scenelayer:query-not-available`,`SceneLayer associated feature layer could not be loaded`,{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return this.statisticsInfo!=null&&this.statisticsInfo.some(t=>t.name===e)}async queryCachedStatistics(e,t){return await this.load(t),await this.fetchStatistics(e,t)}async saveAs(e,t){return this._debouncedSaveOperations(1,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:`scene`},e)}async save(){return this._debouncedSaveOperations(0,{getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:`scene`})}async applyEdits(e,t){let{applyEdits:n}=await import(`./graphics/editingSupport.js`),r=t;await this.load();let i=this.associatedLayer;if(!i)throw new a(`${this.type}-layer:not-editable`,`Service is not editable`);await i.load();let{globalIdField:o}=i,s=!!i.infoFor3D,c=r?.globalIdUsed??!0;if(s&&o==null)throw new a(`${this.type}-layer:not-editable`,`Valid globalIdField expected on editable SceneLayer`);if(s&&!c)throw new a(`${this.type}-layer:globalid-required`,`globalIdUsed must not be false for SceneLayer editing as globalIds are required.`);return T(i.url)&&s&&e.deleteFeatures!=null&&o!=null&&(r={...r,globalIdToObjectId:await F(i,e.deleteFeatures,o)}),n(this,i.source,e,r)}async uploadAssets(e,t){if(await this.load(),this.associatedLayer==null)throw new a(`${this.type}-layer:not-editable`,`Service is not editable`);return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}async convertMesh(e,t){t??={};let n=e=>{throw s.getLogger(this).error(`.convertMesh()`,e.message),e};await this.load(t),this.infoFor3D||n(new a(`invalid:layer`,`SceneLayer has no capability for mesh conversion`));let r=await this.extractAndFilterFiles(e);d(t);let i=r.reduce((e,t)=>de(this.infoFor3D,t)?e+1:e,0);i===0&&n(new ee),i>1&&n(new S);let o=this.spatialReference,c=t.origin,l=await y(c??t.defaultOrigin??new v({x:0,y:0,z:0,spatialReference:o}),o,t),u=o.isGeographic?`local`:`georeferenced`,{createWithExternalSource:f}=await import(`../geometry/support/meshUtils.js`);d(t);let p=f(l,{type:`client`,files:r},{vertexSpace:u,transform:ge(o),unitConversionDisabled:!0}),[m]=await this.uploadAssets([p],{...t,useAssetOrigin:!c});return m}async extractAndFilterFiles(e){await this.load();let t=this.infoFor3D;return t?(await Oe(e)).filter(e=>fe(t,e)):e}validateLayer(e){if(e.layerType&&!X.has(e.layerType))throw new a(`scenelayer:layer-type-not-supported`,`SceneLayer does not support this layer type`,{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new a(`layer:service-version-not-supported`,`Service version is not supported.`,{serviceVersion:this.version.versionString,supportedVersions:`1.x, 2.x`});if(this.version.major>2)throw new a(`layer:service-version-too-new`,`Service version is too new.`,{serviceVersion:this.version.versionString,supportedVersions:`1.x, 2.x`});t(this.normalReferenceFrame,this.spatialReference);function t(e,t){let n=!1,r=!1;if(e==null)n=!0,r=!0;else{let i=t&&t.isGeographic;switch(e){case`east-north-up`:case`earth-centered`:n=!0,r=i;break;case`vertex-reference-frame`:n=!0,r=!i;break;default:n=!1}}if(!n)throw new a(`scenelayer:unsupported-normal-reference-frame`,`Normal reference frame is invalid.`);if(!r)throw new a(`scenelayer:incompatible-normal-reference-frame`,`Normal reference frame is incompatible with layer spatial reference.`)}}get isUsedAsGroundLayer(){return!1}_getTypeKeywords(){let e=[];if(this.profile===`points`)e.push(`Point`);else if(this.profile===`mesh-pyramids`)e.push(`3DObject`);else throw new a(`scenelayer:unknown-profile`,`SceneLayer:save() encountered an unknown SceneLayer profile: `+this.profile);return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(let e of this.fields){let t=!!this.attributeStorageInfo?.some(t=>t.name===e.name),n=!!this.associatedLayer?.fields?.some(t=>t&&e.name===t.name),r={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||n,supportsLayerQuery:n};this._fieldUsageInfo[e.name]=r}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPropertyOverrides(),this._applyAssociatedLayerExtentOverride(),this._applyAssociatedLayerPrivileges()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(let t of this.associatedLayer.fields){let n=this.getField(t.name);n?(!n.domain&&t.domain&&(n.domain=t.domain.clone()),n.editable=t.editable,n.nullable=t.nullable,n.length=t.length):(e||=this.fields?this.fields.slice():[],e.push(t.clone()))}e&&this._set(`fields`,e)}_applyAssociatedLayerPropertyOverrides(){if(!this.associatedLayer)return;let e=[`popupTemplate`,`popupEnabled`,`attributeTableTemplate`],t=_(this);for(let n=0;n<e.length;n++){let r=e[n],i=this.originIdOf(r),a=this.associatedLayer.originIdOf(r);i<a&&(a===2||a===3)&&t.setAtOrigin(r,this.associatedLayer[r],a)}}_applyAssociatedLayerExtentOverride(){let e=this.associatedLayer?.getAtOrigin(`fullExtent`,`service`);this.associatedLayer?.infoFor3D!=null&&e&&T(this.associatedLayer?.url)&&K(this)&&_(this).setAtOrigin(`fullExtent`,e.clone(),2)}_applyAssociatedLayerPrivileges(){let e=this.associatedLayer;e&&(this._set(`userHasEditingPrivileges`,e.userHasEditingPrivileges),this._set(`userHasFullEditingPrivileges`,e.userHasFullEditingPrivileges),this._set(`userHasUpdateItemPrivileges`,e.userHasUpdateItemPrivileges))}async _setAssociatedFeatureLayer(e){if([`mesh-pyramids`,`points`].includes(this.profile))try{let{serverUrl:t,layerId:n,portalItem:r}=await ce(`${this.url}/layers/${this.layerId}`,{sceneLayerItem:this.portalItem,customParameters:this.customParameters,apiKey:this.apiKey,signal:e}),i=await he.FeatureLayer();this.associatedLayer=new i({url:t,customParameters:this.customParameters,apiKey:this.apiKey,layerId:n,portalItem:r}),await this.associatedLayer.load()}catch(e){f(e)||this._logWarningOnPopupEnabled().catch(()=>{})}}async _logWarningOnPopupEnabled(){let e=new AbortController;this.addHandles(o(e));try{await m(()=>this.popupEnabled&&this.popupTemplate!=null,e.signal)}catch(e){p(e);return}let t=`this SceneLayer: ${this.title}`;this.attributeStorageInfo==null?s.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${t}`):s.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${t}`)}_validateElevationInfo(){let e=this.elevationInfo;this.profile===`mesh-pyramids`&&q(s.getLogger(this),Te(`Mesh scene layers`,`relative-to-scene`,e)),q(s.getLogger(this),Ee(`Scene layers`,e))}async fetchStatistics(e,t){return await ye({fieldName:e,statisticsInfo:this.statisticsInfo,errorContext:`scenelayer`,fieldsIndex:this.fieldsIndex,path:this.parsedUrl?.path??``,customParameters:this.customParameters,apiKey:this.apiKey,signal:t?.signal})}async loadTimeInfoFromService(e){let{serviceTimeInfo:t}=this;if(t==null)return;let{startTimeField:n,endTimeField:r}=t;if(n==null&&r==null||K({associatedLayer:this.associatedLayer,serviceUpdateTimeStamp:this.serviceUpdateTimeStamp}))return;let i=async t=>{let r=null;try{r=(await this.fetchStatistics(t,e))?.stats}catch{}if(r==null)return null;let{minTimeStr:i,min:a,maxTimeStr:o,max:s}=r,c=t===n?i??a:o??s;return c==null?null:new Date(c)},[a,o]=await Promise.all([i(n),i(r)]);if(n!=null&&a==null||r!=null&&o==null)return;let s=new J({start:a,end:o});this.setAtOrigin(`timeInfo`,new xe({endField:r,startField:n,fullTimeExtent:s}),`service`)}};e([h({types:{key:`type`,base:null,typeMap:{selection:I}},json:{origins:{"web-scene":{name:`layerDefinition.featureReduction`,write:{allowNull:!0}},"portal-item":{name:`layerDefinition.featureReduction`,write:{allowNull:!0}}}}})],Q.prototype,`featureReduction`,void 0),e([h({type:[_e],json:{read:!1,origins:{"web-scene":{name:`layerDefinition.rangeInfos`,write:!0},"portal-item":{name:`layerDefinition.rangeInfos`,write:!0}}},clonable:!1})],Q.prototype,`rangeInfos`,void 0),e([h({json:{read:!1}})],Q.prototype,`associatedLayer`,void 0),e([h({type:[`show`,`hide`]})],Q.prototype,`listMode`,void 0),e([h({type:[`ArcGISSceneServiceLayer`]})],Q.prototype,`operationalLayerType`,void 0),e([h({json:{read:!1},readOnly:!0})],Q.prototype,`type`,void 0),e([h({...Z.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`fields`,void 0),e([h()],Q.prototype,`types`,null),e([h()],Q.prototype,`typeIdField`,null),e([h()],Q.prototype,`templates`,null),e([h()],Q.prototype,`formTemplate`,null),e([h({readOnly:!0})],Q.prototype,`graphicOrigin`,void 0),e([h({readOnly:!0,clonable:!1})],Q.prototype,`fieldsIndex`,null),e([h({type:me,json:{read:{source:`layerDefinition.floorInfo`},write:{target:`layerDefinition.floorInfo`}}})],Q.prototype,`floorInfo`,void 0),e([h(Z.outFields)],Q.prototype,`outFields`,void 0),e([h({type:H,readOnly:!0,json:{read:!1},clonable:!1})],Q.prototype,`nodePages`,void 0),e([Y(`service`,`nodePages`,[`nodePages`,`pointNodePages`])],Q.prototype,`readNodePages`,null),e([h({type:[U],readOnly:!0,clonable:!1})],Q.prototype,`materialDefinitions`,void 0),e([h({type:[W],readOnly:!0,clonable:!1})],Q.prototype,`textureSetDefinitions`,void 0),e([h({type:[ue],readOnly:!0,clonable:!1})],Q.prototype,`geometryDefinitions`,void 0),e([h({readOnly:!0})],Q.prototype,`serviceUpdateTimeStamp`,void 0),e([h({readOnly:!0})],Q.prototype,`attributeStorageInfo`,void 0),e([h({readOnly:!0})],Q.prototype,`statisticsInfo`,void 0),e([h({type:i.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:`layerDefinition.excludeObjectIds`,write:{enabled:!0}}})],Q.prototype,`excludeObjectIds`,void 0),e([h({type:String,json:{origins:{service:{read:!1,write:!1}},name:`layerDefinition.definitionExpression`,write:{enabled:!0,allowNull:!0}}})],Q.prototype,`definitionExpression`,void 0),e([h({type:ve,json:{name:`layerDefinition.polygonFilter`,write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],Q.prototype,`filter`,void 0),e([h({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Q.prototype,`path`,void 0),e([h(E)],Q.prototype,`elevationInfo`,null),e([h({readOnly:!0,json:{read:!1}})],Q.prototype,`effectiveCapabilities`,null),e([h({readOnly:!0})],Q.prototype,`effectiveEditingEnabled`,null),e([h({type:String})],Q.prototype,`geometryType`,null),e([h(D)],Q.prototype,`labelsVisible`,void 0),e([h({type:[pe],json:{origins:{service:{name:`drawingInfo.labelingInfo`,read:{reader:G},write:!1}},name:`layerDefinition.drawingInfo.labelingInfo`,read:{reader:G},write:!0}})],Q.prototype,`labelingInfo`,void 0),e([h(O)],Q.prototype,`legendEnabled`,void 0),e([h({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:[`opacity`,`layerDefinition.drawingInfo.transparency`],reader(e,t){if(typeof e==`number`&&e>=0&&e<=1)return e;let n=t.layerDefinition?.drawingInfo?.transparency;return n===void 0?void 0:Ne(n)}}},"portal-item":{write:!0},service:{read:!1}}}})],Q.prototype,`opacity`,void 0),e([h({type:[`Low`,`High`],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`priority`,void 0),e([h({type:[`Labels`],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`semantic`,void 0),e([h({types:Ce,json:{origins:{service:{read:{source:`drawingInfo.renderer`}}},name:`layerDefinition.drawingInfo.renderer`,write:!0},value:null})],Q.prototype,`renderer`,null),e([h({json:{read:!1}})],Q.prototype,`cachedDrawingInfo`,void 0),e([Y(`service`,`cachedDrawingInfo`)],Q.prototype,`readCachedDrawingInfo`,null),e([h({readOnly:!0,json:{read:!1}})],Q.prototype,`capabilities`,null),e([h({type:Boolean,json:{read:!1}})],Q.prototype,`editingEnabled`,null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Q.prototype,`infoFor3D`,null),e([h({readOnly:!0,json:{write:!1,read:!1}})],Q.prototype,`relationships`,null),e([h(k)],Q.prototype,`popupEnabled`,void 0),e([h({type:n,json:{name:`popupInfo`,write:!0}})],Q.prototype,`popupTemplate`,void 0),e([h({readOnly:!0,json:{read:!1}})],Q.prototype,`defaultPopupTemplate`,null),e([h(A)],Q.prototype,`attributeTableTemplate`,void 0),e([h({type:String,json:{read:!1}})],Q.prototype,`objectIdField`,void 0),e([Y(`service`,`objectIdField`,[`objectIdField`,`fields`])],Q.prototype,`readObjectIdField`,null),e([h({type:String,json:{read:!1}})],Q.prototype,`globalIdField`,void 0),e([Y(`service`,`globalIdField`,[`globalIdField`,`fields`])],Q.prototype,`readGlobalIdField`,null),e([h({readOnly:!0,type:String,json:{read:!1}})],Q.prototype,`displayField`,null),e([h({type:String,json:{read:!1}})],Q.prototype,`profile`,void 0),e([Y(`service`,`profile`,[`store.profile`])],Q.prototype,`readProfile`,null),e([h({readOnly:!0,type:String,json:{origins:{service:{read:{source:`store.normalReferenceFrame`}}},read:!1}})],Q.prototype,`normalReferenceFrame`,void 0),e([h(j)],Q.prototype,`screenSizePerspectiveEnabled`,void 0),e([h({json:{read:!1,origins:{service:{read:!0}}}})],Q.prototype,`serviceItemId`,void 0),e([h(se)],Q.prototype,`useViewTime`,null),e([h(M({disableServiceOrigin:!0,webDocumentOrigin:`web-scene`}))],Q.prototype,`timeInfo`,null),e([h({type:J,json:{read:!1,write:!1}})],Q.prototype,`timeExtent`,null),e([h({type:ke,json:{read:!1,write:!1}})],Q.prototype,`timeOffset`,null),e([h({type:Boolean,nonNullable:!0,json:{read:!1,write:!1}})],Q.prototype,`datesInUnknownTimezone`,null),e([h({type:be,readOnly:!0,json:{read:{source:`timeInfo`}},clonable:!1})],Q.prototype,`serviceTimeInfo`,void 0),e([h()],Q.prototype,`isUsedAsGroundLayer`,null),Q=e([g(`esri.layers.SceneLayer`)],Q);const $={"mesh-pyramids":`mesh-pyramids`,meshpyramids:`mesh-pyramids`,"features-meshes":`mesh-pyramids`,points:`points`,"features-points":`points`,lines:`lines`,"features-lines":`lines`,polygons:`polygons`,"features-polygons":`polygons`},Pe={"mesh-pyramids":`mesh`,points:`point`},Fe=Q;export{Fe as default};
@@ -37,8 +37,9 @@ export interface SketchLayerProperties extends LayerProperties, PortalLayerPrope
37
37
 
38
38
  /**
39
39
  * The SketchLayer lets you display and modify sketches (features sketched on a web map) from the
40
- * [Map Viewer](https://www.arcgis.com/apps/mapviewer/index.html). A new SketchLayer can also be created
41
- * using the [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/).
40
+ * [Map Viewer](https://www.arcgis.com/apps/mapviewer/index.html). A new SketchLayer can also be used with the
41
+ * [Sketch component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-sketch/)
42
+ * or the [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/).
42
43
  *
43
44
  * Sketches belong to the [graphics](https://developers.arcgis.com/javascript/latest/references/core/layers/SketchLayer/#graphics) collection. Each graphic can have its own
44
45
  * popup template, geometry, and symbol.
@@ -104,6 +105,7 @@ export interface SketchLayerProperties extends LayerProperties, PortalLayerPrope
104
105
  * ```
105
106
  *
106
107
  * @since 5.2
108
+ * @beta
107
109
  * @see [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/)
108
110
  * @see [WebMap](https://developers.arcgis.com/javascript/latest/references/core/WebMap/)
109
111
  * @see [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/)
@@ -395,7 +395,7 @@ export default class SubtypeGroupLayer extends SubtypeGroupLayerSuperclass {
395
395
  */
396
396
  applyEdits(edits: Edits, options?: EditOptions): Promise<EditsResult>;
397
397
  /**
398
- * Creates query parameter object that can be used to fetch features from feature-based layers or
398
+ * Creates a query parameter object that can be used to fetch features from feature-based layers or
399
399
  * image footprints from ImageryLayer that satisfy the layer's configurations such as [definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/#definitionExpression).
400
400
  * It will return `Z` and `M` values based on the layer's [data capabilities](https://developers.arcgis.com/javascript/latest/references/core/layers/SubtypeGroupLayer/#capabilities).
401
401
  * It sets the query parameter's [Query.outFields](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outFields) property to `["*"]`.
@@ -621,7 +621,7 @@ export default class WFSLayer extends WFSLayerSuperclass {
621
621
  */
622
622
  createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined;
623
623
  /**
624
- * Creates query parameter object that can be used to fetch features from feature-based layers or
624
+ * Creates a query parameter object that can be used to fetch features from feature-based layers or
625
625
  * image footprints from ImageryLayer that satisfy the layer's configurations such as [definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/#definitionExpression).
626
626
  * It will return `Z` and `M` values based on the layer's [data capabilities](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/#capabilities).
627
627
  * It sets the query parameter's [Query.outFields](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outFields) property to `["*"]`.
@@ -215,7 +215,7 @@ export default class BuildingComponentSublayer extends BuildingComponentSublayer
215
215
  * satisfy the component sublayer's current [definition expression](https://developers.arcgis.com/javascript/latest/references/core/layers/buildingSublayers/BuildingComponentSublayer/#definitionExpression).
216
216
  * The query should only be used on the layer and not on the layer view.
217
217
  *
218
- * @returns The query object representing the layer's
218
+ * @returns The query parameter object representing the layer's
219
219
  * definition expression.
220
220
  * @since 4.17
221
221
  */
@@ -648,7 +648,7 @@ export default class CatalogFootprintLayer extends CatalogFootprintLayerSupercla
648
648
  */
649
649
  createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined;
650
650
  /**
651
- * Creates query parameter object that can be used to fetch features from feature-based layers or
651
+ * Creates a query parameter object that can be used to fetch features from feature-based layers or
652
652
  * image footprints from ImageryLayer that satisfy the layer's configurations such as [definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/catalog/CatalogFootprintLayer/#definitionExpression).
653
653
  * It will return `Z` and `M` values based on the layer's [data capabilities](https://developers.arcgis.com/javascript/latest/references/core/layers/catalog/CatalogFootprintLayer/#capabilities).
654
654
  * It sets the query parameter's [Query.outFields](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outFields) property to `["*"]`.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../core/Error.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import n from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";import{projectExecute as i}from"../../geometry/operators/projectOperator.js";import{expandMediaBox as a,validateTransform as o,affineTransformationFromGeoreference as s,createGeoreferencer as c}from"./sharedUtils.js";class l{constructor(e){let{bbox:t,bounds:n,gpts:r,lpts:i,gcs:c,mediaBox:l}=this.inputValidation(e);this._bbox=t,this._bounds=n,this._gpts=r,this._lpts=i,this._gcs=c,this.outerExtentMediaBox=a(l),this.geoControlPoints=this._getProjectedGeoControlPoints().map(e=>[e[0],e[1]]);let u=this._getBoundsPolygonPage()??this._getPageControlPoints();this.pairedNeatline=u.map(e=>[e[0],e[1]]),this.neatLine=this.pairedNeatline.flat(),this._georeference=this._createControlPointsGeoreference();let d=o(this._georeference);this.ctm=s(d),this.outputValidation()}toSpatialReference(){return new r({wkt:this._gcs.WKT})}inputValidation(t){let{bbox:n,bounds:r,gpts:i,lpts:a,gcs:o,mediaBox:s}=t;if(!n||n.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Viewport missing or invalid BBox.`);if(!s||s.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Viewport missing or invalid MediaBox.`);if(!i||i.length<6||i.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid GPTS.`);if(!a||a.length<6||a.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid LPTS.`);if(a.length!==i.length)throw new e(`geospatial-pdf-layer: invalid-frame`,`MeasureFrame LPTS and GPTS must be same length`);if(!o?.WKT)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid WKT.`);return{bbox:n,bounds:r,gpts:i,lpts:a,gcs:{WKT:o.WKT},mediaBox:s}}outputValidation(){if(this.outerExtentMediaBox.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Failed to generate outer extent from mediaBox.`);if(this.geoControlPoints.length<2)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 2 geoControlPoints.`);if(this.pairedNeatline.length<4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 4 neatline points.`);if(!this.ctm||this.ctm.length!==6)throw new e(`geospatial-pdf-layer:invalid-frame`,`Missing or invalid Map Frame CTM`)}_createControlPointsGeoreference(){let e=this._getPageControlPoints(),t=this._getProjectedGeoControlPoints(),n=this._getViewportRect();return c(e,t,this.toSpatialReference(),n)}_getBoundsPolygonLocal(){if(!this._bounds||this._bounds.length<8||this._bounds.length%2!=0)return null;let e=[];for(let t=0;t<this._bounds.length;t+=2)e.push({u:this._bounds[t],v:this._bounds[t+1]});return e}_getBoundsPolygonPage(){return this._getBoundsPolygonLocal()?.map(e=>this._localToPage(e.u,e.v))??null}_getPageControlPoints(){let e=[];for(let t=0;t<this._lpts.length;t+=2){let n=this._lpts[t],r=this._lpts[t+1];e.push(this._localToPage(n,r))}return e}_getProjectedGeoControlPoints(){let e=this.toSpatialReference(),r=[];for(let a=0;a<this._gpts.length;a+=2){let o=this._gpts[a],s=this._gpts[a+1],c=new n({x:s,y:o}),l=i(c,e);r.push(t(l.x,l.y))}return r}_getViewportRect(){let[e,t,n,r]=this._bbox;return{xmin:Math.min(e,n),ymin:Math.min(t,r),xmax:Math.max(e,n),ymax:Math.max(t,r)}}_localToPage(e,n){let[r,i,a,o]=this._bbox;return t(r+e*(a-r),i+n*(o-i))}}export{l as ViewportMeasureFrame};
2
+ import e from"../../core/Error.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import n from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";import{projectExecute as i}from"../../geometry/operators/projectOperator.js";import{expandMediaBox as a,validateTransform as o,affineTransformationFromGeoreference as s,createGeoreferencer as c}from"./sharedUtils.js";class l{constructor(e){let{bbox:t,bounds:n,gpts:r,lpts:i,gcs:c,mediaBox:l}=this.inputValidation(e);this._bbox=t,this._bounds=n,this._gpts=r,this._lpts=i,this._gcs=c,this.outerExtentMediaBox=a(l),this.geoControlPoints=this._getProjectedGeoControlPoints().map(e=>[e[0],e[1]]);let u=this._getBoundsPolygonPage()??this._getPageControlPoints();this.pairedNeatline=u.map(e=>[e[0],e[1]]),this.neatLine=this.pairedNeatline.flat(),this._georeference=this._createControlPointsGeoreference();let d=o(this._georeference);this.ctm=s(d),this.outputValidation()}toSpatialReference(){let t=this._gcs;if(t?.WKT)return new r({wkt:t.WKT});if(t?.EPSG!=null)return new r({wkid:t.EPSG});throw new e(`geospatial-pdf-layer: invalid-frame`,`MeasureFrame missing WKT or EPSG.`)}inputValidation(t){let{bbox:n,bounds:r,gpts:i,lpts:a,gcs:o,mediaBox:s}=t;if(!n||n.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Viewport missing or invalid BBox.`);if(!s||s.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Viewport missing or invalid MediaBox.`);if(!i||i.length<6||i.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid GPTS.`);if(!a||a.length<6||a.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid LPTS.`);if(a.length!==i.length)throw new e(`geospatial-pdf-layer: invalid-frame`,`MeasureFrame LPTS and GPTS must be same length`);if(!o?.WKT&&!o?.EPSG)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing a WKT or EPSG code.`);return{bbox:n,bounds:r,gpts:i,lpts:a,gcs:o,mediaBox:s}}outputValidation(){if(this.outerExtentMediaBox.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Failed to generate outer extent from mediaBox.`);if(this.geoControlPoints.length<2)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 2 geoControlPoints.`);if(this.pairedNeatline.length<4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 4 neatline points.`);if(!this.ctm||this.ctm.length!==6)throw new e(`geospatial-pdf-layer:invalid-frame`,`Missing or invalid Map Frame CTM`)}_createControlPointsGeoreference(){let e=this._getPageControlPoints(),t=this._getProjectedGeoControlPoints(),n=this._getViewportRect();return c(e,t,this.toSpatialReference(),n)}_getBoundsPolygonLocal(){if(!this._bounds||this._bounds.length<8||this._bounds.length%2!=0)return null;let e=[];for(let t=0;t<this._bounds.length;t+=2)e.push({u:this._bounds[t],v:this._bounds[t+1]});return e}_getBoundsPolygonPage(){return this._getBoundsPolygonLocal()?.map(e=>this._localToPage(e.u,e.v))??null}_getPageControlPoints(){let e=[];for(let t=0;t<this._lpts.length;t+=2){let n=this._lpts[t],r=this._lpts[t+1];e.push(this._localToPage(n,r))}return e}_getProjectedGeoControlPoints(){let e=this.toSpatialReference(),r=[];for(let a=0;a<this._gpts.length;a+=2){let o=this._gpts[a],s=this._gpts[a+1],c=new n({x:s,y:o}),l=i(c,e);r.push(t(l.x,l.y))}return r}_getViewportRect(){let[e,t,n,r]=this._bbox;return{xmin:Math.min(e,n),ymin:Math.min(t,r),xmax:Math.max(e,n),ymax:Math.max(t,r)}}_localToPage(e,n){let[r,i,a,o]=this._bbox;return t(r+e*(a-r),i+n*(o-i))}}export{l as ViewportMeasureFrame};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../core/Error.js";import"../../core/has.js";import{LGIDictMapFrame as t}from"./LGIDictMapFrame.js";import{projectionToSpatialReference as n}from"./projectionToWKTUtils.js";import{ViewportMeasureFrame as r}from"./ViewportMeasureFrame.js";function i(i,s=0){let c={mediaBox:_(i.MediaBox),rotate:x(i.Rotate),hasLGIDict:i.LGIDict!=null,hasVP:i.VP!=null},l=a(i.LGIDict,s);if(l){if(!l.Projection)throw new e(`geospatial-pdf-layer:parse`,`LGIDict map frame missing Projection.`);let r=n(l.Projection),a;try{a=l.Display?n(l.Display):void 0}catch{a=r}return{result:c,lgiDictFrame:new t({ctm:l.CTM,registration:l.Registration,projection:r,display:a,neatline:l.Neatline,mediaBox:_(i.MediaBox)})}}let u=o(i.VP,s);return u?{result:c,vpFrame:new r({bbox:u.BBox,bounds:u.Measure?.Bounds,gpts:u.Measure?.GPTS,lpts:u.Measure?.LPTS,gcs:u.Measure?.GCS,mediaBox:_(i.MediaBox)})}:{result:c}}function a(e,t){return s(e)[t]}function o(e,t){return c(e)[t]}function s(e){return e==null?[]:Array.isArray(e)?e.map(e=>l(e)):[l(e)]}function c(e){return e==null?[]:Array.isArray(e)?e.map(e=>u(e)):[u(e)]}function l(e){let t=C(e,`LGIDict map frame must be an object.`);return{CTM:_(t.CTM),Registration:v(t.Registration),Neatline:_(t.Neatline),Projection:p(t.Projection),Display:p(t.Display)}}function u(e){let t=C(e,`Viewport frame must be an object.`),n=d(t.Measure);return{BBox:_(t.BBox),Measure_Raw:t.Measure,Measure:n,Raw:t}}function d(e){if(S(e))return{Bounds:_(e.Bounds),GPTS:_(e.GPTS),LPTS:_(e.LPTS),GCS:f(e.GCS)}}function f(e){if(S(e))return{WKT:y(e.WKT)}}function p(e){if(S(e))return{Type:b(e.Type),Units:b(e.Units),Datum:m(e.Datum),Projection_Type:b(e.ProjectionType),Central_Meridian:x(e.CentralMeridian),False_Easting:x(e.FalseEasting),False_Northing:x(e.FalseNorthing),Height:x(e.Height),Hemisphere:b(e.Hemisphere),Latitude_One:x(e.LatitudeOne),Latitude_Two:x(e.LatitudeTwo),Latitude_Of_True_Scale:x(e.LatitudeOfTrueScale),Longitude_One:x(e.LongitudeOne),Longitude_Two:x(e.LongitudeTwo),Longitude_Down_From_Pole:x(e.LongitudeDownFromPole),Orientation:b(e.Orientation),Origin_Height:x(e.OriginHeight),Origin_Latitude:x(e.OriginLatitude),Origin_Longitude:x(e.OriginLongitude),Scale_Factor:x(e.ScaleFactor),Standard_Parallel:x(e.StandardParallel),Standard_Parallel_One:x(e.StandardParallelOne),Standard_Parallel_Two:x(e.StandardParallelTwo),Zone:x(e.Zone),Description:b(e.Description),raw:e}}function m(e){return e==null?null:typeof e==`string`?{kind:`name`,name:b(e),ellipsoid:null,to_WGS84:null,raw:e}:S(e)?{kind:`definition`,name:b(e.Description),ellipsoid:h(e.Ellipsoid),to_WGS84:g(e.ToWGS84),raw:e}:{kind:`unknown`,name:b(e),ellipsoid:null,to_WGS84:null,raw:e}}function h(e){if(S(e))return{semi_Major_Axis:x(e.SemiMajorAxis),inverse_Flattening:x(e.InvFlattening),semi_Minor_Axis:x(e.SemiMinorAxis),description:b(e.Description)}}function g(e){if(S(e))return{dx:x(e.dx)??0,dy:x(e.dy)??0,dz:x(e.dz)??0,rx:x(e.rx)??0,ry:x(e.ry)??0,rz:x(e.rz)??0,sf:x(e.sf)??0}}function _(e){if(!Array.isArray(e))return;let t=[];for(let n of e){let e=x(n);if(e===void 0)return;t.push(e)}return t}function v(e){if(Array.isArray(e))return e.filter(e=>Array.isArray(e)).map(e=>e.map(e=>x(e)).filter(e=>e!==void 0))}function y(e){if(e!=null)return typeof e==`string`?e:String(e)}function b(e){let t=y(e);if(t!==void 0)return t.trim()}function x(e){if(e==null)return;if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(t,n){if(!S(t))throw new e(`geospatial-pdf-layer:parse`,n);return t}export{i as parse};
2
+ import e from"../../core/Error.js";import"../../core/has.js";import{LGIDictMapFrame as t}from"./LGIDictMapFrame.js";import{projectionToSpatialReference as n}from"./projectionToWKTUtils.js";import{ViewportMeasureFrame as r}from"./ViewportMeasureFrame.js";function i(i,s=0){let c={mediaBox:_(i.MediaBox),rotate:x(i.Rotate),hasLGIDict:i.LGIDict!=null,hasVP:i.VP!=null};if(c.hasVP){let t=o(i.VP,s);if(!t)throw new e(`geospatial-pdf-layer:invalid frame`,`Failed to parse VP frame at index ${s}`);return{result:c,vpFrame:new r({bbox:t.BBox,bounds:t.Measure?.Bounds,gpts:t.Measure?.GPTS,lpts:t.Measure?.LPTS,gcs:t.Measure?.GCS,mediaBox:_(i.MediaBox)})}}if(c.hasLGIDict){let r=a(i.LGIDict,s);if(!r)throw new e(`geospatial-pdf-layer:invalid frame`,`Failed to parse LGI Dict frame at index ${s}`);if(!r.Projection)throw new e(`geospatial-pdf-layer:parse`,`LGIDict map frame missing Projection.`);let o=n(r.Projection),l;try{l=r.Display?n(r.Display):void 0}catch{l=o}return{result:c,lgiDictFrame:new t({ctm:r.CTM,registration:r.Registration,projection:o,display:l,neatline:r.Neatline,mediaBox:_(i.MediaBox)})}}return{result:c}}function a(e,t){return s(e)[t]}function o(e,t){return c(e)[t]}function s(e){return e==null?[]:Array.isArray(e)?e.map(e=>l(e)):[l(e)]}function c(e){return e==null?[]:Array.isArray(e)?e.map(e=>u(e)):[u(e)]}function l(e){let t=C(e,`LGIDict map frame must be an object.`);return{CTM:_(t.CTM),Registration:v(t.Registration),Neatline:_(t.Neatline),Projection:p(t.Projection),Display:p(t.Display)}}function u(e){let t=C(e,`Viewport frame must be an object.`),n=d(t.Measure);return{BBox:_(t.BBox),Measure_Raw:t.Measure,Measure:n,Raw:t}}function d(e){if(S(e))return{Bounds:_(e.Bounds),GPTS:_(e.GPTS),LPTS:_(e.LPTS),GCS:f(e.GCS)}}function f(e){if(S(e))return{WKT:y(e.WKT),EPSG:x(e.EPSG)}}function p(e){if(S(e))return{Type:b(e.Type),Units:b(e.Units),Datum:m(e.Datum),Projection_Type:b(e.ProjectionType),Central_Meridian:x(e.CentralMeridian),False_Easting:x(e.FalseEasting),False_Northing:x(e.FalseNorthing),Height:x(e.Height),Hemisphere:b(e.Hemisphere),Latitude_One:x(e.LatitudeOne),Latitude_Two:x(e.LatitudeTwo),Latitude_Of_True_Scale:x(e.LatitudeOfTrueScale),Longitude_One:x(e.LongitudeOne),Longitude_Two:x(e.LongitudeTwo),Longitude_Down_From_Pole:x(e.LongitudeDownFromPole),Orientation:b(e.Orientation),Origin_Height:x(e.OriginHeight),Origin_Latitude:x(e.OriginLatitude),Origin_Longitude:x(e.OriginLongitude),Scale_Factor:x(e.ScaleFactor),Standard_Parallel:x(e.StandardParallel),Standard_Parallel_One:x(e.StandardParallelOne),Standard_Parallel_Two:x(e.StandardParallelTwo),Zone:x(e.Zone),Description:b(e.Description),raw:e}}function m(e){return e==null?null:typeof e==`string`?{kind:`name`,name:b(e),ellipsoid:null,to_WGS84:null,raw:e}:S(e)?{kind:`definition`,name:b(e.Description),ellipsoid:h(e.Ellipsoid),to_WGS84:g(e.ToWGS84),raw:e}:{kind:`unknown`,name:b(e),ellipsoid:null,to_WGS84:null,raw:e}}function h(e){if(S(e))return{semi_Major_Axis:x(e.SemiMajorAxis),inverse_Flattening:x(e.InvFlattening),semi_Minor_Axis:x(e.SemiMinorAxis),description:b(e.Description)}}function g(e){if(S(e))return{dx:x(e.dx)??0,dy:x(e.dy)??0,dz:x(e.dz)??0,rx:x(e.rx)??0,ry:x(e.ry)??0,rz:x(e.rz)??0,sf:x(e.sf)??0}}function _(e){if(!Array.isArray(e))return;let t=[];for(let n of e){let e=x(n);if(e===void 0)return;t.push(e)}return t}function v(e){if(Array.isArray(e))return e.filter(e=>Array.isArray(e)).map(e=>e.map(e=>x(e)).filter(e=>e!==void 0))}function y(e){if(e!=null)return typeof e==`string`?e:String(e)}function b(e){let t=y(e);if(t!==void 0)return t.trim()}function x(e){if(e==null)return;if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(t,n){if(!S(t))throw new e(`geospatial-pdf-layer:parse`,n);return t}export{i as parse};
@@ -1,3 +1,3 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../core/Error.js";import t from"../../geometry/SpatialReference.js";const n={OriginLatitude:`Origin_Latitude`,CentralMeridian:`Central_Meridian`,ScaleFactor:`Scale_Factor`,FalseEasting:`False_Easting`,FalseNorthing:`False_Northing`,Zone:`Zone`,Hemisphere:`Hemisphere`,StandardParallelOne:`Standard_Parallel_One`,StandardParallelTwo:`Standard_Parallel_Two`},r=/^(?:NAD83|NORTH AMERICAN 1983|NAR(?:-[A-Z])?)$/i,i=/^(?:NAD27|NORTH AMERICAN 1927|NAS(?:-[A-Z])?)$/i,a=/^(?:WGS84|WGS 84|WGE)$/i;function o(e){let n=s(e);if(n.kind===`projected`){let{projectionType:r,datum:i}=n;return r===`SPCS`?O(e,i):new t({wkt:p(e,r,i)})}}function s(e){return c(e)}function c(t){let n=l(t.Type),r=u(t.Projection_Type),i;if(r||(i=`Projection is missing or has unsupported ProjectionType`),n||(i=`Projection dictionary is missing or has invalid Type. Expected Projection or Display.`),t.Datum||(i=`Projection is missing a Datum`),i)throw new e(`geospatial-pdf-layer:invalid-projection`,i);return d(t,r),{kind:`projected`,dictionaryType:n,projectionType:r,datum:t.Datum}}function l(e){switch(e){case`Projection`:case`Display`:return e;default:return}}function u(e){switch(e){case`TC`:case`PH`:case`UT`:case`AC`:case`LE`:case`SPCS`:return e;default:return}}function d(t,r){let i=f(r);for(let a of i){let i=t[n[a]];if(i===void 0||i===``)throw new e(`geospatial-pdf-layer:invalid-projection`,`Projection ${r} missing required parameter ${a}.`)}}function f(e){switch(e){case`TC`:return[`OriginLatitude`,`CentralMeridian`,`ScaleFactor`,`FalseEasting`,`FalseNorthing`];case`PH`:return[`OriginLatitude`,`CentralMeridian`,`FalseEasting`,`FalseNorthing`];case`UT`:return[`Zone`,`Hemisphere`];case`AC`:case`LE`:return[`OriginLatitude`,`CentralMeridian`,`StandardParallelOne`,`StandardParallelTwo`,`FalseEasting`,`FalseNorthing`];case`SPCS`:return[`Zone`]}}function p(e,t,n){let r=h(e,t,n),i=m(t),a=_(n),o=v(e.Units??`M`),s=y(e,t);return`PROJCS["${r}",GEOGCS["${S(n)}",${a},PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["${i}"],${s.join(`,
3
- `)},${o}]`}function m(e){switch(e){case`TC`:case`UT`:return`Transverse_Mercator`;case`PH`:return`Polyconic`;case`AC`:return`Albers`;case`LE`:return`Lambert_Conformal_Conic`}}function h(e,t,n){let r=g(n);switch(t){case`TC`:return`${r}_GeospatialPDF_Transverse_Mercator`;case`PH`:return`${r}_GeospatialPDF_Polyconic`;case`UT`:return`${r}_GeospatialPDF_UTM_Zone_${e.Zone}_${e.Hemisphere}`;case`AC`:return`${r}_GeospatialPDF_Albers_Equal_Area`;case`LE`:return`${r}_GeospatialPDF_Lambert_Conformal_Conic`}}function g(e){let t=C(e);return t?T(t)?`NAD_1983`:E(t)?`NAD_1927`:D(t)?`WGS_1984`:`geospatialPDF`:`geospatialPDF`}function _(t){if(t.kind===`definition`){let n=t.ellipsoid;if(!n?.semi_Major_Axis)throw new e(`geospatial-pdf-layer:invalid-Datum`,`Datum definition requires semi-major axis`);let r=x(n),i=t.name??`GeospatialPDF_Datum`,a=`SPHEROID["${n.description??`GeospatialPDF_Spheroid`}",${n.semi_Major_Axis},${r}]`,o=t.to_WGS84;return`DATUM["${i}",${a}${o?`,TOWGS84[${o.dx??0},${o.dy??0},${o.dz??0},${o.rx??0},${o.ry??0},${o.rz??0},${o.sf??0}]`:``}]`}if(t.name){let e=t.name.toUpperCase();if(T(e))return`DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]]`;if(E(e))return`DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]]`;if(D(e))return`DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]]`}throw new e(`geospatial-pdf-layer:invalid-Datum`,`Unsupported datum `+t.name)}function v(e){let t=e.toLowerCase();return[`m`,`meter`,`meters`,`metre`,`metres`].includes(t)?`UNIT["Meter",1.0]`:[`ft`,`foot`,`feet`].includes(t)?`UNIT["Foot",0.3048]`:`UNIT["${e}",1.0]`}function y(e,t){switch(t){case`TC`:return[`PARAMETER["False_Easting",${e.False_Easting}]`,`PARAMETER["False_Northing",${e.False_Northing}]`,`PARAMETER["Central_Meridian",${e.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${e.Origin_Latitude}]`,`PARAMETER["Scale_Factor",${e.Scale_Factor}]`];case`PH`:return[`PARAMETER["False_Easting",${e.False_Easting}]`,`PARAMETER["False_Northing",${e.False_Northing}]`,`PARAMETER["Central_Meridian",${e.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${e.Origin_Latitude}]`];case`AC`:case`LE`:return[`PARAMETER["False_Easting",${e.False_Easting}]`,`PARAMETER["False_Northing",${e.False_Northing}]`,`PARAMETER["Central_Meridian",${e.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${e.Origin_Latitude}]`,`PARAMETER["Standard_Parallel_1",${e.Standard_Parallel_One}]`,`PARAMETER["Standard_Parallel_2",${e.Standard_Parallel_Two}]`];case`UT`:return b(e)}}function b(t){if(!t.Zone)throw new e(`geospatial-pdf-layer:invalid-projection`,`No zone found for projection code UT`);let n=t.Zone*6-183;return[`PARAMETER["False_Easting",500000]`,`PARAMETER["False_Northing",${/^s/i.test(t.Hemisphere??``)?1e7:0}]`,`PARAMETER["Central_Meridian",${n}]`,`PARAMETER["Latitude_Of_Origin",0]`,`PARAMETER["Scale_Factor",0.9996]`]}function x(t){if(t.inverse_Flattening!=null)return t.inverse_Flattening;let n=t.semi_Major_Axis,r=t.semi_Minor_Axis;if(n==null||r==null)throw new e(`geospatial-pdf-layer:invalid-Datum`,`Ellipsoid definition missing InvFlattening or SemiMinorAxis.`);return n===r?0:n/(n-r)}function S(e){let t=C(e);return t?T(t)?`GCS_North_American_1983`:E(t)?`GCS_North_American_1927`:D(t)?`GCS_WGS_1984`:`GCS_GeospatialPDF`:`GCS_GeospatialPDF`}function C(e){return e.name?w(e.name):null}function w(e){return e.trim().toUpperCase().replace(/_/g,` `).replace(/\s+/g,` `)}function T(e){return r.test(e)}function E(e){return i.test(e)}function D(e){return a.test(e)}function O(n,r){let i=C(r);if(n.Zone===2800&&i&&T(i))return new t({wkid:32110});throw new e(`geospatial-pdf-layer:invalid-projection`,`Unsupported State Plane projection: datum ${r.name}, zone ${n.Zone}`)}export{o as projectionToSpatialReference,s as validateProjection};
2
+ import e from"../../core/Error.js";import t from"../../geometry/SpatialReference.js";const n={OriginLatitude:`Origin_Latitude`,CentralMeridian:`Central_Meridian`,ScaleFactor:`Scale_Factor`,FalseEasting:`False_Easting`,FalseNorthing:`False_Northing`,Zone:`Zone`,Hemisphere:`Hemisphere`,StandardParallelOne:`Standard_Parallel_One`,StandardParallelTwo:`Standard_Parallel_Two`},r=/^(?:NAD83|NORTH AMERICAN 1983|NAR(?:-[A-Z])?)$/i,i=/^(?:NAD27|NORTH AMERICAN 1927|NAS(?:-[A-Z])?)$/i,a=/^(?:WGS84|WGS 84|WGE)$/i;function o(e){let n=s(e);if(n.kind===`projected`){let{projectionType:r,datum:i}=n;return r===`SPCS`?O(e,i):new t({wkt:p(e,r,i)})}}function s(e){return c(e)}function c(t){let n=l(t.Type);if(!n)throw new e(`geospatial-pdf-layer:invalid-projection`,`Projection dictionary is missing or has invalid Type`,`Expected Projection or Display`);let r=t.Projection_Type;if(!r)throw new e(`geospatial-pdf-layer:invalid-projection`,`Missing projection code`);let i=u(t.Projection_Type);if(!i)throw new e(`geospatial-pdf-layer:unsupported-projection`,`Unsupported projection code: ${r}`);let a=t.Datum;if(!a)throw new e(`geospatial-pdf-layer:invalid-datum`,`Missing datum definition or code in LGI Dict frame`);if(a.kind===`unknown`)throw new e(`geospatial-pdf-layer:invalid-datum`,`Invalid datum: ${a.name??`unknown`}`);return d(t,i),{kind:`projected`,dictionaryType:n,projectionType:i,datum:t.Datum}}function l(e){switch(e){case`Projection`:case`Display`:return e;default:return}}function u(e){switch(e){case`TC`:case`PH`:case`UT`:case`AC`:case`LE`:case`SPCS`:return e;default:return}}function d(t,r){let i=f(r);for(let a of i){let i=t[n[a]];if(i===void 0||i===``)throw new e(`geospatial-pdf-layer:invalid-projection`,`Projection ${r} missing required parameter ${a}`)}}function f(e){switch(e){case`TC`:return[`OriginLatitude`,`CentralMeridian`,`ScaleFactor`,`FalseEasting`,`FalseNorthing`];case`PH`:return[`OriginLatitude`,`CentralMeridian`,`FalseEasting`,`FalseNorthing`];case`UT`:return[`Zone`,`Hemisphere`];case`AC`:case`LE`:return[`OriginLatitude`,`CentralMeridian`,`StandardParallelOne`,`StandardParallelTwo`,`FalseEasting`,`FalseNorthing`];case`SPCS`:return[`Zone`]}}function p(e,t,n){let r=h(e,t,n),i=m(t),a=_(n),o=v(e.Units??`M`),s=y(e,t);return`PROJCS["${r}",GEOGCS["${S(n)}",${a},PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]],PROJECTION["${i}"],${s.join(`,
3
+ `)},${o}]`}function m(e){switch(e){case`TC`:case`UT`:return`Transverse_Mercator`;case`PH`:return`Polyconic`;case`AC`:return`Albers`;case`LE`:return`Lambert_Conformal_Conic`}}function h(e,t,n){let r=g(n);switch(t){case`TC`:return`${r}_GeospatialPDF_Transverse_Mercator`;case`PH`:return`${r}_GeospatialPDF_Polyconic`;case`UT`:return`${r}_GeospatialPDF_UTM_Zone_${e.Zone}_${e.Hemisphere}`;case`AC`:return`${r}_GeospatialPDF_Albers_Equal_Area`;case`LE`:return`${r}_GeospatialPDF_Lambert_Conformal_Conic`}}function g(e){let t=C(e);return t?T(t)?`NAD_1983`:E(t)?`NAD_1927`:D(t)?`WGS_1984`:`geospatialPDF`:`geospatialPDF`}function _(t){if(t.kind===`definition`){let n=t.raw.Ellipsoid;if(typeof n==`string`)throw new e(`geospatial-pdf-layer:unsupported-ellipsoid`,`Only ellipsoid definitions are supported but found predefined code`,{code:n});let r=t.raw.ToWGS84;if(typeof r==`string`)throw new e(`geospatial-pdf-layer:unsupported-datum-shift`,`Only shift definitions are supported but found predefined code`,{code:r});let i=t.ellipsoid;if(!i?.semi_Major_Axis)throw new e(`geospatial-pdf-layer:invalid-Datum`,`Datum definition requires semi-major axis`);let a=x(i),o=t.name??`GeospatialPDF_Datum`,s=`SPHEROID["${i.description??`GeospatialPDF_Spheroid`}",${i.semi_Major_Axis},${a}]`,c=t.to_WGS84;return`DATUM["${o}",${s}${c?`,TOWGS84[${c.dx??0},${c.dy??0},${c.dz??0},${c.rx??0},${c.ry??0},${c.rz??0},${c.sf??0}]`:``}]`}if(t.name){let e=t.name.toUpperCase();if(T(e))return`DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]]`;if(E(e))return`DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]]`;if(D(e))return`DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]]`}throw new e(`geospatial-pdf-layer:unsupported-datum`,`Unsupported datum code: ${t.name??`unknown`}`)}function v(e){let t=e.toLowerCase();return[`m`,`meter`,`meters`,`metre`,`metres`].includes(t)?`UNIT["Meter",1.0]`:[`ft`,`foot`,`feet`].includes(t)?`UNIT["Foot",0.3048]`:`UNIT["${e}",1.0]`}function y(e,t){switch(t){case`TC`:return[`PARAMETER["False_Easting",${e.False_Easting}]`,`PARAMETER["False_Northing",${e.False_Northing}]`,`PARAMETER["Central_Meridian",${e.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${e.Origin_Latitude}]`,`PARAMETER["Scale_Factor",${e.Scale_Factor}]`];case`PH`:return[`PARAMETER["False_Easting",${e.False_Easting}]`,`PARAMETER["False_Northing",${e.False_Northing}]`,`PARAMETER["Central_Meridian",${e.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${e.Origin_Latitude}]`];case`AC`:case`LE`:return[`PARAMETER["False_Easting",${e.False_Easting}]`,`PARAMETER["False_Northing",${e.False_Northing}]`,`PARAMETER["Central_Meridian",${e.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${e.Origin_Latitude}]`,`PARAMETER["Standard_Parallel_1",${e.Standard_Parallel_One}]`,`PARAMETER["Standard_Parallel_2",${e.Standard_Parallel_Two}]`];case`UT`:return b(e)}}function b(t){if(!t.Zone)throw new e(`geospatial-pdf-layer:invalid-projection`,`No zone found for projection code UT`);let n=t.Zone*6-183;return[`PARAMETER["False_Easting",500000]`,`PARAMETER["False_Northing",${/^s/i.test(t.Hemisphere??``)?1e7:0}]`,`PARAMETER["Central_Meridian",${n}]`,`PARAMETER["Latitude_Of_Origin",0]`,`PARAMETER["Scale_Factor",0.9996]`]}function x(t){if(t.inverse_Flattening!=null)return t.inverse_Flattening;let n=t.semi_Major_Axis,r=t.semi_Minor_Axis;if(n==null||r==null)throw new e(`geospatial-pdf-layer:invalid-Datum`,`Ellipsoid definition missing InvFlattening or SemiMinorAxis`);return n===r?0:n/(n-r)}function S(e){let t=C(e);return t?T(t)?`GCS_North_American_1983`:E(t)?`GCS_North_American_1927`:D(t)?`GCS_WGS_1984`:`GCS_GeospatialPDF`:`GCS_GeospatialPDF`}function C(e){return e.name?w(e.name):null}function w(e){return e.trim().toUpperCase().replace(/_/g,` `).replace(/\s+/g,` `)}function T(e){return r.test(e)}function E(e){return i.test(e)}function D(e){return a.test(e)}function O(n,r){let i=C(r);if(n.Zone===2800&&i&&T(i))return new t({wkid:32110});throw new e(`geospatial-pdf-layer:invalid-projection`,`Unsupported State Plane projection: datum ${r.name}, zone ${n.Zone}`)}export{o as projectionToSpatialReference};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import has from"../../../core/has.js";import{Loadable as n}from"../../../core/Loadable.js";import r from"../../../core/Logger.js";import{debounce as i}from"../../../core/promiseUtils.js";import{open as a}from"../../../core/workers.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import c from"../../../geometry/Extent.js";import l from"../../../geometry/Polygon.js";import{featureGeometryTypeKebabDictionary as u}from"../../../geometry/support/typeUtils.js";import{createCapabilities as d}from"./support/clientSideDefaults.js";import f from"../../../rest/support/FeatureSet.js";let p=class extends n{constructor(){super(...arguments),this.type=`geojson`,this.refresh=i(async e=>{await this.load();let{extent:t,timeExtent:n}=await this._connection.invoke(`refresh`,e);return this.sourceJSON.extent=t,n&&(this.sourceJSON.timeInfo.timeExtent=[n.start,n.end]),{dataChanged:!0,updates:{extent:this.sourceJSON.extent,timeInfo:this.sourceJSON.timeInfo}}})}load(e){let t=e==null?null:e.signal;return this.addResolvingPromise(this._startWorker(t)),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null}applyEdits(e){return this.load().then(()=>this._applyEdits(e))}openPorts(){return this.load().then(()=>this._connection.openPorts())}queryFeatures(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryFeatures`,e?e.toJSON():null,t)).then(e=>f.fromJSON(e))}queryFeaturesJSON(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryFeatures`,e?e.toJSON():null,t))}queryFeatureCount(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryFeatureCount`,e?e.toJSON():null,t))}queryObjectIds(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryObjectIds`,e?e.toJSON():null,t))}queryExtent(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryExtent`,e?e.toJSON():null,t)).then(e=>({count:e.count,extent:c.fromJSON(e.extent)}))}querySnapping(e,t={}){return this.load(t).then(()=>this._connection.invoke(`querySnapping`,e,t))}async queryAttributeBins(e,t={}){return await this.load(),this._connection.invoke(`queryAttributeBins`,e?.toJSON(),t)}_applyEdits(e){if(!this._connection)throw new t(`geojson-layer-source:edit-failure`,`Memory source not loaded`);let n=this.layer.objectIdField,r=[],i=[],a=[];if(e.addFeatures)for(let t of e.addFeatures)r.push(this._serializeFeature(t));if(e.deleteFeatures)for(let t of e.deleteFeatures)`objectId`in t&&t.objectId!=null?i.push(t.objectId):`attributes`in t&&t.attributes[n]!=null&&i.push(t.attributes[n]);if(e.updateFeatures)for(let t of e.updateFeatures)a.push(this._serializeFeature(t));return this._connection.invoke(`applyEdits`,{adds:r,updates:a,deletes:i}).then(({extent:e,timeExtent:t,featureEditResults:n})=>(this.sourceJSON.extent=e,t&&(this.sourceJSON.timeInfo.timeExtent=[t.start,t.end]),this._createEditsResult(n)))}_createEditsResult(e){return{addFeatureResults:e.addResults?e.addResults.map(this._createFeatureEditResult,this):[],updateFeatureResults:e.updateResults?e.updateResults.map(this._createFeatureEditResult,this):[],deleteFeatureResults:e.deleteResults?e.deleteResults.map(this._createFeatureEditResult,this):[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}_createFeatureEditResult(e){let n=e.success===!0?null:e.error||{code:void 0,description:``};return{objectId:e.objectId,globalId:e.globalId,error:n?new t(`geojson-layer-source:edit-failure`,n.description,{code:n.code}):null}}_serializeFeature(e){let{attributes:t}=e,n=this._geometryForSerialization(e);return n?{geometry:n.toJSON(),attributes:t}:{attributes:t}}_geometryForSerialization(e){let{geometry:t}=e;return t==null?null:t.type===`mesh`||t.type===`extent`?l.fromExtent(t.extent):t}async _startWorker(e){this._connection=await a(`GeoJSONSourceWorker`,{strategy:has(`feature-layers-workers`)?`dedicated`:`local`,signal:e,registryTarget:this});let{fields:t,spatialReference:n,hasZ:i,geometryType:o,objectIdField:s,url:c,timeInfo:l,customParameters:f}=this.layer,p=this.layer.originOf(`spatialReference`)===`defaults`,m={url:c,customParameters:f,fields:t&&t.map(e=>e.toJSON()),geometryType:u.toJSON(o),hasZ:i,objectIdField:s,timeInfo:l?l.toJSON():null,spatialReference:p?null:n&&n.toJSON()},h=await this._connection.invoke(`load`,m,{signal:e});for(let e of h.warnings)r.getLogger(this.layer).warn(`#load()`,`${e.message} (title: '${this.layer.title||`no title`}', id: '${this.layer.id??`no id`}')`,{warning:e});h.featureErrors.length&&r.getLogger(this.layer).warn(`#load()`,`Encountered ${h.featureErrors.length} validation errors while loading features. (title: '${this.layer.title||`no title`}', id: '${this.layer.id??`no id`}')`,{errors:h.featureErrors}),this.sourceJSON=h.layerDefinition,this.capabilities=d(this.sourceJSON.hasZ,!0)}};e([o()],p.prototype,`capabilities`,void 0),e([o()],p.prototype,`type`,void 0),e([o({constructOnly:!0})],p.prototype,`layer`,void 0),e([o()],p.prototype,`sourceJSON`,void 0),p=e([s(`esri.layers.graphics.sources.GeoJSONSource`)],p);export{p as GeoJSONSource};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import has from"../../../core/has.js";import{Loadable as n}from"../../../core/Loadable.js";import r from"../../../core/Logger.js";import{debounce as i}from"../../../core/promiseUtils.js";import{open as a}from"../../../core/workers.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import c from"../../../geometry/Extent.js";import l from"../../../geometry/Polygon.js";import{featureGeometryTypeKebabDictionary as u}from"../../../geometry/support/typeUtils.js";import{createCapabilities as d}from"./support/clientSideDefaults.js";import f from"../../../rest/support/FeatureSet.js";let p=class extends n{constructor(){super(...arguments),this.type=`geojson`,this.refresh=i(async e=>{await this.load();let{extent:t,timeExtent:n}=await this._connection.invoke(`refresh`,e);return this.sourceJSON.extent=t,n&&(this.sourceJSON.timeInfo.timeExtent=[n.start,n.end]),{dataChanged:!0,updates:{extent:this.sourceJSON.extent,timeInfo:this.sourceJSON.timeInfo}}})}load(e){let t=e==null?null:e.signal;return this.addResolvingPromise(this._startWorker(t)),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null}applyEdits(e){return this.load().then(()=>this._applyEdits(e))}openPorts(){return this.load().then(()=>this._connection.openPorts())}queryFeatures(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryFeatures`,e?e.toJSON():null,t)).then(e=>f.fromJSON(e))}queryFeaturesJSON(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryFeatures`,e?e.toJSON():null,t))}queryFeatureCount(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryFeatureCount`,e?e.toJSON():null,t))}queryObjectIds(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryObjectIds`,e?e.toJSON():null,t))}queryExtent(e,t={}){return this.load(t).then(()=>this._connection.invoke(`queryExtent`,e?e.toJSON():null,t)).then(e=>({count:e.count,extent:c.fromJSON(e.extent)}))}querySnapping(e,t={}){return this.load(t).then(()=>this._connection.invoke(`querySnapping`,e,t))}async queryAttributeBins(e,t={}){return await this.load(),this._connection.invoke(`queryAttributeBins`,e?.toJSON(),t)}_applyEdits(e){if(!this._connection)throw new t(`geojson-layer-source:edit-failure`,`Memory source not loaded`);let n=this.layer.objectIdField,r=[],i=[],a=[];if(e.addFeatures)for(let t of e.addFeatures)r.push(this._serializeFeature(t));if(e.deleteFeatures)for(let t of e.deleteFeatures)`objectId`in t&&t.objectId!=null?i.push(t.objectId):`attributes`in t&&t.attributes[n]!=null&&i.push(t.attributes[n]);if(e.updateFeatures)for(let t of e.updateFeatures)a.push(this._serializeFeature(t));return this._connection.invoke(`applyEdits`,{adds:r,updates:a,deletes:i}).then(({extent:e,timeExtent:t,featureEditResults:n})=>(this.sourceJSON.extent=e,t&&(this.sourceJSON.timeInfo.timeExtent=[t.start,t.end]),this._createEditsResult(n)))}_createEditsResult(e){return{addFeatureResults:e.addResults?e.addResults.map(this._createFeatureEditResult,this):[],updateFeatureResults:e.updateResults?e.updateResults.map(this._createFeatureEditResult,this):[],deleteFeatureResults:e.deleteResults?e.deleteResults.map(this._createFeatureEditResult,this):[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}_createFeatureEditResult(e){let n=e.success===!0?null:e.error||{code:void 0,description:``};return{objectId:e.objectId,globalId:e.globalId,error:n?new t(`geojson-layer-source:edit-failure`,n.description,{code:n.code}):null}}_serializeFeature(e){let{attributes:t}=e,n=this._geometryForSerialization(e);return n?{geometry:n.toJSON(),attributes:t}:{attributes:t}}_geometryForSerialization(e){let{geometry:t}=e;return t==null?null:t.type===`mesh`||t.type===`extent`?l.fromExtent(t.extent):t}async _startWorker(e){this._connection=await a(`GeoJSONSourceWorker`,{strategy:has(`feature-layers-workers`)?`dedicated`:`local`,signal:e,registryTarget:this});let{fields:t,spatialReference:n,hasZ:i,geometryType:o,objectIdField:s,url:c,timeInfo:l,customParameters:f}=this.layer,p=this.layer.originOf(`spatialReference`)===`defaults`,m={url:c,customParameters:f,fields:t&&t.map(e=>e.toJSON()),geometryType:u.toJSON(o),hasZ:i,objectIdField:s,timeInfo:l?l.toJSON():null,spatialReference:p?null:n&&n.toJSON()},h=await this._connection.invoke(`load`,m,{signal:e});for(let e of h.warnings)r.getLogger(this.layer).warn(`#load()`,`${e.message} (title: '${this.layer.title||`no title`}', id: '${this.layer.id??`no id`}')`,{warning:e});h.featureErrors.length&&r.getLogger(this.layer).warn(`#load()`,`Encountered ${h.featureErrors.length} validation errors while loading features. (title: '${this.layer.title||`no title`}', id: '${this.layer.id??`no id`}')`,{errors:h.featureErrors}),this.sourceJSON=h.layerDefinition,this.capabilities=d(this.sourceJSON.hasZ,!0,!this.sourceJSON.geometryType)}};e([o()],p.prototype,`capabilities`,void 0),e([o()],p.prototype,`type`,void 0),e([o({constructOnly:!0})],p.prototype,`layer`,void 0),e([o()],p.prototype,`sourceJSON`,void 0),p=e([s(`esri.layers.graphics.sources.GeoJSONSource`)],p);export{p as GeoJSONSource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isAbortError as i}from"../../../../core/promiseUtils.js";import{getJsonType as a}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as o,equals as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as c,convertToGeometry as l,convertFromFeatures as u,convertToFeature as d,convertFromFeature as f}from"../../featureConversionUtils.js";import p from"../../data/FeatureStore.js";import{checkProjectionSupport as m,project as h}from"../../data/projectionSupport.js";import{QueryEngine as g}from"../../data/QueryEngine.js";import{inferLayerProperties as _,createOptimizedFeatures as v,validateGeoJSON as y}from"./geojson.js";import{createDefaultTemplate as b,createDefaultAttributesFunction as x,createDrawingInfo as S}from"../support/clientSideDefaults.js";import{queryBinsCapabilities as C,loadGeometryEngineForSimplify as w,mixAttributes as T,createFeatureEditSuccessResult as E,createFeatureEditErrorResult as D,simplify as O}from"../support/sourceUtils.js";import k from"../../../support/FieldsIndex.js";import{kebabDict as A}from"../../../support/fieldType.js";import{getFieldDefaultValue as j,getFieldDefaultLength as M}from"../../../support/fieldUtils.js";import{utc as N}from"../../../../time/constants.js";const P={hasAttachments:!1,capabilities:`query, editing, create, delete, update`,useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsOutDistance:!1,supportsQueryWithResultType:!0,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:[`EnvelopeAggregate`,`CentroidAggregate`,`ConvexHullAggregate`],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0},queryBinsCapabilities:C};class F{constructor(){this._featureIdInfo=null,this._queryEngine=null,this._snapshotFeatures=async e=>{let t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e,t={}){this._loadOptions={url:e.url,customParameters:e.customParameters};let r=[],[i]=await Promise.all([e.url?this._fetch(t?.signal):null,this._checkProjection(e.spatialReference)]),a=_(i,{geometryType:e.geometryType}),s=e.fields||a.fields||[],c=e.hasZ==null?a.hasZ:e.hasZ,l=a.geometryType,u=e.objectIdField||a.objectIdFieldName||`__OBJECTID`,d=e.spatialReference||o,f=e.timeInfo;s===a.fields&&a.unknownFields.length>0&&r.push({name:`geojson-layer:unknown-field-types`,message:`Some fields types couldn't be inferred from the features and were dropped`,details:{unknownFields:a.unknownFields}});let m=new k(s),h=m.dateFields.length>0,v=m.get(u);v?(v.type!==`esriFieldTypeString`&&(v.type=`esriFieldTypeOID`),v.editable=!1,v.nullable=!1,u=v.name):(v={alias:u,name:u,type:a.objectIdFieldType===`string`?`esriFieldTypeString`:`esriFieldTypeOID`,editable:!1,nullable:!1},s.unshift(v));let y={};for(let e of s){if(e.name??=e.alias,e.alias??=e.name,!e.name)throw new n(`geojson-layer:invalid-field-name`,`field name is missing`,{field:e});if(!A.jsonValues.includes(e.type))throw new n(`geojson-layer:invalid-field-type`,`invalid type for field "${e.name}"`,{field:e});if(e.name!==v.name){let t=j(e);t!==void 0&&(y[e.name]=t)}e.length??=M(e)}if(f){if(f.startTimeField){let e=m.get(f.startTimeField);e?(f.startTimeField=e.name,e.type=`esriFieldTypeDate`,h=!0):f.startTimeField=null}if(f.endTimeField){let e=m.get(f.endTimeField);e?(f.endTimeField=e.name,e.type=`esriFieldTypeDate`,h=!0):f.endTimeField=null}if(f.trackIdField){let e=m.get(f.trackIdField);e?f.trackIdField=e.name:(f.trackIdField=null,r.push({name:`geojson-layer:invalid-timeInfo-trackIdField`,message:`trackIdField is missing`,details:{timeInfo:f}}))}!f.startTimeField&&!f.endTimeField&&(r.push({name:`geojson-layer:invalid-timeInfo`,message:`startTimeField and endTimeField are missing`,details:{timeInfo:f}}),f=null)}let C=l?S(l):void 0,w=h?{timeZoneIANA:N}:null,T={warnings:r,featureErrors:[],layerDefinition:{...P,drawingInfo:C??void 0,templates:b(y),extent:void 0,geometryType:l,objectIdField:u,fields:s,hasZ:!!c,timeInfo:f,dateFieldsTimeReference:w}};this._featureIdInfo={type:`object-id`,fieldName:u},this._queryEngine=new g({fieldsIndex:k.fromLayerJSON({fields:s,timeInfo:f,dateFieldsTimeReference:w}),geometryType:l,hasM:!1,hasZ:c,featureIdInfo:this._featureIdInfo,spatialReference:d,timeInfo:f,featureStore:new p({geometryType:l,hasM:!1,hasZ:c})});let E=this._queryEngine.fieldsIndex.requiredFields.indexOf(v);E>-1&&this._queryEngine.fieldsIndex.requiredFields.splice(E,1),this._createDefaultAttributes=x(y,u);let D=this._createFeatures(i);this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,D);let O=this._normalizeFeatures(D,T.featureErrors);this._queryEngine.featureStore.addMany(O);let{fullExtent:F,timeExtent:I}=await this._queryEngine.fetchRecomputedExtents();if(T.layerDefinition.extent=F,I){let{start:e,end:t}=I;T.layerDefinition.timeInfo.timeExtent=[e,t]}return T}async applyEdits(e){let{spatialReference:t,geometryType:n}=this._queryEngine;return await Promise.all([w(t,n),m(e.adds,t),m(e.updates,t)]),await this._waitSnapshotComplete(),this._applyEdits(e)}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,e);let t=this._normalizeFeatures(e);t&&this._queryEngine.featureStore.addMany(t)},e=>{this._queryEngine.featureStore.clear(),i(e)||r.getLogger(`esri.layers.GeoJSONLayer`).error(new n(`geojson-layer:refresh`,`An error occurred during refresh`,{error:e}))}),await this._waitSnapshotComplete();let{fullExtent:a,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:a,timeExtent:o}}_createFeatures(e){if(e==null)return[];let{geometryType:t,hasZ:n}=this._queryEngine,r=this._featureIdInfo.fieldName,i=v(e,{geometryType:t,hasZ:n,objectIdField:r});if(!s(this._queryEngine.spatialReference,o))for(let e of i)e.geometry!=null&&(e.geometry=c(h(l(e.geometry,this._queryEngine.geometryType,this._queryEngine.hasZ,!1),o,this._queryEngine.spatialReference)));return i}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){let{url:n,customParameters:r}=this._loadOptions,i=(await e(n??``,{responseType:`json`,query:{...r},signal:t})).data;return y(i),i}_normalizeFeatures(e,t){let{fieldsIndex:n}=this._queryEngine,r=[],i=this._featureIdInfo.fieldName;for(let a of e){let e=this._createDefaultAttributes(),o=T(n,e,a.attributes,!0);o?t?.push(o):(this._assignObjectId(e,a.attributes,!0),a.attributes=e,a.objectId=e[i],r.push(a))}return r}async _applyEdits(e){let{adds:t,updates:n,deletes:r}=e,i={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(i,t),n?.length&&this._applyUpdateEdits(i,n),r?.length){for(let e of r)i.deleteResults.push(E(e));this._queryEngine.featureStore.removeManyById(r)}let{fullExtent:a,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:a,timeExtent:o,featureEditResults:i}}_applyAddEdits(e,t){let{addResults:n}=e,{geometryType:r,hasM:i,hasZ:o,spatialReference:s,featureStore:c,fieldsIndex:l}=this._queryEngine,d=this._featureIdInfo.fieldName,f=[];for(let i of t){if(i.geometry&&r!==a(i.geometry)){n.push(D(`Incorrect geometry type.`));continue}let t=this._createDefaultAttributes(),o=T(l,t,i.attributes);if(o)n.push(o);else{if(this._assignObjectId(t,i.attributes),i.attributes=t,i.uid!=null){let t=i.attributes[d];e.uidToObjectId[i.uid]=t}if(i.geometry!=null){let e=i.geometry.spatialReference??s;i.geometry=h(O(i.geometry,e),e,s)}f.push(i),n.push(E(i.attributes[d]))}}c.addMany(u([],f,r,o,i,this._featureIdInfo))}_applyUpdateEdits({updateResults:e},t){let{geometryType:n,hasM:r,hasZ:i,spatialReference:o,featureStore:s,fieldsIndex:c}=this._queryEngine,l=this._featureIdInfo.fieldName;for(let u of t){let{attributes:t,geometry:p}=u,m=t?.[l];if(m==null){e.push(D(`Identifier field ${l} missing`));continue}if(!s.has(m)){e.push(D(`Feature with object id ${m} missing`));continue}let g=d(s.getFeature(m),n,i,r);if(p!=null){if(n!==a(p)){e.push(D(`Incorrect geometry type.`));continue}let t=p.spatialReference??o;g.geometry=h(O(p,t),t,o)}if(t){let n=T(c,g.attributes,t);if(n){e.push(n);continue}}s.add(f(g,n,i,r,this._featureIdInfo)),e.push(E(m))}}_createObjectIdGenerator(e,t){let n=this._featureIdInfo.fieldName,r=e.fieldsIndex.get(n);if(r.type===`esriFieldTypeString`)return()=>r.name+`-`+Date.now().toString(16);let i=-1/0;for(let e of t)e.objectId&&(i=Math.max(i,e.objectId));return i=Math.max(0,i)+1,()=>i++}_assignObjectId(e,t,n=!1){let r=this._featureIdInfo.fieldName;e[r]=!n||!(r in t)?this._objectIdGenerator():t[r]}async _checkProjection(e){try{await m(o,e)}catch{throw new n(`geojson-layer`,`Projection not supported`)}}}export{F as default};
2
+ import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import n from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isAbortError as i}from"../../../../core/promiseUtils.js";import{getJsonType as a}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as o,equals as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as c,convertToGeometry as l,convertFromFeatures as u,convertToFeature as d,convertFromFeature as f}from"../../featureConversionUtils.js";import p from"../../data/FeatureStore.js";import{checkProjectionSupport as m,project as h}from"../../data/projectionSupport.js";import{QueryEngine as g}from"../../data/QueryEngine.js";import{inferLayerProperties as _,createOptimizedFeatures as v,validateGeoJSON as y}from"./geojson.js";import{createDefaultTemplate as b,createDefaultAttributesFunction as x,createDrawingInfo as S}from"../support/clientSideDefaults.js";import{tableCapabilities as C,layerCapabilities as w,loadGeometryEngineForSimplify as T,mixAttributes as E,createFeatureEditSuccessResult as D,createFeatureEditErrorResult as O,simplify as k}from"../support/sourceUtils.js";import A from"../../../support/FieldsIndex.js";import{kebabDict as j}from"../../../support/fieldType.js";import{getFieldDefaultValue as M,getFieldDefaultLength as N}from"../../../support/fieldUtils.js";import{utc as P}from"../../../../time/constants.js";class F{constructor(){this._featureIdInfo=null,this._queryEngine=null,this._snapshotFeatures=async e=>{let t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e,t={}){this._loadOptions={url:e.url,customParameters:e.customParameters};let r=[],[i]=await Promise.all([e.url?this._fetch(t?.signal):null,this._checkProjection(e.spatialReference)]),a=_(i,{geometryType:e.geometryType}),s=e.fields||a.fields||[],c=e.hasZ==null?a.hasZ:e.hasZ,l=a.geometryType,u=!l,d=e.objectIdField||a.objectIdFieldName||`__OBJECTID`,f=e.spatialReference||o,m=e.timeInfo;s===a.fields&&a.unknownFields.length>0&&r.push({name:`geojson-layer:unknown-field-types`,message:`Some fields types couldn't be inferred from the features and were dropped`,details:{unknownFields:a.unknownFields}});let h=new A(s),v=h.dateFields.length>0,y=h.get(d);y?(y.type!==`esriFieldTypeString`&&(y.type=`esriFieldTypeOID`),y.editable=!1,y.nullable=!1,d=y.name):(y={alias:d,name:d,type:a.objectIdFieldType===`string`?`esriFieldTypeString`:`esriFieldTypeOID`,editable:!1,nullable:!1},s.unshift(y));let T={};for(let e of s){if(e.name??=e.alias,e.alias??=e.name,!e.name)throw new n(`geojson-layer:invalid-field-name`,`field name is missing`,{field:e});if(!j.jsonValues.includes(e.type))throw new n(`geojson-layer:invalid-field-type`,`invalid type for field "${e.name}"`,{field:e});if(e.name!==y.name){let t=M(e);t!==void 0&&(T[e.name]=t)}e.length??=N(e)}if(m){if(m.startTimeField){let e=h.get(m.startTimeField);e?(m.startTimeField=e.name,e.type=`esriFieldTypeDate`,v=!0):m.startTimeField=null}if(m.endTimeField){let e=h.get(m.endTimeField);e?(m.endTimeField=e.name,e.type=`esriFieldTypeDate`,v=!0):m.endTimeField=null}if(m.trackIdField){let e=h.get(m.trackIdField);e?m.trackIdField=e.name:(m.trackIdField=null,r.push({name:`geojson-layer:invalid-timeInfo-trackIdField`,message:`trackIdField is missing`,details:{timeInfo:m}}))}!m.startTimeField&&!m.endTimeField&&(r.push({name:`geojson-layer:invalid-timeInfo`,message:`startTimeField and endTimeField are missing`,details:{timeInfo:m}}),m=null)}let E=l?S(l):void 0,D=v?{timeZoneIANA:P}:null,O={warnings:r,featureErrors:[],layerDefinition:{...u?C:w,drawingInfo:E??void 0,templates:b(T),extent:void 0,geometryType:l,objectIdField:d,fields:s,hasZ:!!c,timeInfo:m,dateFieldsTimeReference:D}};this._featureIdInfo={type:`object-id`,fieldName:d},this._queryEngine=new g({fieldsIndex:A.fromLayerJSON({fields:s,timeInfo:m,dateFieldsTimeReference:D}),geometryType:l,hasM:!1,hasZ:c,featureIdInfo:this._featureIdInfo,spatialReference:f,timeInfo:m,featureStore:new p({geometryType:l,hasM:!1,hasZ:c})});let k=this._queryEngine.fieldsIndex.requiredFields.indexOf(y);k>-1&&this._queryEngine.fieldsIndex.requiredFields.splice(k,1),this._createDefaultAttributes=x(T,d);let F=this._createFeatures(i);this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,F);let I=this._normalizeFeatures(F,O.featureErrors);this._queryEngine.featureStore.addMany(I);let{fullExtent:L,timeExtent:R}=await this._queryEngine.fetchRecomputedExtents();if(O.layerDefinition.extent=L,R){let{start:e,end:t}=R;O.layerDefinition.timeInfo.timeExtent=[e,t]}return O}async applyEdits(e){let{spatialReference:t,geometryType:n}=this._queryEngine;return await Promise.all([T(t,n),m(e.adds,t),m(e.updates,t)]),await this._waitSnapshotComplete(),this._applyEdits(e)}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,e);let t=this._normalizeFeatures(e);t&&this._queryEngine.featureStore.addMany(t)},e=>{this._queryEngine.featureStore.clear(),i(e)||r.getLogger(`esri.layers.GeoJSONLayer`).error(new n(`geojson-layer:refresh`,`An error occurred during refresh`,{error:e}))}),await this._waitSnapshotComplete();let{fullExtent:a,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:a,timeExtent:o}}_createFeatures(e){if(e==null)return[];let{geometryType:t,hasZ:n}=this._queryEngine,r=this._featureIdInfo.fieldName,i=v(e,{geometryType:t,hasZ:n,objectIdField:r});if(!s(this._queryEngine.spatialReference,o))for(let e of i)e.geometry!=null&&(e.geometry=c(h(l(e.geometry,this._queryEngine.geometryType,this._queryEngine.hasZ,!1),o,this._queryEngine.spatialReference)));return i}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){let{url:n,customParameters:r}=this._loadOptions,i=(await e(n??``,{responseType:`json`,query:{...r},signal:t})).data;return y(i),i}_normalizeFeatures(e,t){let{fieldsIndex:n}=this._queryEngine,r=[],i=this._featureIdInfo.fieldName;for(let a of e){let e=this._createDefaultAttributes(),o=E(n,e,a.attributes,!0);o?t?.push(o):(this._assignObjectId(e,a.attributes,!0),a.attributes=e,a.objectId=e[i],r.push(a))}return r}async _applyEdits(e){let{adds:t,updates:n,deletes:r}=e,i={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(i,t),n?.length&&this._applyUpdateEdits(i,n),r?.length){for(let e of r)i.deleteResults.push(D(e));this._queryEngine.featureStore.removeManyById(r)}let{fullExtent:a,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:a,timeExtent:o,featureEditResults:i}}_applyAddEdits(e,t){let{addResults:n}=e,{geometryType:r,hasM:i,hasZ:o,spatialReference:s,featureStore:c,fieldsIndex:l}=this._queryEngine,d=this._featureIdInfo.fieldName,f=[];for(let i of t){if(i.geometry&&r!==a(i.geometry)){n.push(O(`Incorrect geometry type.`));continue}let t=this._createDefaultAttributes(),o=E(l,t,i.attributes);if(o)n.push(o);else{if(this._assignObjectId(t,i.attributes),i.attributes=t,i.uid!=null){let t=i.attributes[d];e.uidToObjectId[i.uid]=t}if(i.geometry!=null){let e=i.geometry.spatialReference??s;i.geometry=h(k(i.geometry,e),e,s)}f.push(i),n.push(D(i.attributes[d]))}}c.addMany(u([],f,r,o,i,this._featureIdInfo))}_applyUpdateEdits({updateResults:e},t){let{geometryType:n,hasM:r,hasZ:i,spatialReference:o,featureStore:s,fieldsIndex:c}=this._queryEngine,l=this._featureIdInfo.fieldName;for(let u of t){let{attributes:t,geometry:p}=u,m=t?.[l];if(m==null){e.push(O(`Identifier field ${l} missing`));continue}if(!s.has(m)){e.push(O(`Feature with object id ${m} missing`));continue}let g=d(s.getFeature(m),n,i,r);if(p!=null){if(n!==a(p)){e.push(O(`Incorrect geometry type.`));continue}let t=p.spatialReference??o;g.geometry=h(k(p,t),t,o)}if(t){let n=E(c,g.attributes,t);if(n){e.push(n);continue}}s.add(f(g,n,i,r,this._featureIdInfo)),e.push(D(m))}}_createObjectIdGenerator(e,t){let n=this._featureIdInfo.fieldName,r=e.fieldsIndex.get(n);if(r.type===`esriFieldTypeString`)return()=>r.name+`-`+Date.now().toString(16);let i=-1/0;for(let e of t)e.objectId&&(i=Math.max(i,e.objectId));return i=Math.max(0,i)+1,()=>i++}_assignObjectId(e,t,n=!1){let r=this._featureIdInfo.fieldName;e[r]=!n||!(r in t)?this._objectIdGenerator():t[r]}async _checkProjection(e){try{await m(o,e)}catch{throw new n(`geojson-layer`,`Projection not supported`)}}}export{F as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{remove as e}from"../../../../core/arrayUtils.js";import t from"../../../../core/Error.js";import{getJsonType as n,isPoint as r}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as i}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as a,convertToFeature as o,convertFromFeature as s}from"../../featureConversionUtils.js";import{initialObjectId as c,findLastObjectIdFromFeatures as l}from"../../objectIdUtils.js";import u from"../../data/FeatureStore.js";import{checkProjectionSupport as d,project as f}from"../../data/projectionSupport.js";import{QueryEngine as p}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as m,createDefaultTemplate as h,createDrawingInfo as g}from"./clientSideDefaults.js";import{queryBinsCapabilities as _,loadGeometryEngineForSimplify as v,createFeatureEditErrorResult as y,mixAttributes as b,createFeatureEditSuccessResult as x,simplify as S}from"./sourceUtils.js";import C from"../../../support/FieldsIndex.js";import{kebabDict as w}from"../../../support/fieldType.js";import{getFieldDefaultLength as T,getFieldDefaultValue as E}from"../../../support/fieldUtils.js";import{utc as D}from"../../../../time/constants.js";const O=i,k={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:i},A={hasAttachments:!1,capabilities:`query, editing, create, delete, update`,useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:[`EnvelopeAggregate`,`CentroidAggregate`,`ConvexHullAggregate`],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsOutDistance:!1,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0,supportsQueryWithCacheHint:!0},queryBinsCapabilities:_};function j(e){return r(e)?e.z!=null:!!e.hasZ}function M(e){return r(e)?e.m!=null:!!e.hasM}function N(e,t){let n,r=[];if(t.type===`unique-id-composite`){let i=[];for(let n of t.fieldNames)e.attributes[n]?i.push(e.attributes[n]):r.push(n);n=r.length===0?JSON.stringify(i):null}else n=e.attributes[t.fieldName],n||r.push(t.fieldName);return{objectId:n,missingFields:r}}class P{constructor(){this._uniqueIdInfo=null,this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e){let n=[],{features:r}=e,i=this._inferLayerProperties(r,e.fields),a=e.fields||[],o=e.hasM==null?!!i.hasM:e.hasM,s=e.hasZ==null?!!i.hasZ:e.hasZ,f=!e.spatialReference&&!i.spatialReference,_=f?O:e.spatialReference||i.spatialReference,v=f?k:null,y=e.geometryType||i.geometryType,b=!y,x=e.uniqueIdInfo,S=e.objectIdField??i.objectIdField,j=e.timeInfo,M=new C(a);if(!b&&(f&&n.push({name:`feature-layer:spatial-reference-not-found`,message:`Spatial reference not provided or found in features. Defaults to WGS84`}),!y))throw new t(`feature-layer:missing-property`,`geometryType not set and couldn't be inferred from the provided features`);if(x){let e=new Set(a.map(({name:e})=>e));if(!x.fields.every(t=>e.has(t))){let n=x.fields.filter(t=>!e.has(t));throw new t(`feature-layer:missing-property`,`UniqueIdFields not set and couldn't be found in the provided fields. Fields: `+n+` are mssing.`)}S=null}else if(!S)throw new t(`feature-layer:missing-property`,`objectIdField not set and uniqueIdInfo not provided.`);if(i.objectIdField&&S!==i.objectIdField&&(n.push({name:`feature-layer:duplicated-oid-field`,message:`Provided objectIdField "${S}" doesn't match the field name "${i.objectIdField}", found in the provided fields`}),S=i.objectIdField),S&&!i.objectIdField){let e=M.get(S);e?(S=e.name,e.type=`esriFieldTypeOID`,e.editable=!1,e.nullable=!1):a.unshift({alias:S,name:S,type:`esriFieldTypeOID`,editable:!1,nullable:!1})}for(let e of a){if(e.name??=e.alias,e.alias??=e.name,!e.name)throw new t(`feature-layer:invalid-field-name`,`field name is missing`,{field:e});if(e.name===S&&(e.type=`esriFieldTypeOID`),!w.jsonValues.includes(e.type))throw new t(`feature-layer:invalid-field-type`,`invalid type for field "${e.name}"`,{field:e});e.length??=T(e)}let N={};for(let e of a)if(e.type!==`esriFieldTypeOID`&&e.type!==`esriFieldTypeGlobalID`){let t=E(e);t!==void 0&&(N[e.name]=t)}if(j){if(j.startTimeField){let e=M.get(j.startTimeField);e?(j.startTimeField=e.name,e.type=`esriFieldTypeDate`):j.startTimeField=null}if(j.endTimeField){let e=M.get(j.endTimeField);e?(j.endTimeField=e.name,e.type=`esriFieldTypeDate`):j.endTimeField=null}if(j.trackIdField){let e=M.get(j.trackIdField);e?j.trackIdField=e.name:(j.trackIdField=null,n.push({name:`feature-layer:invalid-timeInfo-trackIdField`,message:`trackIdField is missing`,details:{timeInfo:j}}))}!j.startTimeField&&!j.endTimeField&&(n.push({name:`feature-layer:invalid-timeInfo`,message:`startTimeField and endTimeField are missing or invalid`,details:{timeInfo:j}}),j=null)}let P=M.dateFields.length?{timeZoneIANA:e.dateFieldsTimeZone??D}:null;this._createDefaultAttributes=m(N,S),this._uniqueIdInfo=e.uniqueIdInfo??void 0;let F={warnings:n,featureErrors:[],layerDefinition:{...A,drawingInfo:g(y),templates:h(N),extent:v,geometryType:y,objectIdField:S,fields:a,hasZ:s,hasM:o,timeInfo:j,dateFieldsTimeReference:P,uniqueIdInfo:this._uniqueIdInfo??void 0},assignedObjectIds:{}},I=this._uniqueIdInfo?.OIDFieldContainsHashValue?this._uniqueIdInfo.type===`simple`?{type:`unique-id-simple`,fieldName:this._uniqueIdInfo.fields[0]}:{type:`unique-id-composite`,fieldNames:this._uniqueIdInfo.fields}:{type:`object-id`,fieldName:S};if(this._queryEngine=new p({fieldsIndex:C.fromLayerJSON({fields:a,timeInfo:j,dateFieldsTimeReference:P}),geometryType:y,hasM:o,hasZ:s,featureIdInfo:I,spatialReference:_,featureStore:new u({geometryType:y,hasM:o,hasZ:s}),timeInfo:j}),!r?.length)return this._nextObjectId=c,F;if(S){let e=l(S,r);this._nextObjectId=e+1}return await d(r,_),this._loadInitialFeatures(F,r)}async applyEdits(e){let{spatialReference:t,geometryType:n}=this._queryEngine;return await Promise.all([v(t,n),d(e.adds,t),d(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}queryAttributeBins(e,t={}){return this._queryEngine.executeAttributeBinsQuery(e,t.signal)}_inferLayerProperties(e,t){let r,i,a=null,o=null,s=null;for(let t of e){let e=t.geometry;if(e!=null&&(a||=n(e),o||=e.spatialReference,r??=j(e),i??=M(e),a&&o&&r!=null&&i!=null))break}if(t&&t.length){let e=null;t.some(t=>{let n=t.type===`esriFieldTypeOID`,r=!t.type&&t.name&&t.name.toLowerCase()===`objectid`;return e=t,n||r})&&(s=e.name)}return{geometryType:a,spatialReference:o,objectIdField:s,hasM:i,hasZ:r}}async _loadInitialFeatures(e,t){let{geometryType:r,hasM:i,hasZ:o,spatialReference:s,featureStore:c,fieldsIndex:l,featureIdInfo:u}=this._queryEngine,d=[];for(let i of t){if(i.uid!=null&&(e.assignedObjectIds[i.uid]=-1),i.geometry&&r!==n(i.geometry)){e.featureErrors.push(y(`Incorrect geometry type.`));continue}let t=this._createDefaultAttributes(),a=b(l,t,i.attributes,!0);a?e.featureErrors.push(a):(this._assignObjectId(t,i.attributes,!0),i.attributes=t,i.uid&&(e.assignedObjectIds[i.uid]=N(i,u).objectId),i.geometry!=null&&(i.geometry=f(i.geometry,i.geometry.spatialReference,s)),d.push(i))}c.addMany(a([],d,r,o,i,u));let{fullExtent:p,timeExtent:m}=await this._queryEngine.fetchRecomputedExtents();if(e.layerDefinition.extent=p,m){let{start:t,end:n}=m;e.layerDefinition.timeInfo.timeExtent=[t,n]}return e}async _applyEdits(e){let{adds:t,updates:n,deletes:r}=e,i={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(i,t),n?.length&&this._applyUpdateEdits(i,n),r?.length){for(let e of r)i.deleteResults.push(x(e));this._queryEngine.featureStore.removeManyById(r)}let{fullExtent:a,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:a,timeExtent:o,featureEditResults:i}}_applyAddEdits(t,r){let{addResults:i,updateResults:o}=t,{geometryType:s,hasM:c,hasZ:l,spatialReference:u,featureStore:d,featureIdInfo:p,fieldsIndex:m}=this._queryEngine,h=[],g=new Map;for(let a of r){if(a.geometry&&s!==n(a.geometry)){i.push(y(`Incorrect geometry type.`));continue}let r=this._createDefaultAttributes(),c=b(m,r,a.attributes);if(c){i.push(c);continue}this._assignObjectId(r,a.attributes),a.attributes=r;let{objectId:l,missingFields:_}=N(a,p);if(l){if(a.uid!=null&&(t.uidToObjectId[a.uid]=l),a.geometry!=null){let e=a.geometry.spatialReference??u;a.geometry=f(S(a.geometry,e),e,u)}h.push(a);let n=x(l);g.has(l)?e(h,g.get(l)):d.has(l)?o.push(n):i.push(n),g.set(l,a)}else{i.push(y(`Missing unique id field value for fields: ${_.join()}`));continue}}d.addMany(a([],h,s,l,c,p))}_applyUpdateEdits({updateResults:e},t){let{geometryType:r,hasM:i,hasZ:a,spatialReference:c,featureStore:l,fieldsIndex:u,featureIdInfo:d}=this._queryEngine;for(let p of t){let{attributes:t,geometry:m}=p,{objectId:h,missingFields:g}=N(p,d);if(h==null){let t=d.type===`unique-id-composite`?g:d.fieldName;e.push(y(`Identifier fields: ${t} missing`));continue}if(!l.has(h)){e.push(y(`Feature with object id ${h} missing`));continue}let _=o(l.getFeature(h),r,a,i);if(m!=null){if(r!==n(m)){e.push(y(`Incorrect geometry type.`));continue}let t=m.spatialReference??c;_.geometry=f(S(m,t),t,c)}if(t){let n=b(u,_.attributes,t);if(n){e.push(n);continue}}l.add(s(_,r,a,i,d)),e.push(x(h))}}_assignObjectId(e,t,n=!1){if(this._queryEngine.featureIdInfo.type===`object-id`){let r=this._queryEngine.featureIdInfo.fieldName;e[r]=n&&t&&isFinite(t[r])?t[r]:this._nextObjectId++}}}export{P as default};
2
+ import{remove as e}from"../../../../core/arrayUtils.js";import t from"../../../../core/Error.js";import{getJsonType as n,isPoint as r}from"../../../../geometry/support/jsonTypeUtils.js";import{wgs84 as i}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as a,convertToFeature as o,convertFromFeature as s}from"../../featureConversionUtils.js";import{initialObjectId as c,findLastObjectIdFromFeatures as l}from"../../objectIdUtils.js";import u from"../../data/FeatureStore.js";import{checkProjectionSupport as d,project as f}from"../../data/projectionSupport.js";import{QueryEngine as p}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as m,createDefaultTemplate as h,createDrawingInfo as g}from"./clientSideDefaults.js";import{tableCapabilities as _,layerCapabilities as v,loadGeometryEngineForSimplify as y,createFeatureEditErrorResult as b,mixAttributes as x,createFeatureEditSuccessResult as S,simplify as C}from"./sourceUtils.js";import w from"../../../support/FieldsIndex.js";import{kebabDict as T}from"../../../support/fieldType.js";import{getFieldDefaultLength as E,getFieldDefaultValue as D}from"../../../support/fieldUtils.js";import{utc as O}from"../../../../time/constants.js";const k=i,A={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:i};function j(e){return r(e)?e.z!=null:!!e.hasZ}function M(e){return r(e)?e.m!=null:!!e.hasM}function N(e,t){let n,r=[];if(t.type===`unique-id-composite`){let i=[];for(let n of t.fieldNames)e.attributes[n]?i.push(e.attributes[n]):r.push(n);n=r.length===0?JSON.stringify(i):null}else n=e.attributes[t.fieldName],n||r.push(t.fieldName);return{objectId:n,missingFields:r}}class P{constructor(){this._uniqueIdInfo=null,this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e){let n=[],{features:r}=e,i=this._inferLayerProperties(r,e.fields),a=e.fields||[],o=e.hasM==null?!!i.hasM:e.hasM,s=e.hasZ==null?!!i.hasZ:e.hasZ,f=!e.spatialReference&&!i.spatialReference,y=f?k:e.spatialReference||i.spatialReference,b=f?A:null,x=e.geometryType||i.geometryType,S=!x,C=e.uniqueIdInfo,j=e.objectIdField??i.objectIdField,M=e.timeInfo,N=new w(a);if(!S&&(f&&n.push({name:`feature-layer:spatial-reference-not-found`,message:`Spatial reference not provided or found in features. Defaults to WGS84`}),!x))throw new t(`feature-layer:missing-property`,`geometryType not set and couldn't be inferred from the provided features`);if(C){let e=new Set(a.map(({name:e})=>e));if(!C.fields.every(t=>e.has(t))){let n=C.fields.filter(t=>!e.has(t));throw new t(`feature-layer:missing-property`,`UniqueIdFields not set and couldn't be found in the provided fields. Fields: `+n+` are mssing.`)}j=null}else if(!j)throw new t(`feature-layer:missing-property`,`objectIdField not set and uniqueIdInfo not provided.`);if(i.objectIdField&&j!==i.objectIdField&&(n.push({name:`feature-layer:duplicated-oid-field`,message:`Provided objectIdField "${j}" doesn't match the field name "${i.objectIdField}", found in the provided fields`}),j=i.objectIdField),j&&!i.objectIdField){let e=N.get(j);e?(j=e.name,e.type=`esriFieldTypeOID`,e.editable=!1,e.nullable=!1):a.unshift({alias:j,name:j,type:`esriFieldTypeOID`,editable:!1,nullable:!1})}for(let e of a){if(e.name??=e.alias,e.alias??=e.name,!e.name)throw new t(`feature-layer:invalid-field-name`,`field name is missing`,{field:e});if(e.name===j&&(e.type=`esriFieldTypeOID`),!T.jsonValues.includes(e.type))throw new t(`feature-layer:invalid-field-type`,`invalid type for field "${e.name}"`,{field:e});e.length??=E(e)}let P={};for(let e of a)if(e.type!==`esriFieldTypeOID`&&e.type!==`esriFieldTypeGlobalID`){let t=D(e);t!==void 0&&(P[e.name]=t)}if(M){if(M.startTimeField){let e=N.get(M.startTimeField);e?(M.startTimeField=e.name,e.type=`esriFieldTypeDate`):M.startTimeField=null}if(M.endTimeField){let e=N.get(M.endTimeField);e?(M.endTimeField=e.name,e.type=`esriFieldTypeDate`):M.endTimeField=null}if(M.trackIdField){let e=N.get(M.trackIdField);e?M.trackIdField=e.name:(M.trackIdField=null,n.push({name:`feature-layer:invalid-timeInfo-trackIdField`,message:`trackIdField is missing`,details:{timeInfo:M}}))}!M.startTimeField&&!M.endTimeField&&(n.push({name:`feature-layer:invalid-timeInfo`,message:`startTimeField and endTimeField are missing or invalid`,details:{timeInfo:M}}),M=null)}let F=N.dateFields.length?{timeZoneIANA:e.dateFieldsTimeZone??O}:null;this._createDefaultAttributes=m(P,j),this._uniqueIdInfo=e.uniqueIdInfo??void 0;let I={warnings:n,featureErrors:[],layerDefinition:{...S?_:v,drawingInfo:g(x),templates:h(P),extent:b,geometryType:x,objectIdField:j,fields:a,hasZ:s,hasM:o,timeInfo:M,dateFieldsTimeReference:F,uniqueIdInfo:this._uniqueIdInfo??void 0},assignedObjectIds:{}},L=this._uniqueIdInfo?.OIDFieldContainsHashValue?this._uniqueIdInfo.type===`simple`?{type:`unique-id-simple`,fieldName:this._uniqueIdInfo.fields[0]}:{type:`unique-id-composite`,fieldNames:this._uniqueIdInfo.fields}:{type:`object-id`,fieldName:j};if(this._queryEngine=new p({fieldsIndex:w.fromLayerJSON({fields:a,timeInfo:M,dateFieldsTimeReference:F}),geometryType:x,hasM:o,hasZ:s,featureIdInfo:L,spatialReference:y,featureStore:new u({geometryType:x,hasM:o,hasZ:s}),timeInfo:M}),!r?.length)return this._nextObjectId=c,I;if(j){let e=l(j,r);this._nextObjectId=e+1}return await d(r,y),this._loadInitialFeatures(I,r)}async applyEdits(e){let{spatialReference:t,geometryType:n}=this._queryEngine;return await Promise.all([y(t,n),d(e.adds,t),d(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}queryAttributeBins(e,t={}){return this._queryEngine.executeAttributeBinsQuery(e,t.signal)}_inferLayerProperties(e,t){let r,i,a=null,o=null,s=null;for(let t of e){let e=t.geometry;if(e!=null&&(a||=n(e),o||=e.spatialReference,r??=j(e),i??=M(e),a&&o&&r!=null&&i!=null))break}if(t&&t.length){let e=null;t.some(t=>{let n=t.type===`esriFieldTypeOID`,r=!t.type&&t.name&&t.name.toLowerCase()===`objectid`;return e=t,n||r})&&(s=e.name)}return{geometryType:a,spatialReference:o,objectIdField:s,hasM:i,hasZ:r}}async _loadInitialFeatures(e,t){let{geometryType:r,hasM:i,hasZ:o,spatialReference:s,featureStore:c,fieldsIndex:l,featureIdInfo:u}=this._queryEngine,d=[];for(let i of t){if(i.uid!=null&&(e.assignedObjectIds[i.uid]=-1),i.geometry&&r!==n(i.geometry)){e.featureErrors.push(b(`Incorrect geometry type.`));continue}let t=this._createDefaultAttributes(),a=x(l,t,i.attributes,!0);a?e.featureErrors.push(a):(this._assignObjectId(t,i.attributes,!0),i.attributes=t,i.uid&&(e.assignedObjectIds[i.uid]=N(i,u).objectId),i.geometry!=null&&(i.geometry=f(i.geometry,i.geometry.spatialReference,s)),d.push(i))}c.addMany(a([],d,r,o,i,u));let{fullExtent:p,timeExtent:m}=await this._queryEngine.fetchRecomputedExtents();if(e.layerDefinition.extent=p,m){let{start:t,end:n}=m;e.layerDefinition.timeInfo.timeExtent=[t,n]}return e}async _applyEdits(e){let{adds:t,updates:n,deletes:r}=e,i={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(i,t),n?.length&&this._applyUpdateEdits(i,n),r?.length){for(let e of r)i.deleteResults.push(S(e));this._queryEngine.featureStore.removeManyById(r)}let{fullExtent:a,timeExtent:o}=await this._queryEngine.fetchRecomputedExtents();return{extent:a,timeExtent:o,featureEditResults:i}}_applyAddEdits(t,r){let{addResults:i,updateResults:o}=t,{geometryType:s,hasM:c,hasZ:l,spatialReference:u,featureStore:d,featureIdInfo:p,fieldsIndex:m}=this._queryEngine,h=[],g=new Map;for(let a of r){if(a.geometry&&s!==n(a.geometry)){i.push(b(`Incorrect geometry type.`));continue}let r=this._createDefaultAttributes(),c=x(m,r,a.attributes);if(c){i.push(c);continue}this._assignObjectId(r,a.attributes),a.attributes=r;let{objectId:l,missingFields:_}=N(a,p);if(l){if(a.uid!=null&&(t.uidToObjectId[a.uid]=l),a.geometry!=null){let e=a.geometry.spatialReference??u;a.geometry=f(C(a.geometry,e),e,u)}h.push(a);let n=S(l);g.has(l)?e(h,g.get(l)):d.has(l)?o.push(n):i.push(n),g.set(l,a)}else{i.push(b(`Missing unique id field value for fields: ${_.join()}`));continue}}d.addMany(a([],h,s,l,c,p))}_applyUpdateEdits({updateResults:e},t){let{geometryType:r,hasM:i,hasZ:a,spatialReference:c,featureStore:l,fieldsIndex:u,featureIdInfo:d}=this._queryEngine;for(let p of t){let{attributes:t,geometry:m}=p,{objectId:h,missingFields:g}=N(p,d);if(h==null){let t=d.type===`unique-id-composite`?g:d.fieldName;e.push(b(`Identifier fields: ${t} missing`));continue}if(!l.has(h)){e.push(b(`Feature with object id ${h} missing`));continue}let _=o(l.getFeature(h),r,a,i);if(m!=null){if(r!==n(m)){e.push(b(`Incorrect geometry type.`));continue}let t=m.spatialReference??c;_.geometry=f(C(m,t),t,c)}if(t){let n=x(u,_.attributes,t);if(n){e.push(n);continue}}l.add(s(_,r,a,i,d)),e.push(S(h))}}_assignObjectId(e,t,n=!1){if(this._queryEngine.featureIdInfo.type===`object-id`){let r=this._queryEngine.featureIdInfo.fieldName;e[r]=n&&t&&isFinite(t[r])?t[r]:this._nextObjectId++}}}export{P as default};
@@ -5,4 +5,4 @@ import has from"../../../../core/has.js";import{clone as e}from"../../../../core
5
5
  ${n};
6
6
  }
7
7
  }
8
- `)();return()=>new r}catch{return()=>t?{[t]:null,...e}:{...e}}}function u(e){return s.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function d(t={}){return[{name:`New Feature`,description:``,prototype:{attributes:e(t)}}]}function f(e,r){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:r,supportsDelete:r,supportsEditing:r,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:r,supportsExceedsLimitStatistics:!0,supportsAsyncConvert3D:!1},query:n,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:t,editing:{supportsGeometryUpdate:r,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsTrueCurveUpdate:r,supportsTrueCurveUpdateByTrueCurveClientsOnly:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}export{f as createCapabilities,l as createDefaultAttributesFunction,d as createDefaultTemplate,o as createDrawingInfo};
8
+ `)();return()=>new r}catch{return()=>t?{[t]:null,...e}:{...e}}}function u(e){return s.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}function d(t={}){return[{name:`New Feature`,description:``,prototype:{attributes:e(t)}}]}const f={...n,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsCentroid:!1,supportsDistance:!1,supportsExtent:!1,supportsQuantization:!1,supportsQueryGeometry:!1,supportsDisjointSpatialRelationship:!1},p={...t,supportedStatistics:{...t.supportedStatistics,envelope:!1,centroid:!1,convexHull:!1}};function m(e,r,i=!1){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:r,supportsDelete:r,supportsEditing:r,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:r,supportsExceedsLimitStatistics:!0,supportsAsyncConvert3D:!1},query:i?f:n,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:i?p:t,editing:{supportsGeometryUpdate:r,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsTrueCurveUpdate:r,supportsTrueCurveUpdateByTrueCurveClientsOnly:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}export{m as createCapabilities,l as createDefaultAttributesFunction,d as createDefaultTemplate,o as createDrawingInfo};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{parseDate as e}from"../../../../core/date.js";import{importLazily as t}from"../../../../core/importUtils.js";import{isPolygon as n,isPolyline as r}from"../../../../geometry/support/jsonTypeUtils.js";import{isValid as i}from"../../../../geometry/support/spatialReferenceUtils.js";import{validateFieldValue as a,validationErrorToString as o,isNumericField as s,sanitizedParseFloat as c,isStringField as l,isDateField as u,sanitizeNullFieldValue as d}from"../../../support/fieldUtils.js";class f{constructor(e){this.description=e,this.code=null}}class p{constructor(e){this.globalId=null,this.objectId=null,this.success=!1,this.uniqueId=null,this.error=new f(e)}}function m(e){return new p(e)}class h{constructor(e){this.globalId=null,this.success=!0,this.objectId=this.uniqueId=e}}function g(e){return new h(e)}const _=new Set;function v(e,t,n,r=!1){_.clear();for(let i in n){let s=e.get(i);if(!s)continue;let c=n[i],l=y(s,c);if(_.add(s.name),s&&(r||s.editable)){let e=a(s,l);if(!e)t[s.name]=l;else return m(o(e,s,l))}}for(let t of e.requiredFields??[])if(!_.has(t.name))return m(`missing required field "${t.name}"`);return null}function y(t,n){let r=n;return s(t)&&typeof n==`string`?r=c(n):l(t)&&n!=null&&typeof n!=`string`?r=String(n):u(t)&&typeof n==`string`&&(r=e(n)),d(r)}const b=t(()=>import(`../../../../geometry/operators/json/simplifyOperator.js`));function x(e,t){if(!n(e)&&!r(e)||!i(t))return e;let a=b.module;if(a==null)throw TypeError(`simplify operator not loaded`);return a.simplifyExecute({...e,spatialReference:t})??e}async function S(e,t){i(e)&&(t===`esriGeometryPolygon`||t===`esriGeometryPolyline`)&&await b.getImportPromise()}const C={supportsAutoIntervalBin:!0,supportsFixedIntervalBin:!0,supportsFixedBoundariesBin:!0,supportsDateBin:!0,supportsStackBy:!0,supportsSplitBy:!0,supportsNormalization:!0,supportedStatisticTypes:[`COUNT`,`SUM`,`AVG`,`VAR`,`STDDEV`,`MIN`,`MAX`,`PERCENTILE_CONT`,`PERCENTILE_DISC`,`CentroidAggregate`,`EnvelopeAggregate`,`ConvexHullAggregate`],supportedNormalizationTypes:[`field`,`log`,`naturalLog`,`percentOfTotal`,`squareRoot`]};export{m as createFeatureEditErrorResult,g as createFeatureEditSuccessResult,S as loadGeometryEngineForSimplify,v as mixAttributes,C as queryBinsCapabilities,x as simplify};
2
+ import{parseDate as e}from"../../../../core/date.js";import{importLazily as t}from"../../../../core/importUtils.js";import{isPolygon as n,isPolyline as r}from"../../../../geometry/support/jsonTypeUtils.js";import{isValid as i}from"../../../../geometry/support/spatialReferenceUtils.js";import{validateFieldValue as a,validationErrorToString as o,isNumericField as s,sanitizedParseFloat as c,isStringField as l,isDateField as u,sanitizeNullFieldValue as d}from"../../../support/fieldUtils.js";class f{constructor(e){this.description=e,this.code=null}}class p{constructor(e){this.globalId=null,this.objectId=null,this.success=!1,this.uniqueId=null,this.error=new f(e)}}function m(e){return new p(e)}class h{constructor(e){this.globalId=null,this.success=!0,this.objectId=this.uniqueId=e}}function g(e){return new h(e)}const _=new Set;function v(e,t,n,r=!1){_.clear();for(let i in n){let s=e.get(i);if(!s)continue;let c=n[i],l=y(s,c);if(_.add(s.name),s&&(r||s.editable)){let e=a(s,l);if(!e)t[s.name]=l;else return m(o(e,s,l))}}for(let t of e.requiredFields??[])if(!_.has(t.name))return m(`missing required field "${t.name}"`);return null}function y(t,n){let r=n;return s(t)&&typeof n==`string`?r=c(n):l(t)&&n!=null&&typeof n!=`string`?r=String(n):u(t)&&typeof n==`string`&&(r=e(n)),d(r)}const b=t(()=>import(`../../../../geometry/operators/json/simplifyOperator.js`));function x(e,t){if(!n(e)&&!r(e)||!i(t))return e;let a=b.module;if(a==null)throw TypeError(`simplify operator not loaded`);return a.simplifyExecute({...e,spatialReference:t})??e}async function S(e,t){i(e)&&(t===`esriGeometryPolygon`||t===`esriGeometryPolyline`)&&await b.getImportPromise()}const C={supportsAutoIntervalBin:!0,supportsFixedIntervalBin:!0,supportsFixedBoundariesBin:!0,supportsDateBin:!0,supportsStackBy:!0,supportsSplitBy:!0,supportsNormalization:!0,supportedStatisticTypes:[`COUNT`,`SUM`,`AVG`,`VAR`,`STDDEV`,`MIN`,`MAX`,`PERCENTILE_CONT`,`PERCENTILE_DISC`,`CentroidAggregate`,`EnvelopeAggregate`,`ConvexHullAggregate`],supportedNormalizationTypes:[`field`,`log`,`naturalLog`,`percentOfTotal`,`squareRoot`]},w={hasAttachments:!1,capabilities:`query, editing, create, delete, update`,useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentsCountOnly:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsSpatialAggregationStatistics:!0,supportedSpatialAggregationStatistics:[`EnvelopeAggregate`,`CentroidAggregate`,`ConvexHullAggregate`],supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsOutDistance:!1,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0,supportsQueryWithCacheHint:!0},queryBinsCapabilities:C},T={...w,supportsCoordinatesQuantization:!1,supportsReturningQueryGeometry:!1,advancedQueryCapabilities:{...w.advancedQueryCapabilities,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:[],supportsReturningGeometryCentroid:!1,supportsQueryWithDistance:!1,supportsReturningQueryExtent:!1,supportsDisjointSpatialRel:!1},queryBinsCapabilities:{...C,supportedStatisticTypes:C.supportedStatisticTypes.filter(e=>e!==`EnvelopeAggregate`&&e!==`CentroidAggregate`&&e!==`ConvexHullAggregate`)}};export{m as createFeatureEditErrorResult,g as createFeatureEditSuccessResult,w as layerCapabilities,S as loadGeometryEngineForSimplify,v as mixAttributes,C as queryBinsCapabilities,x as simplify,T as tableCapabilities};
@@ -549,7 +549,7 @@ export default class KnowledgeGraphSublayer extends KnowledgeGraphSublayerSuperc
549
549
  */
550
550
  createPopupTemplate(options?: CreatePopupTemplateOptions): PopupTemplate | null | undefined;
551
551
  /**
552
- * Creates query parameter object that can be used to fetch features from feature-based layers or
552
+ * Creates a query parameter object that can be used to fetch features from feature-based layers or
553
553
  * image footprints from ImageryLayer that satisfy the layer's configurations such as [definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#definitionExpression).
554
554
  * It will return `Z` and `M` values based on the layer's [data capabilities](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#capabilities).
555
555
  * It sets the query parameter's [Query.outFields](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outFields) property to `["*"]`.
@@ -836,7 +836,7 @@ export abstract class ArcGISImageService {
836
836
  */
837
837
  computeStatisticsHistograms(parameters: ImageHistogramParameters | ImageHistogramParametersProperties, requestOptions?: RequestOptions): Promise<ImageServiceStatisticsHistogramsResult>;
838
838
  /**
839
- * Creates query parameter object that can be used to fetch features from feature-based layers or
839
+ * Creates a query parameter object that can be used to fetch features from feature-based layers or
840
840
  * image footprints from ImageryLayer that satisfy the layer's configurations such as [definitionExpression](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ArcGISImageService/#definitionExpression).
841
841
  * It will return `Z` and `M` values based on the layer's [data capabilities](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ArcGISImageService/#capabilities).
842
842
  * It sets the query parameter's [Query.outFields](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#outFields) property to `["*"]`.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseGeoKeyDirectory as g,parseXMP as _,parseFieldValues as v,isBSQConfig as y,getTagNumericValues as b,getTagFirstNumericValue as x,getImageInfo as S}from"../formats/tiffParser.js";import{tiffTags as C,ifdTags as w}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as T}from"../functions/stretchUtils.js";import E from"../transforms/PolynomialTransform.js";import D from"../../support/RasterInfo.js";import O from"../../support/RasterStorageInfo.js";import k from"../../../rest/support/FeatureSet.js";const A=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let j=class extends c{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this._chunkSize=10*1024**2,this._fileSize=-1,this._headerChunks=[],this.datasetFormat=`TIFF`}async fetchRawTile(e,t,n,r={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this._headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`)),await this._readHeader(e?.signal);let{rasterInfo:t}=this,{skipMapInfo:n,skipExtensions:r=[]}=this.ioConfig;if(!r.includes(`aux.xml`)&&!n){let n=await this._fetchAuxiliaryMetaData(e);n!=null&&N(n,t)}!r.includes(`vat.dbf`)&&t.bandCount===1&&t.pixelType===`u8`&&!n&&(t.attributeTable=await this._fetchAuxiliaryTable(e),t.attributeTable!=null&&(t.keyProperties.DataType=`thematic`)),n&&this.updateImageSpaceRasterInfo(t),this.updateTileInfo()}async _readHeader(e){try{let n=await this._fetchHeaderData(0,this._bufferSize,e);if(!n)throw new t(`tiffraster:open`,`failed to open url `+this.url);let{littleEndian:r,firstIFDPos:i,isBigTiff:a}=f(n),o=[],s={fileChunk:n,posIFD:i,fileOffset:0};await this._readIFDs(o,s,r,a?8:4,e);let{imageInfo:c,rasterInfo:l}=M(o),u=p(o),d=m(o);this._headerInfo={littleEndian:r,isBigTiff:a,ifds:o,pyramidIFDs:u,maskIFDs:d,...c},this._set(`rasterInfo`,l),this._validateHeader()}finally{this._headerChunks.length=0}}_validateHeader(){let e=this._headerInfo;if(!e.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+e.message);if(!e.tileWidth||!e.tileHeight)throw new t(`tiffraster:open`,A);this.rasterInfo.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let r=e.ifds[0],i=r.get(`PREDICTOR`)?.values?.[0];if(r.get(`SAMPLEFORMAT`)?.values?.[0]===3&&i===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`)}async _fetchHeaderData(e,n,r){let i=this._getCachedHeaderData(e,n);if(i)return i;let a=Math.floor(e/this._bufferSize)*this._bufferSize,o=a+Math.max(1,Math.ceil((n-a)/this._bufferSize))*this._bufferSize,s=this._getMissingHeaderRanges(a,o).map(async e=>{let{from:t,to:n}=e,i=await this._fetchOffsets(t,n,r),a=this._fileSize;return{chunk:i,fileOffset:t,isEOF:a>0?t+i.byteLength>=a:i.byteLength<n-t+1}}),c=await Promise.all(s);this._headerChunks.push(...c),this._headerChunks.sort((e,t)=>e.fileOffset-t.fileOffset);let l=this._getCachedHeaderData(e,n);if(!l)throw new t(`tiffraster:open`,`failed to fetch byte range ${e}-${n} from ${this.url}`);return l}_getCachedHeaderData(e,t){let n=[],r=e;for(let{chunk:i,fileOffset:a,isEOF:o}of this._headerChunks){if(a+i.byteLength-1<r)continue;if(a>r)return null;let s=r-a,c=Math.min(t-a+1,i.byteLength);if(n.push({chunk:i,start:s,end:c}),r=a+c,r>t||o&&c===i.byteLength){let t=new Uint8Array(r-e),i=0;for(let e of n){let n=new Uint8Array(e.chunk,e.start,e.end-e.start);t.set(n,i),i+=n.byteLength}return t.buffer}}return null}_getMissingHeaderRanges(e,t){let n=[],r=(e,t)=>{let r=Math.floor(e/this._bufferSize)*this._bufferSize,i=Math.ceil(t/this._bufferSize)*this._bufferSize;n.push({from:r,to:i})},i=e;for(let{chunk:e,fileOffset:a,isEOF:o}of this._headerChunks){let s=a+e.byteLength-1;if(!(s<i)&&(a>i&&r(i,Math.min(a-1,t)),i=Math.max(i,s+1),i>t||o))return n}return i<=t&&r(i,t),n}async _validateOrFetchHeaderBuffer(e,n){let{fileChunk:r,fileOffset:i,posIFD:a}=e;if(a+8>=r.byteLength||a<0){if(i=a+i,i<0)throw new t(`tiffraster:open`,`invalid IFD position ${i}. failed to open url ${this.url}`);r=await this._fetchHeaderData(i,i+this._bufferSize/2,n),a=0}return{fileChunk:r,fileOffset:i,posIFD:a}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,C,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=C,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===C&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,A);let i=[];e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),g(e),_(e);for(let[t,r]of w){let i=e.get(t),l=i?.data!=null&&Array.from(i.data.values()).some(e=>e.values==null&&e.offlineOffsetSize!=null);if(i&&(!i.data||l)){s=i.valueOffset-c;let e=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);i.data=(await this._readIFD(e,n,r,4,a))?.ifd}}return l}return l.requiredBufferSize?(o=await this._fetchHeaderData(c,c+s+l.requiredBufferSize+8,a),o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=Math.max(s,o+this._bufferSize/4),n=await this._fetchHeaderData(o,e,r);i.forEach(e=>v(n,t,e,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchHeaderData(n[0],n[1]+n[0],r);v(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize;this._fileSize>0&&(t=Math.min(t,this._fileSize-1));let a=Math.ceil((t-e+1)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(this._fileSize===-1&&s[0].httpStatus===206){let e=s[0].getHeader?.(`Content-Range`),t=Number(e?.split(`/`)[1]);Number.isFinite(t)&&(this._fileSize=t)}if(s.length===1)return s[0].data;let c=s.reduce((e,t)=>e+t.data.byteLength,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(new Uint8Array(e.data),u),u+=e.data.byteLength;return l.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{_headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=y(c,s),u=b(c,`TILEOFFSETS`),d=b(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=x(c,`IMAGEWIDTH`),_=x(c,`IMAGELENGTH`),v=x(c,`TILEWIDTH`),S=x(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%v||v,actualTileHeight:t===m&&_%S||S}}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?k.fromJSON(n.recordSet):null}catch{return null}}};e([r()],j.prototype,`_files`,void 0),e([r()],j.prototype,`_headerInfo`,void 0),e([r()],j.prototype,`_bufferSize`,void 0),e([r()],j.prototype,`_chunkSize`,void 0),e([r()],j.prototype,`_fileSize`,void 0),e([r()],j.prototype,`_headerChunks`,void 0),e([r({type:String,json:{write:!0}})],j.prototype,`datasetFormat`,void 0),j=e([i(`esri.layers.raster.datasets.TIFFRaster`)],j);function M(e){let t=S(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:b,colormap:x}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,w=d(C),T=!!t.isPseudoGeographic;w??=(T=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:w}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:w}):new o({x:0,y:0}),j=new O({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),N=b?{BandProperties:b.bandProperties,DataType:b.dataType}:{},P=new D({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:w,isPseudoSpatialReference:T,keyProperties:N,extent:k,colormap:x,statistics:b?b.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:w}),P.transform=new E({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function N(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=T(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const P=j;export{P as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseGeoKeyDirectory as g,parseXMP as _,parseFieldValues as v,isBSQConfig as y,getTagNumericValues as b,getTagFirstNumericValue as x,getImageInfo as S}from"../formats/tiffParser.js";import{tiffTags as C,ifdTags as w}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as T}from"../functions/stretchUtils.js";import E from"../transforms/PolynomialTransform.js";import D from"../../support/RasterInfo.js";import O from"../../support/RasterStorageInfo.js";import k from"../../../rest/support/FeatureSet.js";const A=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let j=class extends c{constructor(){super(...arguments),this._bufferSize=1048576,this._chunkSize=10*1024**2,this._fileSize=-1,this._headerChunks=[],this.datasetFormat=`TIFF`,this.headerInfo=null}async fetchRawTile(e,t,n,r={}){if(!this.headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this.headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`)),await this._readHeader(e?.signal),await this._fetchAllAuxData(),this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(this.rasterInfo),this.updateTileInfo()}async _readHeader(e){try{let n=await this._fetchHeaderData(0,this._bufferSize,e);if(!n)throw new t(`tiffraster:open`,`failed to open url `+this.url);let{littleEndian:r,firstIFDPos:i,isBigTiff:a}=f(n),o=[],s={fileChunk:n,posIFD:i,fileOffset:0};await this._readIFDs(o,s,r,a?8:4,e);let{imageInfo:c,rasterInfo:l}=M(o),u=p(o),d=m(o);this.headerInfo={littleEndian:r,isBigTiff:a,ifds:o,pyramidIFDs:u,maskIFDs:d,...c},this._set(`rasterInfo`,l),this._validateHeader()}finally{this._headerChunks.length=0}}_validateHeader(){let e=this.headerInfo;if(!e.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+e.message);if(!e.tileWidth||!e.tileHeight)throw new t(`tiffraster:open`,A);this.rasterInfo.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let r=e.ifds[0],i=r.get(`PREDICTOR`)?.values?.[0];if(r.get(`SAMPLEFORMAT`)?.values?.[0]===3&&i===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`)}async _fetchHeaderData(e,n,r){let i=this._getCachedHeaderData(e,n);if(i)return i;let a=Math.floor(e/this._bufferSize)*this._bufferSize,o=a+Math.max(1,Math.ceil((n-a)/this._bufferSize))*this._bufferSize,s=this._getMissingHeaderRanges(a,o).map(async e=>{let{from:t,to:n}=e,i=await this._fetchOffsets(t,n,r),a=this._fileSize;return{chunk:i,fileOffset:t,isEOF:a>0?t+i.byteLength>=a:i.byteLength<n-t+1}}),c=await Promise.all(s);this._headerChunks.push(...c),this._headerChunks.sort((e,t)=>e.fileOffset-t.fileOffset);let l=this._getCachedHeaderData(e,n);if(!l)throw new t(`tiffraster:open`,`failed to fetch byte range ${e}-${n} from ${this.url}`);return l}_getCachedHeaderData(e,t){let n=[],r=e;for(let{chunk:i,fileOffset:a,isEOF:o}of this._headerChunks){if(a+i.byteLength-1<r)continue;if(a>r)return null;let s=r-a,c=Math.min(t-a+1,i.byteLength);if(n.push({chunk:i,start:s,end:c}),r=a+c,r>t||o&&c===i.byteLength){let t=new Uint8Array(r-e),i=0;for(let e of n){let n=new Uint8Array(e.chunk,e.start,e.end-e.start);t.set(n,i),i+=n.byteLength}return t.buffer}}return null}_getMissingHeaderRanges(e,t){let n=[],r=(e,t)=>{let r=Math.floor(e/this._bufferSize)*this._bufferSize,i=Math.ceil(t/this._bufferSize)*this._bufferSize;n.push({from:r,to:i})},i=e;for(let{chunk:e,fileOffset:a,isEOF:o}of this._headerChunks){let s=a+e.byteLength-1;if(!(s<i)&&(a>i&&r(i,Math.min(a-1,t)),i=Math.max(i,s+1),i>t||o))return n}return i<=t&&r(i,t),n}async _validateOrFetchHeaderBuffer(e,n){let{fileChunk:r,fileOffset:i,posIFD:a}=e;if(a+8>=r.byteLength||a<0){if(i=a+i,i<0)throw new t(`tiffraster:open`,`invalid IFD position ${i}. failed to open url ${this.url}`);r=await this._fetchHeaderData(i,i+this._bufferSize/2,n),a=0}return{fileChunk:r,fileOffset:i,posIFD:a}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,C,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=C,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===C&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,A);let i=[];e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),g(e),_(e);for(let[t,r]of w){let i=e.get(t),l=i?.data!=null&&Array.from(i.data.values()).some(e=>e.values==null&&e.offlineOffsetSize!=null);if(i&&(!i.data||l)){s=i.valueOffset-c;let e=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);i.data=(await this._readIFD(e,n,r,4,a))?.ifd}}return l}return l.requiredBufferSize?(o=await this._fetchHeaderData(c,c+s+l.requiredBufferSize+8,a),o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=Math.max(s,o+this._bufferSize/4),n=await this._fetchHeaderData(o,e,r);i.forEach(e=>v(n,t,e,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchHeaderData(n[0],n[1]+n[0],r);v(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize;this._fileSize>0&&(t=Math.min(t,this._fileSize-1));let a=Math.ceil((t-e+1)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(this._fileSize===-1&&s[0].httpStatus===206){let e=s[0].getHeader?.(`Content-Range`),t=Number(e?.split(`/`)[1]);Number.isFinite(t)&&(this._fileSize=t)}if(s.length===1)return s[0].data;let c=s.reduce((e,t)=>e+t.data.byteLength,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(new Uint8Array(e.data),u),u+=e.data.byteLength;return l.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this.headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=y(c,s),u=b(c,`TILEOFFSETS`),d=b(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=x(c,`IMAGEWIDTH`),_=x(c,`IMAGELENGTH`),v=x(c,`TILEWIDTH`),S=x(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%v||v,actualTileHeight:t===m&&_%S||S}}async _fetchAllAuxData(e){if(this.ioConfig.skipMapInfo)return;let{rasterInfo:t}=this,{skipExtensions:n=[]}=this.ioConfig,r=n.includes(`aux.xml`)?Promise.resolve(null):this._fetchAuxiliaryMetaData(e),i=!n.includes(`vat.dbf`)&&t.bandCount===1&&t.pixelType===`u8`?this._fetchAuxiliaryTable(e):Promise.resolve(null),[a,o]=await Promise.all([r,i]);a!=null&&N(a,t),o!=null&&(t.attributeTable=o,t.keyProperties.DataType=`thematic`)}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?k.fromJSON(n.recordSet):null}catch{return null}}};e([r()],j.prototype,`_bufferSize`,void 0),e([r()],j.prototype,`_chunkSize`,void 0),e([r()],j.prototype,`_fileSize`,void 0),e([r()],j.prototype,`_headerChunks`,void 0),e([r({type:String,json:{write:!0}})],j.prototype,`datasetFormat`,void 0),e([r()],j.prototype,`headerInfo`,void 0),j=e([i(`esri.layers.raster.datasets.TIFFRaster`)],j);function M(e){let t=S(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:b,colormap:x}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,w=d(C),T=!!t.isPseudoGeographic;w??=(T=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:w}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:w}):new o({x:0,y:0}),j=new O({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),N=b?{BandProperties:b.bandProperties,DataType:b.dataType}:{},P=new D({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:w,isPseudoSpatialReference:T,keyProperties:N,extent:k,colormap:x,statistics:b?b.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:w}),P.transform=new E({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function N(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=T(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const P=j;export{P as default};