@arcgis/core 5.1.0-next.81 → 5.1.0-next.83

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 (171) hide show
  1. package/analysis/ShadowCast/DiscreteOptions.d.ts +12 -0
  2. package/analysis/ShadowCast/TotalDurationOptions.d.ts +12 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/040884cec4b84dd1bb17.js +1 -0
  5. package/assets/esri/core/workers/chunks/05c5f68e117fc58ae801.js +1 -0
  6. package/assets/esri/core/workers/chunks/074f5e6aaeafca13bf72.js +1 -0
  7. package/assets/esri/core/workers/chunks/{7bd1d624f4f4a11a31e8.js → 086d7cdfa92a649c9f7b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{0eed2b1b06355ab89013.js → 0c074c46d106ca4d3bad.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{c758e16b57c96ce88294.js → 1768f1a7e3caa6074d91.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{85d3475667c503ec4fc6.js → 186bfde8c552e3b42302.js} +1 -1
  11. package/assets/esri/core/workers/chunks/1a35121a0c2595a41fdb.js +1 -0
  12. package/assets/esri/core/workers/chunks/1ab66600579fa4232d7b.js +1 -0
  13. package/assets/esri/core/workers/chunks/1e3fe89970c57a883fe5.js +1 -0
  14. package/assets/esri/core/workers/chunks/{824051af00e7a1f05ed0.js → 230e0e43f8e771950397.js} +1 -1
  15. package/assets/esri/core/workers/chunks/26f804c92077c11c626d.js +1 -0
  16. package/assets/esri/core/workers/chunks/28a45bd26eb5c9b3ec7c.js +1 -0
  17. package/assets/esri/core/workers/chunks/38f1a86b8dd9ee684ee5.js +596 -0
  18. package/assets/esri/core/workers/chunks/{71fe127734f33d020a44.js → 475394218caaa4cd3e86.js} +1 -1
  19. package/assets/esri/core/workers/chunks/475409026288f0981ce2.js +1 -0
  20. package/assets/esri/core/workers/chunks/4e206957b28253ddc1a3.js +1 -0
  21. package/assets/esri/core/workers/chunks/5cc38ac051d3d0557920.js +1 -0
  22. package/assets/esri/core/workers/chunks/{992cd87ba0ab6346f692.js → 64e268ebac0b62076f81.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{003fd7745966fe03510c.js → 65ac73de5bb133c6bf89.js} +1 -1
  24. package/assets/esri/core/workers/chunks/6675d56f49d07a97dc40.js +1 -0
  25. package/assets/esri/core/workers/chunks/{484d6c1b0fe1633515b7.js → 72f8f4cfa0842d325fb0.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{283d39dfb1625b5a74db.js → 747e258f57f0543c836e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{dd4f431511edd975a53b.js → 7acf82763aeba44049d0.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{5d8e944b192aad4cf986.js → 7b505112c7e6d9b7a239.js} +1 -1
  29. package/assets/esri/core/workers/chunks/7b8466f892a38a53c600.js +1 -0
  30. package/assets/esri/core/workers/chunks/{77dd719516138afb1a2a.js → 8af9a78cf316581ea482.js} +1 -1
  31. package/assets/esri/core/workers/chunks/988e91cc6cf88c34c2de.js +1 -0
  32. package/assets/esri/core/workers/chunks/9c402657f63a4d5668d0.js +1 -0
  33. package/assets/esri/core/workers/chunks/9ea23cd4b2664c08b670.js +1 -0
  34. package/assets/esri/core/workers/chunks/9f51a69b8f1937a8794a.js +1 -0
  35. package/assets/esri/core/workers/chunks/a28124bba6b43efd74cc.js +1 -0
  36. package/assets/esri/core/workers/chunks/af762422a65c551dcd54.js +1 -0
  37. package/assets/esri/core/workers/chunks/{056fd7847caaff2c9514.js → af8bc56cf1404afc3028.js} +1 -1
  38. package/assets/esri/core/workers/chunks/b9e163f4a898e50cc854.js +1 -0
  39. package/assets/esri/core/workers/chunks/{444f0f51b3ee0b9845a5.js → bb2f6b0fcdfb8b158e26.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{4af39fa53bc0b79101ed.js → bc8a74da48b08309875f.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{026d3fa331caec1ea3d2.js → bf4dd8e50704e4040966.js} +1 -1
  42. package/assets/esri/core/workers/chunks/c19e3f6027b6526de359.js +1 -0
  43. package/assets/esri/core/workers/chunks/ce4dfc3a470230ddc9e4.js +1 -0
  44. package/assets/esri/core/workers/chunks/{8ea4584e07ccc85caabd.js → d11de13537b623739e14.js} +1 -1
  45. package/assets/esri/core/workers/chunks/d897412b99b9fba44bb4.js +1 -0
  46. package/assets/esri/core/workers/chunks/{035dbb0217f83108fa89.js → db86a1119e4e58ecfbda.js} +1 -1
  47. package/assets/esri/core/workers/chunks/dcb7a3ff59677b1cf0f1.js +1 -0
  48. package/assets/esri/core/workers/chunks/{5fe97253f80c797fad7f.js → df8a3d3cac454d42e14d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/dfe1139124fda0d6c059.js +1 -0
  50. package/assets/esri/core/workers/chunks/{8b8f391f27774aec6db9.js → e0b27bceb397482bd0e8.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{84821dff3bcc51161802.js → e89dc473f46a5584d2ef.js} +32 -32
  52. package/assets/esri/core/workers/chunks/{01ee18782a50279f907e.js → f4220b6eab0865318033.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{42336e0d1ef88737b078.js → f468c6ea2818a1f97e19.js} +1 -1
  54. package/assets/esri/core/workers/chunks/fce2306a1b31c6680f90.js +1 -0
  55. package/assets/esri/core/workers/chunks/fcf51697c361e0075cc2.js +1 -0
  56. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  57. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  58. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +15 -0
  59. package/assets/esri/themes/dark/main.css +1 -1
  60. package/assets/esri/themes/light/main.css +1 -1
  61. package/assets/esri/themes/light/view.css +1 -1
  62. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  63. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  64. package/chunks/ShadowCastVisualize.glsl.js +33 -15
  65. package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
  66. package/chunks/arcgis-knowledge-client-core.js +1 -1
  67. package/config.js +1 -1
  68. package/core/workers/registry.js +1 -1
  69. package/form/elements/inputs/MultipleChoiceInput.d.ts +6 -6
  70. package/form/elements/inputs/MultipleChoiceInput.js +1 -1
  71. package/kernel.js +1 -1
  72. package/layers/BaseDynamicLayer.js +1 -1
  73. package/layers/BaseTileLayer.js +1 -1
  74. package/layers/ElevationLayer.js +1 -1
  75. package/layers/MapImageLayer.js +1 -1
  76. package/layers/TileLayer.js +1 -1
  77. package/layers/WMSLayer.js +1 -1
  78. package/layers/WMTSLayer.js +1 -1
  79. package/layers/WebTileLayer.js +1 -1
  80. package/layers/mixins/ArcGISImageService.js +1 -1
  81. package/layers/mixins/TiledImagery.js +1 -1
  82. package/layers/support/imageBitmapUtils.js +1 -1
  83. package/package.json +1 -1
  84. package/request/process.js +1 -1
  85. package/rest/knowledgeGraph/CreateReplicaResponse.d.ts +37 -0
  86. package/rest/knowledgeGraph/CreateReplicaResponse.js +2 -0
  87. package/rest/knowledgeGraph/ReplicaDefinition.d.ts +91 -0
  88. package/rest/knowledgeGraph/ReplicaDefinition.js +2 -0
  89. package/rest/knowledgeGraph/ReplicasInformationResponse.d.ts +24 -0
  90. package/rest/knowledgeGraph/ReplicasInformationResponse.js +2 -0
  91. package/rest/knowledgeGraph/UnregisterReplicaResponse.d.ts +44 -0
  92. package/rest/knowledgeGraph/UnregisterReplicaResponse.js +2 -0
  93. package/rest/knowledgeGraph/wasmInterface/replicaToWasmEncodedFactories.js +2 -0
  94. package/rest/knowledgeGraph/wasmInterface/wasmToReplicaFactories.js +2 -0
  95. package/rest/knowledgeGraphService.d.ts +50 -1
  96. package/rest/knowledgeGraphService.js +1 -1
  97. package/support/revision.js +1 -1
  98. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  99. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
  100. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/FillShader.js +1 -1
  101. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  102. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
  103. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  104. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  105. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  106. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  107. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  108. package/views/2d/layers/TileLayerView2D.js +1 -1
  109. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  110. package/views/2d/layers/WMSLayerView2D.js +1 -1
  111. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  112. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  113. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  114. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  115. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  116. package/views/3d/layers/IntegratedMesh3DTilesLayerWorker.js +2 -0
  117. package/views/3d/layers/IntegratedMesh3DTilesLayerWorkerHandle.js +2 -0
  118. package/views/3d/layers/TileLayerView3D.js +1 -1
  119. package/views/3d/layers/WMTSLayerView3D.js +1 -1
  120. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  121. package/views/3d/layers/support/IntegratedMesh3DTilesVertexProcessing.js +2 -0
  122. package/views/3d/layers/support/makeScheduleFunction.js +1 -1
  123. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  124. package/views/3d/terrain/TerrainData.js +1 -1
  125. package/views/3d/terrain/TerrainSurface.js +1 -1
  126. package/views/3d/terrain/Tile.js +1 -1
  127. package/views/3d/terrain/TileRenderer.js +1 -1
  128. package/views/3d/terrain/terrainUtils.js +1 -1
  129. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  130. package/views/3d/webgl-engine/materials/VisualVariablePassParameters.js +1 -1
  131. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  132. package/views/3d/webgl-engine/shaders/colorRampParameters.js +2 -0
  133. package/views/support/TextureCompressionWorker.js +1 -1
  134. package/views/support/TextureCompressionWorkerHandle.js +1 -1
  135. package/views/webgl/Texture.js +1 -1
  136. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  137. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  138. package/widgets/OrientedImageryViewer/css.js +1 -1
  139. package/widgets/OrientedImageryViewer.js +1 -1
  140. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  141. package/assets/esri/core/workers/chunks/05c3146d87d917606193.js +0 -1
  142. package/assets/esri/core/workers/chunks/0b77c124b743067e4155.js +0 -1
  143. package/assets/esri/core/workers/chunks/11241781baaed346af52.js +0 -1
  144. package/assets/esri/core/workers/chunks/1d9560eb8b21b9e76616.js +0 -1
  145. package/assets/esri/core/workers/chunks/2bd69a7734d170e190ed.js +0 -1
  146. package/assets/esri/core/workers/chunks/2c87c3112a43db8624f6.js +0 -1
  147. package/assets/esri/core/workers/chunks/3a58708217a9c11836ab.js +0 -1
  148. package/assets/esri/core/workers/chunks/3bbf684ee2484eb44c9f.js +0 -1
  149. package/assets/esri/core/workers/chunks/49fb9c47070641bce9a9.js +0 -1
  150. package/assets/esri/core/workers/chunks/5417308eba30e668b1ee.js +0 -1
  151. package/assets/esri/core/workers/chunks/62b3e933f548ce354b99.js +0 -1
  152. package/assets/esri/core/workers/chunks/6e70e922331704b92a08.js +0 -1
  153. package/assets/esri/core/workers/chunks/7c7c11c0fde8b63e330b.js +0 -1
  154. package/assets/esri/core/workers/chunks/7cee7ffaf941a4fe23b0.js +0 -596
  155. package/assets/esri/core/workers/chunks/7f55eef696e9ed717bfc.js +0 -1
  156. package/assets/esri/core/workers/chunks/89dbea6f436d45a3b185.js +0 -1
  157. package/assets/esri/core/workers/chunks/9d216e30d04ea21fc8a2.js +0 -1
  158. package/assets/esri/core/workers/chunks/a5d8d6f3c0c8de474efd.js +0 -1
  159. package/assets/esri/core/workers/chunks/a809b811121099a87a98.js +0 -1
  160. package/assets/esri/core/workers/chunks/c02ba921c0a32d2021e3.js +0 -1
  161. package/assets/esri/core/workers/chunks/c3c19b62d948d53118a8.js +0 -1
  162. package/assets/esri/core/workers/chunks/c46a4adea39636a96d03.js +0 -1
  163. package/assets/esri/core/workers/chunks/c5507480344176fad241.js +0 -1
  164. package/assets/esri/core/workers/chunks/c6030271bd6d39b6e1db.js +0 -1
  165. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +0 -1
  166. package/assets/esri/core/workers/chunks/dcbc4072c18278c2b67d.js +0 -1
  167. package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +0 -1
  168. package/assets/esri/core/workers/chunks/ecb7ede6a8e6c05e4c6c.js +0 -1
  169. package/assets/esri/core/workers/chunks/f227b34cce6843df0fb6.js +0 -1
  170. package/request/ImageWithType.js +0 -2
  171. package/views/3d/layers/support/fetchTile.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import i from"../../request.js";import r from"../../core/Error.js";import{clone as s}from"../../core/lang.js";import n from"../../core/Logger.js";import{watch as a}from"../../core/reactiveUtils.js";import{urlToObject as o}from"../../core/urlUtils.js";import{property as l,subclass as u}from"../../core/accessorSupport/decorators.js";import{Integer as p,ensureClass as m}from"../../core/accessorSupport/ensureType.js";import{runUntracked as c}from"../../core/accessorSupport/tracking.js";import h from"../../geometry/Extent.js";import d from"../../geometry/Polygon.js";import f from"../../geometry/SpatialReference.js";import{srToRESTValue as y}from"../../geometry/support/spatialReferenceUtils.js";import{intersectMultimensionalSubset as g,getEffectiveMultidimensionalDefinition as R,getSubsetVariablesFromMdInfo as I,getDefaultMultidimensionalDefinition as w}from"../raster/datasets/multidimensionalUtils.js";import{decode as v,getFormat as b}from"../raster/formats/RasterCodec.js";import{uvComponentToVector as x}from"../raster/functions/vectorFieldUtils.js";import{opacity as S,url as F}from"../support/commonProperties.js";import _ from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as D}from"../support/ExportImageServiceParameters.js";import O from"../support/Field.js";import T from"../support/FieldsIndex.js";import{createBitmap as C}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as M}from"../support/imageryRendererUtils.js";import q from"../support/MosaicRule.js";import N from"../support/MultidimensionalSubset.js";import P from"../support/PixelBlock.js";import{interpolationKebab as j,noDataInterpretationKebab as E,pixelTypeKebabDict as A}from"../support/rasterEnums.js";import{getServicePixelValueField as Q,getItemPixelValueField as V,getRawServicePixelValueField as J,getProcessedServicePixelValueField as U,getMagnitudeField as B,getDirectionField as z,getMultidimensionalFields as L,getRasterAttributeTableFields as H,addMultidimensionalFieldValues as G,commonRasterFieldNames as k,rasterFieldPrefix as W}from"../support/rasterFieldUtils.js";import $ from"../support/RasterFunction.js";import X from"../support/RasterInfo.js";import{createDefaultRenderer as K,getDefaultBandCombination as Y,getSupportedRendererTypes as Z,matchPresetRenderer as ee,normalizeRendererJSON as te}from"../../renderers/support/rasterRendererHelper.js";import ie from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as re,websceneRasterRendererTypes as se,read as ne}from"../../renderers/support/rasterTypeUtils.js";import{calculateVolume as ae,computeAngles as oe,computePixelSpaceLocations as le,computeHistograms as ue,computeStatisticsHistograms as pe,measureHeight as me,measureAreaAndPerimeter as ce,measureDistanceAndAngle as he,measurePointOrCentroid as de,measureLengthFromImage as fe,measureAreaFromImage as ye,getImageSpatialReferenceQueryParameter as ge,getSamples as Re,identify as Ie,imageToMap as we,imageToMapMultiray as ve,mapToImage as be,findImages as xe,getImageUrl as Se,queryBoundary as Fe,queryGPSInfo as _e}from"../../rest/imageService.js";import{fetchServiceRasterInfo as De,generateRasterInfo as Oe,patchServiceInfo as Te}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as Ce}from"../../rest/imageService/getCatalogItemRasterInfo.js";import{executeForCount as Me}from"../../rest/query/executeForCount.js";import{executeForExtent as qe}from"../../rest/query/executeForExtent.js";import{executeForIds as Ne}from"../../rest/query/executeForIds.js";import{executeQueryJSON as Pe}from"../../rest/query/executeQueryJSON.js";import je from"../../rest/support/FeatureSet.js";import Ee from"../../rest/support/ImageIdentifyParameters.js";import Ae from"../../rest/support/Query.js";import{reader as Qe}from"../../core/accessorSupport/decorators/reader.js";import{writer as Ve}from"../../core/accessorSupport/decorators/writer.js";const Je=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]);function Ue(e){const t=JSON.stringify(e),i=t.includes('"rasterFunctionDefinition":{'),r=i?t.match(/"type":"(.*?FunctionArguments")/gi):t.match(/"rasterFunction":"(.*?")/gi),s=r?.map(e=>i?e.slice(8,-18):e.slice(18,-1));return s?s.join("/"):null}const Be=Be=>{const ze=Be;let Le=class extends ze{constructor(){super(...arguments),this._functionRasterInfos={},this._serviceSupportsMosaicRule=null,this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new D({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach(t=>{e.set(t.name.toLowerCase().replaceAll(/ /gi,"_"),t.name)}),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every(e=>"number"==typeof e))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?c(()=>q.fromJSON(t)):null}get fieldsIndex(){return this.fields?new T(this.fields):null}set format(e){e&&Je.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}get isRenderedFormat(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t?.mosaicMethod&&(t=q.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?q.fromJSON(i):this._isMosaicRuleSupported(t)?q.fromJSON(t):null}writeMosaicRule(e,t,i){const{mosaicRule:r}=this;this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}readObjectIdField(e,t){if(!e){const i=t.fields.find(e=>"esriFieldTypeOID"===e.type||"oid"===e.type);e=i?.name}return e}get parsedUrl(){return o(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}get renderer(){const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){this.activePresetRendererName=null,this.internalRenderer=e}set internalRenderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("internalRenderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,s=ne(r,i);return null==s?null:("vector-field"===s.type&&t.symbolTileSize&&!r.symbolTileSize&&(s.symbolTileSize=t.symbolTileSize),M(s)||n.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),s)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON()}get rasterFields(){const e=this.fields?.map(e=>e.clone())??[];e.push(Q()),"mosaic-dataset"===this.sourceType&&this.fields?.length&&e.push(V()),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some(({name:e})=>"none"===e.toLowerCase())&&e.push(J()),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter(({name:e})=>"none"!==e.toLowerCase()).forEach(({name:t})=>e.push(U(t)));const{rasterInfo:t}=this;if(this._isVectorDataSet()){const i=t?.multidimensionalInfo?.variables[0].unit?.trim(),r=B(i),s=z();e.push(r,s)}if(t?.multidimensionalInfo&&"raster-dataset"===this.sourceType){const i=L(t.multidimensionalInfo);e.push(...i)}const i=t?.attributeTable;if(null!=i){const t=H(i);e.push(...t)}return e}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=$.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?$.fromJSON({rasterFunctionDefinition:t.renderingRule}):$.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?f.fromJSON(i):null}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=A.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e,{renderer:r,symbolizer:s,pixelFilter:n}=this;const{isRawData:a}=e;if(a&&"lerc"!==this.format&&(r??=K(this.rasterInfo,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}),s||(this.symbolizer=new ie({rendererJSON:r.toJSON(),rasterInfo:this.rasterInfo}),s=this.symbolizer)),(a||!this.isRenderedFormat)&&r&&s&&!n){await this._updateSymbolizer(s,r);const n=this.bandIds?.length?this.bandIds:Y(this.rasterInfo);i=await this._symbolize({pixelData:e,bandIds:n,symbolizer:s},t)}return i}destroy(){this._shutdownJobHandler()}async calculateVolume(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsCalculateVolume)throw new r("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=s(e),this.mosaicRule&&null==e.mosaicRule&&(e.mosaicRule=this.mosaicRule),ae(this.url,e,this._getRequestOptions(t))}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new r("imagery-layer:compute-angles","this operation is not supported on the input image service");return oe(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new r("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return le(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new r("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=s(e),this._applyMosaicAndRenderingRules(e),ue(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new r("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=s(e),this._applyMosaicAndRenderingRules(e),pe(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new r("imagery-layer:measure-height","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),me(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new r("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),ce(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new r("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),he(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new r("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),de(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new r("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new r("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return fe(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new r("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new r("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return ye(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async internalFetchImage(e,t,i,r={}){await this._updateCurrentRasterInfo();const{exportImageServiceParameters:s}=this;let n=!1;r.requestRawData&&(await this._initJobHandler(),s.requestRawData||"lerc"===this.format||(n=!0,s.requestRawData=!0));const a=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(n&&(s.requestRawData=!1,a&&!this.bandIds?.length&&(null==a.bandIds||""===a.bandIds))){const e=Y(this.rasterInfo);a.bandIds=e?.join(",")}if(null==a){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){return{imageBitmap:await C(e,`${He(this.parsedUrl)}/exportImage`,r.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(P.createEmptyBand(l,o));return{pixelData:{pixelBlock:new P({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const o=!!r.requestAsImageElement&&!this.pixelFilter,l=o&&!!r.returnImageBitmap,u={imageServiceParameters:a,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:o,returnImageBitmap:l,signal:r.signal};return this._requestArrayBuffer(u)}async fetchPixels(e,t,i,r={}){await this._initJobHandler(),r.applyRendering&&this._updateCurrentRasterInfo();const s=r.applyRendering?void 0:new D({layer:this,requestRawData:!0,interpolation:r.interpolation??"nearest",bandIds:r.bandIds??[]}),n=this.getExportImageServiceParameters(e,t,i,r.timeExtent,s);if(null==n)return{extent:e,pixelBlock:null};delete n.pixelType,r.bandIds||delete n.bandIds,delete n.compressionQuality;const a={imageServiceParameters:n,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:!1,returnImageBitmap:!1,signal:r.signal},{pixelData:o}=await this._requestArrayBuffer(a);return o??{extent:e,pixelBlock:null}}fetchKeyProperties(e){return i(He(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>e.data)}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new r("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):i(He(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>je.fromJSON(e.data))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return Ce(He(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:r}=await i(He(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),s=r?.ics;if(!s)return;let n=null;try{n=(await i(He(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!n?.spatialReference)return{ics:s,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?i(He(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then(e=>e.data).catch(()=>({})):{},o=n.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[n]}),inSR:y(o),outSR:"0:"+e},u=i(He(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then(e=>e.data).catch(()=>({})),p=5,m=(n.xmin+n.xmax)/2,c=(n.ymax-n.ymin)/(p+1),d=n.ymin+c,g=[];for(let i=0;i<p;i++)g.push({x:m,y:d+c*i});const R={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:g}),inSR:y(o),outSR:"0:"+e},I=i(He(this.parsedUrl)+"/project",{query:this._getQueryParams(R),...t}).then(e=>e.data).catch(()=>({})),w=await Promise.all([a,u,I]);let v=w[0].ipxf;if(null==v){const e=s.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(v={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=h.fromJSON(w[1]?.geometries?.[0]);b&&(b.spatialReference=new f({wkid:0,imageCoordinateSystem:s}));const x=w[2].geometries?w[2].geometries.filter(e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y):[],S=x.length;if(S<3)return{ics:s,icsToPixelTransform:v,icsExtent:b,northDirection:null};let F=0,_=0,D=0,O=0;for(let i=0;i<S;i++)F+=x[i].x,_+=x[i].y,D+=x[i].x*x[i].x,O+=x[i].x*x[i].y;const T=(S*O-F*_)/(S*D-F*F);let C=0;const M=x[p-1].x>x[0].x,q=x[p-1].y>x[0].y;return T===1/0?C=q?90:270:0===T?C=M?0:180:T>0?C=M?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(C=q?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:s,icsToPixelTransform:v,icsExtent:b,northDirection:C}}async generateRasterInfo(e,t){const i=m($,e),s={...t,query:this._getQueryParams()};if(!i||"none"===i.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(i))return this.serviceRasterInfo??De(He(this.parsedUrl),this.sourceJSON,s);const n=Ue(i);if(!n)throw new r("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[n])return this._functionRasterInfos[n];const a=Oe(He(this.parsedUrl),i,s);this._functionRasterInfos[n]=a;try{return await a}catch(o){throw this._functionRasterInfos[n]=null,o}}getExportImageServiceParameters(e,t,i,r,s){e=e.clone().shiftCentralMeridian();const n=ge(e.spatialReference,He(this.parsedUrl));s??=this.exportImageServiceParameters;const a=s.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const p=this.rasterFunction?.rasterFunctionDefinition,m=this.renderer?.type,c=!m||"raster-stretch"===m||"raster-colormap"===m||"unique-value"===m||"class-breaks"===m||"raster-shaded-relief"===m;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!p&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=o?.join(",");Array.isArray(l)&&l.length>0&&(a.noData=l.join(","));const h=this._processMultidimensionalIntersection(null,r,s.mosaicRule);if(h.isOutSide)return null;a.mosaicRule=null!=h.mosaicRule?JSON.stringify(h.mosaicRule):null,r=h.timeExtent,a.renderingRule=this._getRenderingRuleString($.fromJSON(u));const d={};if(null!=r){const{start:e,end:t}=r.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+i,...a,...d}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new r("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=s(e);const{raster:n}=this;return n&&null==e.raster&&(e.raster=n),Re(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new r("imagery-layer:identify","identify operation is not supported on the input image service");e=s(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=d.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new r("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:n,rasterFunction:a}=this;return a&&null==e.rasterFunction&&(e.rasterFunction=a),n&&null==e.raster&&(e.raster=n),Ie(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new r("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return we(He(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new r("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return ve(He(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new r("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return be(He(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new r("imagery-layer:find-images","findImages operation is not supported on the input image service");return xe(He(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new r("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return Se(He(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ae({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new r("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},Fe(He(this.parsedUrl),e,this._getRequestOptions(t))}async queryExtent(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const{where:i,objectIds:r,geometry:s,timeExtent:n,start:a,num:o,pixelSize:l}=e,u=null!=i&&"1=1"!==i,p=null!=r&&r.length>0,m=null!=s&&("extent"!==s.type||!s.equals(this.fullExtent)),c=null!=l,h=null!=a||null!=o,{timeInfo:d}=this,f=null!=n&&null!=d&&!n.equals(d.fullTimeExtent);if(!(u||p||m||c||f||h)){const i=await Me(this.url,e,t),{outSpatialReference:r}=e;if(!r||r.equals(this.spatialReference))return{count:i,extent:this.fullExtent.clone()};const s=await import("../../geometry/operators/projectOperator.js");await s.load();return{count:i,extent:s.execute(this.fullExtent,r)}}return qe(this.url,e,t)}async queryRasters(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const i=await Pe(this.url,e,t),r=this.graphicOrigin;return i.features.forEach(e=>{e.layer=this,e.origin=r}),i}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ne(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new r("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},_e(He(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Me(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new r("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:s,returnTopmostRaster:n,showNoDataRecords:a}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p=k.servicePixelValue.toLowerCase(),m=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some(e=>!e.toLowerCase().startsWith(p)),this.version>=10.4)){const t=e.outFields.filter(e=>e.toLowerCase().startsWith(p)&&e.length>p.length).map(e=>{const t=e.slice(p.length+1);return[this._updateRenderingRulesFunctionName(t,m),t]});l=t.map(e=>new $({functionName:e[0]})),u=t.map(e=>e[1]);const{rasterFunction:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some(e=>e.functionName===i.functionName)&&(l.push(i),u.push(i.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:h}=this;let f=e.timeExtent||this.timeExtent;if(h){const{isOutside:t,intersection:i}=g(h,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new r("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=i?.timeExtent&&(f=i.timeExtent)}const y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f);let I=e.geometry;this.version<10.91&&"extent"===I?.type&&(I=d.fromExtent(I));const w=this._getQueryParams({geometry:I,timeExtent:f,mosaicRule:y,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:n?1:null});delete w.f;const v=new Ee(w);try{await this._generateRasterInfo(this.rasterFunction);const i=await Ie(this.url,v,{signal:t?.signal,query:{...this.customParameters}}),r=e.outFields,n=null!=i.value&&i.value.toLowerCase().includes("nodata"),l=o&&!c&&i?.catalogItems?.features.length&&(a||!n),p=this.multidimensionalInfo&&"raster-dataset"===this.sourceType?R({rasterInfo:this.rasterInfo,multidimensionalDefinition:y?.multidimensionalDefinition,timeExtent:f,multidimensionalSubset:this.multidimensionalSubset}):null;if(!l)return this._processVisibleRastersResponse(i,{returnDomainValues:s,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:r,effectiveMultidimensionalDefinition:p});const m=this.objectIdField||"ObjectId",h=i.catalogItems?.features??[],d=h.map(e=>e.attributes?.[m]),g=new Ae({objectIds:d,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[m]}),I=await this.queryRasters(g);return I?.features?.length&&I.features.forEach(t=>{h.forEach(i=>{i.attributes[m]===t.attributes[m]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))})}),this._processVisibleRastersResponse(i,{returnDomainValues:s,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:r,effectiveMultidimensionalDefinition:p})}catch{throw new r("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=i(He(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.statistics),s=i(He(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.histograms),n=await Promise.all([r,s]);return n[0]&&n[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),{statistics:n[0]||null,histograms:n[1]||null}}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return I(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):De(He(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then(e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),Te(e,t),e)),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then(e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.internalRenderer&&!this._isSupportedRenderer(this.internalRenderer)&&(this._set("internalRenderer",null),n.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("internalRenderer",this._configRenderer(this.renderer)),this.addHandles([a(()=>this.rasterFunction,e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then(e=>{e&&(this.rasterInfo=e)})})]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)})}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==i?.startField)return e;const{startField:s}=i,n=r.variables.some(e=>e.dimensions.some(e=>e.name===s))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter(e=>e.dimensionName!==n),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const a=e.multidimensionalDefinition.filter(e=>e.dimensionName===n),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],m=this.version>=10.8;if(a.length)a.forEach(e=>{e.dimensionName===n&&(m?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))});else if(!m){const t=e.multidimensionalDefinition.filter(e=>null!=e.variableName&&null==e.dimensionName);t.length?t.forEach(e=>{e.dimensionName=n,e.isSlice=u,e.values=p}):e.multidimensionalDefinition.push(new _({variableName:"",dimensionName:n,isSlice:u,values:p}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return null==e?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter(e=>!(!e.variableName&&!e.dimensionName)),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this.sourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQuery)throw new r("imagery-layer:query-rasters","query operation is not supported on the input image service");const i=null!=e?m(Ae,e):this.createQuery();return t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:i,requestOptions:t}}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&Z(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:s}=await i(He(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,s&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map(e=>e.trim()).indexOf("tilesonly")>-1)throw new r("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_configRenderer(e){const{rasterInfo:t}=this;if(!this.isRenderedFormat&&!this.pixelFilter||this._isVectorDataSet()){const i=this.mosaicRule?.multidimensionalDefinition?.[0].variableName,r=ee({variableName:i,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>=3){const e=r?.bandIds??Y(t);!e||3===t.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=r?.renderer??K(t,{bandIds:this.bandIds,variableName:this.rasterFunction?null:i}));const s=te(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=s,this.symbolizer.rasterInfo=t):this.symbolizer=new ie({rendererJSON:s,rasterInfo:t}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=e?.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler?this._rasterJobHandler.decode({data:e,options:t}):v(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const r=await i(He(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return r.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:s,returnImageBitmap:n,signal:a}=e;if(s&&this._canRequestImageElement(t.format)){const r=`${He(this.parsedUrl)}/exportImage`,{data:s}=await i(r,{responseType:n?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:a});if(s instanceof Blob){return{imageBitmap:await C(s,r,a),params:t}}return{imageOrCanvasElement:s,params:t}}const o=this._initJobHandler(),l=i(He(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:a}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let m=p;if("bsq"!==m&&"bip"!==m&&(m=b(u)),!m)throw new r("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:a},h=this._decodePixelBlock(u,{width:t.width,height:t.height,format:p,applyJpegMask:!0},c);return{pixelData:{pixelBlock:await h,extent:t.extent},params:t}}_generateRasterInfo(e,t){return this.generateRasterInfo(e,t).catch(()=>null)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=w(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new q;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.functionName?.toLowerCase()&&t.forEach(e=>e.variableName=""),t=t.filter(({variableName:e,dimensionName:t})=>e&&"*"!==e||t),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map(e=>e.replaceAll(/ /gi,", "))||[];const m=this.objectIdField||"ObjectId",c="string"==typeof r&&r.toLowerCase().includes("nodata"),h=[];if(r&&!u&&(!c||n)){const e={};e[m]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})],this.multidimensionalInfo&&"raster-dataset"===this.sourceType&&G(this.rasterFields,e,i.effectiveMultidimensionalDefinition)}if(!u)return[];this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);const{itemPixelValue:d,servicePixelValue:f}=k,y=this.rasterFields.some(e=>e.name===d),g=this.graphicOrigin;for(let t=0;t<u.length;t++){const e=u[t];if(null!=r){const i=p[t],a=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r;if("nodata"===i.toLowerCase()&&!n)continue;y&&(e.attributes[d]=i),e.attributes[f]=a,this._updateFeatureWithMagDirValues(e,i);const o=this.fields&&this.fields.length>0;let u=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?i:r:a;this.rasterFunction||(u=o?i:r),this._updateFeatureWithRasterAttributeTableValues(e,u)}if(e.sourceLayer=e.layer=this,e.origin=g,a&&this._updateFeatureWithDomainValues(e),s&&l&&s.length===l.length)for(let t=0;t<s.length;t++){const i=`${k.servicePixelValue}.${s[t]}`;e.attributes[i]=l[t]}h.push(u[t])}return h}_processMultidimensionalIntersection(e,t,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=g(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=g(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==i)return;const{features:r,fields:s}=i,n=s.map(e=>e.name).find(e=>"value"===e.toLowerCase());if(!n)return;const a=r.filter(e=>e.attributes[n]===(null!=t?parseInt(t,10):null));a&&a[0]&&s.forEach(t=>{const i=W+t.name;e.attributes[i]=a[0].attributes[t.name]})}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map(e=>parseFloat(e)),r=i.map(e=>[e]),s=i.map(e=>({minValue:e,maxValue:e,noDataValue:null})),n=new P({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new h(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:x([n.pixels[0][0],n.pixels[1][0]]);e.attributes[k.magnitude]=a[0],e.attributes[k.direction]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter(e=>"coded-value"===e.domain?.type);null!=t&&t.forEach(t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find(e=>e.code===i);r&&(e.attributes[t.name]=r.name)}})}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach(e=>{if(e?.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}})}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return null!=e?.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e?.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,rasterFunction:r}=this;r&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}async _updateCurrentRasterInfo(e){if(this.renderer||this.symbolizer){const t=await this._generateRasterInfo(this.rasterFunction,{signal:e});t&&(this.rasterInfo=t)}}_applyMosaicRule(e){const{raster:t,mosaicRule:i}=this;i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map(e=>e.trim()):["image","catalog"],{currentVersion:i,maxRecordCount:r}=e,s=t.includes("image"),n="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),o=t.includes("edit"),l=t.includes("mensuration")&&a,u=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map(e=>e.trim()),p=l&&u.includes("basic"),m=this._isMosaicDataset(e)&&t.includes("catalog"),c=t.includes("download"),h=i>=10.7&&n||i>=11.4&&(n||l&&u.includes("3d")),d=m&&e.fields&&e.fields.length>0,f=d&&e.supportsAdvancedQueries?e.advancedQueryCapabilities:void 0;return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:s,supportsExportImage:s,supportsIdentify:s,supportsImageToMap:i>=11.2&&m,supportsImageToMapMultiray:i>=11.2&&m,supportsMapToImage:i>=11.2&&m,supportsFindImages:i>=11.2&&m,supportsGetImageUrl:i>=11.3&&c,supportsMeasure:l,supportsMeasureFromImage:i>=11.2,supportsDownload:c,supportsQuery:d,supportsGetSamples:i>=10.2&&s,supportsProject:i>=10.3&&s,supportsComputeStatisticsHistograms:i>=10.4&&s,supportsQueryBoundary:i>=10.6&&s,supportsCalculateVolume:h,supportsComputePixelLocation:i>=10.7&&m,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&m,supportsAdd:o,supportsDelete:o,supportsEditing:o,supportsUpdate:o,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:r,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,supportsStatistics:!!f?.supportsStatistics,supportsOrderBy:!!f?.supportsOrderBy,supportsDistinct:!!f?.supportsDistinct,supportsPagination:!!f?.supportsPagination,supportsPaginationOnAggregatedQueries:!!f?.supportsPaginationOnAggregatedQueries,supportsStandardizedQueriesOnly:!!f?.useStandardizedQueries,supportsPercentileStatistics:!!f?.supportsPercentileStatistics,supportsCentroid:!!f?.supportsReturningGeometryCentroid,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDistance:!!f?.supportsQueryWithDistance,supportsExtent:!!f?.supportsReturningQueryExtent,supportsGeometryProperties:!!f?.supportsReturningGeometryProperties,supportsHavingClause:!!f?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:f?.supportsSqlExpression??!!f,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!f?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,tileMaxRecordCount:void 0,supportsTrueCurve:!1},mensuration:{supportsDistanceAndAngle:p,supportsAreaAndPerimeter:p,supportsPointOrCentroid:p,supportsHeightFromBaseAndTop:l&&u.includes("base-top height"),supportsHeightFromBaseAndTopShadow:l&&u.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:l&&u.includes("top-top shadow height"),supports3D:l&&u.includes("3d")}}}};function He(e){return e?.path??""}return e([l({clonable:!1})],Le.prototype,"_functionRasterInfos",void 0),e([l({readOnly:!0})],Le.prototype,"_serviceSupportsMosaicRule",void 0),e([Qe("_serviceSupportsMosaicRule",["currentVersion","fields"])],Le.prototype,"readServiceSupportsMosaicRule",null),e([l({readOnly:!0})],Le.prototype,"_rasterFunctionNamesIndex",null),e([l()],Le.prototype,"adjustAspectRatio",void 0),e([l({type:[p],json:{write:!0}})],Le.prototype,"bandIds",void 0),e([Qe("bandIds")],Le.prototype,"readBandIds",null),e([l({readOnly:!0,json:{read:!1}})],Le.prototype,"capabilities",void 0),e([Qe("service","capabilities",["capabilities","currentVersion","serviceDataType"])],Le.prototype,"readCapabilities",null),e([l({type:Number})],Le.prototype,"compressionQuality",void 0),e([Ve("compressionQuality")],Le.prototype,"writeCompressionQuality",null),e([l({type:Number})],Le.prototype,"compressionTolerance",void 0),e([Ve("compressionTolerance")],Le.prototype,"writeCompressionTolerance",null),e([l({json:{read:{source:"copyrightText"}}})],Le.prototype,"copyright",void 0),e([l({readOnly:!0})],Le.prototype,"defaultMosaicRule",void 0),e([Qe("defaultMosaicRule",["defaultMosaicMethod"])],Le.prototype,"readDefaultMosaicRule",null),e([l({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Le.prototype,"definitionExpression",void 0),e([l({readOnly:!0,constructOnly:!0})],Le.prototype,"exportImageServiceParameters",void 0),e([l()],Le.prototype,"rasterInfo",void 0),e([l({readOnly:!0,type:[O]})],Le.prototype,"fields",void 0),e([l({readOnly:!0})],Le.prototype,"fieldsIndex",null),e([l({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff","bip","bsq"],json:{write:!0}})],Le.prototype,"format",null),e([Qe("service","format",["serviceDataType"])],Le.prototype,"readFormat",null),e([l({type:h})],Le.prototype,"fullExtent",void 0),e([l({readOnly:!0})],Le.prototype,"hasMultidimensions",void 0),e([l({json:{read:{source:"maxImageHeight"}}})],Le.prototype,"imageMaxHeight",void 0),e([l({json:{read:{source:"maxImageWidth"}}})],Le.prototype,"imageMaxWidth",void 0),e([l({type:String,json:{type:j.jsonValues,read:j.read,write:j.write}})],Le.prototype,"interpolation",void 0),e([l()],Le.prototype,"minScale",void 0),e([Qe("service","minScale")],Le.prototype,"readMinScale",null),e([l()],Le.prototype,"maxScale",void 0),e([Qe("service","maxScale")],Le.prototype,"readMaxScale",null),e([l({type:q})],Le.prototype,"mosaicRule",null),e([Qe("mosaicRule",["mosaicRule","defaultMosaicMethod"])],Le.prototype,"readMosaicRule",null),e([Ve("mosaicRule")],Le.prototype,"writeMosaicRule",null),e([l()],Le.prototype,"multidimensionalInfo",void 0),e([l({type:N,json:{write:!0}})],Le.prototype,"multidimensionalSubset",void 0),e([l({json:{type:[Number,[Number]],write:!0}})],Le.prototype,"noData",void 0),e([l({type:String,json:{type:E.jsonValues,read:E.read,write:E.write}})],Le.prototype,"noDataInterpretation",void 0),e([l({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],Le.prototype,"objectIdField",void 0),e([Qe("objectIdField")],Le.prototype,"readObjectIdField",null),e([l({readOnly:!0})],Le.prototype,"geometryType",void 0),e([l({})],Le.prototype,"typeIdField",void 0),e([l({})],Le.prototype,"types",void 0),e([l({readOnly:!0})],Le.prototype,"parsedUrl",null),e([l({type:Function})],Le.prototype,"pixelFilter",void 0),e([l()],Le.prototype,"raster",void 0),e([l({readOnly:!0})],Le.prototype,"sourceType",void 0),e([Qe("sourceType",["serviceSourceType","fields"])],Le.prototype,"readSourceType",null),e([l()],Le.prototype,"viewId",void 0),e([l({types:re})],Le.prototype,"renderer",null),e([l({types:re,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:se,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],Le.prototype,"internalRenderer",null),e([Qe("internalRenderer")],Le.prototype,"readRenderer",null),e([Ve("internalRenderer")],Le.prototype,"writeRenderer",null),e([l({clonable:!1})],Le.prototype,"symbolizer",void 0),e([l(S)],Le.prototype,"opacity",void 0),e([l({readOnly:!0})],Le.prototype,"rasterFields",null),e([l({constructOnly:!0})],Le.prototype,"rasterFunctionInfos",void 0),e([l({type:$,json:{name:"renderingRule"}})],Le.prototype,"rasterFunction",null),e([Qe("rasterFunction",["renderingRule","rasterFunctionInfos"])],Le.prototype,"readRasterFunction",null),e([l({readOnly:!0})],Le.prototype,"serviceDataType",void 0),e([l({readOnly:!0,type:f})],Le.prototype,"spatialReference",void 0),e([Qe("spatialReference",["spatialReference","extent"])],Le.prototype,"readSpatialReference",null),e([l({type:A.apiValues,json:{read:A.read,type:A.jsonValues}})],Le.prototype,"pixelType",void 0),e([Ve("pixelType")],Le.prototype,"writePixelType",null),e([l({constructOnly:!0,type:X})],Le.prototype,"serviceRasterInfo",void 0),e([l()],Le.prototype,"sourceJSON",void 0),e([l(F)],Le.prototype,"url",void 0),e([l({readOnly:!0})],Le.prototype,"version",void 0),e([Qe("version",["currentVersion","fields","timeInfo"])],Le.prototype,"readVersion",null),Le=e([u("esri.layers.mixins.ArcGISImageService")],Le),Le};export{Be as ArcGISImageService};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import i from"../../request.js";import r from"../../core/Error.js";import{clone as s}from"../../core/lang.js";import n from"../../core/Logger.js";import{watch as a}from"../../core/reactiveUtils.js";import{urlToObject as o}from"../../core/urlUtils.js";import{property as l,subclass as u}from"../../core/accessorSupport/decorators.js";import{Integer as p,ensureClass as m}from"../../core/accessorSupport/ensureType.js";import{runUntracked as c}from"../../core/accessorSupport/tracking.js";import h from"../../geometry/Extent.js";import d from"../../geometry/Polygon.js";import f from"../../geometry/SpatialReference.js";import{srToRESTValue as y}from"../../geometry/support/spatialReferenceUtils.js";import{intersectMultimensionalSubset as g,getEffectiveMultidimensionalDefinition as R,getSubsetVariablesFromMdInfo as I,getDefaultMultidimensionalDefinition as w}from"../raster/datasets/multidimensionalUtils.js";import{decode as v,getFormat as b}from"../raster/formats/RasterCodec.js";import{uvComponentToVector as x}from"../raster/functions/vectorFieldUtils.js";import{opacity as S,url as F}from"../support/commonProperties.js";import _ from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as D}from"../support/ExportImageServiceParameters.js";import O from"../support/Field.js";import T from"../support/FieldsIndex.js";import{createBitmap as C}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as M}from"../support/imageryRendererUtils.js";import q from"../support/MosaicRule.js";import N from"../support/MultidimensionalSubset.js";import P from"../support/PixelBlock.js";import{interpolationKebab as j,noDataInterpretationKebab as E,pixelTypeKebabDict as A}from"../support/rasterEnums.js";import{getServicePixelValueField as Q,getItemPixelValueField as V,getRawServicePixelValueField as J,getProcessedServicePixelValueField as U,getMagnitudeField as B,getDirectionField as z,getMultidimensionalFields as L,getRasterAttributeTableFields as H,addMultidimensionalFieldValues as G,commonRasterFieldNames as k,rasterFieldPrefix as W}from"../support/rasterFieldUtils.js";import $ from"../support/RasterFunction.js";import X from"../support/RasterInfo.js";import{createDefaultRenderer as K,getDefaultBandCombination as Y,getSupportedRendererTypes as Z,matchPresetRenderer as ee,normalizeRendererJSON as te}from"../../renderers/support/rasterRendererHelper.js";import ie from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as re,websceneRasterRendererTypes as se,read as ne}from"../../renderers/support/rasterTypeUtils.js";import{calculateVolume as ae,computeAngles as oe,computePixelSpaceLocations as le,computeHistograms as ue,computeStatisticsHistograms as pe,measureHeight as me,measureAreaAndPerimeter as ce,measureDistanceAndAngle as he,measurePointOrCentroid as de,measureLengthFromImage as fe,measureAreaFromImage as ye,getImageSpatialReferenceQueryParameter as ge,getSamples as Re,identify as Ie,imageToMap as we,imageToMapMultiray as ve,mapToImage as be,findImages as xe,getImageUrl as Se,queryBoundary as Fe,queryGPSInfo as _e}from"../../rest/imageService.js";import{fetchServiceRasterInfo as De,generateRasterInfo as Oe,patchServiceInfo as Te}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as Ce}from"../../rest/imageService/getCatalogItemRasterInfo.js";import{executeForCount as Me}from"../../rest/query/executeForCount.js";import{executeForExtent as qe}from"../../rest/query/executeForExtent.js";import{executeForIds as Ne}from"../../rest/query/executeForIds.js";import{executeQueryJSON as Pe}from"../../rest/query/executeQueryJSON.js";import je from"../../rest/support/FeatureSet.js";import Ee from"../../rest/support/ImageIdentifyParameters.js";import Ae from"../../rest/support/Query.js";import{reader as Qe}from"../../core/accessorSupport/decorators/reader.js";import{writer as Ve}from"../../core/accessorSupport/decorators/writer.js";const Je=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]);function Ue(e){const t=JSON.stringify(e),i=t.includes('"rasterFunctionDefinition":{'),r=i?t.match(/"type":"(.*?FunctionArguments")/gi):t.match(/"rasterFunction":"(.*?")/gi),s=r?.map(e=>i?e.slice(8,-18):e.slice(18,-1));return s?s.join("/"):null}const Be=Be=>{const ze=Be;let Le=class extends ze{constructor(){super(...arguments),this._functionRasterInfos={},this._serviceSupportsMosaicRule=null,this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new D({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach(t=>{e.set(t.name.toLowerCase().replaceAll(/ /gi,"_"),t.name)}),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every(e=>"number"==typeof e))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?c(()=>q.fromJSON(t)):null}get fieldsIndex(){return this.fields?new T(this.fields):null}set format(e){e&&Je.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}get isRenderedFormat(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t?.mosaicMethod&&(t=q.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?q.fromJSON(i):this._isMosaicRuleSupported(t)?q.fromJSON(t):null}writeMosaicRule(e,t,i){const{mosaicRule:r}=this;this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}readObjectIdField(e,t){if(!e){const i=t.fields.find(e=>"esriFieldTypeOID"===e.type||"oid"===e.type);e=i?.name}return e}get parsedUrl(){return o(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}get renderer(){const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){this.activePresetRendererName=null,this.internalRenderer=e}set internalRenderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("internalRenderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,s=ne(r,i);return null==s?null:("vector-field"===s.type&&t.symbolTileSize&&!r.symbolTileSize&&(s.symbolTileSize=t.symbolTileSize),M(s)||n.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),s)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON()}get rasterFields(){const e=this.fields?.map(e=>e.clone())??[];e.push(Q()),"mosaic-dataset"===this.sourceType&&this.fields?.length&&e.push(V()),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some(({name:e})=>"none"===e.toLowerCase())&&e.push(J()),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter(({name:e})=>"none"!==e.toLowerCase()).forEach(({name:t})=>e.push(U(t)));const{rasterInfo:t}=this;if(this._isVectorDataSet()){const i=t?.multidimensionalInfo?.variables[0].unit?.trim(),r=B(i),s=z();e.push(r,s)}if(t?.multidimensionalInfo&&"raster-dataset"===this.sourceType){const i=L(t.multidimensionalInfo);e.push(...i)}const i=t?.attributeTable;if(null!=i){const t=H(i);e.push(...t)}return e}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=$.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?$.fromJSON({rasterFunctionDefinition:t.renderingRule}):$.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?f.fromJSON(i):null}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=A.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e,{renderer:r,symbolizer:s,pixelFilter:n}=this;const{isRawData:a}=e;if(a&&"lerc"!==this.format&&(r??=K(this.rasterInfo,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}),s||(this.symbolizer=new ie({rendererJSON:r.toJSON(),rasterInfo:this.rasterInfo}),s=this.symbolizer)),(a||!this.isRenderedFormat)&&r&&s&&!n){await this._updateSymbolizer(s,r);const n=this.bandIds?.length?this.bandIds:Y(this.rasterInfo);i=await this._symbolize({pixelData:e,bandIds:n,symbolizer:s},t)}return i}destroy(){this._shutdownJobHandler()}async calculateVolume(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsCalculateVolume)throw new r("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=s(e),this.mosaicRule&&null==e.mosaicRule&&(e.mosaicRule=this.mosaicRule),ae(this.url,e,this._getRequestOptions(t))}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new r("imagery-layer:compute-angles","this operation is not supported on the input image service");return oe(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new r("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return le(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new r("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=s(e),this._applyMosaicAndRenderingRules(e),ue(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new r("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=s(e),this._applyMosaicAndRenderingRules(e),pe(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new r("imagery-layer:measure-height","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),me(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new r("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),ce(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new r("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),he(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new r("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),de(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new r("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new r("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return fe(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new r("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new r("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return ye(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async internalFetchImage(e,t,i,r={}){await this._updateCurrentRasterInfo();const{exportImageServiceParameters:s}=this;let n=!1;r.requestRawData&&(await this._initJobHandler(),s.requestRawData||"lerc"===this.format||(n=!0,s.requestRawData=!0));const a=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(n&&(s.requestRawData=!1,a&&!this.bandIds?.length&&(null==a.bandIds||""===a.bandIds))){const e=Y(this.rasterInfo);a.bandIds=e?.join(",")}if(null==a){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){const{bitmap:t}=await C(e,`${He(this.parsedUrl)}/exportImage`,r);return{imageBitmap:t}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(P.createEmptyBand(l,o));return{pixelData:{pixelBlock:new P({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const o=!!r.requestAsImageElement&&!this.pixelFilter,l=o&&!!r.returnImageBitmap,u={imageServiceParameters:a,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:o,returnImageBitmap:l,signal:r.signal};return this._requestArrayBuffer(u)}async fetchPixels(e,t,i,r={}){await this._initJobHandler(),r.applyRendering&&this._updateCurrentRasterInfo();const s=r.applyRendering?void 0:new D({layer:this,requestRawData:!0,interpolation:r.interpolation??"nearest",bandIds:r.bandIds??[]}),n=this.getExportImageServiceParameters(e,t,i,r.timeExtent,s);if(null==n)return{extent:e,pixelBlock:null};delete n.pixelType,r.bandIds||delete n.bandIds,delete n.compressionQuality;const a={imageServiceParameters:n,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:!1,returnImageBitmap:!1,signal:r.signal},{pixelData:o}=await this._requestArrayBuffer(a);return o??{extent:e,pixelBlock:null}}fetchKeyProperties(e){return i(He(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>e.data)}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new r("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):i(He(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>je.fromJSON(e.data))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return Ce(He(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:r}=await i(He(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),s=r?.ics;if(!s)return;let n=null;try{n=(await i(He(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!n?.spatialReference)return{ics:s,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?i(He(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then(e=>e.data).catch(()=>({})):{},o=n.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[n]}),inSR:y(o),outSR:"0:"+e},u=i(He(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then(e=>e.data).catch(()=>({})),p=5,m=(n.xmin+n.xmax)/2,c=(n.ymax-n.ymin)/(p+1),d=n.ymin+c,g=[];for(let i=0;i<p;i++)g.push({x:m,y:d+c*i});const R={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:g}),inSR:y(o),outSR:"0:"+e},I=i(He(this.parsedUrl)+"/project",{query:this._getQueryParams(R),...t}).then(e=>e.data).catch(()=>({})),w=await Promise.all([a,u,I]);let v=w[0].ipxf;if(null==v){const e=s.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(v={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=h.fromJSON(w[1]?.geometries?.[0]);b&&(b.spatialReference=new f({wkid:0,imageCoordinateSystem:s}));const x=w[2].geometries?w[2].geometries.filter(e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y):[],S=x.length;if(S<3)return{ics:s,icsToPixelTransform:v,icsExtent:b,northDirection:null};let F=0,_=0,D=0,O=0;for(let i=0;i<S;i++)F+=x[i].x,_+=x[i].y,D+=x[i].x*x[i].x,O+=x[i].x*x[i].y;const T=(S*O-F*_)/(S*D-F*F);let C=0;const M=x[p-1].x>x[0].x,q=x[p-1].y>x[0].y;return T===1/0?C=q?90:270:0===T?C=M?0:180:T>0?C=M?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(C=q?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:s,icsToPixelTransform:v,icsExtent:b,northDirection:C}}async generateRasterInfo(e,t){const i=m($,e),s={...t,query:this._getQueryParams()};if(!i||"none"===i.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(i))return this.serviceRasterInfo??De(He(this.parsedUrl),this.sourceJSON,s);const n=Ue(i);if(!n)throw new r("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[n])return this._functionRasterInfos[n];const a=Oe(He(this.parsedUrl),i,s);this._functionRasterInfos[n]=a;try{return await a}catch(o){throw this._functionRasterInfos[n]=null,o}}getExportImageServiceParameters(e,t,i,r,s){e=e.clone().shiftCentralMeridian();const n=ge(e.spatialReference,He(this.parsedUrl));s??=this.exportImageServiceParameters;const a=s.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const p=this.rasterFunction?.rasterFunctionDefinition,m=this.renderer?.type,c=!m||"raster-stretch"===m||"raster-colormap"===m||"unique-value"===m||"class-breaks"===m||"raster-shaded-relief"===m;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!p&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=o?.join(",");Array.isArray(l)&&l.length>0&&(a.noData=l.join(","));const h=this._processMultidimensionalIntersection(null,r,s.mosaicRule);if(h.isOutSide)return null;a.mosaicRule=null!=h.mosaicRule?JSON.stringify(h.mosaicRule):null,r=h.timeExtent,a.renderingRule=this._getRenderingRuleString($.fromJSON(u));const d={};if(null!=r){const{start:e,end:t}=r.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:n,imageSR:n,size:t+","+i,...a,...d}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new r("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=s(e);const{raster:n}=this;return n&&null==e.raster&&(e.raster=n),Re(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new r("imagery-layer:identify","identify operation is not supported on the input image service");e=s(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=d.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new r("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:n,rasterFunction:a}=this;return a&&null==e.rasterFunction&&(e.rasterFunction=a),n&&null==e.raster&&(e.raster=n),Ie(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new r("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return we(He(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new r("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return ve(He(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new r("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return be(He(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new r("imagery-layer:find-images","findImages operation is not supported on the input image service");return xe(He(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new r("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return Se(He(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ae({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new r("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},Fe(He(this.parsedUrl),e,this._getRequestOptions(t))}async queryExtent(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const{where:i,objectIds:r,geometry:s,timeExtent:n,start:a,num:o,pixelSize:l}=e,u=null!=i&&"1=1"!==i,p=null!=r&&r.length>0,m=null!=s&&("extent"!==s.type||!s.equals(this.fullExtent)),c=null!=l,h=null!=a||null!=o,{timeInfo:d}=this,f=null!=n&&null!=d&&!n.equals(d.fullTimeExtent);if(!(u||p||m||c||f||h)){const i=await Me(this.url,e,t),{outSpatialReference:r}=e;if(!r||r.equals(this.spatialReference))return{count:i,extent:this.fullExtent.clone()};const s=await import("../../geometry/operators/projectOperator.js");await s.load();return{count:i,extent:s.execute(this.fullExtent,r)}}return qe(this.url,e,t)}async queryRasters(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const i=await Pe(this.url,e,t),r=this.graphicOrigin;return i.features.forEach(e=>{e.layer=this,e.origin=r}),i}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ne(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new r("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},_e(He(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Me(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new r("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:s,returnTopmostRaster:n,showNoDataRecords:a}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p=k.servicePixelValue.toLowerCase(),m=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some(e=>!e.toLowerCase().startsWith(p)),this.version>=10.4)){const t=e.outFields.filter(e=>e.toLowerCase().startsWith(p)&&e.length>p.length).map(e=>{const t=e.slice(p.length+1);return[this._updateRenderingRulesFunctionName(t,m),t]});l=t.map(e=>new $({functionName:e[0]})),u=t.map(e=>e[1]);const{rasterFunction:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some(e=>e.functionName===i.functionName)&&(l.push(i),u.push(i.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:h}=this;let f=e.timeExtent||this.timeExtent;if(h){const{isOutside:t,intersection:i}=g(h,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new r("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=i?.timeExtent&&(f=i.timeExtent)}const y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f);let I=e.geometry;this.version<10.91&&"extent"===I?.type&&(I=d.fromExtent(I));const w=this._getQueryParams({geometry:I,timeExtent:f,mosaicRule:y,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:n?1:null});delete w.f;const v=new Ee(w);try{await this._generateRasterInfo(this.rasterFunction);const i=await Ie(this.url,v,{signal:t?.signal,query:{...this.customParameters}}),r=e.outFields,n=null!=i.value&&i.value.toLowerCase().includes("nodata"),l=o&&!c&&i?.catalogItems?.features.length&&(a||!n),p=this.multidimensionalInfo&&"raster-dataset"===this.sourceType?R({rasterInfo:this.rasterInfo,multidimensionalDefinition:y?.multidimensionalDefinition,timeExtent:f,multidimensionalSubset:this.multidimensionalSubset}):null;if(!l)return this._processVisibleRastersResponse(i,{returnDomainValues:s,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:r,effectiveMultidimensionalDefinition:p});const m=this.objectIdField||"ObjectId",h=i.catalogItems?.features??[],d=h.map(e=>e.attributes?.[m]),g=new Ae({objectIds:d,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[m]}),I=await this.queryRasters(g);return I?.features?.length&&I.features.forEach(t=>{h.forEach(i=>{i.attributes[m]===t.attributes[m]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))})}),this._processVisibleRastersResponse(i,{returnDomainValues:s,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:r,effectiveMultidimensionalDefinition:p})}catch{throw new r("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=i(He(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.statistics),s=i(He(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.histograms),n=await Promise.all([r,s]);return n[0]&&n[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),{statistics:n[0]||null,histograms:n[1]||null}}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return I(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):De(He(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then(e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),Te(e,t),e)),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then(e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.internalRenderer&&!this._isSupportedRenderer(this.internalRenderer)&&(this._set("internalRenderer",null),n.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("internalRenderer",this._configRenderer(this.renderer)),this.addHandles([a(()=>this.rasterFunction,e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then(e=>{e&&(this.rasterInfo=e)})})]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)})}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==i?.startField)return e;const{startField:s}=i,n=r.variables.some(e=>e.dimensions.some(e=>e.name===s))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter(e=>e.dimensionName!==n),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const a=e.multidimensionalDefinition.filter(e=>e.dimensionName===n),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],m=this.version>=10.8;if(a.length)a.forEach(e=>{e.dimensionName===n&&(m?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))});else if(!m){const t=e.multidimensionalDefinition.filter(e=>null!=e.variableName&&null==e.dimensionName);t.length?t.forEach(e=>{e.dimensionName=n,e.isSlice=u,e.values=p}):e.multidimensionalDefinition.push(new _({variableName:"",dimensionName:n,isSlice:u,values:p}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return null==e?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter(e=>!(!e.variableName&&!e.dimensionName)),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this.sourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQuery)throw new r("imagery-layer:query-rasters","query operation is not supported on the input image service");const i=null!=e?m(Ae,e):this.createQuery();return t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:i,requestOptions:t}}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&Z(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:s}=await i(He(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,s&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map(e=>e.trim()).indexOf("tilesonly")>-1)throw new r("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_configRenderer(e){const{rasterInfo:t}=this;if(!this.isRenderedFormat&&!this.pixelFilter||this._isVectorDataSet()){const i=this.mosaicRule?.multidimensionalDefinition?.[0].variableName,r=ee({variableName:i,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>=3){const e=r?.bandIds??Y(t);!e||3===t.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=r?.renderer??K(t,{bandIds:this.bandIds,variableName:this.rasterFunction?null:i}));const s=te(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=s,this.symbolizer.rasterInfo=t):this.symbolizer=new ie({rendererJSON:s,rasterInfo:t}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=e?.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler?this._rasterJobHandler.decode({data:e,options:t}):v(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const r=await i(He(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return r.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:s,returnImageBitmap:n,signal:a}=e;if(s&&this._canRequestImageElement(t.format)){const r=`${He(this.parsedUrl)}/exportImage`,{data:s}=await i(r,{responseType:n?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:a});if(s instanceof Blob){const{bitmap:e}=await C(s,r,{signal:a});return{imageBitmap:e,params:t}}return{imageOrCanvasElement:s,params:t}}const o=this._initJobHandler(),l=i(He(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:a}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let m=p;if("bsq"!==m&&"bip"!==m&&(m=b(u)),!m)throw new r("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:a},h=this._decodePixelBlock(u,{width:t.width,height:t.height,format:p,applyJpegMask:!0},c);return{pixelData:{pixelBlock:await h,extent:t.extent},params:t}}_generateRasterInfo(e,t){return this.generateRasterInfo(e,t).catch(()=>null)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=w(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new q;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.functionName?.toLowerCase()&&t.forEach(e=>e.variableName=""),t=t.filter(({variableName:e,dimensionName:t})=>e&&"*"!==e||t),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map(e=>e.replaceAll(/ /gi,", "))||[];const m=this.objectIdField||"ObjectId",c="string"==typeof r&&r.toLowerCase().includes("nodata"),h=[];if(r&&!u&&(!c||n)){const e={};e[m]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})],this.multidimensionalInfo&&"raster-dataset"===this.sourceType&&G(this.rasterFields,e,i.effectiveMultidimensionalDefinition)}if(!u)return[];this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);const{itemPixelValue:d,servicePixelValue:f}=k,y=this.rasterFields.some(e=>e.name===d),g=this.graphicOrigin;for(let t=0;t<u.length;t++){const e=u[t];if(null!=r){const i=p[t],a=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r;if("nodata"===i.toLowerCase()&&!n)continue;y&&(e.attributes[d]=i),e.attributes[f]=a,this._updateFeatureWithMagDirValues(e,i);const o=this.fields&&this.fields.length>0;let u=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?i:r:a;this.rasterFunction||(u=o?i:r),this._updateFeatureWithRasterAttributeTableValues(e,u)}if(e.sourceLayer=e.layer=this,e.origin=g,a&&this._updateFeatureWithDomainValues(e),s&&l&&s.length===l.length)for(let t=0;t<s.length;t++){const i=`${k.servicePixelValue}.${s[t]}`;e.attributes[i]=l[t]}h.push(u[t])}return h}_processMultidimensionalIntersection(e,t,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=g(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=g(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==i)return;const{features:r,fields:s}=i,n=s.map(e=>e.name).find(e=>"value"===e.toLowerCase());if(!n)return;const a=r.filter(e=>e.attributes[n]===(null!=t?parseInt(t,10):null));a&&a[0]&&s.forEach(t=>{const i=W+t.name;e.attributes[i]=a[0].attributes[t.name]})}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map(e=>parseFloat(e)),r=i.map(e=>[e]),s=i.map(e=>({minValue:e,maxValue:e,noDataValue:null})),n=new P({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new h(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:x([n.pixels[0][0],n.pixels[1][0]]);e.attributes[k.magnitude]=a[0],e.attributes[k.direction]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter(e=>"coded-value"===e.domain?.type);null!=t&&t.forEach(t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find(e=>e.code===i);r&&(e.attributes[t.name]=r.name)}})}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach(e=>{if(e?.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}})}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return null!=e?.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e?.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,rasterFunction:r}=this;r&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}async _updateCurrentRasterInfo(e){if(this.renderer||this.symbolizer){const t=await this._generateRasterInfo(this.rasterFunction,{signal:e});t&&(this.rasterInfo=t)}}_applyMosaicRule(e){const{raster:t,mosaicRule:i}=this;i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map(e=>e.trim()):["image","catalog"],{currentVersion:i,maxRecordCount:r}=e,s=t.includes("image"),n="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),o=t.includes("edit"),l=t.includes("mensuration")&&a,u=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map(e=>e.trim()),p=l&&u.includes("basic"),m=this._isMosaicDataset(e)&&t.includes("catalog"),c=t.includes("download"),h=i>=10.7&&n||i>=11.4&&(n||l&&u.includes("3d")),d=m&&e.fields&&e.fields.length>0,f=d&&e.supportsAdvancedQueries?e.advancedQueryCapabilities:void 0;return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:s,supportsExportImage:s,supportsIdentify:s,supportsImageToMap:i>=11.2&&m,supportsImageToMapMultiray:i>=11.2&&m,supportsMapToImage:i>=11.2&&m,supportsFindImages:i>=11.2&&m,supportsGetImageUrl:i>=11.3&&c,supportsMeasure:l,supportsMeasureFromImage:i>=11.2,supportsDownload:c,supportsQuery:d,supportsGetSamples:i>=10.2&&s,supportsProject:i>=10.3&&s,supportsComputeStatisticsHistograms:i>=10.4&&s,supportsQueryBoundary:i>=10.6&&s,supportsCalculateVolume:h,supportsComputePixelLocation:i>=10.7&&m,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&m,supportsAdd:o,supportsDelete:o,supportsEditing:o,supportsUpdate:o,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:r,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,supportsStatistics:!!f?.supportsStatistics,supportsOrderBy:!!f?.supportsOrderBy,supportsDistinct:!!f?.supportsDistinct,supportsPagination:!!f?.supportsPagination,supportsPaginationOnAggregatedQueries:!!f?.supportsPaginationOnAggregatedQueries,supportsStandardizedQueriesOnly:!!f?.useStandardizedQueries,supportsPercentileStatistics:!!f?.supportsPercentileStatistics,supportsCentroid:!!f?.supportsReturningGeometryCentroid,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDistance:!!f?.supportsQueryWithDistance,supportsExtent:!!f?.supportsReturningQueryExtent,supportsGeometryProperties:!!f?.supportsReturningGeometryProperties,supportsHavingClause:!!f?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:f?.supportsSqlExpression??!!f,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!f?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,tileMaxRecordCount:void 0,supportsTrueCurve:!1},mensuration:{supportsDistanceAndAngle:p,supportsAreaAndPerimeter:p,supportsPointOrCentroid:p,supportsHeightFromBaseAndTop:l&&u.includes("base-top height"),supportsHeightFromBaseAndTopShadow:l&&u.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:l&&u.includes("top-top shadow height"),supports3D:l&&u.includes("3d")}}}};function He(e){return e?.path??""}return e([l({clonable:!1})],Le.prototype,"_functionRasterInfos",void 0),e([l({readOnly:!0})],Le.prototype,"_serviceSupportsMosaicRule",void 0),e([Qe("_serviceSupportsMosaicRule",["currentVersion","fields"])],Le.prototype,"readServiceSupportsMosaicRule",null),e([l({readOnly:!0})],Le.prototype,"_rasterFunctionNamesIndex",null),e([l()],Le.prototype,"adjustAspectRatio",void 0),e([l({type:[p],json:{write:!0}})],Le.prototype,"bandIds",void 0),e([Qe("bandIds")],Le.prototype,"readBandIds",null),e([l({readOnly:!0,json:{read:!1}})],Le.prototype,"capabilities",void 0),e([Qe("service","capabilities",["capabilities","currentVersion","serviceDataType"])],Le.prototype,"readCapabilities",null),e([l({type:Number})],Le.prototype,"compressionQuality",void 0),e([Ve("compressionQuality")],Le.prototype,"writeCompressionQuality",null),e([l({type:Number})],Le.prototype,"compressionTolerance",void 0),e([Ve("compressionTolerance")],Le.prototype,"writeCompressionTolerance",null),e([l({json:{read:{source:"copyrightText"}}})],Le.prototype,"copyright",void 0),e([l({readOnly:!0})],Le.prototype,"defaultMosaicRule",void 0),e([Qe("defaultMosaicRule",["defaultMosaicMethod"])],Le.prototype,"readDefaultMosaicRule",null),e([l({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Le.prototype,"definitionExpression",void 0),e([l({readOnly:!0,constructOnly:!0})],Le.prototype,"exportImageServiceParameters",void 0),e([l()],Le.prototype,"rasterInfo",void 0),e([l({readOnly:!0,type:[O]})],Le.prototype,"fields",void 0),e([l({readOnly:!0})],Le.prototype,"fieldsIndex",null),e([l({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff","bip","bsq"],json:{write:!0}})],Le.prototype,"format",null),e([Qe("service","format",["serviceDataType"])],Le.prototype,"readFormat",null),e([l({type:h})],Le.prototype,"fullExtent",void 0),e([l({readOnly:!0})],Le.prototype,"hasMultidimensions",void 0),e([l({json:{read:{source:"maxImageHeight"}}})],Le.prototype,"imageMaxHeight",void 0),e([l({json:{read:{source:"maxImageWidth"}}})],Le.prototype,"imageMaxWidth",void 0),e([l({type:String,json:{type:j.jsonValues,read:j.read,write:j.write}})],Le.prototype,"interpolation",void 0),e([l()],Le.prototype,"minScale",void 0),e([Qe("service","minScale")],Le.prototype,"readMinScale",null),e([l()],Le.prototype,"maxScale",void 0),e([Qe("service","maxScale")],Le.prototype,"readMaxScale",null),e([l({type:q})],Le.prototype,"mosaicRule",null),e([Qe("mosaicRule",["mosaicRule","defaultMosaicMethod"])],Le.prototype,"readMosaicRule",null),e([Ve("mosaicRule")],Le.prototype,"writeMosaicRule",null),e([l()],Le.prototype,"multidimensionalInfo",void 0),e([l({type:N,json:{write:!0}})],Le.prototype,"multidimensionalSubset",void 0),e([l({json:{type:[Number,[Number]],write:!0}})],Le.prototype,"noData",void 0),e([l({type:String,json:{type:E.jsonValues,read:E.read,write:E.write}})],Le.prototype,"noDataInterpretation",void 0),e([l({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],Le.prototype,"objectIdField",void 0),e([Qe("objectIdField")],Le.prototype,"readObjectIdField",null),e([l({readOnly:!0})],Le.prototype,"geometryType",void 0),e([l({})],Le.prototype,"typeIdField",void 0),e([l({})],Le.prototype,"types",void 0),e([l({readOnly:!0})],Le.prototype,"parsedUrl",null),e([l({type:Function})],Le.prototype,"pixelFilter",void 0),e([l()],Le.prototype,"raster",void 0),e([l({readOnly:!0})],Le.prototype,"sourceType",void 0),e([Qe("sourceType",["serviceSourceType","fields"])],Le.prototype,"readSourceType",null),e([l()],Le.prototype,"viewId",void 0),e([l({types:re})],Le.prototype,"renderer",null),e([l({types:re,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:se,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],Le.prototype,"internalRenderer",null),e([Qe("internalRenderer")],Le.prototype,"readRenderer",null),e([Ve("internalRenderer")],Le.prototype,"writeRenderer",null),e([l({clonable:!1})],Le.prototype,"symbolizer",void 0),e([l(S)],Le.prototype,"opacity",void 0),e([l({readOnly:!0})],Le.prototype,"rasterFields",null),e([l({constructOnly:!0})],Le.prototype,"rasterFunctionInfos",void 0),e([l({type:$,json:{name:"renderingRule"}})],Le.prototype,"rasterFunction",null),e([Qe("rasterFunction",["renderingRule","rasterFunctionInfos"])],Le.prototype,"readRasterFunction",null),e([l({readOnly:!0})],Le.prototype,"serviceDataType",void 0),e([l({readOnly:!0,type:f})],Le.prototype,"spatialReference",void 0),e([Qe("spatialReference",["spatialReference","extent"])],Le.prototype,"readSpatialReference",null),e([l({type:A.apiValues,json:{read:A.read,type:A.jsonValues}})],Le.prototype,"pixelType",void 0),e([Ve("pixelType")],Le.prototype,"writePixelType",null),e([l({constructOnly:!0,type:X})],Le.prototype,"serviceRasterInfo",void 0),e([l()],Le.prototype,"sourceJSON",void 0),e([l(F)],Le.prototype,"url",void 0),e([l({readOnly:!0})],Le.prototype,"version",void 0),e([Qe("version",["currentVersion","fields","timeInfo"])],Le.prototype,"readVersion",null),Le=e([u("esri.layers.mixins.ArcGISImageService")],Le),Le};export{Be as ArcGISImageService};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import i from"../../core/Logger.js";import{property as n,subclass as s}from"../../core/accessorSupport/decorators.js";import{Integer as o,ensureClass as a}from"../../core/accessorSupport/ensureType.js";import l from"../../geometry/Point.js";import u from"../../geometry/SpatialReference.js";import{getInfo as c}from"../../geometry/support/spatialReferenceUtils.js";import{isFunctionRaster as m}from"../raster/datasets/datasetUtils.js";import d from"../raster/datasets/FunctionRaster.js";import{getEffectiveMultidimensionalDefinition as p,getDefaultVariableInfo as h,isMultiSliceOrRangeDefinition as f,convertOleDateTimeToEpoch as y,getSubsetVariablesFromMdInfo as g,getDefaultMultidimensionalDefinition as R}from"../raster/datasets/multidimensionalUtils.js";import{snapToRaster as b,clip as I}from"../raster/functions/clipUtils.js";import{create as w}from"../raster/functions/rasterFunctionHelper.js";import{load as x,projectExtent as S,projectPolygon as _}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as F}from"../raster/functions/stretchUtils.js";import{sanitizeUrl as v}from"../support/arcgisLayerUrl.js";import{url as J}from"../support/commonProperties.js";import j from"../support/DimensionalDefinition.js";import D from"../support/MultidimensionalSubset.js";import{interpolationKebab as N}from"../support/rasterEnums.js";import T from"../support/RasterFunction.js";import H from"../support/RasterJobHandler.js";import C from"../support/TileInfo.js";import{getVariableRasterInfo as O,getDefaultInterpolation as z,matchPresetRenderer as P,getDefaultBandCombination as E,getFunctionColorRamp as B,createDefaultRenderer as M,normalizeRendererJSON as A}from"../../renderers/support/rasterRendererHelper.js";import U from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as q,websceneRasterRendererTypes as k,read as L}from"../../renderers/support/rasterTypeUtils.js";import V from"../../rest/support/ImageHistogramParameters.js";import $ from"../../rest/support/ImageSample.js";import G from"../../rest/support/ImageSampleParameters.js";import W from"../../rest/support/ImageSampleResult.js";import{enumeration as K}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as Q}from"../../core/accessorSupport/decorators/reader.js";const X=1e3,Y=Y=>{const Z=Y;let ee=class extends Z{constructor(...e){super(...e),this._draRasterConfig=null,this._isConstructedFromFunctionRaster=!1,this.bandIds=null,this.copyright=null,this.interpolation=null,this.multidimensionalSubset=null,this.raster=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster=m(e[0]?.raster)}destroy(){this._draRasterConfig?.rasterJobHandler?.destroy(),this._shutdownJobHandler()}get fullExtent(){return this.serviceRasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}set rasterFunction(e){"none"===e?.functionName?.toLowerCase()&&(e=void 0),this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",v(e,i.getLogger(this)))}get renderer(){if("imagery-tile"!==this.type)return this.internalRenderer;const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const r=t?.find(({name:t})=>t===e);return r?.renderer.clone()}return this.internalRenderer}set renderer(e){"imagery-tile"===this.type&&(this.activePresetRendererName=null),this.internalRenderer=e}set internalRenderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("internalRenderer",e),this.updateRenderer())}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;return L(i,r)||void 0}async computeStatisticsHistograms(e,t){await this.load(t),e=a(V,e).clone();const{serviceRasterInfo:i}=this;if(null==i)throw new r("imagery-tile-mixin:compute-statistics-histograms","serviceRasterInfo must be specified");const{geometry:n}=e;if(null==n)throw new r("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let s=n;const{spatialReference:o}=i;if(!n.spatialReference.equals(o)){await x();const e="extent"===n.type?S(n,o):_(n,o);if(null==e)throw new r("imagery-tile-mixin:compute-statistics-histograms","geometry cannot be projected to the data source");s=e}const u=e.pixelSize??new l({x:i.pixelSize.x,y:i.pixelSize.y,spatialReference:o}),{extent:c,width:m,height:d}=b(i,s,u),p=await this.fetchPixels(c,m,d,{...t,interpolation:"nearest"});if(null==p.pixelBlock)throw new r("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await I(p.pixelBlock,c,s),f=this._rasterJobHandler;return f?f.computeStatisticsHistograms({pixelBlock:h},t):F(h)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.serviceRasterInfo??{};if(null==t)return e;const r=p({rasterInfo:this.raster.rasterInfo,multidimensionalDefinition:e.multidimensionalDefinition||this.multidimensionalDefinition,timeExtent:e.timeExtent??this.timeExtent,multidimensionalSubset:this.multidimensionalSubset});return{...e,multidimensionalDefinition:r,timeExtent:void 0}}async updateRasterFunction(){return this.loaded&&"imagery-tile"===this.type&&(this.rasterFunction||this._cachedRasterFunctionJson)&&JSON.stringify(this.rasterFunction)!==JSON.stringify(this._cachedRasterFunctionJson)?(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this._rasterFunctionUpdatePromise=this._updateRasterFunction(),this._rasterFunctionUpdatePromise):this._rasterFunctionUpdatePromise}async updateRenderer(){const{loaded:e,symbolizer:t,renderer:r}=this;if(!e||!t||!r)return;const{rasterInfo:i}=this.raster,n=h(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=n?.name,o=O(i,s);return this._updateSymbolizer(t,r,s,o)}async applyRenderer(e,t,r){const i=e?.pixelBlock;if(!(null!=i&&i.pixels&&i.pixels.length>0))return null;await this.updateRenderer();const n=this.bandIds??[],{pixelBlock:s}=await this._symbolize({pixelData:e,simpleStretchParams:t,bandIds:n,symbolizer:this.symbolizer},r);return s}getRawDisplayBandIds(){let{bandIds:e,raster:t}=this;if(this.rasterFunction&&m(t)){const r=t.rasterFunction.rawInputBandIds;e=e?.length&&r?.length&&1!==t.rasterInfo.bandCount?e.map(e=>r[Math.min(e,r.length-1)]):r}return e&&e.length>3&&e.every((e,t)=>e===t)?null:e}getTileUrl(e,t,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${r}`:""}getCompatibleTileInfo(e,t,r=!1){if(!this.loaded||null==t)return null;if(r&&e.equals(this.spatialReference))return this.tileInfo;const i=c(e);return C.create({size:256,spatialReference:e,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent?.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,r,i,n={}){if(te(this),n.requestAsImageElement){const s=this.getTileUrl(e,r,i);return t(s,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:n.signal}).then(e=>e.data)}const{serviceRasterInfo:s}=this;if(null!=s.multidimensionalInfo&&null==(n=this.normalizeRasterFetchOptions(n)).multidimensionalDefinition){const t=n.tileInfo||s.storageInfo.tileInfo,o=this.raster.getTileExtentFromTileInfo(e,r,i,t);if(o)return{extent:o,pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(n={...n,buffer:{cols:1,rows:1}}),n={...n,refreshParameters:this.refreshParameters},this.raster.fetchTile(e,r,i,n)}async fetchPixels(e,t,r,i={}){if(null!=this.serviceRasterInfo.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition)return{extent:e,pixelBlock:null};await this._initJobHandler(),await this.updateRasterFunction(),t=Math.round(t),r=Math.round(r);const n=await this.raster.fetchPixels(e,t,r,i);return i.bandIds?.length&&!this.raster.rasterInfo.storageInfo.isBsqTile&&(n.pixelBlock=n.pixelBlock?.extractBands(i.bandIds)),n}async getSamples(e,t){await this.load();const i=a(G,e).clone();if(i.interpolation&&"nearest"!==i.interpolation)throw new r("imagery-tile-mixin:get-samples","only nearest interpolation is currently supported");const n=i.mosaicRule?.multidimensionalDefinition,s={...t,multidimensionalDefinition:n},o=(await this._getSampleLocations(i)).map(e=>this.identify(e,s).then(t=>(t.location=e,t))),l=(await Promise.all(o)).flatMap((e,t)=>this._convertRasterIdentifyResultToSample(e,t));return new W({samples:l})}async identify(e,t={}){await this.load();const i=a(l,e).clone().normalize(),{raster:n,serviceRasterInfo:s}=this;if(null!=s?.multidimensionalInfo){if(!(s.hasMultidimensionalTranspose&&!(!f(t.multidimensionalDefinition)&&!t.transposedVariableName))&&null==(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition)return{location:i,value:null}}const o=this.multidimensionalSubset?.areaOfInterest;if(o&&!o.contains(i))throw new r("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");let u;if(this.serviceRasterInfo?.storageInfo.isBsqTile){const e=m(n)?this.getRawDisplayBandIds():this.bandIds;u=e?.length?e:void 0}return n.identify(i,{...t,bandIds:u})}hasStandardTime(){const e=this.serviceRasterInfo?.multidimensionalInfo;if(null==e||"standard-time"!==this.serviceRasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,r=t?.[0]?.variableName;return e.variables.some(e=>e.name===r&&(!t?.[0].dimensionName||e.dimensions.some(e=>"StdTime"===e.name)))}getStandardTimeValue(e){return new Date(y(e)).toISOString()}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo?.multidimensionalInfo;return g(this.multidimensionalSubset,t)}async getDynamicRangeInputRaster(){if(!this.rasterFunction||!m(this.raster)||!this._cachedRasterFunctionJson)return null;const e=JSON.stringify(this._cachedRasterFunctionJson);if(this._draRasterConfig?.functionJson===e)return this._draRasterConfig;const t=this.raster.rasterFunction.queryRasterFunction(e=>"Stretch"===e.functionName&&e.functionArguments.dynamicRangeAdjustment);if(!t)return null;const r=t.toJSON(),i=this.raster.primaryRasters.rasters,n=t.functionArguments.raster,s=r.rasterFunctionArguments;if(!n||"object"!=typeof n||!("functionName"in n))return this._draRasterConfig={functionJson:e,raster:i[0],functionArguments:s,rasterJobHandler:this._draRasterConfig?.rasterJobHandler},this._draRasterConfig;const o={raster:i[0]};i.length>1&&i.forEach(e=>o[e.url]=e);const a=w(n.toJSON(),o),l=new d({rasterFunction:a});await l.open();let u=this._draRasterConfig?.rasterJobHandler;try{u||(u=new H,await u.initialize()),l.rasterJobHandler=u,await l.syncJobHandler()}catch{}return this._draRasterConfig={functionJson:e,raster:l,functionArguments:s,rasterJobHandler:u},this._draRasterConfig}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=R(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&m(this.raster)&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}async _initJobHandler(){if(!this._rasterJobHandler)return super._initJobHandler().then(async()=>{if(!this._rasterJobHandler)return;te(this);const{raster:e}=this;e.rasterJobHandler=this._rasterJobHandler,m(e)&&e.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch(()=>{}),this.renderer&&this.updateRenderer()}).catch(()=>{})}_shutdownJobHandler(){super._shutdownJobHandler(),this.raster&&(this.raster.rasterJobHandler=null)}async _getSampleLocations(e){const{geometry:t}=e;if("point"===t.type)return[t];const{spatialReference:r,type:i}=t;if("multipoint"===i)return t.points.map(e=>new l({x:e[0],y:e[1],spatialReference:r}));if("polyline"===i){let i=t;if(e.sampleCount||e.sampleDistance){const r=await import("../../geometry/operators/densifyOperator.js"),n=(await import("../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"}),s=Math.min(e.sampleCount||100,X);let o=e.sampleDistance;if(!o){o=n/(s+(2===i.paths[0].length?1:0))}i=r.execute(t,o,{unit:"meters"})}return i.paths.flatMap(e=>e.map(e=>new l({x:e[0],y:e[1],spatialReference:r})))}const n=Math.min(e.sampleCount||100,X),s="extent"===t.type,o=s?t:t.extent,a=Math.sqrt(o.width*o.height/n),u=o.height/a,c=o.width/a,{xmin:m,ymax:d}=o,p=[];for(let h=0;h<u;h++)for(let e=0;e<c;e++){const i=new l({x:m+(e+.5)*a,y:d-(h+.5)*a,spatialReference:r});(s||t.contains(i))&&p.push(i)}return p}_configDefaultInterpolation(){if(null==this.interpolation){te(this);const{raster:e}=this,t=z(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){te(this);const{rasterInfo:t}=this.raster,r=h(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=r?.name,s=P({variableName:n,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>1&&(this.bandIds=s?.bandIds??E(t)),!this.renderer||"override"===e){const e=B(this.raster),r=s?.renderer??M(t,{bandIds:this.bandIds,variableName:n,rasterFunctionColorRamp:e}),i=t.statistics,o=i&&i.length>0?i[0]:null,a=o?.max??0,l=o?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===r.type&&(a>1e24||l<-1e24)&&(r.dynamicRangeAdjustment=!0,r.customStatistics=null,"none"===r.stretchType&&(r.stretchType="min-max")),this.renderer=r}const o=A({...this.renderer.toJSON(),variableName:n}),a=O(t,n);this.symbolizer?(this.symbolizer.rendererJSON=o,this.symbolizer.rasterInfo=a):this.symbolizer=new U({rendererJSON:o,rasterInfo:a});const l=this.symbolizer.bind();if(l.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if(null!=e&&"raster-colormap"===t.type){const e=M(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,r=t.customStatistics?.length;!t.dynamicRangeAdjustment&&r&&e&&r!==e&&this._configDefaultRenderer("override")}}}else i.getLogger(this).warn("imagery-tile-mixin",l.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}async _updateRasterFunction(){if(this._isConstructedFromFunctionRaster&&m(this.raster)){const e=this.raster.rasterFunction.toJSON();return void(!this.rasterFunction&&e&&this._set("rasterFunction",T.fromJSON(e)))}let e,t=this.raster,r=!1;m(t)?(e=t.primaryRasters.rasters,t=e[0],r=!0):e=[t];const{rasterFunction:i}=this;if(i){const r={raster:t};e.length>1&&e.forEach(e=>r[e.url]=e);const n=w(i.functionDefinition?.toJSON()??i.toJSON(),r),s=new d({rasterFunction:n});s.rasterJobHandler=this._rasterJobHandler,await s.open(),this.raster=s}else this.raster=t,await t.open();if(this._cachedRendererJson=void 0,!r&&!i)return;const{bandIds:n}=this,{bandCount:s}=this.raster.rasterInfo,o=n?.length?n.some(e=>e>=s):s>=3;n&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}_convertRasterIdentifyResultToSample(e,t){const{rasterInfo:r}=this.raster,i=r.storageInfo.pyramidScalingFactor**(e.pyramidLevel??0),n=(r.pixelSize.x+r.pixelSize.y)/2*i;if(!e.dataSeries?.length)return[new $({location:e.location,pixelValue:e.value,locationId:t,resolution:n})];const s=[];return e.dataSeries.forEach(({value:r,multidimensionalDefinition:i},o)=>{const a={Variables:i[0].variableName,Dimensions:i.flatMap(({dimensionName:e})=>e).join(",")};for(const{dimensionName:e,values:t}of i){a[e]=Array.isArray(t[0])?t[0][0]:t[0];const r=t[t.length-1];a[`${e}_Max`]=Array.isArray(r)?r[r.length-1]:r}const l=new $({location:e.location,pixelValue:r,rasterId:o,locationId:t,resolution:n,attributes:a});s.push(l)}),s}};function te(e){if(!e.raster||!e.serviceRasterInfo)throw new r("imagery-tile","no raster")}return e([n({clonable:!1})],ee.prototype,"_cachedRasterFunctionJson",void 0),e([n({clonable:!1})],ee.prototype,"_compatibleFullExtent",void 0),e([n({clonable:!1})],ee.prototype,"_draRasterConfig",void 0),e([n({clonable:!1})],ee.prototype,"_isConstructedFromFunctionRaster",void 0),e([n({clonable:!1})],ee.prototype,"_rasterFunctionUpdatePromise",void 0),e([n({type:[o],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],ee.prototype,"bandIds",void 0),e([n({json:{origins:{service:{read:{source:"copyrightText"}}}}})],ee.prototype,"copyright",void 0),e([n({json:{read:!1}})],ee.prototype,"fullExtent",null),e([n({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),K(N)],ee.prototype,"interpolation",void 0),e([n()],ee.prototype,"ioConfig",void 0),e([n({type:[j],json:{write:!0}})],ee.prototype,"multidimensionalDefinition",null),e([n({type:D,json:{write:!0}})],ee.prototype,"multidimensionalSubset",void 0),e([n()],ee.prototype,"raster",void 0),e([n({type:T})],ee.prototype,"rasterFunction",null),e([n()],ee.prototype,"serviceRasterInfo",void 0),e([n()],ee.prototype,"sourceJSON",void 0),e([n({readOnly:!0,type:u,json:{read:!1}})],ee.prototype,"spatialReference",void 0),e([n({type:C})],ee.prototype,"tileInfo",void 0),e([n(J)],ee.prototype,"url",null),e([n({types:q})],ee.prototype,"renderer",null),e([n({types:q,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:k,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],ee.prototype,"internalRenderer",null),e([Q("internalRenderer")],ee.prototype,"readRenderer",null),e([n({clonable:!1})],ee.prototype,"symbolizer",void 0),ee=e([s("esri.layers.mixins.TiledImagery")],ee),ee};export{Y as TiledImagery};
2
+ import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import i from"../../core/Logger.js";import{property as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{Integer as o,ensureClass as a}from"../../core/accessorSupport/ensureType.js";import l from"../../geometry/Point.js";import u from"../../geometry/SpatialReference.js";import{getInfo as m}from"../../geometry/support/spatialReferenceUtils.js";import{isFunctionRaster as c}from"../raster/datasets/datasetUtils.js";import d from"../raster/datasets/FunctionRaster.js";import{getEffectiveMultidimensionalDefinition as p,getDefaultVariableInfo as h,isMultiSliceOrRangeDefinition as f,convertOleDateTimeToEpoch as y,getSubsetVariablesFromMdInfo as g,getDefaultMultidimensionalDefinition as R}from"../raster/datasets/multidimensionalUtils.js";import{snapToRaster as b,clip as I}from"../raster/functions/clipUtils.js";import{create as w}from"../raster/functions/rasterFunctionHelper.js";import{load as x,projectExtent as S,projectPolygon as F}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as _}from"../raster/functions/stretchUtils.js";import{sanitizeUrl as v}from"../support/arcgisLayerUrl.js";import{url as J}from"../support/commonProperties.js";import j from"../support/DimensionalDefinition.js";import{createTileBitmap as D}from"../support/imageBitmapUtils.js";import N from"../support/MultidimensionalSubset.js";import{interpolationKebab as T}from"../support/rasterEnums.js";import H from"../support/RasterFunction.js";import C from"../support/RasterJobHandler.js";import O from"../support/TileInfo.js";import{getVariableRasterInfo as P,getDefaultInterpolation as z,matchPresetRenderer as E,getDefaultBandCombination as B,getFunctionColorRamp as U,createDefaultRenderer as M,normalizeRendererJSON as A}from"../../renderers/support/rasterRendererHelper.js";import q from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as k,websceneRasterRendererTypes as L,read as V}from"../../renderers/support/rasterTypeUtils.js";import $ from"../../rest/support/ImageHistogramParameters.js";import G from"../../rest/support/ImageSample.js";import W from"../../rest/support/ImageSampleParameters.js";import K from"../../rest/support/ImageSampleResult.js";import{enumeration as Q}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as X}from"../../core/accessorSupport/decorators/reader.js";const Y=1e3,Z=Z=>{const ee=Z;let te=class extends ee{constructor(...e){super(...e),this._draRasterConfig=null,this._isConstructedFromFunctionRaster=!1,this.bandIds=null,this.copyright=null,this.interpolation=null,this.multidimensionalSubset=null,this.raster=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster=c(e[0]?.raster)}destroy(){this._draRasterConfig?.rasterJobHandler?.destroy(),this._shutdownJobHandler()}get fullExtent(){return this.serviceRasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}set rasterFunction(e){"none"===e?.functionName?.toLowerCase()&&(e=void 0),this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",v(e,i.getLogger(this)))}get renderer(){if("imagery-tile"!==this.type)return this.internalRenderer;const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const r=t?.find(({name:t})=>t===e);return r?.renderer.clone()}return this.internalRenderer}set renderer(e){"imagery-tile"===this.type&&(this.activePresetRendererName=null),this.internalRenderer=e}set internalRenderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("internalRenderer",e),this.updateRenderer())}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;return V(i,r)||void 0}async computeStatisticsHistograms(e,t){await this.load(t),e=a($,e).clone();const{serviceRasterInfo:i}=this;if(null==i)throw new r("imagery-tile-mixin:compute-statistics-histograms","serviceRasterInfo must be specified");const{geometry:s}=e;if(null==s)throw new r("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=s;const{spatialReference:o}=i;if(!s.spatialReference.equals(o)){await x();const e="extent"===s.type?S(s,o):F(s,o);if(null==e)throw new r("imagery-tile-mixin:compute-statistics-histograms","geometry cannot be projected to the data source");n=e}const u=e.pixelSize??new l({x:i.pixelSize.x,y:i.pixelSize.y,spatialReference:o}),{extent:m,width:c,height:d}=b(i,n,u),p=await this.fetchPixels(m,c,d,{...t,interpolation:"nearest"});if(null==p.pixelBlock)throw new r("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await I(p.pixelBlock,m,n),f=this._rasterJobHandler;return f?f.computeStatisticsHistograms({pixelBlock:h},t):_(h)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.serviceRasterInfo??{};if(null==t)return e;const r=p({rasterInfo:this.raster.rasterInfo,multidimensionalDefinition:e.multidimensionalDefinition||this.multidimensionalDefinition,timeExtent:e.timeExtent??this.timeExtent,multidimensionalSubset:this.multidimensionalSubset});return{...e,multidimensionalDefinition:r,timeExtent:void 0}}async updateRasterFunction(){return this.loaded&&"imagery-tile"===this.type&&(this.rasterFunction||this._cachedRasterFunctionJson)&&JSON.stringify(this.rasterFunction)!==JSON.stringify(this._cachedRasterFunctionJson)?(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this._rasterFunctionUpdatePromise=this._updateRasterFunction(),this._rasterFunctionUpdatePromise):this._rasterFunctionUpdatePromise}async updateRenderer(){const{loaded:e,symbolizer:t,renderer:r}=this;if(!e||!t||!r)return;const{rasterInfo:i}=this.raster,s=h(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=s?.name,o=P(i,n);return this._updateSymbolizer(t,r,n,o)}async applyRenderer(e,t,r){const i=e?.pixelBlock;if(!(null!=i&&i.pixels&&i.pixels.length>0))return null;await this.updateRenderer();const s=this.bandIds??[],{pixelBlock:n}=await this._symbolize({pixelData:e,simpleStretchParams:t,bandIds:s,symbolizer:this.symbolizer},r);return n}getRawDisplayBandIds(){let{bandIds:e,raster:t}=this;if(this.rasterFunction&&c(t)){const r=t.rasterFunction.rawInputBandIds;e=e?.length&&r?.length&&1!==t.rasterInfo.bandCount?e.map(e=>r[Math.min(e,r.length-1)]):r}return e&&e.length>3&&e.every((e,t)=>e===t)?null:e}getTileUrl(e,t,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${r}`:""}getCompatibleTileInfo(e,t,r=!1){if(!this.loaded||null==t)return null;if(r&&e.equals(this.spatialReference))return this.tileInfo;const i=m(e);return O.create({size:256,spatialReference:e,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent?.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,r,i,s={}){if(re(this),s.requestAsImageElement){const n=this.getTileUrl(e,r,i),{data:o}=await t(n,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:s.signal});return o}const{serviceRasterInfo:n}=this;if(null!=n.multidimensionalInfo&&null==(s=this.normalizeRasterFetchOptions(s)).multidimensionalDefinition){const t=s.tileInfo||n.storageInfo.tileInfo,o=this.raster.getTileExtentFromTileInfo(e,r,i,t);if(o)return{extent:o,pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(s={...s,buffer:{cols:1,rows:1}}),s={...s,refreshParameters:this.refreshParameters},this.raster.fetchTile(e,r,i,s)}async fetchImageBitmapTile(e,r,i,s={}){re(this);const n=this.getTileUrl(e,r,i),{data:o}=await t(n,{responseType:"blob",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:s?.signal});return D(o,e,r,i,s)}async fetchPixels(e,t,r,i={}){if(null!=this.serviceRasterInfo.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition)return{extent:e,pixelBlock:null};await this._initJobHandler(),await this.updateRasterFunction(),t=Math.round(t),r=Math.round(r);const s=await this.raster.fetchPixels(e,t,r,i);return i.bandIds?.length&&!this.raster.rasterInfo.storageInfo.isBsqTile&&(s.pixelBlock=s.pixelBlock?.extractBands(i.bandIds)),s}async getSamples(e,t){await this.load();const i=a(W,e).clone();if(i.interpolation&&"nearest"!==i.interpolation)throw new r("imagery-tile-mixin:get-samples","only nearest interpolation is currently supported");const s=i.mosaicRule?.multidimensionalDefinition,n={...t,multidimensionalDefinition:s},o=(await this._getSampleLocations(i)).map(e=>this.identify(e,n).then(t=>(t.location=e,t))),l=(await Promise.all(o)).flatMap((e,t)=>this._convertRasterIdentifyResultToSample(e,t));return new K({samples:l})}async identify(e,t={}){await this.load();const i=a(l,e).clone().normalize(),{raster:s,serviceRasterInfo:n}=this;if(null!=n?.multidimensionalInfo){if(!(n.hasMultidimensionalTranspose&&!(!f(t.multidimensionalDefinition)&&!t.transposedVariableName))&&null==(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition)return{location:i,value:null}}const o=this.multidimensionalSubset?.areaOfInterest;if(o&&!o.contains(i))throw new r("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");let u;if(this.serviceRasterInfo?.storageInfo.isBsqTile){const e=c(s)?this.getRawDisplayBandIds():this.bandIds;u=e?.length?e:void 0}return s.identify(i,{...t,bandIds:u})}hasStandardTime(){const e=this.serviceRasterInfo?.multidimensionalInfo;if(null==e||"standard-time"!==this.serviceRasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,r=t?.[0]?.variableName;return e.variables.some(e=>e.name===r&&(!t?.[0].dimensionName||e.dimensions.some(e=>"StdTime"===e.name)))}getStandardTimeValue(e){return new Date(y(e)).toISOString()}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo?.multidimensionalInfo;return g(this.multidimensionalSubset,t)}async getDynamicRangeInputRaster(){if(!this.rasterFunction||!c(this.raster)||!this._cachedRasterFunctionJson)return null;const e=JSON.stringify(this._cachedRasterFunctionJson);if(this._draRasterConfig?.functionJson===e)return this._draRasterConfig;const t=this.raster.rasterFunction.queryRasterFunction(e=>"Stretch"===e.functionName&&e.functionArguments.dynamicRangeAdjustment);if(!t)return null;const r=t.toJSON(),i=this.raster.primaryRasters.rasters,s=t.functionArguments.raster,n=r.rasterFunctionArguments;if(!s||"object"!=typeof s||!("functionName"in s))return this._draRasterConfig={functionJson:e,raster:i[0],functionArguments:n,rasterJobHandler:this._draRasterConfig?.rasterJobHandler},this._draRasterConfig;const o={raster:i[0]};i.length>1&&i.forEach(e=>o[e.url]=e);const a=w(s.toJSON(),o),l=new d({rasterFunction:a});await l.open();let u=this._draRasterConfig?.rasterJobHandler;try{u||(u=new C,await u.initialize()),l.rasterJobHandler=u,await l.syncJobHandler()}catch{}return this._draRasterConfig={functionJson:e,raster:l,functionArguments:n,rasterJobHandler:u},this._draRasterConfig}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=R(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&c(this.raster)&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}async _initJobHandler(){if(!this._rasterJobHandler)return super._initJobHandler().then(async()=>{if(!this._rasterJobHandler)return;re(this);const{raster:e}=this;e.rasterJobHandler=this._rasterJobHandler,c(e)&&e.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch(()=>{}),this.renderer&&this.updateRenderer()}).catch(()=>{})}_shutdownJobHandler(){super._shutdownJobHandler(),this.raster&&(this.raster.rasterJobHandler=null)}async _getSampleLocations(e){const{geometry:t}=e;if("point"===t.type)return[t];const{spatialReference:r,type:i}=t;if("multipoint"===i)return t.points.map(e=>new l({x:e[0],y:e[1],spatialReference:r}));if("polyline"===i){let i=t;if(e.sampleCount||e.sampleDistance){const r=await import("../../geometry/operators/densifyOperator.js"),s=(await import("../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"}),n=Math.min(e.sampleCount||100,Y);let o=e.sampleDistance;if(!o){o=s/(n+(2===i.paths[0].length?1:0))}i=r.execute(t,o,{unit:"meters"})}return i.paths.flatMap(e=>e.map(e=>new l({x:e[0],y:e[1],spatialReference:r})))}const s=Math.min(e.sampleCount||100,Y),n="extent"===t.type,o=n?t:t.extent,a=Math.sqrt(o.width*o.height/s),u=o.height/a,m=o.width/a,{xmin:c,ymax:d}=o,p=[];for(let h=0;h<u;h++)for(let e=0;e<m;e++){const i=new l({x:c+(e+.5)*a,y:d-(h+.5)*a,spatialReference:r});(n||t.contains(i))&&p.push(i)}return p}_configDefaultInterpolation(){if(null==this.interpolation){re(this);const{raster:e}=this,t=z(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){re(this);const{rasterInfo:t}=this.raster,r=h(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=r?.name,n=E({variableName:s,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>1&&(this.bandIds=n?.bandIds??B(t)),!this.renderer||"override"===e){const e=U(this.raster),r=n?.renderer??M(t,{bandIds:this.bandIds,variableName:s,rasterFunctionColorRamp:e}),i=t.statistics,o=i&&i.length>0?i[0]:null,a=o?.max??0,l=o?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===r.type&&(a>1e24||l<-1e24)&&(r.dynamicRangeAdjustment=!0,r.customStatistics=null,"none"===r.stretchType&&(r.stretchType="min-max")),this.renderer=r}const o=A({...this.renderer.toJSON(),variableName:s}),a=P(t,s);this.symbolizer?(this.symbolizer.rendererJSON=o,this.symbolizer.rasterInfo=a):this.symbolizer=new q({rendererJSON:o,rasterInfo:a});const l=this.symbolizer.bind();if(l.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if(null!=e&&"raster-colormap"===t.type){const e=M(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,r=t.customStatistics?.length;!t.dynamicRangeAdjustment&&r&&e&&r!==e&&this._configDefaultRenderer("override")}}}else i.getLogger(this).warn("imagery-tile-mixin",l.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}async _updateRasterFunction(){if(this._isConstructedFromFunctionRaster&&c(this.raster)){const e=this.raster.rasterFunction.toJSON();return void(!this.rasterFunction&&e&&this._set("rasterFunction",H.fromJSON(e)))}let e,t=this.raster,r=!1;c(t)?(e=t.primaryRasters.rasters,t=e[0],r=!0):e=[t];const{rasterFunction:i}=this;if(i){const r={raster:t};e.length>1&&e.forEach(e=>r[e.url]=e);const s=w(i.functionDefinition?.toJSON()??i.toJSON(),r),n=new d({rasterFunction:s});n.rasterJobHandler=this._rasterJobHandler,await n.open(),this.raster=n}else this.raster=t,await t.open();if(this._cachedRendererJson=void 0,!r&&!i)return;const{bandIds:s}=this,{bandCount:n}=this.raster.rasterInfo,o=s?.length?s.some(e=>e>=n):n>=3;s&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}_convertRasterIdentifyResultToSample(e,t){const{rasterInfo:r}=this.raster,i=r.storageInfo.pyramidScalingFactor**(e.pyramidLevel??0),s=(r.pixelSize.x+r.pixelSize.y)/2*i;if(!e.dataSeries?.length)return[new G({location:e.location,pixelValue:e.value,locationId:t,resolution:s})];const n=[];return e.dataSeries.forEach(({value:r,multidimensionalDefinition:i},o)=>{const a={Variables:i[0].variableName,Dimensions:i.flatMap(({dimensionName:e})=>e).join(",")};for(const{dimensionName:e,values:t}of i){a[e]=Array.isArray(t[0])?t[0][0]:t[0];const r=t[t.length-1];a[`${e}_Max`]=Array.isArray(r)?r[r.length-1]:r}const l=new G({location:e.location,pixelValue:r,rasterId:o,locationId:t,resolution:s,attributes:a});n.push(l)}),n}};function re(e){if(!e.raster||!e.serviceRasterInfo)throw new r("imagery-tile","no raster")}return e([s({clonable:!1})],te.prototype,"_cachedRasterFunctionJson",void 0),e([s({clonable:!1})],te.prototype,"_compatibleFullExtent",void 0),e([s({clonable:!1})],te.prototype,"_draRasterConfig",void 0),e([s({clonable:!1})],te.prototype,"_isConstructedFromFunctionRaster",void 0),e([s({clonable:!1})],te.prototype,"_rasterFunctionUpdatePromise",void 0),e([s({type:[o],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],te.prototype,"bandIds",void 0),e([s({json:{origins:{service:{read:{source:"copyrightText"}}}}})],te.prototype,"copyright",void 0),e([s({json:{read:!1}})],te.prototype,"fullExtent",null),e([s({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),Q(T)],te.prototype,"interpolation",void 0),e([s()],te.prototype,"ioConfig",void 0),e([s({type:[j],json:{write:!0}})],te.prototype,"multidimensionalDefinition",null),e([s({type:N,json:{write:!0}})],te.prototype,"multidimensionalSubset",void 0),e([s()],te.prototype,"raster",void 0),e([s({type:H})],te.prototype,"rasterFunction",null),e([s()],te.prototype,"serviceRasterInfo",void 0),e([s()],te.prototype,"sourceJSON",void 0),e([s({readOnly:!0,type:u,json:{read:!1}})],te.prototype,"spatialReference",void 0),e([s({type:O})],te.prototype,"tileInfo",void 0),e([s(J)],te.prototype,"url",null),e([s({types:k})],te.prototype,"renderer",null),e([s({types:k,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:L,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],te.prototype,"internalRenderer",null),e([X("internalRenderer")],te.prototype,"readRenderer",null),e([s({clonable:!1})],te.prototype,"symbolizer",void 0),te=e([n("esri.layers.mixins.TiledImagery")],te),te};export{Z as TiledImagery};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import r from"../../core/Error.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";async function t(t,o,a){let c;try{c=await createImageBitmap(t)}catch(l){throw new r("request:server",`Unable to load ${o}`,{url:o,error:l})}return e(a),c}async function o(t,o,a,c,l){let n;try{n=await createImageBitmap(t)}catch(i){throw new r("request:server",`Unable to load tile ${o}/${a}/${c}`,{error:i,level:o,row:a,col:c})}return e(l),n}export{t as createBitmap,o as createTileBitmap};
2
+ import e from"../../core/Error.js";import{throwIfAborted as t}from"../../core/promiseUtils.js";async function r(r,a,i){let o;try{o=await n(r,i)}catch(s){throw new e("request:server",`Unable to load ${a}`,{url:a,error:s})}return t(i),o}async function a(r,a,i,o,s){let c;try{c=await n(r,s)}catch(m){throw new e("request:server",`Unable to load tile ${a}/${i}/${o}`,{error:m,level:a,row:i,col:o})}return t(s),c}async function n(e,t){const r=await createImageBitmap(e,{imageOrientation:t?.imageOrientation??"none"}),a=t?.type??(e instanceof Blob?e.type.startsWith("image/")?e.type:t?.allowDeriveTypeFromData?await i(await e.bytes()):void 0:void 0);return new o(r,a)}async function i(e){return e.byteLength<2?"unknown":137===e[0]&&80===e[1]?"image/png":71===e[0]&&73===e[1]?"image/gif":66===e[0]&&77===e[1]?"image/bmp":255===e[0]&&216===e[1]?"image/jpeg":"unknown"}class o{constructor(e,t){this.bitmap=e,this.type=t}get isOpaque(){return"image/jpeg"===this.type}}export{o as CreateBitmapResult,r as createBitmap,n as createBitmapResult,a as createTileBitmap};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.1.0-next.81",
3
+ "version": "5.1.0-next.83",
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": [
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../config.js";import{id as t}from"../kernel.js";import r from"../core/Error.js";import has from"../core/has.js";import{clone as s}from"../core/lang.js";import{isAbortError as o,createAbortError as a,isAborted as n}from"../core/promiseUtils.js";import{isTrustedServer as i,getOrigin as l,isBlobProtocol as u,isDataProtocol as c,toHTTPS as d,objectToQuery as m,getProxyRule as p,getProxyUrl as f,addQueryParameters as h,hasSameOrigin as y,addProxyRule as g,getAppUrl as w}from"../core/urlUtils.js";import{isSecureProxyService as b}from"../portal/support/urlUtils.js";import{requestConfig as T}from"./config.js";import{registerNoCorsDomains as k,isNoCorsRequestRequired as q,sendNoCorsRequest as S}from"./cors.js";import{getImageType as O,ImageWithType as C}from"./ImageWithType.js";import{loadImage as x}from"./loadImage.js";import{setPreferredHost as j,getPreferredUrl as v}from"./preferredHosts.js";const L="FormData"in globalThis,E=new Set([499,498,403,401]),U=new Set(["COM_0056","COM_0057","SB_0008"]),A=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i];async function P(r){let s,o;await H(r);try{do{[s,o]=await I(r)}while(!await W(r,s,o))}catch(u){const e=_("request:server",u,r.parameters,s);throw e.details.ssl=r.useSSL,r.interceptor?.error?.(e),e}const a=r.parameters.url;if(o)if(/\/sharing\/rest\/(accounts|portals)\/self/i.test(a)){if(!r.hasToken&&!r.credentialToken&&o.user?.username&&!i(a)){const t=l(a,!0);t&&e.request.trustedServers.push(t)}Array.isArray(o.authorizedCrossOriginNoCorsDomains)&&k(o.authorizedCrossOriginNoCorsDomains)}else{"json"===(r.parameters.requestOptions.responseType||"json")&&j(a,o)}const n=r.credential;if(n&&t){const e=t.findServerInfo(n.server);let r=e?.owningSystemUrl;if(r){r=r.replace(/\/?$/,"/sharing");const e=t.findCredential(r,n.userId);e&&-1===t._getIdenticalSvcIdx(r,e)&&e.resources.unshift(r)}}return{data:o,getAllHeaders:s?()=>Array.from(s.headers):G,getHeader:s?e=>s.headers.get(e):G,httpStatus:s?.status??200,requestOptions:r.parameters.requestOptions,ssl:r.useSSL,url:r.parameters.url}}async function H(r){const s=r.parameters.url,o=r.parameters.requestOptions,a=r.controller.signal,i=o.body;let l=null,u=null;if(L&&"HTMLFormElement"in globalThis&&(i instanceof FormData?l=i:i instanceof HTMLFormElement&&(l=new FormData(i))),"string"==typeof i&&(u=i),r.fetchOptions={cache:o.cacheMode??(o.cacheBust?"no-cache":"default"),credentials:"same-origin",headers:o.headers||{},keepalive:o.keepAlive??!1,method:"head"===o.method?"HEAD":"GET",mode:"cors",priority:o.priority??e.request.priority,redirect:"follow",signal:a},(l||u)&&(r.fetchOptions.body=l||u),(T.isForeignWorker||"anonymous"===o.authMode)&&(r.useIdentity=!1),r.hasToken=!!(/token=/i.test(s)||o.query?.token||l?.get("token")),!r.hasToken){const{getApiKey:e,getSessionToken:t}=await import("../support/apiKeyUtils.js"),a=await t(s)??e(s);a&&(o.query??={},o.query.token=a,r.hasToken=!0)}if(r.useIdentity&&!r.hasToken&&!r.credential&&!r.credentialToken&&!N(s)&&!n(a)){let e;"immediate"===o.authMode?(await R(),e=await t.getCredential(s,{signal:a})):"no-prompt"===o.authMode?(await R(),e=await t.getCredential(s,{prompt:!1,signal:a}).catch(()=>{})):t&&(e=t.findCredential(s)),e&&(r.credential=e,r.credentialToken=e.token,r.useSSL=!!e.ssl)}}async function I(r){let s=r.parameters.url,o=v(s);const n=r.parameters.requestOptions,k=r.fetchOptions??{},x=u(s)||c(s),j=n.responseType??"json",E="image"===j&&n.imageWithType,U=x?0:null!=n.timeout?n.timeout:e.request.timeout;let A=!1;if(!x){r.useSSL&&(s=d(s));let a={...n.query};r.credentialToken&&(a.token=r.credentialToken);let l=m(a);has("esri-url-encodes-apostrophe")&&(l=l.replaceAll("'","%27"));const u=o.length+1+l.length;let c;A="delete"===n.method||"post"===n.method||"put"===n.method||!!n.body||u>e.request.maxUrlLength;const g=n.useProxy||!!p(s);if(g){const t=f(s);c=t.path,!A&&c.length+1+u>e.request.maxUrlLength&&(A=!0),t.query&&(a={...t.query,...a})}if("HEAD"===k.method&&(A||g)){if(A){if(u>e.request.maxUrlLength)throw _("request:invalid-parameters",new Error("URL exceeds maximum length"),r.parameters);throw _("request:invalid-parameters",new Error("cannot use POST request when method is 'head'"),r.parameters)}if(g)throw _("request:invalid-parameters",new Error("cannot use proxy when method is 'head'"),r.parameters)}if(A?(k.method="delete"===n.method?"DELETE":"put"===n.method?"PUT":"POST",n.body?s=h(s,a):(k.body=m(a),k.headers||(k.headers={}),k.headers["Content-Type"]="application/x-www-form-urlencoded")):s=h(s,a),g&&(r.useProxy=!0,s=`${c}?${s}`),a.token&&L&&k.body instanceof FormData&&!b(s)&&k.body.set("token",a.token),n.hasOwnProperty("withCredentials"))r.withCredentials=n.withCredentials;else if(!y(s,w()))if(i(s))r.withCredentials=!0;else if(t){const e=t.findServerInfo(s);e?.webTierAuth&&(r.withCredentials=!0)}r.withCredentials&&(k.credentials="include",q(s)&&await S(A?h(s,a):s)),o=v(s)}let P,H,R=0,N=!1;U>0&&(R=setTimeout(()=>{N=!0,r.controller.abort()},U));try{if("native-request-init"===n.responseType)H=k,H.url=o,n.signal?H.signal=n.signal:delete H.signal;else if("image"!==n.responseType||"default"!==k.cache||k.keepalive||"GET"!==k.method||A||B(n.headers)||!x&&!r.useProxy&&e.request.proxyUrl&&!F(s)){if(await(T.beforeFetch?.(s,k)),P=await fetch(o,k),await(T.afterFetch?.(P)),r.useProxy||D(s),"native"===n.responseType)H=P;else if("HEAD"!==k.method)if(P.ok){switch(j){case"array-buffer":H=await P.arrayBuffer();break;case"blob":H=await P.blob();break;case"image":H=await(E?P.arrayBuffer():P.blob());break;default:H=await P.text()}if(R&&(clearTimeout(R),R=0),"json"===j||"xml"===j||"document"===j)if(H)switch(j){case"json":H=JSON.parse(H);break;case"xml":H=$(H,"application/xml");break;case"document":H=$(H,"text/html")}else H=null;if(H){if(("array-buffer"===j||"blob"===j)&&H["blob"===j?"size":"byteLength"]<=750)try{const e=await new Response(H).json();e.error&&(H=e)}catch{}if(E&&H instanceof ArrayBuffer){const e=O(H);if("unknown"===e)return n.responseType="image",await I(r);H=await P.blob(),H=await M(URL.createObjectURL(H),r,!0),H=new C(H,e)}"image"===j&&H instanceof Blob&&(H=await M(URL.createObjectURL(H),r,!0))}}else{H=await P.text();try{H=JSON.parse(H)}catch{}}}else H=await M(o,r)}catch(W){if("AbortError"===W.name){if(N)throw K();throw a("Request canceled")}if(!(!P&&W instanceof TypeError&&e.request.proxyUrl)||n.body||"delete"===n.method||"head"===n.method||"post"===n.method||"put"===n.method||r.useProxy||F(s))throw W;r.redoRequest=!0,g({proxyUrl:e.request.proxyUrl,urlPrefix:l(s)??""})}finally{R&&clearTimeout(R)}return[P,H]}function M(t,r,s=!1){const o=r.controller.signal,a=new Image;return r.withCredentials?a.crossOrigin="use-credentials":a.crossOrigin="anonymous",a.alt="",a.fetchPriority=e.request.priority,a.src=t,x(a,t,s,o)}function D(e){const t=l(e);t&&!T.corsServers.includes(t)&&T.corsServers.push(t)}function F(e){const t=l(e);return!t||t.endsWith(".arcgis.com")||T.corsServers.includes(t)||i(t)}async function R(){t||await import("../identity/IdentityManager.js")}function N(e){return A.some(t=>t.test(e))}function B(e){if(e)for(const t of Object.getOwnPropertyNames(e))if(e[t])return!0;return!1}function $(e,t){let r;try{r=(new DOMParser).parseFromString(e,t)}catch{}if(!r||r.getElementsByTagName("parsererror").length)throw new SyntaxError("XML Parse error");return r}async function W(e,r,s){if(e.redoRequest)return e.redoRequest=!1,!1;const o=e.parameters.requestOptions;if(!r||"native"===o.responseType||"native-request-init"===o.responseType)return!0;let a,n;if(s&&(s.error&&"object"==typeof s.error?a=s.error:"error"===s.status&&Array.isArray(s.messages)&&(a={...s},a[z]=s,a.details=s.messages)),!a&&!r.ok)throw a=new Error(`Unable to load ${r.url} status: ${r.status}`),a[z]=s,a;let i,l=null;a&&(n=Number(a.code),l=a.hasOwnProperty("subcode")?Number(a.subcode):null,i=a.messageCode,i=i?.toUpperCase());const u=o.authMode;if(403===n&&(4===l||a.message?.toLowerCase().includes("ssl")&&!a.message.toLowerCase().includes("permission"))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&("no-prompt"!==u||498===n)&&void 0!==n&&E.has(n)&&!N(e.parameters.url)&&(403!==n||(!i||!U.has(i))&&(null==l||2===l&&e.credentialToken))){await R();try{const r=await t.getCredential(e.parameters.url,{error:_("request:server",a,e.parameters),credential:e.credential,prompt:"no-prompt"!==u,signal:e.controller.signal,token:e.credentialToken});return e.credential=r,e.credentialToken=r.token,e.useSSL=e.useSSL||r.ssl,!1}catch(c){if("no-prompt"===u)return e.credential=void 0,e.credentialToken=void 0,!1;a=c}}if(a)throw a;return!0}function _(e,t,n,i){let l;const u={url:n.url,requestOptions:n.requestOptions,getAllHeaders:G,getHeader:G,ssl:!1};if(t instanceof r)return t.details?(t.details=s(t.details),t.details.url=n.url,t.details.requestOptions=n.requestOptions):t.details=u,t;if(t){const e=i&&(()=>Array.from(i.headers)),r=i&&(e=>i.headers.get(e)),s=i?.status,o=t.message;o&&(l=o),e&&r&&(u.getAllHeaders=e,u.getHeader=r),u.httpStatus=(null!=t.httpCode?t.httpCode:t.code)||s||0,u.subCode=t.subcode,u.messageCode=t.messageCode,"string"==typeof t.details?(u.messages=[t.details],l??=t.details):(u.messages=t.details,l??=u.messages?.[0]),u.raw=z in t?t[z]:t}return l??="Error",o(t)?a():new r(e,l,u)}const z=Symbol(),G=()=>null,J="Timeout exceeded";function K(){return new Error(J)}function X(e){return"object"==typeof e&&!!e&&"message"in e&&e.message===J}export{_ as createRequestError,X as isTimeoutError,P as processRequest};
2
+ import e from"../config.js";import{id as t}from"../kernel.js";import r from"../core/Error.js";import has from"../core/has.js";import{clone as s}from"../core/lang.js";import{isAbortError as o,createAbortError as a,isAborted as n}from"../core/promiseUtils.js";import{isTrustedServer as i,getOrigin as l,isBlobProtocol as u,isDataProtocol as c,toHTTPS as d,objectToQuery as m,getProxyRule as p,getProxyUrl as h,addQueryParameters as f,hasSameOrigin as y,addProxyRule as g,getAppUrl as w}from"../core/urlUtils.js";import{isSecureProxyService as b}from"../portal/support/urlUtils.js";import{requestConfig as T}from"./config.js";import{registerNoCorsDomains as k,isNoCorsRequestRequired as q,sendNoCorsRequest as S}from"./cors.js";import{loadImage as O}from"./loadImage.js";import{setPreferredHost as C,getPreferredUrl as x}from"./preferredHosts.js";const j="FormData"in globalThis,v=new Set([499,498,403,401]),E=new Set(["COM_0056","COM_0057","SB_0008"]),L=[/\/arcgis\/tokens/i,/\/sharing(\/rest)?\/generatetoken/i,/\/rest\/info/i];async function U(r){let s,o;await A(r);try{do{[s,o]=await P(r)}while(!await B(r,s,o))}catch(u){const e=$("request:server",u,r.parameters,s);throw e.details.ssl=r.useSSL,r.interceptor?.error?.(e),e}const a=r.parameters.url;if(o)if(/\/sharing\/rest\/(accounts|portals)\/self/i.test(a)){if(!r.hasToken&&!r.credentialToken&&o.user?.username&&!i(a)){const t=l(a,!0);t&&e.request.trustedServers.push(t)}Array.isArray(o.authorizedCrossOriginNoCorsDomains)&&k(o.authorizedCrossOriginNoCorsDomains)}else{"json"===(r.parameters.requestOptions.responseType||"json")&&C(a,o)}const n=r.credential;if(n&&t){const e=t.findServerInfo(n.server);let r=e?.owningSystemUrl;if(r){r=r.replace(/\/?$/,"/sharing");const e=t.findCredential(r,n.userId);e&&-1===t._getIdenticalSvcIdx(r,e)&&e.resources.unshift(r)}}return{data:o,getAllHeaders:s?()=>Array.from(s.headers):z,getHeader:s?e=>s.headers.get(e):z,httpStatus:s?.status??200,requestOptions:r.parameters.requestOptions,ssl:r.useSSL,url:r.parameters.url}}async function A(r){const s=r.parameters.url,o=r.parameters.requestOptions,a=r.controller.signal,i=o.body;let l=null,u=null;if(j&&"HTMLFormElement"in globalThis&&(i instanceof FormData?l=i:i instanceof HTMLFormElement&&(l=new FormData(i))),"string"==typeof i&&(u=i),r.fetchOptions={cache:o.cacheMode??(o.cacheBust?"no-cache":"default"),credentials:"same-origin",headers:o.headers||{},keepalive:o.keepAlive??!1,method:"head"===o.method?"HEAD":"GET",mode:"cors",priority:o.priority??e.request.priority,redirect:"follow",signal:a},(l||u)&&(r.fetchOptions.body=l||u),(T.isForeignWorker||"anonymous"===o.authMode)&&(r.useIdentity=!1),r.hasToken=!!(/token=/i.test(s)||o.query?.token||l?.get("token")),!r.hasToken){const{getApiKey:e,getSessionToken:t}=await import("../support/apiKeyUtils.js"),a=await t(s)??e(s);a&&(o.query??={},o.query.token=a,r.hasToken=!0)}if(r.useIdentity&&!r.hasToken&&!r.credential&&!r.credentialToken&&!F(s)&&!n(a)){let e;"immediate"===o.authMode?(await I(),e=await t.getCredential(s,{signal:a})):"no-prompt"===o.authMode?(await I(),e=await t.getCredential(s,{prompt:!1,signal:a}).catch(()=>{})):t&&(e=t.findCredential(s)),e&&(r.credential=e,r.credentialToken=e.token,r.useSSL=!!e.ssl)}}async function P(r){let s=r.parameters.url,o=x(s);const n=r.parameters.requestOptions,k=r.fetchOptions??{},O=u(s)||c(s),C=n.responseType??"json",v=O?0:null!=n.timeout?n.timeout:e.request.timeout;let E=!1;if(!O){r.useSSL&&(s=d(s));let a={...n.query};r.credentialToken&&(a.token=r.credentialToken);let l=m(a);has("esri-url-encodes-apostrophe")&&(l=l.replaceAll("'","%27"));const u=o.length+1+l.length;let c;E="delete"===n.method||"post"===n.method||"put"===n.method||!!n.body||u>e.request.maxUrlLength;const g=n.useProxy||!!p(s);if(g){const t=h(s);c=t.path,!E&&c.length+1+u>e.request.maxUrlLength&&(E=!0),t.query&&(a={...t.query,...a})}if("HEAD"===k.method&&(E||g)){if(E){if(u>e.request.maxUrlLength)throw $("request:invalid-parameters",new Error("URL exceeds maximum length"),r.parameters);throw $("request:invalid-parameters",new Error("cannot use POST request when method is 'head'"),r.parameters)}if(g)throw $("request:invalid-parameters",new Error("cannot use proxy when method is 'head'"),r.parameters)}if(E?(k.method="delete"===n.method?"DELETE":"put"===n.method?"PUT":"POST",n.body?s=f(s,a):(k.body=m(a),k.headers||(k.headers={}),k.headers["Content-Type"]="application/x-www-form-urlencoded")):s=f(s,a),g&&(r.useProxy=!0,s=`${c}?${s}`),a.token&&j&&k.body instanceof FormData&&!b(s)&&k.body.set("token",a.token),n.hasOwnProperty("withCredentials"))r.withCredentials=n.withCredentials;else if(!y(s,w()))if(i(s))r.withCredentials=!0;else if(t){const e=t.findServerInfo(s);e?.webTierAuth&&(r.withCredentials=!0)}r.withCredentials&&(k.credentials="include",q(s)&&await S(E?f(s,a):s)),o=x(s)}let L,U,A=0,P=!1;v>0&&(A=setTimeout(()=>{P=!0,r.controller.abort()},v));try{if("native-request-init"===n.responseType)U=k,U.url=o,n.signal?U.signal=n.signal:delete U.signal;else if("image"!==n.responseType||"default"!==k.cache||k.keepalive||"GET"!==k.method||E||N(n.headers)||!O&&!r.useProxy&&e.request.proxyUrl&&!D(s)){if(await(T.beforeFetch?.(s,k)),L=await fetch(o,k),await(T.afterFetch?.(L)),r.useProxy||M(s),"native"===n.responseType)U=L;else if("HEAD"!==k.method)if(L.ok){switch(C){case"array-buffer":U=await L.arrayBuffer();break;case"blob":case"image":U=await L.blob();break;default:U=await L.text()}if(A&&(clearTimeout(A),A=0),"json"===C||"xml"===C||"document"===C)if(U)switch(C){case"json":U=JSON.parse(U);break;case"xml":U=R(U,"application/xml");break;case"document":U=R(U,"text/html")}else U=null;if(U){if(("array-buffer"===C||"blob"===C)&&U["blob"===C?"size":"byteLength"]<=750)try{const e=await new Response(U).json();e.error&&(U=e)}catch{}"image"===C&&U instanceof Blob&&(U=await H(URL.createObjectURL(U),r,!0))}}else{U=await L.text();try{U=JSON.parse(U)}catch{}}}else U=await H(o,r)}catch(I){if("AbortError"===I.name){if(P)throw J();throw a("Request canceled")}if(!(!L&&I instanceof TypeError&&e.request.proxyUrl)||n.body||"delete"===n.method||"head"===n.method||"post"===n.method||"put"===n.method||r.useProxy||D(s))throw I;r.redoRequest=!0,g({proxyUrl:e.request.proxyUrl,urlPrefix:l(s)??""})}finally{A&&clearTimeout(A)}return[L,U]}function H(t,r,s=!1){const o=r.controller.signal,a=new Image;return r.withCredentials?a.crossOrigin="use-credentials":a.crossOrigin="anonymous",a.alt="",a.fetchPriority=e.request.priority,a.src=t,O(a,t,s,o)}function M(e){const t=l(e);t&&!T.corsServers.includes(t)&&T.corsServers.push(t)}function D(e){const t=l(e);return!t||t.endsWith(".arcgis.com")||T.corsServers.includes(t)||i(t)}async function I(){t||await import("../identity/IdentityManager.js")}function F(e){return L.some(t=>t.test(e))}function N(e){if(e)for(const t of Object.getOwnPropertyNames(e))if(e[t])return!0;return!1}function R(e,t){let r;try{r=(new DOMParser).parseFromString(e,t)}catch{}if(!r||r.getElementsByTagName("parsererror").length)throw new SyntaxError("XML Parse error");return r}async function B(e,r,s){if(e.redoRequest)return e.redoRequest=!1,!1;const o=e.parameters.requestOptions;if(!r||"native"===o.responseType||"native-request-init"===o.responseType)return!0;let a,n;if(s&&(s.error&&"object"==typeof s.error?a=s.error:"error"===s.status&&Array.isArray(s.messages)&&(a={...s},a[_]=s,a.details=s.messages)),!a&&!r.ok)throw a=new Error(`Unable to load ${r.url} status: ${r.status}`),a[_]=s,a;let i,l=null;a&&(n=Number(a.code),l=a.hasOwnProperty("subcode")?Number(a.subcode):null,i=a.messageCode,i=i?.toUpperCase());const u=o.authMode;if(403===n&&(4===l||a.message?.toLowerCase().includes("ssl")&&!a.message.toLowerCase().includes("permission"))){if(!e.useSSL)return e.useSSL=!0,!1}else if(!e.hasToken&&e.useIdentity&&("no-prompt"!==u||498===n)&&void 0!==n&&v.has(n)&&!F(e.parameters.url)&&(403!==n||(!i||!E.has(i))&&(null==l||2===l&&e.credentialToken))){await I();try{const r=await t.getCredential(e.parameters.url,{error:$("request:server",a,e.parameters),credential:e.credential,prompt:"no-prompt"!==u,signal:e.controller.signal,token:e.credentialToken});return e.credential=r,e.credentialToken=r.token,e.useSSL=e.useSSL||r.ssl,!1}catch(c){if("no-prompt"===u)return e.credential=void 0,e.credentialToken=void 0,!1;a=c}}if(a)throw a;return!0}function $(e,t,n,i){let l;const u={url:n.url,requestOptions:n.requestOptions,getAllHeaders:z,getHeader:z,ssl:!1};if(t instanceof r)return t.details?(t.details=s(t.details),t.details.url=n.url,t.details.requestOptions=n.requestOptions):t.details=u,t;if(t){const e=i&&(()=>Array.from(i.headers)),r=i&&(e=>i.headers.get(e)),s=i?.status,o=t.message;o&&(l=o),e&&r&&(u.getAllHeaders=e,u.getHeader=r),u.httpStatus=(null!=t.httpCode?t.httpCode:t.code)||s||0,u.subCode=t.subcode,u.messageCode=t.messageCode,"string"==typeof t.details?(u.messages=[t.details],l??=t.details):(u.messages=t.details,l??=u.messages?.[0]),u.raw=_ in t?t[_]:t}return l??="Error",o(t)?a():new r(e,l,u)}const _=Symbol(),z=()=>null,G="Timeout exceeded";function J(){return new Error(G)}function K(e){return"object"==typeof e&&!!e&&"message"in e&&e.message===G}export{$ as createRequestError,K as isTimeoutError,U as processRequest};
@@ -0,0 +1,37 @@
1
+ import type Accessor from "../../core/Accessor.js";
2
+ import type { ReplicaSyncDataFormat } from "./ReplicaDefinition.js";
3
+
4
+ export interface CreateReplicaResponseProperties extends Partial<Pick<CreateReplicaResponse, "asyncStatusUrl" | "createReplicaResult">> {}
5
+
6
+ /**
7
+ * The response for [executeCreateReplica()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeCreateReplica).
8
+ *
9
+ * @since 5.1
10
+ */
11
+ export default class CreateReplicaResponse extends Accessor {
12
+ constructor(properties?: CreateReplicaResponseProperties);
13
+ /** URL to check asynchronous status when replica creation runs asynchronously. */
14
+ accessor asyncStatusUrl: string | null | undefined;
15
+ /** Result payload when replica creation returns synchronously. */
16
+ accessor createReplicaResult: CreateReplicaResult | null | undefined;
17
+ }
18
+
19
+ /** Result details returned for a completed replica creation request. */
20
+ export interface CreateReplicaResult {
21
+ /** Error messages returned by the replica creation operation. */
22
+ errors: string[];
23
+ /** Warning messages returned by the replica creation operation. */
24
+ warnings: string[];
25
+ /** Name of the created replica. */
26
+ replicaName: string;
27
+ /** The requested replica name supplied on the create replica request. */
28
+ requestedReplicaName: string;
29
+ /** Unique identifier of the created replica. */
30
+ replicaId: string;
31
+ /** Sync date associated with the created replica. */
32
+ syncDate?: Date | null;
33
+ /** Sync data format of the created replica. */
34
+ replicaDataFormat: ReplicaSyncDataFormat;
35
+ /** URL to fetch replica data. */
36
+ replicaDataUrl: string;
37
+ }
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{property as r,subclass as s}from"../../core/accessorSupport/decorators.js";let o=class extends t{constructor(e){super(e),this.asyncStatusUrl=null,this.createReplicaResult=null}};e([r()],o.prototype,"asyncStatusUrl",void 0),e([r()],o.prototype,"createReplicaResult",void 0),o=e([s("esri.rest.knowledgeGraph.CreateReplicaResponse")],o);export{o as default};
@@ -0,0 +1,91 @@
1
+ import type Accessor from "../../core/Accessor.js";
2
+ import type { ValidBindParameterType } from "./types.js";
3
+
4
+ export interface ReplicaDefinitionProperties extends Partial<Pick<ReplicaDefinition, "creationDate" | "lastSyncDate" | "replicaFilters" | "replicaId" | "replicaName" | "replicaOwner" | "syncDirection">> {}
5
+
6
+ /**
7
+ * A replica definition returned from a knowledge graph replica endpoint.
8
+ *
9
+ * @since 5.1
10
+ */
11
+ export default class ReplicaDefinition extends Accessor {
12
+ constructor(properties?: ReplicaDefinitionProperties);
13
+ /** Date the replica was created. */
14
+ accessor creationDate: Date | null | undefined;
15
+ /** Date of the last replica sync. */
16
+ accessor lastSyncDate: Date | null | undefined;
17
+ /** Filters that define the replica scope. */
18
+ accessor replicaFilters: ReplicaFilters | null | undefined;
19
+ /** Unique identifier of the replica. */
20
+ accessor replicaId: string | null | undefined;
21
+ /** Name of the replica. */
22
+ accessor replicaName: string | null | undefined;
23
+ /** Owner of the replica. */
24
+ accessor replicaOwner: string | null | undefined;
25
+ /** Synchronization direction for the replica. */
26
+ accessor syncDirection: ReplicaSyncDirection | null | undefined;
27
+ }
28
+
29
+ export interface ReplicaReference {}
30
+
31
+ export interface ReplicaTransform {}
32
+
33
+ export type ReplicaProvenanceOptions = {
34
+ includeProvenance: true;
35
+ includeSourceDocuments?: boolean;
36
+ } | { includeProvenance: false; };
37
+
38
+ export type ReplicaDocumentOptions = {
39
+ includeConnectedDocuments: true;
40
+ includeDocumentProvenance: true;
41
+ includeDocumentSourceDocuments?: boolean;
42
+ } | {
43
+ includeConnectedDocuments: true;
44
+ includeDocumentProvenance?: false;
45
+ } | { includeConnectedDocuments: false; };
46
+
47
+ export interface ReplicaNamedTypeDefinition {}
48
+
49
+ export interface ReplicaEntityTypeDefinition extends ReplicaNamedTypeDefinition {}
50
+
51
+ export interface ReplicaRelationshipTypeDefinition extends ReplicaNamedTypeDefinition {}
52
+
53
+ export interface ReplicaStaticDefinition {}
54
+
55
+ export interface ReplicaFilters {}
56
+
57
+ export type ReplicaParameterValue = ValidBindParameterType | boolean | null;
58
+
59
+ export type ReplicaSyncDirection = "bidirectional" | "upload" | "download";
60
+
61
+ export type ReplicaSyncDataFormat = "pbf" | "spbf" | "geoparquet" | "sqlite";
62
+
63
+ /** Base options shared by replica create request variants. */
64
+ export interface BaseReplicaOptions {
65
+ /** Requested name to use when creating the replica. */
66
+ requestedReplicaName: string;
67
+ /** Optional requested replica id in UUID string format. */
68
+ requestedReplicaId?: string;
69
+ /** Synchronization direction for the replica operation. */
70
+ syncDirection: ReplicaSyncDirection;
71
+ /** Data format to use for replica synchronization payloads. */
72
+ syncDataFormat: ReplicaSyncDataFormat;
73
+ /** The type of the replica creation options */
74
+ type: "reference" | "filter";
75
+ }
76
+
77
+ /** Additional options used by [executeCreateReplica()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeCreateReplica) for reference replica creation. */
78
+ export interface ReferenceReplicaOptions extends BaseReplicaOptions {
79
+ /** Reference replica used as a create baseline. */
80
+ referenceReplica: ReplicaReference;
81
+ /** The type of the replica creation options */
82
+ type: "reference";
83
+ }
84
+
85
+ /** Additional options used by [executeCreateReplica()](https://developers.arcgis.com/javascript/latest/references/core/rest/knowledgeGraphService/#executeCreateReplica) for filtered replica creation. */
86
+ export interface FilterReplicaOptions extends BaseReplicaOptions {
87
+ /** filters to define the replica scope. */
88
+ replicaFilters: ReplicaFilters;
89
+ /** The type of the replica creation options */
90
+ type: "filter";
91
+ }
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{property as o,subclass as r}from"../../core/accessorSupport/decorators.js";let i=class extends e{constructor(t){super(t),this.replicaName=null,this.replicaId=null,this.replicaOwner=null,this.lastSyncDate=null,this.creationDate=null,this.syncDirection=null,this.replicaFilters=null}};t([o()],i.prototype,"replicaName",void 0),t([o()],i.prototype,"replicaId",void 0),t([o()],i.prototype,"replicaOwner",void 0),t([o()],i.prototype,"lastSyncDate",void 0),t([o()],i.prototype,"creationDate",void 0),t([o()],i.prototype,"syncDirection",void 0),t([o()],i.prototype,"replicaFilters",void 0),i=t([r("esri.rest.knowledgeGraph.ReplicaDefinition")],i);export{i as default};