@arcgis/core 4.25.0-next.20220821 → 4.25.0-next.20220824

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 (165) hide show
  1. package/analysis/DimensioningAnalysis.d.ts +4 -0
  2. package/analysis/LengthDimension.d.ts +4 -0
  3. package/arcade/featureset/support/shared.js +1 -1
  4. package/arcade/kernel.js +1 -1
  5. package/arcade.js +1 -1
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/0455c2cc352743827b6f.js +1 -0
  8. package/assets/esri/core/workers/chunks/{da13db62d54cbca350c3.js → 2909c5e28c05ddb007a0.js} +1 -1
  9. package/assets/esri/core/workers/chunks/2a2cad4a163777419b88.js +1 -0
  10. package/assets/esri/core/workers/chunks/2c783124624070505cf9.js +1 -0
  11. package/assets/esri/core/workers/chunks/31eab53447f47774354e.js +1 -0
  12. package/assets/esri/core/workers/chunks/{9dbe94a70624a5592690.js → 3e108ee81b5684f81cea.js} +1 -1
  13. package/assets/esri/core/workers/chunks/40bb4e2acbe5c3323715.js +1 -0
  14. package/assets/esri/core/workers/chunks/45397532008f955faf6f.js +2 -0
  15. package/assets/esri/core/workers/chunks/45397532008f955faf6f.js.LICENSE.txt +20 -0
  16. package/assets/esri/core/workers/chunks/4e045b0b3f49fcdecce0.js +1 -0
  17. package/assets/esri/core/workers/chunks/616a20dfd38f25453765.js +1 -0
  18. package/assets/esri/core/workers/chunks/{94784576d519d2440184.js → 69b8fef9bd487b8fb7c9.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{32c7ea6e2068d5646988.js → 6e38ba64131c36edec43.js} +1 -1
  20. package/assets/esri/core/workers/chunks/6f99d0cdee66275cc68e.js +1 -0
  21. package/assets/esri/core/workers/chunks/{3485e2342f44e4d760a2.js → 70171492b13071b68db0.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{b81c0d35f169a7df25c0.js → 8543c2f0a0eb67b101d7.js} +1 -1
  23. package/assets/esri/core/workers/chunks/8ba83fee56dd4f306d87.js +1 -0
  24. package/assets/esri/core/workers/chunks/{0f1fae79b5311d55c0da.js → 92f10a6f8eae3ecf5ac2.js} +1 -1
  25. package/assets/esri/core/workers/chunks/96673467342935d3d99a.js +1 -0
  26. package/assets/esri/core/workers/chunks/9f9418e4b1c39fe4571d.js +1 -0
  27. package/assets/esri/core/workers/chunks/a507e85f388b0504bb6a.js +1 -0
  28. package/assets/esri/core/workers/chunks/{8c2c1909359d794ac8fa.js → b0afc51c778d752488c6.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{70dd8b67e69b084422a3.js → bfea5f112dc5bc08bb11.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{2407a32902f012997e6a.js → c12c6d10edb4953145fa.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{495dfd24894e8d5149c6.js → cfb3cfbc508840d2ea60.js} +1 -1
  32. package/assets/esri/core/workers/chunks/e8d0dbb6b6b241138fcf.js +1 -0
  33. package/assets/esri/core/workers/chunks/{a32c618ad62db6ecba67.js → e97ac86180a3381baf33.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ef174d2fbcca4c3844d7.js +1 -0
  35. package/assets/esri/core/workers/chunks/f2cca221d9bea32f7594.js +1 -0
  36. package/assets/esri/core/workers/chunks/ff729a122ddffd95a6b5.js +1 -0
  37. package/chunks/Clouds.glsl.js +12 -12
  38. package/core/PerformanceSampler.js +1 -1
  39. package/core/imageUtils.js +5 -0
  40. package/geometry/support/MeshTexture.js +1 -1
  41. package/geometry/support/meshUtils/exporters/gltf/buffer.js +1 -1
  42. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  43. package/geometry/support/meshUtils/exporters/gltf/imageutils.js +1 -1
  44. package/geometry/support/meshUtils/exporters/gltf/index.js +1 -1
  45. package/geometry/support/meshUtils/loadExternal.js +1 -1
  46. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  47. package/geometry/support/meshUtils/merge.js +1 -1
  48. package/geometry/support/meshUtils/offset.js +1 -1
  49. package/geometry/support/meshUtils/rotate.js +1 -1
  50. package/geometry/support/meshUtils/scale.js +1 -1
  51. package/interfaces.d.ts +147 -4
  52. package/layers/RouteLayer.js +1 -1
  53. package/layers/graphics/data/projectionSupport.js +1 -1
  54. package/layers/graphics/data/spatialQuerySupport.js +1 -1
  55. package/layers/graphics/data/utils.js +1 -1
  56. package/layers/graphics/featureConversionUtils.js +1 -1
  57. package/layers/ogc/crsUtils.js +1 -1
  58. package/layers/support/FieldsIndex.js +1 -1
  59. package/layers/support/PromiseQueue.js +1 -1
  60. package/layers/support/TileInfo.js +1 -1
  61. package/layers/support/infoFor3D.js +0 -1
  62. package/layers/support/mediaUtils.js +1 -1
  63. package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
  64. package/layers/support/rasterDatasets/pamParser.js +1 -1
  65. package/layers/support/rasterDatasets/wcsCapabilitiesParser.js +1 -1
  66. package/layers/support/rasterFunctions/AspectFunction.js +1 -1
  67. package/layers/support/rasterFunctions/BandArithmeticFunction.js +5 -0
  68. package/layers/support/rasterFunctions/BandArithmeticFunctionArguments.js +5 -0
  69. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  70. package/layers/support/rasterFunctions/ColormapFunction.js +1 -1
  71. package/layers/support/rasterFunctions/LocalFunction.js +5 -0
  72. package/layers/support/rasterFunctions/LocalFunctionArguments.js +5 -0
  73. package/layers/support/rasterFunctions/SlopeFunction.js +1 -1
  74. package/layers/support/rasterFunctions/StretchFunction.js +1 -1
  75. package/layers/support/rasterFunctions/bandIndexUtils.js +1 -1
  76. package/layers/support/rasterFunctions/customBandIndexUtils.js +5 -0
  77. package/layers/support/rasterFunctions/localUtils.js +1 -1
  78. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  79. package/layers/support/wmtsUtils.js +1 -1
  80. package/networks/Network.js +1 -1
  81. package/networks/UtilityNetwork.js +1 -1
  82. package/networks/support/NamedTraceConfiguration.js +1 -1
  83. package/package.json +3 -3
  84. package/portal/AssetMapFieldRole.js +5 -0
  85. package/renderers/DotDensityRenderer.js +1 -1
  86. package/renderers/support/utils.js +1 -1
  87. package/rest/networks/queryNamedTraceConfigurations.js +5 -0
  88. package/rest/networks/support/QueryNamedTraceConfigurationsParameters.js +5 -0
  89. package/rest/networks/support/QueryNamedTraceConfigurationsResult.js +5 -0
  90. package/rest/print.js +1 -1
  91. package/rest/support/GeneralizeParameters.js +1 -1
  92. package/rest/support/ImagePixelLocationParameters.js +1 -1
  93. package/rest/support/OffsetParameters.js +1 -1
  94. package/rest/support/PrintTemplate.js +1 -1
  95. package/rest/support/RelationParameters.js +1 -1
  96. package/rest/support/TopFeaturesQuery.js +1 -1
  97. package/rest/support/meshFeatureSet.js +1 -1
  98. package/support/revision.js +1 -1
  99. package/symbols/cim/GeometryWalker.js +1 -1
  100. package/symbols/cim/effects/EffectDashes.js +1 -1
  101. package/symbols/cim/effects/EffectWave.js +1 -1
  102. package/symbols/cim/placements/PlacementAlongLineSameSize.js +1 -1
  103. package/symbols/cim/placements/PlacementAtRatioPositions.js +1 -1
  104. package/views/2d/constraints/ZoomConstraint.js +1 -1
  105. package/views/2d/engine/Stage.js +1 -1
  106. package/views/2d/engine/webgl/mesh/templates/WGLDynamicMarkerTemplate.js +1 -1
  107. package/views/2d/engine/webgl/mesh/templates/WGLMarkerTemplate.js +1 -1
  108. package/views/2d/tiling/TileCache.js +1 -1
  109. package/views/2d/tiling/TileInfoView.js +1 -1
  110. package/views/3d/analysis/Dimensioning/LengthDimensionComputation.js +1 -1
  111. package/views/3d/analysis/Dimensioning/LengthDimensionSubTool.js +1 -1
  112. package/views/3d/analysis/Dimensioning/settings.js +1 -1
  113. package/views/3d/environment/CloudsComposition.js +1 -1
  114. package/views/3d/environment/CloudsCompositionParameters.js +1 -1
  115. package/views/3d/environment/CloudsData.js +1 -1
  116. package/views/3d/environment/CloudsGenerator.js +1 -1
  117. package/views/3d/environment/CloudsTechnique.js +1 -1
  118. package/views/3d/environment/CloudsTechniqueConfiguration.js +1 -1
  119. package/views/3d/layers/I3SMeshView3D.js +1 -1
  120. package/views/3d/support/StreamDataLoader.js +1 -1
  121. package/views/3d/support/earthUtils.js +1 -1
  122. package/views/3d/terrain/PatchGeometry.js +1 -1
  123. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  124. package/views/3d/terrain/PatchGeometryLUT.js +1 -1
  125. package/views/3d/terrain/TerrainSurface.js +1 -1
  126. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +2 -2
  127. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  128. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +22 -13
  129. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  130. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  131. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  132. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  133. package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
  134. package/views/LayerViewManager.js +1 -1
  135. package/views/ViewAnimation.js +1 -1
  136. package/views/interactive/editGeometry/operations/AppendVertex.js +1 -1
  137. package/views/interactive/editGeometry/operations/RemoveVertices.js +1 -1
  138. package/views/interactive/editGeometry/operations/SplitEdge.js +1 -1
  139. package/views/layers/MapImageLayerView.js +1 -1
  140. package/views/layers/support/Geometry.js +1 -1
  141. package/views/support/screenshotUtils.js +1 -1
  142. package/views/webgl/Measurement.js +1 -1
  143. package/views/webgl/TimerPool.js +5 -0
  144. package/views/webgl/capabilities/DisjointTimerQuery.js +1 -1
  145. package/widgets/Editor/EditorViewModel.js +1 -1
  146. package/widgets/Editor.js +1 -1
  147. package/widgets/FeatureForm/support/formTemplateUtils.js +1 -1
  148. package/assets/esri/core/workers/chunks/0c625803648e554f1fcf.js +0 -1
  149. package/assets/esri/core/workers/chunks/172c15e3dfa53554f591.js +0 -1
  150. package/assets/esri/core/workers/chunks/1e8e9967904da93c687e.js +0 -1
  151. package/assets/esri/core/workers/chunks/2efadbb06bf4a7f83f16.js +0 -1
  152. package/assets/esri/core/workers/chunks/30d7796ee6f7e4a6a3e1.js +0 -2
  153. package/assets/esri/core/workers/chunks/30d7796ee6f7e4a6a3e1.js.LICENSE.txt +0 -9
  154. package/assets/esri/core/workers/chunks/3281656a9bd3627e41ff.js +0 -1
  155. package/assets/esri/core/workers/chunks/3381b5454cd530cf940a.js +0 -1
  156. package/assets/esri/core/workers/chunks/4f4cb6d5b226ab5a38a1.js +0 -1
  157. package/assets/esri/core/workers/chunks/821a0754eae11421e56a.js +0 -1
  158. package/assets/esri/core/workers/chunks/8befbb2679e8285a8acd.js +0 -1
  159. package/assets/esri/core/workers/chunks/9e4c125d37ce66638b22.js +0 -1
  160. package/assets/esri/core/workers/chunks/a0750175b499a89fd07d.js +0 -1
  161. package/assets/esri/core/workers/chunks/c93d6bbe1af74d7bd7f9.js +0 -1
  162. package/assets/esri/core/workers/chunks/cc0a0782b8b9f6ec511e.js +0 -1
  163. package/assets/esri/core/workers/chunks/ef885b22ac8ec2695ad7.js +0 -1
  164. package/assets/esri/core/workers/chunks/f10379f663177a0150e9.js +0 -1
  165. package/assets/esri/core/workers/chunks/f351cccf879ba295acbc.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import has from"../../../../core/has.js";import{someMap as i}from"../../../../core/MapUtils.js";import{destroyMaybe as n,disposeMaybe as a,isSome as h,isNone as o,applySome as d,unwrap as _}from"../../../../core/maybe.js";import{watch as l,syncAndInitial as c,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as T,a as R,m as b}from"../../../../chunks/mat4.js";import{I as E,c as P}from"../../../../chunks/mat4f64.js";import{a as A}from"../../../../chunks/boundedPlane.js";import{MAXIMUM_ANIMATION_LOAD as S,MINIMUM_IDLE_ANIMATION_MS as C}from"../../support/animationUtils.js";import w from"../../support/debugFlags.js";import{RenderPassManager as O}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as D}from"../core/shaderLibrary/ShaderOutput.js";import{HUDTransparentRenderStyle as x}from"../core/shaderLibrary/hud/HUDUniforms.js";import{Decorations as I,RenderRequestType as y,StencilBits as H}from"./basicInterfaces.js";import{BoundingInfo as M}from"./BoundingInfo.js";import{ZERO as L,union as N}from"./depthRange.js";import{depthRangeFromScene as v}from"./depthRangeUtils.js";import{createEmptyDepthTexture as U}from"./glUtil3D.js";import{Highlight as j}from"./Highlight.js";import{RenderOccludedFlag as V}from"./Material.js";import{OffscreenRendering as G}from"./OffscreenRendering.js";import{RenderContext as q}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as F}from"./rendererUtils.js";import{RenderPluginManager as B}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Q}from"./ShadowHighlight.js";import{ShadowMap as Y,SnapshotSlot as X}from"./ShadowMap.js";import z from"./SliceHelper.js";import{SmaaRenderPass as J}from"./SmaaRenderPass.js";import{SSAOHelper as K}from"./SSAOHelper.js";import{TransparencyPassType as Z}from"./TransparencyPassType.js";import{EdgeView as $}from"./edgeRendering/EdgeView.js";import{Transparency as ee}from"./edgeRendering/interfaces.js";import{MergedRenderer as re}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as te}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as se,PerformanceCategory as ie}from"../statistics/RendererPerformanceInfo.js";import{ClearBufferBit as ne,PixelFormat as ae,PixelType as he}from"../../../webgl/enums.js";const oe=.9;let de=class extends r{constructor(e,r,t,i,n,a,h,o,d){super({}),this._materialRepository=e,this._shaderTechniqueRepository=t,this._rctx=i,this._compositingHelper=n,this._magnifierHelper=a,this._requestRender=h,this._stage=d,this._materialRenderers=new Map,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._content=new Map,this._isRendering=!1,this._fallbackDepthStencilTexture=null,this.performanceInfo=new se,this._antialiasing=!0,this._oitEnabled=!1,this._multipassTerrain=!0,this._transparentTerrain=!1,this._hasAnimations=!1,this._animationTimestep=g(0),this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new J(this._rctx,t),this._oitEnabled=this._hasOITSupport,this._requestRender(),this._offscreenRendering=new G(this._rctx,this._compositingHelper),this._sliceHelper=new z,this._shadowMap=new Y(this._rctx,d.viewingMode,2),this._ssaoHelper=new K(t,this._rctx,(()=>this._requestRender())),this._highlight=new j(t,this._rctx),this._shadowHighlight=new Q(this._rctx,d.viewingMode),this._shadowAccumulator=new W(this._rctx,t,d,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureCameraBindParameters(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t),this._renderShadowCascades(D.Shadow,e.shadowMap),e.camera.setGLViewport(this._rctx),this._ensureCameraBindParameters(e.camera,e.contentCamera)}),(()=>this._requestRender())),this._renderContext=new q(this._rctx,this._offscreenRendering,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new B({renderContext:this._renderContext,shaderTechniqueRepository:t,textureRep:r,materialRep:this._materialRepository,requestRender:this._requestRender,schedule:o}),this.renderPassManager=new O(this._rctx,this._shaderTechniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([l((()=>this._stage.state.camera),(()=>this._requestRender()),c),l((()=>w.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ee.TRANSPARENT):()=>{},this._requestRender()}),p)])}get _bindParameters(){return this._renderContext.bindParameters}get hasWater(){return this._hasWater||this._hasOverlayWater}get hasWaterReflection(){return this.hasWater&&this._waterReflectionEnabled}normalizeCtorArgs(){return{}}dispose(){this._handles.destroy(),this._smaaPass.dispose(),this._materialRenderers.forEach((e=>e.dispose())),this._materialRenderers.clear(),this._edgeView=n(this._edgeView),this._offscreenRendering.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.enabled=!1,this._shadowMap.dispose(),this._ssaoHelper.enabled=!1,this._ssaoHelper.dispose(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),M.prune(),this._content.clear()}disposeOffscreenBuffers(){this._offscreenRendering.dispose(),this._shadowMap.dispose(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||h(this._edgeView)&&this._edgeView.updating||this._shadowAccumulator.running||!this.isCameraFinal}ensureEdgeView(){return o(this._edgeView)&&(this._edgeView=new $({rctx:this._rctx,renderSR:this._stage.renderSR,viewingMode:this._stage.viewingMode,techniqueRepository:this._shaderTechniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:e=>this._stage.resourceController.schedule(e)}),this._handles.add(l((()=>d(this._edgeView,(e=>e.updating))),(()=>this._requestRender()),m)),this._requestRender()),this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return T(this._bindParameters.ssr.reprojectionMatrix,E)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setRenderParameters(e){const{_shadowMap:r,_ssaoHelper:t,_bindParameters:s}=this;if(void 0!==e.screenSpaceReflectionsEnabled&&s.ssr.enabled!==e.screenSpaceReflectionsEnabled&&(s.ssr.enabled=e.screenSpaceReflectionsEnabled,this._requestRender()),void 0!==e.shadowMap&&r.enabled!==e.shadowMap&&(r.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),h(e.environment)){h(e.environment.weather)&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=e.weatherVisible,this._renderContext.bindParameters.weather=e.environment.weather,this._renderContext.bindParameters.weatherVisible=e.weatherVisible),void 0!==e.environment.lighting.ambientOcclusionEnabled&&t.enabled!==e.environment.lighting.ambientOcclusionEnabled&&(t.enabled=e.environment.lighting.ambientOcclusionEnabled,this._requestRender()),void 0!==e.environment.lighting.waterReflectionEnabled&&this._waterReflectionEnabled!==e.environment.lighting.waterReflectionEnabled&&(this._waterReflectionEnabled=e.environment.lighting.waterReflectionEnabled,this._requestRender());const r="virtual"!==e.environment.lighting.type;s.enableFillLights!==r&&(s.enableFillLights=r,this._requestRender())}e.background&&this._offscreenRendering.background!==e.background&&(this._offscreenRendering.background=e.background,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasing!==e.antialiasingEnabled&&(this._antialiasing=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._multipassTerrain!==e.highQualityTransparency&&(this._multipassTerrain=e.highQualityTransparency,this._oitEnabled=e.highQualityTransparency&&this._hasOITSupport,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=_(e.slicePlane),this._requestRender()),void 0!==e.transparentTerrain&&this._transparentTerrain!==e.transparentTerrain&&(this._transparentTerrain=e.transparentTerrain,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlendWorking}modify(e){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:t,updates:s}=e;if(0===r.length&&0===t.length&&0===s.length)return;t.forAll((({id:e})=>this._content.delete(e))),r.forAll((e=>this._content.set(e.id,e)));const n=F(e);let a=!1;n.forEach(((e,r)=>{let t=this._materialRenderers.get(r);if(!t){if(!(e.adds.length>0))return;t=new re(this._rctx,this._materialRepository,r),this._materialRenderers.set(r,t)}t.modify(e),t.isEmpty&&(a=!0)})),a&&this._materialRenderers.forEach(((e,r)=>{e.isEmpty&&(this._materialRenderers.delete(r),e.dispose())})),this._hasHighlights=i(this._materialRenderers,(e=>e.hasHighlights)),this._bindParameters.hasOccludees=i(this._materialRenderers,(e=>e.hasOccludees)),this._hasWater=i(this._materialRenderers,(e=>e.hasWater)),this._needsTransparentPass=i(this._materialRenderers,(e=>e.requiresSlot(k.TRANSPARENT_MATERIAL,D.Color))),this._hasHUDElements=i(this._materialRenderers,(e=>e.requiresSlot(k.LINE_CALLOUTS_HUD_DEPTH,D.Color)||e.requiresSlot(k.HUD_MATERIAL,D.Color)||e.requiresSlot(k.LABEL_MATERIAL,D.Color))),this._requestRender()}updateAnimation(e){return this._hasAnimations=!1,this._materialRenderers.forEach((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations}get animationTimestep(){return this._animationTimestep}updateLightSources(e,r,t){this._bindParameters.lighting.groundLightingFactor=r,this._bindParameters.lighting.globalFactor=t,this._bindParameters.lighting.set(e)}render(e,r,t,s,i){this._isRendering=!0,this.performanceInfo.preRender(),this._bindParameters.transparencyPassType=Z.NONE;const n=this._offscreenRendering;n.needLastFrameColorTexture=this.hasWaterReflection,n.advanceCurrentRenderTarget();const a=A(this._sliceHelper.plane);i===I.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),t.setGLViewport(this._rctx),this._ensureCameraBindParameters(t,s),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ie.PREPARE);const d=this._computeDepthRange(t);this._renderShadowMap(e,t,this._bindParameters.lighting.lightingMainDirection,d),this.performanceInfo.advance(ie.SHADOW_MAP),n.initializeFrame(t),this._ensureBindParameters(t,s),this._renderLinearDepth(),this.performanceInfo.advance(ie.LINEAR_DEPTH),this._accumulateShadows(d,t,s),this.performanceInfo.advance(ie.ACCUMULATED_SHADOWS),this._renderNormal(),this.performanceInfo.advance(ie.NORMALS),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ie.OBJECT_AND_LAYER_ID_COLOR),this._ensureBindParametersSSR(),this._ssaoHelper.computeSSAO(this._bindParameters,n.linearDepthTexture,n.normalTexture),this.performanceInfo.advance(ie.SSAO),this._renderContext.output=D.Color,n.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ie.OPAQUE);const _=this._multipassTerrain&&this._transparentTerrain;this._renderTerrainLinearDepth(_),this._setMultipassEnabled(_),this._setTerrainCulling(_),this._renderEdges(ee.OPAQUE),this.performanceInfo.advance(ie.OPAQUE_EDGES),this._offscreenRendering.bindTarget(this._offscreenRendering.currentColorTarget,this._offscreenRendering.mainDepth),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ie.VOXEL),this._renderHiddenTransparentEdges();const l=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.TRANSPARENT),this._renderGeometryLinearDepth(_);const c=this._renderHUDVisibility();_||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ie.HUD_VISIBILITY),this._renderEdges(ee.TRANSPARENT,_),this.performanceInfo.advance(ie.TRANSPARENT_EDGES),this._renderTransparentTerrain(),this._transparentTerrain&&c&&(_?this._renderLineCallouts(x.Occluded):n.compositeTransparentTerrainOntoHUDVisibility(this._bindParameters),this._renderHUD(x.Occluded,n.framebuffer),this.performanceInfo.advance(ie.HUD_OCCLUDED)),this.performanceInfo.advance(ie.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),this._transparentTerrain&&(n.compositeTransparentTerrainOntoMain(this._bindParameters),_&&(this._renderEdges(ee.OPAQUE),this.performanceInfo.advance(ie.OPAQUE_EDGES),l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.TRANSPARENT),this._renderEdges(ee.TRANSPARENT),this.performanceInfo.advance(ie.TRANSPARENT_EDGES))),_&&this._renderLineCallouts(x.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),n.renderToTargets((()=>{this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES)}),n.currentColorTarget,n.mainDepth),this.performanceInfo.advance(ie.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl&&n.renderTmpAndCompositeToMain((()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL)),this._bindParameters,te.PremultipliedAlpha),this.performanceInfo.advance(ie.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ie.OCCLUDED);const p=i===I.ON&&this._magnifierHelper.enabled,m=p&&o(e)?this._offscreenRendering.getFramebuffer(this._offscreenRendering.tmpColor,this._offscreenRendering.tmpDepth):e;this._rctx.bindFramebuffer(m);const g=this._offscreenRendering.colorTexture;!this._renderAntiAliasing(g)&&h(g)&&this._compositingHelper.composite(this._bindParameters,g,te.None),this.performanceInfo.advance(ie.ANTIALIASING),this._renderHUD(x.NotOccluded,m),this.performanceInfo.advance(ie.HUD_NOT_OCCLUDED),this._renderHighlights(m,this._bindParameters),this.performanceInfo.advance(ie.HIGHLIGHTS),p&&this._magnifierHelper.render(this._rctx,this._bindParameters),m!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.tmpColorTexture,te.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=a,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.postRender()}_renderObjectAndLayerIdColor(e){h(e)&&has("enable-feature:objectAndLayerId-rendering")&&(this._rctx.bindFramebuffer(e),this._offscreenRendering.renderToFBO((()=>{this._renderGeometryAndTransparentTerrainPass(D.ObjectAndLayerIdColor)}),[0,0,0,0],!0,!0))}finish(e){if(this._hasAnimations||(this._animationTimestep=g(0)),e===y.BACKGROUND){this._rctx.gl.getError();const e=this.performanceInfo.elapsedTime/S;this._animationTimestep=g(Math.max(this._animationTimestep*oe+e*(1-oe),C))}}readDepthPixels(e,r,t){const s=this._offscreenRendering.bindTarget(this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ne.COLOR_BUFFER_BIT|ne.DEPTH_BUFFER_BIT|ne.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(D.Depth)}s.readPixels(r[0],r[1],r[2],r[3],ae.RGBA,he.UNSIGNED_BYTE,t)}readHUDVisibility(e,r,t,s,i){this._offscreenRendering.bindTarget(this._offscreenRendering.hudVisibility).readPixels(e,r,t,s,ae.RGBA,he.UNSIGNED_BYTE,i)}readAccumulatedShadow(e,r){return this._shadowAccumulator.readAccumulatedShadow(e,r)}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;h(t)&&t.shouldRender()&&this._offscreenRendering.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),this._bindParameters,te.Alpha,r)}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(D.ShadowHighlight,this._shadowMap,(e=>i.takeCascadeSnapshotTo(e,X.Highlight))),i.clear(),this._renderShadowCascades(D.ShadowExludeHighlight,this._shadowMap,(e=>{i.takeCascadeSnapshotTo(e,X.Default),this._renderGeometryAndTransparentTerrainPass(D.ShadowHighlight)}))):this._renderShadowCascades(D.Shadow),i.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.getCascades())s.camera.setGLViewport(this._rctx),this._ensureCameraBindParameters(s.camera,s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.enabled||this._renderPlugins.needsLinearDepth||this._hasWater&&this._waterReflectionEnabled||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreenRendering.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(D.Depth)),this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.linearDepth),this._bindParameters.linearDepthTexture=this._offscreenRendering.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=D.Depth,this._offscreenRendering.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreenRendering.terrainLinearDepth,this._offscreenRendering.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreenRendering.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.output;this._offscreenRendering.renderToTargets((()=>this._renderGeometryPass(D.Depth)),this._offscreenRendering.geometryLinearDepth,this._offscreenRendering.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreenRendering.geometryLinearDepthTexture}get _needsNormal(){return this._ssaoHelper.enabled}_renderNormal(){this._needsNormal?this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(D.Normal)}),this._offscreenRendering.normal,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.normal)}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return L;const r=v(e,this._content,this._stage.layers);return N(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(k.TRANSPARENT_TERRAIN)}_renderHUDVisibility(){let e=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,e=this._renderInternalSlot(k.OCCLUSION_PIXELS)}),this._multipassTerrain&&this._transparentTerrain),e}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===x.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderInternalSlot(k.LINE_CALLOUTS)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOrderIndependentTransparency((()=>this._renderHUDElements(e)),!0),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.hudColorTexture,te.PremultipliedAlpha)):e===x.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderHUDElements(x.Occluded)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this._needsHighlight}_renderHighlights(e,r){if(!this._needsHighlight)return void this._offscreenRendering.disposeTarget(this._offscreenRendering.highlight);const t=this._highlight,s=this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(D.Highlight),this._rctx.clearSafe(ne.DEPTH_BUFFER_BIT),this._renderHUDElements(x.Both)}),this._offscreenRendering.highlight,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this._needsShadowHighlight&&this._shadowHighlight.render(r,e),t.render(this._bindParameters,s,e)}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&this._shadowAccumulator.renderAccumulation(this._offscreenRendering.linearDepthTexture,e,r,t)}_renderOrderIndependentTransparency(e,r){const t=t=>{this._bindParameters.transparencyPassType=t,this._offscreenRendering.renderOITPass((()=>e()),t,r)},s=this._renderContext.output;this._renderContext.output=D.Alpha,t(Z.Alpha),this._renderContext.output=D.Color,t(Z.Color),t(Z.FrontFace),this._offscreenRendering.compositeTransparentOntoOpaque(this._bindParameters,r),this._bindParameters.transparencyPassType=Z.NONE,this._renderContext.output=s,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreenRendering.disposeTarget(this._offscreenRendering.alphaFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.colorFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.frontFaceTarget)),this._oitUsed=!1}_renderOccluded(){let e=0;this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&t.renderOccluded===V.OccludeAndTransparentStencil&&(e|=t.renderOccluded,ce.push(t))}));const r=this._offscreenRendering,t=(t,s,i,n,a)=>{0!=(e&s)&&(r.renderToTargets(i,r.tmpColor,r.mainDepth,[0,0,0,0],n,a),r.compositeOccludedOntoMain(this._bindParameters,t))};0!==ce.length&&(this._renderInternalSlot(k.OCCLUDER_MATERIAL,ce),t(.5,V.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1),ce.length=0),this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&(t.renderOccluded===V.OccludeAndTransparent||t.renderOccluded===V.Transparent||t.renderOccluded===V.Opaque)&&(e|=t.renderOccluded,le.push(t))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,s>V.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,le),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,le),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,le),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=D.Color,t(.5,V.OccludeAndTransparent,(()=>i(V.OccludeAndTransparent)),!0,H.OutlineVisualElementMask),t(.5,V.Transparent,(()=>i(V.Transparent)),!0,H.OutlineVisualElementMask),t(1,V.Opaque,(()=>i(V.Opaque)),!0,H.OutlineVisualElementMask),le.length=0}_renderAntiAliasing(e){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&h(e))return this._smaaPass.render(e),!0}else this._smaaPass.disable();return!1}_ensureCameraBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._ensureCameraBindParameters(e,r);const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.mainColorTexture=t.mainColorTexture,this._bindParameters.highlightDepthTexture=t.depthTexture??this._getFallbackDepthTexture()}_ensureBindParametersSSR(){this.hasWaterReflection?(this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=E:(R(me,this._bindParameters.camera.viewMatrix),R(pe,this._bindParameters.camera.projectionMatrix),b(ge,me,pe),b(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),b(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge),this._bindParameters.ssr.lastFrameColorTexture=this._offscreenRendering.lastFrameColorTexture):this._bindParameters.ssr.lastFrameColorTexture=null,this._bindParameters.ssr.enabled=this.hasWaterReflection}_renderInternalSlot(e,r){let t=!1;return this._bindParameters.slot=e,h(r)?r.forEach((e=>{if(!e.shouldRender(this._renderContext))return;const r=this._materialRenderers.get(e);h(r)&&(t=r.render(this._renderContext.output,this._bindParameters)||t)})):this._materialRenderers.forEach(((e,r)=>{r.shouldRender(this._renderContext)&&e.render(this._renderContext.output,this._bindParameters)&&(t=!0)})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=U(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){return{offscreen:this._offscreenRendering?.gpuMemoryUsage??0,highlights:(this._highlight?.gpuMemoryUsage??0)+(this._shadowHighlight?.gpuMemoryUsage??0),shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreenRendering,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,getFramebufferTexture:r=>{switch(r){case _e.Color:return e._offscreenRendering.colorTexture;case _e.LinearDepth:return e._offscreenRendering.linearDepthTexture;case _e.Normals:return e._offscreenRendering.normalTexture;case _e.ShadowMap:return e._shadowMap.depthTexture;case _e.HudVisibility:return e._offscreenRendering.hudVisibilityTexture;case _e.Highlight:return e._offscreenRendering.highlightTexture}}}}};var _e;e([u()],de.prototype,"_shadowAccumulator",void 0),e([u()],de.prototype,"_smaaPass",void 0),e([u()],de.prototype,"_antialiasing",void 0),e([u()],de.prototype,"_edgeView",void 0),e([u()],de.prototype,"updating",null),e([u()],de.prototype,"isCameraFinal",null),de=e([f("esri.views.3d.webgl-engine.lib.Renderer")],de),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(_e||(_e={}));const le=[],ce=[],pe=P(),me=P(),ge=P();export{_e as FramebufferId,de as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import has from"../../../../core/has.js";import{someMap as i}from"../../../../core/MapUtils.js";import{destroyMaybe as n,disposeMaybe as a,isSome as h,isNone as o,applySome as d,unwrap as _}from"../../../../core/maybe.js";import{watch as l,syncAndInitial as c,initial as p,sync as m}from"../../../../core/reactiveUtils.js";import{Milliseconds as g}from"../../../../core/time.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as T,a as R,m as b}from"../../../../chunks/mat4.js";import{I as E,c as P}from"../../../../chunks/mat4f64.js";import{a as A}from"../../../../chunks/boundedPlane.js";import{MAXIMUM_ANIMATION_LOAD as S,MINIMUM_IDLE_ANIMATION_MS as C}from"../../support/animationUtils.js";import w from"../../support/debugFlags.js";import{RenderPassManager as O}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as D}from"../core/shaderLibrary/ShaderOutput.js";import{HUDTransparentRenderStyle as x}from"../core/shaderLibrary/hud/HUDUniforms.js";import{Decorations as I,RenderRequestType as y,StencilBits as H}from"./basicInterfaces.js";import{BoundingInfo as M}from"./BoundingInfo.js";import{ZERO as L,union as N}from"./depthRange.js";import{depthRangeFromScene as v}from"./depthRangeUtils.js";import{createEmptyDepthTexture as U}from"./glUtil3D.js";import{Highlight as j}from"./Highlight.js";import{RenderOccludedFlag as V}from"./Material.js";import{OffscreenRendering as F}from"./OffscreenRendering.js";import{RenderContext as G}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as q}from"./rendererUtils.js";import{RenderPluginManager as B}from"./RenderPluginManager.js";import{RenderSlot as k}from"./RenderSlot.js";import{ShadowAccumulator as W}from"./ShadowAccumulator.js";import{ShadowHighlight as Q}from"./ShadowHighlight.js";import{ShadowMap as Y,SnapshotSlot as X}from"./ShadowMap.js";import z from"./SliceHelper.js";import{SmaaRenderPass as J}from"./SmaaRenderPass.js";import{SSAOHelper as K}from"./SSAOHelper.js";import{TransparencyPassType as Z}from"./TransparencyPassType.js";import{EdgeView as $}from"./edgeRendering/EdgeView.js";import{Transparency as ee}from"./edgeRendering/interfaces.js";import{MergedRenderer as re}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as te}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as se,PerformanceCategory as ie}from"../statistics/RendererPerformanceInfo.js";import{ClearBufferBit as ne,PixelFormat as ae,PixelType as he}from"../../../webgl/enums.js";const oe=.9;let de=class extends r{constructor(e,r,t,i,n,a,h,o,d){super({}),this._materialRepository=e,this._shaderTechniqueRepository=t,this._rctx=i,this._compositingHelper=n,this._magnifierHelper=a,this._requestRender=h,this._stage=d,this._materialRenderers=new Map,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._content=new Map,this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new z,this._antialiasing=!0,this._oitEnabled=!1,this._multipassTerrain=!0,this._transparentTerrain=!1,this._hasAnimations=!1,this._animationTimestep=g(0),this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new J(this._rctx,t),this._oitEnabled=this._hasOITSupport,this._requestRender(),this._offscreenRendering=new F(this._rctx,this._compositingHelper),this.performanceInfo=new se(this._rctx),this._shadowMap=new Y(this._rctx,d.viewingMode,2),this._ssaoHelper=new K(t,this._rctx,(()=>this._requestRender())),this._highlight=new j(t,this._rctx),this._shadowHighlight=new Q(this._rctx,d.viewingMode),this._shadowAccumulator=new W(this._rctx,t,d,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureCameraBindParameters(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t),this._renderShadowCascades(D.Shadow,e.shadowMap),e.camera.setGLViewport(this._rctx),this._ensureCameraBindParameters(e.camera,e.contentCamera)}),(()=>this._requestRender())),this._renderContext=new G(this._rctx,this._offscreenRendering,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new B({renderContext:this._renderContext,shaderTechniqueRepository:t,textureRep:r,materialRep:this._materialRepository,requestRender:this._requestRender,schedule:o}),this.renderPassManager=new O(this._rctx,this._shaderTechniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([l((()=>this._stage.state.camera),(()=>this._requestRender()),c),l((()=>w.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ee.TRANSPARENT):()=>{},this._requestRender()}),p)])}get _bindParameters(){return this._renderContext.bindParameters}get hasWater(){return this._hasWater||this._hasOverlayWater}get hasWaterReflection(){return this.hasWater&&this._waterReflectionEnabled}normalizeCtorArgs(){return{}}dispose(){this._handles.destroy(),this._smaaPass.dispose(),this._materialRenderers.forEach((e=>e.dispose())),this._materialRenderers.clear(),this._edgeView=n(this._edgeView),this._offscreenRendering.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.enabled=!1,this._shadowMap.dispose(),this._ssaoHelper.enabled=!1,this._ssaoHelper.dispose(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),M.prune(),this._content.clear()}disposeOffscreenBuffers(){this._offscreenRendering.dispose(),this._shadowMap.dispose(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||h(this._edgeView)&&this._edgeView.updating||this._shadowAccumulator.running||!this.isCameraFinal}ensureEdgeView(){return o(this._edgeView)&&(this._edgeView=new $({rctx:this._rctx,renderSR:this._stage.renderSR,viewingMode:this._stage.viewingMode,techniqueRepository:this._shaderTechniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:e=>this._stage.resourceController.schedule(e)}),this._handles.add(l((()=>d(this._edgeView,(e=>e.updating))),(()=>this._requestRender()),m)),this._requestRender()),this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return T(this._bindParameters.ssr.reprojectionMatrix,E)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setRenderParameters(e){const{_shadowMap:r,_ssaoHelper:t,_bindParameters:s}=this;if(void 0!==e.screenSpaceReflectionsEnabled&&s.ssr.enabled!==e.screenSpaceReflectionsEnabled&&(s.ssr.enabled=e.screenSpaceReflectionsEnabled,this._requestRender()),void 0!==e.shadowMap&&r.enabled!==e.shadowMap&&(r.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),h(e.environment)){h(e.environment.weather)&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=e.weatherVisible,this._renderContext.bindParameters.weather=e.environment.weather,this._renderContext.bindParameters.weatherVisible=e.weatherVisible),void 0!==e.environment.lighting.ambientOcclusionEnabled&&t.enabled!==e.environment.lighting.ambientOcclusionEnabled&&(t.enabled=e.environment.lighting.ambientOcclusionEnabled,this._requestRender()),void 0!==e.environment.lighting.waterReflectionEnabled&&this._waterReflectionEnabled!==e.environment.lighting.waterReflectionEnabled&&(this._waterReflectionEnabled=e.environment.lighting.waterReflectionEnabled,this._requestRender());const r="virtual"!==e.environment.lighting.type;s.enableFillLights!==r&&(s.enableFillLights=r,this._requestRender())}e.background&&this._offscreenRendering.background!==e.background&&(this._offscreenRendering.background=e.background,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasing!==e.antialiasingEnabled&&(this._antialiasing=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._multipassTerrain!==e.highQualityTransparency&&(this._multipassTerrain=e.highQualityTransparency,this._oitEnabled=e.highQualityTransparency&&this._hasOITSupport,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=_(e.slicePlane),this._requestRender()),void 0!==e.transparentTerrain&&this._transparentTerrain!==e.transparentTerrain&&(this._transparentTerrain=e.transparentTerrain,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlendWorking}modify(e){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:r,removes:t,updates:s}=e;if(0===r.length&&0===t.length&&0===s.length)return;t.forAll((({id:e})=>this._content.delete(e))),r.forAll((e=>this._content.set(e.id,e)));const n=q(e);let a=!1;n.forEach(((e,r)=>{let t=this._materialRenderers.get(r);if(!t){if(!(e.adds.length>0))return;t=new re(this._rctx,this._materialRepository,r),this._materialRenderers.set(r,t)}t.modify(e),t.isEmpty&&(a=!0)})),a&&this._materialRenderers.forEach(((e,r)=>{e.isEmpty&&(this._materialRenderers.delete(r),e.dispose())})),this._hasHighlights=i(this._materialRenderers,(e=>e.hasHighlights)),this._bindParameters.hasOccludees=i(this._materialRenderers,(e=>e.hasOccludees)),this._hasWater=i(this._materialRenderers,(e=>e.hasWater)),this._needsTransparentPass=i(this._materialRenderers,(e=>e.requiresSlot(k.TRANSPARENT_MATERIAL,D.Color))),this._hasHUDElements=i(this._materialRenderers,(e=>e.requiresSlot(k.LINE_CALLOUTS_HUD_DEPTH,D.Color)||e.requiresSlot(k.HUD_MATERIAL,D.Color)||e.requiresSlot(k.LABEL_MATERIAL,D.Color))),this._requestRender()}updateAnimation(e){return this._hasAnimations=!1,this._materialRenderers.forEach((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations}get animationTimestep(){return this._animationTimestep}updateLightSources(e,r,t){this._bindParameters.lighting.groundLightingFactor=r,this._bindParameters.lighting.globalFactor=t,this._bindParameters.lighting.set(e)}render(e,r,t,s,i){this._isRendering=!0,this.performanceInfo.startFrame(),this._bindParameters.transparencyPassType=Z.NONE;const n=this._offscreenRendering;n.setupRenderTarget(this.hasWaterReflection);const a=A(this._sliceHelper.plane);i===I.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),t.setGLViewport(this._rctx),this._ensureCameraBindParameters(t,s),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ie.PREPARE);const d=this._computeDepthRange(t);this._renderShadowMap(e,t,this._bindParameters.lighting.lightingMainDirection,d),this.performanceInfo.advance(ie.SHADOW_MAP),n.initializeFrame(t),this._ensureBindParameters(t,s),this._renderLinearDepth(),this.performanceInfo.advance(ie.LINEAR_DEPTH),this._accumulateShadows(d,t,s),this.performanceInfo.advance(ie.ACCUMULATED_SHADOWS),this._renderNormal(),this.performanceInfo.advance(ie.NORMALS),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ie.OBJECT_AND_LAYER_ID_COLOR),this._ensureBindParametersSSR(),this._ssaoHelper.computeSSAO(this._bindParameters,n.linearDepthTexture,n.normalTexture),this.performanceInfo.advance(ie.SSAO),this._renderContext.output=D.Color,n.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ie.OPAQUE);const _=this._multipassTerrain&&this._transparentTerrain;this._renderTerrainLinearDepth(_),this._setMultipassEnabled(_),this._setTerrainCulling(_),this._renderEdges(ee.OPAQUE),this.performanceInfo.advance(ie.OPAQUE_EDGES),this._offscreenRendering.bindTarget(this._offscreenRendering.currentColorTarget,this._offscreenRendering.mainDepth),this._renderSlot(k.VOXEL),this.performanceInfo.advance(ie.VOXEL),this._renderHiddenTransparentEdges();const l=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.TRANSPARENT),this._renderGeometryLinearDepth(_);const c=this._renderHUDVisibility();_||this._renderInternalSlot(k.LINE_CALLOUTS),this.performanceInfo.advance(ie.HUD_VISIBILITY),this._renderEdges(ee.TRANSPARENT,_),this.performanceInfo.advance(ie.TRANSPARENT_EDGES),this._renderTransparentTerrain(),this._transparentTerrain&&c&&(_?this._renderLineCallouts(x.Occluded):n.compositeTransparentTerrainOntoHUDVisibility(this._bindParameters),this._renderHUD(x.Occluded,n.framebuffer),this.performanceInfo.advance(ie.HUD_OCCLUDED)),this.performanceInfo.advance(ie.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),this._transparentTerrain&&(n.compositeTransparentTerrainOntoMain(this._bindParameters),_&&(this._renderEdges(ee.OPAQUE),this.performanceInfo.advance(ie.OPAQUE_EDGES),l&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ie.TRANSPARENT),this._renderEdges(ee.TRANSPARENT),this.performanceInfo.advance(ie.TRANSPARENT_EDGES))),_&&this._renderLineCallouts(x.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),n.renderToTargets((()=>{this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(k.LASERLINES)}),n.currentColorTarget,n.mainDepth),this.performanceInfo.advance(ie.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl&&n.renderTmpAndCompositeToMain((()=>this._renderSlot(k.LASERLINES_CONTRAST_CONTROL)),this._bindParameters,te.PremultipliedAlpha),this.performanceInfo.advance(ie.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ie.OCCLUDED);const p=i===I.ON&&this._magnifierHelper.enabled,m=p&&o(e)?this._offscreenRendering.getFramebuffer(this._offscreenRendering.tmpColor,this._offscreenRendering.tmpDepth):e;this._rctx.bindFramebuffer(m);const g=this._offscreenRendering.colorTexture;!this._renderAntiAliasing(g)&&h(g)&&this._compositingHelper.composite(this._bindParameters,g,te.None),this.performanceInfo.advance(ie.ANTIALIASING),this._renderHUD(x.NotOccluded,m),this.performanceInfo.advance(ie.HUD_NOT_OCCLUDED),this._renderHighlights(m,this._bindParameters),this.performanceInfo.advance(ie.HIGHLIGHTS),p&&this._magnifierHelper.render(this._rctx,this._bindParameters),m!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.tmpColorTexture,te.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=a,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_renderObjectAndLayerIdColor(e){h(e)&&has("enable-feature:objectAndLayerId-rendering")&&(this._rctx.bindFramebuffer(e),this._offscreenRendering.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(D.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0))}finish(e){if(this._hasAnimations||(this._animationTimestep=g(0)),e===y.BACKGROUND){this._rctx.gl.getError();const e=this.performanceInfo.elapsedTime/S;this._animationTimestep=g(Math.max(this._animationTimestep*oe+e*(1-oe),C))}}readDepthPixels(e,r,t){const s=this._offscreenRendering.bindTarget(this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ne.COLOR_BUFFER_BIT|ne.DEPTH_BUFFER_BIT|ne.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(D.Depth)}s.readPixels(r[0],r[1],r[2],r[3],ae.RGBA,he.UNSIGNED_BYTE,t)}readHUDVisibility(e,r,t,s,i){this._offscreenRendering.bindTarget(this._offscreenRendering.hudVisibility).readPixels(e,r,t,s,ae.RGBA,he.UNSIGNED_BYTE,i)}readAccumulatedShadow(e,r){return this._shadowAccumulator.readAccumulatedShadow(e,r)}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;h(t)&&t.shouldRender()&&this._offscreenRendering.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),this._bindParameters,te.Alpha,r)}_renderShadowMap(e,r,t,s){const i=this._shadowMap;i.enabled&&(i.start(r,t,s),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(D.ShadowHighlight,this._shadowMap,(e=>i.takeCascadeSnapshotTo(e,X.Highlight))),i.clear(),this._renderShadowCascades(D.ShadowExludeHighlight,this._shadowMap,(e=>{i.takeCascadeSnapshotTo(e,X.Default),this._renderGeometryAndTransparentTerrainPass(D.ShadowHighlight)}))):this._renderShadowCascades(D.Shadow),i.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.getCascades())s.camera.setGLViewport(this._rctx),this._ensureCameraBindParameters(s.camera,s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.enabled||this._renderPlugins.needsLinearDepth||this._hasWater&&this._waterReflectionEnabled||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreenRendering.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(D.Depth)),this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.linearDepth),this._bindParameters.linearDepthTexture=this._offscreenRendering.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=D.Depth,this._offscreenRendering.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreenRendering.terrainLinearDepth,this._offscreenRendering.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreenRendering.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.output;this._offscreenRendering.renderToTargets((()=>this._renderGeometryPass(D.Depth)),this._offscreenRendering.geometryLinearDepth,this._offscreenRendering.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreenRendering.geometryLinearDepthTexture}get _needsNormal(){return this._ssaoHelper.enabled}_renderNormal(){this._needsNormal?this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(D.Normal)}),this._offscreenRendering.normal,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.normal)}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return L;const r=v(e,this._content,this._stage.layers);return N(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderOpaqueGeometry(){this._renderSlot(k.INTEGRATED_MESH),this._renderSlot(k.OPAQUE_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.OPAQUE_MATERIAL),this._renderSlot(k.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(k.TRANSPARENT_MATERIAL),this._renderSlot(k.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(k.TRANSPARENT_TERRAIN)}_renderHUDVisibility(){let e=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,e=this._renderInternalSlot(k.OCCLUSION_PIXELS)}),this._multipassTerrain&&this._transparentTerrain),e}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===x.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderInternalSlot(k.LINE_CALLOUTS)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderInternalSlot(k.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOrderIndependentTransparency((()=>this._renderHUDElements(e)),!0),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.hudColorTexture,te.PremultipliedAlpha)):e===x.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderHUDElements(x.Occluded)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._renderInternalSlot(k.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(k.HUD_MATERIAL),this._renderInternalSlot(k.LABEL_MATERIAL)}get _needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this._needsHighlight}_renderHighlights(e,r){if(!this._needsHighlight)return void this._offscreenRendering.disposeTarget(this._offscreenRendering.highlight);const t=this._highlight,s=this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(D.Highlight),this._rctx.clearSafe(ne.DEPTH_BUFFER_BIT),this._renderHUDElements(x.Both)}),this._offscreenRendering.highlight,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this._needsShadowHighlight&&this._shadowHighlight.render(r,e),t.render(this._bindParameters,s,e)}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&this._shadowAccumulator.renderAccumulation(this._offscreenRendering.linearDepthTexture,e,r,t)}_renderOrderIndependentTransparency(e,r){const t=t=>{this._bindParameters.transparencyPassType=t,this._offscreenRendering.renderOITPass((()=>e()),t,r)},s=this._renderContext.output;this._renderContext.output=D.Alpha,t(Z.Alpha),this._renderContext.output=D.Color,t(Z.Color),t(Z.FrontFace),this._offscreenRendering.compositeTransparentOntoOpaque(this._bindParameters,r),this._bindParameters.transparencyPassType=Z.NONE,this._renderContext.output=s,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreenRendering.disposeTarget(this._offscreenRendering.alphaFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.colorFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.frontFaceTarget)),this._oitUsed=!1}_renderOccluded(){let e=0;this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&t.renderOccluded===V.OccludeAndTransparentStencil&&(e|=t.renderOccluded,ce.push(t))}));const r=this._offscreenRendering,t=(t,s,i,n,a)=>{0!=(e&s)&&(r.renderToTargets(i,r.tmpColor,r.mainDepth,[0,0,0,0],n,a),r.compositeOccludedOntoMain(this._bindParameters,t))};0!==ce.length&&(this._renderInternalSlot(k.OCCLUDER_MATERIAL,ce),t(.5,V.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(k.TRANSPARENT_OCCLUDER_MATERIAL,ce)),!1,!1),ce.length=0),this._materialRenderers.forEach(((r,t)=>{t&&t.isVisible()&&(t.renderOccluded===V.OccludeAndTransparent||t.renderOccluded===V.Transparent||t.renderOccluded===V.Opaque)&&(e|=t.renderOccluded,le.push(t))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,s>V.Occlude&&this._renderSlot(k.OCCLUDED_TERRAIN),this._renderInternalSlot(k.OPAQUE_MATERIAL,le),this._renderInternalSlot(k.TRANSPARENT_MATERIAL,le),this._renderInternalSlot(k.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,le),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=D.Color,t(.5,V.OccludeAndTransparent,(()=>i(V.OccludeAndTransparent)),!0,H.OutlineVisualElementMask),t(.5,V.Transparent,(()=>i(V.Transparent)),!0,H.OutlineVisualElementMask),t(1,V.Opaque,(()=>i(V.Opaque)),!0,H.OutlineVisualElementMask),le.length=0}_renderAntiAliasing(e){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&h(e))return this._smaaPass.render(e),!0}else this._smaaPass.disable();return!1}_ensureCameraBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._ensureCameraBindParameters(e,r);const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.mainColorTexture=t.mainColorTexture,this._bindParameters.highlightDepthTexture=t.depthTexture??this._getFallbackDepthTexture()}_ensureBindParametersSSR(){this.hasWaterReflection?(this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=E:(R(me,this._bindParameters.camera.viewMatrix),R(pe,this._bindParameters.camera.projectionMatrix),b(ge,me,pe),b(ge,this._renderContext.lastFrameCamera.viewMatrix,ge),b(ge,this._renderContext.lastFrameCamera.projectionMatrix,ge),this._reprojectionMatrix=ge),this._bindParameters.ssr.lastFrameColorTexture=this._offscreenRendering.lastFrameColorTexture):this._bindParameters.ssr.lastFrameColorTexture=null,this._bindParameters.ssr.enabled=this.hasWaterReflection}_renderInternalSlot(e,r){let t=!1;return this._bindParameters.slot=e,h(r)?r.forEach((e=>{if(!e.shouldRender(this._renderContext))return;const r=this._materialRenderers.get(e);h(r)&&(t=r.render(this._renderContext.output,this._bindParameters)||t)})):this._materialRenderers.forEach(((e,r)=>{r.shouldRender(this._renderContext)&&e.render(this._renderContext.output,this._bindParameters)&&(t=!0)})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=U(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){return{offscreen:this._offscreenRendering?.gpuMemoryUsage??0,highlights:(this._highlight?.gpuMemoryUsage??0)+(this._shadowHighlight?.gpuMemoryUsage??0),shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreenRendering,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,getFramebufferTexture:r=>{switch(r){case _e.Color:return e._offscreenRendering.colorTexture;case _e.LinearDepth:return e._offscreenRendering.linearDepthTexture;case _e.Normals:return e._offscreenRendering.normalTexture;case _e.ShadowMap:return e._shadowMap.depthTexture;case _e.HudVisibility:return e._offscreenRendering.hudVisibilityTexture;case _e.Highlight:return e._offscreenRendering.highlightTexture}}}}};var _e;e([u()],de.prototype,"_shadowAccumulator",void 0),e([u()],de.prototype,"_smaaPass",void 0),e([u()],de.prototype,"_antialiasing",void 0),e([u()],de.prototype,"_edgeView",void 0),e([u()],de.prototype,"updating",null),e([u()],de.prototype,"isCameraFinal",null),de=e([f("esri.views.3d.webgl-engine.lib.Renderer")],de),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(_e||(_e={}));const le=[],ce=[],pe=P(),me=P(),ge=P();export{_e as FramebufferId,de as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e}from"../../../../../core/maybe.js";import{isAborted as t,throwIfAborted as a}from"../../../../../core/promiseUtils.js";import{c as s}from"../../../../../chunks/mat4f64.js";import{b as n,e as i,m as r}from"../../../../../chunks/vec3.js";import{c as o}from"../../../../../chunks/vec3f64.js";import{c as l,f as c}from"../../../../../chunks/vec4f64.js";import h from"../../../support/debugFlags.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{ShaderOutput as u}from"../../core/shaderLibrary/ShaderOutput.js";import{Camera as _}from"../Camera.js";import{Default3D as m}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as f}from"../IntersectorInterfaces.js";import p from"../Octree.js";import{RenderSlot as g}from"../RenderSlot.js";import{assert as C}from"../Util.js";import{InstanceData as I,StateFlags as D}from"./InstanceData.js";import{InstanceOctree as y}from"./InstanceOctree.js";import{LevelSelector as v}from"./LevelSelector.js";import{LodLevel as b}from"./LodLevel.js";import{RenderInstanceData as R}from"./RenderInstanceData.js";import{getInstanceBufferLayout as E}from"../../materials/DefaultMaterial.js";import{colorMixModes as A}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as L}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as T}from"../../shaders/DefaultMaterialTechnique.js";import{bindVertexBufferLayout as S,unbindVertexBufferLayout as O}from"../../../../webgl/Util.js";let U=e=>{const t=e.baseBoundingSphere.radius,a=e.levels.map((e=>e.minScreenSpaceRadius));return new v(t,a)};function j(e){U=e}class x{constructor(e,t,a,s){this.type=f.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=[],this._highlightRenderInstanceData=[],this._instanceIndex=0,this._slicePlane=!1,this._enableLevelSelection=!0,this._lastCamera=new _,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.slots=[g.OPAQUE_MATERIAL,g.TRANSPARENT_MATERIAL],this.canRender=!0,this._symbol=e,this._optionalFields=t,this._metadata=a,this._instanceBufferLayout=E({instancedDoublePrecision:!0,instanced:t}),this._glInstanceBufferLayout=d(this._instanceBufferLayout,1),this._instanceData=new I(this._optionalFields,s),this._instanceData.on("instance-added",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-removed",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-transform-changed",(e=>{this._requestUpdateCycle(),this._metadata.notifyGraphicGeometryChanged(e.index)})),this._instanceData.on("instance-visibility-changed",(e=>{this._requestUpdateCycle(!0),this._metadata.notifyGraphicVisibilityChanged(e.index)})),this._instanceData.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0))),this._enableLevelSelection=this._symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this._metadata.layerUid}get instanceData(){return this._instanceData}get memoryUsage(){const e={cpu:0,gpu:0};return this._defaultRenderInstanceData.forEach((t=>{const a=t.memoryUsage;e.cpu+=a.cpu,e.gpu+=a.gpu})),this._highlightRenderInstanceData.forEach((t=>{const a=t.memoryUsage;e.cpu+=a.cpu,e.gpu+=a.gpu})),e}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,a)=>{const s=this._defaultRenderInstanceData[a],n=this._highlightRenderInstanceData[a],i=s.size+n.size,r=e.triangleCount;t.push({renderedInstances:i,renderedTriangles:i*r,trianglesPerInstance:r})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,s){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this._symbol.levels.map((t=>(this._defaultRenderInstanceData.push(new R(n,this._instanceBufferLayout)),this._highlightRenderInstanceData.push(new R(n,this._instanceBufferLayout)),b.create(e,t,s))))),r=i.map((e=>"fulfilled"===e.status?e.value:null)).filter((e=>e));if(t(s)||r.length!==i.length){r.forEach((e=>e.destroy())),a(s);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=r,this._levelSelector=U(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceData.forEach((e=>e.destroy()))}get needsTransparentPass(){return this._levels.some((e=>e.components.some((e=>e.material.requiresSlot(g.TRANSPARENT_MATERIAL,u.Color)))))}get needsHighlight(){return this._highlightRenderInstanceData.some((e=>e.size>0))}prepareRender(e){if(h.LOD_INSTANCE_RENDERER_DISABLE_UPDATES)return;if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._lastCamera);this._lastCamera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}const t=this._needFullCycle?this._instanceData.size:2e3;this._needFullCycle=!1,this._updateInstances(e.bindParameters.contentCamera,t),this._needsUpdates&&this._context.requestRender()}render(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return;e.rctx.bindVAO();e.output!==u.Highlight&&e.output!==u.ShadowHighlight&&this._renderComponents(e,this._defaultRenderInstanceData);e.output!==u.ShadowExludeHighlight&&this._renderComponents(e,this._highlightRenderInstanceData)}intersect(e,t,a,s){if(!this.baseMaterial.isVisible())return;const i=o();n(i,s,a);const l=n=>{this._instanceData.getCombinedModelTransform(n,N),e.transform.set(N),r(q,a,e.transform.inverse),r(H,s,e.transform.inverse);const i=this._instanceData.getState(n),o=this._instanceData.getLodLevel(n),l=this._levels.length;C(i&D.ACTIVE,"invalid instance state"),C(o>=0&&o<l,"invaid lod level"),this._levels[o].intersect(e,t,q,H,n,this._metadata,l)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(l):this._octree.forEachAlongRay(a,i,l)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree()}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,e&&(this._needFullCycle=!0),this._needsUpdates&&this._context.requestRender()}get _needsUpdates(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}get _octree(){return this._octreeCached||(this._octreeCached=this._buildOctree()),this._octreeCached}_invalidateOctree(){this._octreeCached&&(this._octreeCached.destroy(),this._octreeCached=null)}_buildOctree(){const e=new y(this._instanceData,this.baseBoundingSphere),t=this._instanceData,a=t.view?t.view.state:null;for(let s=0;s<this._instanceData.capacity;++s){a.get(s)&D.ACTIVE&&e.addInstance(s)}return e}_queryDepthRangeOctree(e){const t=e.eye,a=e.viewForward,s=this._octree.findClosest(a,p.DepthOrder.FRONT_TO_BACK,e.frustum),r=this._octree.findClosest(a,p.DepthOrder.BACK_TO_FRONT,e.frustum);if(null!=s&&null!=r){this._instanceData.view.boundingSphere.getVec(s,w),n(w,w,t);const o=i(w,a)-w[3];this._instanceData.view.boundingSphere.getVec(r,w),n(w,w,t);const l=i(w,a)+w[3];return{near:Math.max(e.near,o),far:Math.min(e.far,l)}}return{near:1/0,far:-1/0}}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._defaultRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this._highlightRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this._needsUpdates&&this._context.requestRender()}_updateInstances(e,t){const a=this._enableLevelSelection,s=this._levelSelector;s.updateCamera(e),this._defaultRenderInstanceData.forEach((e=>{e.beginUpdate()})),this._highlightRenderInstanceData.forEach((e=>{e.beginUpdate()}));const n=this._instanceData,i=this._instanceData.view,r=n.size,o=n.capacity;let l=this._instanceIndex;t=Math.min(r,t);for(let c=0;c<t;++c){0===l&&this._startUpdateCycle();const e=i.state.get(l);let r=0;if(!(e&D.ALLOCATED)){l=l+1===o?0:l+1,t++;continue}const c=i.lodLevel.get(l);if(e&D.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[c].freeTail(),e&D.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[c].freeTail(),e&D.REMOVE)n.freeInstance(l);else if(e&D.VISIBLE){let t=0;a&&(i.modelOrigin.getVec(l,F),t=s.selectLevel(F,n.getCombinedMedianScaleFactor(l))),r=e&~(D.ACTIVE|D.TRANSFORM_CHANGED),t>=0&&(e&D.HIGHLIGHT?(M(this._highlightRenderInstanceData[t],i,l),r|=D.HIGHLIGHT_ACTIVE):(M(this._defaultRenderInstanceData[t],i,l),r|=D.DEFAULT_ACTIVE)),i.state.set(l,r),i.lodLevel.set(l,t)}else r=e&~(D.ACTIVE|D.TRANSFORM_CHANGED),i.state.set(l,r);if(this._octreeCached){const t=!!(e&D.ACTIVE),a=!!(r&D.ACTIVE);!t&&a?this._octreeCached.addInstance(l):t&&!a?this._octreeCached.removeInstance(l):t&&a&&e&D.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1}this._instanceIndex=l,this._defaultRenderInstanceData.forEach((e=>{e.endUpdate()})),this._highlightRenderInstanceData.forEach((e=>{e.endUpdate()}))}_renderComponents(e,t){this.levels.forEach(((a,s)=>{a.components.forEach((a=>{this._renderComponent(e,t[s],a,s)}))}))}_renderComponent(t,a,s,n){const{bindParameters:i,rctx:r,output:o}=t;if(0===a.size||!s.material.requiresSlot(i.slot,t.output))return;const l=s.glMaterials.load(r,i.slot,o);if(e(l))return;const c=l.beginSlot(i),d=r.bindTechnique(c,s.material.parameters,i);r.bindVAO(s.vao),c.ensureAttributeLocations(s.vao),d.bindDraw(P,i,s.material.parameters),h.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&t.output===u.Color&&(d.setUniform4fv("externalColor",B[Math.min(n,B.length-1)]),d.setUniform1i("colorMixMode",A.replace));const _=r.capabilities.instancing,f=a.capacity,p=a.headIndex,g=a.tailIndex,I=a.firstIndex,D=this._glInstanceBufferLayout,y=(e,t)=>{S(r,m,a.buffer,D,e),_.drawArraysInstanced(c.primitiveType,0,s.vertexCount,t-e),O(r,m,a.buffer,D)};s.material.parameters.transparent&&null!=I?p>g?(C(I>=g&&I<=p,"invalid firstIndex"),y(I,p),y(g,I)):p<g&&(I<=p?(C(I>=0&&I<=p,"invalid firstIndex"),y(I,p),y(g,f),y(0,I)):(C(I>=g&&I<=f,"invalid firstIndex"),y(I,f),y(0,p),y(g,I))):p>g?y(g,p):p<g&&(y(0,p),y(g,f)),r.bindVAO(null)}}function M(e,t,a){const s=e.allocateHead();V(t,a,e.view,s)}function V(e,t,a,s){L(e.modelOrigin,t,a.modelOriginHi,a.modelOriginLo,s),a.model.copyFrom(s,e.model,t),a.modelNormal.copyFrom(s,e.modelNormal,t),e.color&&a.color&&a.color.copyFrom(s,e.color,t),e.objectAndLayerIdColor&&a.objectAndLayerIdColor&&a.objectAndLayerIdColor.copyFrom(s,e.objectAndLayerIdColor,t),e.featureAttribute&&a.featureAttribute&&a.featureAttribute.copyFrom(s,e.featureAttribute,t)}const F=o(),w=l(),N=s(),q=o(),H=o(),B=[c(1,0,1,1),c(0,0,1,1),c(0,1,0,1),c(1,1,0,1),c(1,0,0,1)],P=new T;export{x as LodRenderer,j as setLevelSelectorFactory};
