@arcgis/core 4.34.0-next.45 → 4.34.0-next.47

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 (215) hide show
  1. package/AttributeBinsGraphic.js +1 -1
  2. package/PopupTemplate.js +1 -1
  3. package/arcade/featureSetUtils.js +1 -1
  4. package/arcade/functions/featuresetbase.js +1 -1
  5. package/arcade/geometry/wkt.js +1 -1
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/04cbd3aa9965b2eb71ea.js +1 -0
  8. package/assets/esri/core/workers/chunks/{33f3e3d05429f845c139.js → 0b67b16d7e6c030bcfc7.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{787d281b2fe1edf6cf30.js → 2bb61f80473b495163e3.js} +1 -1
  10. package/assets/esri/core/workers/chunks/2cda605c302176905e84.js +1 -0
  11. package/assets/esri/core/workers/chunks/{78de16f65ea297452a65.js → 31c6e951b99315e8e68a.js} +1 -1
  12. package/assets/esri/core/workers/chunks/3610357c8fa9bec9e0dc.js +1 -0
  13. package/assets/esri/core/workers/chunks/{d547b27ac750953a998f.js → 46a470bea2a3601182dc.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{17df0f766ee1e323d3fa.js → 46ab551bd19e52e73649.js} +1 -1
  15. package/assets/esri/core/workers/chunks/47f2e905ef42e36897aa.js +1 -0
  16. package/assets/esri/core/workers/chunks/4f5e72993a4f5180d703.js +1 -0
  17. package/assets/esri/core/workers/chunks/50d526a16bc86a481055.js +1 -0
  18. package/assets/esri/core/workers/chunks/516b30778cd54d29e362.js +1 -0
  19. package/assets/esri/core/workers/chunks/54b1a960bb8c3fe05976.js +1 -0
  20. package/assets/esri/core/workers/chunks/5713f96bade5ebb54c81.js +1 -0
  21. package/assets/esri/core/workers/chunks/{d70e1b8b8bee88a7a5b8.js → 574ea32d6c257e0d2079.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{dd0f1e06b7df953ea223.js → 576792b5e1e13084adba.js} +1 -1
  23. package/assets/esri/core/workers/chunks/5d331f7628514a572f82.js +1 -0
  24. package/assets/esri/core/workers/chunks/5f7dc9657803ae3140a6.js +1 -0
  25. package/assets/esri/core/workers/chunks/65e1f5b20a585e04655a.js +1 -0
  26. package/assets/esri/core/workers/chunks/66db5f77e09d25e33951.js +1 -0
  27. package/assets/esri/core/workers/chunks/{863e87ac982d7727b435.js → 69e37365c17e7cc4168f.js} +1 -1
  28. package/assets/esri/core/workers/chunks/6fe738748ce837811ff4.js +1 -0
  29. package/assets/esri/core/workers/chunks/719450ccd455f503d81a.js +1 -0
  30. package/assets/esri/core/workers/chunks/{14d3039f92b0d96944f0.js → 71acded1b3c0057917a1.js} +1 -1
  31. package/assets/esri/core/workers/chunks/790e97ddbe318bc75415.js +1 -0
  32. package/assets/esri/core/workers/chunks/7df8c78e36b04ad657d2.js +1 -0
  33. package/assets/esri/core/workers/chunks/838c7fd37b2e78b1d582.js +1 -0
  34. package/assets/esri/core/workers/chunks/8736b78256037b145f8b.js +1 -0
  35. package/assets/esri/core/workers/chunks/8c6119dde0eead8d90d9.js +1 -0
  36. package/assets/esri/core/workers/chunks/{4f3c187a7cb2b1444281.js → 8c81156b1605a16acc29.js} +1 -1
  37. package/assets/esri/core/workers/chunks/8f70650aba8e55eb7a96.js +1 -0
  38. package/assets/esri/core/workers/chunks/{48514235c32917e43a3f.js → 90a97ffba604c1c35532.js} +23 -12
  39. package/assets/esri/core/workers/chunks/{44116cf0bd4d6a127c96.js → 99b9392946d776a62997.js} +1 -1
  40. package/assets/esri/core/workers/chunks/9affcf990ea810fa426b.js +1 -0
  41. package/assets/esri/core/workers/chunks/9b7fee0adffeee8d45ae.js +1 -0
  42. package/assets/esri/core/workers/chunks/9cbec2ffa445a72d4c33.js +1 -0
  43. package/assets/esri/core/workers/chunks/9f178cf73c63caaea190.js +1 -0
  44. package/assets/esri/core/workers/chunks/a50026e567b1edff87c6.js +1 -0
  45. package/assets/esri/core/workers/chunks/a6493607b98783bf1ef2.js +1 -0
  46. package/assets/esri/core/workers/chunks/a69258f34a5eb5a1954f.js +1 -0
  47. package/assets/esri/core/workers/chunks/a7ff44157b8cf19de37e.js +1 -0
  48. package/assets/esri/core/workers/chunks/{8bab4c59c9b644224ecb.js → b87ed14fde381f79bc9f.js} +1 -1
  49. package/assets/esri/core/workers/chunks/bd1c2afaf491d1c79a9e.js +1 -0
  50. package/assets/esri/core/workers/chunks/{f34739daceab54a280ad.js → beb77cdae0b1b6ad73da.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{a638f1688ac9525a52a7.js → c2f184e9f579152aa29a.js} +1 -1
  52. package/assets/esri/core/workers/chunks/c483d2149d9d0099bfdb.js +1 -0
  53. package/assets/esri/core/workers/chunks/cf6330f721c6910d25ff.js +1 -0
  54. package/assets/esri/core/workers/chunks/cfa8b17cf1349f6ed355.js +33 -0
  55. package/assets/esri/core/workers/chunks/{0faec78b2dd6990a5da0.js → d09ded9fb621491e2466.js} +1 -1
  56. package/assets/esri/core/workers/chunks/d1842745a7699879a1e1.js +1 -0
  57. package/assets/esri/core/workers/chunks/d62d41091f7ac5f77f16.js +1 -0
  58. package/assets/esri/core/workers/chunks/d8d17e3ecccec7e99f0b.js +1 -0
  59. package/assets/esri/core/workers/chunks/{01ae7d36bda6b6186786.js → eb61b47df99a54a364c8.js} +1 -1
  60. package/assets/esri/core/workers/chunks/ef02e33ea53b46b566cb.js +1 -0
  61. package/assets/esri/core/workers/chunks/{b4304673696fc0774bff.js → f1de768b0a6d345f7e39.js} +1 -1
  62. package/assets/esri/core/workers/chunks/fc6408208c850eec4019.js +1 -0
  63. package/assets/esri/core/workers/chunks/ff79a8df1b1941ae350d.js +1 -0
  64. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  65. package/chunks/BloomBlur.glsl.js +8 -8
  66. package/chunks/BloomComposition.glsl.js +15 -21
  67. package/chunks/NativeLine.glsl.js +5 -14
  68. package/chunks/bundle.js +1 -1
  69. package/chunks/languageUtils.js +1 -1
  70. package/chunks/persistableUrlUtils.js +1 -1
  71. package/colorUtils.js +1 -1
  72. package/config.js +1 -1
  73. package/core/BidiEngine.js +1 -1
  74. package/core/accessorSupport/get.js +1 -1
  75. package/core/accessorSupport/read.js +1 -1
  76. package/core/accessorSupport/tracking.js +1 -1
  77. package/core/screenUtils.js +1 -1
  78. package/core/sql/DateOnly.js +1 -1
  79. package/core/urlUtils.js +1 -1
  80. package/core/uuid.js +1 -1
  81. package/editing/templateUtils.js +1 -1
  82. package/identity/IdentityManagerBase.js +1 -1
  83. package/kernel.js +1 -1
  84. package/layers/VoxelWasmPerSceneView.js +1 -1
  85. package/layers/graphics/sources/ParquetSource.js +1 -1
  86. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  87. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  88. package/layers/support/TitleCreator.js +1 -1
  89. package/layers/support/parquetUtils.js +1 -1
  90. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  91. package/libs/maquette-advanced-projector/utils.js +1 -1
  92. package/package.json +1 -1
  93. package/rest/featureService/FeatureService.js +1 -1
  94. package/rest/generateRenderer.js +1 -1
  95. package/rest/networks/support/Subcircuit.js +5 -0
  96. package/rest/networks/support/TraceResult.js +1 -1
  97. package/rest/sharedTemplates/querySharedTemplates.js +1 -1
  98. package/smartMapping/statistics/support/utils.js +1 -1
  99. package/support/revision.js +1 -1
  100. package/symbols/cim/cimAnalyzer.js +1 -1
  101. package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
  102. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  103. package/views/2d/engine/webgl/shaderGraph/graph/glsl.js +1 -1
  104. package/views/2d/engine/webgl/shaderGraph/techniques/TestTechnique.js +1 -1
  105. package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillTechnique.js +1 -1
  106. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternFillTechnique.js +1 -1
  107. package/views/2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillTechnique.js +1 -1
  108. package/views/2d/engine/webgl/shaderGraph/techniques/line/TexturedLineTechnique.js +1 -1
  109. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js +1 -1
  110. package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
  111. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
  112. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
  113. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexOutlineFillShader.js +1 -1
  114. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextTechnique.js +1 -1
  115. package/views/2d/engine/webgl/shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js +1 -1
  116. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  117. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  118. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  119. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  120. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  121. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  122. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  123. package/views/3d/terrain/OverlayRenderer.js +1 -1
  124. package/views/3d/terrain/TerrainRenderer.js +1 -1
  125. package/views/3d/terrain/TerrainSurface.js +1 -1
  126. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  127. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  128. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  129. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  130. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +5 -5
  131. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
  132. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  133. package/views/3d/webgl-engine/effects/bloom/BloomPresets.glsl.js +1 -1
  134. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  135. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  136. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  137. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  138. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  139. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  140. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  141. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  142. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  143. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  144. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  145. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  146. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  150. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  151. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  152. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  153. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  154. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
  155. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  156. package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +1 -1
  157. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  158. package/views/draw/DrawOperation.js +1 -1
  159. package/views/draw/{DrawManipulator.js → LegacyDrawManipulator.js} +1 -1
  160. package/views/draw/{DrawTool.js → LegacyDrawTool.js} +1 -1
  161. package/views/draw/PointDrawAction.js +1 -1
  162. package/views/draw/PolygonDrawAction.js +1 -1
  163. package/views/draw/PolylineDrawAction.js +1 -1
  164. package/views/draw/SegmentDrawAction.js +1 -1
  165. package/views/draw/support/Box.js +1 -1
  166. package/views/draw/support/Reshape.js +1 -1
  167. package/webscene/spec-certification/spec.js +1 -1
  168. package/widgets/Feature/support/featureUtils.js +1 -1
  169. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  170. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  171. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  172. package/widgets/OrientedImageryViewer/components/VideoEnhancementTools.js +5 -0
  173. package/widgets/OrientedImageryViewer/symbols.js +1 -1
  174. package/widgets/OrientedImageryViewer.js +1 -1
  175. package/widgets/Track/TrackViewModel.js +1 -1
  176. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  177. package/assets/esri/core/workers/chunks/0494e1212dd94d927287.js +0 -1
  178. package/assets/esri/core/workers/chunks/092cb42b88ecfb9c4a07.js +0 -1
  179. package/assets/esri/core/workers/chunks/129144cbdb3fcbb87baf.js +0 -1
  180. package/assets/esri/core/workers/chunks/2370ff6c3006691ac688.js +0 -1
  181. package/assets/esri/core/workers/chunks/2c816d3a737e39e6eb84.js +0 -1
  182. package/assets/esri/core/workers/chunks/2f54776ff86f397adc55.js +0 -1
  183. package/assets/esri/core/workers/chunks/349da65a8793f7873366.js +0 -22
  184. package/assets/esri/core/workers/chunks/3af4a410ff0bca7ba2e3.js +0 -1
  185. package/assets/esri/core/workers/chunks/4970d439d9648e97fd5a.js +0 -1
  186. package/assets/esri/core/workers/chunks/73140c5c0beda7ea3703.js +0 -1
  187. package/assets/esri/core/workers/chunks/7c7338af011b8f0d7218.js +0 -1
  188. package/assets/esri/core/workers/chunks/838998bfda90f099c6e9.js +0 -1
  189. package/assets/esri/core/workers/chunks/84f3e1ce25c36e46fd2a.js +0 -1
  190. package/assets/esri/core/workers/chunks/8e36693e5213c20158d7.js +0 -1
  191. package/assets/esri/core/workers/chunks/8f3ce10eacb5bc14a641.js +0 -1
  192. package/assets/esri/core/workers/chunks/8fae35af98c29bef8500.js +0 -1
  193. package/assets/esri/core/workers/chunks/91be247f868ce6596c9e.js +0 -1
  194. package/assets/esri/core/workers/chunks/a2a13dd95238bb144479.js +0 -1
  195. package/assets/esri/core/workers/chunks/b45772b72f2b8f4fd53f.js +0 -1
  196. package/assets/esri/core/workers/chunks/b5f6a0607b620b027cdd.js +0 -1
  197. package/assets/esri/core/workers/chunks/c645009f3d2576494bfc.js +0 -1
  198. package/assets/esri/core/workers/chunks/c6e3d4c6bb02d58d5cfe.js +0 -1
  199. package/assets/esri/core/workers/chunks/cd6398a2951922e13b86.js +0 -1
  200. package/assets/esri/core/workers/chunks/ceb63ca9ad473c3f1820.js +0 -1
  201. package/assets/esri/core/workers/chunks/d392fbbcfac2a1b54bd6.js +0 -1
  202. package/assets/esri/core/workers/chunks/da396fdbd6f213042aa7.js +0 -1
  203. package/assets/esri/core/workers/chunks/dd79d3aa6e1a8aee6881.js +0 -1
  204. package/assets/esri/core/workers/chunks/e1272db232194cbe102c.js +0 -1
  205. package/assets/esri/core/workers/chunks/e5aeb34d918dee539694.js +0 -1
  206. package/assets/esri/core/workers/chunks/e65fc26f4384a328a753.js +0 -1
  207. package/assets/esri/core/workers/chunks/e7806a57d29bca385f1d.js +0 -1
  208. package/assets/esri/core/workers/chunks/e799433770e4303fcd9c.js +0 -1
  209. package/assets/esri/core/workers/chunks/ea262087938335fed19f.js +0 -1
  210. package/assets/esri/core/workers/chunks/ec9fd49e0252797f7f6a.js +0 -1
  211. package/assets/esri/core/workers/chunks/f1b02c4bd5fde235212b.js +0 -1
  212. package/assets/esri/core/workers/chunks/f65b2d3a91a0c726fee4.js +0 -1
  213. package/assets/esri/core/workers/chunks/f67997250569069ee2ef.js +0 -1
  214. package/assets/esri/core/workers/chunks/fc3a6f2f99629e57dbbd.js +0 -1
  215. package/assets/esri/core/workers/chunks/ff9eef1940eaa3406223.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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import{getCapabilities as a,describeCoverage as l}from"../../ogc/wcsUtils.js";import c from"../DimensionalDefinition.js";import d from"./BaseRaster.js";import{convertOleDateTimeToEpoch as f}from"./multidimensionalUtils.js";import{parse as p}from"./multipartParser.js";import{standardizeInterpolations as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as m}from"../rasterFunctions/pixelUtils.js";const g=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",I="server returns an exception",C=new Set(["1.0.0","1.1.0","1.1.1","1.1.2","2.0.1"]);let b=class extends d{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,u=this.getTileExtent({x:l,y:c},i,n,p,r,[d,f]),h=this.rasterInfo.extent,g=u.xmax>h.xmax,w=u.ymin<h.ymin,v=g||w;let y=u,x=d,I=f;if(v&&(y=u.clone().intersection(h),null!=y&&(g&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(I=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*I))),null==y||x<=1||I<=1)return null;const C=await this._getCoverage(y,x,I,a,s);if(!C)return null;const{coverageDescription:b}=this.coverageInfo,{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo,{multidimensionalDefinition:j}=s;let T;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===b.version){const t=b.rangeType[0].find(t=>t.name===e);T=t?.nilValue}else if("1.1"===b.version){const t=b.range.find(t=>t.identifier===e);T=t?.nullValues}}const L=T??$,P=await this.decodePixelBlock(C,{width:x,height:I,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(L)?L[0]:L,matchAllNoData:!0});if(null==P)return null;if(P&&(P.width!==x||P.height!==I))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${P.width}, height: {pixelBlock.height}`);return v?m(P,{x:0,y:0},{width:f,height:f}):P}async _open(e){const{customFetchParameters:i}=this.ioConfig,n=e?.signal,s=await a(this.url,{version:i?.version??this.version,customParameters:i,signal:n});if(this.capabilities=s,!this.version){let e=s.version.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.version:(e=s.supportedVersions.find(e=>"2.0.1"===e)||s.supportedVersions.find(e=>"2.0"===e.slice(0,3))||s.supportedVersions.find(e=>"1.1"===e.slice(0,3))||s.supportedVersions.find(e=>"1.0"===e.slice(0,3))||"1.0.0",this.version=e)}const{version:o}=this;if(!C.has(o))throw new t("wcsraster-open",`unsupported WCS version ${o}`);const{gridCoverages:r}=s;if(!r.length)throw new t("wcsraster-open","cannot find rectified grid coverages");this.coverageId??=r[0].id;const{coverageId:c}=this,d=r.find(e=>e.id===c);if(null==d)throw new t("wcsraster-open",`the coverageId ${c} does not exist in capabilities`);const f=await l(this.url,{coverageIds:[c],version:o,customParameters:i,signal:n});if(this.coverageInfo=f[0],"2.0"===o.slice(0,3)){const{coverageInfo:e}=this;e.lonLatEnvelope=d.lonLatEnvelope,e.supportedInterpolations=u(s.supportedInterpolations),this._patchDimensionValues201(c,n)}this.datasetName=this.coverageInfo.title;const{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set("rasterInfo",p),null==p.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${c}`);const{pixelType:h,bandCount:m}=await this._getPixelTypeAndBandCount(n);p.pixelType=h,1===p.bandCount&&m>1&&(p.bandCount=m),this.updateTileInfo()}async _patchDimensionValues201(e,t){const{coverageInfo:i}=this,n=i.rasterInfo.multidimensionalInfo?.variables,s=C.has("1.1.2")?"1.1.2":C.has("1.1.1")?"1.1.1":C.has("1.1.0")?"1.1.0":null,{customFetchParameters:o}=this.ioConfig;if(n&&s)try{const i=this.url.includes("/ImageServer/"),r=e.length>8&&e.startsWith("Coverage")&&i?e.slice(8):e,a=await l(this.url,{coverageIds:[r??e],version:s,customParameters:o,signal:t}).catch(()=>{if(r)return l(this.url,{coverageIds:[e],version:s,customParameters:o,signal:t})}),c=a?.[0].rasterInfo.multidimensionalInfo?.variables;if(c)for(const e of n){const t=c.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let n=e.dimensions.length-1;n>=0;n--){const s=e.dimensions[n],o=t.dimensions.find(({name:e})=>e===s.name);o?o.values&&o.extent?.join(",")===s.extent?.join(",")&&(e.dimensions[n]={...s,values:o.values}):i&&e.dimensions.splice(n,1)}}}catch{}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,a=s.center,l=new o({xmin:a.x-n.x,xmax:a.x+n.x,ymin:a.y-n.y,ymax:a.y+n.y,spatialReference:s.spatialReference});let d=[];if(null!=r){const e=r.variables[0];d=[],e.dimensions.forEach(t=>{d.push(new c({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}const{coverageDescription:f}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:d,signal:e},{version:u}=f,{ioConfig:h}=this,m="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let g;try{g=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!m)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!g&&m&&("2.0"===u&&(h.allowAnyMediaType=!0),g=await this._getCoverage(l,2,2,1,p),g&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!g)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:c}=l,d="2.0"===c?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===c?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),f="2.0"===c?await this.request(this._constructWCS201Url(d),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:d,signal:r.signal,responseType:"array-buffer"});if("1.0"===c)return f.data;if("2.0"===c&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(f.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),f.data}const u=p(f);if(u.isMultipart&&u.data){const e=u.data.find(e=>e.isValidImage);return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const m=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,m).toLowerCase().includes("exception"),w=g&&String.fromCharCode.apply(null,m).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(g)throw new t("wcsraster:getcoverage",I,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map(e=>this.coverageInfo.bandNames[e]):null,f=g[c],{multidimensionalDefinition:p}=n;let u;if(null!=p&&null!=this.rasterInfo.multidimensionalInfo){const e=p.find(e=>"StdTime"===e.dimensionName);let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),u=t.map(e=>$(e)).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:u,interpolation:f,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",p=this._getInterpolationIndex(l),u=w[p],h=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),m=s.domain.spatialDomain,g=m.origin.x<=m.envelope.xmin&&m.origin.y<=m.envelope.ymin,v=e.width/t,y=e.height/i*(g?1:-1),x=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],I=m.useEPSGAxis&&r(c),C=I?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,b=this.ioConfig.use2GridOffsets,S=I?b?`${y},${v}`:`${y},0,0,${v}`:b?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,P=Math.abs(y)/2,R=e.ymin+P,D=e.ymax-P,_=I?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,A=s.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes("band")));let E,G=A&&u&&a?h?`${A.identifier}[${A.axis[0].identifier}[${a.join(",")}]]`:`${A.identifier}:${u}[${A.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase(),n=s.range.find(e=>e.identifier.toLowerCase()===i);if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)E=e.map(e=>$(e)).join(",");else if(n){const i=n.axis.find(e=>e.identifier.toLowerCase()===t);i&&(G=h?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+u+"["+i.identifier+"["+e.join(",")+"]]")}r===o.length-1&&n&&!G&&(G=h?n.identifier:n.identifier+":"+u)}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:f,crs:`EPSG:${c}`,boundingbox:_,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:S,gridBaseCRS:d,timeSequence:E,rangeSubset:G}}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find(e=>e.toLowerCase().includes("nearest"));break;case 1:c=d.find(e=>e.toLowerCase().includes("linear"));break;case 2:c=d.find(e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic"))}const f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",{bandNames:p}=this.coverageInfo,{boundedBy:u,domainSet:h,rangeType:m}=o,g=u.isEastFirst?0:1,w=1-g,{axisLabels:v}=u,y=v[g],x=v[w],I=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=I,b=[];b.push(`${y}(${e.xmin},${e.xmax})`),b.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=h.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();u.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=$(e,!0)),b.push(v[D]+",http://www.opengis.net("+t+")")}else b.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=r&&r.length){const e=[];m.forEach(t=>t.forEach(t=>e.push(t.name)));const t=[];for(let i=0;i<r.length;i++){const n=v.find(e=>e===r[i].dimensionName),s=e.find(e=>e===r[i].variableName);if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map(e=>$(e)).join(","):e.join(",");const i=b.findIndex(e=>0===e.indexOf(n+",http://www.opengis.net"));-1===i&&b.push(n+",http://www.opengis.net("+t+")"),-1===i||b[i].includes("("+t+")")||b.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(p?.length>=2){j=(s.bandIds?s.bandIds.map(e=>p[e]):p).join(",")}const T=b.join("&subset="),L=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,P=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:P,scaleFactor:R,subset:T,format:f,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:I,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach(e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach(e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)}):i.push(`${e}=${encodeURIComponent(n)}`))});return`${encodeURI(this.url)}?${i.join("&")}`}};function $(e,t=!1){return(t?new Date(f(e)):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),e([n({readOnly:!0})],b.prototype,"rasterId",null),b=e([s("esri.layers.support.rasterDatasets.WCSRaster")],b);export{b as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import{getCapabilities as a,describeCoverage as l}from"../../ogc/wcsUtils.js";import c from"../DimensionalDefinition.js";import d from"./BaseRaster.js";import{convertOleDateTimeToEpoch as f}from"./multidimensionalUtils.js";import{parse as p}from"./multipartParser.js";import{standardizeInterpolations as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as m}from"../rasterFunctions/pixelUtils.js";const g=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",I="server returns an exception",C=new Set(["1.0.0","1.1.0","1.1.1","1.1.2","2.0.1"]);let b=class extends d{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,u=this.getTileExtent({x:l,y:c},i,n,p,r,[d,f]),h=this.rasterInfo.extent,g=u.xmax>h.xmax,w=u.ymin<h.ymin,v=g||w;let y=u,x=d,I=f;if(v&&(y=u.clone().intersection(h),null!=y&&(g&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(I=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*I))),null==y||x<=1||I<=1)return null;const C=await this._getCoverage(y,x,I,a,s);if(!C)return null;const{coverageDescription:b}=this.coverageInfo,{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo,{multidimensionalDefinition:j}=s;let T;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===b.version){const t=b.rangeType[0].find(t=>t.name===e);T=t?.nilValue}else if("1.1"===b.version){const t=b.range.find(t=>t.identifier===e);T=t?.nullValues}}const L=T??$,P=await this.decodePixelBlock(C,{width:x,height:I,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(L)?L[0]:L,matchAllNoData:!0});if(null==P)return null;if(P&&(P.width!==x||P.height!==I))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${P.width}, height: {pixelBlock.height}`);return v?m(P,{x:0,y:0},{width:f,height:f}):P}async _open(e){const{customFetchParameters:i}=this.ioConfig,n=e?.signal,s=await a(this.url,{version:i?.version??this.version,customParameters:i,signal:n});if(this.capabilities=s,!this.version){let e=s.version.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.version:(e=s.supportedVersions.find(e=>"2.0.1"===e)||s.supportedVersions.find(e=>e.startsWith("2.0"))||s.supportedVersions.find(e=>e.startsWith("1.1"))||s.supportedVersions.find(e=>e.startsWith("1.0"))||"1.0.0",this.version=e)}const{version:o}=this;if(!C.has(o))throw new t("wcsraster-open",`unsupported WCS version ${o}`);const{gridCoverages:r}=s;if(!r.length)throw new t("wcsraster-open","cannot find rectified grid coverages");this.coverageId??=r[0].id;const{coverageId:c}=this,d=r.find(e=>e.id===c);if(null==d)throw new t("wcsraster-open",`the coverageId ${c} does not exist in capabilities`);const f=await l(this.url,{coverageIds:[c],version:o,customParameters:i,signal:n});if(this.coverageInfo=f[0],o.startsWith("2.0")){const{coverageInfo:e}=this;e.lonLatEnvelope=d.lonLatEnvelope,e.supportedInterpolations=u(s.supportedInterpolations),this._patchDimensionValues201(c,n)}this.datasetName=this.coverageInfo.title;const{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set("rasterInfo",p),null==p.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${c}`);const{pixelType:h,bandCount:m}=await this._getPixelTypeAndBandCount(n);p.pixelType=h,1===p.bandCount&&m>1&&(p.bandCount=m),this.updateTileInfo()}async _patchDimensionValues201(e,t){const{coverageInfo:i}=this,n=i.rasterInfo.multidimensionalInfo?.variables,s=C.has("1.1.2")?"1.1.2":C.has("1.1.1")?"1.1.1":C.has("1.1.0")?"1.1.0":null,{customFetchParameters:o}=this.ioConfig;if(n&&s)try{const i=this.url.includes("/ImageServer/"),r=e.length>8&&e.startsWith("Coverage")&&i?e.slice(8):e,a=await l(this.url,{coverageIds:[r??e],version:s,customParameters:o,signal:t}).catch(()=>{if(r)return l(this.url,{coverageIds:[e],version:s,customParameters:o,signal:t})}),c=a?.[0].rasterInfo.multidimensionalInfo?.variables;if(c)for(const e of n){const t=c.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let n=e.dimensions.length-1;n>=0;n--){const s=e.dimensions[n],o=t.dimensions.find(({name:e})=>e===s.name);o?o.values&&o.extent?.join(",")===s.extent?.join(",")&&(e.dimensions[n]={...s,values:o.values}):i&&e.dimensions.splice(n,1)}}}catch{}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,a=s.center,l=new o({xmin:a.x-n.x,xmax:a.x+n.x,ymin:a.y-n.y,ymax:a.y+n.y,spatialReference:s.spatialReference});let d=[];if(null!=r){const e=r.variables[0];d=[],e.dimensions.forEach(t=>{d.push(new c({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}const{coverageDescription:f}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:d,signal:e},{version:u}=f,{ioConfig:h}=this,m="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let g;try{g=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!m)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!g&&m&&("2.0"===u&&(h.allowAnyMediaType=!0),g=await this._getCoverage(l,2,2,1,p),g&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!g)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:c}=l,d="2.0"===c?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===c?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),f="2.0"===c?await this.request(this._constructWCS201Url(d),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:d,signal:r.signal,responseType:"array-buffer"});if("1.0"===c)return f.data;if("2.0"===c&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(f.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),f.data}const u=p(f);if(u.isMultipart&&u.data){const e=u.data.find(e=>e.isValidImage);return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const m=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,m).toLowerCase().includes("exception"),w=g&&String.fromCharCode.apply(null,m).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(g)throw new t("wcsraster:getcoverage",I,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map(e=>this.coverageInfo.bandNames[e]):null,f=g[c],{multidimensionalDefinition:p}=n;let u;if(null!=p&&null!=this.rasterInfo.multidimensionalInfo){const e=p.find(e=>"StdTime"===e.dimensionName);let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),u=t.map(e=>$(e)).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:u,interpolation:f,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",p=this._getInterpolationIndex(l),u=w[p],h=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),m=s.domain.spatialDomain,g=m.origin.x<=m.envelope.xmin&&m.origin.y<=m.envelope.ymin,v=e.width/t,y=e.height/i*(g?1:-1),x=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],I=m.useEPSGAxis&&r(c),C=I?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,b=this.ioConfig.use2GridOffsets,S=I?b?`${y},${v}`:`${y},0,0,${v}`:b?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,P=Math.abs(y)/2,R=e.ymin+P,D=e.ymax-P,_=I?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,A=s.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes("band")));let E,W=A&&u&&a?h?`${A.identifier}[${A.axis[0].identifier}[${a.join(",")}]]`:`${A.identifier}:${u}[${A.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase(),n=s.range.find(e=>e.identifier.toLowerCase()===i);if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)E=e.map(e=>$(e)).join(",");else if(n){const i=n.axis.find(e=>e.identifier.toLowerCase()===t);i&&(W=h?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+u+"["+i.identifier+"["+e.join(",")+"]]")}r===o.length-1&&n&&!W&&(W=h?n.identifier:n.identifier+":"+u)}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:f,crs:`EPSG:${c}`,boundingbox:_,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:S,gridBaseCRS:d,timeSequence:E,rangeSubset:W}}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find(e=>e.toLowerCase().includes("nearest"));break;case 1:c=d.find(e=>e.toLowerCase().includes("linear"));break;case 2:c=d.find(e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic"))}const f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",{bandNames:p}=this.coverageInfo,{boundedBy:u,domainSet:h,rangeType:m}=o,g=u.isEastFirst?0:1,w=1-g,{axisLabels:v}=u,y=v[g],x=v[w],I=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=I,b=[];b.push(`${y}(${e.xmin},${e.xmax})`),b.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=h.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();u.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=$(e,!0)),b.push(v[D]+",http://www.opengis.net("+t+")")}else b.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=r&&r.length){const e=[];m.forEach(t=>t.forEach(t=>e.push(t.name)));const t=[];for(let i=0;i<r.length;i++){const n=v.find(e=>e===r[i].dimensionName),s=e.find(e=>e===r[i].variableName);if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map(e=>$(e)).join(","):e.join(",");const i=b.findIndex(e=>e.startsWith(n+",http://www.opengis.net"));-1===i&&b.push(n+",http://www.opengis.net("+t+")"),-1===i||b[i].includes("("+t+")")||b.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(p?.length>=2){j=(s.bandIds?s.bandIds.map(e=>p[e]):p).join(",")}const T=b.join("&subset="),L=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,P=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:P,scaleFactor:R,subset:T,format:f,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:I,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach(e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach(e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)}):i.push(`${e}=${encodeURIComponent(n)}`))});return`${encodeURI(this.url)}?${i.join("&")}`}};function $(e,t=!1){return(t?new Date(f(e)):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),e([n({readOnly:!0})],b.prototype,"rasterId",null),b=e([s("esri.layers.support.rasterDatasets.WCSRaster")],b);export{b as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- const e={namespace:void 0,performanceLogger:()=>{},eventHandlerInterceptor:void 0,styleApplyer:(e,r,t)=>{"-"===r.charAt(0)?e.style.setProperty(r,t):e.style[r]=t}},r=r=>({...e,...r});export{r as applyDefaultProjectionOptions};
