@arcgis/core 4.30.0-next.20240321 → 4.30.0-next.20240323

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 (84) hide show
  1. package/arcade/Dictionary.js +1 -1
  2. package/arcade/Feature.js +1 -1
  3. package/arcade/featureset/actions/Adapted.js +1 -1
  4. package/arcade/featureset/support/shared.js +1 -1
  5. package/arcade/featureset/support/sqlUtils.js +1 -1
  6. package/arcade/parser.js +1 -1
  7. package/arcade/validation/arcadeValidator.js +1 -1
  8. package/arcade/validation/languageKeywords.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/{4e4ad7ac43a72a2f88a1.js → 0005267c754235ae6784.js} +1 -1
  11. package/assets/esri/core/workers/chunks/07fd6804c7eaa8d2ac3f.js +1 -0
  12. package/assets/esri/core/workers/chunks/{ff4151d794ec73064fac.js → 10b4fbdc0f8be85737f0.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{8fc69ac4cce6d4dd5513.js → 18a9b472007d4f2b7bbb.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{f484d2a3deb3c60d7038.js → 1ad1cdde4db5ab793623.js} +1 -1
  15. package/assets/esri/core/workers/chunks/36dfc55dc536b1831918.js +1 -0
  16. package/assets/esri/core/workers/chunks/{cee492b97e841a6d4678.js → 5b41ec1bd24314f6f153.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{d518a0adc3d88700235c.js → 65680926c761bf53fd14.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{9c78ccff1c7f8ae90b06.js → 671892e733d8976e48bb.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{4be6d5660ec1c8ac7606.js → 70188e0aa47da1aa1a7f.js} +1 -1
  20. package/assets/esri/core/workers/chunks/7c212395100080cf122e.js +1 -0
  21. package/assets/esri/core/workers/chunks/8c07e1000522c3251ac0.js +1 -0
  22. package/assets/esri/core/workers/chunks/9d240e70a24520b2a810.js +1 -0
  23. package/assets/esri/core/workers/chunks/{ee1345b212cde1ff4755.js → a7ac2c5e701f44a67aa3.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{5a747af5273646ab848c.js → c38c6cae22627fbf6f3b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/c4d2ff515fc70b07cb5f.js +1 -0
  26. package/assets/esri/core/workers/chunks/{96fd6fd8cbb3a2ee088e.js → caa03837b9c173ea493f.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{dd5a078b7919f749ba3e.js → d90ee005599c44bfb6ad.js} +1 -1
  28. package/assets/esri/core/workers/chunks/dc3a6ab23a13ec5deed7.js +1 -0
  29. package/assets/esri/core/workers/chunks/{eb3e82ed1653ecf348da.js → e1a2f7282d889e251809.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{52274afa07468bc555aa.js → ec52127b5ada8410acf3.js} +13 -13
  31. package/assets/esri/core/workers/chunks/f8693321bbd8a93666c7.js +1 -0
  32. package/assets/esri/core/workers/chunks/{fe7dfb8546d0fc40843c.js → fec0d24e8841ba1994f0.js} +1 -1
  33. package/chunks/LineSeries.js +1 -1
  34. package/chunks/Theme.js +1 -1
  35. package/chunks/index.js +5 -0
  36. package/chunks/languageUtils.js +1 -1
  37. package/core/number.js +1 -1
  38. package/core/workers/loaderConfig.js +1 -1
  39. package/interfaces.d.ts +3 -3
  40. package/layers/mixins/ArcGISImageService.js +1 -1
  41. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  42. package/package.json +1 -1
  43. package/rest/knowledgeGraphService.js +1 -1
  44. package/support/revision.js +1 -1
  45. package/symbols/cim/cimAnalyzer.js +1 -1
  46. package/undoredo/support/DataEditingContext.js +5 -0
  47. package/views/2d/constraints/ZoomConstraint.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/markers/ComputedMarkerParams.js +1 -1
  49. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  50. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  51. package/views/2d/layers/features/schema/processor/symbols/utils.js +5 -0
  52. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  53. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  54. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  55. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  56. package/views/3d/terrain/TerrainRenderer.js +1 -1
  57. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  58. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  59. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  60. package/views/3d/webgl-engine/lib/IntersectorInterfaces.js +1 -1
  61. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  62. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  63. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  64. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  65. package/widgets/BasemapLayerList.js +1 -1
  66. package/widgets/LayerList.js +1 -1
  67. package/widgets/TableList.js +1 -1
  68. package/arcade/lib/arcade-parser.js +0 -5
  69. package/arcade/lib/assert.js +0 -5
  70. package/arcade/lib/character.js +0 -5
  71. package/arcade/lib/comment-handler.js +0 -5
  72. package/arcade/lib/error-handler.js +0 -5
  73. package/arcade/lib/parser.js +0 -5
  74. package/arcade/lib/scanner.js +0 -5
  75. package/arcade/lib/tokenizer.js +0 -5
  76. package/arcade/lib/types.js +0 -5
  77. package/assets/esri/core/workers/chunks/12b95408753cea053a40.js +0 -1
  78. package/assets/esri/core/workers/chunks/16397420fb6067b47b25.js +0 -1
  79. package/assets/esri/core/workers/chunks/1fdbeb110fae52b96bb3.js +0 -1
  80. package/assets/esri/core/workers/chunks/689a122c77b39e5c73eb.js +0 -1
  81. package/assets/esri/core/workers/chunks/7b07f3bc68a54974cd03.js +0 -1
  82. package/assets/esri/core/workers/chunks/ad95daa3f4ad7030bf24.js +0 -1
  83. package/assets/esri/core/workers/chunks/c2573c1cb7c714435acc.js +0 -1
  84. package/assets/esri/core/workers/chunks/df38774f63984be0a478.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{rasterRendererTypes as r,websceneRasterRendererTypes as i,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import a from"../../core/Error.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{watch as p}from"../../core/reactiveUtils.js";import{urlToObject as m}from"../../core/urlUtils.js";import{property as c,ensureRange as d}from"../../core/accessorSupport/decorators/property.js";import{Integer as h,ensureClass as g,ensureNumber as f}from"../../core/accessorSupport/ensureType.js";import{reader as y}from"../../core/accessorSupport/decorators/reader.js";import{subclass as R}from"../../core/accessorSupport/decorators/subclass.js";import{writer as b}from"../../core/accessorSupport/decorators/writer.js";import{srToRESTValue as I}from"../../geometry/support/spatialReferenceUtils.js";import{opacity as w,url as v}from"../support/commonProperties.js";import S from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as x}from"../support/ExportImageServiceParameters.js";import _ from"../support/Field.js";import F from"../support/FieldsIndex.js";import{createBitmap as D}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as T}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import j from"../support/MultidimensionalSubset.js";import O from"../support/PixelBlock.js";import{interpolationKebab as M,noDataInterpretationKebab as C,pixelTypeKebabDict as N}from"../support/rasterEnums.js";import q from"../support/RasterFunction.js";import A from"../support/RasterInfo.js";import E from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as J,getSubsetVariablesFromMdInfo as V,getDefaultMultidimensionalDefinition as Q}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as H,getFormat as U}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as B}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as L,getDefaultBandCombination as z,createDefaultRenderer as G,normalizeRendererJSON as k}from"../../renderers/support/rasterRendererHelper.js";import W from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as $,computePixelSpaceLocations as X,computeHistograms as K,computeStatisticsHistograms as Y,measureHeight as Z,measureAreaAndPerimeter as ee,measureDistanceAndAngle as te,measurePointOrCentroid as re,measureLengthFromImage as ie,measureAreaFromImage as se,getImageSpatialReferenceQueryParameter as ne,getSamples as oe,identify as ae,imageToMap as le,imageToMapMultiray as ue,mapToImage as pe,findImages as me,getImageUrl as ce,queryBoundary as de,queryGPSInfo as he}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as ge}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/ellipsoidUtils.js";import"../../geometry/support/aaBoundingBox.js";import"../../core/mathUtils.js";import fe from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import ye from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtilsCommon.js";import Re from"../../geometry/SpatialReference.js";import"../../geometry/support/Ellipsoid.js";import"../../core/pbf.js";import be from"../../rest/support/FeatureSet.js";import Ie from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as we}from"../../rest/query/executeForCount.js";import{executeForIds as ve}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{generateRasterInfo as Se,fetchServiceRasterInfo as xe,patchServiceInfo as _e}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as Fe}from"../../rest/imageService/getCatalogItemRasterInfo.js";import De from"../../rest/support/FindImagesParameters.js";import Te from"../../rest/support/ImageAngleParameters.js";import Pe from"../../rest/support/ImageAreaParameters.js";import je from"../../rest/support/ImageBoundaryParameters.js";import Oe from"../../rest/support/ImageDistanceParameters.js";import Me from"../../rest/support/ImageGPSInfoParameters.js";import Ce from"../../rest/support/ImageHeightParameters.js";import Ne from"../../rest/support/ImageHistogramParameters.js";import qe from"../../rest/support/ImageIdentifyParameters.js";import Ae from"../../rest/support/ImagePixelLocationParameters.js";import Ee from"../../rest/support/ImagePointParameters.js";import Je from"../../rest/support/ImageSampleParameters.js";import Ve from"../../rest/support/ImageToMapMultirayParameters.js";import Qe from"../../rest/support/ImageToMapParameters.js";import He from"../../rest/support/ImageUrlParameters.js";import Ue from"../../rest/support/MapToImageParameters.js";import Be from"../../rest/support/MeasureFromImageParameters.js";import{createFlowMesh as Le}from"../../views/2d/engine/flow/dataUtils.js";const ze=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),Ge=d(f,{min:0,max:255});function ke(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=t?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const We=d=>{let f=class extends d{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._cachedRendererJson=null,this._serviceSupportsMosaicRule=null,this._rasterAttributeTableFieldPrefix="Raster.",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 x({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,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?P.fromJSON(t):null}get fieldsIndex(){return this.fields?new F(this.fields):null}set format(e){e&&ze.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"}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=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?P.fromJSON(r):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new P({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=Ge(e))}readObjectIdField(e,t){if(!e){const r=t.fields.find((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r?.name}return e}get parsedUrl(){return m(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer,n=s(i,r);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!i.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),T(n)||u.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix,t=new _({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new _({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new _({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities?.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new _({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new _({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new _({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const{attributeTable:n}=this.rasterInfo??{};if(null!=n){const t=n.fields.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}get renderingRule(){return o(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this.rasterFunction}set renderingRule(e){o(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this._set("rasterFunction",e)}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=q.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r?.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?q.fromJSON({rasterFunctionDefinition:t.renderingRule}):q.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?Re.fromJSON(r):null}readPixelType(e){return N.fromJSON(e)||e}writePixelType(e,t,r){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[r]=N.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;const{renderer:i,symbolizer:s,pixelFilter:n,bandIds:o}=this;if(!this._isPicture()&&i&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(i.toJSON()),a=this._rasterJobHandler.instance;if(a){n&&(s.bind(),await a.updateSymbolizer(s,t),this._cachedRendererJson=i.toJSON());const l=await a.symbolize({bandIds:o,...e},t);r={extent:e.extent,pixelBlock:l}}else r={extent:e.extent,pixelBlock:s.symbolize({bandIds:o,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=g(Te,e).clone(),$(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new a("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=g(Ae,e).clone(),X(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=g(Ne,e).clone(),this._applyMosaicAndRenderingRules(e),K(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=g(Ne,e).clone(),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const r=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?r.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?r.mensuration.supportsHeightFromBaseAndTopShadow:r.mensuration.supportsHeightFromTopAndTopShadow))throw new a("imagery-layer:measure-height","this operation is not supported on the input image service");return e=g(Ce,e).clone(),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsAreaAndPerimeter&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=g(Pe,e).clone(),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsDistanceAndAngle&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=g(Oe,e).clone(),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsPointOrCentroid&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=g(Ee,e).clone(),this._applyMosaicAndRenderingRules(e),re(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new a("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new a("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return e=g(Be,e).clone(),ie(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new a("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new a("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return e=g(Be,e).clone(),se(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}async fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)throw new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");if(this.renderer||this.symbolizer){const e=await this._generateRasterInfo(this.rasterFunction,{signal:i.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,r,i.timeExtent);if(null==s){if(i.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=r,i.returnImageBitmap){return{imageBitmap:await D(e,`${We(this.parsedUrl)}/exportImage`,i.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,o=(s?.length||n.bandCount)??0,a=t*r,l=n.pixelType,u=[];for(let e=0;e<o;e++)u.push(O.createEmptyBand(l,a));return{pixelData:{pixelBlock:new O({width:t,height:r,pixels:u,mask:new Uint8Array(a),pixelType:l}),extent:e}}}const n=!!i.requestAsImageElement&&!this.pixelFilter,o=n&&!!i.returnImageBitmap,l={imageServiceParameters:s,imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:n,returnImageBitmap:o,signal:i.signal};return this._requestArrayBuffer(l)}fetchKeyProperties(e){return n(We(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 a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(We(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then((e=>be.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return Fe(We(this.parsedUrl),e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(We(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r?.ics;if(!i)return;let s=null;try{s=(await n(We(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(We(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:I(a),outSR:"0:"+e},u=n(We(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,m=(s.xmin+s.xmax)/2,c=(s.ymax-s.ymin)/(p+1),d=s.ymin+c,h=[];for(let n=0;n<p;n++)h.push({x:m,y:d+c*n});const g={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:I(a),outSR:"0:"+e},f=n(We(this.parsedUrl)+"/project",{query:this._getQueryParams(g),...t}).then((e=>e.data)).catch((()=>({}))),y=await Promise.all([o,u,f]);let R=y[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=fe.fromJSON(y[1]?.geometries?.[0]);b&&(b.spatialReference=new Re({wkid:0,imageCoordinateSystem:i}));const w=y[2].geometries?y[2].geometries.filter((e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],v=w.length;if(v<3)return{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:null};let S=0,x=0,_=0,F=0;for(let n=0;n<v;n++)S+=w[n].x,x+=w[n].y,_+=w[n].x*w[n].x,F+=w[n].x*w[n].y;const D=(v*F-S*x)/(v*_-S*S);let T=0;const P=w[p-1].x>w[0].x,j=w[p-1].y>w[0].y;return D===1/0?T=j?90:270:0===D?T=P?0:180:D>0?T=P?180*Math.atan(D)/Math.PI:180*Math.atan(D)/Math.PI+180:D<0&&(T=j?180+180*Math.atan(D)/Math.PI:360+180*Math.atan(D)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:T}}async generateRasterInfo(e,t){if(e=g(q,e),this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const r=ke(e);if(!r)throw new a("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i={...t,query:this._getQueryParams()},s=Se(We(this.parsedUrl),e,i);this._functionRasterInfos[r]=s;try{return await s}catch(n){throw this._functionRasterInfos[r]=null,n}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=ne(e.spatialReference,We(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.rasterFunction?.rasterFunctionDefinition,p=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!u&&p){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const m=this._processMultidimensionalIntersection(null,i,this.exportImageServiceParameters.mosaicRule);if(m.isOutSide)return null;n.mosaicRule=null!=m.mosaicRule?JSON.stringify(m.mosaicRule):null,i=m.timeExtent,n.renderingRule=this._getRenderingRuleString(q.fromJSON(l));const c={};if(null!=i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?c.time=""+e:null==e&&null==t||(c.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...c}}async getSamples(e,t){const r=await this._fetchCapabilities(t?.signal);if(!r?.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=g(Je,e).clone();const{raster:i}=this;return i&&null==e.raster&&(e.raster=i),oe(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new a("imagery-layer:identify","identify operation is not supported on the input image service");e=g(qe,e).clone(),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=ye.fromExtent(e.geometry));const r=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(r.isOutSide)throw new a("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=r.timeExtent,e.mosaicRule=r.mosaicRule;const{raster:i,rasterFunction:s}=this;return s&&null==e.rasterFunction&&(e.rasterFunction=s),i&&null==e.raster&&(e.raster=i),ae(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new a("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return e=g(Qe,e),le(We(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new a("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return e=g(Ve,e),ue(We(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new a("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return e=g(Ue,e),pe(We(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new a("imagery-layer:find-images","findImages operation is not supported on the input image service");return e=g(De,e),me(We(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new a("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return e=g(He,e),ce(We(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ie({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new a("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=g(je,e??{outSpatialReference:this.spatialReference}).clone(),de(We(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ge(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ve(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new a("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=g(Me,e??{outSpatialReference:this.spatialReference}).clone(),he(We(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),we(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new a("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p="raster.servicepixelvalue",m=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some((e=>!e.toLowerCase().includes(p))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(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 q({functionName:e[0]}))),u=t.map((e=>e[1]));const{rasterFunction:r}=this;0===l.length?r?.functionName?(l.push(r),u.push(r.functionName)):l=null:r?.functionName&&!l.some((e=>e.functionName===r.functionName))&&(l.push(r),u.push(r.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:d}=this;let h=e.timeExtent||this.timeExtent;if(d){const{isOutside:t,intersection:r}=J(d,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new a("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=r?.timeExtent&&(h=r.timeExtent)}const g=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,h);let f=e.geometry;this.version<10.91&&"extent"===f?.type&&(f=ye.fromExtent(f));const y=this._getQueryParams({geometry:f,timeExtent:h,mosaicRule:g,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:r,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:s?1:null});delete y.f;const R=new qe(y);try{await this._generateRasterInfo(this.rasterFunction);const r=await ae(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,a=null!=r.value&&r.value.toLowerCase().includes("nodata");if(!(o&&!c&&r?.catalogItems?.features.length&&(n||!a)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",p=r.catalogItems?.features??[],m=p.map((e=>e.attributes?.[l])),d=new Ie({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{p.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new ye(t.geometry),null!=e.outSpatialReference&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(We(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(We(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):Le(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return V(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):xe(We(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),_e(e,t),e))),i=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),u.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.addHandles([p((()=>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 r=this.timeInfo,{multidimensionalInfo:i}=this.serviceRasterInfo;if(null==e||null==i||null==t||null==r?.startField)return e;const{startField:s}=r,n=i.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 o=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),a=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==a||null==l||a===l,p=u?[a||l]:[[a,l]],m=this.version>=10.8;if(o.length)o.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 S({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 a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=null!=e?g(Ie,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new E;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>{})),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:r}=this;return"unique-value"===e.type&&this._hasRasterFunction(r)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&L(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:i}=await n(We(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new a("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),r=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:r}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&r.bandCount>=3){const e=z(r);!e||3===r.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=G(r,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=k(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=r):this.symbolizer=new W({rendererJSON:t,rasterInfo:r}),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:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):H(e,t,r)}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 n(We(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:r,returnImageBitmap:i,signal:s}=e;if(r&&this._canRequestImageElement(t.format)){const r=`${We(this.parsedUrl)}/exportImage`,{data:o}=await n(r,{responseType:i?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:s});if(o instanceof Blob){return{imageBitmap:await D(o,r,s),params:t}}return{imageOrCanvasElement:o,params:t}}const o=this._initJobHandler(),l=n(We(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let m=p;if("bsq"!==m&&"bip"!==m&&(m=U(u)),!m)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===m||"jpg"===m)?H(u,{useCanvas:!0,...t},c):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},c);return{pixelData:{pixelBlock:await d,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=Q(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new P;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,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=r,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 i&&i.toLowerCase().includes("nodata"),d=[];if(i&&!u&&!c){const e={};e[m]=0;p=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let h,g,f;this._updateResponseFieldNames(u,a),c&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(h=u[t],null!=i){if(g=p[t],f=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:i,"nodata"===g.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";h.attributes[e]=g,h.attributes[r]=f,this._updateFeatureWithMagDirValues(h,g);const o=this.fields&&this.fields.length>0;let a=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?g:i:f;this.rasterFunction||(a=o?g:i),this._updateFeatureWithRasterAttributeTableValues(h,a)}if(h.sourceLayer=h.layer=this,o&&this._updateFeatureWithDomainValues(h),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];h.attributes[t]=l[e]}d.push(u[t])}return d}_processMultidimensionalIntersection(e,t,r){const{multidimensionalSubset:i}=this;if(!i)return{isOutSide:!1,timeExtent:t,mosaicRule:r=this._combineMosaicRuleWithTimeExtent(r,t)};if(i){const{isOutside:r,intersection:s}=J(i,{geometry:e,timeExtent:t});if(r)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(r=this._combineMosaicRuleWithTimeExtent(r,t),r?.multidimensionalDefinition){const{isOutside:e}=J(i,{multidimensionalDefinition:r.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:r}}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==r)return;const{features:i,fields:s}=r,n=s.map((e=>e.name)).find((e=>"value"===e.toLowerCase()));if(!n)return;const o=i.filter((e=>e.attributes[n]===(null!=t?parseInt(t,10):null)));o&&o[0]&&s.forEach((t=>{const r=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=o[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new O({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new fe(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:B([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;null!=r&&e.forEach((e=>{if(e?.attributes)for(const i of t){const t=r.get(i)?.name;t&&t!==i&&(e.attributes[i]=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 r=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(r)?t.get(r):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:r,rasterFunction:i}=this;i&&e instanceof Ne&&null==e.rasterFunction&&(e.rasterFunction=i),r&&null==e.mosaicRule&&(e.mosaicRule=r),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&a,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),m=u&&p.includes("basic"),c=this._isMosaicDataset(e)&&t.includes("catalog"),d=t.includes("download");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsImageToMap:r>=11.2&&c,supportsImageToMapMultiray:r>=11.2&&c,supportsMapToImage:r>=11.2&&c,supportsFindImages:r>=11.2&&c,supportsGetImageUrl:r>=11.2&&d,supportsMeasure:u,supportsMeasureFromImage:r>=11.2,supportsDownload:d,supportsQuery:c&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&o,supportsComputePixelLocation:r>=10.7&&c,supportsComputeAngles:r>=10.91,supportsQueryGPSInfo:r>=11.2&&c,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:m,supportsAreaAndPerimeter:m,supportsPointOrCentroid:m,supportsHeightFromBaseAndTop:u&&p.includes("base-top height"),supportsHeightFromBaseAndTopShadow:u&&p.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:u&&p.includes("top-top shadow height"),supports3D:u&&p.includes("3d")}}}};function We(e){return e?.path??""}return e([c({clonable:!1})],f.prototype,"_functionRasterInfos",void 0),e([c({clonable:!1})],f.prototype,"_rasterJobHandler",void 0),e([c({clonable:!1})],f.prototype,"_cachedRendererJson",void 0),e([c({readOnly:!0})],f.prototype,"_serviceSupportsMosaicRule",void 0),e([y("_serviceSupportsMosaicRule",["currentVersion","fields"])],f.prototype,"readServiceSupportsMosaicRule",null),e([c({readOnly:!0})],f.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([c({readOnly:!0})],f.prototype,"_rasterFunctionNamesIndex",null),e([c()],f.prototype,"adjustAspectRatio",void 0),e([c({type:[h],json:{write:!0}})],f.prototype,"bandIds",void 0),e([y("bandIds")],f.prototype,"readBandIds",null),e([c({readOnly:!0,json:{read:!1}})],f.prototype,"capabilities",void 0),e([y("service","capabilities",["capabilities","currentVersion","serviceDataType"])],f.prototype,"readCapabilities",null),e([c({type:Number})],f.prototype,"compressionQuality",void 0),e([b("compressionQuality")],f.prototype,"writeCompressionQuality",null),e([c({type:Number})],f.prototype,"compressionTolerance",void 0),e([b("compressionTolerance")],f.prototype,"writeCompressionTolerance",null),e([c({json:{read:{source:"copyrightText"}}})],f.prototype,"copyright",void 0),e([c({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],f.prototype,"defaultMosaicRule",void 0),e([y("defaultMosaicRule",["defaultMosaicMethod"])],f.prototype,"readDefaultMosaicRule",null),e([c({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],f.prototype,"definitionExpression",void 0),e([c({readOnly:!0,constructOnly:!0})],f.prototype,"exportImageServiceParameters",void 0),e([c()],f.prototype,"rasterInfo",void 0),e([c({readOnly:!0,type:[_]})],f.prototype,"fields",void 0),e([c({readOnly:!0})],f.prototype,"fieldsIndex",null),e([c({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],f.prototype,"format",null),e([y("service","format",["serviceDataType"])],f.prototype,"readFormat",null),e([c({type:fe})],f.prototype,"fullExtent",void 0),e([c({readOnly:!0})],f.prototype,"hasMultidimensions",void 0),e([c({json:{read:{source:"maxImageHeight"}}})],f.prototype,"imageMaxHeight",void 0),e([c({json:{read:{source:"maxImageWidth"}}})],f.prototype,"imageMaxWidth",void 0),e([c({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],f.prototype,"interpolation",void 0),e([c()],f.prototype,"minScale",void 0),e([y("service","minScale")],f.prototype,"readMinScale",null),e([c()],f.prototype,"maxScale",void 0),e([y("service","maxScale")],f.prototype,"readMaxScale",null),e([c({type:P})],f.prototype,"mosaicRule",null),e([y("mosaicRule",["mosaicRule","defaultMosaicMethod"])],f.prototype,"readMosaicRule",null),e([b("mosaicRule")],f.prototype,"writeMosaicRule",null),e([c()],f.prototype,"multidimensionalInfo",void 0),e([c({type:j,json:{write:!0}})],f.prototype,"multidimensionalSubset",void 0),e([c({json:{type:h}})],f.prototype,"noData",void 0),e([b("noData")],f.prototype,"writeNoData",null),e([c({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],f.prototype,"noDataInterpretation",void 0),e([c({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],f.prototype,"objectIdField",void 0),e([y("objectIdField")],f.prototype,"readObjectIdField",null),e([c({readOnly:!0})],f.prototype,"geometryType",void 0),e([c({})],f.prototype,"typeIdField",void 0),e([c({})],f.prototype,"types",void 0),e([c({readOnly:!0})],f.prototype,"parsedUrl",null),e([c({type:Function})],f.prototype,"pixelFilter",void 0),e([c()],f.prototype,"raster",void 0),e([c({readOnly:!0})],f.prototype,"sourceType",void 0),e([y("sourceType",["serviceSourceType","fields"])],f.prototype,"readSourceType",null),e([c()],f.prototype,"viewId",void 0),e([c({types:r,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],f.prototype,"renderer",null),e([y("renderer")],f.prototype,"readRenderer",null),e([b("renderer")],f.prototype,"writeRenderer",null),e([c({clonable:!1})],f.prototype,"symbolizer",void 0),e([c(w)],f.prototype,"opacity",void 0),e([c({readOnly:!0})],f.prototype,"rasterFields",null),e([c({constructOnly:!0})],f.prototype,"rasterFunctionInfos",void 0),e([c({type:q})],f.prototype,"renderingRule",null),e([c({type:q,json:{name:"renderingRule"}})],f.prototype,"rasterFunction",null),e([y("rasterFunction",["renderingRule","rasterFunctionInfos"])],f.prototype,"readRasterFunction",null),e([c({readOnly:!0})],f.prototype,"serviceDataType",void 0),e([c({readOnly:!0,type:Re})],f.prototype,"spatialReference",void 0),e([y("spatialReference",["spatialReference","extent"])],f.prototype,"readSpatialReference",null),e([c({json:{type:N.jsonValues}})],f.prototype,"pixelType",void 0),e([y("pixelType")],f.prototype,"readPixelType",null),e([b("pixelType")],f.prototype,"writePixelType",null),e([c({constructOnly:!0,type:A})],f.prototype,"serviceRasterInfo",void 0),e([c()],f.prototype,"sourceJSON",void 0),e([c(v)],f.prototype,"url",void 0),e([c({readOnly:!0})],f.prototype,"version",void 0),e([y("version",["currentVersion","fields","timeInfo"])],f.prototype,"readVersion",null),f=e([R("esri.layers.mixins.ArcGISImageService")],f),f};export{We as ArcGISImageService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{rasterRendererTypes as r,websceneRasterRendererTypes as i,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import{deprecatedProperty as a}from"../../core/deprecate.js";import o from"../../core/Error.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{watch as p}from"../../core/reactiveUtils.js";import{urlToObject as m}from"../../core/urlUtils.js";import{property as c,ensureRange as d}from"../../core/accessorSupport/decorators/property.js";import{Integer as h,ensureClass as g,ensureNumber as f}from"../../core/accessorSupport/ensureType.js";import{reader as y}from"../../core/accessorSupport/decorators/reader.js";import{subclass as R}from"../../core/accessorSupport/decorators/subclass.js";import{writer as b}from"../../core/accessorSupport/decorators/writer.js";import{srToRESTValue as I}from"../../geometry/support/spatialReferenceUtils.js";import{opacity as w,url as v}from"../support/commonProperties.js";import S from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as x}from"../support/ExportImageServiceParameters.js";import _ from"../support/Field.js";import F from"../support/FieldsIndex.js";import{createBitmap as D}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as T}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import j from"../support/MultidimensionalSubset.js";import O from"../support/PixelBlock.js";import{interpolationKebab as M,noDataInterpretationKebab as C,pixelTypeKebabDict as N}from"../support/rasterEnums.js";import q from"../support/RasterFunction.js";import A from"../support/RasterInfo.js";import E from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as J,getSubsetVariablesFromMdInfo as V,getDefaultMultidimensionalDefinition as Q}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as H,getFormat as U}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as B}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as L,getDefaultBandCombination as z,createDefaultRenderer as G,normalizeRendererJSON as k}from"../../renderers/support/rasterRendererHelper.js";import W from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as $,computePixelSpaceLocations as X,computeHistograms as K,computeStatisticsHistograms as Y,measureHeight as Z,measureAreaAndPerimeter as ee,measureDistanceAndAngle as te,measurePointOrCentroid as re,measureLengthFromImage as ie,measureAreaFromImage as se,getImageSpatialReferenceQueryParameter as ne,getSamples as ae,identify as oe,imageToMap as le,imageToMapMultiray as ue,mapToImage as pe,findImages as me,getImageUrl as ce,queryBoundary as de,queryGPSInfo as he}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as ge}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/ellipsoidUtils.js";import"../../geometry/support/aaBoundingBox.js";import"../../core/mathUtils.js";import fe from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import ye from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtilsCommon.js";import Re from"../../geometry/SpatialReference.js";import"../../geometry/support/Ellipsoid.js";import"../../core/pbf.js";import be from"../../rest/support/FeatureSet.js";import Ie from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as we}from"../../rest/query/executeForCount.js";import{executeForIds as ve}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{generateRasterInfo as Se,fetchServiceRasterInfo as xe,patchServiceInfo as _e}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as Fe}from"../../rest/imageService/getCatalogItemRasterInfo.js";import De from"../../rest/support/FindImagesParameters.js";import Te from"../../rest/support/ImageAngleParameters.js";import Pe from"../../rest/support/ImageAreaParameters.js";import je from"../../rest/support/ImageBoundaryParameters.js";import Oe from"../../rest/support/ImageDistanceParameters.js";import Me from"../../rest/support/ImageGPSInfoParameters.js";import Ce from"../../rest/support/ImageHeightParameters.js";import Ne from"../../rest/support/ImageHistogramParameters.js";import qe from"../../rest/support/ImageIdentifyParameters.js";import Ae from"../../rest/support/ImagePixelLocationParameters.js";import Ee from"../../rest/support/ImagePointParameters.js";import Je from"../../rest/support/ImageSampleParameters.js";import Ve from"../../rest/support/ImageToMapMultirayParameters.js";import Qe from"../../rest/support/ImageToMapParameters.js";import He from"../../rest/support/ImageUrlParameters.js";import Ue from"../../rest/support/MapToImageParameters.js";import Be from"../../rest/support/MeasureFromImageParameters.js";import{createFlowMesh as Le}from"../../views/2d/engine/flow/dataUtils.js";const ze=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),Ge=d(f,{min:0,max:255});function ke(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=t?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const We=d=>{let f=class extends d{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._cachedRendererJson=null,this._serviceSupportsMosaicRule=null,this._rasterAttributeTableFieldPrefix="Raster.",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 x({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,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?P.fromJSON(t):null}get fieldsIndex(){return this.fields?new F(this.fields):null}set format(e){e&&ze.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"}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=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?P.fromJSON(r):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new P({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=Ge(e))}readObjectIdField(e,t){if(!e){const r=t.fields.find((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r?.name}return e}get parsedUrl(){return m(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer,n=s(i,r);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!i.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),T(n)||u.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix,t=new _({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new _({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new _({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities?.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new _({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new _({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new _({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const{attributeTable:n}=this.rasterInfo??{};if(null!=n){const t=n.fields.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}get renderingRule(){return a(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this.rasterFunction}set renderingRule(e){a(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this._set("rasterFunction",e)}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=q.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r?.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?q.fromJSON({rasterFunctionDefinition:t.renderingRule}):q.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?Re.fromJSON(r):null}readPixelType(e){return N.fromJSON(e)||e}writePixelType(e,t,r){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[r]=N.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;const{renderer:i,symbolizer:s,pixelFilter:n,bandIds:a}=this;if(!this._isPicture()&&i&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(i.toJSON()),o=this._rasterJobHandler.instance;if(o){n&&(s.bind(),await o.updateSymbolizer(s,t),this._cachedRendererJson=i.toJSON());const l=await o.symbolize({bandIds:a,...e},t);r={extent:e.extent,pixelBlock:l}}else r={extent:e.extent,pixelBlock:s.symbolize({bandIds:a,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new o("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=g(Te,e).clone(),$(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new o("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=g(Ae,e).clone(),X(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new o("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=g(Ne,e).clone(),this._applyMosaicAndRenderingRules(e),K(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new o("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=g(Ne,e).clone(),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const r=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?r.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?r.mensuration.supportsHeightFromBaseAndTopShadow:r.mensuration.supportsHeightFromTopAndTopShadow))throw new o("imagery-layer:measure-height","this operation is not supported on the input image service");return e=g(Ce,e).clone(),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsAreaAndPerimeter&&(!e.is3D||r.mensuration.supports3D)))throw new o("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=g(Pe,e).clone(),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsDistanceAndAngle&&(!e.is3D||r.mensuration.supports3D)))throw new o("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=g(Oe,e).clone(),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsPointOrCentroid&&(!e.is3D||r.mensuration.supports3D)))throw new o("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=g(Ee,e).clone(),this._applyMosaicAndRenderingRules(e),re(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new o("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new o("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return e=g(Be,e).clone(),ie(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new o("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new o("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return e=g(Be,e).clone(),se(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}async fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)throw new o("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");if(this.renderer||this.symbolizer){const e=await this._generateRasterInfo(this.rasterFunction,{signal:i.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,r,i.timeExtent);if(null==s){if(i.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=r,i.returnImageBitmap){return{imageBitmap:await D(e,`${We(this.parsedUrl)}/exportImage`,i.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*r,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(O.createEmptyBand(l,o));return{pixelData:{pixelBlock:new O({width:t,height:r,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const n=!!i.requestAsImageElement&&!this.pixelFilter,a=n&&!!i.returnImageBitmap,l={imageServiceParameters:s,imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:n,returnImageBitmap:a,signal:i.signal};return this._requestArrayBuffer(l)}fetchKeyProperties(e){return n(We(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 o("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(We(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then((e=>be.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return Fe(We(this.parsedUrl),e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(We(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r?.ics;if(!i)return;let s=null;try{s=(await n(We(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(We(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:I(o),outSR:"0:"+e},u=n(We(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,m=(s.xmin+s.xmax)/2,c=(s.ymax-s.ymin)/(p+1),d=s.ymin+c,h=[];for(let n=0;n<p;n++)h.push({x:m,y:d+c*n});const g={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:I(o),outSR:"0:"+e},f=n(We(this.parsedUrl)+"/project",{query:this._getQueryParams(g),...t}).then((e=>e.data)).catch((()=>({}))),y=await Promise.all([a,u,f]);let R=y[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=fe.fromJSON(y[1]?.geometries?.[0]);b&&(b.spatialReference=new Re({wkid:0,imageCoordinateSystem:i}));const w=y[2].geometries?y[2].geometries.filter((e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],v=w.length;if(v<3)return{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:null};let S=0,x=0,_=0,F=0;for(let n=0;n<v;n++)S+=w[n].x,x+=w[n].y,_+=w[n].x*w[n].x,F+=w[n].x*w[n].y;const D=(v*F-S*x)/(v*_-S*S);let T=0;const P=w[p-1].x>w[0].x,j=w[p-1].y>w[0].y;return D===1/0?T=j?90:270:0===D?T=P?0:180:D>0?T=P?180*Math.atan(D)/Math.PI:180*Math.atan(D)/Math.PI+180:D<0&&(T=j?180+180*Math.atan(D)/Math.PI:360+180*Math.atan(D)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:T}}async generateRasterInfo(e,t){if(e=g(q,e),this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const r=ke(e);if(!r)throw new o("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i={...t,query:this._getQueryParams()},s=Se(We(this.parsedUrl),e,i);this._functionRasterInfos[r]=s;try{return await s}catch(n){throw this._functionRasterInfos[r]=null,n}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=ne(e.spatialReference,We(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:a,noData:o}=n;let{renderingRule:l}=n;const u=this.rasterFunction?.rasterFunctionDefinition,p=!this.renderer||"raster-stretch"===this.renderer.type;if(a?.length&&this._hasRasterFunction(this.rasterFunction)&&!u&&p){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:a}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=a?.join(",");Array.isArray(o)&&o.length>0&&(n.noData=o.join(","));const m=this._processMultidimensionalIntersection(null,i,this.exportImageServiceParameters.mosaicRule);if(m.isOutSide)return null;n.mosaicRule=null!=m.mosaicRule?JSON.stringify(m.mosaicRule):null,i=m.timeExtent,n.renderingRule=this._getRenderingRuleString(q.fromJSON(l));const c={};if(null!=i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?c.time=""+e:null==e&&null==t||(c.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...c}}async getSamples(e,t){const r=await this._fetchCapabilities(t?.signal);if(!r?.operations.supportsGetSamples)throw new o("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=g(Je,e).clone();const{raster:i}=this;return i&&null==e.raster&&(e.raster=i),ae(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new o("imagery-layer:identify","identify operation is not supported on the input image service");e=g(qe,e).clone(),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=ye.fromExtent(e.geometry));const r=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(r.isOutSide)throw new o("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=r.timeExtent,e.mosaicRule=r.mosaicRule;const{raster:i,rasterFunction:s}=this;return s&&null==e.rasterFunction&&(e.rasterFunction=s),i&&null==e.raster&&(e.raster=i),oe(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new o("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return e=g(Qe,e),le(We(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new o("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return e=g(Ve,e),ue(We(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new o("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return e=g(Ue,e),pe(We(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new o("imagery-layer:find-images","findImages operation is not supported on the input image service");return e=g(De,e),me(We(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new o("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return e=g(He,e),ce(We(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ie({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new o("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=g(je,e??{outSpatialReference:this.spatialReference}).clone(),de(We(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ge(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ve(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new o("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=g(Me,e??{outSpatialReference:this.spatialReference}).clone(),he(We(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),we(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new o("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let a=!1,l=null,u=null;const p="raster.servicepixelvalue",m=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(a=e.outFields.some((e=>!e.toLowerCase().includes(p))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(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 q({functionName:e[0]}))),u=t.map((e=>e[1]));const{rasterFunction:r}=this;0===l.length?r?.functionName?(l.push(r),u.push(r.functionName)):l=null:r?.functionName&&!l.some((e=>e.functionName===r.functionName))&&(l.push(r),u.push(r.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:d}=this;let h=e.timeExtent||this.timeExtent;if(d){const{isOutside:t,intersection:r}=J(d,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new o("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=r?.timeExtent&&(h=r.timeExtent)}const g=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,h);let f=e.geometry;this.version<10.91&&"extent"===f?.type&&(f=ye.fromExtent(f));const y=this._getQueryParams({geometry:f,timeExtent:h,mosaicRule:g,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:r,returnCatalogItems:a,returnGeometry:c,raster:this.raster,maxItemCount:s?1:null});delete y.f;const R=new qe(y);try{await this._generateRasterInfo(this.rasterFunction);const r=await oe(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,o=null!=r.value&&r.value.toLowerCase().includes("nodata");if(!(a&&!c&&r?.catalogItems?.features.length&&(n||!o)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",p=r.catalogItems?.features??[],m=p.map((e=>e.attributes?.[l])),d=new Ie({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{p.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new ye(t.geometry),null!=e.outSpatialReference&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new o("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(We(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(We(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):Le(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return V(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):xe(We(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),_e(e,t),e))),i=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),u.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.addHandles([p((()=>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 r=this.timeInfo,{multidimensionalInfo:i}=this.serviceRasterInfo;if(null==e||null==i||null==t||null==r?.startField)return e;const{startField:s}=r,n=i.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 S({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 o("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=null!=e?g(Ie,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new E;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>{})),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:r}=this;return"unique-value"===e.type&&this._hasRasterFunction(r)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&L(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:i}=await n(We(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new o("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),r=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:r}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&r.bandCount>=3){const e=z(r);!e||3===r.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=G(r,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=k(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=r):this.symbolizer=new W({rendererJSON:t,rasterInfo:r}),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:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):H(e,t,r)}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 n(We(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:r,returnImageBitmap:i,signal:s}=e;if(r&&this._canRequestImageElement(t.format)){const r=`${We(this.parsedUrl)}/exportImage`,{data:a}=await n(r,{responseType:i?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:s});if(a instanceof Blob){return{imageBitmap:await D(a,r,s),params:t}}return{imageOrCanvasElement:a,params:t}}const a=this._initJobHandler(),l=n(We(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s}),u=(await Promise.all([l,a]))[0].data,p=t.format||"jpgpng";let m=p;if("bsq"!==m&&"bip"!==m&&(m=U(u)),!m)throw new o("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===m||"jpg"===m)?H(u,{useCanvas:!0,...t},c):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},c);return{pixelData:{pixelBlock:await d,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=Q(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new P;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,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=r,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 i&&i.toLowerCase().includes("nodata"),d=[];if(i&&!u&&!c){const e={};e[m]=0;p=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let h,g,f;this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(h=u[t],null!=i){if(g=p[t],f=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:i,"nodata"===g.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";h.attributes[e]=g,h.attributes[r]=f,this._updateFeatureWithMagDirValues(h,g);const a=this.fields&&this.fields.length>0;let o=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?a?g:i:f;this.rasterFunction||(o=a?g:i),this._updateFeatureWithRasterAttributeTableValues(h,o)}if(h.sourceLayer=h.layer=this,a&&this._updateFeatureWithDomainValues(h),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];h.attributes[t]=l[e]}d.push(u[t])}return d}_processMultidimensionalIntersection(e,t,r){const{multidimensionalSubset:i}=this;if(!i)return{isOutSide:!1,timeExtent:t,mosaicRule:r=this._combineMosaicRuleWithTimeExtent(r,t)};if(i){const{isOutside:r,intersection:s}=J(i,{geometry:e,timeExtent:t});if(r)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(r=this._combineMosaicRuleWithTimeExtent(r,t),r?.multidimensionalDefinition){const{isOutside:e}=J(i,{multidimensionalDefinition:r.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:r}}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==r)return;const{features:i,fields:s}=r,n=s.map((e=>e.name)).find((e=>"value"===e.toLowerCase()));if(!n)return;const a=i.filter((e=>e.attributes[n]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const r=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new O({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new fe(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:B([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;null!=r&&e.forEach((e=>{if(e?.attributes)for(const i of t){const t=r.get(i)?.name;t&&t!==i&&(e.attributes[i]=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 r=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(r)?t.get(r):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:r,rasterFunction:i}=this;i&&e instanceof Ne&&null==e.rasterFunction&&(e.rasterFunction=i),r&&null==e.mosaicRule&&(e.mosaicRule=r),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!(!e.spatialReference&&!e.extent?.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&o,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),m=u&&p.includes("basic"),c=this._isMosaicDataset(e)&&t.includes("catalog"),d=t.includes("download");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsImageToMap:r>=11.2&&c,supportsImageToMapMultiray:r>=11.2&&c,supportsMapToImage:r>=11.2&&c,supportsFindImages:r>=11.2&&c,supportsGetImageUrl:r>=11.2&&d,supportsMeasure:u,supportsMeasureFromImage:r>=11.2,supportsDownload:d,supportsQuery:c&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&a,supportsComputePixelLocation:r>=10.7&&c,supportsComputeAngles:r>=10.91,supportsQueryGPSInfo:r>=11.2&&c,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:m,supportsAreaAndPerimeter:m,supportsPointOrCentroid:m,supportsHeightFromBaseAndTop:u&&p.includes("base-top height"),supportsHeightFromBaseAndTopShadow:u&&p.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:u&&p.includes("top-top shadow height"),supports3D:u&&p.includes("3d")}}}};function We(e){return e?.path??""}return e([c({clonable:!1})],f.prototype,"_functionRasterInfos",void 0),e([c({clonable:!1})],f.prototype,"_rasterJobHandler",void 0),e([c({clonable:!1})],f.prototype,"_cachedRendererJson",void 0),e([c({readOnly:!0})],f.prototype,"_serviceSupportsMosaicRule",void 0),e([y("_serviceSupportsMosaicRule",["currentVersion","fields"])],f.prototype,"readServiceSupportsMosaicRule",null),e([c({readOnly:!0})],f.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([c({readOnly:!0})],f.prototype,"_rasterFunctionNamesIndex",null),e([c()],f.prototype,"adjustAspectRatio",void 0),e([c({type:[h],json:{write:!0}})],f.prototype,"bandIds",void 0),e([y("bandIds")],f.prototype,"readBandIds",null),e([c({readOnly:!0,json:{read:!1}})],f.prototype,"capabilities",void 0),e([y("service","capabilities",["capabilities","currentVersion","serviceDataType"])],f.prototype,"readCapabilities",null),e([c({type:Number})],f.prototype,"compressionQuality",void 0),e([b("compressionQuality")],f.prototype,"writeCompressionQuality",null),e([c({type:Number})],f.prototype,"compressionTolerance",void 0),e([b("compressionTolerance")],f.prototype,"writeCompressionTolerance",null),e([c({json:{read:{source:"copyrightText"}}})],f.prototype,"copyright",void 0),e([c({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],f.prototype,"defaultMosaicRule",void 0),e([y("defaultMosaicRule",["defaultMosaicMethod"])],f.prototype,"readDefaultMosaicRule",null),e([c({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],f.prototype,"definitionExpression",void 0),e([c({readOnly:!0,constructOnly:!0})],f.prototype,"exportImageServiceParameters",void 0),e([c()],f.prototype,"rasterInfo",void 0),e([c({readOnly:!0,type:[_]})],f.prototype,"fields",void 0),e([c({readOnly:!0})],f.prototype,"fieldsIndex",null),e([c({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],f.prototype,"format",null),e([y("service","format",["serviceDataType"])],f.prototype,"readFormat",null),e([c({type:fe})],f.prototype,"fullExtent",void 0),e([c({readOnly:!0})],f.prototype,"hasMultidimensions",void 0),e([c({json:{read:{source:"maxImageHeight"}}})],f.prototype,"imageMaxHeight",void 0),e([c({json:{read:{source:"maxImageWidth"}}})],f.prototype,"imageMaxWidth",void 0),e([c({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],f.prototype,"interpolation",void 0),e([c()],f.prototype,"minScale",void 0),e([y("service","minScale")],f.prototype,"readMinScale",null),e([c()],f.prototype,"maxScale",void 0),e([y("service","maxScale")],f.prototype,"readMaxScale",null),e([c({type:P})],f.prototype,"mosaicRule",null),e([y("mosaicRule",["mosaicRule","defaultMosaicMethod"])],f.prototype,"readMosaicRule",null),e([b("mosaicRule")],f.prototype,"writeMosaicRule",null),e([c()],f.prototype,"multidimensionalInfo",void 0),e([c({type:j,json:{write:!0}})],f.prototype,"multidimensionalSubset",void 0),e([c({json:{type:h}})],f.prototype,"noData",void 0),e([b("noData")],f.prototype,"writeNoData",null),e([c({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],f.prototype,"noDataInterpretation",void 0),e([c({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],f.prototype,"objectIdField",void 0),e([y("objectIdField")],f.prototype,"readObjectIdField",null),e([c({readOnly:!0})],f.prototype,"geometryType",void 0),e([c({})],f.prototype,"typeIdField",void 0),e([c({})],f.prototype,"types",void 0),e([c({readOnly:!0})],f.prototype,"parsedUrl",null),e([c({type:Function})],f.prototype,"pixelFilter",void 0),e([c()],f.prototype,"raster",void 0),e([c({readOnly:!0})],f.prototype,"sourceType",void 0),e([y("sourceType",["serviceSourceType","fields"])],f.prototype,"readSourceType",null),e([c()],f.prototype,"viewId",void 0),e([c({types:r,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],f.prototype,"renderer",null),e([y("renderer")],f.prototype,"readRenderer",null),e([b("renderer")],f.prototype,"writeRenderer",null),e([c({clonable:!1})],f.prototype,"symbolizer",void 0),e([c(w)],f.prototype,"opacity",void 0),e([c({readOnly:!0})],f.prototype,"rasterFields",null),e([c({constructOnly:!0})],f.prototype,"rasterFunctionInfos",void 0),e([c({type:q})],f.prototype,"renderingRule",null),e([c({type:q,json:{name:"renderingRule"}})],f.prototype,"rasterFunction",null),e([y("rasterFunction",["renderingRule","rasterFunctionInfos"])],f.prototype,"readRasterFunction",null),e([c({readOnly:!0})],f.prototype,"serviceDataType",void 0),e([c({readOnly:!0,type:Re})],f.prototype,"spatialReference",void 0),e([y("spatialReference",["spatialReference","extent"])],f.prototype,"readSpatialReference",null),e([c({json:{type:N.jsonValues}})],f.prototype,"pixelType",void 0),e([y("pixelType")],f.prototype,"readPixelType",null),e([b("pixelType")],f.prototype,"writePixelType",null),e([c({constructOnly:!0,type:A})],f.prototype,"serviceRasterInfo",void 0),e([c()],f.prototype,"sourceJSON",void 0),e([c(v)],f.prototype,"url",void 0),e([c({readOnly:!0})],f.prototype,"version",void 0),e([y("version",["currentVersion","fields","timeInfo"])],f.prototype,"readVersion",null),f=e([R("esri.layers.mixins.ArcGISImageService")],f),f};export{We as ArcGISImageService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as f}from"../rasterFormats/RasterCodec.js";import{clip as h}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,n=await this._getCapabilities(i);if(this.capabilities=n,!this.version){let e=n.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=n.capabilitiesVersion:(e=n.supportedVersions.find((e=>"2.0.1"===e))||n.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const s=n.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!s.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=s[0].id);const o=s.find((e=>e.id===this.coverageId));if(null==o)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const r=await this._describeCoverage(i);this.coverageInfo=r[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=o.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(n.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,f=this.getTileExtent({x:l,y:c},i,n,u,r,[d,p]),g=this.rasterInfo.extent,m=f.xmax>g.xmax,w=f.ymin<g.ymin,v=m||w;let y=f,x=d,C=p;if(v&&(y=f.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,s);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=s;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?h(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(s){if(!n(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version?.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(o){if(!n(o))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw o}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:o}=this.rasterInfo,r=s.center,l=new g({xmin:r.x-n.x,xmax:r.x+n.x,ymin:r.y-n.y,ymax:r.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=o){const e=o.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:f}=this,h="2.0"===u&&null==f.allowAnyMediaType||"1.1"===u&&null==f.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!h)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;f.use2GridOffsets=!0}}if(!m&&h&&("2.0"===u&&(f.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===d?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:r.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===f(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const h=c(u);if(h.isMultipart&&h.data){const e=h.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=n;let f;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(t[0]instanceof Array&&(t=t[0]),f=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:f,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),f=w[u],h=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&r(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=s.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&f&&a?h?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${f}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const n=s.range.find((e=>e.identifier.toLowerCase()===i));if(n){const i=n.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=h?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+f+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:f,domainSet:h,rangeType:g}=o,m=f.isEastFirst?0:1,w=1-m,{axisLabels:v}=f,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=h.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();f.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=r&&r.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<r.length;i++){const n=v.find((e=>e===r[i].dimensionName)),s=e.find((e=>e===r[i].variableName));if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(n+",http://www.opengis.net")));-1===i&&$.push(n+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(n)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([s({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([s()],b.prototype,"tileType",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([o("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as f}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,n=await this._getCapabilities(i);if(this.capabilities=n,!this.version){let e=n.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=n.capabilitiesVersion:(e=n.supportedVersions.find((e=>"2.0.1"===e))||n.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const s=n.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!s.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=s[0].id);const r=s.find((e=>e.id===this.coverageId));if(null==r)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(i);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=r.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(n.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:r,spatialReference:o}=this.rasterInfo,a=2**e,l=r.x*a,c=r.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,n,u,o,[d,p]),g=this.rasterInfo.extent,m=h.xmax>g.xmax,w=h.ymin<g.ymin,v=m||w;let y=h,x=d,C=p;if(v&&(y=h.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,s);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=s;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?f(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(s){if(!n(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version?.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(r){if(!n(r))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw r}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,o=s.center,l=new g({xmin:o.x-n.x,xmax:o.x+n.x,ymin:o.y-n.y,ymax:o.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,f="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!f)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!m&&f&&("2.0"===u&&(h.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,r,o,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,n,s,r,o,l):"1.1"===d?this._getCoverage110Parameters(e,n,s,o,l):this._getCoverage100Parameters(e,n,s,o),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:o.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const f=c(u);if(f.isMultipart&&f.data){const e=f.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,r=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=n;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${r}`,bbox:s,width:t,height:i,time:h,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:r,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],f=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&o(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=s.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&h&&a?f?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${h}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=r&&r.length)for(let o=0;o<r.length;o++){let e=r[o].values;const t=r[o].dimensionName?.toLowerCase(),i=r[o].variableName?.toLowerCase();if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const n=s.range.find((e=>e.identifier.toLowerCase()===i));if(n){const i=n.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=f?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,n,s,r){const{multidimensionalDefinition:o,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:f,rangeType:g}=r,m=h.isEastFirst?0:1,w=1-m,{axisLabels:v}=h,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=f.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=o&&o.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<o.length;i++){const n=v.find((e=>e===o[i].dimensionName)),s=e.find((e=>e===o[i].variableName));if(t.includes(s)||t.push(s),n){let e=o[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(n+",http://www.opengis.net")));-1===i&&$.push(n+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!r.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(n)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([s({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([s()],b.prototype,"tileType",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([r("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.30.0-next.20240321",
3
+ "version": "4.30.0-next.20240323",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import"../geometry.js";import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import n from"./knowledgeGraph/GraphQueryResult.js";import o from"./knowledgeGraph/GraphQueryStreamingResult.js";import i from"./knowledgeGraph/KnowledgeGraph.js";import d from"./knowledgeGraph/ServiceDefinition.js";import{getWasmInterface as s}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{setInputQuantizationParametersOnEncoder as p,setOutputQuantizationParametersOnEncoder as c,bindParamArrayToWasm as l,geometryToWasm as u,bindParamObjectToWasm as h}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{inputQuantizationParametersToWasmFormat as f,namedObjectToWasm as g}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmToDataModel as w}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{decodedWasmObjToQueryResponseObj as y}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as m}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import _ from"../geometry/SpatialReference.js";import k from"../geometry/Geometry.js";const b={fetchKnowledgeGraph:async e=>{const t=new i({url:e}),r=[];return r.push(q(t)),r.push(Q(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await z(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new d(r),e.serviceDefinition},executeQueryStreaming:async(e,t,a)=>{const n=`${e.url}/graph/query`;await M(e);const i=await F(n,a);i.data.body=await D(t,e);const d=await A(i.data.url,i.data);if(e.dataModel)return new o({resultRowsStream:await I(d,e.dataModel,t.outputSpatialReference??void 0)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await M(e);const o=await F(n,a);o.data.body=await C(t,e);return P(await A(o.data.url,o.data))},executeQuery:async(e,a,o)=>{const i=`${e.url}/graph/query`,d=await t(i,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...o?.query},signal:o?.signal,timeout:o?.timeout}),p=d.getHeader?.("content-type"),c=d.data;if(p?.includes("application/x-protobuf")){const t=new((await s()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel)return new n({resultRows:L(t,c,e.dataModel)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:p,data:d.data})},executeSearch:async(e,a,o)=>{const i=a.typeCategoryFilter,d=`${e.url}/graph/search`,p=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:i,...o?.query},signal:o?.signal,timeout:o?.timeout}),c=p.getHeader?.("content-type"),l=p.data;if(c?.includes("application/x-protobuf")){const t=new((await s()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel)return new n({resultRows:L(t,l,e.dataModel)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:c,data:p.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await M(e);const i=await F(n,a);i.data.body=await W(t);const d=await A(i.data.url,i.data);if(e.dataModel)return new o({resultRowsStream:await I(d,e.dataModel)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},_fetchWrapper:async(e,t)=>fetch(e,t)};async function v(e,t,r){return b.executeApplyEdits(e,t,r)}async function S(e,t,r){return b.executeQuery(e,t,r)}async function G(e,t,r){return b.executeQueryStreaming(e,t,r)}async function x(e,t,r){return b.executeSearch(e,t,r)}async function E(e,t,r){return b.executeSearchStreaming(e,t,r)}async function T(e){return b.fetchKnowledgeGraph(e)}async function q(e){return b.refreshDataModel(e)}async function Q(e){return b.refreshServiceDefinition(e)}async function A(e,t){return b._fetchWrapper(e,t)}async function M(t){const r=e?.findCredential(t.url);r||(t.dataModel?await z(t):await q(t))}function R(e,t,a){if(0!==e.error_code)throw new r(t,a,{errorCode:e.error_code,errorMessage:e.error_message})}function j(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof k?r.set_param_key_value(e,u(t,a)):t instanceof Array?r.set_param_key_value(e,l(t,a)):r.set_param_key_value(e,h(t,a))}async function C(e,t){if(t.dataModel||await q(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await s(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?f(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach((e=>{t=o.add_entity(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipAdds?.forEach((e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach((e=>{t.delete_by_id(e)}))})),e.relationshipDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach((e=>{t.delete_by_id(e)}))})),o.encode()}catch(d){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:d})}const i=o.get_encoding_result();return R(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(i.get_byte_buffer())}async function D(e,t){const a=await s(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,d]of Object.entries(e.bindParameters))j(r,d,n,a);if(e.bindGeometryQuantizationParameters)p(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await q(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&c(e.outputQuantizationParameters,n,a);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function W(e){const t=await s(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(l(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach((e=>{a.add_named_type_filter(e)}));try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function F(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function P(e){const t=e.headers.get("content-type");if(t?.includes("application/x-protobuf")){const t=await e.arrayBuffer(),r=new((await s()).GraphApplyEditsDecoder);return r.deleteLater(),r.decode(new Uint8Array(t)),m(r)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:t,data:e.text()})}function L(e,t,a,n=new _({wkid:_.WGS84.wkid})){e.push_buffer(new Uint8Array(t));const o=[];let i=0;for(;e.next_row();){i||(i=e.get_header_keys().size());const t=new Array(i);for(let r=0;r<i;r++){const o=e.get_value(r);t[r]=y(o,a,n)}o.push(t)}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return o}async function I(e,t,n){const o=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),o?.includes("application/x-protobuf")){const a=e.body?.getReader(),o=new((await s()).GraphQueryDecoder);return o.deleteLater(),new ReadableStream({async start(e){try{return i()}catch(d){a?.releaseLock(),e.error(new r("knowledge-graph:stream-decoding-error","The server returned a valid response, but there was an error decoding the response stream",{error:d})),e.close()}function i(){return a?.read().then((({done:d,value:s})=>{if(d){let t;if(o.has_error()&&(t=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded",{errorCode:o.error.error_code,errorMessage:o.error.error_message})),a.releaseLock(),t)throw e.error(t),t;return void e.close()}const p=L(o,s,t,n);return p.length>0&&e.enqueue(p),i()}))}}})}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:e.text()})}async function z(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),i=n.data;if(o?.includes("application/x-protobuf")){const e=(await s()).decode_data_model_from_protocol_buffer(new Uint8Array(i));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return w(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{A as _fetchWrapper,v as executeApplyEdits,S as executeQuery,G as executeQueryStreaming,x as executeSearch,E as executeSearchStreaming,T as fetchKnowledgeGraph,b as kgRestServices,q as refreshDataModel,Q as refreshServiceDefinition};
5
+ import"../geometry.js";import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import n from"./knowledgeGraph/GraphQueryResult.js";import o from"./knowledgeGraph/GraphQueryStreamingResult.js";import i from"./knowledgeGraph/KnowledgeGraph.js";import d from"./knowledgeGraph/ServiceDefinition.js";import{getWasmInterface as s}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{setInputQuantizationParametersOnEncoder as p,setOutputQuantizationParametersOnEncoder as c,bindParamArrayToWasm as l,geometryToWasm as u,bindParamObjectToWasm as h}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{inputQuantizationParametersToWasmFormat as f,namedObjectToWasm as g}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmToDataModel as y}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{decodedWasmObjToQueryResponseObj as w}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as m}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import _ from"../geometry/SpatialReference.js";import k from"../geometry/Geometry.js";const b={fetchKnowledgeGraph:async e=>{const t=new i({url:e}),r=[];return r.push(q(t)),r.push(A(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await z(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new d(r),e.serviceDefinition},executeQueryStreaming:async(e,t,a)=>{const n=`${e.url}/graph/query`;await M(e);const i=await F(n,a);i.data.body=await D(t,e);const d=await Q(i.data.url,i.data);if(e.dataModel)return new o({resultRowsStream:await I(d,e.dataModel,t.outputSpatialReference??void 0)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await M(e);const o=await F(n,a);o.data.body=await C(t,e);return P(await Q(o.data.url,o.data))},executeQuery:async(e,a,o)=>{const i=`${e.url}/graph/query`,d=await t(i,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...o?.query},signal:o?.signal,timeout:o?.timeout}),p=d.getHeader?.("content-type"),c=d.data;if(p?.includes("application/x-protobuf")){const t=new((await s()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel)return new n({resultRows:L(t,c,e.dataModel)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:p,data:d.data})},executeSearch:async(e,a,o)=>{const i=a.typeCategoryFilter,d=`${e.url}/graph/search`,p=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:i,...o?.query},signal:o?.signal,timeout:o?.timeout}),c=p.getHeader?.("content-type"),l=p.data;if(c?.includes("application/x-protobuf")){const t=new((await s()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel)return new n({resultRows:L(t,l,e.dataModel)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:c,data:p.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await M(e);const i=await F(n,a);i.data.body=await W(t);const d=await Q(i.data.url,i.data);if(e.dataModel)return new o({resultRowsStream:await I(d,e.dataModel)});throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},_fetchWrapper:async(e,t)=>fetch(e,t)};async function v(e,t,r){return b.executeApplyEdits(e,t,r)}async function S(e,t,r){return b.executeQuery(e,t,r)}async function G(e,t,r){return b.executeQueryStreaming(e,t,r)}async function x(e,t,r){return b.executeSearch(e,t,r)}async function E(e,t,r){return b.executeSearchStreaming(e,t,r)}async function T(e){return b.fetchKnowledgeGraph(e)}async function q(e){return b.refreshDataModel(e)}async function A(e){return b.refreshServiceDefinition(e)}async function Q(e,t){return b._fetchWrapper(e,t)}async function M(t){const r=e?.findCredential(t.url);r||(t.dataModel?await z(t):await q(t))}function R(e,t,a){if(0!==e.error_code)throw new r(t,a,{errorCode:e.error_code,errorMessage:e.error_message})}function j(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof k?r.set_param_key_value(e,u(t,a)):Array.isArray(t)?r.set_param_key_value(e,l(t,a)):r.set_param_key_value(e,h(t,a))}async function C(e,t){if(t.dataModel||await q(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await s(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?f(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach((e=>{t=o.add_entity(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipAdds?.forEach((e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(g(e,a)),R(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach((e=>{t.delete_by_id(e)}))})),e.relationshipDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach((e=>{t.delete_by_id(e)}))})),o.encode()}catch(d){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:d})}const i=o.get_encoding_result();return R(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(i.get_byte_buffer())}async function D(e,t){const a=await s(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,d]of Object.entries(e.bindParameters))j(r,d,n,a);if(e.bindGeometryQuantizationParameters)p(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await q(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&c(e.outputQuantizationParameters,n,a);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function W(e){const t=await s(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(l(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach((e=>{a.add_named_type_filter(e)}));try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function F(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function P(e){const t=e.headers.get("content-type");if(t?.includes("application/x-protobuf")){const t=await e.arrayBuffer(),r=new((await s()).GraphApplyEditsDecoder);return r.deleteLater(),r.decode(new Uint8Array(t)),m(r)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:t,data:e.text()})}function L(e,t,a,n=new _({wkid:_.WGS84.wkid})){e.push_buffer(new Uint8Array(t));const o=[];let i=0;for(;e.next_row();){i||(i=e.get_header_keys().size());const t=new Array(i);for(let r=0;r<i;r++){const o=e.get_value(r);t[r]=w(o,a,n)}o.push(t)}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return o}async function I(e,t,n){const o=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),o?.includes("application/x-protobuf")){const a=e.body?.getReader(),o=new((await s()).GraphQueryDecoder);return o.deleteLater(),new ReadableStream({async start(e){try{return i()}catch(d){a?.releaseLock(),e.error(new r("knowledge-graph:stream-decoding-error","The server returned a valid response, but there was an error decoding the response stream",{error:d})),e.close()}function i(){return a?.read().then((({done:d,value:s})=>{if(d){let t;if(o.has_error()&&(t=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded",{errorCode:o.error.error_code,errorMessage:o.error.error_message})),a.releaseLock(),t)throw e.error(t),t;return void e.close()}const p=L(o,s,t,n);return p.length>0&&e.enqueue(p),i()}))}}})}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:e.text()})}async function z(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),i=n.data;if(o?.includes("application/x-protobuf")){const e=(await s()).decode_data_model_from_protocol_buffer(new Uint8Array(i));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return y(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{Q as _fetchWrapper,v as executeApplyEdits,S as executeQuery,G as executeQueryStreaming,x as executeSearch,E as executeSearchStreaming,T as fetchKnowledgeGraph,b as kgRestServices,q as refreshDataModel,A as refreshServiceDefinition};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- const c="20240321",e="5c137206f26af974d9982a83f25e8b96ce106517";export{c as buildDate,e as commitHash};
5
+ const c="20240323",b="cf33f6edd549bc0551830b507c77583487a24865";export{c as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as t}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{CIMSymbolHelper as l}from"./CIMSymbolHelper.js";import{defaultCIMValues as n}from"./defaultCIMValues.js";import{Alignment as c}from"./enums.js";import{OverrideHelper as p}from"./OverrideHelper.js";import{getExtent as m,getSDFMetrics as y}from"./SDFHelper.js";import{colorToArray as f,normalizeAlpha as h,getSize as d,isCIMMarkerStrokePlacement as u,getTintColor as v,getValue as O,getDefaultCIMValue as _,getEnum as g,getFillColor as S,getStrokeColor as k,getStrokeWidth as M,fromCIMFontDecoration as b,fromCIMFontStyle as C,fromCIMHorizontalAlignment as P,fromCIMVerticalAlignment as x,isValidCIMValue as z,uncapitalize as L}from"./utils.js";import{CIMEffectHelper as E}from"./effects/CIMEffectHelper.js";import{randomInsidePolygonTextureSize as I}from"../../views/2d/engine/webgl/definitions.js";const V=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function N(e){const r=e.markerPlacement;return r&&r.angleToLine?c.MAP:c.SCREEN}class w{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],e&&(this._resourceManager=e)}analyzeSymbolReference(r,t,i){if(this._cimLayers=i??[],!r)return this._cimLayers;if(this._reset(),r.primitiveOverrides){this._primitiveOverrides=r.primitiveOverrides;for(const r of this._primitiveOverrides){const t=r.valueExpressionInfo;if(t)this._setPoMap(r.primitiveName,r.propertyName,t);else if(null!=r.value){let t=r.value;r.propertyName.includes("Color")&&(e(t)&&(t=f(t)),t=h(t)),this._setPoMap(r.primitiveName,r.propertyName,t)}}}return this._analyzeSymbol(r.symbol,t),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,r){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,r)}}_analyzeMultiLayerSymbol(e,r){const t=e?.symbolLayers;if(!t)return;const i=e.effects;let o=c.SCREEN;const a=d(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=c.MAP);const s="CIMPolygonSymbol"===e.type;let l=t.length;for(;l--;){const n=t[l];if(!n||!1===n.enable)continue;let c;i?.length&&(c=[...i]);const m=n.effects;m?.length&&(i?c.push(...m):c=[...m]);let y=null;if(c){y=[];for(const e of c){const r=p.findEffectOverrides(e,this._primitiveOverrides);r&&y.push(r)}}const f=[];switch(p.findApplicableOverrides(n,this._primitiveOverrides,f),n.type){case"CIMSolidFill":this._analyzeSolidFill(n,y);break;case"CIMPictureFill":this._analyzePictureFill(n,y);break;case"CIMHatchFill":this._analyzeHatchFill(n,y);break;case"CIMGradientFill":this._analyzeGradientFill(n,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(n,y,s,a);break;case"CIMPictureStroke":this._analyzePictureStroke(n,y,s,a);break;case"CIMGradientStroke":this._analyzeGradientStroke(n,y,s,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=N(n));const t=[],i=n.primitiveName;i&&t.push(i);const l=s&&u(n.markerPlacement);this._analyzeMarker(n,y,null,t,o,a,r,[],!1,l);break}default:V().error("Cannot analyze CIM layer",n.type)}}}_analyzeSolidFill(e,r){const{primitiveName:t,type:i}=e,o=h(e.color);this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(i,t,"Color",o),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:r,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1})}_analyzePictureFill(e,r){const{primitiveName:t,type:i}=e,o=v(e),a=O(e.height,n.CIMPictureFill.height);let s=O(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height),s/=t*(a/r)}const l={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(t,i)};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(i,t,"TintColor",o),height:this._getValueOrOverrideExpression(i,t,"Height",a),scaleX:this._getValueOrOverrideExpression(i,t,"ScaleX",s),angle:this._getValueOrOverrideExpression(i,t,"Rotation",O(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",O(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",O(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeHatchFill(e,r){const{primitiveName:t,type:i}=e,o=A(this._analyzeMaterialOverrides(t,["Rotation","OffsetX","OffsetY"]));let a=[255,255,255,1],s=!1;if(e.lineSymbol?.symbolLayers)for(const n of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==n.type)continue;const e=n.primitiveName??t;s||!e||n.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(a=h(n.color),a=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",a),s=!0);const r=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(r){let t=null,a=null;"number"==typeof r?t=r:a=r.valueExpressionInfo;let s=o.find((e=>"strokeWidth"===e.propertyName));s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:a,value:t,defaultValue:_(i,"width")},o.push(s))}}const l={type:"sprite-rasterization-param",resource:e,overrides:o};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:a,height:this._getValueOrOverrideExpression(i,t,"Separation",O(e.separation,n.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,t,"Rotation",O(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",O(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",O(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!s})}_analyzeGradientFill(e,r){this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeSolidStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=h(e.color),l=O(e.width,n.CIMSolidStroke.width),c=g(e.capStyle,n.CIMSolidStroke.capstyle),p=g(e.joinStyle,n.CIMSolidStroke.joinstyle),m=e.miterLimit;let y,f,d=[];if(this._analyzePrimitiveOverrides(o,r,null,null)&&(d=this._getPrimitiveMaterialOverrides(o,a)),r&&r instanceof Array&&r.length>0){const e=r[r.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&null===e.offsetAlongLine&&(y=e.dashTemplate,f=e.scaleDash,(r=[...r]).pop())}const u=void 0!==y?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:y,capStyle:c},overrides:d}:null;this._cimLayers.push({type:"line",spriteRasterizationParam:u,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"Color",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",c),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:m&&this._getValueOrOverrideExpression(a,o,"MiterLimit",m),referenceWidth:i,zOrder:G(e.name),dashTemplate:y,scaleDash:f,sampleAlphaOnly:!0})}_analyzePictureStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=v(e),l=O(e.width,n.CIMPictureStroke.width),c=g(e.capStyle,n.CIMPictureStroke.capstyle),p=g(e.joinStyle,n.CIMPictureStroke.joinstyle),m=e.miterLimit,y={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(o,a)};this._cimLayers.push({type:"line",spriteRasterizationParam:y,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"TintColor",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",c),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:m&&this._getValueOrOverrideExpression(a,o,"MiterLimit",m),referenceWidth:i,zOrder:G(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=O(e.width,n.CIMSolidStroke.width),l=g(e.capStyle,n.CIMGradientStroke.capstyle),c=g(e.joinStyle,n.CIMGradientStroke.joinstyle),p=e.miterLimit;this._cimLayers.push({type:"line",spriteRasterizationParam:null,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],width:this._getValueOrOverrideExpression(a,o,"Width",s),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",l),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",c),miterLimit:p&&this._getValueOrOverrideExpression(a,o,"MiterLimit",p),referenceWidth:i,zOrder:G(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,r,t,i,o,a,s,l,c=!1,p=!1){if(c||=!!e.colorLocked,this._analyzeMarkerInsidePolygon(e,r,c))return;const m=O(e.size,n.CIMVectorMarker.size),y=O(e.rotation),f=O(e.offsetX),h=O(e.offsetY),{primitiveName:d,type:u}=e,v=this._getValueOrOverrideExpression(u,d,"Size",m),_=this._getValueOrOverrideExpression(u,d,"Rotation",y),g=this._getValueOrOverrideExpression(u,d,"OffsetX",f),S=this._getValueOrOverrideExpression(u,d,"OffsetY",h);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,r,t,i,o,a,v,_,g,S,l,c,p);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,r,t,i,o,a,v,_,g,S,l,s,c,p)}}_analyzeMarkerInsidePolygon(e,r,t){const{markerPlacement:i,type:o}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===o||"CIMPictureMarker"===o){const t=e.primitiveName;if(t&&this._analyzePrimitiveOverrides([t],r,null,null))return!1;const a=i.primitiveName;if(a&&this._analyzePrimitiveOverrides([a],r,null,null))return!1;if("CIMVectorMarker"===o){const{markerGraphics:r}=e;if(r)for(const e of r){const{symbol:r}=e;if("CIMPolygonSymbol"===r?.type&&r.symbolLayers){const{symbolLayers:e}=r;for(const r of e)if("CIMSolidStroke"===r.type)return!1}}}else{const{animatedSymbolProperties:r}=e;if(r)return!1}}const s=Math.abs(i.stepX),l=Math.abs(i.stepY);if(0===s||0===l)return!0;let n,c;if("Random"===i.gridType){const e=a(I),r=Math.max(Math.floor(e/s),1);n=l*Math.max(Math.floor(e/l),1);c=r*s/n}else i.shiftOddRows?(n=2*l,c=s/l*.5):(n=l,c=s/l);const p=v(e),m="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:m,colorLocked:t,effects:r,color:p,height:n,scaleX:c,angle:i.gridAngle,offsetX:O(i.offsetX),offsetY:O(i.offsetY),applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,r,i,o,a,l,n,c,p,m,y,f,h){const{primitiveName:d,type:u}=e;let _=O(e.scaleX,1);const g=v(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createAnimatedSymbolPropertiesOverrideExpression(e.animatedSymbolProperties),k=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height);_/=t*(O(e.size)/r)}const M=[...o];let b;e.primitiveName&&M.push(e.primitiveName),e.animatedSymbolProperties||S?b={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(b=t(e),b.markerPlacement=null);const C={type:"sprite-rasterization-param",resource:b,overrides:this._getMaterialOverrides(M,u)};S&&C.overrides.push(...S.overrides),this._cimLayers.push({type:"marker",spriteRasterizationParam:C,colorLocked:f,effects:r,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(u,d,"ScaleX",_),rotation:c,offsetX:p,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(u,d,"TintColor",g),anchorPoint:{x:k.x,y:k.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:h,markerPlacement:i,animatedSymbolProperties:S})}_analyzeVectorMarker(e,r,t,i,o,a,s,l,n,c,p,m,y,f){const h=e.markerGraphics;if(!h)return;const d=e.frame;let u=0;if(u=d?d.ymax-d.ymin:a,u){const r={offsetX:n,offsetY:c,rotation:l,size:s,frameHeight:u,rotateClockWise:!!e.rotateClockwise};p=[...p,r]}t||(t=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const v of h)if(v){const s=v.symbol;if(!s)continue;const l=v.primitiveName;let n;if(l&&i.push(l),("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&d){let r=0,t=0;const i=v.geometry;"x"in i&&"y"in i&&(r+=i.x-.5*(d.xmin+d.xmax),t+=i.y-.5*(d.ymin+d.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(r-=o.x,t-=o.y):d&&(r-=(d.xmax-d.xmin)*o.x,t-=(d.ymax-d.ymin)*o.y));const a={offsetX:r,offsetY:t,rotation:0,size:0,frameHeight:0,rotateClockWise:!1};n=[...p,a]}switch(s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":m||T(s)?this._analyzeMultiLayerGraphicNonSDF(e,r,t,null,v,i,o,a,n??p,u,y,f):this._analyzeMultiLayerGraphic(e,r,t,null,v,i,o,a,n??p,u,y,f);break;case"CIMTextSymbol":this._analyzeTextGraphic(r,t,v,i,o,a,n??p,y)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,r,t,i,o,a,s,l,n,c,p,f){const d=o.symbol,u=d.symbolLayers;if(!u)return;let v=u.length;if(F(u))return void this._analyzeCompositeMarkerGraphic(e,r,t,i,o,u,s,l,n,c,p,f);const O=this._resourceManager.geometryEngine,_=E.applyEffects(d.effects,o.geometry,O);if(_)for(;v--;){const d=u[v];if(!d||!1===d.enable)continue;const g=d.primitiveName;switch(g&&a.push(g),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const a=E.applyEffects(d.effects,_,O),u=m(a);if(!u)continue;const v="Relative"!==e.anchorPointUnits,[b,C,P,x]=y(u,e.frame,e.size,e.anchorPoint,v),z="CIMSolidFill"===d.type,L={type:"sdf",geom:a,asFill:z},{path:I}=d,V=z?h(S(d)):null==I?h(k(d)):[0,0,0,0],N=z?[0,0,0,0]:h(k(d)),w=M(d)??0;if(!z&&!w)break;const R=o.primitiveName;let A=null;z&&!d.colorLocked&&(A=this._maybeGetValueOrOverrideExpression(R,"FillColor"));let G=null;z||d.colorLocked||(G=this._maybeGetValueOrOverrideExpression(R,"StrokeColor"));const X=A??this._getValueOrOverrideExpression(d.type,g,"Color",V),F=G??this._getValueOrOverrideExpression(d.type,g,"Color",N),T=this._maybeGetValueOrOverrideExpression(R,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,g,"Width",w),Y=I?{type:"sprite-rasterization-param",resource:{type:"path",path:I,asFill:z},overrides:[]}:{type:"sprite-rasterization-param",resource:L,overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:Y,colorLocked:!!d.colorLocked||!!p,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:C,y:P},isAbsoluteAnchorPoint:v,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:n},frameHeight:c,widthRatio:x,rotateClockwise:!1,referenceSize:l,sizeRatio:b,color:X,outlineColor:F,outlineWidth:T,isOutline:f,markerPlacement:t,animatedSymbolProperties:i});break}case"CIMPictureMarker":case"CIMVectorMarker":d.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,n,c,!!d.colorLocked||!!p,f):this._analyzeMarker(d,r,t,a,s,l,!1,n,p,f);break;default:this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,n,c,!!d.colorLocked||!!p,f)}g&&a.pop()}}_analyzeTextGraphic(e,t,i,o,a,s,l,c){const m=[];p.findApplicableOverrides(i,this._primitiveOverrides,m);const y=i.geometry;if(!("x"in y)||!("y"in y))return;const f=i.symbol,d=b(f),u=C(f.fontStyleName),v=r(f.fontFamilyName);f.font={family:v,decoration:d,...u};const _=O(f.height,n.CIMTextSymbol.height),g=O(f.angle),z=O(f.offsetX),L=O(f.offsetY),E=h(S(f));let I=h(k(f)),V=M(f)??0;V||(I=h(S(f.haloSymbol)),V=O(f.haloSize));let N=!1;if(f.symbol?.symbolLayers)for(const r of f.symbol.symbolLayers){null!=h(S(r))&&(N=!!r.colorLocked)}const w=i.primitiveName;let R=null;N||(R=this._maybeGetValueOrOverrideExpression(w,"FillColor"));const A=this._maybeGetValueOrOverrideExpression(w,"TextSize"),G=this._maybeGetValueOrOverrideExpression(w,"TextAngle"),X=this._maybeGetValueOrOverrideExpression(w,"TextOffsetX"),F=this._maybeGetValueOrOverrideExpression(w,"TextOffsetY");let T=null,Y=null,j=0;if(f.callout&&"CIMBackgroundCallout"===f.callout.type){const e=f.callout;if(e.backgroundSymbol){const r=e.backgroundSymbol.symbolLayers;if(r)for(const e of r)"CIMSolidFill"===e.type?T=h(e.color):"CIMSolidStroke"===e.type&&(Y=h(e.color),j=O(e.width,n.CIMSolidStroke.width))}}const W=this._getValueOrOverrideExpression(f.type,i.primitiveName,"TextString",i.textString??"");if(null==W)return;const{fontStyleName:D}=f,H=v+(D?"-"+D.toLowerCase():"-regular"),U=this._getMaterialOverrides(o,f.type);U.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,f.type));const J={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:f.font,symbol:f,primitiveName:i.primitiveName},overrides:U};this._cimLayers.push({type:"text",lineWidth:null,textRasterizationParam:J,colorLocked:!!c||!!N,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:H,decoration:d,weight:u.weight,style:u.style,size:A??_,angle:G??g,offsetX:X??z,offsetY:F??L,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:P(f.horizontalAlignment),verticalAlignment:x(f.verticalAlignment),text:W,color:R??this._getValueOrOverrideExpression(f.type,i.primitiveName,"Color",E),outlineColor:I,outlineSize:V,backgroundColor:T,borderLineColor:Y,borderLineWidth:j,referenceSize:s,sizeRatio:1,markerPlacement:t})}_analyzeMultiLayerGraphicNonSDF(e,r,t,i,a,s,n,c,p,m,y,f){const h=R(e,a),d=e.primitiveName,u=A(this._analyzeMaterialOverrides(d,["Rotation","OffsetX","OffsetY"])),[v,O,_]=l.getTextureAnchor(h,this._resourceManager),g=this._getMaterialOverrides(s,e.type);g.push(...u);const S={type:"sprite-rasterization-param",resource:{...h,avoidSDFRasterization:!0},overrides:g};this._cimLayers.push({type:"marker",spriteRasterizationParam:S,colorLocked:y,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:n,anchorPoint:{x:v,y:O},isAbsoluteAnchorPoint:!1,size:m,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:p},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:m,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:c,sizeRatio:_/o(e.size),isOutline:f,markerPlacement:t,animatedSymbolProperties:i})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const r=[];return p.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-marker-placement-info",placement:e,overrides:Y(r)}}_createAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const r=[];return p.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-animation-info",animation:e,overrides:Y(r)}}_analyzeCompositeMarkerGraphic(e,r,t,i,o,a,s,l,c,p,f,d){const u=o.geometry,v=a[0],_=a[1],g=m(u);if(!g)return;const S="Relative"!==e.anchorPointUnits,[k,M,b,C]=y(g,e.frame,e.size,e.anchorPoint,S),{path:P}=_,x=_.primitiveName,z=v.primitiveName,L=o.primitiveName;let E=null;_.colorLocked||f||(E=this._maybeGetValueOrOverrideExpression(L,"FillColor"));const I=E??this._getValueOrOverrideExpression(_.type,x,"Color",h(_.color));let V=null;v.colorLocked||f||(V=this._maybeGetValueOrOverrideExpression(L,"StrokeColor"));const N=V??this._getValueOrOverrideExpression(v.type,z,"Color",h(v.color)),w=this._maybeGetValueOrOverrideExpression(L,"StrokeWidth")??this._getValueOrOverrideExpression(v.type,z,"Width",O(v.width,n.CIMSolidStroke.width)),R={type:"sprite-rasterization-param",resource:P?{type:"path",path:P,asFill:!0}:{type:"sdf",geom:u,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:R,colorLocked:f,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:M,y:b},isAbsoluteAnchorPoint:S,size:p,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:c},frameHeight:p,widthRatio:C,rotateClockwise:!1,referenceSize:l,sizeRatio:k,color:I,outlineColor:N,outlineWidth:w,isOutline:d,markerPlacement:t,animatedSymbolProperties:i})}_setPoMap(e,r,t){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[r]=t}_maybeGetValueOrOverrideExpression(e,r,t){return this._getValueOrOverrideExpression("",e,r,t,!1)}_getValueOrOverrideExpression(e,r,t,i,o=!0){if(o&&!z(i)&&(i=_(e,t.toLowerCase())),null==r)return i;const a=this._poMap[r];if(null==a)return i;const s=a[t];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,r,t,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,r){if(!e)return[];const t=[];for(const i of e)t.push(...this._getPrimitiveMaterialOverrides(i,r));return t}_getPrimitiveMaterialOverrides(e,r){if(!e)return[];const t=A(this._primitiveOverrides.filter((r=>r.primitiveName===e)));return t.forEach((e=>e.defaultValue=_(r,e.propertyName.toLowerCase()))),t}_analyzeMaterialOverrides(e,r){return this._primitiveOverrides.filter((t=>t.primitiveName!==e||!r.includes(t.propertyName)))}}function R(e,r){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[r],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function A(e){return e.map((e=>({...e,propertyName:L(e.propertyName)})))}function G(e){if(e&&0===e.indexOf("Level_")){const r=parseInt(e.substr(6),10);if(!isNaN(r))return r}return 0}function X(e,r){if(!r||0===r.length)return e;const i=t(e);return p.applyOverrides(i,r),i}const F=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects;function T(e){const r=e.symbolLayers;if(!r||2!==r.length)return!1;const t=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)))),i=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectAddControlPoints"===e.type))));return!!t||!!i}function Y(e){return t(e).map((e=>({...e,propertyName:L(e.propertyName)})))}export{w as CIMAnalyzer,X as analyzeCIMResource};
5
+ import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as t}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{CIMSymbolHelper as l}from"./CIMSymbolHelper.js";import{defaultCIMValues as n}from"./defaultCIMValues.js";import{Alignment as c}from"./enums.js";import{OverrideHelper as p}from"./OverrideHelper.js";import{getExtent as m,getSDFMetrics as y}from"./SDFHelper.js";import{colorToArray as f,normalizeAlpha as h,getSize as d,isCIMMarkerStrokePlacement as u,getTintColor as v,getValue as O,getDefaultCIMValue as _,getEnum as g,getFillColor as S,getStrokeColor as k,getStrokeWidth as M,fromCIMFontDecoration as b,fromCIMFontStyle as C,fromCIMHorizontalAlignment as P,fromCIMVerticalAlignment as x,isValidCIMValue as z,uncapitalize as L}from"./utils.js";import{CIMEffectHelper as E}from"./effects/CIMEffectHelper.js";import{randomInsidePolygonTextureSize as I}from"../../views/2d/engine/webgl/definitions.js";const V=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function N(e){const r=e.markerPlacement;return r&&r.angleToLine?c.MAP:c.SCREEN}class w{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],e&&(this._resourceManager=e)}analyzeSymbolReference(r,t,i){if(this._cimLayers=i??[],!r)return this._cimLayers;if(this._reset(),r.primitiveOverrides){this._primitiveOverrides=r.primitiveOverrides;for(const r of this._primitiveOverrides){const t=r.valueExpressionInfo;if(t)this._setPoMap(r.primitiveName,r.propertyName,t);else if(null!=r.value){let t=r.value;r.propertyName.includes("Color")&&(e(t)&&(t=f(t)),t=h(t)),this._setPoMap(r.primitiveName,r.propertyName,t)}}}return this._analyzeSymbol(r.symbol,t),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,r){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,r)}}_analyzeMultiLayerSymbol(e,r){const t=e?.symbolLayers;if(!t)return;const i=e.effects;let o=c.SCREEN;const a=d(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=c.MAP);const s="CIMPolygonSymbol"===e.type;let l=t.length;for(;l--;){const n=t[l];if(!n||!1===n.enable)continue;let c;i?.length&&(c=[...i]);const m=n.effects;m?.length&&(i?c.push(...m):c=[...m]);let y=null;if(c){y=[];for(const e of c){const r=p.findEffectOverrides(e,this._primitiveOverrides);r&&y.push(r)}}const f=[];switch(p.findApplicableOverrides(n,this._primitiveOverrides,f),n.type){case"CIMSolidFill":this._analyzeSolidFill(n,y);break;case"CIMPictureFill":this._analyzePictureFill(n,y);break;case"CIMHatchFill":this._analyzeHatchFill(n,y);break;case"CIMGradientFill":this._analyzeGradientFill(n,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(n,y,s,a);break;case"CIMPictureStroke":this._analyzePictureStroke(n,y,s,a);break;case"CIMGradientStroke":this._analyzeGradientStroke(n,y,s,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=N(n));const t=[],i=n.primitiveName;i&&t.push(i);const l=s&&u(n.markerPlacement);this._analyzeMarker(n,y,null,t,o,a,r,[],!1,l);break}default:V().error("Cannot analyze CIM layer",n.type)}}}_analyzeSolidFill(e,r){const{primitiveName:t,type:i}=e,o=h(e.color);this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(i,t,"Color",o),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:r,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1})}_analyzePictureFill(e,r){const{primitiveName:t,type:i}=e,o=v(e),a=O(e.height,n.CIMPictureFill.height);let s=O(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height),s/=t*(a/r)}const l={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(t,i)};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(i,t,"TintColor",o),height:this._getValueOrOverrideExpression(i,t,"Height",a),scaleX:this._getValueOrOverrideExpression(i,t,"ScaleX",s),angle:this._getValueOrOverrideExpression(i,t,"Rotation",O(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",O(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",O(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeHatchFill(e,r){const{primitiveName:t,type:i}=e,o=A(this._analyzeMaterialOverrides(t,["Rotation","OffsetX","OffsetY"]));let a=[255,255,255,1],s=!1;if(e.lineSymbol?.symbolLayers)for(const n of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==n.type)continue;const e=n.primitiveName??t;s||!e||n.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(a=h(n.color),a=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",a),s=!0);const r=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(r){let t=null,a=null;"number"==typeof r?t=r:a=r.valueExpressionInfo;let s=o.find((e=>"strokeWidth"===e.propertyName));s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:a,value:t,defaultValue:_(i,"width")},o.push(s))}}const l={type:"sprite-rasterization-param",resource:e,overrides:o};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:a,height:this._getValueOrOverrideExpression(i,t,"Separation",O(e.separation,n.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,t,"Rotation",O(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",O(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",O(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!s})}_analyzeGradientFill(e,r){this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeSolidStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=h(e.color),l=O(e.width,n.CIMSolidStroke.width),c=g(e.capStyle,n.CIMSolidStroke.capstyle),p=g(e.joinStyle,n.CIMSolidStroke.joinstyle),m=e.miterLimit;let y,f,d=[];if(this._analyzePrimitiveOverrides(o,r,null,null)&&(d=this._getPrimitiveMaterialOverrides(o,a)),r&&Array.isArray(r)&&r.length>0){const e=r[r.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&null===e.offsetAlongLine&&(y=e.dashTemplate,f=e.scaleDash,(r=[...r]).pop())}const u=void 0!==y?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:y,capStyle:c},overrides:d}:null;this._cimLayers.push({type:"line",spriteRasterizationParam:u,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"Color",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",c),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:m&&this._getValueOrOverrideExpression(a,o,"MiterLimit",m),referenceWidth:i,zOrder:G(e.name),dashTemplate:y,scaleDash:f,sampleAlphaOnly:!0})}_analyzePictureStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=v(e),l=O(e.width,n.CIMPictureStroke.width),c=g(e.capStyle,n.CIMPictureStroke.capstyle),p=g(e.joinStyle,n.CIMPictureStroke.joinstyle),m=e.miterLimit,y={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(o,a)};this._cimLayers.push({type:"line",spriteRasterizationParam:y,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"TintColor",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",c),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:m&&this._getValueOrOverrideExpression(a,o,"MiterLimit",m),referenceWidth:i,zOrder:G(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=O(e.width,n.CIMSolidStroke.width),l=g(e.capStyle,n.CIMGradientStroke.capstyle),c=g(e.joinStyle,n.CIMGradientStroke.joinstyle),p=e.miterLimit;this._cimLayers.push({type:"line",spriteRasterizationParam:null,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],width:this._getValueOrOverrideExpression(a,o,"Width",s),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",l),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",c),miterLimit:p&&this._getValueOrOverrideExpression(a,o,"MiterLimit",p),referenceWidth:i,zOrder:G(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,r,t,i,o,a,s,l,c=!1,p=!1){if(c||=!!e.colorLocked,this._analyzeMarkerInsidePolygon(e,r,c))return;const m=O(e.size,n.CIMVectorMarker.size),y=O(e.rotation),f=O(e.offsetX),h=O(e.offsetY),{primitiveName:d,type:u}=e,v=this._getValueOrOverrideExpression(u,d,"Size",m),_=this._getValueOrOverrideExpression(u,d,"Rotation",y),g=this._getValueOrOverrideExpression(u,d,"OffsetX",f),S=this._getValueOrOverrideExpression(u,d,"OffsetY",h);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,r,t,i,o,a,v,_,g,S,l,c,p);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,r,t,i,o,a,v,_,g,S,l,s,c,p)}}_analyzeMarkerInsidePolygon(e,r,t){const{markerPlacement:i,type:o}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===o||"CIMPictureMarker"===o){const t=e.primitiveName;if(t&&this._analyzePrimitiveOverrides([t],r,null,null))return!1;const a=i.primitiveName;if(a&&this._analyzePrimitiveOverrides([a],r,null,null))return!1;if("CIMVectorMarker"===o){const{markerGraphics:r}=e;if(r)for(const e of r){const{symbol:r}=e;if("CIMPolygonSymbol"===r?.type&&r.symbolLayers){const{symbolLayers:e}=r;for(const r of e)if("CIMSolidStroke"===r.type)return!1}}}else{const{animatedSymbolProperties:r}=e;if(r)return!1}}const s=Math.abs(i.stepX),l=Math.abs(i.stepY);if(0===s||0===l)return!0;let n,c;if("Random"===i.gridType){const e=a(I),r=Math.max(Math.floor(e/s),1);n=l*Math.max(Math.floor(e/l),1);c=r*s/n}else i.shiftOddRows?(n=2*l,c=s/l*.5):(n=l,c=s/l);const p=v(e),m="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:m,colorLocked:t,effects:r,color:p,height:n,scaleX:c,angle:i.gridAngle,offsetX:O(i.offsetX),offsetY:O(i.offsetY),applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,r,i,o,a,l,n,c,p,m,y,f,h){const{primitiveName:d,type:u}=e;let _=O(e.scaleX,1);const g=v(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createAnimatedSymbolPropertiesOverrideExpression(e.animatedSymbolProperties),k=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height);_/=t*(O(e.size)/r)}const M=[...o];let b;e.primitiveName&&M.push(e.primitiveName),e.animatedSymbolProperties||S?b={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(b=t(e),b.markerPlacement=null);const C={type:"sprite-rasterization-param",resource:b,overrides:this._getMaterialOverrides(M,u)};S&&C.overrides.push(...S.overrides),this._cimLayers.push({type:"marker",spriteRasterizationParam:C,colorLocked:f,effects:r,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(u,d,"ScaleX",_),rotation:c,offsetX:p,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(u,d,"TintColor",g),anchorPoint:{x:k.x,y:k.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:h,markerPlacement:i,animatedSymbolProperties:S})}_analyzeVectorMarker(e,r,t,i,o,a,s,l,n,c,p,m,y,f){const h=e.markerGraphics;if(!h)return;const d=e.frame;let u=0;if(u=d?d.ymax-d.ymin:a,u){const r={offsetX:n,offsetY:c,rotation:l,size:s,frameHeight:u,rotateClockWise:!!e.rotateClockwise};p=[...p,r]}t||(t=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const v of h)if(v){const s=v.symbol;if(!s)continue;const l=v.primitiveName;let n;if(l&&i.push(l),("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&d){let r=0,t=0;const i=v.geometry;"x"in i&&"y"in i&&(r+=i.x-.5*(d.xmin+d.xmax),t+=i.y-.5*(d.ymin+d.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(r-=o.x,t-=o.y):d&&(r-=(d.xmax-d.xmin)*o.x,t-=(d.ymax-d.ymin)*o.y));const a={offsetX:r,offsetY:t,rotation:0,size:0,frameHeight:0,rotateClockWise:!1};n=[...p,a]}switch(s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":m||T(s)?this._analyzeMultiLayerGraphicNonSDF(e,r,t,null,v,i,o,a,n??p,u,y,f):this._analyzeMultiLayerGraphic(e,r,t,null,v,i,o,a,n??p,u,y,f);break;case"CIMTextSymbol":this._analyzeTextGraphic(r,t,v,i,o,a,n??p,y)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,r,t,i,o,a,s,l,n,c,p,f){const d=o.symbol,u=d.symbolLayers;if(!u)return;let v=u.length;if(F(u))return void this._analyzeCompositeMarkerGraphic(e,r,t,i,o,u,s,l,n,c,p,f);const O=this._resourceManager.geometryEngine,_=E.applyEffects(d.effects,o.geometry,O);if(_)for(;v--;){const d=u[v];if(!d||!1===d.enable)continue;const g=d.primitiveName;switch(g&&a.push(g),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const a=E.applyEffects(d.effects,_,O),u=m(a);if(!u)continue;const v="Relative"!==e.anchorPointUnits,[b,C,P,x]=y(u,e.frame,e.size,e.anchorPoint,v),z="CIMSolidFill"===d.type,L={type:"sdf",geom:a,asFill:z},{path:I}=d,V=z?h(S(d)):null==I?h(k(d)):[0,0,0,0],N=z?[0,0,0,0]:h(k(d)),w=M(d)??0;if(!z&&!w)break;const R=o.primitiveName;let A=null;z&&!d.colorLocked&&(A=this._maybeGetValueOrOverrideExpression(R,"FillColor"));let G=null;z||d.colorLocked||(G=this._maybeGetValueOrOverrideExpression(R,"StrokeColor"));const X=A??this._getValueOrOverrideExpression(d.type,g,"Color",V),F=G??this._getValueOrOverrideExpression(d.type,g,"Color",N),T=this._maybeGetValueOrOverrideExpression(R,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,g,"Width",w),Y=I?{type:"sprite-rasterization-param",resource:{type:"path",path:I,asFill:z},overrides:[]}:{type:"sprite-rasterization-param",resource:L,overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:Y,colorLocked:!!d.colorLocked||!!p,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:C,y:P},isAbsoluteAnchorPoint:v,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:n},frameHeight:c,widthRatio:x,rotateClockwise:!1,referenceSize:l,sizeRatio:b,color:X,outlineColor:F,outlineWidth:T,isOutline:f,markerPlacement:t,animatedSymbolProperties:i});break}case"CIMPictureMarker":case"CIMVectorMarker":d.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,n,c,!!d.colorLocked||!!p,f):this._analyzeMarker(d,r,t,a,s,l,!1,n,p,f);break;default:this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,n,c,!!d.colorLocked||!!p,f)}g&&a.pop()}}_analyzeTextGraphic(e,t,i,o,a,s,l,c){const m=[];p.findApplicableOverrides(i,this._primitiveOverrides,m);const y=i.geometry;if(!("x"in y)||!("y"in y))return;const f=i.symbol,d=b(f),u=C(f.fontStyleName),v=r(f.fontFamilyName);f.font={family:v,decoration:d,...u};const _=O(f.height,n.CIMTextSymbol.height),g=O(f.angle),z=O(f.offsetX),L=O(f.offsetY),E=h(S(f));let I=h(k(f)),V=M(f)??0;V||(I=h(S(f.haloSymbol)),V=O(f.haloSize));let N=!1;if(f.symbol?.symbolLayers)for(const r of f.symbol.symbolLayers){null!=h(S(r))&&(N=!!r.colorLocked)}const w=i.primitiveName;let R=null;N||(R=this._maybeGetValueOrOverrideExpression(w,"FillColor"));const A=this._maybeGetValueOrOverrideExpression(w,"TextSize"),G=this._maybeGetValueOrOverrideExpression(w,"TextAngle"),X=this._maybeGetValueOrOverrideExpression(w,"TextOffsetX"),F=this._maybeGetValueOrOverrideExpression(w,"TextOffsetY");let T=null,Y=null,j=0;if(f.callout&&"CIMBackgroundCallout"===f.callout.type){const e=f.callout;if(e.backgroundSymbol){const r=e.backgroundSymbol.symbolLayers;if(r)for(const e of r)"CIMSolidFill"===e.type?T=h(e.color):"CIMSolidStroke"===e.type&&(Y=h(e.color),j=O(e.width,n.CIMSolidStroke.width))}}const W=this._getValueOrOverrideExpression(f.type,i.primitiveName,"TextString",i.textString??"");if(null==W)return;const{fontStyleName:D}=f,H=v+(D?"-"+D.toLowerCase():"-regular"),U=this._getMaterialOverrides(o,f.type);U.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,f.type));const J={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:f.font,symbol:f,primitiveName:i.primitiveName},overrides:U};this._cimLayers.push({type:"text",lineWidth:null,textRasterizationParam:J,colorLocked:!!c||!!N,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:H,decoration:d,weight:u.weight,style:u.style,size:A??_,angle:G??g,offsetX:X??z,offsetY:F??L,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:P(f.horizontalAlignment),verticalAlignment:x(f.verticalAlignment),text:W,color:R??this._getValueOrOverrideExpression(f.type,i.primitiveName,"Color",E),outlineColor:I,outlineSize:V,backgroundColor:T,borderLineColor:Y,borderLineWidth:j,referenceSize:s,sizeRatio:1,markerPlacement:t})}_analyzeMultiLayerGraphicNonSDF(e,r,t,i,a,s,n,c,p,m,y,f){const h=R(e,a),d=e.primitiveName,u=A(this._analyzeMaterialOverrides(d,["Rotation","OffsetX","OffsetY"])),[v,O,_]=l.getTextureAnchor(h,this._resourceManager),g=this._getMaterialOverrides(s,e.type);g.push(...u);const S={type:"sprite-rasterization-param",resource:{...h,avoidSDFRasterization:!0},overrides:g};this._cimLayers.push({type:"marker",spriteRasterizationParam:S,colorLocked:y,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:n,anchorPoint:{x:v,y:O},isAbsoluteAnchorPoint:!1,size:m,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:p},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:m,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:c,sizeRatio:_/o(e.size),isOutline:f,markerPlacement:t,animatedSymbolProperties:i})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const r=[];return p.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-marker-placement-info",placement:e,overrides:Y(r)}}_createAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const r=[];return p.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-animation-info",animation:e,overrides:Y(r)}}_analyzeCompositeMarkerGraphic(e,r,t,i,o,a,s,l,c,p,f,d){const u=o.geometry,v=a[0],_=a[1],g=m(u);if(!g)return;const S="Relative"!==e.anchorPointUnits,[k,M,b,C]=y(g,e.frame,e.size,e.anchorPoint,S),{path:P}=_,x=_.primitiveName,z=v.primitiveName,L=o.primitiveName;let E=null;_.colorLocked||f||(E=this._maybeGetValueOrOverrideExpression(L,"FillColor"));const I=E??this._getValueOrOverrideExpression(_.type,x,"Color",h(_.color));let V=null;v.colorLocked||f||(V=this._maybeGetValueOrOverrideExpression(L,"StrokeColor"));const N=V??this._getValueOrOverrideExpression(v.type,z,"Color",h(v.color)),w=this._maybeGetValueOrOverrideExpression(L,"StrokeWidth")??this._getValueOrOverrideExpression(v.type,z,"Width",O(v.width,n.CIMSolidStroke.width)),R={type:"sprite-rasterization-param",resource:P?{type:"path",path:P,asFill:!0}:{type:"sdf",geom:u,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:R,colorLocked:f,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:M,y:b},isAbsoluteAnchorPoint:S,size:p,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:c},frameHeight:p,widthRatio:C,rotateClockwise:!1,referenceSize:l,sizeRatio:k,color:I,outlineColor:N,outlineWidth:w,isOutline:d,markerPlacement:t,animatedSymbolProperties:i})}_setPoMap(e,r,t){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[r]=t}_maybeGetValueOrOverrideExpression(e,r,t){return this._getValueOrOverrideExpression("",e,r,t,!1)}_getValueOrOverrideExpression(e,r,t,i,o=!0){if(o&&!z(i)&&(i=_(e,t.toLowerCase())),null==r)return i;const a=this._poMap[r];if(null==a)return i;const s=a[t];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,r,t,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,r){if(!e)return[];const t=[];for(const i of e)t.push(...this._getPrimitiveMaterialOverrides(i,r));return t}_getPrimitiveMaterialOverrides(e,r){if(!e)return[];const t=A(this._primitiveOverrides.filter((r=>r.primitiveName===e)));return t.forEach((e=>e.defaultValue=_(r,e.propertyName.toLowerCase()))),t}_analyzeMaterialOverrides(e,r){return this._primitiveOverrides.filter((t=>t.primitiveName!==e||!r.includes(t.propertyName)))}}function R(e,r){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[r],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function A(e){return e.map((e=>({...e,propertyName:L(e.propertyName)})))}function G(e){if(e&&0===e.indexOf("Level_")){const r=parseInt(e.substr(6),10);if(!isNaN(r))return r}return 0}function X(e,r){if(!r||0===r.length)return e;const i=t(e);return p.applyOverrides(i,r),i}const F=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects;function T(e){const r=e.symbolLayers;if(!r||2!==r.length)return!1;const t=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)))),i=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectAddControlPoints"===e.type))));return!!t||!!i}function Y(e){return t(e).map((e=>({...e,propertyName:L(e.propertyName)})))}export{w as CIMAnalyzer,X as analyzeCIMResource};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
+ */
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import t from"../../core/ReactiveSet.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";var s;let a=null,p=s=class extends e{constructor(){super(),this.preventEditingDefaultVersion=!0,this.canEditVersionDirectly=!1,this.autoCreateTempVersion=!1,this.autoStartEditSession=!0,this.multiServiceEditsSupported=!0,this.supportUndoRedo=!0,this.confirmBeforeDelete=!1,this.allowedUndoRedoStrategies=new t(["versioning","compensatory"]),this.editsNotVisibleCallback=async(o,e)=>await Promise.resolve(),this.continueOperationCallback=async(o,e)=>await Promise.resolve(!0),this.operationErrorCallback=async(o,e,t,r)=>await Promise.resolve("cancel")}static get defaultContext(){return a||(a=new s),a}};o([r()],p.prototype,"preventEditingDefaultVersion",void 0),o([r()],p.prototype,"canEditVersionDirectly",void 0),o([r()],p.prototype,"autoCreateTempVersion",void 0),o([r()],p.prototype,"autoStartEditSession",void 0),o([r()],p.prototype,"multiServiceEditsSupported",void 0),o([r()],p.prototype,"supportUndoRedo",void 0),o([r()],p.prototype,"confirmBeforeDelete",void 0),o([r()],p.prototype,"allowedUndoRedoStrategies",void 0),p=s=o([i("esri.undoredo.support.DataEditingContext")],p);export{p as DataEditingContext};