5
+ import{isNone as e,destroyMaybe as t,isSome as a}from"../../../../../core/maybe.js";import{isAborted as s,throwIfAborted as n}from"../../../../../core/promiseUtils.js";import{c as i}from"../../../../../chunks/mat4f64.js";import{b as r,e as o,m as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec3f64.js";import{c as h,f as d}from"../../../../../chunks/vec4f64.js";import u from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{ShaderOutput as m}from"../../core/shaderLibrary/ShaderOutput.js";import{Camera as f}from"../Camera.js";import{Default3D as p}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as g}from"../IntersectorInterfaces.js";import C from"../Octree.js";import{RenderSlot as I}from"../RenderSlot.js";import{assert as D}from"../Util.js";import{InstanceData as y,StateFlags as v}from"./InstanceData.js";import{InstanceOctree as b}from"./InstanceOctree.js";import{LevelSelector as R}from"./LevelSelector.js";import{LodLevel as E}from"./LodLevel.js";import{RenderInstanceData as A}from"./RenderInstanceData.js";import{getInstanceBufferLayout as T}from"../../materials/DefaultMaterial.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as S}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as O}from"../../shaders/DefaultMaterialTechnique.js";import{bindVertexBufferLayout as U,unbindVertexBufferLayout as j}from"../../../../webgl/Util.js";let x=e=>{const t=e.baseBoundingSphere.radius,a=e.levels.map((e=>e.minScreenSpaceRadius));return new R(t,a)};function M(e){x=e}class V{constructor(e,t,a,s){this.type=g.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=[],this._highlightRenderInstanceData=[],this._instanceIndex=0,this._slicePlane=!1,this._lastCamera=new f,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.slots=[I.OPAQUE_MATERIAL,I.TRANSPARENT_MATERIAL],this.canRender=!0,this._symbol=e,this._optionalFields=t,this._metadata=a,this._instanceBufferLayout=T({instancedDoublePrecision:!0,instanced:t}),this._glInstanceBufferLayout=_(this._instanceBufferLayout,1),this._instanceData=new y(this._optionalFields,s),this._instanceData.on("instance-added",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-removed",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-transform-changed",(e=>{this._requestUpdateCycle(),this._metadata.notifyGraphicGeometryChanged(e.index)})),this._instanceData.on("instance-visibility-changed",(e=>{this._requestUpdateCycle(!0),this._metadata.notifyGraphicVisibilityChanged(e.index)})),this._instanceData.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0))),this._enableLevelSelection=this._symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this._metadata.layerUid}get instanceData(){return this._instanceData}get memoryUsage(){const e={cpu:0,gpu:0};return this._defaultRenderInstanceData.forEach((t=>{const a=t.memoryUsage;e.cpu+=a.cpu,e.gpu+=a.gpu})),this._highlightRenderInstanceData.forEach((t=>{const a=t.memoryUsage;e.cpu+=a.cpu,e.gpu+=a.gpu})),e}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,a)=>{const s=this._defaultRenderInstanceData[a],n=this._highlightRenderInstanceData[a],i=s.size+n.size,r=e.triangleCount;t.push({renderedInstances:i,renderedTriangles:i*r,trianglesPerInstance:r})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,t){this._context=e;const a=e.renderContext.rctx,i=await Promise.allSettled(this._symbol.levels.map((s=>(this._defaultRenderInstanceData.push(new A(a,this._instanceBufferLayout)),this._highlightRenderInstanceData.push(new A(a,this._instanceBufferLayout)),E.create(e,s,t))))),r=i.map((e=>"fulfilled"===e.status?e.value:null)).filter((e=>e));if(s(t)||r.length!==i.length){r.forEach((e=>e.destroy())),n(t);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=r,this._levelSelector=x(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceData.forEach((e=>e.destroy()))}get needsTransparentPass(){return this._levels.some((e=>e.components.some((e=>e.material.requiresSlot(I.TRANSPARENT_MATERIAL,m.Color)))))}get needsHighlight(){return this._highlightRenderInstanceData.some((e=>e.size>0))}prepareRender(e){if(u.LOD_INSTANCE_RENDERER_DISABLE_UPDATES)return;if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._lastCamera);this._lastCamera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}const t=this._needFullCycle?this._instanceData.size:2e3;this._needFullCycle=!1,this._updateInstances(e.bindParameters.contentCamera,t),this._needsUpdates&&this._context.requestRender()}render(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return;e.rctx.bindVAO();e.output!==m.Highlight&&e.output!==m.ShadowHighlight&&this._renderComponents(e,this._defaultRenderInstanceData);e.output!==m.ShadowExludeHighlight&&this._renderComponents(e,this._highlightRenderInstanceData)}intersect(e,t,a,s){if(!this.baseMaterial.isVisible())return;const n=c();r(n,s,a);const i=n=>{this._instanceData.getCombinedModelTransform(n,H),e.transform.set(H),l(B,a,e.transform.inverse),l(P,s,e.transform.inverse);const i=this._instanceData.getState(n),r=this._instanceData.getLodLevel(n),o=this._levels.length;D(i&v.ACTIVE,"invalid instance state"),D(r>=0&&r<o,"invaid lod level"),this._levels[r].intersect(e,t,B,P,n,this._metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(i):this._octree.forEachAlongRay(a,n,i)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree()}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,e&&(this._needFullCycle=!0),this._needsUpdates&&this._context.requestRender()}get _needsUpdates(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}get _octree(){return e(this._octreeCached)&&(this._octreeCached=this._buildOctree()),this._octreeCached}_invalidateOctree(){this._octreeCached=t(this._octreeCached)}_buildOctree(){const e=new b(this._instanceData,this.baseBoundingSphere),t=this._instanceData,a=t.view?t.view.state:null;for(let s=0;s<this._instanceData.capacity;++s){a.get(s)&v.ACTIVE&&e.addInstance(s)}return e}_queryDepthRangeOctree(e){const t=e.eye,a=e.viewForward,s=this._octree.findClosest(a,C.DepthOrder.FRONT_TO_BACK,e.frustum),n=this._octree.findClosest(a,C.DepthOrder.BACK_TO_FRONT,e.frustum);if(null!=s&&null!=n){this._instanceData.view.boundingSphere.getVec(s,q),r(q,q,t);const i=o(q,a)-q[3];this._instanceData.view.boundingSphere.getVec(n,q),r(q,q,t);const l=o(q,a)+q[3];return{near:Math.max(e.near,i),far:Math.min(e.far,l)}}return{near:1/0,far:-1/0}}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._defaultRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this._highlightRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this._needsUpdates&&this._context.requestRender()}_updateInstances(e,t){const s=this._enableLevelSelection,n=this._levelSelector;n.updateCamera(e),this._defaultRenderInstanceData.forEach((e=>e.beginUpdate())),this._highlightRenderInstanceData.forEach((e=>e.beginUpdate()));const i=this._instanceData,r=this._instanceData.view,o=i.size,l=i.capacity;let c=this._instanceIndex;t=Math.min(o,t);for(let h=0;h<t;++h){0===c&&this._startUpdateCycle();const e=r.state.get(c);let o=0;if(!(e&v.ALLOCATED)){c=c+1===l?0:c+1,t++;continue}const h=r.lodLevel.get(c);if(e&v.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[h].freeTail(),e&v.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[h].freeTail(),e&v.REMOVE)i.freeInstance(c);else if(e&v.VISIBLE){let t=0;s&&(r.modelOrigin.getVec(c,N),t=n.selectLevel(N,i.getCombinedMedianScaleFactor(c))),o=e&~(v.ACTIVE|v.TRANSFORM_CHANGED),t>=0&&(e&v.HIGHLIGHT?(F(this._highlightRenderInstanceData[t],r,c),o|=v.HIGHLIGHT_ACTIVE):(F(this._defaultRenderInstanceData[t],r,c),o|=v.DEFAULT_ACTIVE)),r.state.set(c,o),r.lodLevel.set(c,t)}else o=e&~(v.ACTIVE|v.TRANSFORM_CHANGED),r.state.set(c,o);if(a(this._octreeCached)){const t=!!(e&v.ACTIVE),a=!!(o&v.ACTIVE);!t&&a?this._octreeCached.addInstance(c):t&&!a?this._octreeCached.removeInstance(c):t&&a&&e&v.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(c),this._octreeCached.addInstance(c))}c=c+1===l?0:c+1}this._instanceIndex=c,this._defaultRenderInstanceData.forEach((e=>e.endUpdate())),this._highlightRenderInstanceData.forEach((e=>e.endUpdate()))}_renderComponents(e,t){this.levels.forEach(((a,s)=>{a.components.forEach((a=>{this._renderComponent(e,t[s],a,s)}))}))}_renderComponent(t,a,s,n){const{bindParameters:i,rctx:r,output:o}=t;if(0===a.size||!s.material.requiresSlot(i.slot,t.output))return;const l=s.glMaterials.load(r,i.slot,o);if(e(l))return;const c=l.beginSlot(i),h=r.bindTechnique(c,s.material.parameters,i);r.bindVAO(s.vao),c.ensureAttributeLocations(s.vao),h.bindDraw(z,i,s.material.parameters),u.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&t.output===m.Color&&(h.setUniform4fv("externalColor",G[Math.min(n,G.length-1)]),h.setUniform1i("colorMixMode",L.replace));const d=r.capabilities.instancing,_=a.capacity,f=a.headIndex,g=a.tailIndex,C=a.firstIndex,I=this._glInstanceBufferLayout,y=(e,t)=>{U(r,p,a.buffer,I,e),d.drawArraysInstanced(c.primitiveType,0,s.vertexCount,t-e),j(r,p,a.buffer,I)};s.material.parameters.transparent&&null!=C?f>g?(D(C>=g&&C<=f,"invalid firstIndex"),y(C,f),y(g,C)):f<g&&(C<=f?(D(C>=0&&C<=f,"invalid firstIndex"),y(C,f),y(g,_),y(0,C)):(D(C>=g&&C<=_,"invalid firstIndex"),y(C,_),y(0,f),y(g,C))):f>g?y(g,f):f<g&&(y(0,f),y(g,_)),r.bindVAO(null)}}function F(e,t,a){const s=e.allocateHead();w(t,a,e.view,s)}function w(e,t,a,s){S(e.modelOrigin,t,a.modelOriginHi,a.modelOriginLo,s),a.model.copyFrom(s,e.model,t),a.modelNormal.copyFrom(s,e.modelNormal,t),e.color&&a.color&&a.color.copyFrom(s,e.color,t),e.objectAndLayerIdColor&&a.objectAndLayerIdColor&&a.objectAndLayerIdColor.copyFrom(s,e.objectAndLayerIdColor,t),e.featureAttribute&&a.featureAttribute&&a.featureAttribute.copyFrom(s,e.featureAttribute,t)}const N=c(),q=h(),H=i(),B=c(),P=c(),G=[d(1,0,1,1),d(0,0,1,1),d(0,1,0,1),d(1,1,0,1),d(1,0,0,1)],z=new O;export{V as LodRenderer,M as setLevelSelectorFactory};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e}from"../../../../core/maybe.js";import{createResolver as t}from"../../../../core/promiseUtils.js";import{d as r}from"../../../../chunks/vec4f64.js";import{AutoDisposable as s}from"../lib/AutoDisposable.js";import{RenderRequestType as i,Decorations as n}from"../lib/basicInterfaces.js";import{createEmptyImageData as o,resampleHermite as a}from"../../../support/screenshotUtils.js";import{PixelFormat as h,DataType as c,TargetType as l,DepthStencilTargetType as d}from"../../../webgl/enums.js";import{FramebufferObject as f}from"../../../webgl/FramebufferObject.js";class u extends s{constructor(e,t,r,s){super(),this._rctx=e,this._renderFunctions=t,this._forceCameraHook=r,this._disposeOffscreenBuffers=s,this.supersample=!0,this._screenshotQueue=new Array}dispose(){this._rctx=null}async takeScreenshot(e){await this._renderFunctions.prepareOverlay(),this._renderFunctions.requestRenderScene(i.BACKGROUND);const r=t();return this._screenshotQueue.push({settings:e,resolver:r}),r.promise}update(e){for(const t of this._screenshotQueue){if(this.isDisposed){t.resolver.reject();continue}const r={...t.settings,pixelRatio:t.settings.pixelRatio*e.viewCamera.pixelRatio},s=this._renderScreenshot(e,r);t.resolver(s)}this._screenshotQueue.length=0}_renderScreenshotOverlay(e,t,r){e.width=t.width,e.height=t.height;const s=e.getContext("2d"),i=r.pixelRatio;return s.save(),s.translate(0,t.height),s.scale(1,-1),r.region&&s.translate(-r.region.x,-r.region.y),s.scale(i,i),t=this._renderFunctions.renderOverlay(e,t),s.restore(),t}_readbackScreenshot(e,t){return e.resample?this._readbackScreenshotResampled(e,t):this._readbackScreenshotImmediate(e,t)}_readbackScreenshotResampled(e,t){const{framebufferWidth:r,framebufferHeight:s,region:i,resample:n}=e,l=this._ensureScreenshotEncodeCanvas();let d=o(r,s,l);this._rctx.gl.readPixels(0,0,r,s,h.RGBA,c.UNSIGNED_BYTE,new Uint8Array(d.data.buffer)),t(),d=this._renderScreenshotOverlay(l,d,{...e,region:null});const f=o(i.width,i.height,l);return a(d,f,!0,n.region.x,s-(n.region.y+n.region.height),n.region.width,n.region.height)}_readbackScreenshotImmediate(e,t){const{framebufferHeight:r,region:s}=e,i=this._ensureScreenshotEncodeCanvas(),n=o(s.width,s.height,i);return this._rctx.gl.readPixels(s.x,r-(s.y+s.height),s.width,s.height,h.RGBA,c.UNSIGNED_BYTE,new Uint8Array(n.data.buffer)),t(),this._renderScreenshotOverlay(i,n,e)}_renderScreenshot(t,s){let i=null,o=null;const a=t.viewCamera,{framebufferWidth:h,framebufferHeight:c}=s;let u=!1;const _=s.disableDecorations&&t.frameHasDecorations,g=h!==a.fullWidth||c!==a.fullHeight,m=s.ignorePadding&&a.pixelRatio!==s.pixelRatio,p=g||_||m||s.objectAndLayerIdColor;if(s.objectAndLayerIdColor&&(o=new f(this._rctx,{width:h,height:c,colorTarget:l.TEXTURE,depthStencilTarget:d.DEPTH_STENCIL_RENDER_BUFFER})),p){const e=a.clone();if(s.ignorePadding){const t=r(e.padding);for(let r=0;r<4;r++)t[r]=Math.round(t[r]/e.pixelRatio*s.pixelRatio);e.padding=t}e.fullWidth=h,e.fullHeight=c,e.pixelRatio=s.pixelRatio;const t=a.fovX-e.fovX,_=a.fovY-e.fovY;t<0&&t<_?e.fovX=a.fovX:_<0&&_<t&&(e.fovY=a.fovY),this._forceCameraHook(e),u=!0,i=new f(this._rctx,{width:e.fullWidth,height:e.fullHeight,colorTarget:l.TEXTURE,depthStencilTarget:d.DEPTH_STENCIL_RENDER_BUFFER}),this._renderFunctions.renderScene(i,o,e,s.disableDecorations?n.OFF:n.ON),this._disposeOffscreenBuffers()}const b=()=>{this._rctx.bindFramebuffer(null),e(i)},x=this._readbackScreenshot(s,b);b();let v=null;if(s.objectAndLayerIdColor){const t=()=>{this._rctx.bindFramebuffer(null),e(o)};this._rctx.bindFramebuffer(o),v=this._readbackScreenshot(s,t),this._rctx.bindFramebuffer(null),t()}if(p&&!this._rctx.contextAttributes.alpha)for(let e=3;e<x.data.length;e+=4)x.data[e]=255;if(v&&!this._rctx.contextAttributes.alpha)for(let e=3;e<v.data.length;e+=4)v.data[e]=255;return u&&this._forceCameraHook(a),[x,v]}_ensureScreenshotEncodeCanvas(){return this._screenshotEncodeCanvas||(this._screenshotEncodeCanvas=document.createElement("canvas")),this._screenshotEncodeCanvas}}export{u as ScreenshotManager};
5
+ import{disposeMaybe as e}from"../../../../core/maybe.js";import{createResolver as t}from"../../../../core/promiseUtils.js";import{d as r}from"../../../../chunks/vec4f64.js";import{AutoDisposable as s}from"../lib/AutoDisposable.js";import{RenderRequestType as i,Decorations as o}from"../lib/basicInterfaces.js";import{resampleHermite as n}from"../../../support/screenshotUtils.js";import{PixelFormat as a,DataType as h,TargetType as c,DepthStencilTargetType as l}from"../../../webgl/enums.js";import{FramebufferObject as d}from"../../../webgl/FramebufferObject.js";import{createEmptyImageData as f}from"../../../../core/imageUtils.js";class u extends s{constructor(e,t,r,s){super(),this._rctx=e,this._renderFunctions=t,this._forceCameraHook=r,this._disposeOffscreenBuffers=s,this.supersample=!0,this._screenshotQueue=new Array}dispose(){this._rctx=null}async takeScreenshot(e){await this._renderFunctions.prepareOverlay(),this._renderFunctions.requestRenderScene(i.BACKGROUND);const r=t();return this._screenshotQueue.push({settings:e,resolver:r}),r.promise}update(e){for(const t of this._screenshotQueue){if(this.isDisposed){t.resolver.reject();continue}const r={...t.settings,pixelRatio:t.settings.pixelRatio*e.viewCamera.pixelRatio},s=this._renderScreenshot(e,r);t.resolver(s)}this._screenshotQueue.length=0}_renderScreenshotOverlay(e,t,r){e.width=t.width,e.height=t.height;const s=e.getContext("2d"),i=r.pixelRatio;return s.save(),s.translate(0,t.height),s.scale(1,-1),r.region&&s.translate(-r.region.x,-r.region.y),s.scale(i,i),t=this._renderFunctions.renderOverlay(e,t),s.restore(),t}_readbackScreenshot(e,t){return e.resample?this._readbackScreenshotResampled(e,t):this._readbackScreenshotImmediate(e,t)}_readbackScreenshotResampled(e,t){const{framebufferWidth:r,framebufferHeight:s,region:i,resample:o}=e,c=this._ensureScreenshotEncodeCanvas();let l=f(r,s,c);this._rctx.gl.readPixels(0,0,r,s,a.RGBA,h.UNSIGNED_BYTE,new Uint8Array(l.data.buffer)),t(),l=this._renderScreenshotOverlay(c,l,{...e,region:null});const d=f(i.width,i.height,c);return n(l,d,!0,o.region.x,s-(o.region.y+o.region.height),o.region.width,o.region.height)}_readbackScreenshotImmediate(e,t){const{framebufferHeight:r,region:s}=e,i=this._ensureScreenshotEncodeCanvas(),o=f(s.width,s.height,i);return this._rctx.gl.readPixels(s.x,r-(s.y+s.height),s.width,s.height,a.RGBA,h.UNSIGNED_BYTE,new Uint8Array(o.data.buffer)),t(),this._renderScreenshotOverlay(i,o,e)}_renderScreenshot(t,s){let i=null,n=null;const a=t.viewCamera,{framebufferWidth:h,framebufferHeight:f}=s;let u=!1;const _=s.disableDecorations&&t.frameHasDecorations,g=h!==a.fullWidth||f!==a.fullHeight,m=s.ignorePadding&&a.pixelRatio!==s.pixelRatio,p=g||_||m||s.objectAndLayerIdColor;if(s.objectAndLayerIdColor&&(n=new d(this._rctx,{width:h,height:f,colorTarget:c.TEXTURE,depthStencilTarget:l.DEPTH_STENCIL_RENDER_BUFFER})),p){const e=a.clone();if(s.ignorePadding){const t=r(e.padding);for(let r=0;r<4;r++)t[r]=Math.round(t[r]/e.pixelRatio*s.pixelRatio);e.padding=t}e.fullWidth=h,e.fullHeight=f,e.pixelRatio=s.pixelRatio;const t=a.fovX-e.fovX,_=a.fovY-e.fovY;t<0&&t<_?e.fovX=a.fovX:_<0&&_<t&&(e.fovY=a.fovY),this._forceCameraHook(e),u=!0,i=new d(this._rctx,{width:e.fullWidth,height:e.fullHeight,colorTarget:c.TEXTURE,depthStencilTarget:l.DEPTH_STENCIL_RENDER_BUFFER}),this._renderFunctions.renderScene(i,n,e,s.disableDecorations?o.OFF:o.ON),this._disposeOffscreenBuffers()}const b=()=>{this._rctx.bindFramebuffer(null),e(i)},x=this._readbackScreenshot(s,b);b();let v=null;if(s.objectAndLayerIdColor){const t=()=>{this._rctx.bindFramebuffer(null),e(n)};this._rctx.bindFramebuffer(n),v=this._readbackScreenshot(s,t),this._rctx.bindFramebuffer(null),t()}if(p&&!this._rctx.contextAttributes.alpha)for(let e=3;e<x.data.length;e+=4)x.data[e]=255;if(v&&!this._rctx.contextAttributes.alpha)for(let e=3;e<v.data.length;e+=4)v.data[e]=255;return u&&this._forceCameraHook(a),[x,v]}_ensureScreenshotEncodeCanvas(){return this._screenshotEncodeCanvas||(this._screenshotEncodeCanvas=document.createElement("canvas")),this._screenshotEncodeCanvas}}export{u as ScreenshotManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,disposeMaybe as t,isSome as r,abortMaybe as a}from"../../../../core/maybe.js";import i from"../../../../core/PerformanceSampler.js";import{Milliseconds as s}from"../../../../core/time.js";import{once as m}from"../../../../core/accessorSupport/utils.js";import{createElapsedTimerPool as o}from"../../../webgl/Measurement.js";var l;!function(e){e.PREPARE="prepare",e.SHADOW_MAP="shadow map",e.LINEAR_DEPTH="linear depth",e.ACCUMULATED_SHADOWS="accumulated shadows",e.NORMALS="normals",e.OBJECT_AND_LAYER_ID_COLOR="object/layer id color",e.SSAO="SSAO",e.OPAQUE="opaque",e.OPAQUE_EDGES="opaque edges",e.VOXEL="voxel",e.TRANSPARENT="transparent",e.TRANSPARENT_EDGES="transparent edges",e.HUD_VISIBILITY="HUD visibility",e.TRANSPARENT_TERRAIN="transparent terrain",e.ENVIRONMENT="environment",e.LASER_LINE="laser line",e.OCCLUDED="occluded",e.ANTIALIASING="antialiasing",e.HIGHLIGHTS="highlights",e.HUD_OCCLUDED="HUD occluded",e.HUD_NOT_OCCLUDED="HUD not occluded"}(l||(l={}));class n{constructor(){this._startTimeStampCPU=s(0),this._lastTimeStampCPU=s(0),this._enableDetailedTimer=0,this._totalRenderTimeSamplerCPU=new i("Total"),this._renderTimeSamplersCPU=new Map(Object.values(l).map((e=>[e,new i(e)]))),this._enableTimerGPU=0,this._measureTotalFrameGPU=!1,this._totalFrameCategoryGPU="total",this._totalRenderTimeSamplerGPU=new i("GPU"),this._renderTimeSamplersGPU=new Map(Object.values(l).map((e=>[e,new i(e)]))),this._totalTime=s(0),this._totalFrameCount=0}get totalRenderTimeSamplerCPU(){return this._totalRenderTimeSamplerCPU}get renderTimeSamplersCPU(){return Array.from(this._renderTimeSamplersCPU.values())}get totalRenderTimeSamplerGPU(){return this._totalRenderTimeSamplerGPU}get renderTimeSamplersGPU(){return Array.from(this._renderTimeSamplersGPU.values())}get totalTime(){return this._totalTime}get totalFrameCount(){return this._totalFrameCount}get elapsedTime(){return s(performance.now()-this._startTimeStampCPU)}enableDetailedPerformanceInfo(r){if(++this._enableDetailedTimer,e(this._elapsedTimerPoolGPU)){const e=[...Object.values(l),this._totalFrameCategoryGPU];this._elapsedTimerPoolGPU=o(r,e)}return e(this._elapsedTimerPoolGPU)?{hasGPUTimerSupport:!1,remove:m((()=>--this._enableDetailedTimer))}:(++this._enableTimerGPU,{hasGPUTimerSupport:!0,remove:m((()=>{--this._enableDetailedTimer,--this._enableTimerGPU,0===this._enableTimerGPU&&(this._elapsedTimerPoolGPU=t(this._elapsedTimerPoolGPU))}))})}preRender(){this._startTimeStampCPU=this._lastTimeStampCPU=s(performance.now()),r(this._elapsedTimerPoolGPU)&&(this._measureTotalFrameGPU=this._totalFrameCount%2==0,this._elapsedTimerPoolGPU.start())}advance(e){if(!this._enableDetailedTimer)return;const t=s(performance.now());if(this._renderTimeSamplersCPU.get(e).record(t-this._lastTimeStampCPU),this._lastTimeStampCPU=t,r(this._elapsedTimerPoolGPU)&&!this._measureTotalFrameGPU){const t=this._elapsedTimerPoolGPU.stop(e);r(t)&&this._renderTimeSamplersGPU.get(e).record(t),this._elapsedTimerPoolGPU.start()}}postRender(){const e=s(performance.now()-this._startTimeStampCPU);if(this._totalTime=s(this._totalTime+e),++this._totalFrameCount,this._enableDetailedTimer){if(this._totalRenderTimeSamplerCPU.record(e),r(this._elapsedTimerPoolGPU)&&this._measureTotalFrameGPU){const e=this._elapsedTimerPoolGPU.stop(this._totalFrameCategoryGPU);r(e)&&this._totalRenderTimeSamplerGPU.record(e)}a(this._elapsedTimerPoolGPU)}}}export{l as PerformanceCategory,n as RendererPerformanceInfo};
5
+ import{isNone as t,disposeMaybe as e,isSome as r}from"../../../../core/maybe.js";import i from"../../../../core/PerformanceSampler.js";import{Milliseconds as o}from"../../../../core/time.js";import{once as s}from"../../../../core/accessorSupport/utils.js";import{createElapsedTimerPool as a}from"../../../webgl/TimerPool.js";var m;!function(t){t.PREPARE="prepare",t.SHADOW_MAP="shadow map",t.LINEAR_DEPTH="linear depth",t.ACCUMULATED_SHADOWS="accumulated shadows",t.NORMALS="normals",t.OBJECT_AND_LAYER_ID_COLOR="object/layer id color",t.SSAO="SSAO",t.OPAQUE="opaque",t.OPAQUE_EDGES="opaque edges",t.VOXEL="voxel",t.TRANSPARENT="transparent",t.TRANSPARENT_EDGES="transparent edges",t.HUD_VISIBILITY="HUD visibility",t.TRANSPARENT_TERRAIN="transparent terrain",t.ENVIRONMENT="environment",t.LASER_LINE="laser line",t.OCCLUDED="occluded",t.ANTIALIASING="antialiasing",t.HIGHLIGHTS="highlights",t.HUD_OCCLUDED="HUD occluded",t.HUD_NOT_OCCLUDED="HUD not occluded",t.FINISH="finish"}(m||(m={}));const l="Total";class p{constructor(t){this._rctx=t,this._startTimeStampCPU=o(0),this._lastTimeStampCPU=o(0),this._totalCPUTime=new i(l),this._cpuTimeSamplers=new Map(Object.values(m).map((t=>[t,new i(t)]))),this._enableGPUTimer=0,this._totalGPUTime=new i("GPU"),this._gpuTimeSamplers=new Map(Object.values(m).map((t=>[t,new i(t)]))),this._totalTime=o(0),this._totalFrameCount=0}get totalCPUTimeSampler(){return this._totalCPUTime}get cpuTimeSamplers(){return Array.from(this._cpuTimeSamplers.values())}get totalGPUTimeSampler(){return this._totalGPUTime}get gpuTimeSamplers(){return Array.from(this._gpuTimeSamplers.values())}get totalTime(){return this._totalTime}get totalFrameCount(){return this._totalFrameCount}get elapsedTime(){return o(performance.now()-this._startTimeStampCPU)}enableGPUPerformanceInfo(){if(t(this._gpuTimerPool)){const t=[...Object.values(m),l];this._gpuTimerPool=a(this._rctx,t)}return t(this._gpuTimerPool)?{hasGPUTimerSupport:!1,remove:()=>{}}:(++this._enableGPUTimer,{hasGPUTimerSupport:!0,remove:s((()=>{--this._enableGPUTimer,0===this._enableGPUTimer&&(this._gpuTimerPool=e(this._gpuTimerPool))}))})}startFrame(){this._startTimeStampCPU=this._lastTimeStampCPU=o(performance.now()),r(this._gpuTimerPool)&&this._gpuTimerPool.start()}advance(t){const e=o(performance.now());if(this._cpuTimeSamplers.get(t).record(e-this._lastTimeStampCPU),this._lastTimeStampCPU=e,r(this._gpuTimerPool)){const e=this._gpuTimerPool.stop(t);this._gpuTimeSamplers.get(t).record(e),this._gpuTimerPool.start()}}finishFrame(){if(r(this._gpuTimerPool)){const t=this._gpuTimerPool.stop(m.FINISH);this._gpuTimeSamplers.get(m.FINISH).record(t)}const t=o(performance.now()-this._startTimeStampCPU);this._totalTime=o(this._totalTime+t),this._totalCPUTime.record(t),r(this._gpuTimerPool)&&this._totalGPUTime.record(this.gpuTimeSamplers.reduce(((t,e)=>t+(e.last||0)),0)),++this._totalFrameCount}}export{m as PerformanceCategory,p as RendererPerformanceInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/CollectionFlattener.js";import t from"../core/Error.js";import{HandleOwner as i}from"../core/HandleOwner.js";import a from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{isNone as o,isSome as l,removeMaybe as n}from"../core/maybe.js";import{createDeferred as h,isAbortError as y,onAbort as p,throwIfAborted as w}from"../core/promiseUtils.js";import{on as c,watch as d,syncAndInitial as m}from"../core/reactiveUtils.js";import{schedule as u}from"../core/scheduling.js";import{property as f}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as _}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as g}from"../core/support/WatchUpdatingTracking.js";class v{constructor(e,r,i){this.layer=e,this.view=r,this.layerViewImporter=i,this._controller=new AbortController,this._deferred=h(),this._started=!1,this.done=!1,p(this._controller.signal,(()=>{const r=new t("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}get promise(){return this._deferred.promise}destroy(){this._controller.abort();const{layerView:e}=this;if(!e)return;const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e}),this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:i}=this;this._map=i.map;try{let s,o;if(await r.load({signal:e}),"prefetchResources"in r&&await r.prefetchResources({signal:e}),r.createLayerView)s=await r.createLayerView(i,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new t("layer:view-not-supported","No layerview implementation was found");const a=await this.layerViewImporter.importLayerView(r);w(e),s="default"in a?new a.default({layer:r,view:i}):new a({layer:r,view:i})}const l=()=>{o=n(o),s.destroyed||s.destroy(),s.layer=null,s.parent=null,s.view=null,this.done=!0};o=p(e,l),w(e);try{await s.when()}catch(a){throw l(),a}const h=this._map?.allLayers?.includes(r);if(!h)return l(),void this._deferred.reject(new t("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=s,r.emit("layerview-create",{view:i,layerView:s}),i.emit("layerview-create",{layer:r,layerView:s}),this.done=!0,this._deferred.resolve(s)}catch(a){r.emit("layerview-create-error",{view:i,error:a}),i.emit("layerview-create-error",{layer:r,error:a}),this.done=!0,this._deferred.reject(new t("layerview:create-error","layerview creation failed",{layer:r,error:a}))}}}let V=class extends i{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._watchUpdatingTracking=new g,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>(o(this._workPromise)&&(this._workPromise=h()),this.handles.remove("reschedule"),this.handles.add(u(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),o(this._workPromise))return void this.notifyChange("updating");this.handles.remove("reschedule"),this.handles.remove("collection-change");const t=new r({getCollections:()=>this._rootCollectionNames.map((e=>this.get(e))),getChildrenFunction:e=>e&&"layers"in e?e.layers:null});if(!t)return this._workPromise.resolve(),void(this._workPromise=null);for(const r of t)this._createLayerView(r);this._refreshCollections();for(const[r,s]of this._layerLayerViewInfoMap)t.includes(r)||(this._layerLayerViewInfoMap.delete(s.layer),s.destroy());const i=t.filter((e=>"group"===e.type)).map((e=>e.layers)),a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers,...i].filter((e=>!!e));this.handles.add(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.handles.add([c((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),d((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),m)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),this._watchUpdatingTracking.destroy(),this._map=null}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return l(this._workPromise)||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){if(!this.destroyed){for(const e of this._layerLayerViewInfoMap.values())e.destroy();this._layerLayerViewInfoMap.clear(),this._refreshCollections()}}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e))throw new t("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,t){if(!e||!r)return void(r&&r.removeAll());let i=0;for(const a of e){const e=this._layerLayerViewInfoMap.get(a);if(!e||!e.layerView)continue;const s=e.layerView;s.layer=a,s.parent=t,r.getItemAt(i)!==s&&r.splice(i,0,s),a.layers&&this._populateLayerViewsOwners(a.layers,s.layerViews,s),i+=1}i<r.length&&r.splice(i,r.length)}_createLayerView(e){if(this._layerLayerViewInfoMap.has(e))return this.view.ready&&this._layerLayerViewInfoMap.get(e).start(),this.notifyChange("updating"),void this.notifyChange("updatingRemaining");e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new v(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(y(r)||"cancelled:layerview-create"===r.name)||a.getLogger(this.declaredClass).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([f()],V.prototype,"_workPromise",void 0),e([f({readOnly:!0})],V.prototype,"_watchUpdatingTracking",void 0),e([f({readOnly:!0})],V.prototype,"_layersToLayerViews",null),e([f({readOnly:!0})],V.prototype,"_rootCollectionNames",null),e([f()],V.prototype,"layerViewImporter",void 0),e([f()],V.prototype,"supportsGround",void 0),e([f({readOnly:!0})],V.prototype,"updating",null),e([f({readOnly:!0})],V.prototype,"updatingRemaining",null),e([f({constructOnly:!0})],V.prototype,"view",void 0),V=e([_("esri.views.LayerViewManager")],V);const L=V;export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../core/CollectionFlattener.js";import t from"../core/Error.js";import{HandleOwner as i}from"../core/HandleOwner.js";import a from"../core/Logger.js";import{someMap as s}from"../core/MapUtils.js";import{isNone as o,isSome as l,removeMaybe as n}from"../core/maybe.js";import{createDeferred as h,createAbortError as y,isAbortError as w,onAbort as p,throwIfAborted as c}from"../core/promiseUtils.js";import{on as d,watch as m,syncAndInitial as u}from"../core/reactiveUtils.js";import{schedule as f}from"../core/scheduling.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as v}from"../core/support/WatchUpdatingTracking.js";class V{constructor(e,r,i){this.layer=e,this.view=r,this.layerViewImporter=i,this._controller=new AbortController,this._deferred=h(),this._started=!1,this.done=!1,p(this._controller.signal,(()=>{const r=new t("cancelled:layerview-create","layerview creation cancelled",{layer:e});this._deferred.reject(r)}))}get promise(){return this._deferred.promise}destroy(){this._controller.abort();const{layerView:e}=this;if(!e)return;const{layer:r,view:t}=this;r.emit("layerview-destroy",{view:t,layerView:e}),t.emit("layerview-destroy",{layer:r,layerView:e}),this.done=!0,this.layer=null,this.layerView=null,this.view=null,this.layerViewImporter=null}async start(){if(this._started)return;this._started=!0;const{_controller:{signal:e},layer:r,view:i}=this;this._map=i.map;try{let s,o;if(await r.load({signal:e}),"prefetchResources"in r&&await r.prefetchResources({signal:e}),r.createLayerView)s=await r.createLayerView(i,{signal:e});else{if(!this.layerViewImporter.hasLayerViewModule(r))throw new t("layer:view-not-supported","No layerview implementation was found");const a=await this.layerViewImporter.importLayerView(r);c(e),s="default"in a?new a.default({layer:r,view:i}):new a({layer:r,view:i})}const l=()=>{o=n(o),s.destroyed||s.destroy(),s.layer=null,s.parent=null,s.view=null,this.done=!0};o=p(e,l),c(e);try{await s.when()}catch(a){throw l(),a}const h=this._map?.allLayers?.includes(r);if(!h)return l(),void this._deferred.reject(new t("view:no-layerview-for-layer","The layer has been removed from the map",{layer:r}));this.layerView=s,r.emit("layerview-create",{view:i,layerView:s}),i.emit("layerview-create",{layer:r,layerView:s}),this.done=!0,this._deferred.resolve(s)}catch(a){r.emit("layerview-create-error",{view:i,error:a}),i.emit("layerview-create-error",{layer:r,error:a}),this.done=!0,this._deferred.reject(new t("layerview:create-error","layerview creation failed",{layer:r,error:a}))}}}let L=class extends i{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._watchUpdatingTracking=new v,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>(o(this._workPromise)&&(this._workPromise=h()),this.handles.remove("reschedule"),this.handles.add(f(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{const e=this.view.map;if(this._map!==e&&(this.clear(),this._map=e),o(this._workPromise))return void this.notifyChange("updating");this.handles.remove("reschedule"),this.handles.remove("collection-change");const t=new r({getCollections:()=>this._rootCollectionNames.map((e=>this.get(e))),getChildrenFunction:e=>e&&"layers"in e?e.layers:null});if(!t)return this._workPromise.resolve(),void(this._workPromise=null);for(const r of t)this._createLayerView(r);this._refreshCollections();for(const[r,s]of this._layerLayerViewInfoMap)t.includes(r)||(this._layerLayerViewInfoMap.delete(s.layer),s.destroy());const i=t.filter((e=>"group"===e.type)).map((e=>e.layers)),a=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.referenceLayers,e?.layers,...i].filter((e=>!!e));this.handles.add(a.map((e=>this._watchUpdatingTracking.addOnCollectionChange((()=>e),this._reschedule))),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.handles.add([d((()=>this.view?.map?.allLayers),"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),m((()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]}),(()=>this._reschedule()),u)]),this._preloadLayerViewModules(),this._reschedule()}destroy(){this.clear(),this._watchUpdatingTracking.destroy(),this._map=null,l(this._workPromise)&&(this._workPromise.reject(y()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.layers","view.layerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return l(this._workPromise)||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,(e=>!e.done))}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){if(!this.destroyed){for(const e of this._layerLayerViewInfoMap.values())e.destroy();this._layerLayerViewInfoMap.clear(),this._refreshCollections()}}async whenLayerView(e){if(await this._reschedule(),!this._layerLayerViewInfoMap.has(e))throw new t("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return this._layerLayerViewInfoMap.get(e).promise}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(this.get(e),this.get(r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_populateLayerViewsOwners(e,r,t){if(!e||!r)return void(r&&r.removeAll());let i=0;for(const a of e){const e=this._layerLayerViewInfoMap.get(a);if(!e||!e.layerView)continue;const s=e.layerView;s.layer=a,s.parent=t,r.getItemAt(i)!==s&&r.splice(i,0,s),a.layers&&this._populateLayerViewsOwners(a.layers,s.layerViews,s),i+=1}i<r.length&&r.splice(i,r.length)}_createLayerView(e){if(this._layerLayerViewInfoMap.has(e))return this.view.ready&&this._layerLayerViewInfoMap.get(e).start(),this.notifyChange("updating"),void this.notifyChange("updatingRemaining");e.load().catch((()=>{})),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new V(e,this.view,this.layerViewImporter);r.promise.then((()=>this._refreshCollections()),(r=>{r&&(w(r)||"cancelled:layerview-create"===r.name)||a.getLogger(this.declaredClass).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this._refreshCollections()})),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([_()],L.prototype,"_workPromise",void 0),e([_({readOnly:!0})],L.prototype,"_watchUpdatingTracking",void 0),e([_({readOnly:!0})],L.prototype,"_layersToLayerViews",null),e([_({readOnly:!0})],L.prototype,"_rootCollectionNames",null),e([_()],L.prototype,"layerViewImporter",void 0),e([_()],L.prototype,"supportsGround",void 0),e([_({readOnly:!0})],L.prototype,"updating",null),e([_({readOnly:!0})],L.prototype,"updatingRemaining",null),e([_({constructOnly:!0})],L.prototype,"view",void 0),L=e([g("esri.views.LayerViewManager")],L);const I=L;export{I as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import s from"../core/Error.js";import{EsriPromise as e}from"../core/Promise.js";import{isPromiseLike as r}from"../core/promiseUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";let p=class extends e{constructor(t){super(t),this.state="running",this.target=null}initialize(){this.addResolvingPromise(new Promise(((t,s)=>this._dfd={resolve:t,reject:s})))}get done(){return"finished"===this.state||"stopped"===this.state}stop(){"stopped"!==this.state&&"finished"!==this.state&&(this._set("state","stopped"),this._dfd.reject(new s("ViewAnimation stopped")))}finish(){"stopped"!==this.state&&"finished"!==this.state&&(this._set("state","finished"),this._dfd.resolve())}update(t,s){s||(s=r(t)?"waiting-for-target":"running"),this._set("target",t),this._set("state",s)}};t([i({readOnly:!0})],p.prototype,"done",null),t([i({readOnly:!0,type:String})],p.prototype,"state",void 0),t([i()],p.prototype,"target",void 0),p=t([o("esri.views.ViewAnimation")],p),function(t){t.State={RUNNING:"running",STOPPED:"stopped",FINISHED:"finished",WAITING_FOR_TARGET:"waiting-for-target"}}(p||(p={}));const n=p;export{n as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import s from"../core/Error.js";import{EsriPromise as e}from"../core/Promise.js";import{isPromiseLike as r}from"../core/promiseUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";let p=class extends e{constructor(t){super(t),this.state="running",this.target=null,this._dfd=null}initialize(){this.addResolvingPromise(new Promise(((t,s)=>this._dfd={resolve:t,reject:s})))}get done(){return"finished"===this.state||"stopped"===this.state}stop(){"stopped"!==this.state&&"finished"!==this.state&&(this._set("state","stopped"),this._dfd?.reject(new s("ViewAnimation stopped")))}finish(){"stopped"!==this.state&&"finished"!==this.state&&(this._set("state","finished"),this._dfd?.resolve())}update(t,s){s||(s=r(t)?"waiting-for-target":"running"),this._set("target",t),this._set("state",s)}};t([i({readOnly:!0})],p.prototype,"done",null),t([i({readOnly:!0,type:String})],p.prototype,"state",void 0),t([i()],p.prototype,"target",void 0),p=t([o("esri.views.ViewAnimation")],p),function(t){t.State={RUNNING:"running",STOPPED:"stopped",FINISHED:"finished",WAITING_FOR_TARGET:"waiting-for-target"}}(p||(p={}));const n=p;export{n as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t}from"../../../../core/maybe.js";import{Vertex as i,Edge as s}from"../EditGeometry.js";class d{constructor(e,t,i){this._editGeometry=e,this._component=t,this._pos=i,this._addedVertex=null,this._originalEdge=null,this._left=null,this._right=null}apply(){let d="redo";e(this._addedVertex)&&(d="apply",this._addedVertex=new i(this._component));const h=this._component.getLastVertex();if(e(h))this._component.vertices.push(this._addedVertex),this._addedVertex.pos=this._pos,this._addedVertex.index=0;else{let i=null;h.rightEdge&&(this._originalEdge=h.rightEdge,i=this._originalEdge.rightVertex,this._component.edges.splice(this._component.edges.indexOf(this._originalEdge),1)),this._component.vertices.push(this._addedVertex),this._addedVertex.pos=this._pos,e(this._left)&&(this._left=new s(this._component,h,this._addedVertex)),this._component.edges.push(this._left),h.rightEdge=this._left,t(this._originalEdge)&&t(i)&&(e(this._right)&&(this._right=new s(this._component,this._addedVertex,i)),this._component.edges.push(this._right),i.leftEdge=this._right),this._component.updateVertexIndex(this._addedVertex,h.index+1)}this._editGeometry.notifyChanges({operation:d,addedVertices:[this._addedVertex]})}undo(){if(e(this._addedVertex))return null;this._component.vertices.splice(this._component.vertices.indexOf(this._addedVertex),1),t(this._left)&&(this._component.edges.splice(this._component.edges.indexOf(this._left),1),this._left.leftVertex.rightEdge=null),t(this._right)&&(this._component.edges.splice(this._component.edges.indexOf(this._right),1),this._right.rightVertex.leftEdge=null),t(this._originalEdge)&&(this._component.edges.push(this._originalEdge),this._originalEdge.leftVertex.rightEdge=this._originalEdge,this._originalEdge.rightVertex.leftEdge=this._originalEdge),t(this._left)?this._component.updateVertexIndex(this._left.leftVertex,this._left.leftVertex.index):this._component.updateVertexIndex(this._addedVertex,0),this._editGeometry.notifyChanges({operation:"undo",removedVertices:[this._addedVertex]})}accumulate(){return!1}}export{d as AppendVertex};
5
+ import{isNone as e,isSome as t}from"../../../../core/maybe.js";import{Vertex as i,Edge as s}from"../EditGeometry.js";class d{constructor(e,t,i){this._editGeometry=e,this._component=t,this._pos=i,this._addedVertex=null,this._originalEdge=null,this._left=null,this._right=null}apply(){let d="redo";e(this._addedVertex)&&(d="apply",this._addedVertex=new i(this._component));const h=this._component.getLastVertex();if(e(h))this._component.vertices.push(this._addedVertex),this._addedVertex.pos=this._pos,this._addedVertex.index=0;else{let i=null;h.rightEdge&&(this._originalEdge=h.rightEdge,i=this._originalEdge.rightVertex,this._component.edges.splice(this._component.edges.indexOf(this._originalEdge),1)),this._component.vertices.push(this._addedVertex),this._addedVertex.pos=this._pos,e(this._left)&&(this._left=new s(this._component,h,this._addedVertex)),this._component.edges.push(this._left),h.rightEdge=this._left,t(this._originalEdge)&&t(i)&&(e(this._right)&&(this._right=new s(this._component,this._addedVertex,i)),this._component.edges.push(this._right),i.leftEdge=this._right),this._component.updateVertexIndex(this._addedVertex,h.index+1)}this._editGeometry.notifyChanges({operation:d,addedVertices:[this._addedVertex]})}undo(){e(this._addedVertex)||(this._component.vertices.splice(this._component.vertices.indexOf(this._addedVertex),1),t(this._left)&&(this._component.edges.splice(this._component.edges.indexOf(this._left),1),this._left.leftVertex.rightEdge=null),t(this._right)&&(this._component.edges.splice(this._component.edges.indexOf(this._right),1),this._right.rightVertex.leftEdge=null),t(this._originalEdge)&&(this._component.edges.push(this._originalEdge),this._originalEdge.leftVertex.rightEdge=this._originalEdge,this._originalEdge.rightVertex.leftEdge=this._originalEdge),t(this._left)?this._component.updateVertexIndex(this._left.leftVertex,this._left.leftVertex.index):this._component.updateVertexIndex(this._addedVertex,0),this._editGeometry.notifyChanges({operation:"undo",removedVertices:[this._addedVertex]}))}accumulate(){return!1}}export{d as AppendVertex};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../../../core/maybe.js";import{Edge as t}from"../EditGeometry.js";class r{constructor(e,t,r=0){this._editGeometry=e,this._vertices=t,this._minNumberOfVertices=r,this.removedVertices=null}apply(){let t="redo";null==this.removedVertices?(this.removedVertices=[],this._vertices.forEach((t=>{const r=this._removeVertex(t);e(r)&&this.removedVertices.push(r)})),t="apply"):this.removedVertices.forEach((e=>{this._removeVertex(e.removedVertex)})),this._editGeometry.notifyChanges({operation:t,removedVertices:this._vertices})}undo(){this.removedVertices.forEach((e=>{this._undoRemoveVertex(e)})),this._editGeometry.notifyChanges({operation:"undo",addedVertices:this._vertices})}accumulate(){return!1}_removeVertex(e){const r=e.component;if(r.vertices.length<=this._minNumberOfVertices)return null;const i={removedVertex:e,createdEdge:null},s=e.leftEdge,d=e.rightEdge;return r.vertices.splice(r.vertices.indexOf(e),1),s&&(r.edges.splice(r.edges.indexOf(s),1),s.leftVertex.rightEdge=null),d&&(r.edges.splice(r.edges.indexOf(d),1),d.rightVertex.leftEdge=null),0===e.index&&d&&this._vertices.length>0&&r.swapVertices(r.vertices.indexOf(d.rightVertex),0),s&&d&&(i.createdEdge=new t(r,s.leftVertex,d.rightVertex),r.edges.push(i.createdEdge)),d&&r.updateVertexIndex(d.rightVertex,d.rightVertex.index-1),i}_undoRemoveVertex(e){const t=e.removedVertex,r=e.removedVertex.component,i=t.leftEdge,s=t.rightEdge;e.createdEdge&&r.edges.splice(r.edges.indexOf(e.createdEdge),1),r.vertices.push(t),i&&(r.edges.push(i),i.leftVertex.rightEdge=i),s&&(r.edges.push(s),s.rightVertex.leftEdge=s),r.updateVertexIndex(t,t.index)}}export{r as RemoveVertices};
5
+ import{isSome as e}from"../../../../core/maybe.js";import{Edge as t}from"../EditGeometry.js";class r{constructor(e,t,r=0){this._editGeometry=e,this._vertices=t,this._minNumberOfVertices=r,this.removedVertices=null}apply(){let t="redo";if(null==this.removedVertices){const r=this.removedVertices=[];this._vertices.forEach((t=>{const i=this._removeVertex(t);e(i)&&r.push(i)})),t="apply"}else this.removedVertices.forEach((e=>{this._removeVertex(e.removedVertex)}));this._editGeometry.notifyChanges({operation:t,removedVertices:this._vertices})}undo(){this.removedVertices?.forEach((e=>{this._undoRemoveVertex(e)})),this._editGeometry.notifyChanges({operation:"undo",addedVertices:this._vertices})}accumulate(){return!1}_removeVertex(e){const r=e.component;if(r.vertices.length<=this._minNumberOfVertices)return null;const i={removedVertex:e,createdEdge:null},s=e.leftEdge,d=e.rightEdge;return r.vertices.splice(r.vertices.indexOf(e),1),s&&(r.edges.splice(r.edges.indexOf(s),1),s.leftVertex.rightEdge=null),d&&(r.edges.splice(r.edges.indexOf(d),1),d.rightVertex.leftEdge=null),0===e.index&&d&&this._vertices.length>0&&r.swapVertices(r.vertices.indexOf(d.rightVertex),0),s&&d&&(i.createdEdge=new t(r,s.leftVertex,d.rightVertex),r.edges.push(i.createdEdge)),d&&r.updateVertexIndex(d.rightVertex,d.rightVertex.index-1),i}_undoRemoveVertex(e){const t=e.removedVertex,r=e.removedVertex.component,i=t.leftEdge,s=t.rightEdge;e.createdEdge&&r.edges.splice(r.edges.indexOf(e.createdEdge),1),r.vertices.push(t),i&&(r.edges.push(i),i.leftVertex.rightEdge=i),s&&(r.edges.push(s),s.rightVertex.leftEdge=s),r.updateVertexIndex(t,t.index)}}export{r as RemoveVertices};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e}from"../../../../core/maybe.js";import{Vertex as t,Edge as i}from"../EditGeometry.js";class r{constructor(e,t,i){this._editGeometry=e,this._edge=t,this._t=i,this.createdVertex=null,this._left=null,this._right=null}apply(){let r="redo";const s=this._edge,d=s.component,h=s.leftVertex,g=s.rightVertex;d.edges.splice(d.edges.indexOf(s),1),e(this.createdVertex)&&(r="apply",this.createdVertex=new t(s.component)),d.vertices.push(this.createdVertex),this.createdVertex.pos=this._editGeometry.coordinateHelper.lerp(s.leftVertex.pos,s.rightVertex.pos,this._t,this._editGeometry.coordinateHelper.createVector()),e(this._left)&&(this._left=new i(d,h,this.createdVertex)),this._left.leftVertex.leftEdge?d.edges.push(this._left):d.edges.unshift(this._left),h.rightEdge=this._left,e(this._right)&&(this._right=new i(d,this.createdVertex,g)),d.edges.push(this._right),g.leftEdge=this._right,d.updateVertexIndex(this.createdVertex,h.index+1),this._editGeometry.notifyChanges({operation:r,addedVertices:[this.createdVertex]})}undo(){if(e(this.createdVertex)||e(this._left)||e(this._right))return null;const t=this._edge,i=t.component,r=this.createdVertex.leftEdge,s=this.createdVertex.rightEdge,d=r.leftVertex,h=s.rightVertex;i.vertices.splice(i.vertices.indexOf(this.createdVertex),1),i.edges.splice(i.edges.indexOf(this._left),1),i.edges.splice(i.edges.indexOf(this._right),1),this._edge.leftVertex.leftEdge?i.edges.push(this._edge):i.edges.unshift(this._edge),d.rightEdge=t,h.leftEdge=t,i.updateVertexIndex(d,d.index),this._editGeometry.notifyChanges({operation:"undo",removedVertices:[this.createdVertex]})}accumulate(){return!1}}export{r as SplitEdge};
5
+ import{isNone as e}from"../../../../core/maybe.js";import{Vertex as t,Edge as i}from"../EditGeometry.js";class r{constructor(e,t,i){this._editGeometry=e,this._edge=t,this._t=i,this.createdVertex=null,this._left=null,this._right=null}apply(){let r="redo";const s=this._edge,d=s.component,h=s.leftVertex,g=s.rightVertex;d.edges.splice(d.edges.indexOf(s),1),e(this.createdVertex)&&(r="apply",this.createdVertex=new t(s.component)),d.vertices.push(this.createdVertex),this.createdVertex.pos=this._editGeometry.coordinateHelper.lerp(s.leftVertex.pos,s.rightVertex.pos,this._t,this._editGeometry.coordinateHelper.createVector()),e(this._left)&&(this._left=new i(d,h,this.createdVertex)),this._left.leftVertex.leftEdge?d.edges.push(this._left):d.edges.unshift(this._left),h.rightEdge=this._left,e(this._right)&&(this._right=new i(d,this.createdVertex,g)),d.edges.push(this._right),g.leftEdge=this._right,d.updateVertexIndex(this.createdVertex,h.index+1),this._editGeometry.notifyChanges({operation:r,addedVertices:[this.createdVertex]})}undo(){if(e(this.createdVertex)||e(this._left)||e(this._right))return null;const t=this._edge,i=t.component,r=this.createdVertex.leftEdge,s=this.createdVertex.rightEdge,d=r?.leftVertex,h=s?.rightVertex;i.vertices.splice(i.vertices.indexOf(this.createdVertex),1),i.edges.splice(i.edges.indexOf(this._left),1),i.edges.splice(i.edges.indexOf(this._right),1),this._edge.leftVertex.leftEdge?i.edges.push(this._edge):i.edges.unshift(this._edge),d&&(d.rightEdge=t),h&&(h.leftEdge=t),d&&i.updateVertexIndex(d,d.index),this._editGeometry.notifyChanges({operation:"undo",removedVertices:[this.createdVertex]})}accumulate(){return!1}}export{r as SplitEdge};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import has from"../../core/has.js";import{isNone as t,isSome as s}from"../../core/maybe.js";import{eachAlways as a}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Extent.js";import{getResolutionForScale as n}from"../../geometry/support/scaleUtils.js";import{combinedViewLayerTimeExtentProperty as l}from"../../layers/support/commonProperties.js";import{ExportImageParameters as m}from"../../layers/support/ExportImageParameters.js";import{getLayerFloorFilterClause as c}from"../../layers/support/floorFilterUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{identify as y}from"../../rest/identify.js";import h from"../../rest/support/IdentifyParameters.js";import{loadArcade as f}from"../../support/arcadeOnDemand.js";import{getRequiredFields as d,getFetchPopupTemplate as w}from"./support/popupUtils.js";const P=P=>{let x=class extends P{initialize(){this.exportImageParameters=new m({layer:this.layer})}destroy(){this.exportImageParameters.destroy(),this.exportImageParameters=null}get exportImageVersion(){return this.exportImageParameters?.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}async fetchPopupFeatures(e,t){const{layer:s}=this;if(!e)throw new r("mapimagelayer:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const a=this.layer.capabilities?.operations?.supportsQuery??!0;if(!((this.layer.capabilities?.operations?.supportsIdentify??!0)&&this.layer.version>=10.5)&&!a)throw new r("mapimagelayer:fetchPopupFeatures-not-supported","query operation is disabled for this service",{layer:s});return a?this._fetchPopupFeaturesUsingQueries(e,t):this._fetchPopupFeaturesUsingIdentify(e,t)}canResume(){return!!super.canResume()&&!this.timeExtent?.isEmpty}async _fetchPopupFeaturesUsingIdentify(e,r){const s=await this._createIdentifyParameters(e,r);if(t(s))return[];const{results:a}=await y(this.layer.parsedUrl,s);return a.map((e=>e.feature))}async _createIdentifyParameters(e,r){const{floors:t,spatialReference:a,scale:o}=this.view,i=s(r)?r.event:null,l=await this._collectPopupProviders(this.layer.sublayers,o,r);if(!l.length)return null;await Promise.all(l.map((({sublayer:e})=>e.load().catch((()=>{})))));const m=Math.min(has("mapimagelayer-popup-identify-max-tolerance"),this.layer.allSublayers.reduce(((e,r)=>r.renderer?u({renderer:r.renderer,event:i}):e),2)),c=this.createFetchPopupFeaturesQueryGeometry(e,m),y=n(o,a),f=Math.round(c.width/y),d=new p({xmin:c.center.x-y*f,ymin:c.center.y-y*f,xmax:c.center.x+y*f,ymax:c.center.y+y*f,spatialReference:c.spatialReference}),w=!1===this.layer.capabilities?.operations?.supportsQuery||await new Promise((e=>{let r=!1;Promise.all(l.map((async({popupTemplate:t})=>{if(t){const s=await this._loadArcadeModules(t);if(r)return;const a=s?.arcadeUtils.hasGeometryOperations(t);a&&(r=!0,e(!0))}}))).finally((()=>e(!1)))}));return new h({floors:t,gdbVersion:this.layer.gdbVersion,geometry:e,height:f,layerOption:"popup",mapExtent:d,maxAllowableOffset:w?0:y,returnGeometry:!0,spatialReference:a,sublayers:this.layer.sublayers,timeExtent:this.timeExtent,tolerance:m,width:f})}async _fetchPopupFeaturesUsingQueries(e,r){const t=await this._collectPopupProviders(this.layer.sublayers,this.view.scale,r),o=s(r)?r.event:null,i=t.map((async({sublayer:r,popupTemplate:t})=>{await r.load().catch((()=>{}));const a=r.createQuery(),i=u({renderer:r.renderer,event:o}),p=this.createFetchPopupFeaturesQueryGeometry(e,i);if(a.geometry=p,a.outFields=await d(r,t),"floors"in this.view){const e=this.view?.floors?.clone(),t=c(e,r);s(t)&&(a.where=a.where?`(${a.where}) AND (${t})`:t)}const n=await this._loadArcadeModules(t);n&&n.arcadeUtils.hasGeometryOperations(t)||(a.maxAllowableOffset=p.width/i);return(await r.queryFeatures(a)).features}));return(await a(i)).reduce(((e,r)=>r.value?[...e,...r.value]:e),[]).filter((e=>null!=e))}async _collectPopupProviders(e,r,t){const a=[],o=async e=>{const i=0===e.minScale||r<=e.minScale,p=0===e.maxScale||r>=e.maxScale;if(e.visible&&i&&p)if(e.sublayers)e.sublayers.forEach(o);else if(e.popupEnabled){const r=w(e,{...t,defaultPopupTemplateEnabled:!1});s(r)&&a.unshift({sublayer:e,popupTemplate:r})}},i=e.toArray().reverse().map(o);return await Promise.all(i),a}_loadArcadeModules(e){if(e.expressionInfos?.length||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type)))return f()}};return e([o()],x.prototype,"exportImageParameters",void 0),e([o({readOnly:!0})],x.prototype,"exportImageVersion",null),e([o()],x.prototype,"layer",void 0),e([o()],x.prototype,"suspended",void 0),e([o(l)],x.prototype,"timeExtent",void 0),x=e([i("esri.views.layers.MapImageLayerView")],x),x};export{P as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import has from"../../core/has.js";import{isNone as t,isSome as s}from"../../core/maybe.js";import{eachAlways as a}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Extent.js";import{getResolutionForScale as n}from"../../geometry/support/scaleUtils.js";import{combinedViewLayerTimeExtentProperty as l}from"../../layers/support/commonProperties.js";import{ExportImageParameters as m}from"../../layers/support/ExportImageParameters.js";import{getLayerFloorFilterClause as c}from"../../layers/support/floorFilterUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{identify as y}from"../../rest/identify.js";import h from"../../rest/support/IdentifyParameters.js";import{loadArcade as f}from"../../support/arcadeOnDemand.js";import{getRequiredFields as d,getFetchPopupTemplate as w}from"./support/popupUtils.js";const x=x=>{let P=class extends x{initialize(){this.exportImageParameters=new m({layer:this.layer})}destroy(){this.exportImageParameters.destroy(),this.exportImageParameters=null}get exportImageVersion(){return this.exportImageParameters?.commitProperty("version"),this.commitProperty("timeExtent"),(this._get("exportImageVersion")||0)+1}async fetchPopupFeatures(e,t){const{layer:s}=this;if(!e)throw new r("mapimagelayer:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const a=this.layer.capabilities?.operations?.supportsQuery??!0;if(!((this.layer.capabilities?.operations?.supportsIdentify??!0)&&this.layer.version>=10.5)&&!a)throw new r("mapimagelayer:fetchPopupFeatures-not-supported","query operation is disabled for this service",{layer:s});return a?this._fetchPopupFeaturesUsingQueries(e,t):this._fetchPopupFeaturesUsingIdentify(e,t)}canResume(){return!!super.canResume()&&!this.timeExtent?.isEmpty}async _fetchPopupFeaturesUsingIdentify(e,r){const s=await this._createIdentifyParameters(e,r);if(t(s))return[];const{results:a}=await y(this.layer.parsedUrl,s);return a.map((e=>e.feature))}async _createIdentifyParameters(e,r){const{floors:t,spatialReference:a,scale:o}=this.view,i=s(r)?r.event:null,l=await this._collectPopupProviders(this.layer.sublayers,o,r);if(!l.length)return null;await Promise.all(l.map((({sublayer:e})=>e.load().catch((()=>{})))));const m=Math.min(has("mapimagelayer-popup-identify-max-tolerance"),this.layer.allSublayers.reduce(((e,r)=>r.renderer?u({renderer:r.renderer,event:i}):e),2)),c=this.createFetchPopupFeaturesQueryGeometry(e,m),y=n(o,a),f=Math.round(c.width/y),d=new p({xmin:c.center.x-y*f,ymin:c.center.y-y*f,xmax:c.center.x+y*f,ymax:c.center.y+y*f,spatialReference:c.spatialReference}),w=!1===this.layer.capabilities?.operations?.supportsQuery||await new Promise((e=>{let r=!1;Promise.all(l.map((async({popupTemplate:t})=>{if(t){const s=await this._loadArcadeModules(t);if(r)return;const a=s?.arcadeUtils.hasGeometryOperations(t);a&&(r=!0,e(!0))}}))).finally((()=>e(!1)))}));return new h({floors:t,gdbVersion:this.layer.gdbVersion,geometry:e,height:f,layerOption:"popup",mapExtent:d,maxAllowableOffset:w?0:y,returnGeometry:!0,spatialReference:a,sublayers:this.layer.sublayers,timeExtent:this.timeExtent,tolerance:m,width:f})}async _fetchPopupFeaturesUsingQueries(e,r){const t=await this._collectPopupProviders(this.layer.sublayers,this.view.scale,r),o=s(r)?r.event:null,i=t.map((async({sublayer:r,popupTemplate:t})=>{await r.load().catch((()=>{}));const a=r.createQuery(),i=u({renderer:r.renderer,event:o}),p=this.createFetchPopupFeaturesQueryGeometry(e,i);if(a.geometry=p,a.outFields=await d(r,t),a.timeExtent=this.timeExtent,"floors"in this.view){const e=this.view?.floors?.clone(),t=c(e,r);s(t)&&(a.where=a.where?`(${a.where}) AND (${t})`:t)}const n=await this._loadArcadeModules(t);n&&n.arcadeUtils.hasGeometryOperations(t)||(a.maxAllowableOffset=p.width/i);return(await r.queryFeatures(a)).features}));return(await a(i)).reduce(((e,r)=>r.value?[...e,...r.value]:e),[]).filter((e=>null!=e))}async _collectPopupProviders(e,r,t){const a=[],o=async e=>{const i=0===e.minScale||r<=e.minScale,p=0===e.maxScale||r>=e.maxScale;if(e.visible&&i&&p)if(e.sublayers)e.sublayers.forEach(o);else if(e.popupEnabled){const r=w(e,{...t,defaultPopupTemplateEnabled:!1});s(r)&&a.unshift({sublayer:e,popupTemplate:r})}},i=e.toArray().reverse().map(o);return await Promise.all(i),a}_loadArcadeModules(e){if(e.expressionInfos?.length||Array.isArray(e.content)&&e.content.some((e=>"expression"===e.type)))return f()}};return e([o()],P.prototype,"exportImageParameters",void 0),e([o({readOnly:!0})],P.prototype,"exportImageVersion",null),e([o()],P.prototype,"layer",void 0),e([o()],P.prototype,"suspended",void 0),e([o(l)],P.prototype,"timeExtent",void 0),P=e([i("esri.views.layers.MapImageLayerView")],P),P};export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import t from"../../../geometry/Geometry.js";import{fromJSON as s}from"../../../geometry/support/jsonUtils.js";import p from"./ClipArea.js";import m from"../../../geometry/Extent.js";import i from"../../../geometry/Polygon.js";var y;const n={base:t,key:"type",typeMap:{extent:m,polygon:i}};let c=y=class extends p{constructor(){super(...arguments),this.type="geometry",this.geometry=null}get version(){return(this._get("version")||0)+1}clone(){return new y({geometry:this.geometry.clone()})}};r([e({types:n,json:{read:s,write:!0}})],c.prototype,"geometry",void 0),r([e({readOnly:!0})],c.prototype,"version",null),c=y=r([o("esri.views.layers.support.Geometry")],c);const a=c;export{a as default};
5
+ import{_ as r}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import t from"../../../geometry/Geometry.js";import{fromJSON as s}from"../../../geometry/support/jsonUtils.js";import p from"./ClipArea.js";import m from"../../../geometry/Extent.js";import i from"../../../geometry/Polygon.js";var y;const n={base:t,key:"type",typeMap:{extent:m,polygon:i}};let c=y=class extends p{constructor(){super(...arguments),this.type="geometry",this.geometry=null}get version(){return(this._get("version")||0)+1}clone(){return new y({geometry:this.geometry?.clone()??null})}};r([e({types:n,json:{read:s,write:!0}})],c.prototype,"geometry",void 0),r([e({readOnly:!0})],c.prototype,"version",null),c=y=r([o("esri.views.layers.support.Geometry")],c);const a=c;export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import{clamp as t}from"../../core/mathUtils.js";import{isNone as i}from"../../core/maybe.js";const h=2048,e=1.5,n=8;function o(i,h){const{format:e,quality:n,rotation:o,disableDecorations:a}=i||{},r=P(i,h.padding),l=I(i,{width:h.width-r.left-r.right,height:h.height-r.top-r.bottom}),{width:g,height:u}=v(i,l),f=k(e),d=W[f];return{format:f,quality:t(null!=n?n:d,0,100),area:l,width:g,height:u,rotation:o,disableDecorations:!!a,ignoreBackground:!(!i||!i.ignoreBackground),ignorePadding:!(!i||!i.ignorePadding)}}function a(t,i){const h=o(t,i),e=h.area,n=h.width/e.width,a=P(h,i.padding),r=a.left+a.right,l=a.top+a.bottom,g=i.width-r,u=i.height-l,f=Math.floor(g*n+r),d=Math.floor(u*n+l),c=t&&t.layers?t.layers:[],s=h.ignoreBackground,w=h.ignorePadding;return{framebufferWidth:f,framebufferHeight:d,region:{x:Math.floor(e.x*n)+a.left,y:Math.floor(e.y*n)+a.top,width:h.width,height:h.height},format:h.format,quality:h.quality,rotation:h.rotation,pixelRatio:n,layers:c,disableDecorations:h.disableDecorations,ignoreBackground:s,ignorePadding:w,objectAndLayerIdColor:!1}}function r(t,i,h){const{ctx:e,canvas:n}=g(t,h),o=e.getImageData(0,0,t.width,t.height),a=c(n,i);return u(n),{dataUrl:a,data:o}}function l(t,i){const{ctx:h,canvas:e}=g(t,i),n=h.getImageData(0,0,t.width,t.height);return u(e),n}function g(t,i){const h=f();i.premultipliedAlpha&&E(t),h.width=t.width,h.height=t.height;const e=h.getContext("2d");return e.putImageData(t,0,0),i.flipY&&B(e),{ctx:e,canvas:h}}function u(t){t.width=0,t.height=0}function f(){return i(d)&&(d=document.createElement("canvas")),d}let d=null;function c(t,i){const h=R[i.format],e=i.quality/100;return t.toDataURL(h,e)}function s(i,h){const e=k(i),n=W[e];return{format:e,quality:t(null!=h?h:n,0,100)}}function w(t,i){return i/Math.max(t[0],t[1])}function m(t,i,h){if(!t||!i)throw new Error("Cannot construct image data without dimensions");if(j)try{return new ImageData(t,i)}catch(e){j=!1}return x(t,i,h)}function M(t,i,h,e){if(!i||!h)throw new Error("Cannot construct image data without dimensions");if(j)try{return new ImageData(t,i,h)}catch(o){j=!1}const n=x(i,h,e);return n.data.set(t,0),n}function p(t,i,h,e=0,n=0,o=t.width-e,a=t.height-n,r=!1){const{data:l}=t,{width:g,height:u,data:f}=i,d=o/g,c=a/u,s=Math.ceil(d/2),w=Math.ceil(c/2),m=t.width;for(let M=0;M<u;M++)for(let t=0;t<g;t++){const i=4*(t+(r?u-M-1:M)*g);let o=0,a=0,p=0,y=0,x=0,b=0;const j=(M+.5)*c;for(let r=Math.floor(M*c);r<(M+1)*c;r++){const i=Math.abs(j-(r+.5))/w,g=(t+.5)*d,u=i*i;for(let f=Math.floor(t*d);f<(t+1)*d;f++){const t=Math.abs(g-(f+.5))/s,i=Math.sqrt(u+t*t);if(i>=1)continue;let d=2*i*i*i-3*i*i+1;const c=4*(e+f+(n+r)*m);b+=d*l[c+3],a+=d,!h&&l[c+3]<255&&(d=d*l[c+3]/255),p+=d*l[c],y+=d*l[c+1],x+=d*l[c+2],o+=d}}f[i]=p/o,f[i+1]=y/o,f[i+2]=x/o,f[i+3]=b/a}return i}function y(t,i,o){if(!i)return t;const{framebufferWidth:a,framebufferHeight:r,pixelRatio:l,region:g}=t,u=P(t,o),f=u.left+u.right,d=u.top+u.bottom,c=a-f,s=r-d,w=Math.min(n,Math.min((h-f)/c,(h-d)/s));return w<e?t:{...t,framebufferWidth:Math.round(c*w)+f,framebufferHeight:Math.round(s*w)+d,pixelRatio:l*w,resample:{region:{x:Math.round((g.x-u.left)*w)+u.left,y:Math.round((g.y-u.top)*w)+u.top,width:Math.round(g.width*w),height:Math.round(g.height*w)},width:a,height:r}}}function x(t,i,h){return h||(h=D()),h.getContext("2d").createImageData(t,i)}let b=null,j=!0;function D(){return b||(b=document.createElement("canvas"),b.width=1,b.height=1),b}function v(t,i){if(!t)return i;const h=t.width,e=t.height;if(null!=h&&null!=e)return{width:Math.floor(h),height:Math.floor(e)};if(null==h&&null==e)return i;const n=i.width/i.height;return null==e?{width:Math.floor(h),height:Math.floor(h/n)}:{width:Math.floor(e*n),height:Math.floor(e)}}function I(t,i){const h={x:0,y:0,width:i.width,height:i.height};if(t&&t.area){null!=t.area.x&&(h.x=Math.floor(t.area.x)),null!=t.area.y&&(h.y=Math.floor(t.area.y));const e=null!=t.area.width?Math.floor(t.area.width):null,n=null!=t.area.height?Math.floor(t.area.height):null;if(h.width=i.width-h.x,h.height=i.height-h.y,null!=e&&null!=n)h.width=Math.min(h.width,e),h.height=Math.min(h.height,n);else if(null==e&&null!=n){const t=Math.min(h.width,e);h.height=t/h.width*h.height,h.width=t}else if(null!=e&&null==n){const t=Math.min(h.height,n);h.width=t/h.height*h.width,h.height=t}}return q(C(h,t),i)}function q(t,i){const h=Math.floor(Math.max(t.x,0)),e=Math.floor(Math.max(t.y,0)),n={x:h,y:e,width:Math.floor(Math.min(t.width,i.width-h)),height:Math.floor(Math.min(t.height,i.height-e))},o=n.width/n.height,a=t.width/t.height;if(a===o)return n;if(a>o){const t=Math.floor(n.width/a),i=n.height-t;return{x:n.x,y:Math.floor(n.y+i/2),width:n.width,height:t}}const r=Math.floor(n.height*a),l=n.width-r;return{x:Math.floor(n.x+l/2),y:n.y,width:r,height:n.height}}function C(t,i){if(!i||null==i.width||null==i.height)return t;const h=i.width/i.height,e=t.width/t.height;if(e===h)return t;if(e<h){const i=Math.floor(t.height*h);return t.x-=(i-t.width)/2,t.width=i,t}const n=Math.floor(t.width/h);return t.y-=(n-t.height)/2,t.height=n,t}function P(t,i){return!i||t&&t.ignorePadding?A:i}function k(t){switch(t){case"png":case"jpg":case"jpeg":return t;default:return U}}function B(t){t.save(),t.globalCompositeOperation="copy",t.scale(1,-1),t.translate(0,-t.canvas.height),t.drawImage(t.canvas,0,0),t.restore()}function E(t){const i=t.data,h=i.length;for(let e=0;e<h;e+=4){const t=i[e+3];if(255!==t&&t>0){const h=255/t;i[e+0]=i[e+0]*h,i[e+1]=i[e+1]*h,i[e+2]=i[e+2]*h}}}const R={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg"},H=98,U="png",W={png:100,jpg:H,jpeg:H},A={top:0,right:0,bottom:0,left:0};export{o as completeUserSettings,m as createEmptyImageData,r as encode,l as encodeData,s as getFormatAndQuality,w as getMaximumResolutionScale,p as resampleHermite,y as screenshotSuperSampleSettings,c as toDataUrl,a as toRenderSettings,M as wrapImageData};
5
+ import"../../core/has.js";import{clamp as t}from"../../core/mathUtils.js";import{isNone as h}from"../../core/maybe.js";export{createEmptyImageData}from"../../core/imageUtils.js";const i=2048,e=1.5,o=8;function n(h,i){const{format:e,quality:o,rotation:n,disableDecorations:a}=h||{},r=j(h,i.padding),l=y(h,{width:i.width-r.left-r.right,height:i.height-r.top-r.bottom}),{width:g,height:f}=p(h,l),d=D(e),u=B[d];return{format:d,quality:t(null!=o?o:u,0,100),area:l,width:g,height:f,rotation:n,disableDecorations:!!a,ignoreBackground:!(!h||!h.ignoreBackground),ignorePadding:!(!h||!h.ignorePadding)}}function a(t,h){const i=n(t,h),e=i.area,o=i.width/e.width,a=j(i,h.padding),r=a.left+a.right,l=a.top+a.bottom,g=h.width-r,f=h.height-l,d=Math.floor(g*o+r),u=Math.floor(f*o+l),c=t&&t.layers?t.layers:[],s=i.ignoreBackground,w=i.ignorePadding;return{framebufferWidth:d,framebufferHeight:u,region:{x:Math.floor(e.x*o)+a.left,y:Math.floor(e.y*o)+a.top,width:i.width,height:i.height},format:i.format,quality:i.quality,rotation:i.rotation,pixelRatio:o,layers:c,disableDecorations:i.disableDecorations,ignoreBackground:s,ignorePadding:w,objectAndLayerIdColor:!1}}function r(t,h,i){const{ctx:e,canvas:o}=g(t,i),n=e.getImageData(0,0,t.width,t.height),a=c(o,h);return f(o),{dataUrl:a,data:n}}function l(t,h){const{ctx:i,canvas:e}=g(t,h),o=i.getImageData(0,0,t.width,t.height);return f(e),o}function g(t,h){const i=d();h.premultipliedAlpha&&v(t),i.width=t.width,i.height=t.height;const e=i.getContext("2d");return e.putImageData(t,0,0),h.flipY&&q(e),{ctx:e,canvas:i}}function f(t){t.width=0,t.height=0}function d(){return h(u)&&(u=document.createElement("canvas")),u}let u=null;function c(t,h){const i=I[h.format],e=h.quality/100;return t.toDataURL(i,e)}function s(h,i){const e=D(h),o=B[e];return{format:e,quality:t(null!=i?i:o,0,100)}}function w(t,h){return h/Math.max(t[0],t[1])}function m(t,h,i,e=0,o=0,n=t.width-e,a=t.height-o,r=!1){const{data:l}=t,{width:g,height:f,data:d}=h,u=n/g,c=a/f,s=Math.ceil(u/2),w=Math.ceil(c/2),m=t.width;for(let M=0;M<f;M++)for(let t=0;t<g;t++){const h=4*(t+(r?f-M-1:M)*g);let n=0,a=0,p=0,y=0,x=0,b=0;const j=(M+.5)*c;for(let r=Math.floor(M*c);r<(M+1)*c;r++){const h=Math.abs(j-(r+.5))/w,g=(t+.5)*u,f=h*h;for(let d=Math.floor(t*u);d<(t+1)*u;d++){const t=Math.abs(g-(d+.5))/s,h=Math.sqrt(f+t*t);if(h>=1)continue;let u=2*h*h*h-3*h*h+1;const c=4*(e+d+(o+r)*m);b+=u*l[c+3],a+=u,!i&&l[c+3]<255&&(u=u*l[c+3]/255),p+=u*l[c],y+=u*l[c+1],x+=u*l[c+2],n+=u}}d[h]=p/n,d[h+1]=y/n,d[h+2]=x/n,d[h+3]=b/a}return h}function M(t,h,n){if(!h)return t;const{framebufferWidth:a,framebufferHeight:r,pixelRatio:l,region:g}=t,f=j(t,n),d=f.left+f.right,u=f.top+f.bottom,c=a-d,s=r-u,w=Math.min(o,Math.min((i-d)/c,(i-u)/s));return w<e?t:{...t,framebufferWidth:Math.round(c*w)+d,framebufferHeight:Math.round(s*w)+u,pixelRatio:l*w,resample:{region:{x:Math.round((g.x-f.left)*w)+f.left,y:Math.round((g.y-f.top)*w)+f.top,width:Math.round(g.width*w),height:Math.round(g.height*w)},width:a,height:r}}}function p(t,h){if(!t)return h;const i=t.width,e=t.height;if(null!=i&&null!=e)return{width:Math.floor(i),height:Math.floor(e)};if(null==i&&null==e)return h;const o=h.width/h.height;return null==e?{width:Math.floor(i),height:Math.floor(i/o)}:{width:Math.floor(e*o),height:Math.floor(e)}}function y(t,h){const i={x:0,y:0,width:h.width,height:h.height};if(t&&t.area){null!=t.area.x&&(i.x=Math.floor(t.area.x)),null!=t.area.y&&(i.y=Math.floor(t.area.y));const e=null!=t.area.width?Math.floor(t.area.width):null,o=null!=t.area.height?Math.floor(t.area.height):null;if(i.width=h.width-i.x,i.height=h.height-i.y,null!=e&&null!=o)i.width=Math.min(i.width,e),i.height=Math.min(i.height,o);else if(null==e&&null!=o){const t=Math.min(i.width,e);i.height=t/i.width*i.height,i.width=t}else if(null!=e&&null==o){const t=Math.min(i.height,o);i.width=t/i.height*i.width,i.height=t}}return x(b(i,t),h)}function x(t,h){const i=Math.floor(Math.max(t.x,0)),e=Math.floor(Math.max(t.y,0)),o={x:i,y:e,width:Math.floor(Math.min(t.width,h.width-i)),height:Math.floor(Math.min(t.height,h.height-e))},n=o.width/o.height,a=t.width/t.height;if(a===n)return o;if(a>n){const t=Math.floor(o.width/a),h=o.height-t;return{x:o.x,y:Math.floor(o.y+h/2),width:o.width,height:t}}const r=Math.floor(o.height*a),l=o.width-r;return{x:Math.floor(o.x+l/2),y:o.y,width:r,height:o.height}}function b(t,h){if(!h||null==h.width||null==h.height)return t;const i=h.width/h.height,e=t.width/t.height;if(e===i)return t;if(e<i){const h=Math.floor(t.height*i);return t.x-=(h-t.width)/2,t.width=h,t}const o=Math.floor(t.width/i);return t.y-=(o-t.height)/2,t.height=o,t}function j(t,h){return!h||t&&t.ignorePadding?R:h}function D(t){switch(t){case"png":case"jpg":case"jpeg":return t;default:return k}}function q(t){t.save(),t.globalCompositeOperation="copy",t.scale(1,-1),t.translate(0,-t.canvas.height),t.drawImage(t.canvas,0,0),t.restore()}function v(t){const h=t.data,i=h.length;for(let e=0;e<i;e+=4){const t=h[e+3];if(255!==t&&t>0){const i=255/t;h[e+0]=h[e+0]*i,h[e+1]=h[e+1]*i,h[e+2]=h[e+2]*i}}}const I={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg"},P=98,k="png",B={png:100,jpg:P,jpeg:P},R={top:0,right:0,bottom:0,left:0};export{n as completeUserSettings,r as encode,l as encodeData,s as getFormatAndQuality,w as getMaximumResolutionScale,m as resampleHermite,M as screenshotSuperSampleSettings,c as toDataUrl,a as toRenderSettings};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t}from"../../core/maybe.js";function i(t){const i=t.capabilities.disjointTimerQuery;return e(i)?null:i.timestampBits()>0?new _(i):u?null:new s(i)}function r(t,i){const r=t.capabilities.disjointTimerQuery;return e(r)?null:new h(r,i)}class s{constructor(e){this._timer=e,this._timer.disjoint(),this._query=this._timer.createQuery(),u=!0,this._timer.beginTimeElapsed(this._query)}stop(e,t=50){this._timer.endTimeElapsed(),u=!1,this._checkQueryResult(e,t)}abort(){this._deleteQuery(),u=!1}_deleteQuery(){this._query&&(this._timer.deleteQuery(this._query),this._query=null)}_checkQueryResult(e,t){if(this._timer.disjoint())return this._deleteQuery(),void e(null);if(!this._timer.resultAvailable(this._query))return void setTimeout((()=>this._checkQueryResult(e,t)),t);const i=this._timer.getResult(this._query);this._deleteQuery(),e(i/1e6)}}let u=!1;class h{constructor(e,t){this._timer=e,this._queryPool=new Array,this._queryResults=new Map,this._currentQuery=null,t.forEach((e=>{const t=this._timer.createQuery(),i=this._timer.createQuery();this._queryPool.push(t,i),this._queryResults.set(e,null)}))}start(){u||(this._currentQuery=this._queryPool.pop(),e(this._currentQuery)||(this._timer.disjoint(),u=!0,this._timer.beginTimeElapsed(this._currentQuery)))}stop(t){let i=null;if(this._timer.disjoint()||e(this._currentQuery)||!this._queryResults.has(t))return this.abort(),i;this._timer.endTimeElapsed(),u=!1;const r=this._queryResults.get(t);return e(r)?(this._queryResults.set(t,this._currentQuery),this._currentQuery=null,i):this._timer.resultAvailable(r)?(i=this._timer.getResult(r)/1e6,this._queryPool.unshift(r),this._queryResults.set(t,this._currentQuery),this._currentQuery=null,i):(this._queryPool.unshift(this._currentQuery),this._currentQuery=null,i)}abort(){t(this._currentQuery)&&(this._timer.deleteQuery(this._currentQuery),this._queryPool.unshift(this._timer.createQuery()),this._currentQuery=null),u=!1}dispose(){t(this._currentQuery)&&this._timer.deleteQuery(this._currentQuery),u=!1,this._queryPool.forEach((e=>{this._timer.deleteQuery(e)})),this._queryResults.forEach((t=>{e(t)||this._timer.deleteQuery(t)}))}}class _{constructor(e){this._timer=e,this._timer.disjoint(),this._start=this._timer.createQuery(),this._end=this._timer.createQuery(),this._timer.createTimestamp(this._start)}abort(){this._deleteQueries()}stop(e,t=50){this._timer.createTimestamp(this._end),this._checkQueryResult(e,t)}_deleteQueries(){this._start&&(this._timer.deleteQuery(this._start),this._start=null),this._end&&(this._timer.deleteQuery(this._end),this._end=null)}_checkQueryResult(e,t){if(this._timer.disjoint())return this._deleteQueries(),void e(null);if(!this._timer.resultAvailable(this._end))return void setTimeout((()=>this._checkQueryResult(e,t)),t);const i=this._timer.getResult(this._start),r=this._timer.getResult(this._end);this._deleteQueries(),e((r-i)/1e6)}}export{r as createElapsedTimerPool,i as startMeasurement};
5
+ import{isNone as e}from"../../core/maybe.js";import{hasRunningElapsedTimer as t}from"./capabilities/DisjointTimerQuery.js";function i(i){const h=i.capabilities.disjointTimerQuery;return e(h)?null:h.timestampBits()>0?new r(h):t?null:new s(h)}class s{constructor(e){this._timer=e,this._timer.disjoint(),this._query=this._timer.createQuery(),this._timer.beginTimeElapsed(this._query)}stop(e,t=50){this._timer.endTimeElapsed(),this._checkQueryResult(e,t)}abort(){this._deleteQuery()}_deleteQuery(){this._query&&(this._timer.deleteQuery(this._query),this._query=null)}_checkQueryResult(e,t){if(this._timer.disjoint())return this._deleteQuery(),void e(null);if(!this._timer.resultAvailable(this._query))return void setTimeout((()=>this._checkQueryResult(e,t)),t);const i=this._timer.getResult(this._query);this._deleteQuery(),e(i/1e6)}}class r{constructor(e){this._timer=e,this._timer.disjoint(),this._start=this._timer.createQuery(),this._end=this._timer.createQuery(),this._timer.createTimestamp(this._start)}abort(){this._deleteQueries()}stop(e,t=50){this._timer.createTimestamp(this._end),this._checkQueryResult(e,t)}_deleteQueries(){this._start&&(this._timer.deleteQuery(this._start),this._start=null),this._end&&(this._timer.deleteQuery(this._end),this._end=null)}_checkQueryResult(e,t){if(this._timer.disjoint())return this._deleteQueries(),void e(null);if(!this._timer.resultAvailable(this._end))return void setTimeout((()=>this._checkQueryResult(e,t)),t);const i=this._timer.getResult(this._start),s=this._timer.getResult(this._end);this._deleteQueries(),e((s-i)/1e6)}}export{i as startMeasurement};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
+ */
5
+ import{isNone as e,isSome as t}from"../../core/maybe.js";import{hasRunningElapsedTimer as r}from"./capabilities/DisjointTimerQuery.js";function s(t,r){const s=t.capabilities.disjointTimerQuery;return e(s)?null:new i(s,r)}class i{constructor(e,t){this._timer=e,this._queryPool=new Array,this._queryResults=new Map,this._currentQuery=null,t.forEach((e=>{const t=this._timer.createQuery(),r=this._timer.createQuery();this._queryPool.push(t,r),this._queryResults.set(e,null)}))}start(){r||(this._currentQuery=this._queryPool.pop(),e(this._currentQuery)||(this._timer.disjoint(),this._timer.beginTimeElapsed(this._currentQuery)))}stop(t){if(this._timer.disjoint()||e(this._currentQuery)||!this._queryResults.has(t))return this.abort(),null;this._timer.endTimeElapsed();const r=this._queryResults.get(t);if(e(r))return this._queryResults.set(t,this._currentQuery),this._currentQuery=null,null;if(!this._timer.resultAvailable(r))return this._queryPool.unshift(this._currentQuery),this._currentQuery=null,null;const s=this._timer.getResult(r)/1e6;return this._queryPool.unshift(r),this._queryResults.set(t,this._currentQuery),this._currentQuery=null,s}abort(){t(this._currentQuery)&&(this._timer.deleteQuery(this._currentQuery),this._queryPool.unshift(this._timer.createQuery()),this._currentQuery=null)}dispose(){t(this._currentQuery)&&this._timer.deleteQuery(this._currentQuery),this._queryPool.forEach((e=>{this._timer.deleteQuery(e)})),this._queryResults.forEach((t=>{e(t)||this._timer.deleteQuery(t)}))}}export{s as createElapsedTimerPool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"./isWebGL2Context.js";class t{constructor(e,t,E,T,r,_,i,u,s){this.createQuery=e,this.deleteQuery=t,this.resultAvailable=E,this.getResult=T,this.disjoint=r,this.beginTimeElapsed=_,this.endTimeElapsed=i,this.createTimestamp=u,this.timestampBits=s}}function E(E,T){if(T.disjointTimerQuery)return null;let r=E.getExtension("EXT_disjoint_timer_query_webgl2");return r&&e(E)?new t((()=>E.createQuery()),(e=>E.deleteQuery(e)),(e=>E.getQueryParameter(e,E.QUERY_RESULT_AVAILABLE)),(e=>E.getQueryParameter(e,E.QUERY_RESULT)),(()=>E.getParameter(r.GPU_DISJOINT_EXT)),(e=>E.beginQuery(r.TIME_ELAPSED_EXT,e)),(()=>E.endQuery(r.TIME_ELAPSED_EXT)),(e=>r.queryCounterEXT(e,r.TIMESTAMP_EXT)),(()=>E.getQuery(r.TIMESTAMP_EXT,r.QUERY_COUNTER_BITS_EXT))):(r=E.getExtension("EXT_disjoint_timer_query"),r?new t((()=>r.createQueryEXT()),(e=>r.deleteQueryEXT(e)),(e=>r.getQueryObjectEXT(e,r.QUERY_RESULT_AVAILABLE_EXT)),(e=>r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)),(()=>E.getParameter(r.GPU_DISJOINT_EXT)),(e=>r.beginQueryEXT(r.TIME_ELAPSED_EXT,e)),(()=>r.endQueryEXT(r.TIME_ELAPSED_EXT)),(e=>r.queryCounterEXT(e,r.TIMESTAMP_EXT)),(()=>r.getQueryEXT(r.TIMESTAMP_EXT,r.QUERY_COUNTER_BITS_EXT))):null)}export{t as DisjointTimerQuery,E as createDisjointTimerQuery};
5
+ import e from"./isWebGL2Context.js";class t{constructor(e,t,E,T,r,_,i,u,s){this.createQuery=e,this.deleteQuery=t,this.resultAvailable=E,this.getResult=T,this.disjoint=r,this.beginTimeElapsed=_,this.endTimeElapsed=i,this.createTimestamp=u,this.timestampBits=s}}let E=!1;function T(T,r){if(r.disjointTimerQuery)return null;let _=T.getExtension("EXT_disjoint_timer_query_webgl2");return _&&e(T)?new t((()=>T.createQuery()),(e=>{T.deleteQuery(e),E=!1}),(e=>T.getQueryParameter(e,T.QUERY_RESULT_AVAILABLE)),(e=>T.getQueryParameter(e,T.QUERY_RESULT)),(()=>T.getParameter(_.GPU_DISJOINT_EXT)),(e=>{E||(E=!0,T.beginQuery(_.TIME_ELAPSED_EXT,e))}),(()=>{T.endQuery(_.TIME_ELAPSED_EXT),E=!1}),(e=>_.queryCounterEXT(e,_.TIMESTAMP_EXT)),(()=>T.getQuery(_.TIMESTAMP_EXT,_.QUERY_COUNTER_BITS_EXT))):(_=T.getExtension("EXT_disjoint_timer_query"),_?new t((()=>_.createQueryEXT()),(e=>{_.deleteQueryEXT(e),E=!1}),(e=>_.getQueryObjectEXT(e,_.QUERY_RESULT_AVAILABLE_EXT)),(e=>_.getQueryObjectEXT(e,_.QUERY_RESULT_EXT)),(()=>T.getParameter(_.GPU_DISJOINT_EXT)),(e=>{E||(E=!0,_.beginQueryEXT(_.TIME_ELAPSED_EXT,e))}),(()=>{_.endQueryEXT(_.TIME_ELAPSED_EXT),E=!1}),(e=>_.queryCounterEXT(e,_.TIMESTAMP_EXT)),(()=>_.getQueryEXT(_.TIMESTAMP_EXT,_.QUERY_COUNTER_BITS_EXT))):null)}export{t as DisjointTimerQuery,T as createDisjointTimerQuery,E as hasRunningElapsedTimer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import a from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{on as s,when as n,watch as l,whenOnce as p,initial as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import f from"../Attachments/AttachmentsViewModel.js";import h from"./CreateFeaturesWorkflow.js";import k from"./CreateWorkflow.js";import{workflowDeprecation as y}from"./deprecationUtils.js";import m from"./UpdateWorkflow.js";import W from"../FeatureForm/FeatureFormViewModel.js";import v from"../FeatureTemplates/FeatureTemplatesViewModel.js";import g from"../Sketch/SketchViewModel.js";import _ from"../Spinner/SpinnerViewModel.js";const C="esri.widgets.Editor.EditorViewModel",F=i.getLogger(C),b=["create","create-features","update"];function M(e,t,a){F.error(new r(e,t,a))}function V(e,t){return e&&e.find((e=>e.layer===t))}let O=class extends(o(a.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new w({listMode:"hide",internal:!0}),this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new f({abilities:{editing:!0}}),this.featureFormViewModel=new W,this.featureTemplatesViewModel=new v,this.layerInfos=null,this.sketchViewModel=new g({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new _}initialize(){this.handles.add([s((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),s((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),n((()=>this.view?.map),(e=>{e.add(this._sketchGraphicsLayer)}),c),l((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...b]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")))}get editableItems(){const e=this.view?.allLayerViews;if(!e)return new t;const r=this.view?.map?.editableLayers,a=new Set(r),o=r?.filter((e=>e.capabilities.operations.supportsAdd&&!e.capabilities.operations.supportsQuery)),i=e.filter((e=>a.has(e.layer))).map((({layer:e,suspended:t})=>this._getEditableItemFromLayer(e,t))).reverse();return o?.forEach((e=>i.push(this._getEditableItemFromLayer(e,!1)))),i}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(e){this.sketchViewModel.labelOptions=e}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(e){this.sketchViewModel.snappingOptions=e}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(e){this.sketchViewModel.tooltipOptions=e}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(y(F,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(y(F,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(e,t);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(e){if(y(F,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):M("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&M("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return h.create(this,e,t,((e,t)=>this._applyEdits(e,t)))}_createCreateWorkflow(e){return k.create(this,e,((e,t)=>this._applyEdits(e,t)))}_createUpdateWorkflow(e){return m.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e.sourceLayer;"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}async _applyEdits(e,t){await this._queueOperation((async()=>{if(e.capabilities.operations.supportsQuery){const r=await this.view.whenLayerView(e),a=await e.applyEdits(t);return await p((()=>!r.updating)),a}return e.applyEdits(t)}))}_queueOperation(e){this._activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((({addFeatureResults:e,deleteFeatureResults:t,updateFeatureResults:r})=>{const a=e.find((e=>!!e.error))||r.find((e=>!!e.error))||t.find((e=>!!e.error));if(a)throw a.error})).catch((r=>{M("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue),this.notifyChange("syncing")}))}_getEditableItemFromLayer(e,t=!0){const{data:r,operations:a}=e.capabilities,o=V(this.layerInfos,e),i="supportsAttachment"in r&&r.supportsAttachment&&(!o||!1!==o.allowAttachments);if(t)return{hasAttachments:i,layer:e,supports:[]};const s=[];return a.supportsAdd&&(this.allowedWorkflows.includes("create")||this.allowedWorkflows.includes("create-features"))&&(!o||!1!==o.enabled&&!1!==o.addEnabled)&&s.push("create"),a.supportsUpdate&&this.allowedWorkflows.includes("update")&&(!o||!1!==o.enabled&&!1!==o.updateEnabled)&&s.push("update"),!1!==(o&&o.deleteEnabled)&&a.supportsDelete&&s.push("delete"),{hasAttachments:i,layer:e,supports:s}}};e([d({readOnly:!0})],O.prototype,"activeWorkflow",void 0),e([d({readOnly:!0})],O.prototype,"_activityQueue",void 0),e([d({value:[...b]})],O.prototype,"allowedWorkflows",null),e([d({readOnly:!0})],O.prototype,"canCreate",null),e([d({readOnly:!0})],O.prototype,"canUpdate",null),e([d({readOnly:!0})],O.prototype,"editableItems",null),e([d({readOnly:!0})],O.prototype,"failures",void 0),e([d()],O.prototype,"attachmentsViewModel",void 0),e([d()],O.prototype,"featureFormViewModel",void 0),e([d()],O.prototype,"featureTemplatesViewModel",void 0),e([d()],O.prototype,"labelOptions",null),e([d()],O.prototype,"layerInfos",void 0),e([d()],O.prototype,"sketchViewModel",void 0),e([d()],O.prototype,"snappingOptions",null),e([d()],O.prototype,"spinnerViewModel",void 0),e([d()],O.prototype,"state",null),e([d({readOnly:!0})],O.prototype,"syncing",null),e([d()],O.prototype,"tooltipOptions",null),e([d()],O.prototype,"view",null),O=e([u(C)],O);const A=O;export{A as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import a from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{on as s,when as n,watch as l,whenOnce as p,initial as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import f from"../Attachments/AttachmentsViewModel.js";import h from"./CreateFeaturesWorkflow.js";import k from"./CreateWorkflow.js";import{workflowDeprecation as y}from"./deprecationUtils.js";import m from"./UpdateWorkflow.js";import W from"../FeatureForm/FeatureFormViewModel.js";import v from"../FeatureTemplates/FeatureTemplatesViewModel.js";import g from"../Sketch/SketchViewModel.js";import _ from"../Spinner/SpinnerViewModel.js";const C="esri.widgets.Editor.EditorViewModel",F=i.getLogger(C),b=["create","create-features","update"];function M(e,t,a){F.error(new r(e,t,a))}function V(e,t){return e&&e.find((e=>e.layer===t))}let O=class extends(o(a.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new w({listMode:"hide",internal:!0}),this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new f({abilities:{editing:!0}}),this.featureFormViewModel=new W,this.featureTemplatesViewModel=new v,this.layerInfos=null,this.sketchViewModel=new g({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new _}initialize(){this.handles.add([s((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),s((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),n((()=>this.view?.map),(e=>{e.add(this._sketchGraphicsLayer)}),c),l((()=>this.editableItems.toArray()),(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...b]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")))}get editableItems(){const e=this.view?.allLayerViews;if(!e)return new t;const r=this.view?.map?.editableLayers,a=new Set(r),o=r?.filter((e=>e.visible&&e.capabilities.operations.supportsAdd&&!e.capabilities.operations.supportsQuery)),i=e.filter((e=>a.has(e.layer))).map((({layer:e,suspended:t})=>this._getEditableItemFromLayer(e,t))).reverse();return o?.forEach((e=>i.push(this._getEditableItemFromLayer(e,!1)))),i}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(e){this.sketchViewModel.labelOptions=e}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(e){this.sketchViewModel.snappingOptions=e}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(e){this.sketchViewModel.tooltipOptions=e}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(y(F,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(y(F,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(e,t);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(e){if(y(F,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void M("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void M("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):M("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&M("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return h.create(this,e,t,((e,t)=>this._applyEdits(e,t)))}_createCreateWorkflow(e){return k.create(this,e,((e,t)=>this._applyEdits(e,t)))}_createUpdateWorkflow(e){return m.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e.sourceLayer;"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}async _applyEdits(e,t){await this._queueOperation((async()=>{if(e.capabilities.operations.supportsQuery){const r=await this.view.whenLayerView(e),a=await e.applyEdits(t);return await p((()=>!r.updating)),a}return e.applyEdits(t)}))}_queueOperation(e){this._activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((({addFeatureResults:e,deleteFeatureResults:t,updateFeatureResults:r})=>{const a=e.find((e=>!!e.error))||r.find((e=>!!e.error))||t.find((e=>!!e.error));if(a)throw a.error})).catch((r=>{M("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue),this.notifyChange("syncing")}))}_getEditableItemFromLayer(e,t=!0){const{data:r,operations:a}=e.capabilities,o=V(this.layerInfos,e),i="supportsAttachment"in r&&r.supportsAttachment&&(!o||!1!==o.allowAttachments);if(t)return{hasAttachments:i,layer:e,supports:[]};const s=[];return a.supportsAdd&&(this.allowedWorkflows.includes("create")||this.allowedWorkflows.includes("create-features"))&&(!o||!1!==o.enabled&&!1!==o.addEnabled)&&s.push("create"),a.supportsUpdate&&this.allowedWorkflows.includes("update")&&(!o||!1!==o.enabled&&!1!==o.updateEnabled)&&s.push("update"),!1!==(o&&o.deleteEnabled)&&a.supportsDelete&&s.push("delete"),{hasAttachments:i,layer:e,supports:s}}};e([d({readOnly:!0})],O.prototype,"activeWorkflow",void 0),e([d({readOnly:!0})],O.prototype,"_activityQueue",void 0),e([d({value:[...b]})],O.prototype,"allowedWorkflows",null),e([d({readOnly:!0})],O.prototype,"canCreate",null),e([d({readOnly:!0})],O.prototype,"canUpdate",null),e([d({readOnly:!0})],O.prototype,"editableItems",null),e([d({readOnly:!0})],O.prototype,"failures",void 0),e([d()],O.prototype,"attachmentsViewModel",void 0),e([d()],O.prototype,"featureFormViewModel",void 0),e([d()],O.prototype,"featureTemplatesViewModel",void 0),e([d()],O.prototype,"labelOptions",null),e([d()],O.prototype,"layerInfos",void 0),e([d()],O.prototype,"sketchViewModel",void 0),e([d()],O.prototype,"snappingOptions",null),e([d()],O.prototype,"spinnerViewModel",void 0),e([d()],O.prototype,"state",null),e([d({readOnly:!0})],O.prototype,"syncing",null),e([d()],O.prototype,"tooltipOptions",null),e([d()],O.prototype,"view",null),O=e([u(C)],O);const A=O;export{A as default};