5
+ const e={namespace:void 0,performanceLogger:()=>{},eventHandlerInterceptor:void 0,styleApplyer:(e,t,r)=>{t.startsWith("-")?e.style.setProperty(t,r):e.style[t]=r}},t=t=>({...e,...t});export{t as applyDefaultProjectionOptions};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.34.0-next.45",
3
+ "version": "4.34.0-next.47",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../config.js";import{id as s}from"../../kernel.js";import r from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import{clone as l}from"../../core/lang.js";import{Loadable as u}from"../../core/Loadable.js";import{throwIfAborted as d,throwIfAbortError as p}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../editing/sharedTemplates/SharedTemplateMetadata.js";import f from"../../geometry/SpatialReference.js";import{getFeatureJSON as b,getFeatureIds as g,getAttachmentEditsJSON as v,isProtectedOrPrivateVersionError as j,unpackEditResultData as S,createEditedFeatures as O}from"../../layers/graphics/applyEditsUtils.js";import{checkEditingCapabilities as E,normalizeEdits as R,normalizeGeometries as w}from"../../layers/graphics/editingSupport.js";import{emitApplyEditsEvent as A}from"../../layers/mixins/EditBusLayer.js";import{ensureCredentialIfSignedIn as I}from"../../layers/support/featureLayerUtils.js";import{getOwningPortalUrl as F}from"../../layers/support/layerUtils.js";import{getFeatureLayerCapabilities as T}from"../../layers/support/serviceCapabilitiesUtils.js";import U from"../../portal/PortalItem.js";import{getUserPrivileges as C}from"../../portal/support/portalItemUtils.js";import{isSecureProxyService as D}from"../../portal/support/urlUtils.js";import{parseUrl as P,asValidOptions as V,encode as G}from"../utils.js";import{unapplyEditsZUnitScaling as k}from"../query/operations/editsZScale.js";import{querySharedTemplates as N}from"../sharedTemplates/querySharedTemplates.js";import{readBoolean as M,readNumber as q}from"../support/jsonUtils.js";import{isSafeToEditVersion as L,isVersionInEditSession as _,currentSessionId as x}from"../../versionManagement/support/versionManagementUtils.js";function J(e,t){const s=t.id;return{id:s,name:t.name,url:`${e}/${s}`,type:t.type||"Table"}}function Q(e){return{data:W(e),sync:z(e),operations:H(e.capabilities,e),query:B(e),editing:$(e)}}function W(e){return{isDataVersioned:M(e,"hasVersionedData",!1),isDataBranchVersioned:M(e,"hasBranchVersionedData",!1)}}function H(e,t){const s=e?e.toLowerCase().split(",").map(e=>e.trim()):[],r=s.includes("query"),i=s.includes("editing")&&!t.datesInUnknownTimezone;let a=i&&s.includes("create"),o=i&&s.includes("delete"),n=i&&s.includes("update");return i&&!(a||o||n)&&(a=o=n=!0),{supportsAdd:a,supportsDelete:o,supportsEditing:i,supportsChangeTracking:s.includes("changetracking"),supportsQuery:r,supportsQueryDataElements:M(t,"supportsQueryDataElements",!1),supportsQueryDomains:M(t,"supportsQueryDomains",!1),supportsQueryContingentValues:M(t,"supportsQueryContingentValues",!1),supportsSync:s.includes("sync"),supportsUpdate:n}}function B(e){return{maxRecordCountFactor:q(e,"maxRecordCountFactor",void 0),maxRecordCount:q(e,"maxRecordCount",void 0)}}function $(e){const t=e?.advancedEditingCapabilities;return{supportsAsyncApplyEdits:M(t,"supportsAsyncApplyEdits",!1),supportsGlobalId:M(e,"supportsApplyEditsWithGlobalIds",!1),supportsReturnServiceEditsInSourceSpatialReference:M(t,"supportsReturnServiceEditsInSourceSR",!1),supportsSharedTemplates:M(e,"supportsSharedTemplates",!1)||M(e,"hasSharedTemplates",!1),supportsSplit:M(t,"supportsSplit",!1)}}function z(e){const t=e?.syncCapabilities,s=t?.supportedSyncDataOptions;return{supportsAsync:M(t,"supportsAsync",!1),supportedSyncDataOptions:{annotations:!(1&~s),dimensions:!(2&~s),contingentValues:!(4&~s),attributeRules:!(8&~s),utilityNetworkSystem:!(16&~s),annotationFullModel:!(32&~s),include3DObjects:!(64&~s),utilityNetworkMissingLayers:!(128&~s),preserveTrueCurves:!(256&~s)}}}let Z=class extends(n(o(u))){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.userTypeExtensions=[],this.layerInfos=null,this.tableInfos=null,this.capabilities=null}read(e,t){this.sourceJSON=e,super.read(e,t)}get utilityNetworkUrl(){if(this.sourceJSON)for(const e of this.sourceJSON.layers)if("Utility Network Layer"===e.type)return`${this.url}/${e.id}`;return null}get versionManagementServiceUrl(){return this.sourceJSON?.hasBranchVersionedData&&!D(this.url)?this.url.replace(/\/FeatureServer/i,"/VersionManagementServer"):null}readLayerInfos(e,t){return(t.layers||[]).map(e=>{const{type:t,geometryType:s}=e;return{...J(this.url,e),type:t||"Feature Layer",geometryType:s}})}readTableInfos(e,t){return(t.tables||[]).map(e=>J(this.url,e))}readCapabilities(e,t){return Q(t)}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=l(e),{operations:s}=t;return this.userHasUpdateItemPrivileges?(s.supportsAdd=s.supportsDelete=s.supportsEditing=s.supportsQuery=s.supportsUpdate=!0,t):(this.userHasFullEditingPrivileges&&s.supportsEditing&&(s.supportsAdd=s.supportsDelete=s.supportsUpdate=!0),t)}get loaded(){return super.loaded}load(e){return this.addResolvingPromise(this._fetchService(this.url,e).then(()=>this._setUserPrivileges(e))),Promise.resolve(this)}async fetchAllLayersAndTables(e){return await this.load(e),this._fetchLayersAndTablesPromise||=this._fetchLayersAndTables(this.url),d(e),this._fetchLayersAndTablesPromise}async applyEdits(e,t){let s=null;try{const{results:r,edits:i,editedFeatures:a}=await this._internalApplyEdits(e,t),o=e=>e.filter(e=>!e.error).map(l);let n=0;return r.map(e=>{s=A(this.url,e.id,t?.gdbVersion,!0);const r={edits:i[n],addedFeatures:o(e.addFeatureResults),updatedFeatures:o(e.updateFeatureResults),deletedFeatures:o(e.deleteFeatureResults),addedAttachments:o(e.addAttachmentResults),updatedAttachments:o(e.updateAttachmentResults),deletedAttachments:o(e.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:e.editMoment?new Date(e.editMoment):null};n+=1,a.length>0&&(r.editedFeatures=a),s.resolve(r),s=null}),r}catch(r){throw s&&s.reject(r),r}}async querySharedTemplates(e){const t={...e?.query};null==t.layers&&null==t.templateIds&&(t.layers=this.layerInfos.map(e=>e.id));return(await N({serviceUrl:this.url,query:t,requestOptions:e?.requestOptions})).map(e=>{const t=h.fromJSON(e);return t.featureService=this,t})}async _setUserPrivileges(e){if(t.userPrivilegesApplied)try{const{features:{fullEdit:t},content:{updateItem:s}}=await this._fetchUserPrivileges(this.sourceJSON.serviceItemId,e);this._set("userHasFullEditingPrivileges",t),this._set("userHasUpdateItemPrivileges",s)}catch(s){p(s)}}async _fetchUserPrivileges(e,t){const r=!0,i=!1,a=!1;if(!e)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};let o,n,l;try{o=await F(this.url,t)}catch(u){p(u)}try{const e=null!=t?t.signal:null;n=await(s?.getCredential(`${o}/sharing`,{prompt:!1,signal:e}))}catch(u){p(u)}if(!n)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};try{if(l=new U({id:e,portal:{url:o}}),await l.load(t),l.portal.user)return C(l)}catch(u){p(u)}return{features:{edit:r,fullEdit:i},content:{updateItem:a}}}async _internalApplyEdits(e,t){await I(this.url);const s=t?.globalIdUsed??!1,a=f.fromJSON(this.sourceJSON.spatialReference),{edits:o,options:n}=await this._processApplyEditsParams(e,t),l=await Promise.all(o.map(async e=>{const t=e.addFeatures?.map(e=>b({spatialReference:a},e,null))??[],r=(await Promise.all(t)).filter(i),o=r.length>0?r:null,n=e.updateFeatures?.map(e=>b({spatialReference:a},e,null))??[],l=(await Promise.all(n)).filter(i),u=l.length>0?l:null,d=g(e.identifierFields,e.deleteFeatures,s),p=d.length>0?d:null;k(o,u,a);const c=await v(e.identifierFields,e);let m=null;if(c){m={adds:c.adds.length>0?c.adds:void 0,updates:c.updates.length>0?c.updates:void 0,deletes:c.deletes.length>0?c.deletes:void 0}}const y={};return e.deleteAssociations&&(y.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(y.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(y.divideGroupedObjects=e.divideGroupedObjects),{id:e.id,adds:o,updates:u,deletes:p,attachments:m,...y}})),u={gdbVersion:n?.gdbVersion,rollbackOnFailure:!0,useGlobalIds:s,returnEditMoment:!0,honorSequenceOfEdits:n?.honorSequenceOfEdits,usePreviousEditMoment:n?.usePreviousEditMoment,returnServiceEditsInSourceSR:!1,returnServiceEditsOption:"originalAndCurrentFeatures",async:!1};await L(this.url,t?.gdbVersion,!0);const d=_(this.url,t?.gdbVersion||null);u.edits=JSON.stringify(l);const p=P(this.url),c=V(p.query,{query:G({...u,f:"json"}),method:"post"});let m;d&&(c.authMode="immediate",c.query.sessionId=x);try{m=await r(this.url+"/applyEdits",c)}catch(y){if(!j(y))throw y;c.authMode="immediate",m=await r(this.url+"/applyEdits",c)}return{...K(m),edits:o}}async _processApplyEditsParams(e,t){const s={...t,usingFeatureServiceEndpoint:!0,usingTelecomOperations:e.some(e=>e.deleteAssociations||e.combineGroupedObjects||e.divideGroupedObjects)};return{edits:await Promise.all(e.map(async e=>{const t=this.effectiveCapabilities,r=e&&(e.addFeatures||e.updateFeatures||e.deleteFeatures),i=e&&(e.addAttachments||e.updateAttachments||e.deleteAttachments);if(E(e,t,s,!!r,!!i,"feature-service"),!t.data.isDataVersioned&&s?.gdbVersion)throw new a("feature-service:invalid-parameter","'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isDataVersioned'");const o=R(e,t,"feature-service"),n={};e.deleteAssociations&&(n.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(n.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(n.divideGroupedObjects=e.divideGroupedObjects);const l=await w(o);return{id:e.id,...l,...n,identifierFields:e.identifierFields}})),options:s}}async _fetchService(e,t){if(this.sourceJSON)return void this.read(this.sourceJSON,{url:P(e)});const s=await r(e,{responseType:"json",query:{f:"json"},...t});this.read(s.data,{url:P(e)})}async _fetchLayersAndTables(e){const t=`${e}/layers`,s=await r(t,{responseType:"json",query:{f:"json"}});return{layers:s.data.layers.map(e=>{const{type:t,geometryType:s}=e,r=J(this.url,e),i=T(e,r.url);return{...r,type:t||"Feature Layer",geometryType:s,capabilities:i}}),tables:s.data.tables.map(e=>{const t=J(this.url,e),s=T(e,t.url);return{...t,capabilities:s}})}}};function K(e){const t=e.data,s=[];return{results:t.map(e=>{const t={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment},r=S(t),i=e.editedFeatures,a=i?.spatialReference?new f({wkid:i?.spatialReference.wkid,wkt:i?.spatialReference.wkt,latestWkid:i?.spatialReference.latestWkid,latestVcsWkid:i?.spatialReference.latestVcsWkid,vcsWkid:i?.spatialReference.vcsWkid}):null,o=i?O(i,a):null;o&&s.push({layerId:e.id,editedFeatures:o});const n={};return e.divideGroupedObjectResults&&(n.divideGroupedObjectResults=e.divideGroupedObjectResults),e.combineGroupedObjectResults&&(n.combineGroupedObjectResults=e.combineGroupedObjectResults),{id:e.id,editedFeatures:o,...r,...n}}),editedFeatures:s}}e([c()],Z.prototype,"url",void 0),e([c()],Z.prototype,"sourceJSON",void 0),e([c()],Z.prototype,"userHasFullEditingPrivileges",void 0),e([c()],Z.prototype,"userHasUpdateItemPrivileges",void 0),e([c({readOnly:!0})],Z.prototype,"utilityNetworkUrl",null),e([c({readOnly:!0})],Z.prototype,"versionManagementServiceUrl",null),e([c()],Z.prototype,"userTypeExtensions",void 0),e([c({json:{read:{source:["layers"]}}})],Z.prototype,"layerInfos",void 0),e([m("layerInfos",["layers"])],Z.prototype,"readLayerInfos",null),e([c({json:{read:{source:["tables"]}}})],Z.prototype,"tableInfos",void 0),e([m("tableInfos",["tables"])],Z.prototype,"readTableInfos",null),e([c({readOnly:!0,json:{read:{source:["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"]}}})],Z.prototype,"capabilities",void 0),e([m("capabilities",["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"])],Z.prototype,"readCapabilities",null),e([c({readOnly:!0})],Z.prototype,"effectiveCapabilities",null),Z=e([y("esri.rest.featureService.FeatureService")],Z);const X=Z;export{X as default};
5
+ import{__decorate as e}from"tslib";import t from"../../config.js";import{id as s}from"../../kernel.js";import r from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import{clone as l}from"../../core/lang.js";import{Loadable as u}from"../../core/Loadable.js";import{throwIfAborted as d,throwIfAbortError as p}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/SpatialReference.js";import{getFeatureJSON as f,getFeatureIds as b,getAttachmentEditsJSON as g,isProtectedOrPrivateVersionError as v,unpackEditResultData as j,createEditedFeatures as S}from"../../layers/graphics/applyEditsUtils.js";import{checkEditingCapabilities as E,normalizeEdits as O,normalizeGeometries as R}from"../../layers/graphics/editingSupport.js";import{emitApplyEditsEvent as A}from"../../layers/mixins/EditBusLayer.js";import{ensureCredentialIfSignedIn as w}from"../../layers/support/featureLayerUtils.js";import{getOwningPortalUrl as F}from"../../layers/support/layerUtils.js";import{getFeatureLayerCapabilities as I}from"../../layers/support/serviceCapabilitiesUtils.js";import U from"../../portal/PortalItem.js";import{getUserPrivileges as C}from"../../portal/support/portalItemUtils.js";import{isSecureProxyService as T}from"../../portal/support/urlUtils.js";import{parseUrl as D,asValidOptions as P,encode as V}from"../utils.js";import{unapplyEditsZUnitScaling as G}from"../query/operations/editsZScale.js";import{readBoolean as k,readNumber as N}from"../support/jsonUtils.js";import{isSafeToEditVersion as L,isVersionInEditSession as M,currentSessionId as _}from"../../versionManagement/support/versionManagementUtils.js";function x(e,t){const s=t.id;return{id:s,name:t.name,url:`${e}/${s}`,type:t.type||"Table"}}function Q(e){return{data:J(e),sync:B(e),operations:q(e.capabilities,e),query:W(e),editing:H(e)}}function J(e){return{isDataVersioned:k(e,"hasVersionedData",!1),isDataBranchVersioned:k(e,"hasBranchVersionedData",!1)}}function q(e,t){const s=e?e.toLowerCase().split(",").map(e=>e.trim()):[],r=s.includes("query"),i=s.includes("editing")&&!t.datesInUnknownTimezone;let a=i&&s.includes("create"),o=i&&s.includes("delete"),n=i&&s.includes("update");return i&&!(a||o||n)&&(a=o=n=!0),{supportsAdd:a,supportsDelete:o,supportsEditing:i,supportsChangeTracking:s.includes("changetracking"),supportsQuery:r,supportsQueryDataElements:k(t,"supportsQueryDataElements",!1),supportsQueryDomains:k(t,"supportsQueryDomains",!1),supportsQueryContingentValues:k(t,"supportsQueryContingentValues",!1),supportsSync:s.includes("sync"),supportsUpdate:n}}function W(e){return{maxRecordCountFactor:N(e,"maxRecordCountFactor",void 0),maxRecordCount:N(e,"maxRecordCount",void 0)}}function H(e){const t=e?.advancedEditingCapabilities;return{supportsAsyncApplyEdits:k(t,"supportsAsyncApplyEdits",!1),supportsGlobalId:k(e,"supportsApplyEditsWithGlobalIds",!1),supportsReturnServiceEditsInSourceSpatialReference:k(t,"supportsReturnServiceEditsInSourceSR",!1),supportsSharedTemplates:k(e,"supportsSharedTemplates",!1)||k(e,"hasSharedTemplates",!1),supportsSplit:k(t,"supportsSplit",!1)}}function B(e){const t=e?.syncCapabilities,s=t?.supportedSyncDataOptions;return{supportsAsync:k(t,"supportsAsync",!1),supportedSyncDataOptions:{annotations:!(1&~s),dimensions:!(2&~s),contingentValues:!(4&~s),attributeRules:!(8&~s),utilityNetworkSystem:!(16&~s),annotationFullModel:!(32&~s),include3DObjects:!(64&~s),utilityNetworkMissingLayers:!(128&~s),preserveTrueCurves:!(256&~s)}}}let $=class extends(n(o(u))){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.userTypeExtensions=[],this.layerInfos=null,this.tableInfos=null,this.capabilities=null}read(e,t){this.sourceJSON=e,super.read(e,t)}get utilityNetworkUrl(){if(this.sourceJSON)for(const e of this.sourceJSON.layers)if("Utility Network Layer"===e.type)return`${this.url}/${e.id}`;return null}get versionManagementServiceUrl(){return this.sourceJSON?.hasBranchVersionedData&&!T(this.url)?this.url.replace(/\/FeatureServer/i,"/VersionManagementServer"):null}readLayerInfos(e,t){return(t.layers||[]).map(e=>{const{type:t,geometryType:s}=e;return{...x(this.url,e),type:t||"Feature Layer",geometryType:s}})}readTableInfos(e,t){return(t.tables||[]).map(e=>x(this.url,e))}readCapabilities(e,t){return Q(t)}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=l(e),{operations:s}=t;return this.userHasUpdateItemPrivileges?(s.supportsAdd=s.supportsDelete=s.supportsEditing=s.supportsQuery=s.supportsUpdate=!0,t):(this.userHasFullEditingPrivileges&&s.supportsEditing&&(s.supportsAdd=s.supportsDelete=s.supportsUpdate=!0),t)}get loaded(){return super.loaded}load(e){return this.addResolvingPromise(this._fetchService(this.url,e).then(()=>this._setUserPrivileges(e))),Promise.resolve(this)}async fetchAllLayersAndTables(e){return await this.load(e),this._fetchLayersAndTablesPromise||=this._fetchLayersAndTables(this.url),d(e),this._fetchLayersAndTablesPromise}async applyEdits(e,t){let s=null;try{const{results:r,edits:i,editedFeatures:a}=await this._internalApplyEdits(e,t),o=e=>e.filter(e=>!e.error).map(l);let n=0;return r.map(e=>{s=A(this.url,e.id,t?.gdbVersion,!0);const r={edits:i[n],addedFeatures:o(e.addFeatureResults),updatedFeatures:o(e.updateFeatureResults),deletedFeatures:o(e.deleteFeatureResults),addedAttachments:o(e.addAttachmentResults),updatedAttachments:o(e.updateAttachmentResults),deletedAttachments:o(e.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:e.editMoment?new Date(e.editMoment):null};n+=1,a.length>0&&(r.editedFeatures=a),s.resolve(r),s=null}),r}catch(r){throw s&&s.reject(r),r}}async _setUserPrivileges(e){if(t.userPrivilegesApplied)try{const{features:{fullEdit:t},content:{updateItem:s}}=await this._fetchUserPrivileges(this.sourceJSON.serviceItemId,e);this._set("userHasFullEditingPrivileges",t),this._set("userHasUpdateItemPrivileges",s)}catch(s){p(s)}}async _fetchUserPrivileges(e,t){const r=!0,i=!1,a=!1;if(!e)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};let o,n,l;try{o=await F(this.url,t)}catch(u){p(u)}try{const e=null!=t?t.signal:null;n=await(s?.getCredential(`${o}/sharing`,{prompt:!1,signal:e}))}catch(u){p(u)}if(!n)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};try{if(l=new U({id:e,portal:{url:o}}),await l.load(t),l.portal.user)return C(l)}catch(u){p(u)}return{features:{edit:r,fullEdit:i},content:{updateItem:a}}}async _internalApplyEdits(e,t){await w(this.url);const s=t?.globalIdUsed??!1,a=h.fromJSON(this.sourceJSON.spatialReference),{edits:o,options:n}=await this._processApplyEditsParams(e,t),l=await Promise.all(o.map(async e=>{const t=e.addFeatures?.map(e=>f({spatialReference:a},e,null))??[],r=(await Promise.all(t)).filter(i),o=r.length>0?r:null,n=e.updateFeatures?.map(e=>f({spatialReference:a},e,null))??[],l=(await Promise.all(n)).filter(i),u=l.length>0?l:null,d=b(e.identifierFields,e.deleteFeatures,s),p=d.length>0?d:null;G(o,u,a);const c=await g(e.identifierFields,e);let m=null;if(c){m={adds:c.adds.length>0?c.adds:void 0,updates:c.updates.length>0?c.updates:void 0,deletes:c.deletes.length>0?c.deletes:void 0}}const y={};return e.deleteAssociations&&(y.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(y.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(y.divideGroupedObjects=e.divideGroupedObjects),{id:e.id,adds:o,updates:u,deletes:p,attachments:m,...y}})),u={gdbVersion:n?.gdbVersion,rollbackOnFailure:!0,useGlobalIds:s,returnEditMoment:!0,honorSequenceOfEdits:n?.honorSequenceOfEdits,usePreviousEditMoment:n?.usePreviousEditMoment,returnServiceEditsInSourceSR:!1,returnServiceEditsOption:"originalAndCurrentFeatures",async:!1};await L(this.url,t?.gdbVersion,!0);const d=M(this.url,t?.gdbVersion||null);u.edits=JSON.stringify(l);const p=D(this.url),c=P(p.query,{query:V({...u,f:"json"}),method:"post"});let m;d&&(c.authMode="immediate",c.query.sessionId=_);try{m=await r(this.url+"/applyEdits",c)}catch(y){if(!v(y))throw y;c.authMode="immediate",m=await r(this.url+"/applyEdits",c)}return{...z(m),edits:o}}async _processApplyEditsParams(e,t){const s={...t,usingFeatureServiceEndpoint:!0,usingTelecomOperations:e.some(e=>e.deleteAssociations||e.combineGroupedObjects||e.divideGroupedObjects)};return{edits:await Promise.all(e.map(async e=>{const t=this.effectiveCapabilities,r=e&&(e.addFeatures||e.updateFeatures||e.deleteFeatures),i=e&&(e.addAttachments||e.updateAttachments||e.deleteAttachments);if(E(e,t,s,!!r,!!i,"feature-service"),!t.data.isDataVersioned&&s?.gdbVersion)throw new a("feature-service:invalid-parameter","'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isDataVersioned'");const o=O(e,t,"feature-service"),n={};e.deleteAssociations&&(n.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(n.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(n.divideGroupedObjects=e.divideGroupedObjects);const l=await R(o);return{id:e.id,...l,...n,identifierFields:e.identifierFields}})),options:s}}async _fetchService(e,t){if(this.sourceJSON)return void this.read(this.sourceJSON,{url:D(e)});const s=await r(e,{responseType:"json",query:{f:"json"},...t});this.read(s.data,{url:D(e)})}async _fetchLayersAndTables(e){const t=`${e}/layers`,s=await r(t,{responseType:"json",query:{f:"json"}});return{layers:s.data.layers.map(e=>{const{type:t,geometryType:s}=e,r=x(this.url,e),i=I(e,r.url);return{...r,type:t||"Feature Layer",geometryType:s,capabilities:i}}),tables:s.data.tables.map(e=>{const t=x(this.url,e),s=I(e,t.url);return{...t,capabilities:s}})}}};function z(e){const t=e.data,s=[];return{results:t.map(e=>{const t={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment},r=j(t),i=e.editedFeatures,a=i?.spatialReference?new h({wkid:i?.spatialReference.wkid,wkt:i?.spatialReference.wkt,latestWkid:i?.spatialReference.latestWkid,latestVcsWkid:i?.spatialReference.latestVcsWkid,vcsWkid:i?.spatialReference.vcsWkid}):null,o=i?S(i,a):null;o&&s.push({layerId:e.id,editedFeatures:o});const n={};return e.divideGroupedObjectResults&&(n.divideGroupedObjectResults=e.divideGroupedObjectResults),e.combineGroupedObjectResults&&(n.combineGroupedObjectResults=e.combineGroupedObjectResults),{id:e.id,editedFeatures:o,...r,...n}}),editedFeatures:s}}e([c()],$.prototype,"url",void 0),e([c()],$.prototype,"sourceJSON",void 0),e([c()],$.prototype,"userHasFullEditingPrivileges",void 0),e([c()],$.prototype,"userHasUpdateItemPrivileges",void 0),e([c({readOnly:!0})],$.prototype,"utilityNetworkUrl",null),e([c({readOnly:!0})],$.prototype,"versionManagementServiceUrl",null),e([c()],$.prototype,"userTypeExtensions",void 0),e([c({json:{read:{source:["layers"]}}})],$.prototype,"layerInfos",void 0),e([m("layerInfos",["layers"])],$.prototype,"readLayerInfos",null),e([c({json:{read:{source:["tables"]}}})],$.prototype,"tableInfos",void 0),e([m("tableInfos",["tables"])],$.prototype,"readTableInfos",null),e([c({readOnly:!0,json:{read:{source:["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"]}}})],$.prototype,"capabilities",void 0),e([m("capabilities",["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"])],$.prototype,"readCapabilities",null),e([c({readOnly:!0})],$.prototype,"effectiveCapabilities",null),$=e([y("esri.rest.featureService.FeatureService")],$);const Z=$;export{Z 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.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../request.js";import{fromJSON as t}from"../renderers/support/jsonUtils.js";import{parseUrl as n}from"./utils.js";import{executeQuery as i}from"./query/executeQuery.js";import a from"./support/Query.js";import s from"./support/StatisticDefinition.js";async function l(t,i,a,s){const l=n(t),{source:r,checkValueRange:u}=i,{classificationDefinition:c}=a,f={...a.toJSON(),f:"json"};let m=null;if(m="class-breaks-definition"===c?.type?c.classificationField:c?.attributeField,r){const e={source:r?.toJSON()};f.layer=JSON.stringify(e)}f.classificationDef&&(f.classificationDef=JSON.stringify(f.classificationDef));let p={query:f};s&&(p={...s,...p});const y={url:l.path,field:m,checkValueRange:u},d=l.path+"/generateRenderer";return e(d,p).then(e=>o(y,e))}function o(e,t){const{field:n,checkValueRange:l,url:o}=e,u=t?.data;if(!u)return;if(!l){const e=r(u);return Promise.resolve(e)}const c=new s({statisticType:"min",onStatisticField:n}),f=new s({statisticType:"max",onStatisticField:n}),m=new a({outStatistics:[c,f]});return i(o,m).then(e=>{const t=e.features[0].attributes;let n=null,i=null;for(const a in t)0===a.toLowerCase().indexOf("min")?n=t[a]:i=t[a];return r(u,n,i)})}function r(e,n,i){if("classBreaks"===e.type){const a=t(e);return{classBreaks:a.classBreakInfos.map((e,t)=>(0===t&&null!=n&&(e.minValue=n),t===a.classBreakInfos.length-1&&null!=i&&(e.maxValue=i),{minValue:e.minValue,maxValue:e.maxValue,label:e.label})),normalizationTotal:a.normalizationTotal}}const{uniqueValueInfos:a}=e;return{uniqueValues:a?.map((e,t)=>(0===t&&null!=n&&(e.value=n),t===a.length-1&&null!=i&&(e.value=i),{count:e.count,value:e.value,label:e.label}))??[]}}export{l as generateRenderer};
5
+ import e from"../request.js";import{fromJSON as t}from"../renderers/support/jsonUtils.js";import{parseUrl as n}from"./utils.js";import{executeQuery as i}from"./query/executeQuery.js";import s from"./support/Query.js";import a from"./support/StatisticDefinition.js";async function l(t,i,s,a){const l=n(t),{source:o,checkValueRange:u}=i,{classificationDefinition:c}=s,f={...s.toJSON(),f:"json"};let m=null;if(m="class-breaks-definition"===c?.type?c.classificationField:c?.attributeField,o){const e={source:o?.toJSON()};f.layer=JSON.stringify(e)}f.classificationDef&&(f.classificationDef=JSON.stringify(f.classificationDef));let p={query:f};a&&(p={...a,...p});const y={url:l.path,field:m,checkValueRange:u},V=l.path+"/generateRenderer";return e(V,p).then(e=>r(y,e))}function r(e,t){const{field:n,checkValueRange:l,url:r}=e,u=t?.data;if(!u)return;if(!l){const e=o(u);return Promise.resolve(e)}const c=new a({statisticType:"min",onStatisticField:n}),f=new a({statisticType:"max",onStatisticField:n}),m=new s({outStatistics:[c,f]});return i(r,m).then(e=>{const t=e.features[0].attributes;let n=null,i=null;for(const s in t)s.toLowerCase().startsWith("min")?n=t[s]:i=t[s];return o(u,n,i)})}function o(e,n,i){if("classBreaks"===e.type){const s=t(e);return{classBreaks:s.classBreakInfos.map((e,t)=>(0===t&&null!=n&&(e.minValue=n),t===s.classBreakInfos.length-1&&null!=i&&(e.maxValue=i),{minValue:e.minValue,maxValue:e.maxValue,label:e.label})),normalizationTotal:s.normalizationTotal}}const{uniqueValueInfos:s}=e;return{uniqueValues:s?.map((e,t)=>(0===t&&null!=n&&(e.value=n),t===s.length-1&&null!=i&&(e.value=i),{count:e.count,value:e.value,label:e.label}))??[]}}export{l as generateRenderer};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as o}from"tslib";import{JSONSupport as r}from"../../../core/JSONSupport.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";let s=class extends r{constructor(o){super(o),this.name=null,this.globalId=null,this.providerId=null,this.consumerId=null,this.isReserved=!1}};o([t({type:String,json:{write:!0}})],s.prototype,"name",void 0),o([t({type:String,json:{write:!0}})],s.prototype,"globalId",void 0),o([t({type:String,readOnly:!0})],s.prototype,"providerId",void 0),o([t({type:String,readOnly:!0})],s.prototype,"consumerId",void 0),o([t({type:Boolean,json:{write:!0}})],s.prototype,"isReserved",void 0),s=o([e("esri.rest.networks.support.Subcircuit")],s);const p=s;export{p 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{reader as o}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{writer as n}from"../../../core/accessorSupport/decorators/writer.js";import i from"./AggregatedGeometry.js";import p from"./CircuitPath.js";import l from"./CircuitTraceResult.js";import m from"./FunctionResult.js";import a from"./NetworkElement.js";import u from"./TelecomNetworkElement.js";let c=class extends t{constructor(e){super(e),this.aggregatedGeometry=null,this.circuits=null,this.elements=null,this.globalFunctionResults=null,this.kFeaturesForKNNFound=!1,this.paths=null,this.startingPointsIgnored=!1,this.warnings=null}readNetworkElements(e,t){return null!=t.elements?t.elements.map(e=>"firstUnit"in e&&"numUnits"in e?new u({...e}):new a({...e})):[]}writeNetworkElements(e,t){t.elements=e.map(e=>e.toJSON())}};e([r({type:i,json:{write:!0},readOnly:!0})],c.prototype,"aggregatedGeometry",void 0),e([r({type:[l],json:{write:!0},readOnly:!0})],c.prototype,"circuits",void 0),e([r({type:[a],json:{write:!0},readOnly:!0})],c.prototype,"elements",void 0),e([o("elements")],c.prototype,"readNetworkElements",null),e([n("elements")],c.prototype,"writeNetworkElements",null),e([r({type:[m],json:{write:!0},readOnly:!0})],c.prototype,"globalFunctionResults",void 0),e([r({type:Boolean,json:{write:!0},readOnly:!0})],c.prototype,"kFeaturesForKNNFound",void 0),e([r({type:[p],json:{write:!0},readOnly:!0})],c.prototype,"paths",void 0),e([r({type:Boolean,json:{write:!0},readOnly:!0})],c.prototype,"startingPointsIgnored",void 0),e([r({type:[String],json:{write:!0},readOnly:!0})],c.prototype,"warnings",void 0),c=e([s("esri.rest.networks.support.TraceResult")],c);export{c as default};
5
+ import{__decorate as e}from"tslib";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{reader as o}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{writer as n}from"../../../core/accessorSupport/decorators/writer.js";import i from"./AggregatedGeometry.js";import p from"./CircuitPath.js";import l from"./CircuitTraceResult.js";import a from"./FunctionResult.js";import m from"./NetworkElement.js";import u from"./TelecomNetworkElement.js";let c=class extends t{constructor(e){super(e),this.aggregatedGeometry=null,this.circuits=null,this.elements=null,this.globalFunctionResults=null,this.kFeaturesForKNNFound=!1,this.paths=null,this.startingPointsIgnored=!1,this.warnings=null}readNetworkElements(e,t){return null!=t.elements&&Array.isArray(t.elements)?t.elements.map(e=>"firstUnit"in e&&"numUnits"in e?new u({...e}):new m({...e})):[]}writeNetworkElements(e,t){t.elements=e.map(e=>e.toJSON())}};e([r({type:i,json:{write:!0},readOnly:!0})],c.prototype,"aggregatedGeometry",void 0),e([r({type:[l],json:{write:!0},readOnly:!0})],c.prototype,"circuits",void 0),e([r({type:[m],json:{write:!0},readOnly:!0})],c.prototype,"elements",void 0),e([o("elements")],c.prototype,"readNetworkElements",null),e([n("elements")],c.prototype,"writeNetworkElements",null),e([r({type:[a],json:{write:!0},readOnly:!0})],c.prototype,"globalFunctionResults",void 0),e([r({type:Boolean,json:{write:!0},readOnly:!0})],c.prototype,"kFeaturesForKNNFound",void 0),e([r({type:[p],json:{write:!0},readOnly:!0})],c.prototype,"paths",void 0),e([r({type:Boolean,json:{write:!0},readOnly:!0})],c.prototype,"startingPointsIgnored",void 0),e([r({type:[String],json:{write:!0},readOnly:!0})],c.prototype,"warnings",void 0),c=e([s("esri.rest.networks.support.TraceResult")],c);export{c 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.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../request.js";import r from"../../core/Error.js";import{join as t}from"../../core/urlUtils.js";async function s({serviceUrl:s,query:l,requestOptions:o={}}){if(null==l.layers&&null==l.templateIds)throw new r("query-shared-templates:invalid-parameters","Must supply a value for either the 'layers' or the 'templateIds' parameters");const p=t(s,"sharedTemplates","query"),n={f:"json",...o.query,...l};n.layers&&(n.layers=a(n.layers)),n.templateIds&&(n.templateIds=a(n.templateIds)),n.tags&&(n.tags=a(n.tags));const u={...o,responseType:"json",query:n};return(await e(p,u)).data.templates}function a(e){return Array.isArray(e)?e.join(","):""}export{s as querySharedTemplates};
5
+ import e from"../../request.js";import r from"../../core/Error.js";import{join as t}from"../../core/urlUtils.js";import a from"../../editing/sharedTemplates/SharedTemplateMetadata.js";async function s({featureService:s,query:n,requestOptions:p={}}){if(o(n.layers)&&o(n.templateIds)&&(n.layers=s.layerInfos.map(e=>e.id),!n.layers.length))throw new r("query-shared-templates:invalid-parameters","Must supply a value for either the 'layers' or the 'templateIds' parameters");const m=t(s.url,"sharedTemplates","query"),u={f:"json",...p.query,...n};u.layers&&(u.layers=l(u.layers)),u.templateIds&&(u.templateIds=l(u.templateIds)),u.tags&&(u.tags=l(u.tags));const i={...p,responseType:"json",query:u};return(await e(m,i)).data.templates.map(e=>{const r=a.fromJSON(e);return r.featureService=s,r})}function l(e){return Array.isArray(e)?e.join(","):""}function o(e){return null==e||!e.length}export{s as querySharedTemplates};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{pt2px as t}from"../../../core/screenUtils.js";import{millisecondsPerTimeUnit as n}from"../../../core/timeUtils.js";import r from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import{quantizePoint as i}from"../../../geometry/support/quantizationUtils.js";import{isWrappable as s,getInfo as l}from"../../../geometry/support/spatialReferenceUtils.js";import{isTimeOnlyField as a,isNumericField as u,numericTypes as f}from"../../../layers/support/fieldUtils.js";import{createValueFunction as c,evaluateDensityKernel as m}from"../../../renderers/support/heatmapUtils.js";import{isAnyDateField as p}from"../../support/utils.js";import{processNullValue as d,getNormalizedValue as h}from"../../../statistics/utils.js";import{loadArcade as y}from"../../../support/loadArcade.js";let $=null;const g=/^(?<hh>([01][0-9])|(2[0-3])):(?<mm>[0-5][0-9])(:(?<ss>[0-5][0-9]))?(\.(?<ms>\d+))?$/;function j(e,t,n){return e.x<0?e.x+=t:e.x>n&&(e.x-=t),e}function x(e,t,n,o){const a=s(n)?l(n):null,u=a?Math.round((a.valid[1]-a.valid[0])/t.scale[0]):null;return e.map(e=>{const n=new r(e.geometry);return i(t,n,n),e.geometry=a?j(n,u??0,o[0]):n,e})}function w(e,n=18,r,o,i){const s=new Float64Array(o*i);n=Math.round(t(n));let l=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;const u=c(r);for(const{geometry:t,attributes:f}of e){const{x:e,y:r}=t,c=Math.max(0,e-n),p=Math.max(0,r-n),d=Math.min(i,r+n),h=Math.min(o,e+n),y=+u(f);for(let t=p;t<d;t++)for(let i=c;i<h;i++){const u=t*o+i,f=m(i-e,t-r,n)*y,c=s[u]+=f;l=Math.min(l,c),a=Math.max(a,c)}}return{min:l,max:a}}function I(e){const t=g.exec(e);if(!t)return null;const{hh:r,mm:o,ss:i,ms:s}=t.groups;return Number(r)*n.hours+Number(o)*n.minutes+Number(i)*n.seconds+Number(s||0)}async function b(e,t,n=!0){if(!t)return[];const{field:r,field2:i,field3:s,fieldDelimiter:l,fieldInfos:u,timeZone:f}=e,c=r&&u?.find(e=>e.name.toLowerCase()===r.toLowerCase()),m=!!c&&a(c),g=!!c&&p(c),j=e.valueExpression,x=e.normalizationType,w=e.normalizationField,b=e.normalizationTotal,F=[],N=e.viewInfoParams;let E=null,v=null;if(j){if(!$){const{arcadeUtils:e}=await y();$=e}$.hasGeometryOperations(j)&&await $.enableGeometryOperations(),E=$.createFunction(j),v=N?$.getViewInfo({viewingMode:N.viewingMode,scale:N.scale,spatialReference:new o(N.spatialReference)}):null}const U=e.fieldInfos,M=!(t[0]&&"declaredClass"in t[0]&&"esri.Graphic"===t[0].declaredClass)&&U?{fields:U}:null;return t.forEach(e=>{const t=e.attributes;let o;if(j){const t=M?{...e,layer:M}:e,n=$.createExecContext(t,v,f);o=$.executeFunction(E,n)}else t&&(o=t[r],i?(o=`${d(o)}${l}${d(t[i])}`,s&&(o=`${o}${l}${d(t[s])}`)):"string"==typeof o&&n&&(g?o=o?new Date(o).getTime():null:m&&(o=o?I(o):null)));if(x&&"number"==typeof o&&isFinite(o)){const e=t&&parseFloat(t[w]);o=h(o,x,e,b)}F.push(o)}),F}function F(e){const t=e.field,n=e.normalizationType,r=e.normalizationField;let o;return"field"===n?o="(NOT "+r+" = 0)":"log"!==n&&"natural-log"!==n&&"square-root"!==n||(o=`(${t} > 0)`),o}function N(e,t,n){const r=null!=t?e+" >= "+t:"",o=null!=n?e+" <= "+n:"";let i="";return i=r&&o?U(r,o):r||o,i?"("+i+")":""}function E(t,n,r,o){let i;return n?n.name!==t.objectIdField&&o.includes(n.type)||(i=new e(r,"'field' should be one of these types: "+o.join(","))):i=new e(r,"'field' is not defined in the layer schema"),i}function v(t,n,r){let o;return n?n.name!==t.objectIdField&&u(n)||(o=new e(r,"'field' should be one of these numeric types: "+f.join(","))):o=new e(r,"'field' is not defined in the layer schema"),o}function U(e,t){let n=null!=e?e:"";return null!=t&&t&&(n=n?"("+n+") AND ("+t+")":t),n}function M(t,n){if(t&&"intersects"!==t.spatialRelationship)return new e(n,"Only 'intersects' spatialRelationship is supported for featureFilter")}function T(t,n,r){const o=z({layer:t,fields:n});if(o.length)return new e(r,"Unknown fields: "+o.join(", ")+". You can only use fields defined in the layer schema");const i=R({layer:t,fields:n});return i.length?new e(r,"Unsupported fields: "+i.join(", ")+". You can only use fields that can be fetched i.e. AdapterFieldUsageInfo.supportsStatistics must be true"):void 0}function z(e){const t=e.layer;return e.fields.filter(e=>!t.getField(e))}function R(e){const t=e.layer;return e.fields.filter(e=>{const n=t.getFieldUsageInfo(e);return!n||!n.supportsStatistics})}function A(e,t,n){const r=[],o=[],i=[],s=[],l=[];e.forEach((e,t)=>{const a=e.field?"field":"expression",u=e.field||e.valueExpression;e.field?(l.push(u),o.push(`var ${a}${t} = Number($feature["${u}"]);`)):(r.push(`function getValueForExpr${t}() {\n ${u} \n}`),o.push(`var ${a}${t} = Number(getValueForExpr${t}());`)),n||i.push(`${a}${t} = IIf(${a}${t} < 0, 0, ${a}${t});`),s.push(`${a}${t}`)});const a=r.length?null:l.reduce((e,t)=>`${e} + ${t}`);let u=null;t||n?t?n||a&&(u=`(( ${a} ) >= 0)`):a&&(u=`(( ${a} ) <> 0)`):a&&(u=`(( ${a} ) > 0)`);return{valueExpression:[r.length?r.join("\n"):"",o.join("\n"),i.join("\n"),`var total = ${s.join(" + ")};`,"return total;"].filter(Boolean).join("\n\n"),sqlExpression:a,sqlWhere:u}}export{w as calculateHeatmapStats,b as getDataValues,N as getRangeExpr,F as getSQLFilterForNormalization,A as getSumOfAttributesExpr,U as mergeWhereClauses,x as quantizeFeatures,I as timeOnlyToMilliseconds,T as verifyBasicFieldValidity,E as verifyFieldType,M as verifyFilterValidity,v as verifyNumericField};
5
+ import e from"../../../core/Error.js";import{pt2px as t}from"../../../core/screenUtils.js";import{millisecondsPerTimeUnit as n}from"../../../core/timeUtils.js";import r from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import{quantizePoint as i}from"../../../geometry/support/quantizationUtils.js";import{isWrappable as s,getInfo as l}from"../../../geometry/support/spatialReferenceUtils.js";import{isTimeOnlyField as a,isNumericField as u,numericTypes as f}from"../../../layers/support/fieldUtils.js";import{createValueFunction as c,evaluateDensityKernel as m}from"../../../renderers/support/heatmapUtils.js";import{isAnyDateField as p}from"../../support/utils.js";import{processNullValue as d,getNormalizedValue as h}from"../../../statistics/utils.js";import{loadArcade as y}from"../../../support/loadArcade.js";let $=null;const g=/^(?<hh>([01][0-9])|(2[0-3])):(?<mm>[0-5][0-9])(:(?<ss>[0-5][0-9]))?(\.(?<ms>\d+))?$/;function j(e,t,n){return e.x<0?e.x+=t:e.x>n&&(e.x-=t),e}function x(e,t,n,o){const a=s(n)?l(n):null,u=a?Math.round((a.valid[1]-a.valid[0])/t.scale[0]):null;return e.map(e=>{const n=new r(e.geometry);return i(t,n,n),e.geometry=a?j(n,u??0,o[0]):n,e})}function w(e,n=18,r,o,i){const s=new Float64Array(o*i);n=Math.round(t(n));let l=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;const u=c(r);for(const{geometry:t,attributes:f}of e){const{x:e,y:r}=t,c=Math.max(0,e-n),p=Math.max(0,r-n),d=Math.min(i,r+n),h=Math.min(o,e+n),y=+u(f);for(let t=p;t<d;t++)for(let i=c;i<h;i++){const u=t*o+i,f=m(i-e,t-r,n)*y,c=s[u]+=f;l=Math.min(l,c),a=Math.max(a,c)}}return{min:l,max:a}}function b(e){const t=g.exec(e);if(!t)return null;const{hh:r,mm:o,ss:i,ms:s}=t.groups;return Number(r)*n.hours+Number(o)*n.minutes+Number(i)*n.seconds+Number(s||0)}async function I(e,t,n=!0){if(!t)return[];const{field:r,field2:i,field3:s,fieldDelimiter:l,fieldInfos:u,timeZone:f}=e,c=r&&u?.find(e=>e.name.toLowerCase()===r.toLowerCase()),m=!!c&&a(c),g=!!c&&p(c),j=e.valueExpression,x=e.normalizationType,w=e.normalizationField,I=e.normalizationTotal,F=[],N=e.viewInfoParams;let E=null,v=null;if(j){if(!$){const{arcadeUtils:e}=await y();$=e}$.hasGeometryOperations(j)&&await $.enableGeometryOperations(),E=$.createFunction(j),v=N?$.getViewInfo({viewingMode:N.viewingMode,scale:N.scale,spatialReference:new o(N.spatialReference)}):null}const U=e.fieldInfos,M=!(t[0]&&"declaredClass"in t[0]&&"esri.Graphic"===t[0].declaredClass)&&U?{fields:U}:null;return t.forEach(e=>{const t=e.attributes;let o;if(j){const t=M?Object.assign({},e,{layer:M}):e,n=$.createExecContext(t,v,f);o=$.executeFunction(E,n)}else t&&(o=t[r],i?(o=`${d(o)}${l}${d(t[i])}`,s&&(o=`${o}${l}${d(t[s])}`)):"string"==typeof o&&n&&(g?o=o?new Date(o).getTime():null:m&&(o=o?b(o):null)));if(x&&"number"==typeof o&&isFinite(o)){const e=t&&parseFloat(t[w]);o=h(o,x,e,I)}F.push(o)}),F}function F(e){const t=e.field,n=e.normalizationType,r=e.normalizationField;let o;return"field"===n?o="(NOT "+r+" = 0)":"log"!==n&&"natural-log"!==n&&"square-root"!==n||(o=`(${t} > 0)`),o}function N(e,t,n){const r=null!=t?e+" >= "+t:"",o=null!=n?e+" <= "+n:"";let i="";return i=r&&o?U(r,o):r||o,i?"("+i+")":""}function E(t,n,r,o){let i;return n?n.name!==t.objectIdField&&o.includes(n.type)||(i=new e(r,"'field' should be one of these types: "+o.join(","))):i=new e(r,"'field' is not defined in the layer schema"),i}function v(t,n,r){let o;return n?n.name!==t.objectIdField&&u(n)||(o=new e(r,"'field' should be one of these numeric types: "+f.join(","))):o=new e(r,"'field' is not defined in the layer schema"),o}function U(e,t){let n=null!=e?e:"";return null!=t&&t&&(n=n?"("+n+") AND ("+t+")":t),n}function M(t,n){if(t&&"intersects"!==t.spatialRelationship)return new e(n,"Only 'intersects' spatialRelationship is supported for featureFilter")}function T(t,n,r){const o=z({layer:t,fields:n});if(o.length)return new e(r,"Unknown fields: "+o.join(", ")+". You can only use fields defined in the layer schema");const i=O({layer:t,fields:n});return i.length?new e(r,"Unsupported fields: "+i.join(", ")+". You can only use fields that can be fetched i.e. AdapterFieldUsageInfo.supportsStatistics must be true"):void 0}function z(e){const t=e.layer;return e.fields.filter(e=>!t.getField(e))}function O(e){const t=e.layer;return e.fields.filter(e=>{const n=t.getFieldUsageInfo(e);return!n||!n.supportsStatistics})}function R(e,t,n){const r=[],o=[],i=[],s=[],l=[];e.forEach((e,t)=>{const a=e.field?"field":"expression",u=e.field||e.valueExpression;e.field?(l.push(u),o.push(`var ${a}${t} = Number($feature["${u}"]);`)):(r.push(`function getValueForExpr${t}() {\n ${u} \n}`),o.push(`var ${a}${t} = Number(getValueForExpr${t}());`)),n||i.push(`${a}${t} = IIf(${a}${t} < 0, 0, ${a}${t});`),s.push(`${a}${t}`)});const a=r.length?null:l.reduce((e,t)=>`${e} + ${t}`);let u=null;t||n?t?n||a&&(u=`(( ${a} ) >= 0)`):a&&(u=`(( ${a} ) <> 0)`):a&&(u=`(( ${a} ) > 0)`);return{valueExpression:[r.length?r.join("\n"):"",o.join("\n"),i.join("\n"),`var total = ${s.join(" + ")};`,"return total;"].filter(Boolean).join("\n\n"),sqlExpression:a,sqlWhere:u}}export{w as calculateHeatmapStats,I as getDataValues,N as getRangeExpr,F as getSQLFilterForNormalization,R as getSumOfAttributesExpr,U as mergeWhereClauses,x as quantizeFeatures,b as timeOnlyToMilliseconds,T as verifyBasicFieldValidity,E as verifyFieldType,M as verifyFilterValidity,v as verifyNumericField};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- const a="20250722",b="340ac9c2ea5f8185b388bef4939f83b7be5aa639";export{a as buildDate,b as commitHash};
5
+ const e="20250726",d="a75b15d4a0f3eb1d6f20e7b57deee565fedc97c9";export{e as buildDate,d as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as t}from"../../core/fontUtils.js";import"../../core/has.js";import{clone as r}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAbsoluteAnchor as p,handleMarker as c,handleRelativeAnchor as m,getFrameTranslation as y,translate as d,getStaticParam as h,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as u}from"./CIMSymbolHelper.js";import{antialiasingOutlineFillSettings as v}from"./constants.js";import{defaultCIMValues as O}from"./defaultCIMValues.js";import{fitVectorMarker as g}from"./fitVectorMarker.js";import{OverrideHelper as _}from"./OverrideHelper.js";import{getExtent as S,getSDFMetrics as M,getSDFDimensions as k}from"./SDFHelper.js";import{colorToArray as C,normalizeAlpha as b,getSize as x,isCIMMarkerStrokePlacement as P,hasStrokeLayer as z,getTintColor as I,getNumericValue as E,normalizePrimitiveOverrideProps as L,getDefaultCIMValue as V,getEnum as N,getStrokeWidth as R,getFillColor as w,getStrokeColor as A,fromCIMFontDecoration as G,fromCIMFontStyle as T,fromCIMVerticalAlignment as F,fromCIMHorizontalAlignment as X,getTextCasing as j,isValidCIMValue as Y,uncapitalize as W}from"./utils.js";import{CIMEffectHelper as D}from"./effects/CIMEffectHelper.js";import{rasterizedVectorMarkerMinSize as U,randomInsidePolygonTextureSize as H}from"../../views/2d/engine/webgl/definitions.js";const J=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function B(e){const t=e.markerPlacement;return t&&t.angleToLine?1:0}class q{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._hasTextStringTemplates=!1,e&&(this._resourceManager=e)}analyzeSymbolReference(t,r,i){if(this._cimLayers=i??[],!t)return this._cimLayers;if(this._reset(),this._hasTextStringTemplates=t.hasTextStringTemplates??!1,t.primitiveOverrides){this._primitiveOverrides=t.primitiveOverrides;for(const t of this._primitiveOverrides){const r=t.valueExpressionInfo;if(r)this._setPoMap(t.primitiveName,t.propertyName,r);else if(null!=t.value){let r=t.value;t.propertyName.includes("Color")&&(e(r)&&(r=C(r)),r=b(r)),this._setPoMap(t.primitiveName,t.propertyName,r)}}}return this._analyzeSymbol(t.symbol,r),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t)}}_analyzeMultiLayerSymbol(e,t){const r=e?.symbolLayers;if(!r)return;for(let l=0;l<r.length;l++){const e=r[l];"CIMVectorMarker"===e.type&&(r[l]=g(e))}const i=e.effects;let o=0;const a=x(e)??0;if("CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=1),re(r,i))return this._analyzeCompositeOutlineFill(r,i,a);let s={transform:[0,0,0,1],fromColor:[1,1,1,1],toColor:[1,1,1,1],colorMix:[0,0,0,0],toOpacity:[1,1,1,1],opacityMix:[0,0,0,0],shift:[1,1,1,1],hasAnimations:l(e),hasShiftAnimation:!1,hasMotionAnimations:!1};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=r.length;for(;c--;){const l=r[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let y=null;if(n){y=[];for(const e of n){const t=_.findEffectOverrides(e,this._primitiveOverrides);t&&y.push(t)}}const d=[];switch(_.findApplicableOverrides(l,this._primitiveOverrides,d),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,y,s,z(r));break;case"CIMPictureFill":this._analyzePictureFill(l,y,s);break;case"CIMHatchFill":this._analyzeHatchFill(l,y);break;case"CIMGradientFill":this._analyzeGradientFill(l,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,y,p,a,s);break;case"CIMPictureStroke":this._analyzePictureStroke(l,y,p,a,s);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,y,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=B(l));const r=[],i=l.primitiveName;i&&r.push(i);const n=p&&P(l.markerPlacement);this._analyzeMarker(l,y,null,r,o,a,t,[],s,!1,n);break}default:J().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,t,r,i){const{primitiveName:o,type:a}=e,s=b(e.color),l=n(this._poMap,e,r);if(!i&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.effect.type)){const r=this._getValueOrOverrideExpression(a,o,"Color",s);return void this._cimLayers.push({type:"outlineFill",colorLocked:!!e.colorLocked,color:r,effects:t,outlineColor:r,outlineColorLocked:!!e.colorLocked,...v,outlineEffects:t})}this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(a,o,"Color",s),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1,animationParams:oe(l)})}_analyzePictureFill(e,t,r){const{primitiveName:i,type:o}=e,a=I(e),s=E(e.height,O.CIMPictureFill.height);let l=E(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height),l/=r*(s/t)}const p={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(i,o)},c=n(this._poMap,e,r);this._cimLayers.push({type:"fill",spriteRasterizationParam:p,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(o,i,"TintColor",a),height:this._getValueOrOverrideExpression(o,i,"Height",s),scaleX:this._getValueOrOverrideExpression(o,i,"ScaleX",l),angle:this._getValueOrOverrideExpression(o,i,"Rotation",E(e.rotation)),offsetX:this._getValueOrOverrideExpression(o,i,"OffsetX",E(e.offsetX)),offsetY:this._getValueOrOverrideExpression(o,i,"OffsetY",E(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1,animationParams:oe(c)})}_analyzeHatchFill(e,t){const{primitiveName:r,type:i}=e,o=this._analyzeMaterialOverrides(r,["Rotation","OffsetX","OffsetY"]),a=L(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??r;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=b(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const t=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(t){let r=null,o=null;"number"==typeof t?r=t:o=t.valueExpressionInfo;let s=a.find(e=>"strokeWidth"===e.propertyName);s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:r,defaultValue:V(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:t,color:s,height:this._getValueOrOverrideExpression(i,r,"Separation",E(e.separation,O.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,r,"Rotation",E(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,r,"OffsetX",E(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,r,"OffsetY",E(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,t){const{angle:r,gradientMethod:i,gradientSize:o,gradientSizeUnits:a,gradientType:s,interval:l,primitiveName:n,type:p}=e,c=O.CIMGradientFill,m=e.colorRamp;this._cimLayers.push({type:"gradientFill",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(n,p)},colorLocked:!1,effects:t,color:[255,255,255,1],gradientMethod:this._getValueOrOverrideExpression(p,n,"GradientMethod",i??"Linear"),angle:this._getValueOrOverrideExpression(p,n,"Angle",E(r,c.angle)),gradientType:this._getValueOrOverrideExpression(p,n,"GradientType",s??c.gradientType),interval:this._getValueOrOverrideExpression(p,n,"Interval",E(l,"CIMFixedColorRamp"===m.type?m.colors.length:c.interval)),gradientSize:this._getValueOrOverrideExpression(p,n,"GradientSize",E(o,c.gradientSize)),gradientSizeUnits:"Absolute"===a?1:"Relative"===a?0:c.gradientSizeUnits})}_analyzeCompositeOutlineFill(e,t,r){const i=e.find(e=>"CIMSolidFill"===e.type),o=e.find(e=>"CIMSolidStroke"===e.type);if(null==i||null==o)return;const a=[...t??[],...i.effects??[]].map(e=>_.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),s=[...t??[],...o.effects??[]].map(e=>_.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),l=E(o.width,O.CIMSolidStroke.width),n=N(o.capStyle,O.CIMSolidStroke.capstyle),p=N(o.joinStyle,O.CIMSolidStroke.joinstyle),c=o.miterLimit;this._cimLayers.push({type:"outlineFill",colorLocked:!!i.colorLocked,color:this._getValueOrOverrideExpression(i.type,i.primitiveName,"Color",b(i.color)),effects:a,outlineColorLocked:!!o.colorLocked,outlineColor:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Color",b(o.color)),outlineWidth:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Width",l),cap:this._getValueOrOverrideExpression(o.type,o.primitiveName,"CapStyle",n),join:this._getValueOrOverrideExpression(o.type,o.primitiveName,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(o.type,o.primitiveName,"MiterLimit",c),referenceWidth:r,outlineEffects:s})}_analyzeSolidStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=b(e.color),p=E(e.width,O.CIMSolidStroke.width),c=N(e.capStyle,O.CIMSolidStroke.capstyle),m=N(e.joinStyle,O.CIMSolidStroke.joinstyle),y=e.miterLimit;let d,h,f,u,v=[];if(this._analyzePrimitiveOverrides(a,t,null,null)&&(v=this._getPrimitiveMaterialOverrides(a,s)),t&&Array.isArray(t)&&t.length>0){const e=t[t.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(d=e.dashTemplate,h=e.scaleDash,f=e.offsetAlongLine,u=e.primitiveName,(t=[...t]).pop())}null!=u&&v.push(...this._getPrimitiveMaterialOverrides(u,s).filter(e=>"dashTemplate"===e.propertyName));const g=void 0!==d?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:d,primitiveName:u},overrides:v}:null,_=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:g,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"Color",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:Q(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(u,"DashTemplate")??d,offsetAlongLine:this._getValueOrOverrideExpression(s,u,"OffsetAlongLine",f??0),scaleDash:h,sampleAlphaOnly:!0,animationParams:oe(_)})}_analyzePictureStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=I(e),p=E(e.width,O.CIMPictureStroke.width),c=N(e.capStyle,O.CIMPictureStroke.capstyle),m=N(e.joinStyle,O.CIMPictureStroke.joinstyle),y=e.miterLimit,d={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(a,s)},h=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:d,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"TintColor",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:Q(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1,animationParams:oe(h)})}_analyzeGradientStroke(e,t,r,i){const{gradientMethod:o,gradientSize:a,gradientSizeUnits:s,gradientType:l,interval:n,primitiveName:p,type:c}=e,m=O.CIMGradientStroke,y=E(e.width,m.width),d=N(e.capStyle,m.capstyle),h=N(e.joinStyle,m.joinstyle),f=e.miterLimit,u=e.colorRamp;this._cimLayers.push({type:"gradientStroke",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(p,c)},colorLocked:!!e.colorLocked,effects:t,color:[255,255,255,1],width:this._getValueOrOverrideExpression(c,p,"Width",y),cap:this._getValueOrOverrideExpression(c,p,"CapStyle",d),join:this._getValueOrOverrideExpression(c,p,"JoinStyle",h),miterLimit:f&&this._getValueOrOverrideExpression(c,p,"MiterLimit",f),referenceWidth:i,isOutline:r,gradientMethod:this._getValueOrOverrideExpression(c,p,"GradientMethod",o??m.gradientMethod),gradientType:this._getValueOrOverrideExpression(c,p,"GradientType",l??m.gradientType),interval:this._getValueOrOverrideExpression(c,p,"Interval",E(n,"CIMFixedColorRamp"===u.type?u.colors.length:m.interval)),gradientSize:this._getValueOrOverrideExpression(c,p,"GradientSize",E(a,m.gradientSize)),gradientSizeUnits:"Absolute"===s?1:"Relative"===s?0:m.gradientSizeUnits})}_analyzeMarker(e,t,r,i,o,a,s,l,y,d=!1,h=!1){d||=!!e.colorLocked;let f=y;if(f=p(e,f),f=c(this._poMap,e,f),f=m(e,f),f=n(this._poMap,e,f),this._analyzeMarkerInsidePolygon(e,t,d,f))return;const u=E(e.size,O.CIMVectorMarker.size),v=E(e.rotation),g=E(e.offsetX),_=E(e.offsetY),{primitiveName:S,type:M}=e,k=this._getValueOrOverrideExpression(M,S,"Size",u),C=this._getValueOrOverrideExpression(M,S,"Rotation",v),b=this._getValueOrOverrideExpression(M,S,"OffsetX",g),x=this._getValueOrOverrideExpression(M,S,"OffsetY",_);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,r,i,o,a,k,C,b,x,l,f,d,h);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,r,i,o,a,k,C,b,x,l,f,s,d,h)}}_analyzeMarkerInsidePolygon(e,t,r,i){const{markerPlacement:o,type:s}=e;if(!o||"CIMMarkerPlacementInsidePolygon"!==o.type||i.hasMotionAnimations)return!1;if("CIMVectorMarker"===s||"CIMPictureMarker"===s){const r=e.primitiveName;if(r&&this._analyzePrimitiveOverrides([r],t,null,null))return!1;const i=o.primitiveName;if(i&&this._analyzePrimitiveOverrides([i],t,null,null))return!1;if("CIMVectorMarker"===s){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const l=Math.abs(o.stepX),n=Math.abs(o.stepY);if(0===l||0===n)return!0;let p,c;if("Random"===o.gridType){const e=a(H),t=Math.max(Math.floor(e/l),1);p=n*Math.max(Math.floor(e/n),1);c=t*l/p}else o.shiftOddRows?(p=2*n,c=l/n*.5):(p=n,c=l/n);const m=I(e),y="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:y,colorLocked:r,effects:t,color:m,height:p,scaleX:c,angle:o.gridAngle,offsetX:E(o.offsetX),offsetY:E(o.offsetY),applyRandomOffset:"Random"===o.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0,animationParams:oe(i)}),!0}_analyzePictureMarker(e,t,i,o,a,l,n,p,c,m,y,d,h,f){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let g=E(e.scaleX,1);const _=I(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),M=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height);g/=r*(E(e.size)/t)}const k=[...o];let C;e.primitiveName&&k.push(e.primitiveName),u||S?C={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(C=r(e),C.markerPlacement=null);const b={type:"sprite-rasterization-param",resource:C,overrides:this._getMaterialOverrides(k,O)};S&&b.overrides.push(...S.overrides);const x=n;this._cimLayers.push({type:"marker",spriteRasterizationParam:b,colorLocked:h,effects:t,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",g),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(O,v,"TintColor",_),anchorPoint:{x:M.x,y:M.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:f,markerPlacement:i,animationParams:oe(d),baseSize:x})}_analyzeVectorMarker(e,t,r,i,o,a,s,l,p,c,m,f,u,v,O){const g=e.markerGraphics;if(!g)return;const _=e.frame;let S=0;S=_?_.ymax-_.ymin:a;const M=!!e.scaleSymbolsProportionally;if(S){const t={offsetX:p,offsetY:c,rotation:l,size:s,frameHeight:S,rotateClockWise:!!e.rotateClockwise,absoluteAnchorPoint:!1,scaleSymbolsProportionally:M};m=[...m,t]}r||(r=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const k of g)if(k){const s=k.symbol;if(!s)continue;const l=k.primitiveName;l&&i.push(l);let p,c=f;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let t=0,r=0;const i=k.geometry;"x"in i&&"y"in i&&(t+=i.x-.5*(_.xmin+_.xmax),r+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;let a=!1;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,r-=o.y,a=!0):_&&(t-=(_.xmax-_.xmin)*o.x,r-=(_.ymax-_.ymin)*o.y));const s={offsetX:t,offsetY:r,rotation:0,size:0,frameHeight:0,rotateClockWise:!1,absoluteAnchorPoint:a,scaleSymbolsProportionally:M};p=[...m,s]}const g=k.geometry,[C,b]=y(g,_);switch(0===C&&0===b||(c=d(c,C,b)),"CIMPointSymbol"===s.type&&(c=n(this._poMap,s,c)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":u||ee(s)?(c={...c,transform:{type:"AnimatedTransform",relativeTranslation:!1,absoluteScale:!0,translation:h([0,0]),rotation:h(0),scale:h(S),parent:f.transform}},this._analyzeMultiLayerGraphicNonSDF(e,t,r,k,i,o,a,p??m,c,S,v,O)):this._analyzeMultiLayerGraphic(e,t,r,k,i,o,a,p??m,c,S,v,O);break;case"CIMTextSymbol":this._analyzeTextGraphic(t,r,k,i,o,a,p??m,v)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,t,r,i,o,a,s,l,n,p,c,m){const y=i.symbol.symbolLayers;y&&(!$(y)||f(n)?te(y)?this._analyzeMultiLayerGraphicNonSDF(e,t,r,i,o,a,s,l,n,p,!!c,m):this._analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,n,p,c,m):this._analyzeCompositeMarkerGraphic(e,t,r,i,y,a,s,l,p,c,m))}_analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,p,c,m,y){const d=i.symbol,h=d.symbolLayers;if(!h)return;const f=D.applyEffects(d.effects,i.geometry);if(!f)return;let u=h.length;for(;u--;){const d=h[u];if(!d||!1===d.enable)continue;const v=d.primitiveName;switch(v&&o.push(v),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=D.applyEffects(d.effects,f),h=S(o);if(!h)continue;const u="Relative"!==e.anchorPointUnits,g=R(d)??0,{frameSizeRatio:_,anchorX:C,anchorY:x,widthRatio:P,sdfPaddingRatio:z}=M(h,e.frame,e.size,e.anchorPoint,u,g,e.scaleSymbolsProportionally),I="CIMSolidFill"===d.type,L={type:"sdf",geom:o,sdfPaddingRatio:z,asFill:I},{path:V}=d,N=I?b(w(d)):null==V?b(A(d)):[0,0,0,0],G=I?[0,0,0,0]:b(A(d));if(!I&&!g)break;const T=i.primitiveName;let F=null;I&&!d.colorLocked&&(F=this._maybeGetValueOrOverrideExpression(T,"FillColor"));let X=null;I||d.colorLocked||(X=this._maybeGetValueOrOverrideExpression(T,"StrokeColor"));const j=F??this._getValueOrOverrideExpression(d.type,v,"Color",N),Y=X??this._getValueOrOverrideExpression(d.type,v,"Color",G),W=this._maybeGetValueOrOverrideExpression(T,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,v,"Width",g),U=V?{type:"sprite-rasterization-param",resource:{type:"path",path:V,asFill:I},overrides:[]}:{type:"sprite-rasterization-param",resource:L,overrides:[]},H=n(this._poMap,d,p),J=E(e.size,O.CIMVectorMarker.size),B=this._getValueOrOverrideExpression(e.type,e.primitiveName,"Size",J);this._cimLayers.push({type:"marker",spriteRasterizationParam:U,colorLocked:!!d.colorLocked||!!m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:C,y:x},isAbsoluteAnchorPoint:u,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:P,rotateClockwise:!1,referenceSize:s,sizeRatio:_,color:j,outlineColor:Y,outlineWidth:W,isOutline:y,markerPlacement:r,animationParams:oe(H),isStroke:"CIMSolidFill"!==d.type,baseSize:B,...k(o,z)});break}case"CIMPictureMarker":case"CIMVectorMarker":if(d.markerPlacement){J().error("Error analyzing CIM, got unexpected marker placement");break}this._analyzeMarker(d,t,r,o,a,s,!1,l,p,m,y)}v&&o.pop()}}_analyzeTextGraphic(e,r,i,o,a,s,l,n){const p=[];_.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,y=G(m),d=T(m.fontStyleName),h=t(m.fontFamilyName);m.font={family:h,decoration:y,...d};const f=E(m.height,O.CIMTextSymbol.height),u=E(m.angle),v=E(m.offsetX),g=E(m.offsetY),{haloSymbol:S}=m,M=E(m.haloSize,0);let k=[0,0,0,0];if(S?.symbolLayers?.length){const e=S.symbolLayers;for(const t of e)if(t.color){k=this._getValueOrOverrideExpression(m?.haloSymbol?.type??"CIMPolygonSymbol",t.primitiveName,"Color",b(t.color));break}}const C=i.primitiveName;let x=[0,0,0,1],P=[0,0,0,0],z=0,I=!1;if(m.symbol?.symbolLayers)for(const t of m.symbol.symbolLayers){const e=t.primitiveName;if("CIMSolidStroke"===t.type)P=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Color",b(t.color)),z=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Width",R(t)??0);else if("CIMSolidFill"===t.type){const r=b(t.color);I=I??!!t.colorLocked,x=this._getValueOrOverrideExpression("CIMSolidFill",e??C,"Color",r)}}let L=null,V=null,N=null,w=null,A=null;C&&(L=this._maybeGetValueOrOverrideExpression(C,"TextSize"),V=this._maybeGetValueOrOverrideExpression(C,"TextAngle"),N=this._maybeGetValueOrOverrideExpression(C,"TextOffsetX"),w=this._maybeGetValueOrOverrideExpression(C,"TextOffsetY"),I||(A=this._maybeGetValueOrOverrideExpression(C,"FillColor")));const j=A??x;let Y=null,W=null,D=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?Y=b(e.color):"CIMSolidStroke"===e.type&&(W=b(e.color),D=E(e.width,O.CIMSolidStroke.width))}}const U=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==U)return;const{fontStyleName:H}=m,J=h+(H?"-"+H.toLowerCase():"-regular"),B=this._getMaterialOverrides(o,m.type);B.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type)),this._collectDictionaryTemplateOverrides(B,i);const q={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:B};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:q,colorLocked:!!n||!!I,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:J,decoration:y,haloSize:M,haloColor:k,weight:d.weight,style:d.style,size:L??f,angle:V??u,offsetX:N??v,offsetY:w??g,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:X(m.horizontalAlignment),verticalAlignment:F(m.verticalAlignment),text:U,color:j,outlineColor:P,outlineSize:z,backgroundColor:Y,borderLineColor:W,borderLineWidth:D,referenceSize:s,sizeRatio:1,markerPlacement:r})}_collectDictionaryTemplateOverrides(e,t){if(t.textString&&this._hasTextStringTemplates){const r=j(t.symbol);e.push({propertyName:"textString",defaultValue:"",valueExpressionInfo:{type:"dictionary-template",textCase:r,template:t.textString},primitiveName:t.primitiveName})}}_analyzeMultiLayerGraphicNonSDF(e,t,r,i,a,s,l,n,p,c,m,y){const d=K(e,i),h=e.primitiveName,f=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),v=L(f),[g,_,S]=u.getTextureAnchor(d,this._resourceManager,U),M=this._getMaterialOverrides(a,e.type);M.push(...v);const k={type:"sprite-rasterization-param",resource:{...d,avoidSDFRasterization:!0},overrides:M},C=E(e.size,O.CIMVectorMarker.size),b=this._getValueOrOverrideExpression(e.type,h,"Size",C);this._cimLayers.push({type:"marker",spriteRasterizationParam:k,colorLocked:m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:!1,size:c,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:c,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:S/o(e.size),isOutline:y,markerPlacement:r,animationParams:oe(p),baseSize:b})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const t=[];return _.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-marker-placement-param",placement:e,overrides:ie(t)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const t=[];return _.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-gif-animation-params",animation:e,overrides:ie(t)}}_analyzeCompositeMarkerGraphic(e,t,r,i,o,a,s,l,n,p,c){const m=i.geometry,y=o[0],d=o[1],h=S(m);if(!h)return;const f="Relative"!==e.anchorPointUnits,u=E(y.width,O.CIMSolidStroke.width),{frameSizeRatio:v,anchorX:g,anchorY:_,widthRatio:k,sdfPaddingRatio:C}=M(h,e.frame,e.size,e.anchorPoint,f,u,e.scaleSymbolsProportionally),{path:x}=d,P=d.primitiveName,z=y.primitiveName,I=i.primitiveName;let L=null;d.colorLocked||p||(L=this._maybeGetValueOrOverrideExpression(I,"FillColor"));const V=L??this._getValueOrOverrideExpression(d.type,P,"Color",b(d.color));let N=null;y.colorLocked||p||(N=this._maybeGetValueOrOverrideExpression(I,"StrokeColor"));const R=N??this._getValueOrOverrideExpression(y.type,z,"Color",b(y.color)),w=this._maybeGetValueOrOverrideExpression(I,"StrokeWidth")??this._getValueOrOverrideExpression(y.type,z,"Width",u),A={type:"sprite-rasterization-param",resource:x?{type:"path",path:x,asFill:!0}:{type:"sdf",geom:m,sdfPaddingRatio:C,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:A,colorLocked:p,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:f,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:k,rotateClockwise:!1,referenceSize:s,sizeRatio:v,color:V,outlineColor:R,outlineWidth:w,isOutline:c,markerPlacement:r})}_setPoMap(e,t,r){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[t]=r}_maybeGetValueOrOverrideExpression(e,t,r){return this._getValueOrOverrideExpression("",e,t,r,!1)}_getValueOrOverrideExpression(e,t,r,i,o=!0){if(o&&!Y(i)&&(i=V(e,r.toLowerCase())),null==t)return i;const a=this._poMap[t];if(null==a)return i;const s=a[r];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,t,r,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,t){if(!e)return[];const r=[];for(const i of e)r.push(...this._getPrimitiveMaterialOverrides(i,t));return r}_getPrimitiveMaterialOverrides(e,t){if(!e)return[];const r=L(this._primitiveOverrides.filter(t=>t.primitiveName===e));return r.forEach(e=>e.defaultValue=V(t,e.propertyName.toLowerCase())),r}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter(r=>r.primitiveName!==e||!t.includes(r.propertyName))}}function K(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function Q(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.slice(6),10);if(!isNaN(t))return t}return 0}function Z(e,t){if(!t||0===t.length)return e;const i=r(e);return _.applyOverrides(i,t),i}const $=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function ee(e){const t=e.symbolLayers;if(!t)return!1;const r=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)),i=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectAddControlPoints"===e.type));return!!r||!!i}function te(e){return e.some(e=>"CIMSolidFill"!==e.type&&"CIMSolidStroke"!==e.type&&("CIMVectorMarker"!==e.type&&"CIMPictureMarker"!==e.type||null!=e.markerPlacement))}function re(e,t){if(t?.some(e=>"CIMGeometricEffectRadial"===e.type)&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.type)&&2===e.length){const t=e.find(e=>"CIMSolidFill"===e.type),r=e.find(e=>"CIMSolidStroke"===e.type),i=r?.effects?.some(e=>"CIMGeometricEffectDashes"===e.type);if(null!=t&&null!=r&&!i)return!0}return!1}function ie(e){return r(e).map(e=>({...e,propertyName:W(e.propertyName)}))}function oe(e){return f(e)?{type:"animation-params",params:e}:null}export{q as CIMAnalyzer,Z as analyzeCIMResource};
5
+ import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as t}from"../../core/fontUtils.js";import"../../core/has.js";import{clone as r}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAbsoluteAnchor as p,handleMarker as c,handleRelativeAnchor as m,getFrameTranslation as y,translate as d,getStaticParam as h,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as u}from"./CIMSymbolHelper.js";import{antialiasingOutlineFillSettings as v}from"./constants.js";import{defaultCIMValues as O}from"./defaultCIMValues.js";import{fitVectorMarker as g}from"./fitVectorMarker.js";import{OverrideHelper as _}from"./OverrideHelper.js";import{getExtent as S,getSDFMetrics as M,getSDFDimensions as k}from"./SDFHelper.js";import{colorToArray as C,normalizeAlpha as b,getSize as x,isCIMMarkerStrokePlacement as P,hasStrokeLayer as z,getTintColor as I,getNumericValue as E,normalizePrimitiveOverrideProps as L,getDefaultCIMValue as V,getEnum as N,getStrokeWidth as R,getFillColor as w,getStrokeColor as A,fromCIMFontDecoration as G,fromCIMFontStyle as T,fromCIMVerticalAlignment as F,fromCIMHorizontalAlignment as X,getTextCasing as j,isValidCIMValue as W,uncapitalize as Y}from"./utils.js";import{CIMEffectHelper as D}from"./effects/CIMEffectHelper.js";import{rasterizedVectorMarkerMinSize as U,randomInsidePolygonTextureSize as H}from"../../views/2d/engine/webgl/definitions.js";const J=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function B(e){const t=e.markerPlacement;return t&&t.angleToLine?1:0}class q{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._hasTextStringTemplates=!1,e&&(this._resourceManager=e)}analyzeSymbolReference(t,r,i){if(this._cimLayers=i??[],!t)return this._cimLayers;if(this._reset(),this._hasTextStringTemplates=t.hasTextStringTemplates??!1,t.primitiveOverrides){this._primitiveOverrides=t.primitiveOverrides;for(const t of this._primitiveOverrides){const r=t.valueExpressionInfo;if(r)this._setPoMap(t.primitiveName,t.propertyName,r);else if(null!=t.value){let r=t.value;t.propertyName.includes("Color")&&(e(r)&&(r=C(r)),r=b(r)),this._setPoMap(t.primitiveName,t.propertyName,r)}}}return this._analyzeSymbol(t.symbol,r),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t)}}_analyzeMultiLayerSymbol(e,t){const r=e?.symbolLayers;if(!r)return;for(let l=0;l<r.length;l++){const e=r[l];"CIMVectorMarker"===e.type&&(r[l]=g(e))}const i=e.effects;let o=0;const a=x(e)??0;if("CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=1),re(r,i))return this._analyzeCompositeOutlineFill(r,i,a);let s={transform:[0,0,0,1],fromColor:[1,1,1,1],toColor:[1,1,1,1],colorMix:[0,0,0,0],toOpacity:[1,1,1,1],opacityMix:[0,0,0,0],shift:[1,1,1,1],hasAnimations:l(e),hasShiftAnimation:!1,hasMotionAnimations:!1};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=r.length;for(;c--;){const l=r[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let y=null;if(n){y=[];for(const e of n){const t=_.findEffectOverrides(e,this._primitiveOverrides);t&&y.push(t)}}const d=[];switch(_.findApplicableOverrides(l,this._primitiveOverrides,d),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,y,s,z(r));break;case"CIMPictureFill":this._analyzePictureFill(l,y,s);break;case"CIMHatchFill":this._analyzeHatchFill(l,y);break;case"CIMGradientFill":this._analyzeGradientFill(l,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,y,p,a,s);break;case"CIMPictureStroke":this._analyzePictureStroke(l,y,p,a,s);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,y,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=B(l));const r=[],i=l.primitiveName;i&&r.push(i);const n=p&&P(l.markerPlacement);this._analyzeMarker(l,y,null,r,o,a,t,[],s,!1,n);break}default:J().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,t,r,i){const{primitiveName:o,type:a}=e,s=b(e.color),l=n(this._poMap,e,r);if(!i&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.effect.type)){const r=this._getValueOrOverrideExpression(a,o,"Color",s);return void this._cimLayers.push({type:"outlineFill",colorLocked:!!e.colorLocked,color:r,effects:t,outlineColor:r,outlineColorLocked:!!e.colorLocked,...v,outlineEffects:t})}this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(a,o,"Color",s),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1,animationParams:oe(l)})}_analyzePictureFill(e,t,r){const{primitiveName:i,type:o}=e,a=I(e),s=E(e.height,O.CIMPictureFill.height);let l=E(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height),l/=r*(s/t)}const p={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(i,o)},c=n(this._poMap,e,r);this._cimLayers.push({type:"fill",spriteRasterizationParam:p,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(o,i,"TintColor",a),height:this._getValueOrOverrideExpression(o,i,"Height",s),scaleX:this._getValueOrOverrideExpression(o,i,"ScaleX",l),angle:this._getValueOrOverrideExpression(o,i,"Rotation",E(e.rotation)),offsetX:this._getValueOrOverrideExpression(o,i,"OffsetX",E(e.offsetX)),offsetY:this._getValueOrOverrideExpression(o,i,"OffsetY",E(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1,animationParams:oe(c)})}_analyzeHatchFill(e,t){const{primitiveName:r,type:i}=e,o=this._analyzeMaterialOverrides(r,["Rotation","OffsetX","OffsetY"]),a=L(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??r;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=b(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const t=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(t){let r=null,o=null;"number"==typeof t?r=t:o=t.valueExpressionInfo;let s=a.find(e=>"strokeWidth"===e.propertyName);s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:r,defaultValue:V(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:t,color:s,height:this._getValueOrOverrideExpression(i,r,"Separation",E(e.separation,O.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,r,"Rotation",E(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,r,"OffsetX",E(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,r,"OffsetY",E(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,t){const{angle:r,gradientMethod:i,gradientSize:o,gradientSizeUnits:a,gradientType:s,interval:l,primitiveName:n,type:p}=e,c=O.CIMGradientFill,m=e.colorRamp;this._cimLayers.push({type:"gradientFill",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(n,p)},colorLocked:!1,effects:t,color:[255,255,255,1],gradientMethod:this._getValueOrOverrideExpression(p,n,"GradientMethod",i??"Linear"),angle:this._getValueOrOverrideExpression(p,n,"Angle",E(r,c.angle)),gradientType:this._getValueOrOverrideExpression(p,n,"GradientType",s??c.gradientType),interval:this._getValueOrOverrideExpression(p,n,"Interval",E(l,"CIMFixedColorRamp"===m.type?m.colors.length:c.interval)),gradientSize:this._getValueOrOverrideExpression(p,n,"GradientSize",E(o,c.gradientSize)),gradientSizeUnits:"Absolute"===a?1:"Relative"===a?0:c.gradientSizeUnits})}_analyzeCompositeOutlineFill(e,t,r){const i=e.find(e=>"CIMSolidFill"===e.type),o=e.find(e=>"CIMSolidStroke"===e.type);if(null==i||null==o)return;const a=[...t??[],...i.effects??[]].map(e=>_.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),s=[...t??[],...o.effects??[]].map(e=>_.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),l=E(o.width,O.CIMSolidStroke.width),n=N(o.capStyle,O.CIMSolidStroke.capstyle),p=N(o.joinStyle,O.CIMSolidStroke.joinstyle),c=o.miterLimit;this._cimLayers.push({type:"outlineFill",colorLocked:!!i.colorLocked,color:this._getValueOrOverrideExpression(i.type,i.primitiveName,"Color",b(i.color)),effects:a,outlineColorLocked:!!o.colorLocked,outlineColor:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Color",b(o.color)),outlineWidth:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Width",l),cap:this._getValueOrOverrideExpression(o.type,o.primitiveName,"CapStyle",n),join:this._getValueOrOverrideExpression(o.type,o.primitiveName,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(o.type,o.primitiveName,"MiterLimit",c),referenceWidth:r,outlineEffects:s})}_analyzeSolidStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=b(e.color),p=E(e.width,O.CIMSolidStroke.width),c=N(e.capStyle,O.CIMSolidStroke.capstyle),m=N(e.joinStyle,O.CIMSolidStroke.joinstyle),y=e.miterLimit;let d,h,f,u,v=[];if(this._analyzePrimitiveOverrides(a,t,null,null)&&(v=this._getPrimitiveMaterialOverrides(a,s)),t&&Array.isArray(t)&&t.length>0){const e=t[t.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(d=e.dashTemplate,h=e.scaleDash,f=e.offsetAlongLine,u=e.primitiveName,(t=[...t]).pop())}null!=u&&v.push(...this._getPrimitiveMaterialOverrides(u,s).filter(e=>"dashTemplate"===e.propertyName));const g=void 0!==d?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:d,primitiveName:u},overrides:v}:null,_=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:g,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"Color",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:Q(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(u,"DashTemplate")??d,offsetAlongLine:this._getValueOrOverrideExpression(s,u,"OffsetAlongLine",f??0),scaleDash:h,sampleAlphaOnly:!0,animationParams:oe(_)})}_analyzePictureStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=I(e),p=E(e.width,O.CIMPictureStroke.width),c=N(e.capStyle,O.CIMPictureStroke.capstyle),m=N(e.joinStyle,O.CIMPictureStroke.joinstyle),y=e.miterLimit,d={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(a,s)},h=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:d,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"TintColor",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:Q(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1,animationParams:oe(h)})}_analyzeGradientStroke(e,t,r,i){const{gradientMethod:o,gradientSize:a,gradientSizeUnits:s,gradientType:l,interval:n,primitiveName:p,type:c}=e,m=O.CIMGradientStroke,y=E(e.width,m.width),d=N(e.capStyle,m.capstyle),h=N(e.joinStyle,m.joinstyle),f=e.miterLimit,u=e.colorRamp;this._cimLayers.push({type:"gradientStroke",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(p,c)},colorLocked:!!e.colorLocked,effects:t,color:[255,255,255,1],width:this._getValueOrOverrideExpression(c,p,"Width",y),cap:this._getValueOrOverrideExpression(c,p,"CapStyle",d),join:this._getValueOrOverrideExpression(c,p,"JoinStyle",h),miterLimit:f&&this._getValueOrOverrideExpression(c,p,"MiterLimit",f),referenceWidth:i,isOutline:r,gradientMethod:this._getValueOrOverrideExpression(c,p,"GradientMethod",o??m.gradientMethod),gradientType:this._getValueOrOverrideExpression(c,p,"GradientType",l??m.gradientType),interval:this._getValueOrOverrideExpression(c,p,"Interval",E(n,"CIMFixedColorRamp"===u.type?u.colors.length:m.interval)),gradientSize:this._getValueOrOverrideExpression(c,p,"GradientSize",E(a,m.gradientSize)),gradientSizeUnits:"Absolute"===s?1:"Relative"===s?0:m.gradientSizeUnits})}_analyzeMarker(e,t,r,i,o,a,s,l,y,d=!1,h=!1){d||=!!e.colorLocked;let f=y;if(f=p(e,f),f=c(this._poMap,e,f),f=m(e,f),f=n(this._poMap,e,f),this._analyzeMarkerInsidePolygon(e,t,d,f))return;const u=E(e.size,O.CIMVectorMarker.size),v=E(e.rotation),g=E(e.offsetX),_=E(e.offsetY),{primitiveName:S,type:M}=e,k=this._getValueOrOverrideExpression(M,S,"Size",u),C=this._getValueOrOverrideExpression(M,S,"Rotation",v),b=this._getValueOrOverrideExpression(M,S,"OffsetX",g),x=this._getValueOrOverrideExpression(M,S,"OffsetY",_);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,r,i,o,a,k,C,b,x,l,f,d,h);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,r,i,o,a,k,C,b,x,l,f,s,d,h)}}_analyzeMarkerInsidePolygon(e,t,r,i){const{markerPlacement:o,type:s}=e;if(!o||"CIMMarkerPlacementInsidePolygon"!==o.type||i.hasMotionAnimations)return!1;if("CIMVectorMarker"===s||"CIMPictureMarker"===s){const r=e.primitiveName;if(r&&this._analyzePrimitiveOverrides([r],t,null,null))return!1;const i=o.primitiveName;if(i&&this._analyzePrimitiveOverrides([i],t,null,null))return!1;if("CIMVectorMarker"===s){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const l=Math.abs(o.stepX),n=Math.abs(o.stepY);if(0===l||0===n)return!0;let p,c;if("Random"===o.gridType){const e=a(H),t=Math.max(Math.floor(e/l),1);p=n*Math.max(Math.floor(e/n),1);c=t*l/p}else o.shiftOddRows?(p=2*n,c=l/n*.5):(p=n,c=l/n);const m=I(e),y="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:y,colorLocked:r,effects:t,color:m,height:p,scaleX:c,angle:o.gridAngle,offsetX:E(o.offsetX),offsetY:E(o.offsetY),applyRandomOffset:"Random"===o.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0,animationParams:oe(i)}),!0}_analyzePictureMarker(e,t,i,o,a,l,n,p,c,m,y,d,h,f){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let g=E(e.scaleX,1);const _=I(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),M=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height);g/=r*(E(e.size)/t)}const k=[...o];let C;e.primitiveName&&k.push(e.primitiveName),u||S?C={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(C=r(e),C.markerPlacement=null);const b={type:"sprite-rasterization-param",resource:C,overrides:this._getMaterialOverrides(k,O)};S&&b.overrides.push(...S.overrides);const x=n;this._cimLayers.push({type:"marker",spriteRasterizationParam:b,colorLocked:h,effects:t,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",g),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(O,v,"TintColor",_),anchorPoint:{x:M.x,y:M.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:f,markerPlacement:i,animationParams:oe(d),baseSize:x})}_analyzeVectorMarker(e,t,r,i,o,a,s,l,p,c,m,f,u,v,O){const g=e.markerGraphics;if(!g)return;const _=e.frame;let S=0;S=_?_.ymax-_.ymin:a;const M=!!e.scaleSymbolsProportionally;if(S){const t={offsetX:p,offsetY:c,rotation:l,size:s,frameHeight:S,rotateClockWise:!!e.rotateClockwise,absoluteAnchorPoint:!1,scaleSymbolsProportionally:M};m=[...m,t]}r||(r=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const k of g)if(k){const s=k.symbol;if(!s)continue;const l=k.primitiveName;l&&i.push(l);let p,c=f;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let t=0,r=0;const i=k.geometry;"x"in i&&"y"in i&&(t+=i.x-.5*(_.xmin+_.xmax),r+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;let a=!1;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,r-=o.y,a=!0):_&&(t-=(_.xmax-_.xmin)*o.x,r-=(_.ymax-_.ymin)*o.y));const s={offsetX:t,offsetY:r,rotation:0,size:0,frameHeight:0,rotateClockWise:!1,absoluteAnchorPoint:a,scaleSymbolsProportionally:M};p=[...m,s]}const g=k.geometry,[C,b]=y(g,_);switch(0===C&&0===b||(c=d(c,C,b)),"CIMPointSymbol"===s.type&&(c=n(this._poMap,s,c)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":u||ee(s)?(c={...c,transform:{type:"AnimatedTransform",relativeTranslation:!1,absoluteScale:!0,translation:h([0,0]),rotation:h(0),scale:h(S),parent:f.transform}},this._analyzeMultiLayerGraphicNonSDF(e,t,r,k,i,o,a,p??m,c,S,v,O)):this._analyzeMultiLayerGraphic(e,t,r,k,i,o,a,p??m,c,S,v,O);break;case"CIMTextSymbol":this._analyzeTextGraphic(t,r,k,i,o,a,p??m,v)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,t,r,i,o,a,s,l,n,p,c,m){const y=i.symbol.symbolLayers;y&&(!$(y)||f(n)?te(y)?this._analyzeMultiLayerGraphicNonSDF(e,t,r,i,o,a,s,l,n,p,!!c,m):this._analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,n,p,c,m):this._analyzeCompositeMarkerGraphic(e,t,r,i,y,a,s,l,p,c,m))}_analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,p,c,m,y){const d=i.symbol,h=d.symbolLayers;if(!h)return;const f=D.applyEffects(d.effects,i.geometry);if(!f)return;let u=h.length;for(;u--;){const d=h[u];if(!d||!1===d.enable)continue;const v=d.primitiveName;switch(v&&o.push(v),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=D.applyEffects(d.effects,f),h=S(o);if(!h)continue;const u="Relative"!==e.anchorPointUnits,g=R(d)??0,{frameSizeRatio:_,anchorX:C,anchorY:x,widthRatio:P,sdfPaddingRatio:z}=M(h,e.frame,e.size,e.anchorPoint,u,g,e.scaleSymbolsProportionally),I="CIMSolidFill"===d.type,L={type:"sdf",geom:o,sdfPaddingRatio:z,asFill:I},{path:V}=d,N=I?b(w(d)):null==V?b(A(d)):[0,0,0,0],G=I?[0,0,0,0]:b(A(d));if(!I&&!g)break;const T=i.primitiveName;let F=null;I&&!d.colorLocked&&(F=this._maybeGetValueOrOverrideExpression(T,"FillColor"));let X=null;I||d.colorLocked||(X=this._maybeGetValueOrOverrideExpression(T,"StrokeColor"));const j=F??this._getValueOrOverrideExpression(d.type,v,"Color",N),W=X??this._getValueOrOverrideExpression(d.type,v,"Color",G),Y=this._maybeGetValueOrOverrideExpression(T,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,v,"Width",g),U=V?{type:"sprite-rasterization-param",resource:{type:"path",path:V,asFill:I},overrides:[]}:{type:"sprite-rasterization-param",resource:L,overrides:[]},H=n(this._poMap,d,p),J=E(e.size,O.CIMVectorMarker.size),B=this._getValueOrOverrideExpression(e.type,e.primitiveName,"Size",J);this._cimLayers.push({type:"marker",spriteRasterizationParam:U,colorLocked:!!d.colorLocked||!!m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:C,y:x},isAbsoluteAnchorPoint:u,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:P,rotateClockwise:!1,referenceSize:s,sizeRatio:_,color:j,outlineColor:W,outlineWidth:Y,isOutline:y,markerPlacement:r,animationParams:oe(H),isStroke:"CIMSolidFill"!==d.type,baseSize:B,...k(o,z)});break}case"CIMPictureMarker":case"CIMVectorMarker":if(d.markerPlacement){J().error("Error analyzing CIM, got unexpected marker placement");break}this._analyzeMarker(d,t,r,o,a,s,!1,l,p,m,y)}v&&o.pop()}}_analyzeTextGraphic(e,r,i,o,a,s,l,n){const p=[];_.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,y=G(m),d=T(m.fontStyleName),h=t(m.fontFamilyName);m.font={family:h,decoration:y,...d};const f=E(m.height,O.CIMTextSymbol.height),u=E(m.angle),v=E(m.offsetX),g=E(m.offsetY),{haloSymbol:S}=m,M=E(m.haloSize,0);let k=[0,0,0,0];if(S?.symbolLayers?.length){const e=S.symbolLayers;for(const t of e)if(t.color){k=this._getValueOrOverrideExpression(m?.haloSymbol?.type??"CIMPolygonSymbol",t.primitiveName,"Color",b(t.color));break}}const C=i.primitiveName;let x=[0,0,0,1],P=[0,0,0,0],z=0,I=!1;if(m.symbol?.symbolLayers)for(const t of m.symbol.symbolLayers){const e=t.primitiveName;if("CIMSolidStroke"===t.type)P=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Color",b(t.color)),z=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Width",R(t)??0);else if("CIMSolidFill"===t.type){const r=b(t.color);I=I??!!t.colorLocked,x=this._getValueOrOverrideExpression("CIMSolidFill",e??C,"Color",r)}}let L=null,V=null,N=null,w=null,A=null;C&&(L=this._maybeGetValueOrOverrideExpression(C,"TextSize"),V=this._maybeGetValueOrOverrideExpression(C,"TextAngle"),N=this._maybeGetValueOrOverrideExpression(C,"TextOffsetX"),w=this._maybeGetValueOrOverrideExpression(C,"TextOffsetY"),I||(A=this._maybeGetValueOrOverrideExpression(C,"FillColor")));const j=A??x;let W=null,Y=null,D=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?W=b(e.color):"CIMSolidStroke"===e.type&&(Y=b(e.color),D=E(e.width,O.CIMSolidStroke.width))}}const U=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==U)return;const{fontStyleName:H}=m,J=h+(H?"-"+H.toLowerCase():"-regular"),B=this._getMaterialOverrides(o,m.type);B.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type)),this._collectDictionaryTemplateOverrides(B,i);const q={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:B};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:q,colorLocked:!!n||!!I,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:J,decoration:y,haloSize:M,haloColor:k,weight:d.weight,style:d.style,size:L??f,angle:V??u,offsetX:N??v,offsetY:w??g,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:X(m.horizontalAlignment),verticalAlignment:F(m.verticalAlignment),text:U,color:j,outlineColor:P,outlineSize:z,backgroundColor:W,borderLineColor:Y,borderLineWidth:D,referenceSize:s,sizeRatio:1,markerPlacement:r})}_collectDictionaryTemplateOverrides(e,t){if(t.textString&&this._hasTextStringTemplates){const r=j(t.symbol);e.push({propertyName:"textString",defaultValue:"",valueExpressionInfo:{type:"dictionary-template",textCase:r,template:t.textString},primitiveName:t.primitiveName})}}_analyzeMultiLayerGraphicNonSDF(e,t,r,i,a,s,l,n,p,c,m,y){const d=K(e,i),h=e.primitiveName,f=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),v=L(f),[g,_,S]=u.getTextureAnchor(d,this._resourceManager,U),M=this._getMaterialOverrides(a,e.type);M.push(...v);const k={type:"sprite-rasterization-param",resource:{...d,avoidSDFRasterization:!0},overrides:M},C=E(e.size,O.CIMVectorMarker.size),b=this._getValueOrOverrideExpression(e.type,h,"Size",C);this._cimLayers.push({type:"marker",spriteRasterizationParam:k,colorLocked:m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:!1,size:c,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:c,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:S/o(e.size),isOutline:y,markerPlacement:r,animationParams:oe(p),baseSize:b})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const t=[];return _.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-marker-placement-param",placement:e,overrides:ie(t)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const t=[];return _.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-gif-animation-params",animation:e,overrides:ie(t)}}_analyzeCompositeMarkerGraphic(e,t,r,i,o,a,s,l,n,p,c){const m=i.geometry,y=o[0],d=o[1],h=S(m);if(!h)return;const f="Relative"!==e.anchorPointUnits,u=E(y.width,O.CIMSolidStroke.width),{frameSizeRatio:v,anchorX:g,anchorY:_,widthRatio:k,sdfPaddingRatio:C}=M(h,e.frame,e.size,e.anchorPoint,f,u,e.scaleSymbolsProportionally),{path:x}=d,P=d.primitiveName,z=y.primitiveName,I=i.primitiveName;let L=null;d.colorLocked||p||(L=this._maybeGetValueOrOverrideExpression(I,"FillColor"));const V=L??this._getValueOrOverrideExpression(d.type,P,"Color",b(d.color));let N=null;y.colorLocked||p||(N=this._maybeGetValueOrOverrideExpression(I,"StrokeColor"));const R=N??this._getValueOrOverrideExpression(y.type,z,"Color",b(y.color)),w=this._maybeGetValueOrOverrideExpression(I,"StrokeWidth")??this._getValueOrOverrideExpression(y.type,z,"Width",u),A={type:"sprite-rasterization-param",resource:x?{type:"path",path:x,asFill:!0}:{type:"sdf",geom:m,sdfPaddingRatio:C,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:A,colorLocked:p,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:f,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:k,rotateClockwise:!1,referenceSize:s,sizeRatio:v,color:V,outlineColor:R,outlineWidth:w,isOutline:c,markerPlacement:r})}_setPoMap(e,t,r){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[t]=r}_maybeGetValueOrOverrideExpression(e,t,r){return this._getValueOrOverrideExpression("",e,t,r,!1)}_getValueOrOverrideExpression(e,t,r,i,o=!0){if(o&&!W(i)&&(i=V(e,r.toLowerCase())),null==t)return i;const a=this._poMap[t];if(null==a)return i;const s=a[r];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,t,r,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,t){if(!e)return[];const r=[];for(const i of e)r.push(...this._getPrimitiveMaterialOverrides(i,t));return r}_getPrimitiveMaterialOverrides(e,t){if(!e)return[];const r=L(this._primitiveOverrides.filter(t=>t.primitiveName===e));return r.forEach(e=>e.defaultValue=V(t,e.propertyName.toLowerCase())),r}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter(r=>r.primitiveName!==e||!t.includes(r.propertyName))}}function K(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function Q(e){if(e?.startsWith("Level_")){const t=parseInt(e.slice(6),10);if(!isNaN(t))return t}return 0}function Z(e,t){if(!t||0===t.length)return e;const i=r(e);return _.applyOverrides(i,t),i}const $=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function ee(e){const t=e.symbolLayers;if(!t)return!1;const r=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)),i=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectAddControlPoints"===e.type));return!!r||!!i}function te(e){return e.some(e=>"CIMSolidFill"!==e.type&&"CIMSolidStroke"!==e.type&&("CIMVectorMarker"!==e.type&&"CIMPictureMarker"!==e.type||null!=e.markerPlacement))}function re(e,t){if(t?.some(e=>"CIMGeometricEffectRadial"===e.type)&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.type)&&2===e.length){const t=e.find(e=>"CIMSolidFill"===e.type),r=e.find(e=>"CIMSolidStroke"===e.type),i=r?.effects?.some(e=>"CIMGeometricEffectDashes"===e.type);if(null!=t&&null!=r&&!i)return!0}return!1}function ie(e){return r(e).map(e=>({...e,propertyName:Y(e.propertyName)}))}function oe(e){return f(e)?{type:"animation-params",params:e}:null}export{q as CIMAnalyzer,Z as analyzeCIMResource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{Float as r,Int as o,Vec4 as n,Vec2 as s}from"./graph/glsl.js";import{GlslShaderWriter as i}from"./graph/GlslGraphWriter.js";import{ShaderGraphContext as p}from"./graph/ShaderGraphContext.js";import{setReachableUids as a}from"./graph/ShaderGraphNode.js";import{TypedShaderProgram as u}from"./typed/TypedShaderProgram.js";import{ShaderBuilder as c}from"../../../../webgl/ShaderBuilder.js";function y(t){return new t}function d(t,e,r){const o=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:o.slice()}),t.constructor[e].push(r)}function f(t,e){return(r,o)=>{d(r,"locations",{typeCtor:e,propertyKey:o,parameterIndex:null,index:t})}}const h=t=>(e,r)=>{d(e,"builtins",{builtin:t,propertyKey:r})},l=t=>(e,r,o)=>{d(e,"inputs",{inputCtor:t,propertyKey:r,parameterIndex:o})},m=t=>(e,r)=>{d(e,"uniforms",{typeCtor:t,propertyKey:r})},g=t=>(e,r)=>{d(e,"options",{typeCtor:t,propertyKey:r})},_=(t,e)=>{d(t,"defines",{propertyKey:e})};function K(t){return(e,r)=>{d(e,"transformFeedbackBindings",{propertyKey:r,parameterIndex:null,index:t})}}const x=(t,e)=>(r,o)=>{r.constructor.builtins.push({builtin:t,propertyKey:o,typeCtor:e})};class b{static{this.builtins=[]}}t([x("gl_VertexID",o)],b.prototype,"glVertexID",void 0);class C{}class I{static{this.builtins=[]}}t([x("gl_FragCoord",n)],I.prototype,"glFragCoord",void 0),t([x("gl_PointCoord",s)],I.prototype,"glPointCoord",void 0);class v{}t([h("gl_FragDepth")],v.prototype,"glFragDepth",void 0);class w{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class P{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=this._shaderModuleClass.inputs.findLast(t=>"vertex"===t.propertyKey&&0===t.parameterIndex);if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return this._shaderModuleClass.inputs.findLast(t=>"vertex"===t.propertyKey&&1===t.parameterIndex)}get fragmentInput(){const t=this._shaderModuleClass.inputs.findLast(t=>"fragment"===t.propertyKey);if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,r=new Set;for(const o of this.locations)r.has(o.index)?e.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${o.propertyKey} to ${o.index}. Index already in use`,{locationsMap:t}):(t.set(o.propertyKey,o.index),r.add(o.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map(([t,e])=>`${t}.${e}`).join("."),r=this.computeAttributes;this._locationInfo={stringHash:e,locations:t,computeAttributeMap:r}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,r,o){try{const{vertex:n,fragment:s,uniformBindings:i}=this._generateShaders(t,e,r,o);return new u(n,s,this.renamedLocationsMap,i,this.transformFeedbackBindings)}catch(n){return new u("","",this.renamedLocationsMap,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find(e=>e.propertyKey===t);if(e)return{type:"option",className:e.typeCtor};const r=this._uniforms.find(e=>e.propertyKey===t);if(!r)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:r.typeCtor}}getShaderKey(t,e,r,o){const n=Object.keys(t).map(e=>`${e}.${t[e]}`).join("."),s=Object.keys(r).map(t=>`${t}.${r[t]}`).join("."),i=Object.keys(o).map(t=>`${t}.${o[t]}`).join("."),p=Object.keys(e).filter(t=>this.optionPropertyKeys.has(t)&&e[t]).join(".");return`${this.type}.${n}.${s}.${i}.${p}`}_generateShaders(t,e,r,o){const n=[];this._setDefines(r),this._setOptionalUniforms(n,e),this._setRequiredUniforms(n);const s=this._hydrateVertexInput(o),u=this._injectPackPrecisionFactor(s,t),c=this._hydrateComputeInput(),y=c&&this._injectComputePackPrecisionFactor(c,t),d=this.vertex(u,y),f=this._hydrateFragmentInput(d),h=this.fragment(f),l=new Set;for(const i in h){const t=h[i];a(l,t)}const m=this._getVertexInputBuiltins(),g=p.createVertex({...s,...c},d,m,n,this.transformFeedbackBindings,l);(new i).write(g);const _=this._getFragmentInputBuiltins(h);_.set("glPointCoord","gl_PointCoord");const K=p.createFragment(f,h,_,n,g,this.transformFeedbackBindings);(new i).write(K);const x=this._createShaderBuilder(g,K),b=x.generate("vertex"),C=x.generate("fragment");return this.logShader&&(console.log(b),console.log(C)),{vertex:b,fragment:C,uniformBindings:n}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const r of this._options){e[r.propertyKey]?this[r.propertyKey]=this._hydrateUniformGroup(t,r):this[r.propertyKey]=null}}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const r=new(0,e.typeCtor);for(const o of r._uniforms??[]){const n=y(o.typeCtor),s=`u_${e.propertyKey}_${o.propertyKey}`,i=n.type,p=[e.propertyKey,o.propertyKey].join(".");if("type"in o.typeCtor&&"array"===o.typeCtor.type){const e=n;t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:n})}else if("type"in o.typeCtor&&"array-2d"===o.typeCtor.type){const e=n;t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:n})}else t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformHydrated:n});r[o.propertyKey]=n}return r}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,r=e.locations.reduce((e,r)=>!1===t[r.propertyKey]?e:{...e,[r.propertyKey]:y(r.typeCtor)},{});for(const{propertyKey:o,typeCtor:n}of e.builtins){const t=y(n);r[o]=t}return r}_hydrateComputeInput(){if(null==this.computeInput)return null;return this.computeInput.inputCtor.locations.reduce((t,e)=>({...t,[e.propertyKey]:y(e.typeCtor)}),{})}_injectPackPrecisionFactor(t,e){const o={};for(const n in t){const s=t[n],i=e[n];if(i){if("float"!==s.type&&"vec2"!==s.type&&"vec3"!==s.type&&"vec4"!==s.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${s.type}`);o[n]=s.divide(new r(i))}else o[n]=s}return o}_injectComputePackPrecisionFactor(t,e){const o={},n=new Map;for(const r in this.computeAttributes)for(const t of this.computeAttributes[r]??[])n.set(t,r);for(const s in t){const i=t[s],p=n.get(s);if(!p)continue;const a=e[p];if(a){if("float"!==i.type&&"vec2"!==i.type&&"vec3"!==i.type&&"vec4"!==i.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${i.type}`);o[s]=i.divide(new r(a))}else o[s]=i}return o}_hydrateFragmentInput(t){const e={};for(const r in t)e[r]=t[r];for(const{propertyKey:r,typeCtor:o}of I.builtins){const t=y(o);e[r]=t}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:r,propertyKey:o}of t.builtins)e.set(o,r);return e}_getFragmentInputBuiltins(t){const e=t.constructor,r=new Map;for(const o of e.builtins??[])r.set(o.propertyKey,o.builtin);return r}_createShaderBuilder(t,e){const r=new c;return this._insertDebugInfo(r),t.insertVertexShader(r),e.insertFragmentShader(r),r}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}export{C as ComputeVertexInput,I as FragmentInput,v as FragmentOutput,P as GraphShaderModule,w as UniformGroup,b as VertexInput,h as builtin,_ as define,l as input,f as location,g as option,K as transformFeedback,m as uniform};
5
+ import{__decorate as t}from"tslib";import"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{Float as r,Int as o,Vec4 as n,Vec2 as s}from"./graph/glsl.js";import{GlslShaderWriter as i}from"./graph/GlslGraphWriter.js";import{ShaderGraphContext as p}from"./graph/ShaderGraphContext.js";import{setReachableUids as a}from"./graph/ShaderGraphNode.js";import{TypedShaderProgram as u}from"./typed/TypedShaderProgram.js";import{ShaderBuilder as c}from"../../../../webgl/ShaderBuilder.js";function y(t){return new t}function d(t,e,r){const o=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:o.slice()}),t.constructor[e].push(r)}function f(t,e){return(r,o)=>{d(r,"locations",{typeCtor:e,propertyKey:o,parameterIndex:null,index:t})}}const h=t=>(e,r)=>{d(e,"builtins",{builtin:t,propertyKey:r})},l=t=>(e,r,o)=>{d(e,"inputs",{inputCtor:t,propertyKey:r,parameterIndex:o})},m=t=>(e,r)=>{d(e,"uniforms",{typeCtor:t,propertyKey:r})},g=t=>(e,r)=>{d(e,"options",{typeCtor:t,propertyKey:r})},_=(t,e)=>{d(t,"defines",{propertyKey:e})};function K(t){return(e,r)=>{d(e,"transformFeedbackBindings",{propertyKey:r,parameterIndex:null,index:t})}}const b=(t,e)=>(r,o)=>{r.constructor.builtins.push({builtin:t,propertyKey:o,typeCtor:e})};class x{static{this.builtins=[]}}t([b("gl_VertexID",o)],x.prototype,"glVertexID",void 0);class C{}class I{static{this.builtins=[]}}t([b("gl_FragCoord",n)],I.prototype,"glFragCoord",void 0),t([b("gl_PointCoord",s)],I.prototype,"glPointCoord",void 0);class v{}t([h("gl_FragDepth")],v.prototype,"glFragDepth",void 0);class w{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class P{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=this._shaderModuleClass.inputs.findLast(t=>"vertex"===t.propertyKey&&0===t.parameterIndex);if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return this._shaderModuleClass.inputs.findLast(t=>"vertex"===t.propertyKey&&1===t.parameterIndex)}get fragmentInput(){const t=this._shaderModuleClass.inputs.findLast(t=>"fragment"===t.propertyKey);if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,r=new Set;for(const o of this.locations)r.has(o.index)?e.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${o.propertyKey} to ${o.index}. Index already in use`,{locationsMap:t}):(t.set(o.propertyKey,o.index),r.add(o.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map(([t,e])=>`${t}.${e}`).join("."),r=this.computeAttributes;this._locationInfo={stringHash:e,locations:t,computeAttributeMap:r}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,r,o){try{const{vertex:n,fragment:s,uniformBindings:i}=this._generateShaders(t,e,r,o);return new u(n,s,this.renamedLocationsMap,i,this.transformFeedbackBindings)}catch(n){return new u("","",this.renamedLocationsMap,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find(e=>e.propertyKey===t);if(e)return{type:"option",className:e.typeCtor};const r=this._uniforms.find(e=>e.propertyKey===t);if(!r)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:r.typeCtor}}getShaderKey(t,e,r,o){const n=Object.keys(t).map(e=>`${e}.${t[e]}`).join("."),s=Object.keys(r).map(t=>`${t}.${r[t]}`).join("."),i=Object.keys(o).map(t=>`${t}.${o[t]}`).join("."),p=Object.keys(e).filter(t=>this.optionPropertyKeys.has(t)&&e[t]).join(".");return`${this.type}.${n}.${s}.${i}.${p}`}_generateShaders(t,e,r,o){const n=[];this._setDefines(r),this._setOptionalUniforms(n,e),this._setRequiredUniforms(n);const s=this._hydrateVertexInput(o),u=this._injectPackPrecisionFactor(s,t),c=this._hydrateComputeInput(),y=c&&this._injectComputePackPrecisionFactor(c,t),d=this.vertex(u,y),f=this._hydrateFragmentInput(d),h=this.fragment(f),l=new Set;for(const i in h){const t=h[i];a(l,t)}const m=this._getVertexInputBuiltins(),g={};for(const[i,p]of Object.entries(s))g[i]=p;if(null!=c)for(const[i,p]of Object.entries(c))g[i]=p;const _=p.createVertex(g,d,m,n,this.transformFeedbackBindings,l);(new i).write(_);const K=this._getFragmentInputBuiltins(h);K.set("glPointCoord","gl_PointCoord");const b=p.createFragment(f,h,K,n,_,this.transformFeedbackBindings);(new i).write(b);const x=this._createShaderBuilder(_,b),C=x.generate("vertex"),I=x.generate("fragment");return this.logShader&&(console.log(C),console.log(I)),{vertex:C,fragment:I,uniformBindings:n}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const r of this._options){e[r.propertyKey]?this[r.propertyKey]=this._hydrateUniformGroup(t,r):this[r.propertyKey]=null}}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const r=new(0,e.typeCtor);for(const o of r._uniforms??[]){const n=y(o.typeCtor),s=`u_${e.propertyKey}_${o.propertyKey}`,i=n.type,p=[e.propertyKey,o.propertyKey].join(".");if("type"in o.typeCtor&&"array"===o.typeCtor.type){const e=n;t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:n})}else if("type"in o.typeCtor&&"array-2d"===o.typeCtor.type){const e=n;t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:n})}else t.push({shaderModulePath:p,uniformName:s,uniformType:i,uniformHydrated:n});r[o.propertyKey]=n}return r}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,r=e.locations.reduce((e,r)=>!1===t[r.propertyKey]?e:{...e,[r.propertyKey]:y(r.typeCtor)},{});for(const{propertyKey:o,typeCtor:n}of e.builtins){const t=y(n);r[o]=t}return r}_hydrateComputeInput(){if(null==this.computeInput)return null;return this.computeInput.inputCtor.locations.reduce((t,e)=>({...t,[e.propertyKey]:y(e.typeCtor)}),{})}_injectPackPrecisionFactor(t,e){const o={};for(const n in t){const s=t[n],i=e[n];if(i){if("float"!==s.type&&"vec2"!==s.type&&"vec3"!==s.type&&"vec4"!==s.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${s.type}`);o[n]=s.divide(new r(i))}else o[n]=s}return o}_injectComputePackPrecisionFactor(t,e){const o={},n=new Map;for(const r in this.computeAttributes)for(const t of this.computeAttributes[r]??[])n.set(t,r);for(const s in t){const i=t[s],p=n.get(s);if(!p)continue;const a=e[p];if(a){if("float"!==i.type&&"vec2"!==i.type&&"vec3"!==i.type&&"vec4"!==i.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${i.type}`);o[s]=i.divide(new r(a))}else o[s]=i}return o}_hydrateFragmentInput(t){const e={};for(const r in t)e[r]=t[r];for(const{propertyKey:r,typeCtor:o}of I.builtins){const t=y(o);e[r]=t}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:r,propertyKey:o}of t.builtins)e.set(o,r);return e}_getFragmentInputBuiltins(t){const e=t.constructor,r=new Map;for(const o of e.builtins??[])r.set(o.propertyKey,o.builtin);return r}_createShaderBuilder(t,e){const r=new c;return this._insertDebugInfo(r),t.insertVertexShader(r),e.insertFragmentShader(r),r}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}export{C as ComputeVertexInput,I as FragmentInput,v as FragmentOutput,P as GraphShaderModule,w as UniformGroup,x as VertexInput,h as builtin,_ as define,l as input,f as location,g as option,K as transformFeedback,m as uniform};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{cloneShaderNode as e}from"./ShaderGraphNode.js";class t{constructor(e,t,d){this.variableName=e,this.variableInputType=t,this.node=d,this.type="shader-input",this.isUsed=!1}clone(){return new t(this.variableName,this.variableInputType,e(this.node))}}class d{constructor(e,t,d){this.outVariableName=e,this.outVariableType=t,this.node=d,this.type="shader-output"}clone(){const t=new d(this.outVariableName,this.outVariableType,e(this.node));return t.variableName=this.variableName,t}}class o{static createVertex(e,a,n,i,r,s){const u=[];for(const d in e){const o=e[d],a=n.get(d);a?u.push(new t(a,"builtin",o)):u.push(new t("a_"+d,"in",o))}for(const d of i){const e=d.uniformHydrated;u.push(new t(d.uniformName,"uniform",e))}const p=[];for(const t in a){const e=a[t];"glPosition"===t?p.push(new d("gl_Position","builtin",e)):"glPointSize"===t?p.push(new d("gl_PointSize","builtin",e)):p.push(new d("v_"+t,"out",e))}return new o(u,p,r,s)}static createFragment(e,a,n,i,r,s){const u=[],p=Array.from(r.rootOutputNodes());for(const d in e){const o=e[d],a=n.get(d);if(a){u.push(new t(a,"builtin",o));continue}const i=p.find(e=>e.node===o);i&&u.push(new t(i.outVariableName,"in",o))}for(const d of i){const e=d.uniformHydrated;u.push(new t(d.uniformName,"uniform",e))}const h=[];for(const t in a){const e=a[t],o=n.get(t);"discard"===t?h.push(new d(null,"discard",e)):o?h.push(new d(o,"builtin",e)):h.push(new d(t,"out",e))}return new o(u,h,s)}constructor(e,t,d,o){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const a of e)this._inputShaderTypesByNodeUid.set(a.node.uid,a);this._outputShaderTypes=t,this._transformFeedbackBindings=d,this._transformFeedbackNames=new Set(d.map(e=>"v_"+e.propertyKey)),this._usedInFragmentShader=o}shouldPruneOutputNode(e){return!!this._usedInFragmentShader&&("builtin"!==e.outVariableType&&(!this._transformFeedbackNames.has(e.outVariableName)&&!this._usedInFragmentShader.has(e.node.uid)))}setEmit(e,t){this._nodeEmitMap.set(e.uid,t)}getEmit(e){return this._nodeEmitMap.get(e.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(e){return this._inputShaderTypesByNodeUid.get(e.uid)}*rootOutputNodes(){for(const e of this._outputShaderTypes)yield e}*nodes(){const e=[];for(const t of this._outputShaderTypes.values())e.push(t.node);for(;e.length;){const t=e.pop();"number"!=typeof t&&"boolean"!=typeof t&&e.push(...t.children.filter(Boolean)),yield t}}*nodesOfTypeOrFunction(){for(const e of this.nodes())"number"!=typeof e&&"boolean"!=typeof e&&(yield e)}createSubgraphContext(){const e=this.clone();return e.body="",e.indent=this.indent+2,e._nodeEmitMap=new Map(this._nodeEmitMap),e}clone(){const e=new o([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return e._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,e.indent=this.indent,e.body=this.body,e.varCount=this.varCount,e._nodeEmitMap=this._nodeEmitMap,e}insertVertexShader(e){e.vertex.code.add(""),this._insertInputs(e,"vertex"),e.vertex.code.add(""),e.vertex.code.add("// OUTPUTS: "),e.vertex.code.add("// --------------------------------------------------------- ");for(const t of this.rootOutputNodes()){const d="builtin"===t.outVariableType;this.shouldPruneOutputNode(t)||(d?e.vertex.code.add(`// ${t.outVariableType.padEnd(7)} ${t.node.type.padEnd(9)} ${t.outVariableName};`):e.vertex.code.add(`${t.outVariableType.padEnd(10)} ${t.node.type.padEnd(9)} ${t.outVariableName};`))}e.vertex.code.add(""),e.vertex.code.add("void main() {"),e.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const t of this.rootOutputNodes())this.shouldPruneOutputNode(t)||e.vertex.code.add(` ${t.outVariableName} = ${t.variableName};`);e.vertex.code.add("}")}insertFragmentShader(e){this._insertInputs(e,"fragment"),e.fragment.code.add(""),e.fragment.code.add("// OUTPUTS: "),e.fragment.code.add("// --------------------------------------------------------- ");let t=0;for(const d of this.rootOutputNodes()){"builtin"===d.outVariableType?e.fragment.code.add(`// ${d.outVariableType.padEnd(7)} ${d.node.type.padEnd(9)} ${d.outVariableName};`):e.outputs.add(d.outVariableName,d.node.type,t++)}e.fragment.code.add(""),e.fragment.code.add("void main() {"),e.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const d of this.rootOutputNodes())"discard"===d.outVariableType?(e.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),e.fragment.code.add(` if (${d.variableName}) {`),e.fragment.code.add(" discard;"),e.fragment.code.add(" }"),e.fragment.code.add(" ")):e.fragment.code.add(` ${d.outVariableName} = ${d.variableName};`);e.fragment.code.add("}")}_insertInputs(e,t){e[t].code.add("// INPUTS: "),e[t].code.add("// --------------------------------------------------------- ");for(const d of this.inputs())d.isUsed&&"builtin"!==d.variableInputType&&("array"===d.node.type?e[t].code.add(`${d.variableInputType.padEnd(10)} ${d.node.elementType.type.padEnd(9)} ${d.variableName}[${d.node.size}];`):"array-2d"===d.node.type?e[t].code.add(`${d.variableInputType.padEnd(10)} ${d.node.elementType.type.padEnd(9)} ${d.variableName}[${d.node.size}]; // Emulated 2D Array. Not supported by ES3.0`):e[t].code.add(`${d.variableInputType.padEnd(10)} ${d.node.type.padEnd(9)} ${d.variableName};`))}}export{o as ShaderGraphContext,t as ShaderInput,d as ShaderOutput};
5
+ import{cloneShaderNode as e}from"./ShaderGraphNode.js";class t{constructor(e,t,a,n=[]){this.variableName=e,this.variableInputType=t,this.node=a,this.qualifiers=n,this.type="shader-input",this.isUsed=!1}clone(){return new t(this.variableName,this.variableInputType,e(this.node),[...this.qualifiers])}}class a{constructor(e,t,a,n=[]){this.outVariableName=e,this.outVariableType=t,this.node=a,this.qualifiers=n,this.type="shader-output"}clone(){const t=new a(this.outVariableName,this.outVariableType,e(this.node),[...this.qualifiers]);return t.variableName=this.variableName,t}}class n{static createVertex(e,d,s,i,r,u){const p=[];for(const a in e){const n=e[a],o=s.get(a);o?p.push(new t(o,"builtin",n)):p.push(new t("a_"+a,"in",n))}for(const a of i){const e=a.uniformHydrated;p.push(new t(a.uniformName,"uniform",e))}const c=[];for(const t in d){const e=d[t];if("glPosition"===t)c.push(new a("gl_Position","builtin",e));else if("glPointSize"===t)c.push(new a("gl_PointSize","builtin",e));else{const n=o(e),d=[];n&&d.push(n),c.push(new a("v_"+t,"out",e,d))}}return new n(p,c,r,u)}static createFragment(e,o,d,s,i,r){const u=[],p=Array.from(i.rootOutputNodes());for(const a in e){const n=e[a],o=d.get(a);if(o){u.push(new t(o,"builtin",n));continue}const s=p.find(e=>e.node===n);s&&u.push(new t(s.outVariableName,"in",n))}for(const a of s){const e=a.uniformHydrated;u.push(new t(a.uniformName,"uniform",e))}const c=[];for(const t in o){const e=o[t],n=d.get(t);switch(t){case"discard":c.push(new a(null,"discard",e));break;case"fragData0":c.push(new a("fragData0","fragData0",e));break;case"fragData1":c.push(new a("fragData1","fragData1",e));break;case"fragData2":c.push(new a("fragData2","fragData2",e));break;case"fragData3":c.push(new a("fragData3","fragData3",e));break;default:n?c.push(new a(n,"builtin",e)):c.push(new a(t,"out",e))}}return new n(u,c,r)}constructor(e,t,a,n){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const o of e)this._inputShaderTypesByNodeUid.set(o.node.uid,o);this._outputShaderTypes=t,this._transformFeedbackBindings=a,this._transformFeedbackNames=new Set(a.map(e=>"v_"+e.propertyKey)),this._usedInFragmentShader=n}shouldPruneOutputNode(e){return!!this._usedInFragmentShader&&("builtin"!==e.outVariableType&&(!this._transformFeedbackNames.has(e.outVariableName)&&!this._usedInFragmentShader.has(e.node.uid)))}setEmit(e,t){this._nodeEmitMap.set(e.uid,t)}getEmit(e){return this._nodeEmitMap.get(e.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(e){return this._inputShaderTypesByNodeUid.get(e.uid)}*rootOutputNodes(){for(const e of this._outputShaderTypes)yield e}*nodes(){const e=[];for(const t of this._outputShaderTypes.values())e.push(t.node);for(;e.length;){const t=e.pop();"number"!=typeof t&&"boolean"!=typeof t&&e.push(...t.children.filter(Boolean)),yield t}}*nodesOfTypeOrFunction(){for(const e of this.nodes())"number"!=typeof e&&"boolean"!=typeof e&&(yield e)}createSubgraphContext(){const e=this.clone();return e.body="",e.indent=this.indent+2,e._nodeEmitMap=new Map(this._nodeEmitMap),e}clone(){const e=new n([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return e._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,e.indent=this.indent,e.body=this.body,e.varCount=this.varCount,e._nodeEmitMap=this._nodeEmitMap,e}insertVertexShader(e){e.vertex.code.add(""),this._insertInputs(e,"vertex"),e.vertex.code.add(""),e.vertex.code.add("// OUTPUTS: "),e.vertex.code.add("// --------------------------------------------------------- ");for(const t of this.rootOutputNodes()){const a="builtin"===t.outVariableType;if(!this.shouldPruneOutputNode(t))if(a)e.vertex.code.add(`// ${t.outVariableType.padEnd(7)} ${t.node.type.padEnd(9)} ${t.outVariableName};`);else{const a=[...t.qualifiers,t.outVariableType].join(" ");e.vertex.code.add(`${a.padEnd(10)} ${t.node.type.padEnd(9)} ${t.outVariableName};`)}}e.vertex.code.add(""),e.vertex.code.add("void main() {"),e.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const t of this.rootOutputNodes())this.shouldPruneOutputNode(t)||e.vertex.code.add(` ${t.outVariableName} = ${t.variableName};`);e.vertex.code.add("}")}insertFragmentShader(e){this._insertInputs(e,"fragment"),e.fragment.code.add(""),e.fragment.code.add("// OUTPUTS: "),e.fragment.code.add("// --------------------------------------------------------- ");let t=0;for(const a of this.rootOutputNodes()){"builtin"===a.outVariableType?e.fragment.code.add(`// ${a.outVariableType.padEnd(7)} ${a.node.type.padEnd(9)} ${a.outVariableName};`):e.outputs.add(a.outVariableName,a.node.type,t++)}e.fragment.code.add(""),e.fragment.code.add("void main() {"),e.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const a of this.rootOutputNodes())"discard"===a.outVariableType?(e.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),e.fragment.code.add(` if (${a.variableName}) {`),e.fragment.code.add(" discard;"),e.fragment.code.add(" }"),e.fragment.code.add(" ")):e.fragment.code.add(` ${a.outVariableName} = ${a.variableName};`);e.fragment.code.add("}")}_insertInputs(e,t){e[t].code.add("// INPUTS: "),e[t].code.add("// --------------------------------------------------------- ");for(const a of this.inputs())if(a.isUsed&&"builtin"!==a.variableInputType)if("array"===a.node.type)e[t].code.add(`${a.variableInputType.padEnd(10)} ${a.node.elementType.type.padEnd(9)} ${a.variableName}[${a.node.size}];`);else if("array-2d"===a.node.type)e[t].code.add(`${a.variableInputType.padEnd(10)} ${a.node.elementType.type.padEnd(9)} ${a.variableName}[${a.node.size}]; // Emulated 2D Array. Not supported by ES3.0`);else{const n=[...a.qualifiers,a.variableInputType].join(" ");e[t].code.add(` ${n.padEnd(10)} ${a.node.type.padEnd(9)} ${a.variableName};`)}}}function o(e){switch(e.type){case"float":case"vec2":case"vec3":case"vec4":return null;case"int":case"ivec2":case"ivec3":case"ivec4":case"uint":case"uvec2":case"uvec3":case"uvec4":case"bool":case"bvec2":case"bvec3":case"bvec4":return"flat";case"mat2":case"mat3":case"mat4":case"array":case"sampler2D":case"array-2d":throw new Error(`InternalError: ${e.type} is not a valid output type`)}}export{n as ShaderGraphContext,t as ShaderInput,a as ShaderOutput};