@arcgis/core 4.28.0-rc.2 → 4.28.0-rc.4

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 (163) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/functions/featuresetbase.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{0e354096ad8817971eed.js → 02d235849ba93541d7ad.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0422c5160491fbcf01dc.js +1 -0
  6. package/assets/esri/core/workers/chunks/1da721608993783dc9cf.js +1 -0
  7. package/assets/esri/core/workers/chunks/224e79f6c172da444e0a.js +1 -0
  8. package/assets/esri/core/workers/chunks/{ca3d5803cdf035d7389d.js → 30776102fbab294bfe7b.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{61dec8399919b278b636.js → 3ac9001b19a90faf5573.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{fa6103e3d4e857b0035b.js → 3dcb2a82e1e4b520c9c9.js} +11 -8
  11. package/assets/esri/core/workers/chunks/41081c921037e543a22f.js +1 -0
  12. package/assets/esri/core/workers/chunks/4564a7885d045a850887.js +1 -0
  13. package/assets/esri/core/workers/chunks/4adf3a8c6b49c381a633.js +1 -0
  14. package/assets/esri/core/workers/chunks/{2721aa6b6941b28b9758.js → 63c8bf00120a4e67f5b0.js} +1 -1
  15. package/assets/esri/core/workers/chunks/6bc1f6f8a2408fa4bb6a.js +1 -0
  16. package/assets/esri/core/workers/chunks/74951370a341f02d3714.js +1 -0
  17. package/assets/esri/core/workers/chunks/78e49a70193e5adea17c.js +1 -0
  18. package/assets/esri/core/workers/chunks/7b8377b3a9f78f9d3613.js +1 -0
  19. package/assets/esri/core/workers/chunks/{fd28400141a6751327ae.js → 7cf7f2b991a7cbdad2ce.js} +1 -1
  20. package/assets/esri/core/workers/chunks/830d99e6c58a52a58973.js +1 -0
  21. package/assets/esri/core/workers/chunks/{1a723bb4a341f645e5fe.js → 83b8141f0c80e3448012.js} +1 -1
  22. package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +1 -0
  23. package/assets/esri/core/workers/chunks/934c32c49bb9e21482fd.js +1 -0
  24. package/assets/esri/core/workers/chunks/{a4341ec0fe89b865d849.js → a160576f21ada91995ac.js} +1 -1
  25. package/assets/esri/core/workers/chunks/a1e16c33f1843dbdce26.js +1 -0
  26. package/assets/esri/core/workers/chunks/{d07235ce2765a25b9be4.js → a50ec5b647a160199cb2.js} +1 -1
  27. package/assets/esri/core/workers/chunks/b6bd31674076e543d8b2.js +1 -0
  28. package/assets/esri/core/workers/chunks/{77923afde29ae1ff10ca.js → b6e86e179f99b5cf8dff.js} +1 -1
  29. package/assets/esri/core/workers/chunks/c3ddf5dbc34f118002df.js +1 -0
  30. package/assets/esri/core/workers/chunks/{562eafa5090827ebb7ec.js → c87e9280681c20d042b5.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{7b3d5f044c96e2c2af11.js → d191267d91a53db42956.js} +1 -1
  32. package/assets/esri/core/workers/chunks/ffa330a19a09679212fb.js +1 -0
  33. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +9 -13
  34. package/assets/esri/themes/base/widgets/_Features.scss +5 -0
  35. package/assets/esri/themes/base/widgets/_Legend.scss +1 -1
  36. package/assets/esri/themes/base/widgets/_Popup.scss +0 -1
  37. package/assets/esri/themes/base/widgets/_TimeZoneLabel.scss +3 -3
  38. package/assets/esri/themes/dark/main.css +1 -1
  39. package/assets/esri/themes/light/main.css +1 -1
  40. package/assets/esri/themes/light/view.css +1 -1
  41. package/geometry/support/meshUtils/georeference.js +1 -1
  42. package/interfaces.d.ts +1506 -314
  43. package/intl/date.js +1 -1
  44. package/kernel.js +1 -1
  45. package/layers/FeatureLayer.js +1 -1
  46. package/layers/GroupLayer.js +1 -1
  47. package/layers/OrientedImageryLayer.js +1 -1
  48. package/layers/SceneLayer.js +1 -1
  49. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  50. package/layers/graphics/data/QueryEngineResult.js +1 -1
  51. package/layers/graphics/data/queryValidationUtils.js +1 -1
  52. package/layers/mixins/ArcGISMapService.js +1 -1
  53. package/layers/save/groupLayerUtils.js +1 -1
  54. package/layers/save/utils.js +1 -1
  55. package/layers/support/ImageElement.js +1 -1
  56. package/layers/support/LayerContingentValuesCache.js +1 -1
  57. package/layers/support/Sublayer.js +1 -1
  58. package/layers/support/Subtype.d.ts +4 -0
  59. package/layers/support/Subtype.js +1 -1
  60. package/layers/support/imageryRendererUtils.js +1 -1
  61. package/networks/Network.js +1 -1
  62. package/package.json +1 -1
  63. package/portal/support/jsonContext.js +1 -1
  64. package/portal/support/layersLoader.js +1 -1
  65. package/rest/featureService/FeatureService.d.ts +4 -0
  66. package/rest/featureService/FeatureService.js +1 -1
  67. package/rest/featureService/utils.d.ts +4 -0
  68. package/rest/query/operations/query.js +1 -1
  69. package/smartMapping/support/utils.js +1 -1
  70. package/statistics/utils.js +1 -1
  71. package/support/basemapUtils.js +1 -1
  72. package/support/revision.js +1 -1
  73. package/versionManagement/VersionManagementService.d.ts +4 -0
  74. package/versionManagement/VersionManagementService.js +1 -1
  75. package/views/2d/engine/Container.js +1 -1
  76. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  77. package/views/2d/engine/webgl/Overlay.js +1 -1
  78. package/views/2d/input/handlers/KeyPan.js +1 -1
  79. package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
  80. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  81. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  82. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  83. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  84. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  85. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  86. package/views/3d/layers/I3SMeshView3D.js +1 -1
  87. package/views/3d/layers/MediaLayerView3D.js +1 -1
  88. package/views/3d/layers/SceneLayerWorker.js +1 -1
  89. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  90. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  91. package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
  92. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  93. package/views/3d/support/MemoryController.js +1 -1
  94. package/views/3d/support/PBFDecoder.js +1 -1
  95. package/views/3d/support/ResourceController.js +1 -1
  96. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  97. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  98. package/views/3d/webgl-engine/core/FBOPool.js +5 -0
  99. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -6
  100. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
  101. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  102. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  103. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  104. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  105. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  106. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  107. package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
  108. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  109. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  110. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  111. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +1 -1
  112. package/views/draw/DrawOperation.js +1 -1
  113. package/views/draw/support/Reshape.js +1 -1
  114. package/views/interactive/sketch/constraints.js +1 -1
  115. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  116. package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
  117. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  118. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  119. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  120. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  121. package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
  122. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  123. package/webdoc/support/writeUtils.js +1 -1
  124. package/widgets/BasemapGallery.js +1 -1
  125. package/widgets/DirectionalPad.js +1 -1
  126. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  127. package/widgets/Editor/EditorViewModel.js +1 -1
  128. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  129. package/widgets/Editor/UpdateWorkflow.js +1 -1
  130. package/widgets/Editor/VisibleElements.js +1 -1
  131. package/widgets/Editor/workflowUtils.js +1 -1
  132. package/widgets/Editor.js +1 -1
  133. package/widgets/FeatureForm/FieldInput.js +1 -1
  134. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  135. package/widgets/FeatureForm.js +1 -1
  136. package/widgets/Features.js +1 -1
  137. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +4 -0
  138. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  139. package/widgets/OrientedImageryViewer.js +1 -1
  140. package/widgets/TimeSlider.js +1 -1
  141. package/widgets/TimeZoneLabel.js +1 -1
  142. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  143. package/widgets/UtilityNetworkTrace.js +1 -1
  144. package/widgets/support/dateUtils.js +1 -1
  145. package/assets/esri/core/workers/chunks/00da3c16741a9bc47f3a.js +0 -1
  146. package/assets/esri/core/workers/chunks/0e4646d14fa0775bf463.js +0 -1
  147. package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +0 -1
  148. package/assets/esri/core/workers/chunks/51b8913dff24e693bd25.js +0 -1
  149. package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +0 -1
  150. package/assets/esri/core/workers/chunks/7388fd97e7b1a2142744.js +0 -1
  151. package/assets/esri/core/workers/chunks/7648f3341b7dff2825c3.js +0 -1
  152. package/assets/esri/core/workers/chunks/92d8f75e616afa5c761e.js +0 -1
  153. package/assets/esri/core/workers/chunks/9c77d69a13ec22cdd760.js +0 -1
  154. package/assets/esri/core/workers/chunks/a821fa1870b83fed5d31.js +0 -1
  155. package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +0 -1
  156. package/assets/esri/core/workers/chunks/b251d8a856dc8b9406e0.js +0 -1
  157. package/assets/esri/core/workers/chunks/c416df0668f6c596095f.js +0 -1
  158. package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +0 -1
  159. package/assets/esri/core/workers/chunks/f0d342303fc20e266d27.js +0 -1
  160. package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +0 -1
  161. package/assets/esri/core/workers/chunks/fc95b1a36ed68b851400.js +0 -1
  162. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +0 -4
  163. package/widgets/DirectionalPad.d.ts +0 -4
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as d}from"./geometryUtils.js";import{project as m}from"./projectionSupport.js";import{makeEdgeCandidate as h,makeVertexCandidate as g}from"./SnappingCandidate.js";import{isDateField as f,isDateOnlyField as p,isTimestampOffsetField as y,isStringField as x,isTimeOnlyField as I}from"../../support/fieldUtils.js";import{isNullCountSupported as V,calculateStringStatistics as T,calculateStatistics as F,processSummaryStatisticsResult as S,calculateUniqueValuesCount as _,createUVResult as v,calculateClassBreaks as b,resolveCBResult as R,calculateHistogram as A,getAttributeComparator as z,calculatePercentile as M}from"../../../statistics/utils.js";class q{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!n.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,r);s.push(t)}n.set(a,this._calculateUniqueValues(s,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:i,items:a}=u[t],r=i.join(",");s&&!e.validateItems(a,s)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(this.query):await this._createStatisticsQueryResponse(this.query)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;n(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...m(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t){const s=this.featureAdapter,i=C(this.hasZ,this.hasM),{point:a,mode:r}=e,n="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y,l={candidates:[]},u="esriGeometryPolygon"===this.geometryType,c=this._getPointCreator(r,this.spatialReference,t),d=new D(null,0),m=new D(null,0),f={x:0,y:0,z:0};for(const p of this.items){const t=s.getGeometry(p);if(null==t)continue;const{coords:r,lengths:y}=t;if(d.coords=r,m.coords=r,e.returnEdge){let e=0;for(let t=0;t<y.length;t++){const r=y[t];for(let t=0;t<r;t++,e+=i){const u=d;if(u.coordsIndex=e,t!==r-1){const t=m;t.coordsIndex=e+i;const r=f;N(f,a,u,t);const d=(a.x-r.x)/n,g=(a.y-r.y)/o,y=d*d+g*g;y<=1&&l.candidates.push(h(s.getObjectId(p),c(r),Math.sqrt(y),c(u),c(t)))}}}}if("none"!==e.vertexMode){const t=u?r.length-i:r.length;if("all"===e.vertexMode)for(let e=0;e<t;e+=i){const t=d;t.coordsIndex=e;const i=(a.x-t.x)/n,r=(a.y-t.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(t),Math.sqrt(u)))}else if("ends"===e.vertexMode){const e=[0];u||e.push(r.length-i);for(const t of e){const e=d;e.coordsIndex=t;const i=(a.x-e.x)/n,r=(a.y-e.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(e),Math.sqrt(u)))}}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>m(e,t,s),{hasZ:a}=this,r=0;return"3d"===e?a?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:r}):({x:e,y:t})=>i({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u}=e,c=this.fieldsIndex.get(t),d=f(c)||p(c)||y(c),m=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u}),h=V({normalizationType:a,normalizationField:i,minValue:n,maxValue:o}),g={value:.5,fieldType:c?.type},I=x(c)?T({values:m,supportsNullCount:h,percentileParams:g}):F({values:m,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:h,percentileParams:g});return S(I,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:r,timeZone:n},!1),l=_(o);return v(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m}),g=b(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return R(g,n)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m});return A(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.reverse()){const t=i.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=z(r?.type,n);e.sort(((e,t)=>{const i=s(e,a,r),n=s(t,a,r);return o(i,n)}))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:s,hasM:i,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:d,resultRecordCount:m,resultOffset:h,returnZ:g,returnM:f}=e,p=null!=m&&t.length>(h||0)+m,y=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:p,features:this._createFeatures(e,t),fields:y,geometryType:s,hasM:i&&f,hasZ:a&&g,objectIdFieldName:n,spatialReference:u(c||o),transform:d&&r(d)||null}}_createFeatures(e,t){const s=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:m,maxAllowableOffset:h,resultOffset:g,resultRecordCount:f,returnZ:p=!1,returnM:y=!1}=e,x=a&&p,I=i&&y;let V=[],T=0;const F=[...t];if(this._sortFeatures(F,n,((e,t,i)=>s.getFieldValue(e,t,i))),u||m){const e=r(o)??void 0;if(u&&!m)for(const t of F)V[T++]={attributes:s.getAttributes(t),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)};else if(!u&&m)for(const t of F)V[T++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)V[T++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)}}else for(const r of F){const e=s.getAttributes(r);e&&(V[T++]={attributes:e})}const S=g||0;if(null!=f){const e=S+f;V=V.slice(S,Math.min(V.length,e))}return V}_createExceedsLimitQueryResponse(e){let t=!1,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const r of e.outStatistics??[])if("exceedslimit"===r.statisticType){s=null!=r.maxPointCount?r.maxPointCount:Number.POSITIVE_INFINITY,i=null!=r.maxRecordCount?r.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=r.maxVertexCount?r.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)t=this.items.length>s;else if(this.items.length>i)t=!0;else{const e=C(this.hasZ,this.hasM),s=this.featureAdapter;t=this.items.reduce(((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(t)}}]}}async _createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,a=new Map,r=new Map,n=new Map,o=new l(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m,resultRecordCount:h}=e,g=c?.length,f=!!g,p=f?c[0]:null,y=f&&!this.fieldsIndex.get(p);for(const l of u??[]){const{outStatisticFieldName:e,statisticType:u}=l,m=l,I="exceedslimit"!==u?l.onStatisticField:void 0,V="percentile_disc"===u||"percentile_cont"===u,T="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,F=f&&1===g&&(I===p||y)&&"count"===u;if(f){if(!r.has(I)){const e=[];for(const t of c){const s=this._getAttributeValues(o,t,i);e.push(s)}r.set(I,this._calculateUniqueValues(e,!T&&o.returnDistinctValues))}const t=r.get(I);if(!t)continue;const s=Object.keys(t);h&&(s.sort(),s.length=h);for(const a of s){const{count:s,data:r,items:l,itemPositions:u}=t[a],h=r.join(",");if(!d||o.validateItems(l,d)){const t=n.get(h)||{attributes:{}};if(T){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,l);t.aggregateGeometries[s]=e}else{let a=null;if(F)a=s;else{const e=this._getAttributeValues(o,I,i),t=u.map((t=>e[t]));a=V&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,o.returnDistinctValues)}t.attributes[e]=a}let a=0;c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++a]=r[s])),n.set(h,t)}}}else if(T){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,this.items);t.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(o,I,i);t.attributes[e]=V&&"statisticParameters"in m?this._getPercentileValue(m,s):this._getStatisticValue(m,s,a,o.returnDistinctValues)}const S="min"!==u&&"max"!==u||!x(this.fieldsIndex.get(I))&&!this._isAnyDateField(I)?null:this.fieldsIndex.get(I)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const I=f?Array.from(n.values()):[t];return this._sortFeatures(I,m,((e,t)=>e.attributes[t])),{fields:s,features:I}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return f(t)||p(t)||y(t)||I(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:d,spatialReference:m,geometryType:h,hasZ:g,hasM:f}=this,p=r.map((e=>c(h,g,f,d.getGeometry(e)))),y=n(m,p,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=y?i(y):a(o(m,p));x.aggregateGeometries={...e,spatialReference:m},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=y?t(y):s(a(o(m,p)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=y,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:r}=e;let n=null;n=s?.has(a)?s.get(a):x(this.fieldsIndex.get(a))||this._isAnyDateField(a)?T({values:t,returnDistinct:i}):F({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:r,orderBy:n}=i,o=this.fieldsIndex.get(s);return M(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),a=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,a),a}_calculateUniqueValues(e,t){const s={},i=this.items,a=i.length;for(let r=0;r<a;r++){const a=i[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(t||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,s=!0){const i=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:a,scale:r,timeZone:n}=t;return a?i.getExpressionValues(this.items,a,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},n):i.getDataValues(this.items,e(t),s)}}function N(e,t,s,i){const a=i.x-s.x,r=i.y-s.y,n=a*a+r*r,o=(t.x-s.x)*a+(t.y-s.y)*r,l=Math.min(1,Math.max(0,o/n));e.x=s.x+a*l,e.y=s.y+r*l}function C(e,t){return e?t?4:3:t?3:2}class D{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}export{q as QueryEngineResult};
5
+ import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as d}from"./geometryUtils.js";import{project as m}from"./projectionSupport.js";import{makeEdgeCandidate as h,makeVertexCandidate as g}from"./SnappingCandidate.js";import{isDateField as f,isDateOnlyField as p,isTimestampOffsetField as y,isStringField as x,isTimeOnlyField as I}from"../../support/fieldUtils.js";import{isNullCountSupported as T,calculateStringStatistics as V,calculateStatistics as F,processSummaryStatisticsResult as S,calculateUniqueValuesCount as _,createUVResult as v,calculateClassBreaks as b,resolveCBResult as R,calculateHistogram as A,getAttributeComparator as z,calculatePercentile as M}from"../../../statistics/utils.js";class q{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!n.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,r);s.push(t)}n.set(a,this._calculateUniqueValues(s,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:i,items:a}=u[t],r=i.join(",");s&&!e.validateItems(a,s)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(this.query):await this._createStatisticsQueryResponse(this.query)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;n(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...m(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t){const s=this.featureAdapter,i=C(this.hasZ,this.hasM),{point:a,mode:r}=e,n="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y,l={candidates:[]},u="esriGeometryPolygon"===this.geometryType,c=this._getPointCreator(r,this.spatialReference,t),d=new D(null,0),m=new D(null,0),f={x:0,y:0,z:0};for(const p of this.items){const t=s.getGeometry(p);if(null==t)continue;const{coords:r,lengths:y}=t;if(d.coords=r,m.coords=r,e.returnEdge){let e=0;for(let t=0;t<y.length;t++){const r=y[t];for(let t=0;t<r;t++,e+=i){const u=d;if(u.coordsIndex=e,t!==r-1){const t=m;t.coordsIndex=e+i;const r=f;N(f,a,u,t);const d=(a.x-r.x)/n,g=(a.y-r.y)/o,y=d*d+g*g;y<=1&&l.candidates.push(h(s.getObjectId(p),c(r),Math.sqrt(y),c(u),c(t)))}}}}if("none"!==e.vertexMode){const t=u?r.length-i:r.length;if("all"===e.vertexMode)for(let e=0;e<t;e+=i){const t=d;t.coordsIndex=e;const i=(a.x-t.x)/n,r=(a.y-t.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(t),Math.sqrt(u)))}else if("ends"===e.vertexMode){const e=[0];u||e.push(r.length-i);for(const t of e){const e=d;e.coordsIndex=t;const i=(a.x-e.x)/n,r=(a.y-e.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(e),Math.sqrt(u)))}}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>m(e,t,s),{hasZ:a}=this,r=0;return"3d"===e?a?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:r}):({x:e,y:t})=>i({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u}=e,c=this.fieldsIndex.get(t),d=f(c)||p(c)||y(c),m=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u}),h=T({normalizationType:a,normalizationField:i,minValue:n,maxValue:o}),g={value:.5,fieldType:c?.type},I=x(c)?V({values:m,supportsNullCount:h,percentileParams:g}):F({values:m,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:h,percentileParams:g});return S(I,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:r,timeZone:n},!1),l=_(o);return v(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m}),g=b(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return R(g,n)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m});return A(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.reverse()){const t=i.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=z(r?.type,n);e.sort(((e,t)=>{const i=s(e,a,r),n=s(t,a,r);return o(i,n)}))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:s,hasM:i,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:d,resultRecordCount:m,resultOffset:h,returnZ:g,returnM:f}=e,p=null!=m&&t.length>(h||0)+m,y=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:p,features:this._createFeatures(e,t),fields:y,geometryType:s,hasM:i&&f,hasZ:a&&g,objectIdFieldName:n,spatialReference:u(c||o),transform:d&&r(d)||null}}_createFeatures(e,t){const s=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:m,maxAllowableOffset:h,resultOffset:g,resultRecordCount:f,returnZ:p=!1,returnM:y=!1}=e,x=a&&p,I=i&&y;let T=[],V=0;const F=[...t];if(this._sortFeatures(F,n,((e,t,i)=>s.getFieldValue(e,t,i))),this.geometryType&&(u||m)){const e=r(o)??void 0;if(u&&!m)for(const t of F)T[V++]={attributes:s.getAttributes(t),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)};else if(!u&&m)for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)}}else for(const r of F){const e=s.getAttributes(r);e&&(T[V++]={attributes:e})}const S=g||0;if(null!=f){const e=S+f;T=T.slice(S,Math.min(T.length,e))}return T}_createExceedsLimitQueryResponse(e){let t=!1,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const r of e.outStatistics??[])if("exceedslimit"===r.statisticType){s=null!=r.maxPointCount?r.maxPointCount:Number.POSITIVE_INFINITY,i=null!=r.maxRecordCount?r.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=r.maxVertexCount?r.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)t=this.items.length>s;else if(this.items.length>i)t=!0;else{const e=C(this.hasZ,this.hasM),s=this.featureAdapter;t=this.items.reduce(((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(t)}}]}}async _createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,a=new Map,r=new Map,n=new Map,o=new l(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m,resultRecordCount:h}=e,g=c?.length,f=!!g,p=f?c[0]:null,y=f&&!this.fieldsIndex.get(p);for(const l of u??[]){const{outStatisticFieldName:e,statisticType:u}=l,m=l,I="exceedslimit"!==u?l.onStatisticField:void 0,T="percentile_disc"===u||"percentile_cont"===u,V="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,F=f&&1===g&&(I===p||y)&&"count"===u;if(f){if(!r.has(I)){const e=[];for(const t of c){const s=this._getAttributeValues(o,t,i);e.push(s)}r.set(I,this._calculateUniqueValues(e,!V&&o.returnDistinctValues))}const t=r.get(I);if(!t)continue;const s=Object.keys(t);h&&(s.sort(),s.length=Math.min(h,s.length));for(const a of s){const{count:s,data:r,items:l,itemPositions:u}=t[a],h=r.join(",");if(!d||o.validateItems(l,d)){const t=n.get(h)||{attributes:{}};if(V){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,l);t.aggregateGeometries[s]=e}else{let a=null;if(F)a=s;else{const e=this._getAttributeValues(o,I,i),t=u.map((t=>e[t]));a=T&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,o.returnDistinctValues)}t.attributes[e]=a}let a=0;c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++a]=r[s])),n.set(h,t)}}}else if(V){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,this.items);t.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(o,I,i);t.attributes[e]=T&&"statisticParameters"in m?this._getPercentileValue(m,s):this._getStatisticValue(m,s,a,o.returnDistinctValues)}const S="min"!==u&&"max"!==u||!x(this.fieldsIndex.get(I))&&!this._isAnyDateField(I)?null:this.fieldsIndex.get(I)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const I=f?Array.from(n.values()):[t];return this._sortFeatures(I,m,((e,t)=>e.attributes[t])),{fields:s,features:I}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return f(t)||p(t)||y(t)||I(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:d,spatialReference:m,geometryType:h,hasZ:g,hasM:f}=this,p=r.map((e=>c(h,g,f,d.getGeometry(e)))),y=n(m,p,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=y?i(y):a(o(m,p));x.aggregateGeometries={...e,spatialReference:m},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=y?t(y):s(a(o(m,p)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=y,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:r}=e;let n=null;n=s?.has(a)?s.get(a):x(this.fieldsIndex.get(a))||this._isAnyDateField(a)?V({values:t,returnDistinct:i}):F({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:r,orderBy:n}=i,o=this.fieldsIndex.get(s);return M(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),a=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,a),a}_calculateUniqueValues(e,t){const s={},i=this.items,a=i.length;for(let r=0;r<a;r++){const a=i[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(t||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,s=!0){const i=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:a,scale:r,timeZone:n}=t;return a?i.getExpressionValues(this.items,a,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},n):i.getDataValues(this.items,e(t),s)}}function N(e,t,s,i){const a=i.x-s.x,r=i.y-s.y,n=a*a+r*r,o=(t.x-s.x)*a+(t.y-s.y)*r,l=Math.min(1,Math.max(0,o/n));e.x=s.x+a*l,e.y=s.y+r*l}function C(e,t){return e?t?4:3:t?3:2}class D{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}export{q as QueryEngineResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{numericFieldTypes as t,allDateAndTimeFieldTypes as i,validateFields as s,validateWhere as r,validateHaving as o}from"./attributeSupport.js";import{checkProjectionSupport as n}from"./projectionSupport.js";import{checkSpatialQuerySupport as a}from"./spatialQuerySupport.js";import{loadArcade as l}from"../../../support/arcadeOnDemand.js";const u="unsupported-query";async function c(t,{fieldsIndex:i,geometryType:s,spatialReference:r,availableFields:o}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(u,"Unsupported query options",{query:t});return p(i,o,t),f(i,o,t),Promise.all([a(t,s,r),n(r,t.outSR)]).then((()=>t))}function p(t,i,o){const{outFields:n,orderByFields:a,returnDistinctValues:l,outStatistics:c}=o,p=c?c.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(a&&a.length>0){const e=" asc",r=" desc",n=a.map((t=>{const i=t.toLowerCase();return i.includes(e)?i.split(e)[0]:i.includes(r)?i.split(r)[0]:t})).filter((e=>!p.includes(e)));s(t,i,n,{expressionName:"orderByFields",query:o})}if(n&&n.length>0)s(t,i,n,{expressionName:"outFields",query:o});else if(l)throw new e(u,"outFields should be specified for returnDistinctValues",{query:o});r(t,i,o.where,o)}const d=new Set([...t,...i]);function f(t,i,r){const{outStatistics:n,groupByFieldsForStatistics:a,having:l}=r,c=a?.length,p=n?.length;if(l){if(!c||!p)throw new e(u,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:r});o(t,i,l,n,r)}if(p){if(!h(n))return;const o=n.map((e=>e.onStatisticField)).filter(Boolean);s(t,i,o,{expressionName:"onStatisticFields",query:r}),c&&s(t,i,a,{expressionName:"groupByFieldsForStatistics",query:r});for(const a of n){const{onStatisticField:o,statisticType:n}=a;if(("percentile_disc"===n||"percentile_cont"===n)&&"statisticParameters"in a){const{statisticParameters:t}=a;if(!t)throw new e(u,"statisticParameters should be set for percentile type",{definition:a,query:r})}else t.get(o)&&"count"!==n&&"min"!==n&&"max"!==n&&s(t,i,[o],{expressionName:`outStatistics with '${n}' statistic type`,allowedFieldTypes:d,query:r})}}}async function m(t,i,{fieldsIndex:s,geometryType:r,spatialReference:o,availableFields:l}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(u,"Unsupported query options",{query:t});return p(s,l,t),Promise.all([y(s,l,i,t),a(t,r,o),n(o,t.outSR)]).then((()=>t))}async function y(t,i,r,o){let n=[];if(r.valueExpression){const{arcadeUtils:e}=await l();n=e.extractFieldNames(r.valueExpression)}if(r.field&&n.push(r.field),r.field2&&n.push(r.field2),r.field3&&n.push(r.field3),r.normalizationField&&n.push(r.normalizationField),!n.length&&!r.valueExpression)throw new e(u,"field or valueExpression is required",{params:r});s(t,i,n,{expressionName:"statistics",query:o})}function h(e){return null!=e&&e.every((e=>"exceedslimit"!==e.statisticType))}export{c as validateQuery,m as validateStatisticsQuery};
5
+ import e from"../../../core/Error.js";import{numericFieldTypes as t,allDateAndTimeFieldTypes as i,validateFields as s,validateWhere as r,validateHaving as o}from"./attributeSupport.js";import{checkProjectionSupport as n}from"./projectionSupport.js";import{checkSpatialQuerySupport as a}from"./spatialQuerySupport.js";import{loadArcade as l}from"../../../support/arcadeOnDemand.js";const u="unsupported-query";async function c(t,{fieldsIndex:i,geometryType:s,spatialReference:r,availableFields:o}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption&&"xyFootprint"!==t.multipatchOption||t.pixelSize||t.relationParam||t.text)throw new e(u,"Unsupported query options",{query:t});return p(i,o,t),f(i,o,t),Promise.all([a(t,s,r),n(r,t.outSR)]).then((()=>t))}function p(t,i,o){const{outFields:n,orderByFields:a,returnDistinctValues:l,outStatistics:c}=o,p=c?c.map((e=>e.outStatisticFieldName&&e.outStatisticFieldName.toLowerCase())).filter(Boolean):[];if(a&&a.length>0){const e=" asc",r=" desc",n=a.map((t=>{const i=t.toLowerCase();return i.includes(e)?i.split(e)[0]:i.includes(r)?i.split(r)[0]:t})).filter((e=>!p.includes(e)));s(t,i,n,{expressionName:"orderByFields",query:o})}if(n&&n.length>0)s(t,i,n,{expressionName:"outFields",query:o});else if(l)throw new e(u,"outFields should be specified for returnDistinctValues",{query:o});r(t,i,o.where,o)}const d=new Set([...t,...i]);function f(t,i,r){const{outStatistics:n,groupByFieldsForStatistics:a,having:l}=r,c=a?.length,p=n?.length;if(l){if(!c||!p)throw new e(u,"outStatistics and groupByFieldsForStatistics should be specified with having",{query:r});o(t,i,l,n,r)}if(p){if(!h(n))return;const o=n.map((e=>e.onStatisticField)).filter(Boolean);s(t,i,o,{expressionName:"onStatisticFields",query:r}),c&&s(t,i,a,{expressionName:"groupByFieldsForStatistics",query:r});for(const a of n){const{onStatisticField:o,statisticType:n}=a;if(("percentile_disc"===n||"percentile_cont"===n)&&"statisticParameters"in a){const{statisticParameters:t}=a;if(!t)throw new e(u,"statisticParameters should be set for percentile type",{definition:a,query:r})}else t.get(o)&&"count"!==n&&"min"!==n&&"max"!==n&&s(t,i,[o],{expressionName:`outStatistics with '${n}' statistic type`,allowedFieldTypes:d,query:r})}}}async function m(t,i,{fieldsIndex:s,geometryType:r,spatialReference:o,availableFields:l}){if((t.distance??0)<0||null!=t.geometryPrecision||t.multipatchOption||t.pixelSize||t.relationParam||t.text||t.outStatistics||t.groupByFieldsForStatistics||t.having||t.orderByFields)throw new e(u,"Unsupported query options",{query:t});return p(s,l,t),Promise.all([y(s,l,i,t),a(t,r,o),n(o,t.outSR)]).then((()=>t))}async function y(t,i,r,o){let n=[];if(r.valueExpression){const{arcadeUtils:e}=await l();n=e.extractFieldNames(r.valueExpression)}if(r.field&&n.push(r.field),r.field2&&n.push(r.field2),r.field3&&n.push(r.field3),r.normalizationField&&n.push(r.normalizationField),!n.length&&!r.valueExpression)throw new e(u,"field or valueExpression is required",{params:r});s(t,i,n,{expressionName:"statistics",query:o})}function h(e){return null!=e&&e.every((e=>"exceedslimit"!==e.statisticType))}export{c as validateQuery,m as validateStatisticsQuery};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../request.js";import{getOrCreateMapValue as t}from"../../core/MapUtils.js";import{throwIfAborted as s}from"../../core/promiseUtils.js";import{join as o}from"../../core/urlUtils.js";import{Version as i}from"../../core/Version.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{OriginId as n}from"../../core/accessorSupport/PropertyOrigin.js";import c from"../../geometry/Extent.js";import u from"../../geometry/SpatialReference.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{id as m,popupEnabled as d}from"../support/commonProperties.js";import{isHostedLayer as h}from"../../portal/support/portalItemUtils.js";const f=f=>{let b=class extends f{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesMap=null}readCapabilities(e,r){const t=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!t)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};const s=this.type,o="tile"!==s&&!!r.supportsDynamicLayers,a=t.includes("query"),p=t.includes("map"),l=!!r.exportTilesAllowed,n=t.includes("tilemap"),c=t.includes("data"),u="tile"!==s&&(!r.tileInfo||o),y="tile"!==s&&(!r.tileInfo||o),m="tile"!==s,d=r.cimVersion&&i.parse(r.cimVersion),h=d?.since(1,4)??!1,f=d?.since(2,0)??!1;return{operations:{supportsExportMap:p,supportsExportTiles:l,supportsIdentify:a,supportsQuery:c,supportsTileMap:n},exportMap:p?{supportsArcadeExpressionForLabeling:h,supportsSublayersChanges:m,supportsDynamicLayers:o,supportsSublayerVisibility:u,supportsSublayerDefinitionExpression:y,supportsCIMSymbols:f}:null,exportTiles:l?{maxExportTilesCount:+r.maxExportTilesCount}:null}}readVersion(e,r){let t=r.currentVersion;return t||(t=r.hasOwnProperty("capabilities")||r.hasOwnProperty("tables")?10:r.hasOwnProperty("supportedImageFormatTypes")?9.31:9.3),t}async fetchRelatedService(e){const r=this.portalItem;if(!r||!h(r))return null;this._relatedFeatureServicePromise||(this._relatedFeatureServicePromise=r.fetchRelatedItems({relationshipType:"Service2Service",direction:"reverse"},e).then((e=>e.find((e=>"Feature Service"===e.type))??null),(()=>null)));const t=await this._relatedFeatureServicePromise;return s(e),t?{itemId:t.id,url:t.url}:null}async fetchSublayerInfo(e,t){const{source:s}=e;if(this?.portalItem&&"tile"===this.type&&"map-layer"===s?.type&&h(this.portalItem)&&e.originIdOf("url")<n.SERVICE){const r=await this.fetchRelatedService(t);r&&(e.url=o(r.url,s.mapLayerId.toString()),e.layerItemId=r.itemId)}const{url:i}=e;let a;if("data-layer"===s.type){a=(await r(i,{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey},...t})).data}else if(i&&e.originIdOf("url")>n.SERVICE)try{a=(await this._fetchAllLayersAndTablesFromService(i)).get(s.mapLayerId)}catch{}else{let r=e.id;"map-layer"===s?.type&&(r=s.mapLayerId);try{a=(await this.fetchAllLayersAndTables(t)).get(r)}catch{}}return a}async fetchAllLayersAndTables(e){return this._fetchAllLayersAndTablesFromService(this.parsedUrl?.path,e)}async _fetchAllLayersAndTablesFromService(e,i){await this.load(i),this._allLayersAndTablesMap||=new Map;const a=y(e),p=t(this._allLayersAndTablesMap,a?.url.path,(()=>r(o(a?.url.path,"/layers"),{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey}}).then((e=>{const r=new Map;for(const t of e.data.layers)r.set(t.id,t);return{result:r}}),(e=>({error:e}))))),l=await p;if(s(i),"result"in l)return l.result;throw l.error}};return e([a({readOnly:!0})],b.prototype,"capabilities",void 0),e([p("service","capabilities",["capabilities","exportTilesAllowed","maxExportTilesCount","supportsDynamicLayers","tileInfo"])],b.prototype,"readCapabilities",null),e([a({json:{read:{source:"copyrightText"}}})],b.prototype,"copyright",void 0),e([a({type:c})],b.prototype,"fullExtent",void 0),e([a(m)],b.prototype,"id",void 0),e([a({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend"}}})],b.prototype,"legendEnabled",void 0),e([a(d)],b.prototype,"popupEnabled",void 0),e([a({type:u})],b.prototype,"spatialReference",void 0),e([a({readOnly:!0})],b.prototype,"version",void 0),e([p("version",["currentVersion","capabilities","tables","supportedImageFormatTypes"])],b.prototype,"readVersion",null),b=e([l("esri.layers.mixins.ArcGISMapService")],b),b};export{f as ArcGISMapService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../request.js";import{getOrCreateMapValue as t}from"../../core/MapUtils.js";import{throwIfAborted as s}from"../../core/promiseUtils.js";import{join as o}from"../../core/urlUtils.js";import{Version as i}from"../../core/Version.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{OriginId as n}from"../../core/accessorSupport/PropertyOrigin.js";import c from"../../geometry/Extent.js";import u from"../../geometry/SpatialReference.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{id as m,popupEnabled as d}from"../support/commonProperties.js";import{isHostedLayer as h}from"../../portal/support/portalItemUtils.js";const f=f=>{let b=class extends f{constructor(){super(...arguments),this.capabilities=void 0,this.copyright=null,this.fullExtent=null,this.legendEnabled=!0,this.spatialReference=null,this.version=void 0,this._allLayersAndTablesMap=null}readCapabilities(e,r){const t=r.capabilities&&r.capabilities.split(",").map((e=>e.toLowerCase().trim()));if(!t)return{operations:{supportsExportMap:!1,supportsExportTiles:!1,supportsIdentify:!1,supportsQuery:!1,supportsTileMap:!1},exportMap:null,exportTiles:null};const s=this.type,o="tile"!==s&&!!r.supportsDynamicLayers,a=t.includes("query"),p=t.includes("map"),l=!!r.exportTilesAllowed,n=t.includes("tilemap"),c=t.includes("data"),u="tile"!==s&&(!r.tileInfo||o),y="tile"!==s&&(!r.tileInfo||o),m="tile"!==s,d=r.cimVersion&&i.parse(r.cimVersion),h=d?.since(1,4)??!1,f=d?.since(2,0)??!1;return{operations:{supportsExportMap:p,supportsExportTiles:l,supportsIdentify:a,supportsQuery:c,supportsTileMap:n},exportMap:p?{supportsArcadeExpressionForLabeling:h,supportsSublayersChanges:m,supportsDynamicLayers:o,supportsSublayerVisibility:u,supportsSublayerDefinitionExpression:y,supportsCIMSymbols:f}:null,exportTiles:l?{maxExportTilesCount:+r.maxExportTilesCount}:null}}readVersion(e,r){let t=r.currentVersion;return t||(t=r.hasOwnProperty("capabilities")||r.hasOwnProperty("tables")?10:r.hasOwnProperty("supportedImageFormatTypes")?9.31:9.3),t}async fetchRelatedService(e){const r=this.portalItem;if(!r||!h(r))return null;this._relatedFeatureServicePromise||(this._relatedFeatureServicePromise=r.fetchRelatedItems({relationshipType:"Service2Service",direction:"reverse"},e).then((e=>e.find((e=>"Feature Service"===e.type))??null),(()=>null)));const t=await this._relatedFeatureServicePromise;return s(e),t?{itemId:t.id,url:t.url}:null}async fetchSublayerInfo(e,t){const{source:s}=e;if(this?.portalItem&&"tile"===this.type&&"map-layer"===s?.type&&h(this.portalItem)&&e.originIdOf("url")<n.SERVICE){const r=await this.fetchRelatedService(t);r&&(e.url=o(r.url,s.mapLayerId.toString()),e.layerItemId=r.itemId)}const{url:i}=e;let a;if("data-layer"===s.type){a=(await r(i,{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey},...t})).data}else if(i&&e.originIdOf("url")>n.SERVICE)try{const e=await this._fetchAllLayersAndTablesFromService(i),r=y(i)?.sublayer??s.mapLayerId;a=e.get(r)}catch{}else{let r=e.id;"map-layer"===s?.type&&(r=s.mapLayerId);try{a=(await this.fetchAllLayersAndTables(t)).get(r)}catch{}}return a}async fetchAllLayersAndTables(e){return this._fetchAllLayersAndTablesFromService(this.parsedUrl?.path,e)}async _fetchAllLayersAndTablesFromService(e,i){await this.load(i),this._allLayersAndTablesMap||=new Map;const a=y(e),p=t(this._allLayersAndTablesMap,a?.url.path,(()=>r(o(a?.url.path,"/layers"),{responseType:"json",query:{f:"json",...this.customParameters,token:this.apiKey}}).then((e=>{const r=new Map;for(const t of e.data.layers)r.set(t.id,t);return{result:r}}),(e=>({error:e}))))),l=await p;if(s(i),"result"in l)return l.result;throw l.error}};return e([a({readOnly:!0})],b.prototype,"capabilities",void 0),e([p("service","capabilities",["capabilities","exportTilesAllowed","maxExportTilesCount","supportsDynamicLayers","tileInfo"])],b.prototype,"readCapabilities",null),e([a({json:{read:{source:"copyrightText"}}})],b.prototype,"copyright",void 0),e([a({type:c})],b.prototype,"fullExtent",void 0),e([a(m)],b.prototype,"id",void 0),e([a({type:Boolean,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend"}}})],b.prototype,"legendEnabled",void 0),e([a(d)],b.prototype,"popupEnabled",void 0),e([a({type:u})],b.prototype,"spatialReference",void 0),e([a({readOnly:!0})],b.prototype,"version",void 0),e([p("version",["currentVersion","capabilities","tables","supportedImageFormatTypes"])],b.prototype,"readVersion",null),b=e([l("esri.layers.mixins.ArcGISMapService")],b),b};export{f as ArcGISMapService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{save as e,saveAs as t}from"./utils.js";import{createForGroupLayerItemWrite as r}from"../../portal/support/jsonContext.js";import{TypeKeyword as a,hasTypeKeyword as o,addTypeKeyword as s}from"../../portal/support/portalItemUtils.js";const n="Group Layer",i="group-layer-save",l="group-layer-save-as",p=a.GROUP_LAYER_MAP;function u(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function y(e){return{isValid:o(e,p),errorMessage:`Layer.portalItem.typeKeywords should have '${p}'`}}function m(e){const t=e.layerJSON;return t&&delete t.itemId,Promise.resolve(t&&Object.keys(t).length?t:null)}async function c(e,t){t.title||=e.title,s(t,p)}async function f(t,a){return e({layer:t,itemType:n,validateLayer:u,validateItem:y,createJSONContext:e=>r(e),createItemData:m,errorNamePrefix:i},a)}async function d(e,a,o){return t({layer:e,itemType:n,validateLayer:u,createJSONContext:e=>r(e),createItemData:m,errorNamePrefix:l,newItem:a,setItemProperties:c},o)}export{f as save,d as saveAs};
5
+ import{save as e,saveAs as r}from"./utils.js";import{createForGroupLayerItemWrite as t}from"../../portal/support/jsonContext.js";import{TypeKeyword as s,hasTypeKeyword as a,addTypeKeyword as o}from"../../portal/support/portalItemUtils.js";import{saveResources as n}from"../../webdoc/support/saveUtils.js";const i="Group Layer",u="group-layer-save",c="group-layer-save-as",l=s.GROUP_LAYER_MAP;function p(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function m(e){return{isValid:a(e,l),errorMessage:`Layer.portalItem.typeKeywords should have '${l}'`}}function y(e){const r=e.layerJSON;return Promise.resolve(r&&Object.keys(r).length?r:null)}async function f(e,r){r.title||=e.title,o(r,l)}async function v(r,s){return e({layer:r,itemType:i,validateLayer:p,validateItem:m,createJSONContext:e=>t(e,r),createItemData:y,errorNamePrefix:u,saveResources:async(e,t)=>(r.sourceIsPortalItem||await e.removeAllResources().catch((()=>{})),n(r.resourceReferences,t))},s)}async function d(e,s,a){return r({layer:e,itemType:i,validateLayer:p,createJSONContext:r=>t(r,e),createItemData:y,errorNamePrefix:c,newItem:s,setItemProperties:f,saveResources:(r,t)=>n(e.resourceReferences,t)},a)}export{v as save,d as saveAs};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import r from"../../portal/Portal.js";import o from"../../portal/PortalItem.js";import{createForItemWrite as a}from"../../portal/support/jsonContext.js";import{addTypeKeyword as i,TypeKeyword as n}from"../../portal/support/portalItemUtils.js";import{validateSaveAPIKey as s}from"../../webdoc/saveAPIKeyUtils.js";function l(t,r,o){const a=o(t);if(!a.isValid)throw new e(`${r}:invalid-parameters`,a.errorMessage,{layer:t})}async function p(e){const{layer:t,errorNamePrefix:r,validateLayer:o}=e;await t.load(),l(t,r,o)}function m(e,t){return`Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t}`}function d(t){const{item:r,itemType:o,errorNamePrefix:a,layer:i,validateItem:n}=t;if(s(r),r.type!==o)throw new e(`${a}:portal-item-wrong-type`,`Portal item type should be "${o}"`,{item:r,layer:i});if(n){const t=n(r);if(!t.isValid)throw new e(`${a}:invalid-parameters`,t.errorMessage,{layer:i})}}function c(t){const{layer:r,errorNamePrefix:o}=t,{portalItem:a}=r;if(!a)throw new e(`${o}:portal-item-not-set`,m(r,"requires the portalItem property to be set"));if(!a.loaded)throw new e(`${o}:portal-item-not-loaded`,m(r,"cannot be saved to a portal item that does not exist or is inaccessible"));d({...t,item:a})}function f(e){const{newItem:t,itemType:a}=e;let i=o.from(t);return i.id&&(i=i.clone(),i.id=null),i.type??=a,i.portal??=r.getDefault(),d({...e,item:i}),i}function u(t,r){let o=(t.messages??[]).filter((({type:e})=>"error"===e)).map((({name:t,message:r,details:o})=>new e(t,r,o)));if(r?.ignoreUnsupported&&(o=o.filter((({name:e})=>"layer:unsupported"!==e&&"symbol:unsupported"!==e&&"symbol-layer:unsupported"!==e&&"property:unsupported"!==e&&"url:unsupported"!==e))),o.length>0)throw new e("layer-write:unsupported","Failed to save layer due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:o})}async function y(e,t,r){"beforeSave"in e&&"function"==typeof e.beforeSave&&await e.beforeSave();const o=e.write({},t);return u(t,r),o}function w(e){i(e,n.JSAPI),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}async function I(e,t,r){const o=e.portal;await o.signIn(),await(o.user?.addItem({item:e,data:t,folder:r?.folder}))}async function v(e,r){const{layer:o,createItemData:i,createJSONContext:n}=e;await p(e),c(e);const s=o.portalItem,l=n?n(s):a(s),m=await y(o,l,r),d=await i({layer:o,layerJSON:m},s);return w(s),await s.update({data:d}),t(l),s}async function b(e,r){const{layer:o,createItemData:i,createJSONContext:n,setItemProperties:s}=e;await p(e);const l=f(e),m=n?n(l):a(l),d=await y(o,m,r),c=await i({layer:o,layerJSON:d},l);return await s(o,l),w(l),await I(l,c,r),o.portalItem=l,t(m),l}export{I as addItem,m as createErrorMessage,c as ensureItemConfig,l as ensureLayerConfig,y as getLayerJSON,f as getPortalItem,v as save,b as saveAs,w as setCommonItemProperties};
5
+ import e from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import r from"../../portal/Portal.js";import o from"../../portal/PortalItem.js";import{createForItemWrite as a}from"../../portal/support/jsonContext.js";import{addTypeKeyword as i,TypeKeyword as n}from"../../portal/support/portalItemUtils.js";import{validateSaveAPIKey as s}from"../../webdoc/saveAPIKeyUtils.js";function l(t,r,o){const a=o(t);if(!a.isValid)throw new e(`${r}:invalid-parameters`,a.errorMessage,{layer:t})}async function p(e){const{layer:t,errorNamePrefix:r,validateLayer:o}=e;await t.load(),l(t,r,o)}function m(e,t){return`Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t}`}function c(t){const{item:r,itemType:o,errorNamePrefix:a,layer:i,validateItem:n}=t;if(s(r),r.type!==o)throw new e(`${a}:portal-item-wrong-type`,`Portal item type should be "${o}"`,{item:r,layer:i});if(n){const t=n(r);if(!t.isValid)throw new e(`${a}:invalid-parameters`,t.errorMessage,{layer:i})}}function d(t){const{layer:r,errorNamePrefix:o}=t,{portalItem:a}=r;if(!a)throw new e(`${o}:portal-item-not-set`,m(r,"requires the portalItem property to be set"));if(!a.loaded)throw new e(`${o}:portal-item-not-loaded`,m(r,"cannot be saved to a portal item that does not exist or is inaccessible"));c({...t,item:a})}function u(e){const{newItem:t,itemType:a}=e;let i=o.from(t);return i.id&&(i=i.clone(),i.id=null),i.type??=a,i.portal??=r.getDefault(),c({...e,item:i}),i}function f(t,r){let o=(t.messages??[]).filter((({type:e})=>"error"===e)).map((({name:t,message:r,details:o})=>new e(t,r,o)));if(t.blockedRelativeUrls&&(o=o.concat(t.blockedRelativeUrls.map((t=>new e("url:unsupported",`Relative url '${t}' is not supported`))))),r?.ignoreUnsupported&&(o=o.filter((({name:e})=>"layer:unsupported"!==e&&"symbol:unsupported"!==e&&"symbol-layer:unsupported"!==e&&"property:unsupported"!==e&&"url:unsupported"!==e))),o.length>0)throw new e("layer-write:unsupported","Failed to save layer due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:o})}async function y(e,t,r){"beforeSave"in e&&"function"==typeof e.beforeSave&&await e.beforeSave();const o=e.write({},t);return await Promise.all(t.resources?.pendingOperations??[]),f(t,r),o}function w(e){i(e,n.JSAPI),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}async function v(e,t,r){const o=e.portal;await o.signIn(),await(o.user?.addItem({item:e,data:t,folder:r?.folder}))}async function I(e,r){const{layer:o,createItemData:i,createJSONContext:n,saveResources:s}=e;await p(e),d(e);const l=o.portalItem,m=n?n(l):a(l),c=await y(o,m,r),u=await i({layer:o,layerJSON:c},l);return w(l),await l.update({data:u}),t(m),await(s?.(l,m)),l}async function b(e,r){const{layer:o,createItemData:i,createJSONContext:n,setItemProperties:s,saveResources:l}=e;await p(e);const m=u(e),c=n?n(m):a(m),d=await y(o,c,r),f=await i({layer:o,layerJSON:d},m);return await s(o,m),w(m),await v(m,f,r),o.portalItem=m,t(c),await(l?.(m,c)),m}export{v as addItem,m as createErrorMessage,d as ensureItemConfig,l as ensureLayerConfig,y as getLayerJSON,u as getPortalItem,I as save,b as saveAs,w as setCommonItemProperties};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import r from"../../core/Error.js";import{getImageData as o}from"../../core/imageUtils.js";import{isDataProtocol as n,isBlobProtocol as i,isAbsolute as s,dataToBlob as a,join as m}from"../../core/urlUtils.js";import{generateUUID as l}from"../../core/uuid.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../../core/accessorSupport/decorators/writer.js";import d from"./MediaElementBase.js";import{getResourceContentExtension as g}from"../../portal/support/resourceExtension.js";import{f,t as y,i as v,M as j}from"../../chunks/persistableUrlUtils.js";let I=class extends d{constructor(e){super(e),this.animationOptions=null,this.content=null,this.image=null,this.type="image",this.image=null}load(){const e=this.image;if("string"==typeof e){const t=o(e).then((e=>{this._set("content",e)}));this.addResolvingPromise(t)}else if(e instanceof HTMLImageElement){const t=e.decode().then((()=>{this._set("content",e)}));this.addResolvingPromise(t)}else e?this._set("content",e):this.addResolvingPromise(Promise.reject(new r("image-element:invalid-image-type","Invalid image type",{image:e})));return Promise.resolve(this)}get contentWidth(){return null==this.content?0:this.content instanceof HTMLImageElement?this.content.naturalWidth:this.content.width}get contentHeight(){return null==this.content?0:this.content instanceof HTMLImageElement?this.content.naturalHeight:this.content.height}readImage(e,t,r){return f(t.url,r)}writeImage(e,t,r,o){if(null==e)return;const a=o?.portalItem,m=o?.resources;if(!a||!m)return void("string"==typeof e&&(t[r]=y(e,o)));const l="string"!=typeof e||n(e)||i(e)?null:e;if(l){if(null==v(l))return void(t[r]=l);const e=y(l,{...o,verifyItemRelativeUrls:o?.verifyItemRelativeUrls?{writtenUrls:o.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},j.NO);if(a&&e&&!s(e))return m.toKeep.push({resource:a.resourceFromPath(e),compress:!1}),void(t[r]=e)}t[r]="<pending>",m.pendingOperations.push(w(e).then((e=>{const o=H(e,a);t[r]=o.itemRelativeUrl,m.toAdd.push({resource:o,content:{type:"blob",blob:e},compress:!1,finish:e=>{this.image=e.url}})})))}};e([c()],I.prototype,"animationOptions",void 0),e([c({readOnly:!0})],I.prototype,"content",void 0),e([c({readOnly:!0})],I.prototype,"contentWidth",null),e([c({readOnly:!0})],I.prototype,"contentHeight",null),e([c({json:{name:"url",type:String}})],I.prototype,"image",void 0),e([p("image",["url"])],I.prototype,"readImage",null),e([h("image")],I.prototype,"writeImage",null),e([c({readOnly:!0,json:{name:"mediaType"}})],I.prototype,"type",void 0),I=e([u("esri.layers.support.ImageElement")],I);const b=I;async function w(e){if("string"==typeof e){if(i(e)){const{data:r}=await t(e,{responseType:"blob"});return r}if(n(e))return a(e);return w((await t(e,{responseType:"image"})).data)}return new Promise((t=>E(e).toBlob(t)))}function E(e){if(e instanceof HTMLCanvasElement)return e;const t=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height,o=document.createElement("canvas"),n=o.getContext("2d");return o.width=t,o.height=r,e instanceof HTMLImageElement?n.drawImage(e,0,0,e.width,e.height):e instanceof ImageData&&n.putImageData(e,0,0),o}function H(e,t){const r=l(),o=`${m("media",r)}.${g({type:"blob",blob:e})}`;return t.resourceFromPath(o)}export{b as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import r from"../../core/Error.js";import{getImageData as o}from"../../core/imageUtils.js";import{isDataProtocol as n,isBlobProtocol as i,isAbsolute as s,dataToBlob as a,join as l}from"../../core/urlUtils.js";import{generateUUID as m}from"../../core/uuid.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as p}from"../../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../../core/accessorSupport/decorators/writer.js";import d from"./MediaElementBase.js";import{getResourceContentExtension as g}from"../../portal/support/resourceExtension.js";import{f,t as y,i as v,M as j}from"../../chunks/persistableUrlUtils.js";let I=class extends d{constructor(t){super(t),this.animationOptions=null,this.content=null,this.image=null,this.type="image",this.image=null}load(){const t=this.image;if("string"==typeof t){const e=o(t).then((t=>{this._set("content",t)}));this.addResolvingPromise(e)}else if(t instanceof HTMLImageElement){const e=t.decode().then((()=>{this._set("content",t)}));this.addResolvingPromise(e)}else t?this._set("content",t):this.addResolvingPromise(Promise.reject(new r("image-element:invalid-image-type","Invalid image type",{image:t})));return Promise.resolve(this)}get contentWidth(){return null==this.content?0:this.content instanceof HTMLImageElement?this.content.naturalWidth:this.content.width}get contentHeight(){return null==this.content?0:this.content instanceof HTMLImageElement?this.content.naturalHeight:this.content.height}readImage(t,e,r){return f(e.url,r)}writeImage(t,e,r,o){if(null==t)return;const a=o?.portalItem,l=o?.resources;if(!a||!l)return void("string"==typeof t&&(e[r]=y(t,o)));const m="string"!=typeof t||n(t)||i(t)?null:t;if(m){if(null==v(m))return void(e[r]=m);const t=y(m,{...o,verifyItemRelativeUrls:o?.verifyItemRelativeUrls?{writtenUrls:o.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},j.NO);if(a&&t&&!s(t))return l.toKeep.push({resource:a.resourceFromPath(t),compress:!1}),void(e[r]=t)}e[r]="<pending>",l.pendingOperations.push(w(t).then((t=>{const o=H(t,a);e[r]=o.itemRelativeUrl,l.toAdd.push({resource:o,content:{type:"blob",blob:t},compress:!1,finish:t=>{this.image=t.url}})})))}};t([c()],I.prototype,"animationOptions",void 0),t([c({readOnly:!0})],I.prototype,"content",void 0),t([c({readOnly:!0})],I.prototype,"contentWidth",null),t([c({readOnly:!0})],I.prototype,"contentHeight",null),t([c({json:{name:"url",type:String}})],I.prototype,"image",void 0),t([p("image",["url"])],I.prototype,"readImage",null),t([h("image")],I.prototype,"writeImage",null),t([c({readOnly:!0,json:{name:"mediaType"}})],I.prototype,"type",void 0),I=t([u("esri.layers.support.ImageElement")],I);const b=I;async function w(t){if("string"==typeof t){if(n(t))return a(t);return(await e(t,{responseType:"blob"})).data}return new Promise((e=>E(t).toBlob(e)))}function E(t){if(t instanceof HTMLCanvasElement)return t;const e=t instanceof HTMLImageElement?t.naturalWidth:t.width,r=t instanceof HTMLImageElement?t.naturalHeight:t.height,o=document.createElement("canvas"),n=o.getContext("2d");return o.width=e,o.height=r,t instanceof HTMLImageElement?n.drawImage(t,0,0,t.width,t.height):t instanceof ImageData&&n.putImageData(t,0,0),o}function H(t,e){const r=m(),o=`${l("media",r)}.${g({type:"blob",blob:t})}`;return e.resourceFromPath(o)}export{b as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{isSome as n}from"../../core/arrayUtils.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import s from"../../core/Loadable.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{parse as a}from"./arcgisLayerUrl.js";import l from"./Contingency.js";import u from"./ContingencyConstraintViolation.js";import c from"./ContingentValue.js";import p from"./ContingentValuesResult.js";import d from"./FieldGroup.js";import{isStringField as f,isDateField as y}from"./fieldUtils.js";import m from"./Subtype.js";var h;let g=h=class extends(i(s)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}get subtypeFieldName(){const{layer:e}=this;return"subtype-group"===e.type?e.subtypeField:e.typeIdField}static async createLoadedLayerContingentValuesCache(e){await e.load();const t=e.sourceJSON;if(void 0===e.layerId)return null;const n=t.hasContingentValuesDefinition;if(n)return new h({layer:e}).load();if(void 0===n){const t=a(e.url);if(null==t)return null;const n=t.url.path;if((await h._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await h._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names})));return new h({layer:e,fieldGroupDefinitions:t}).load()}}}return null}async load(e){const t=this.layer.load(e).then((()=>this._initializeContingentValues(this.fieldGroupDefinitions,e)));return this.addResolvingPromise(t),this}validateContingencyConstraints(e,t){const n=Object.keys(e),i=[],s=[];for(const r of this.fieldGroups){const o=r.isEditingRestrictive?"error":"warning";if(t&&!r.fields.some((e=>t.includes(e))))continue;if(!r.fields.every((e=>n.includes(e)))){s.push(new u({fieldGroup:r,type:o}));continue}let a=!1;const l=e[this.subtypeFieldName],c=r.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===l));for(const t of c){let n=!0;for(const i in t.values){const s=t.values[i];if("any"!==s.objectType)if("null"===s.objectType){if(null!=e[i]){n=!1;break}}else if("code"===s.objectType){if(e[i]!==s.codedValue.code){n=!1;break}}else if("range"===s.objectType){const t=e[i];if(t<s.minValue||t>s.maxValue){n=!1;break}}}if(n){a=!0;break}}a||i.push(new u({fieldGroup:r,type:o}))}return{invalid:i,incomplete:s}}getContingentValues(e,t,n=!1){const i=e[this.subtypeFieldName],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new c({objectType:"any"}));for(const l of a){let a=[];const u=l.contingencies.filter((e=>!(e.isRetired||e.subtype&&s&&e.subtype.code!==i)));let c=!1;const p={};for(const n of u){let i,s=!0;for(const r in n.values){const o=n.values[r];if(t!==r){if(void 0!==e[r]&&"any"!==o.objectType)if("null"===o.objectType)null!==e[r]&&(s=!1);else if("code"===o.objectType)e[r]!==o.codedValue.code&&(s=!1);else if("range"===o.objectType){const t=e[r];(t<o.minValue||t>o.maxValue)&&(s=!1)}}else i=o,c=c||"range"===o.objectType}if(i&&s){if("any"===i.objectType){a.length=0,a.push(i);break}const e=this._generateKey(i);p[e]||a.push(i),p[e]=!0}}c&&(a=this._joinRange(a)),r[l.name]=a,o=n?this._filterIntersection(o,a):[]}return 1===a.length&&n&&(o=[]),new p({contingentValuesAllGroups:o,contingentValuesByFieldGroup:r})}_generateKey(e){switch(e.objectType){case"any":return"@any@";case"null":return"@null@";case"code":return e.codedValue.name+e.codedValue.code.toString();case"range":return e.minValue.toString()+"-"+e.maxValue.toString()}}_joinRange(e){let t,n;e.sort(((e,t)=>"null"===e.objectType?-1:"null"===t.objectType?1:e.minValue-t.minValue));const i=[];for(const s of e)"null"!==s.objectType?null!=t&&null!=n?n<s.minValue?(i.push(new c({objectType:"range",minValue:t,maxValue:n})),t=s.minValue,n=s.maxValue):n<s.maxValue&&(n=s.maxValue):(t=s.minValue,n=s.maxValue):i.push(s);return i.push(new c({objectType:"range",minValue:t,maxValue:n})),i}_filterIntersection(e,t){if(0===e.length||0===t.length)return[];if("any"===e[0].objectType)return t;if("any"===t[0].objectType)return e;const n="range"===e[0].objectType||"range"===e[1]?.objectType,i="range"===t[0].objectType||"range"===t[1]?.objectType;return n||i?this._intersectRanges(e,t):this._intersectValues(e,t)}_intersectRanges(e,t){const n=[];let i,s=0;for(const r of e)for(;s<t.length;s++){const e=t[s];if("null"===r.objectType&&"null"===e.objectType)n.push(new c({objectType:"null"}));else{if("null"===r.objectType)break;if("null"===e.objectType)continue}if(r.maxValue<e.minValue)break;if(r.maxValue===e.minValue){n.push(new c({objectType:"range",minValue:r.maxValue,maxValue:e.minValue}));break}if(!(r.minValue>e.maxValue))if(r.minValue!==e.maxValue){if(i=r.minValue>e.minValue?r.minValue:e.minValue,r.maxValue<e.maxValue){n.push(new c({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new c({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new c({objectType:"range",minValue:r.minValue,maxValue:e.maxValue}))}return n}_intersectValues(e,t){const n=[];for(const i of e)t.some((e=>{if(i.objectType===e.objectType)switch(i.objectType){case"any":case"null":return!0;case"code":return i.codedValue.code===e.codedValue.code&&i.codedValue.name===e.codedValue.name}return!1}))&&n.push(i);return n}static async _staticFetchEnterpriseFeatureRoot(e,n){return t(e,{responseType:"json",query:{f:"json"},...n}).then((e=>e.data))}static async _staticFetchEnterpriseFieldGroup(e,n,i){return t(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.layerDataElements?.[0].dataElement.fieldGroups))}async _initializeContingentValues(e,t){const n=e??await this._fetchFieldGroupDefs(t);if(0===n.length)return void(this.fieldGroups=[]);const i=await this._fetchContingentValues(n,t);this.fieldGroups=i}async _fetchFieldGroupDefs(e){if(void 0===this.layer.layerId)return[];const t=this.layer.sourceJSON,n=this.layer.layerId.toString(),i=a(this.layer.url).url.path;if(t.hasContingentValuesDefinition){return(await this._fetchAGOLFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.restrictive,fields:e.fields.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return void 0!==t.hasContingentValuesDefinition?[]:this._fetchEnterpriseFeatureRoot(i,e).then((async t=>{if(t.supportsQueryDataElements){return(await this._fetchEnterpriseFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return[]}))}async _fetchAGOLFieldGroup(e,n,i){return t(`${e}/${n}/fieldgroups`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data.fieldGroups))}async _fetchEnterpriseFieldGroup(e,t,n){return h._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return h._staticFetchEnterpriseFeatureRoot(e,t)}async _fetchContingentValues(e,t){if(void 0===this.layer.layerId)return[];const n=this.layer.sourceJSON,i=this.layer.layerId.toString(),s=a(this.layer.url).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const r=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,r)}_constructFieldGroupsAGOL(e,t){return e.map((e=>{const n=t.contingentValuesDefinition.fieldGroups.find((t=>t.name===e.name));if(n){let i=[];return i=t.contingentValuesDefinition.hasSubType?this._parseAGOLFieldGroupSubtype(e,t,n.subTypes):this._parseAGOLFieldGroup(e,t,n.contingentValues),new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}_parseAGOLFieldGroupSubtype(e,t,n){let i=[];return n?.forEach((n=>{const s=this._getSubtypeAGOL(n.name);i=i.concat(this._parseAGOLFieldGroup(e,t,n.contingentValues,s))})),i}_parseAGOLFieldGroup(e,t,n,i=null){const s=[];for(const r of n??[]){const n=this._parseAGOLContingency(r,e,t,i);s.push(n)}return s}_parseAGOLContingency(e,t,n,i){const s=e.id,r=!!e.retired&&1===e.retired,o={};for(let a=0,l=0;a<t.fields.length;a++){const s=t.fields[a],r=n.typeCodes[e.types[a]];if("Code"===r){let t=e.values[l];l++;const r=this._getDomain(i,s),a=this.layer.getField(s);if("string"===a?.type){const e=n.stringDicts.find((e=>e.domain===r.name));e&&(t=e.entries[t])}const u=r.codedValues.find((e=>e.code===t)),p=new c({codedValue:u,objectType:"code"});o[s]=p}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new c({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new c({objectType:"any"});o[s]=e}else{const e=new c({objectType:"null"});o[s]=e}}return new l({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const i=t.fieldGroups;return e.map((e=>{const n=i.find((t=>t.name===e.name));if(n){const i=n.contingencies.map((n=>{const i=n.id,s=n.isRetired||!1,r=this._getSubtypeEnterprise(n.subtypeCode),o={};for(let a=0;a<e.fields.length;a++){const i=e.fields[a];let s=n.values[a];if("number"==typeof s||"string"==typeof s){const e=this._getDomain(r,i),n=this.layer.getField(i);if(f(n))s=t.stringDictionary[s];else if(y(n)){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e.codedValues.find((e=>e.code===s)),l=new c({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new c({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new c({objectType:"any"});o[i]=e}else{const e=new c({objectType:"null"});o[i]=e}}return new l({id:i,isRetired:s,subtype:r,values:o})}));return new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}async _fetchEnterpriseContingentValues(e,n,i){return t(`${e}/queryContingentValues`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.contingentValueSets?.[0]))}async _fetchAGOLContingentValues(e,n,i){return t(`${e}/${n}/contingentValues`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data))}_getSubtypeEnterprise(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.code===e));n=m.fromJSON(i)}return n||null}_getSubtypeAGOL(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.name===e));n=m.fromJSON(i)}return n||null}_getDomain(e,t){const n=e?e.domains?.[t]:this.layer.getFieldDomain(t);return"inherited"===n?.type?this.layer.getFieldDomain(t):n}};e([r({constructOnly:!0})],g.prototype,"layer",void 0),e([r({constructOnly:!0})],g.prototype,"request",void 0),e([r({type:[d]})],g.prototype,"fieldGroups",void 0),e([r({constructOnly:!0})],g.prototype,"fieldGroupDefinitions",void 0),e([r()],g.prototype,"subtypeFieldName",null),g=h=e([o("esri.layers.support.LayerContingentValuesCache")],g);const V=g;export{V as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{isSome as n}from"../../core/arrayUtils.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import s from"../../core/Loadable.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{parse as a}from"./arcgisLayerUrl.js";import l from"./Contingency.js";import u from"./ContingencyConstraintViolation.js";import c from"./ContingentValue.js";import p from"./ContingentValuesResult.js";import d from"./FieldGroup.js";import{isStringField as f,isDateField as y}from"./fieldUtils.js";import m from"./Subtype.js";var h;let g=h=class extends(i(s)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}get subtypeFieldName(){const{layer:e}=this;return"subtype-group"===e.type?e.subtypeField:e.typeIdField}static async createLoadedLayerContingentValuesCache(e){await e.load();const t=e.sourceJSON;if(void 0===e.layerId)return null;const n=t.hasContingentValuesDefinition;if(n)return new h({layer:e}).load();if(void 0===n){const t=a(e.url);if(null==t)return null;const n=t.url.path;if((await h._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await h._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names})));return new h({layer:e,fieldGroupDefinitions:t}).load()}}}return null}async load(e){const t=this.layer.load(e).then((()=>this._initializeContingentValues(this.fieldGroupDefinitions,e)));return this.addResolvingPromise(t),this}validateContingencyConstraints(e,t){const n=Object.keys(e),i=[],s=[];for(const r of this.fieldGroups){const o=r.isEditingRestrictive?"error":"warning";if(t&&!r.fields.some((e=>t.includes(e))))continue;if(!r.fields.every((e=>n.includes(e)))){s.push(new u({fieldGroup:r,type:o}));continue}let a=!1;const l=e[this.subtypeFieldName],c=r.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===l));for(const t of c){let n=!0;for(const i in t.values){const s=t.values[i];if("any"!==s.objectType)if("null"===s.objectType){if(null!=e[i]){n=!1;break}}else if("code"===s.objectType){if(e[i]!==s.codedValue.code){n=!1;break}}else if("range"===s.objectType){const t=e[i];if(t<s.minValue||t>s.maxValue){n=!1;break}}}if(n){a=!0;break}}a||i.push(new u({fieldGroup:r,type:o}))}return{invalid:i,incomplete:s}}getContingentValues(e,t,n=!1){const i=e[this.subtypeFieldName],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new c({objectType:"any"}));for(const l of a){let a=[];const u=l.contingencies.filter((e=>!(e.isRetired||e.subtype&&s&&e.subtype.code!==i)));let c=!1;const p={};for(const n of u){let i,s=!0;for(const r in n.values){const o=n.values[r];if(t!==r){if(void 0!==e[r]&&"any"!==o.objectType)if("null"===o.objectType)null!==e[r]&&(s=!1);else if("code"===o.objectType)e[r]!==o.codedValue.code&&(s=!1);else if("range"===o.objectType){const t=e[r];(t<o.minValue||t>o.maxValue)&&(s=!1)}}else i=o,c=c||"range"===o.objectType}if(i&&s){if("any"===i.objectType){a.length=0,a.push(i);break}const e=this._generateKey(i);p[e]||a.push(i),p[e]=!0}}c&&(a=this._joinRange(a)),r[l.name]=a,o=n?this._filterIntersection(o,a):[]}return 1===a.length&&n&&(o=[]),new p({contingentValuesAllGroups:o,contingentValuesByFieldGroup:r})}_generateKey(e){switch(e.objectType){case"any":return"@any@";case"null":return"@null@";case"code":return e.codedValue.name+e.codedValue.code.toString();case"range":return e.minValue.toString()+"-"+e.maxValue.toString()}}_joinRange(e){let t,n;e.sort(((e,t)=>"null"===e.objectType?-1:"null"===t.objectType?1:e.minValue-t.minValue));const i=[];for(const s of e)"null"!==s.objectType?null!=t&&null!=n?n<s.minValue?(i.push(new c({objectType:"range",minValue:t,maxValue:n})),t=s.minValue,n=s.maxValue):n<s.maxValue&&(n=s.maxValue):(t=s.minValue,n=s.maxValue):i.push(s);return i.push(new c({objectType:"range",minValue:t,maxValue:n})),i}_filterIntersection(e,t){if(0===e.length||0===t.length)return[];if("any"===e[0].objectType)return t;if("any"===t[0].objectType)return e;const n="range"===e[0].objectType||"range"===e[1]?.objectType,i="range"===t[0].objectType||"range"===t[1]?.objectType;return n||i?this._intersectRanges(e,t):this._intersectValues(e,t)}_intersectRanges(e,t){const n=[];let i,s=0;for(const r of e)for(;s<t.length;s++){const e=t[s];if("null"===r.objectType&&"null"===e.objectType)n.push(new c({objectType:"null"}));else{if("null"===r.objectType)break;if("null"===e.objectType)continue}if(r.maxValue<e.minValue)break;if(r.maxValue===e.minValue){n.push(new c({objectType:"range",minValue:r.maxValue,maxValue:e.minValue}));break}if(!(r.minValue>e.maxValue))if(r.minValue!==e.maxValue){if(i=r.minValue>e.minValue?r.minValue:e.minValue,r.maxValue<e.maxValue){n.push(new c({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new c({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new c({objectType:"range",minValue:r.minValue,maxValue:e.maxValue}))}return n}_intersectValues(e,t){const n=[];for(const i of e)t.some((e=>{if(i.objectType===e.objectType)switch(i.objectType){case"any":case"null":return!0;case"code":return i.codedValue.code===e.codedValue.code&&i.codedValue.name===e.codedValue.name}return!1}))&&n.push(i);return n}static async _staticFetchEnterpriseFeatureRoot(e,n){return t(e,{responseType:"json",query:{f:"json"},...n}).then((e=>e.data))}static async _staticFetchEnterpriseFieldGroup(e,n,i){return t(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.layerDataElements?.[0].dataElement.fieldGroups))}async _initializeContingentValues(e,t){const n=e??await this._fetchFieldGroupDefs(t);if(0===n.length)return void(this.fieldGroups=[]);const i=await this._fetchContingentValues(n,t);this.fieldGroups=i}async _fetchFieldGroupDefs(e){if(void 0===this.layer.layerId)return[];const t=this.layer.sourceJSON,n=this.layer.layerId.toString(),i=a(this.layer.url).url.path;if(t.hasContingentValuesDefinition){return(await this._fetchAGOLFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.restrictive,fields:e.fields.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return void 0!==t.hasContingentValuesDefinition?[]:this._fetchEnterpriseFeatureRoot(i,e).then((async t=>{if(t.supportsQueryDataElements){return(await this._fetchEnterpriseFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return[]}))}async _fetchAGOLFieldGroup(e,n,i){return t(`${e}/${n}/fieldgroups`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data.fieldGroups))}async _fetchEnterpriseFieldGroup(e,t,n){return h._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return h._staticFetchEnterpriseFeatureRoot(e,t)}async _fetchContingentValues(e,t){if(void 0===this.layer.layerId)return[];const n=this.layer.sourceJSON,i=this.layer.layerId.toString(),s=a(this.layer.url).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const r=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,r)}_constructFieldGroupsAGOL(e,t){return e.map((e=>{const n=t.contingentValuesDefinition.fieldGroups.find((t=>t.name===e.name));if(n){let i=[];return i=t.contingentValuesDefinition.hasSubType?this._parseAGOLFieldGroupSubtype(e,t,n.subTypes):this._parseAGOLFieldGroup(e,t,n.contingentValues),new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}_parseAGOLFieldGroupSubtype(e,t,n){let i=[];return n?.forEach((n=>{const s=this._getSubtypeAGOL(n.name);i=i.concat(this._parseAGOLFieldGroup(e,t,n.contingentValues,s))})),i}_parseAGOLFieldGroup(e,t,n,i=null){const s=[];for(const r of n??[]){const n=this._parseAGOLContingency(r,e,t,i);s.push(n)}return s}_parseAGOLContingency(e,t,n,i){const s=e.id,r=!!e.retired&&1===e.retired,o={};for(let a=0,l=0;a<t.fields.length;a++){const s=t.fields[a],r=n.typeCodes[e.types[a]];if("Code"===r){let t=e.values[l];l++;const r=this._getDomain(i,s),a=this.layer.getField(s);if("string"===a?.type){const e=n.stringDicts.find((e=>e.domain===r?.name));e&&(t=e.entries[t])}const u=r?.codedValues.find((e=>e.code===t)),p=new c({codedValue:u,objectType:"code"});o[s]=p}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new c({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new c({objectType:"any"});o[s]=e}else{const e=new c({objectType:"null"});o[s]=e}}return new l({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const i=t.fieldGroups;return e.map((e=>{const n=i.find((t=>t.name===e.name));if(n){const i=n.contingencies.map((n=>{const i=n.id,s=n.isRetired||!1,r=this._getSubtypeEnterprise(n.subtypeCode),o={};for(let a=0;a<e.fields.length;a++){const i=e.fields[a];let s=n.values[a];if("number"==typeof s||"string"==typeof s){const e=this._getDomain(r,i),n=this.layer.getField(i);if(f(n))s=t.stringDictionary[s];else if(y(n)){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e?.codedValues.find((e=>e.code===s)),l=new c({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new c({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new c({objectType:"any"});o[i]=e}else{const e=new c({objectType:"null"});o[i]=e}}return new l({id:i,isRetired:s,subtype:r,values:o})}));return new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}async _fetchEnterpriseContingentValues(e,n,i){return t(`${e}/queryContingentValues`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.contingentValueSets?.[0]))}async _fetchAGOLContingentValues(e,n,i){return t(`${e}/${n}/contingentValues`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data))}_getSubtypeEnterprise(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.code===e));n=m.fromJSON(i)}return n||null}_getSubtypeAGOL(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.name===e));n=m.fromJSON(i)}return n||null}_findDomainByFieldName(e,t){const n=e.domains;if(n){const[e,i]=Object.entries(n).find((([e])=>e.trim().toLowerCase()===t.trim().toLowerCase()))||[];return i||null}return null}_getDomain(e,t){const n=e?this._findDomainByFieldName(e,t):this.layer.getFieldDomain(t);return"inherited"===n?.type?this.layer.getFieldDomain(t):n}};e([r({constructOnly:!0})],g.prototype,"layer",void 0),e([r({constructOnly:!0})],g.prototype,"request",void 0),e([r({type:[d]})],g.prototype,"fieldGroups",void 0),e([r({constructOnly:!0})],g.prototype,"fieldGroupDefinitions",void 0),e([r()],g.prototype,"subtypeFieldName",null),g=h=e([o("esri.layers.support.LayerContingentValuesCache")],g);const V=g;export{V as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as t,webSceneRendererTypes as i}from"../../renderers/support/types.js";import o from"../../request.js";import{isSymbol3D as s}from"../../symbols.js";import a from"../../core/Collection.js";import l from"../../core/Error.js";import has from"../../core/has.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import{clone as p}from"../../core/lang.js";import y from"../../core/Loadable.js";import d from"../../core/Logger.js";import{MultiOriginJSONMixin as u}from"../../core/MultiOriginJSONSupport.js";import{sqlAnd as c}from"../../core/sql.js";import{objectToQuery as f}from"../../core/urlUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as h}from"../../core/accessorSupport/decorators/cast.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";import{ensureInteger as I,ensureType as w,Integer as v,ensureClass as j}from"../../core/accessorSupport/ensureType.js";import{OriginId as L,nameToId as D}from"../../core/accessorSupport/PropertyOrigin.js";import{getProperties as E}from"../../core/accessorSupport/utils.js";import x from"../graphics/sources/support/QueryTask.js";import F from"./FeatureType.js";import P from"./Field.js";import O from"./FieldsIndex.js";import T from"./LabelClass.js";import{validateLabelingInfo as _}from"./labelingInfo.js";import A from"./LayerFloorInfo.js";import{getFeatureLayerCapabilities as V}from"./serviceCapabilitiesUtils.js";import{DataLayerSource as M}from"./source/DataLayerSource.js";import{MapLayerSource as N}from"./source/MapLayerSource.js";import q from"../../rest/support/AttachmentQuery.js";import R from"../../rest/support/Query.js";import{createPopupTemplate as U}from"../../support/popupUtils.js";import k from"../../geometry/Extent.js";import{featureGeometryTypeKebabDictionary as C}from"../../geometry/support/typeUtils.js";var Q;function B(e){return null!=e&&"esriSMS"===e.type}function J(e,r,t){const i=this.originIdOf(r)>=D(t.origin);return{ignoreOrigin:!0,allowNull:i,enabled:!!t&&("map-image"===t.layer?.type&&(t.writeSublayerStructure||i))}}function $(e,r,t){return{enabled:!!t&&("tile"===t.layer?.type&&(t.origin&&this.originIdOf(r)>=D(t.origin)||this._isOverridden(r)))}}function G(e,r,t){return{ignoreOrigin:!0,enabled:t&&t.writeSublayerStructure||!1}}function H(e,r,t){return{ignoreOrigin:!0,enabled:!!t&&(t.writeSublayerStructure||this.originIdOf(r)>=D(t.origin))}}let z=0;const K=new Set;K.add("layer"),K.add("parent"),K.add("loaded"),K.add("loadStatus"),K.add("loadError"),K.add("loadWarnings");let W=Q=class extends(u(n(y))){constructor(e){super(e),this.capabilities=void 0,this.maxScaleRange={minScale:0,maxScale:0},this.fields=null,this.fullExtent=null,this.geometryType=null,this.globalIdField=null,this.legendEnabled=!0,this.objectIdField=null,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.sourceJSON=null,this.title=null,this.typeIdField=null,this.type="sublayer",this.types=null,this._lastParsedUrl=null}async load(e){return this.addResolvingPromise((async()=>{const{layer:r,url:t}=this;if(!r&&!t)throw new l("sublayer:missing-layer","Sublayer can't be loaded without being part of a layer",{sublayer:this});const i=r?await r.fetchSublayerInfo(this,e):(await o(t,{responseType:"json",query:{f:"json"},...e})).data;i&&(this.sourceJSON=i,this.read({layerDefinition:i},{origin:"service"}))})()),this}readCapabilities(e,r){r=r.layerDefinition||r;const{operations:{supportsQuery:t,supportsQueryAttachments:i},query:{supportsFormatPBF:o},data:{supportsAttachment:s}}=V(r,this.url);return{exportMap:{supportsModification:!!r.canModifyLayer},operations:{supportsQuery:t,supportsQueryAttachments:i},data:{supportsAttachment:s},query:{supportsFormatPBF:o}}}get defaultPopupTemplate(){return this.createPopupTemplate()}set definitionExpression(e){this._setAndNotifyLayer("definitionExpression",e)}get effectiveScaleRange(){const{minScale:e,maxScale:r}=this;return{minScale:e,maxScale:r}}readMaxScaleRange(e,r){return{minScale:r.minScale??0,maxScale:r.maxScale??0}}get fieldsIndex(){return new O(this.fields||[])}set floorInfo(e){this._setAndNotifyLayer("floorInfo",e)}readGlobalIdFieldFromService(e,r){if((r=r.layerDefinition||r).globalIdField)return r.globalIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeGlobalID"===t.type)return t.name}get id(){const e=this._get("id");return e??z++}set id(e){this._get("id")!==e&&(!1!==this.layer?.capabilities?.exportMap?.supportsDynamicLayers?this._set("id",e):this._logLockedError("id","capability not available 'layer.capabilities.exportMap.supportsDynamicLayers'"))}set labelingInfo(e){this._setAndNotifyLayer("labelingInfo",e)}writeLabelingInfo(e,r,t,i){e&&e.length&&(r.layerDefinition={drawingInfo:{labelingInfo:e.map((e=>e.write({},i)))}})}set labelsVisible(e){this._setAndNotifyLayer("labelsVisible",e)}set layer(e){this._set("layer",e),this.sublayers&&this.sublayers.forEach((r=>r.layer=e))}set listMode(e){this._set("listMode",e)}set minScale(e){this._setAndNotifyLayer("minScale",e)}readMinScale(e,r){return r.minScale||r.layerDefinition?.minScale||0}set maxScale(e){this._setAndNotifyLayer("maxScale",e)}readMaxScale(e,r){return r.maxScale||r.layerDefinition?.maxScale||0}readObjectIdFieldFromService(e,r){if((r=r.layerDefinition||r).objectIdField)return r.objectIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeOID"===t.type)return t.name}set opacity(e){this._setAndNotifyLayer("opacity",e)}readOpacity(e,r){const t=r.layerDefinition;return 1-.01*((null!=t?.transparency?t.transparency:t?.drawingInfo?.transparency)??0)}writeOpacity(e,r,t,i){r.layerDefinition={drawingInfo:{transparency:100-100*e}}}writeParent(e,r){this.parent&&this.parent!==this.layer?r.parentLayerId=I(this.parent.id):r.parentLayerId=-1}get queryTask(){if(!this.layer)return null;const{spatialReference:e}=this.layer,r="gdbVersion"in this.layer?this.layer.gdbVersion:void 0,{capabilities:t,fieldsIndex:i}=this,o=has("featurelayer-pbf")&&t?.query.supportsFormatPBF,s=t?.operations?.supportsQueryAttachments??!1;return new x({url:this.url,pbfSupported:o,fieldsIndex:i,gdbVersion:r,sourceSpatialReference:e,queryAttachmentsSupported:s})}set renderer(e){if(e)for(const r of e.getSymbols())if(s(r)){d.getLogger(this).warn("Sublayer renderer should use 2D symbols");break}this._setAndNotifyLayer("renderer",e)}get source(){return this._get("source")||new N({mapLayerId:this.id})}set source(e){this._setAndNotifyLayer("source",e)}set sublayers(e){this._handleSublayersChange(e,this._get("sublayers")),this._set("sublayers",e)}castSublayers(e){return w(a.ofType(Q),e)}writeSublayers(e,r,t){this.sublayers?.length&&(r[t]=this.sublayers.map((e=>e.id)).toArray().reverse())}readTypeIdField(e,r){let t=(r=r.layerDefinition||r).typeIdField;if(t&&r.fields){t=t.toLowerCase();const e=r.fields.find((e=>e.name.toLowerCase()===t));e&&(t=e.name)}return t}get url(){const e=this.layer?.parsedUrl??this._lastParsedUrl,r=this.source;if(!e)return null;if(this._lastParsedUrl=e,"map-layer"===r?.type)return`${e.path}/${r.mapLayerId}`;const t={layer:JSON.stringify({source:this.source})};return`${e.path}/dynamicLayer?${f(t)}`}set url(e){this._overrideIfSome("url",e)}set visible(e){this._setAndNotifyLayer("visible",e)}writeVisible(e,r,t,i){r[t]=this.getAtOrigin("defaultVisibility","service")||e}clone(){const{store:e}=E(this),r=new Q;return E(r).store=e.clone(K),this.commitProperty("url"),r._lastParsedUrl=this._lastParsedUrl,r}createPopupTemplate(e){return U(this,e)}createQuery(){return new R({returnGeometry:!0,where:this.definitionExpression||"1=1"})}async createFeatureLayer(){if(this.hasOwnProperty("sublayers"))return null;const{layer:e}=this,r=e?.parsedUrl,t=new(0,(await import("../FeatureLayer.js")).default)({url:r?.path});return r&&this.source&&("map-layer"===this.source.type?t.layerId=this.source.mapLayerId:t.dynamicDataSource=this.source),null!=e?.refreshInterval&&(t.refreshInterval=e.refreshInterval),this.definitionExpression&&(t.definitionExpression=this.definitionExpression),this.floorInfo&&(t.floorInfo=p(this.floorInfo)),this.originIdOf("labelingInfo")>L.SERVICE&&(t.labelingInfo=p(this.labelingInfo)),this.originIdOf("labelsVisible")>L.DEFAULTS&&(t.labelsVisible=this.labelsVisible),this.originIdOf("legendEnabled")>L.DEFAULTS&&(t.legendEnabled=this.legendEnabled),this.originIdOf("visible")>L.DEFAULTS&&(t.visible=this.visible),this.originIdOf("minScale")>L.DEFAULTS&&(t.minScale=this.minScale),this.originIdOf("maxScale")>L.DEFAULTS&&(t.maxScale=this.maxScale),this.originIdOf("opacity")>L.DEFAULTS&&(t.opacity=this.opacity),this.originIdOf("popupTemplate")>L.DEFAULTS&&(t.popupTemplate=p(this.popupTemplate)),this.originIdOf("renderer")>L.SERVICE&&(t.renderer=p(this.renderer)),"data-layer"===this.source?.type&&(t.dynamicDataSource=this.source.clone()),this.originIdOf("title")>L.DEFAULTS&&(t.title=this.title),"map-image"===e?.type&&e.originIdOf("customParameters")>L.DEFAULTS&&(t.customParameters=e.customParameters),"tile"===e?.type&&e.originIdOf("customParameters")>L.DEFAULTS&&(t.customParameters=e.customParameters),t}getField(e){return this.fieldsIndex.get(e)}getFeatureType(e){const{typeIdField:r,types:t}=this;if(!r||!e)return null;const i=e.attributes?e.attributes[r]:void 0;if(null==i)return null;let o=null;return t?.some((e=>{const{id:r}=e;return null!=r&&(r.toString()===i.toString()&&(o=e),!!o)})),o}getFieldDomain(e,r){const t=r?.feature,i=this.getFeatureType(t);if(i){const r=i.domains&&i.domains[e];if(r&&"inherited"!==r.type)return r}return this._getLayerDomain(e)}async queryAttachments(e,r){await this.load(),e=q.from(e);const t=this.capabilities;if(!t?.data?.supportsAttachment)throw new l("queryAttachments:not-supported","this layer doesn't support attachments");const{attachmentTypes:i,objectIds:o,globalIds:s,num:a,size:n,start:p,where:y}=e;if(!t?.operations?.supportsQueryAttachments){if(i?.length>0||s?.length>0||n?.length>0||a||p||y)throw new l("queryAttachments:option-not-supported","when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",e)}if(!(o?.length||s?.length||y))throw new l("queryAttachments:invalid-query","'objectIds', 'globalIds', or 'where' are required to perform attachment query",e);return this.queryTask.executeAttachmentQuery(e,r)}async queryFeatures(e=this.createQuery(),r){if(await this.load(),!this.capabilities.operations.supportsQuery)throw new l("queryFeatures:not-supported","this layer doesn't support queries.");if(!this.url)throw new l("queryFeatures:not-supported","this layer has no url.");const t=await this.queryTask.execute(e,{...r,query:{...this.layer?.customParameters,token:this.layer?.apiKey}});if(t?.features)for(const i of t.features)i.sourceLayer=this;return t}toExportImageJSON(e){const r={id:this.id,source:this.source?.toJSON()||{mapLayerId:this.id,type:"mapLayer"}},t=c(e,this.definitionExpression);null!=t&&(r.definitionExpression=t);const i=["renderer","labelingInfo","opacity","labelsVisible"].reduce(((e,r)=>(e[r]=this.originIdOf(r),e)),{}),o=Object.keys(i).some((e=>i[e]>L.SERVICE));if(o){const e=r.drawingInfo={};if(i.renderer>L.SERVICE&&(e.renderer=this.renderer?this.renderer.toJSON():null),i.labelsVisible>L.SERVICE&&(e.showLabels=this.labelsVisible),this.labelsVisible&&i.labelingInfo>L.SERVICE)if(this.labelingInfo){!this.loaded&&this.labelingInfo?.some((e=>!e.labelPlacement))&&d.getLogger(this).warnOnce(`A Sublayer (title: ${this.title}, id: ${this.id}) has an undefined 'labelPlacement' and so labels cannot be displayed. Either define a valid 'labelPlacement' or call Sublayer.load() to use a default value based on geometry type.`,{sublayer:this});let r=this.labelingInfo;null!=this.geometryType&&(r=_(this.labelingInfo,C.toJSON(this.geometryType))),e.showLabels=!0,e.labelingInfo=r.filter((e=>e.labelPlacement)).map((e=>e.toJSON({origin:"service",layer:this.layer})))}else e.showLabels=!1;i.opacity>L.SERVICE&&(e.transparency=100-100*this.opacity),this._assignDefaultSymbolColors(e.renderer)}return r}_assignDefaultSymbolColors(e){this._forEachSimpleMarkerSymbols(e,(e=>{e.color||"esriSMSX"!==e.style&&"esriSMSCross"!==e.style||(e.outline?.color?e.color=e.outline.color:e.color=[0,0,0,0])}))}_forEachSimpleMarkerSymbols(e,r){if(e){const t=("uniqueValueInfos"in e?e.uniqueValueInfos:"classBreakInfos"in e?e.classBreakInfos:null)??[];for(const e of t)B(e.symbol)&&r(e.symbol);"symbol"in e&&B(e.symbol)&&r(e.symbol),"defaultSymbol"in e&&B(e.defaultSymbol)&&r(e.defaultSymbol)}}_setAndNotifyLayer(e,r){const t=this.layer,i=this._get(e);let o,s;switch(e){case"definitionExpression":case"floorInfo":o="supportsSublayerDefinitionExpression";break;case"minScale":case"maxScale":case"visible":o="supportsSublayerVisibility";break;case"labelingInfo":case"labelsVisible":case"opacity":case"renderer":case"source":o="supportsDynamicLayers",s="supportsModification"}const a=E(this).getDefaultOrigin();if("service"!==a){if(o&&!1===this.layer?.capabilities?.exportMap?.[o])return void this._logLockedError(e,`capability not available 'layer.capabilities.exportMap.${o}'`);if(s&&!1===this.capabilities?.exportMap[s])return void this._logLockedError(e,`capability not available 'capabilities.exportMap.${s}'`)}"source"!==e||"not-loaded"===this.loadStatus?(this._set(e,r),"service"!==a&&i!==r&&t&&t.emit&&t.emit("sublayer-update",{propertyName:e,target:this})):this._logLockedError(e,"'source' can't be changed after calling sublayer.load()")}_handleSublayersChange(e,r){r&&(r.forEach((e=>{e.parent=null,e.layer=null})),this.removeAllHandles()),e&&(e.forEach((e=>{e.parent=this,e.layer=this.layer})),this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this,e.layer=this.layer})),e.on("after-remove",(({item:e})=>{e.parent=null,e.layer=null})),e.on("before-changes",(e=>{const r=this.layer?.capabilities?.exportMap?.supportsSublayersChanges;null==r||r||(d.getLogger(this).error(new l("sublayer:sublayers-non-modifiable","Sublayer can't be added, moved, or removed from the layer's sublayers",{sublayer:this,layer:this.layer})),e.preventDefault())}))]))}_logLockedError(e,r){const{layer:t,declaredClass:i}=this;d.getLogger(i).error(new l("sublayer:locked",`Property '${String(e)}' can't be changed on Sublayer from the layer '${t?.id}'`,{reason:r,sublayer:this,layer:t}))}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}};W.test={isMapImageLayerOverridePolicy:e=>e===G||e===J,isTileImageLayerOverridePolicy:e=>e===$},e([m({readOnly:!0})],W.prototype,"capabilities",void 0),e([b("service","capabilities",["layerDefinition.canModifyLayer","layerDefinition.capabilities"])],W.prototype,"readCapabilities",null),e([m()],W.prototype,"defaultPopupTemplate",null),e([m({type:String,value:null,json:{name:"layerDefinition.definitionExpression",write:{allowNull:!0,overridePolicy:J}}})],W.prototype,"definitionExpression",null),e([m({readOnly:!0})],W.prototype,"effectiveScaleRange",null),e([b("service","maxScaleRange",["minScale","maxScale"])],W.prototype,"readMaxScaleRange",null),e([m({type:[P],json:{origins:{service:{read:{source:"layerDefinition.fields"}}}}})],W.prototype,"fields",void 0),e([m({readOnly:!0})],W.prototype,"fieldsIndex",null),e([m({type:A,value:null,json:{name:"layerDefinition.floorInfo",read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo",overridePolicy:J},origins:{"web-scene":{read:!1,write:!1}}}})],W.prototype,"floorInfo",null),e([m({type:k,json:{read:{source:"layerDefinition.extent"}}})],W.prototype,"fullExtent",void 0),e([m({type:C.apiValues,json:{origins:{service:{name:"layerDefinition.geometryType",read:{reader:C.read}}}}})],W.prototype,"geometryType",void 0),e([m({type:String})],W.prototype,"globalIdField",void 0),e([b("service","globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],W.prototype,"readGlobalIdFieldFromService",null),e([m({type:v,json:{write:{ignoreOrigin:!0}}})],W.prototype,"id",null),e([m({value:null,type:[T],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo"},write:{target:"layerDefinition.drawingInfo.labelingInfo",overridePolicy:G}}})],W.prototype,"labelingInfo",null),e([S("labelingInfo")],W.prototype,"writeLabelingInfo",null),e([m({type:Boolean,value:!0,json:{read:{source:"layerDefinition.drawingInfo.showLabels"},write:{target:"layerDefinition.drawingInfo.showLabels",overridePolicy:G}}})],W.prototype,"labelsVisible",null),e([m({value:null})],W.prototype,"layer",null),e([m({type:String,json:{write:{overridePolicy:$}}})],W.prototype,"layerItemId",void 0),e([m({type:Boolean,value:!0,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend",overridePolicy:H}}})],W.prototype,"legendEnabled",void 0),e([m({type:["show","hide","hide-children"],value:"show",json:{read:!1,write:!1,origins:{"web-scene":{read:!0,write:!0}}}})],W.prototype,"listMode",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"minScale",null),e([b("minScale",["minScale","layerDefinition.minScale"])],W.prototype,"readMinScale",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"maxScale",null),e([b("maxScale",["maxScale","layerDefinition.maxScale"])],W.prototype,"readMaxScale",null),e([m({type:String})],W.prototype,"objectIdField",void 0),e([b("service","objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],W.prototype,"readObjectIdFieldFromService",null),e([m({type:Number,value:1,json:{write:{target:"layerDefinition.drawingInfo.transparency",overridePolicy:G}}})],W.prototype,"opacity",null),e([b("opacity",["layerDefinition.drawingInfo.transparency","layerDefinition.transparency"])],W.prototype,"readOpacity",null),e([S("opacity")],W.prototype,"writeOpacity",null),e([m({json:{type:v,write:{target:"parentLayerId",writerEnsuresNonNull:!0,overridePolicy:G}}})],W.prototype,"parent",void 0),e([S("parent")],W.prototype,"writeParent",null),e([m({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy:H,writer(e,r,t){r[t]=!e}}}})],W.prototype,"popupEnabled",void 0),e([m({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy:H}}})],W.prototype,"popupTemplate",void 0),e([m({readOnly:!0})],W.prototype,"queryTask",null),e([m({types:t,value:null,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G},origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G}}}}})],W.prototype,"renderer",null),e([m({types:{key:"type",base:null,typeMap:{"data-layer":M,"map-layer":N}},cast(e){if(e){if("mapLayerId"in e)return j(N,e);if("dataSource"in e)return j(M,e)}return e},json:{name:"layerDefinition.source",write:{overridePolicy:G}}})],W.prototype,"source",null),e([m()],W.prototype,"sourceJSON",void 0),e([m({value:null,json:{type:[v],write:{target:"subLayerIds",allowNull:!0,overridePolicy:G}}})],W.prototype,"sublayers",null),e([h("sublayers")],W.prototype,"castSublayers",null),e([S("sublayers")],W.prototype,"writeSublayers",null),e([m({type:String,json:{name:"name",write:{overridePolicy:H}}})],W.prototype,"title",void 0),e([m({type:String})],W.prototype,"typeIdField",void 0),e([m({json:{read:!1},readOnly:!0,value:"sublayer"})],W.prototype,"type",void 0),e([b("typeIdField",["layerDefinition.typeIdField"])],W.prototype,"readTypeIdField",null),e([m({type:[F],json:{origins:{service:{read:{source:"layerDefinition.types"}}}}})],W.prototype,"types",void 0),e([m({type:String,json:{name:"layerUrl",write:{overridePolicy:$}}})],W.prototype,"url",null),e([m({type:Boolean,value:!0,json:{read:{source:"defaultVisibility"},write:{target:"defaultVisibility",overridePolicy:G}}})],W.prototype,"visible",null),e([S("visible")],W.prototype,"writeVisible",null),W=Q=e([g("esri.layers.support.Sublayer")],W);const X=W;export{X as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import r from"../../PopupTemplate.js";import"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import"../../renderers/Renderer.js";import"../../renderers/SimpleRenderer.js";import"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import{rendererTypes as t,webSceneRendererTypes as i}from"../../renderers/support/types.js";import o from"../../request.js";import{isSymbol3D as a}from"../../symbols.js";import s from"../../core/Collection.js";import l from"../../core/Error.js";import has from"../../core/has.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import{clone as p}from"../../core/lang.js";import y from"../../core/Loadable.js";import d from"../../core/Logger.js";import{MultiOriginJSONMixin as u}from"../../core/MultiOriginJSONSupport.js";import{sqlAnd as c}from"../../core/sql.js";import{objectToQuery as f}from"../../core/urlUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as h}from"../../core/accessorSupport/decorators/cast.js";import{reader as b}from"../../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";import{ensureInteger as I,ensureType as w,Integer as v,ensureClass as j}from"../../core/accessorSupport/ensureType.js";import{OriginId as L,nameToId as D}from"../../core/accessorSupport/PropertyOrigin.js";import{getProperties as E}from"../../core/accessorSupport/utils.js";import F from"../graphics/sources/support/QueryTask.js";import x from"./FeatureType.js";import P from"./Field.js";import O from"./FieldsIndex.js";import T from"./LabelClass.js";import{validateLabelingInfo as _}from"./labelingInfo.js";import A from"./LayerFloorInfo.js";import{getFeatureLayerCapabilities as V}from"./serviceCapabilitiesUtils.js";import{DataLayerSource as M}from"./source/DataLayerSource.js";import{MapLayerSource as N}from"./source/MapLayerSource.js";import q from"../../rest/support/AttachmentQuery.js";import C from"../../rest/support/Query.js";import{createPopupTemplate as R}from"../../support/popupUtils.js";import U from"../../geometry/Extent.js";import{featureGeometryTypeKebabDictionary as k}from"../../geometry/support/typeUtils.js";var Q;function B(e){return null!=e&&"esriSMS"===e.type}function J(e,r,t){const i=this.originIdOf(r)>=D(t.origin);return{ignoreOrigin:!0,allowNull:i,enabled:!!t&&("map-image"===t.layer?.type&&(t.writeSublayerStructure||i))}}function $(e,r,t){return{enabled:!!t&&("tile"===t.layer?.type&&(t.origin&&this.originIdOf(r)>=D(t.origin)||this._isOverridden(r)))}}function G(e,r,t){return{ignoreOrigin:!0,enabled:t&&t.writeSublayerStructure||!1}}function H(e,r,t){return{ignoreOrigin:!0,enabled:!!t&&(t.writeSublayerStructure||this.originIdOf(r)>=D(t.origin))}}let z=0;const K=new Set;K.add("layer"),K.add("parent"),K.add("loaded"),K.add("loadStatus"),K.add("loadError"),K.add("loadWarnings");let W=Q=class extends(u(n(y))){constructor(e){super(e),this.capabilities=void 0,this.maxScaleRange={minScale:0,maxScale:0},this.fields=null,this.fullExtent=null,this.geometryType=null,this.globalIdField=null,this.legendEnabled=!0,this.objectIdField=null,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.sourceJSON=null,this.title=null,this.typeIdField=null,this.type="sublayer",this.types=null,this._lastParsedUrl=null}async load(e){return this.addResolvingPromise((async()=>{const{layer:r,url:t}=this;if(!r&&!t)throw new l("sublayer:missing-layer","Sublayer can't be loaded without being part of a layer",{sublayer:this});const i=r?await r.fetchSublayerInfo(this,e):(await o(t,{responseType:"json",query:{f:"json"},...e})).data;i&&(this.sourceJSON=i,this.read({layerDefinition:i},{origin:"service"}))})()),this}readCapabilities(e,r){r=r.layerDefinition||r;const{operations:{supportsQuery:t,supportsQueryAttachments:i},query:{supportsFormatPBF:o},data:{supportsAttachment:a}}=V(r,this.url);return{exportMap:{supportsModification:!!r.canModifyLayer},operations:{supportsQuery:t,supportsQueryAttachments:i},data:{supportsAttachment:a},query:{supportsFormatPBF:o}}}get defaultPopupTemplate(){return this.createPopupTemplate()}set definitionExpression(e){this._setAndNotifyLayer("definitionExpression",e)}get effectiveScaleRange(){const{minScale:e,maxScale:r}=this;return{minScale:e,maxScale:r}}readMaxScaleRange(e,r){return{minScale:(r=r.layerDefinition||r).minScale??0,maxScale:r.maxScale??0}}get fieldsIndex(){return new O(this.fields||[])}set floorInfo(e){this._setAndNotifyLayer("floorInfo",e)}readGlobalIdFieldFromService(e,r){if((r=r.layerDefinition||r).globalIdField)return r.globalIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeGlobalID"===t.type)return t.name}get id(){const e=this._get("id");return e??z++}set id(e){this._get("id")!==e&&(!1!==this.layer?.capabilities?.exportMap?.supportsDynamicLayers?this._set("id",e):this._logLockedError("id","capability not available 'layer.capabilities.exportMap.supportsDynamicLayers'"))}set labelingInfo(e){this._setAndNotifyLayer("labelingInfo",e)}writeLabelingInfo(e,r,t,i){e&&e.length&&(r.layerDefinition={drawingInfo:{labelingInfo:e.map((e=>e.write({},i)))}})}set labelsVisible(e){this._setAndNotifyLayer("labelsVisible",e)}set layer(e){this._set("layer",e),this.sublayers&&this.sublayers.forEach((r=>r.layer=e))}set listMode(e){this._set("listMode",e)}set minScale(e){this._setAndNotifyLayer("minScale",e)}readMinScale(e,r){return r.minScale||r.layerDefinition?.minScale||0}set maxScale(e){this._setAndNotifyLayer("maxScale",e)}readMaxScale(e,r){return r.maxScale||r.layerDefinition?.maxScale||0}readObjectIdFieldFromService(e,r){if((r=r.layerDefinition||r).objectIdField)return r.objectIdField;if(r.fields)for(const t of r.fields)if("esriFieldTypeOID"===t.type)return t.name}set opacity(e){this._setAndNotifyLayer("opacity",e)}readOpacity(e,r){const t=r.layerDefinition;return 1-.01*((null!=t?.transparency?t.transparency:t?.drawingInfo?.transparency)??0)}writeOpacity(e,r,t,i){r.layerDefinition={drawingInfo:{transparency:100-100*e}}}writeParent(e,r){this.parent&&this.parent!==this.layer?r.parentLayerId=I(this.parent.id):r.parentLayerId=-1}get queryTask(){if(!this.layer)return null;const{spatialReference:e}=this.layer,r="gdbVersion"in this.layer?this.layer.gdbVersion:void 0,{capabilities:t,fieldsIndex:i}=this,o=has("featurelayer-pbf")&&t?.query.supportsFormatPBF,a=t?.operations?.supportsQueryAttachments??!1;return new F({url:this.url,pbfSupported:o,fieldsIndex:i,gdbVersion:r,sourceSpatialReference:e,queryAttachmentsSupported:a})}set renderer(e){if(e)for(const r of e.getSymbols())if(a(r)){d.getLogger(this).warn("Sublayer renderer should use 2D symbols");break}this._setAndNotifyLayer("renderer",e)}get source(){return this._get("source")||new N({mapLayerId:this.id})}set source(e){this._setAndNotifyLayer("source",e)}set sublayers(e){this._handleSublayersChange(e,this._get("sublayers")),this._set("sublayers",e)}castSublayers(e){return w(s.ofType(Q),e)}writeSublayers(e,r,t){this.sublayers?.length&&(r[t]=this.sublayers.map((e=>e.id)).toArray().reverse())}readTitle(e,r){return r.layerDefinition?.name??r.name}readTypeIdField(e,r){let t=(r=r.layerDefinition||r).typeIdField;if(t&&r.fields){t=t.toLowerCase();const e=r.fields.find((e=>e.name.toLowerCase()===t));e&&(t=e.name)}return t}get url(){const e=this.layer?.parsedUrl??this._lastParsedUrl,r=this.source;if(!e)return null;if(this._lastParsedUrl=e,"map-layer"===r?.type)return`${e.path}/${r.mapLayerId}`;const t={layer:JSON.stringify({source:this.source})};return`${e.path}/dynamicLayer?${f(t)}`}set url(e){this._overrideIfSome("url",e)}set visible(e){this._setAndNotifyLayer("visible",e)}writeVisible(e,r,t,i){r[t]=this.getAtOrigin("defaultVisibility","service")||e}clone(){const{store:e}=E(this),r=new Q;return E(r).store=e.clone(K),this.commitProperty("url"),r._lastParsedUrl=this._lastParsedUrl,r}createPopupTemplate(e){return R(this,e)}createQuery(){return new C({returnGeometry:!0,where:this.definitionExpression||"1=1"})}async createFeatureLayer(){if(this.hasOwnProperty("sublayers"))return null;const e=(await import("../FeatureLayer.js")).default,{layer:r,url:t}=this;let i;if(t&&this.originIdOf("url")>L.SERVICE)i=new e({url:t});else{if(!r?.parsedUrl)throw new l("createFeatureLayer:missing-information","Cannot create a FeatureLayer without a url or a parent layer");{const t=r.parsedUrl;i=new e({url:t.path}),t&&this.source&&("map-layer"===this.source.type?i.layerId=this.source.mapLayerId:i.dynamicDataSource=this.source)}}return null!=r?.refreshInterval&&(i.refreshInterval=r.refreshInterval),this.definitionExpression&&(i.definitionExpression=this.definitionExpression),this.floorInfo&&(i.floorInfo=p(this.floorInfo)),this.originIdOf("labelingInfo")>L.SERVICE&&(i.labelingInfo=p(this.labelingInfo)),this.originIdOf("labelsVisible")>L.DEFAULTS&&(i.labelsVisible=this.labelsVisible),this.originIdOf("legendEnabled")>L.DEFAULTS&&(i.legendEnabled=this.legendEnabled),this.originIdOf("visible")>L.DEFAULTS&&(i.visible=this.visible),this.originIdOf("minScale")>L.DEFAULTS&&(i.minScale=this.minScale),this.originIdOf("maxScale")>L.DEFAULTS&&(i.maxScale=this.maxScale),this.originIdOf("opacity")>L.DEFAULTS&&(i.opacity=this.opacity),this.originIdOf("popupTemplate")>L.DEFAULTS&&(i.popupTemplate=p(this.popupTemplate)),this.originIdOf("renderer")>L.SERVICE&&(i.renderer=p(this.renderer)),"data-layer"===this.source?.type&&(i.dynamicDataSource=this.source.clone()),this.originIdOf("title")>L.DEFAULTS&&(i.title=this.title),"map-image"===r?.type&&r.originIdOf("customParameters")>L.DEFAULTS&&(i.customParameters=r.customParameters),"tile"===r?.type&&r.originIdOf("customParameters")>L.DEFAULTS&&(i.customParameters=r.customParameters),i}getField(e){return this.fieldsIndex.get(e)}getFeatureType(e){const{typeIdField:r,types:t}=this;if(!r||!e)return null;const i=e.attributes?e.attributes[r]:void 0;if(null==i)return null;let o=null;return t?.some((e=>{const{id:r}=e;return null!=r&&(r.toString()===i.toString()&&(o=e),!!o)})),o}getFieldDomain(e,r){const t=r?.feature,i=this.getFeatureType(t);if(i){const r=i.domains&&i.domains[e];if(r&&"inherited"!==r.type)return r}return this._getLayerDomain(e)}async queryAttachments(e,r){await this.load(),e=q.from(e);const t=this.capabilities;if(!t?.data?.supportsAttachment)throw new l("queryAttachments:not-supported","this layer doesn't support attachments");const{attachmentTypes:i,objectIds:o,globalIds:a,num:s,size:n,start:p,where:y}=e;if(!t?.operations?.supportsQueryAttachments){if(i?.length>0||a?.length>0||n?.length>0||s||p||y)throw new l("queryAttachments:option-not-supported","when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",e)}if(!(o?.length||a?.length||y))throw new l("queryAttachments:invalid-query","'objectIds', 'globalIds', or 'where' are required to perform attachment query",e);return this.queryTask.executeAttachmentQuery(e,r)}async queryFeatures(e=this.createQuery(),r){if(await this.load(),!this.capabilities.operations.supportsQuery)throw new l("queryFeatures:not-supported","this layer doesn't support queries.");if(!this.url)throw new l("queryFeatures:not-supported","this layer has no url.");const t=await this.queryTask.execute(e,{...r,query:{...this.layer?.customParameters,token:this.layer?.apiKey}});if(t?.features)for(const i of t.features)i.sourceLayer=this;return t}toExportImageJSON(e){const r={id:this.id,source:this.source?.toJSON()||{mapLayerId:this.id,type:"mapLayer"}},t=c(e,this.definitionExpression);null!=t&&(r.definitionExpression=t);const i=["renderer","labelingInfo","opacity","labelsVisible"].reduce(((e,r)=>(e[r]=this.originIdOf(r),e)),{}),o=Object.keys(i).some((e=>i[e]>L.SERVICE));if(o){const e=r.drawingInfo={};if(i.renderer>L.SERVICE&&(e.renderer=this.renderer?this.renderer.toJSON():null),i.labelsVisible>L.SERVICE&&(e.showLabels=this.labelsVisible),this.labelsVisible&&i.labelingInfo>L.SERVICE)if(this.labelingInfo){!this.loaded&&this.labelingInfo?.some((e=>!e.labelPlacement))&&d.getLogger(this).warnOnce(`A Sublayer (title: ${this.title}, id: ${this.id}) has an undefined 'labelPlacement' and so labels cannot be displayed. Either define a valid 'labelPlacement' or call Sublayer.load() to use a default value based on geometry type.`,{sublayer:this});let r=this.labelingInfo;null!=this.geometryType&&(r=_(this.labelingInfo,k.toJSON(this.geometryType))),e.showLabels=!0,e.labelingInfo=r.filter((e=>e.labelPlacement)).map((e=>e.toJSON({origin:"service",layer:this.layer})))}else e.showLabels=!1;i.opacity>L.SERVICE&&(e.transparency=100-100*this.opacity),this._assignDefaultSymbolColors(e.renderer)}return r}_assignDefaultSymbolColors(e){this._forEachSimpleMarkerSymbols(e,(e=>{e.color||"esriSMSX"!==e.style&&"esriSMSCross"!==e.style||(e.outline?.color?e.color=e.outline.color:e.color=[0,0,0,0])}))}_forEachSimpleMarkerSymbols(e,r){if(e){const t=("uniqueValueInfos"in e?e.uniqueValueInfos:"classBreakInfos"in e?e.classBreakInfos:null)??[];for(const e of t)B(e.symbol)&&r(e.symbol);"symbol"in e&&B(e.symbol)&&r(e.symbol),"defaultSymbol"in e&&B(e.defaultSymbol)&&r(e.defaultSymbol)}}_setAndNotifyLayer(e,r){const t=this.layer,i=this._get(e);let o,a;switch(e){case"definitionExpression":case"floorInfo":o="supportsSublayerDefinitionExpression";break;case"minScale":case"maxScale":case"visible":o="supportsSublayerVisibility";break;case"labelingInfo":case"labelsVisible":case"opacity":case"renderer":case"source":o="supportsDynamicLayers",a="supportsModification"}const s=E(this).getDefaultOrigin();if("service"!==s){if(o&&!1===this.layer?.capabilities?.exportMap?.[o])return void this._logLockedError(e,`capability not available 'layer.capabilities.exportMap.${o}'`);if(a&&!1===this.capabilities?.exportMap[a])return void this._logLockedError(e,`capability not available 'capabilities.exportMap.${a}'`)}"source"!==e||"not-loaded"===this.loadStatus?(this._set(e,r),"service"!==s&&i!==r&&t&&t.emit&&t.emit("sublayer-update",{propertyName:e,target:this})):this._logLockedError(e,"'source' can't be changed after calling sublayer.load()")}_handleSublayersChange(e,r){r&&(r.forEach((e=>{e.parent=null,e.layer=null})),this.removeAllHandles()),e&&(e.forEach((e=>{e.parent=this,e.layer=this.layer})),this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this,e.layer=this.layer})),e.on("after-remove",(({item:e})=>{e.parent=null,e.layer=null})),e.on("before-changes",(e=>{const r=this.layer?.capabilities?.exportMap?.supportsSublayersChanges;null==r||r||(d.getLogger(this).error(new l("sublayer:sublayers-non-modifiable","Sublayer can't be added, moved, or removed from the layer's sublayers",{sublayer:this,layer:this.layer})),e.preventDefault())}))]))}_logLockedError(e,r){const{layer:t,declaredClass:i}=this;d.getLogger(i).error(new l("sublayer:locked",`Property '${String(e)}' can't be changed on Sublayer from the layer '${t?.id}'`,{reason:r,sublayer:this,layer:t}))}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}};W.test={isMapImageLayerOverridePolicy:e=>e===G||e===J,isTileImageLayerOverridePolicy:e=>e===$},e([m({readOnly:!0})],W.prototype,"capabilities",void 0),e([b("service","capabilities",["layerDefinition.canModifyLayer","layerDefinition.capabilities"])],W.prototype,"readCapabilities",null),e([m()],W.prototype,"defaultPopupTemplate",null),e([m({type:String,value:null,json:{name:"layerDefinition.definitionExpression",write:{allowNull:!0,overridePolicy:J}}})],W.prototype,"definitionExpression",null),e([m({readOnly:!0})],W.prototype,"effectiveScaleRange",null),e([b("service","maxScaleRange",["minScale","maxScale"])],W.prototype,"readMaxScaleRange",null),e([m({type:[P],json:{origins:{service:{read:{source:"layerDefinition.fields"}}}}})],W.prototype,"fields",void 0),e([m({readOnly:!0})],W.prototype,"fieldsIndex",null),e([m({type:A,value:null,json:{name:"layerDefinition.floorInfo",read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo",overridePolicy:J},origins:{"web-scene":{read:!1,write:!1}}}})],W.prototype,"floorInfo",null),e([m({type:U,json:{read:{source:"layerDefinition.extent"}}})],W.prototype,"fullExtent",void 0),e([m({type:k.apiValues,json:{origins:{service:{name:"layerDefinition.geometryType",read:{reader:k.read}}}}})],W.prototype,"geometryType",void 0),e([m({type:String})],W.prototype,"globalIdField",void 0),e([b("service","globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],W.prototype,"readGlobalIdFieldFromService",null),e([m({type:v,json:{write:{ignoreOrigin:!0}}})],W.prototype,"id",null),e([m({value:null,type:[T],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo"},write:{target:"layerDefinition.drawingInfo.labelingInfo",overridePolicy:G}}})],W.prototype,"labelingInfo",null),e([S("labelingInfo")],W.prototype,"writeLabelingInfo",null),e([m({type:Boolean,value:!0,json:{read:{source:"layerDefinition.drawingInfo.showLabels"},write:{target:"layerDefinition.drawingInfo.showLabels",overridePolicy:G}}})],W.prototype,"labelsVisible",null),e([m({value:null})],W.prototype,"layer",null),e([m({type:String,json:{write:{overridePolicy:$}}})],W.prototype,"layerItemId",void 0),e([m({type:Boolean,value:!0,json:{origins:{service:{read:{enabled:!1}}},read:{source:"showLegend"},write:{target:"showLegend",overridePolicy:H}}})],W.prototype,"legendEnabled",void 0),e([m({type:["show","hide","hide-children"],value:"show",json:{read:!1,write:!1,origins:{"web-scene":{read:!0,write:!0}}}})],W.prototype,"listMode",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"minScale",null),e([b("minScale",["minScale","layerDefinition.minScale"])],W.prototype,"readMinScale",null),e([m({type:Number,value:0,json:{write:{overridePolicy:G}}})],W.prototype,"maxScale",null),e([b("maxScale",["maxScale","layerDefinition.maxScale"])],W.prototype,"readMaxScale",null),e([m({type:String})],W.prototype,"objectIdField",void 0),e([b("service","objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],W.prototype,"readObjectIdFieldFromService",null),e([m({type:Number,value:1,json:{write:{target:"layerDefinition.drawingInfo.transparency",overridePolicy:G}}})],W.prototype,"opacity",null),e([b("opacity",["layerDefinition.drawingInfo.transparency","layerDefinition.transparency"])],W.prototype,"readOpacity",null),e([S("opacity")],W.prototype,"writeOpacity",null),e([m({json:{type:v,write:{target:"parentLayerId",writerEnsuresNonNull:!0,overridePolicy:G}}})],W.prototype,"parent",void 0),e([S("parent")],W.prototype,"writeParent",null),e([m({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy:H,writer(e,r,t){r[t]=!e}}}})],W.prototype,"popupEnabled",void 0),e([m({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy:H}}})],W.prototype,"popupTemplate",void 0),e([m({readOnly:!0})],W.prototype,"queryTask",null),e([m({types:t,value:null,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G},origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:G}}}}})],W.prototype,"renderer",null),e([m({types:{key:"type",base:null,typeMap:{"data-layer":M,"map-layer":N}},cast(e){if(e){if("mapLayerId"in e)return j(N,e);if("dataSource"in e)return j(M,e)}return e},json:{name:"layerDefinition.source",write:{overridePolicy:G}}})],W.prototype,"source",null),e([m()],W.prototype,"sourceJSON",void 0),e([m({value:null,json:{type:[v],write:{target:"subLayerIds",allowNull:!0,overridePolicy:G}}})],W.prototype,"sublayers",null),e([h("sublayers")],W.prototype,"castSublayers",null),e([S("sublayers")],W.prototype,"writeSublayers",null),e([m({type:String,json:{name:"name",write:{overridePolicy:H}}})],W.prototype,"title",void 0),e([b("service","title",["name","layerDefinition.name"])],W.prototype,"readTitle",null),e([m({type:String})],W.prototype,"typeIdField",void 0),e([m({json:{read:!1},readOnly:!0,value:"sublayer"})],W.prototype,"type",void 0),e([b("typeIdField",["layerDefinition.typeIdField"])],W.prototype,"readTypeIdField",null),e([m({type:[x],json:{origins:{service:{read:{source:"layerDefinition.types"}}}}})],W.prototype,"types",void 0),e([m({type:String,json:{name:"layerUrl",write:{overridePolicy:$}}})],W.prototype,"url",null),e([m({type:Boolean,value:!0,json:{read:{source:"defaultVisibility"},write:{target:"defaultVisibility",overridePolicy:G}}})],W.prototype,"visible",null),e([S("visible")],W.prototype,"writeVisible",null),W=Q=e([g("esri.layers.support.Sublayer")],W);const X=W;export{X as default};
@@ -0,0 +1,4 @@
1
+ import "../../interfaces";
2
+
3
+ import Subtype = __esri.Subtype;
4
+ export default Subtype;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import{ClonableMixin as r}from"../../core/Clonable.js";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as e}from"../../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{writer as i}from"../../core/accessorSupport/decorators/writer.js";import{fromJSON as a}from"./domains.js";let c=class extends(r(t)){constructor(){super(...arguments),this.code=null,this.defaultValues={},this.domains=null,this.name=null}readDomains(o){if(!o)return null;const r={};for(const t of Object.keys(o))r[t]=a(o[t]);return r}writeDomains(o,r){if(!o)return;const t={};for(const s of Object.keys(o))o[s]&&(t[s]=o[s]?.toJSON());r.domains=t}};o([s({type:Number,json:{write:!0}})],c.prototype,"code",void 0),o([s({type:Object,json:{write:!0}})],c.prototype,"defaultValues",void 0),o([s({json:{write:!0}})],c.prototype,"domains",void 0),o([e("domains")],c.prototype,"readDomains",null),o([i("domains")],c.prototype,"writeDomains",null),o([s({type:String,json:{write:!0}})],c.prototype,"name",void 0),c=o([p("esri.layers.support.Subtype")],c);const n=c;export{n as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import{ClonableMixin as r}from"../../core/Clonable.js";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as e}from"../../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{writer as i}from"../../core/accessorSupport/decorators/writer.js";import{fromJSON as a}from"./domains.js";let c=class extends(r(t)){constructor(o){super(o),this.code=null,this.defaultValues={},this.domains=null,this.name=null}readDomains(o){if(!o)return null;const r={};for(const t of Object.keys(o))r[t]=a(o[t]);return r}writeDomains(o,r){if(!o)return;const t={};for(const s of Object.keys(o))o[s]&&(t[s]=o[s]?.toJSON());r.domains=t}};o([s({type:Number,json:{write:!0}})],c.prototype,"code",void 0),o([s({type:Object,json:{write:!0}})],c.prototype,"defaultValues",void 0),o([s({json:{write:!0}})],c.prototype,"domains",void 0),o([e("domains")],c.prototype,"readDomains",null),o([i("domains")],c.prototype,"writeDomains",null),o([s({type:String,json:{write:!0}})],c.prototype,"name",void 0),c=o([p("esri.layers.support.Subtype")],c);const n=c;export{n as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../core/lang.js";import n from"./RasterFunction.js";import{getPixelValueRange as t}from"./rasterFormats/pixelRangeUtils.js";import{schema as r}from"./rasterFunctions/rasterFunctionSchema.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,convertRGBATo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c=new Set(["u1","u2","u4","u8","s8","u16","s16"]),m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function p(e){return f.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.functionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.functionDefinition.arguments,t),r.rasterFunctionDefinition=r.functionDefinition.toJSON()}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const t=e(r[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(t.arguments[e]=h(o[e]),t.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(t.arguments[e].value=V(o[e]),t.arguments.ColorSchemeType.value=0):t.arguments[e].value=o[e];return t}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return w(e,n);case"class-breaks":return S(e,n);case"unique-value":return F(e,n);case"raster-colormap":return A(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,t){const r=new n;r.functionName="VectorFieldRenderer";const{dataType:o,bandNames:a}=t,i="vector-uv"===o;let s,u;if(a&&2===a.length){const e=a.map((e=>e.toLowerCase()));s=e.indexOf("magnitude"),u=e.indexOf("direction")}-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,f="flow-from"===e.flowRepresentation?0:1,p=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:f,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:p.minDataValue,maximumMagnitude:p.maxDataValue,minimumSymbolSize:p.minSize,maximumSymbolSize:p.maxSize};r.functionArguments=g;const d=h(r);return t.convertToRFT?n.fromJSON({rasterFunctionDefinition:d}):r}function v(e,t){const r=t.convertToRFT;if("elevation"!==t.dataType&&("generic"!==t.dataType||1!==t.bandCount||"s16"!==t.pixelType&&"s32"!==t.pixelType&&"f32"!==t.pixelType&&"f64"!==t.pixelType))return new n;const i=new n;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new n({rasterFunctionDefinition:h(i)}):i}function w(e,t){const r=t.convertToRFT,s=new n;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new n;if(r)l.functionArguments={ColorRamp:o(u)};else{const n=i(u,!0);if(n)l.functionArguments={colorRampName:n};else if(!t.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new n({rasterFunctionDefinition:h(l)}):l}return r?new n({rasterFunctionDefinition:h(s)}):s}function S(e,t){const r=[],o=[],a=[],i=[],s=1e-6,{pixelType:u,rasterAttributeTable:l}=t,c=null==l?null:l.features,m=C(l);if(m&&c&&Array.isArray(c)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&c.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&i.push([a.attributes[m],r.r,r.g,r.b]))}))}));const r=u?x(i,u):i,o=new n;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=r,o.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?r.push(e.minValue,e.maxValue+s):r.push(e.minValue+s,e.maxValue+s),o.push(n),i.push([n,t.r,t.g,t.b])):a.push(e.minValue,e.maxValue)}));const f=u?x(i,u):i,p=new n;p.functionName="Remap",p.functionArguments={InputRanges:r,OutputValues:o,NoDataRanges:a},p.variableName="Raster";const g=new n;return g.functionName="Colormap",g.functionArguments={Colormap:f,Raster:p},t.convertToRFT?new n({rasterFunctionDefinition:h(g)}):g}function x(e,n){const r=c.has(n)?t(n):null;return r&&e.push([Math.floor(r[0]-1),0,0,0],[Math.ceil(r[1]+1),0,0,0]),e}function C(e){if(null==e)return;const{fields:n}=e,t=n?.find((e=>e?.name&&"value"===e.name.toLowerCase()));return t?.name}function F(e,t){const r=[],{pixelType:o,rasterAttributeTable:a}=t,i=null==a?null:a.features,s=C(a),u=e.defaultSymbol?.color?.toRgb(),l=e.uniqueValueInfos;if(l)if(i){if(s){const n=new Map;l.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r?.a&&n.set(String(t),r.toRgb())}));const t=e.field;i.forEach((({attributes:e})=>{const o=String(e[t]),a=e[s],i=n.get(o);i?r.push([a,...i]):u&&r.push([a,...u])}))}}else for(let n=0;n<l.length;n++){const e=l[n],t=e.symbol?.color,o=+e.value;if(t?.a){if(isNaN(o))return null;r.push([o,t.r,t.g,t.b])}}const c=o?x(r,o):r,m=new n;return m.functionName="Colormap",m.functionArguments={},m.functionArguments.Colormap=c,m.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(m)}):m}function A(e,t){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=t,a=o?x(r,o):r,i=new n;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,t.convertToRFT?new n({rasterFunctionDefinition:h(i)}):i}function N(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function V(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(s([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{g as combineRenderingRules,y as convertRendererToRenderingRule,h as convertRenderingRuleToRFT,p as isSupportedRendererType};
5
+ import{clone as e}from"../../core/lang.js";import n from"./RasterFunction.js";import{getPixelValueRange as t}from"./rasterFormats/pixelRangeUtils.js";import{schema as r}from"./rasterFunctions/rasterFunctionSchema.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,convertRGBATo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c=new Set(["u1","u2","u4","u8","s8","u16","s16"]),m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function p(e){return f.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.functionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.functionDefinition.arguments,t),r.rasterFunctionDefinition=r.functionDefinition.toJSON()}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const t=e(r[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(t.arguments[e]=h(o[e]),t.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(t.arguments[e].value=V(o[e]),t.arguments.ColorSchemeType.value=0):t.arguments[e].value=o[e];return t}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return w(e,n);case"class-breaks":return S(e,n);case"unique-value":return F(e,n);case"raster-colormap":return A(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster??e?.raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,t){const r=new n;r.functionName="VectorFieldRenderer";const{dataType:o,bandNames:a}=t,i="vector-uv"===o;let s,u;if(a&&2===a.length){const e=a.map((e=>e.toLowerCase()));s=e.indexOf("magnitude"),u=e.indexOf("direction")}-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,f="flow-from"===e.flowRepresentation?0:1,p=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:f,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:p.minDataValue,maximumMagnitude:p.maxDataValue,minimumSymbolSize:p.minSize,maximumSymbolSize:p.maxSize};r.functionArguments=g;const d=h(r);return t.convertToRFT?n.fromJSON({rasterFunctionDefinition:d}):r}function v(e,t){const r=t.convertToRFT;if("elevation"!==t.dataType&&("generic"!==t.dataType||1!==t.bandCount||"s16"!==t.pixelType&&"s32"!==t.pixelType&&"f32"!==t.pixelType&&"f64"!==t.pixelType))return new n;const i=new n;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new n({rasterFunctionDefinition:h(i)}):i}function w(e,t){const r=t.convertToRFT,s=new n;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new n;if(r)l.functionArguments={ColorRamp:o(u)};else{const n=i(u,!0);if(n)l.functionArguments={colorRampName:n};else if(!t.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new n({rasterFunctionDefinition:h(l)}):l}return r?new n({rasterFunctionDefinition:h(s)}):s}function S(e,t){const r=[],o=[],a=[],i=[],s=1e-6,{pixelType:u,rasterAttributeTable:l}=t,c=null==l?null:l.features,m=C(l);if(m&&c&&Array.isArray(c)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&c.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&i.push([a.attributes[m],r.r,r.g,r.b]))}))}));const r=u?x(i,u):i,o=new n;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=r,o.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?r.push(e.minValue,e.maxValue+s):r.push(e.minValue+s,e.maxValue+s),o.push(n),i.push([n,t.r,t.g,t.b])):a.push(e.minValue,e.maxValue)}));const f=u?x(i,u):i,p=new n;p.functionName="Remap",p.functionArguments={InputRanges:r,OutputValues:o,NoDataRanges:a},p.variableName="Raster";const g=new n;return g.functionName="Colormap",g.functionArguments={Colormap:f,Raster:p},t.convertToRFT?new n({rasterFunctionDefinition:h(g)}):g}function x(e,n){const r=c.has(n)?t(n):null;return r&&e.push([Math.floor(r[0]-1),0,0,0],[Math.ceil(r[1]+1),0,0,0]),e}function C(e){if(null==e)return;const{fields:n}=e,t=n?.find((e=>e?.name&&"value"===e.name.toLowerCase()));return t?.name}function F(e,t){const r=[],{pixelType:o,rasterAttributeTable:a}=t,i=null==a?null:a.features,s=C(a),u=e.defaultSymbol?.color?.toRgb(),l=e.uniqueValueInfos;if(l)if(i){if(s){const n=new Map;l.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r?.a&&n.set(String(t),r.toRgb())}));const t=e.field;i.forEach((({attributes:e})=>{const o=String(e[t]),a=e[s],i=n.get(o);i?r.push([a,...i]):u&&r.push([a,...u])}))}}else for(let n=0;n<l.length;n++){const e=l[n],t=e.symbol?.color,o=+e.value;if(t?.a){if(isNaN(o))return null;r.push([o,t.r,t.g,t.b])}}const c=o?x(r,o):r,m=new n;return m.functionName="Colormap",m.functionArguments={},m.functionArguments.Colormap=c,m.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(m)}):m}function A(e,t){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=t,a=o?x(r,o):r,i=new n;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,t.convertToRFT?new n({rasterFunctionDefinition:h(i)}):i}function N(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function V(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(s([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{g as combineRenderingRules,y as convertRendererToRenderingRule,h as convertRenderingRuleToRFT,p as isSupportedRendererType};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/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 r from"../request.js";import o from"../core/Error.js";import s from"../core/Loadable.js";import i from"../core/Logger.js";import{MultiOriginJSONMixin as a}from"../core/MultiOriginJSONSupport.js";import{isAbortError as n}from"../core/promiseUtils.js";import{urlToObject as l}from"../core/urlUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import u from"../geometry/Extent.js";import{fromJSON as c}from"../geometry/support/jsonUtils.js";import{versionMatches as m,onApplyEditsEvent as y,onUpdateMomentEvent as h,emitApplyEditsEvent as f}from"../layers/mixins/EditBusLayer.js";import{parse as g}from"../layers/support/arcgisLayerUrl.js";import v from"./support/TopologyValidationJobInfo.js";import{networkFromPortalItem as w}from"./support/utils.js";import{isVersionInEditSession as j}from"../versionManagement/support/versionManagementUtils.js";import S from"../geometry/SpatialReference.js";let U=class extends(a(s)){static fromPortalItem(e){return w(e)}constructor(e){super(e),this.id=null,this.title=null,this.layerUrl=null,this.dataElement=null,this.fullExtent=null,this.spatialReference=null,this.type=null,this.sourceJSON=null,this.gdbVersion=null,this.historicMoment=null,this._applyEditsHandler=e=>{const{serviceUrl:t,gdbVersion:r,result:o}=e,s=t===this.featureServiceUrl,i=m(t,r,this.gdbVersion);s&&i&&o.then((e=>{j(t,r)&&(this.historicMoment=e.historicMoment)}))},this._updateMomentHandler=e=>{const{serviceUrl:t,gdbVersion:r,moment:o}=e,s=t===this.featureServiceUrl,i=m(t,r,this.gdbVersion);s&&i&&(this.historicMoment=o)},this.when().then((()=>{this.addHandles([y(this._applyEditsHandler),h(this._updateMomentHandler)])}),(()=>{}))}initialize(){this.when().catch((e=>{n(e)||i.getLogger(this).error("#load()",`Failed to load layer (title: '${this.title??"no title"}', id: '${this.id??"no id"}')`,{error:e})}))}get datasetName(){return this.dataElement?.name??null}get owner(){return this.dataElement?.userIdentity??null}get schemaGeneration(){return this.dataElement?.schemaGeneration??null}get parsedUrl(){return l(this.layerUrl)}get featureServiceUrl(){return g(this.parsedUrl.path).url.path}get networkServiceUrl(){return this.featureServiceUrl.replace(/\/FeatureServer/i,"/UtilityNetworkServer")}get layerId(){return g(this.parsedUrl.path).sublayer}get networkSystemLayers(){return null}async load(e){return this.addResolvingPromise(this._fetchDataElement(this.featureServiceUrl,this.layerId.toString(),e)),this.addResolvingPromise(this._fetchLayerMetaData(this.layerUrl,e)),this}getLayerIdBySourceId(e){if(this.dataElement){const t=this.dataElement.domainNetworks;for(const r of t){for(const t of r.edgeSources??[])if(t.sourceId===e)return t.layerId;for(const t of r.junctionSources??[])if(t.sourceId===e)return t.layerId}return null}return null}async queryNamedTraceConfigurations(e,t){const[{queryNamedTraceConfigurations:r},{default:o}]=await Promise.all([import("../rest/networks/queryNamedTraceConfigurations.js"),import("../rest/networks/support/QueryNamedTraceConfigurationsParameters.js")]),s=this.networkServiceUrl,i=o.from(e);return(await r(s,i,{...t}))?.namedTraceConfigurations}async validateTopology(e,t){if(!e.validateArea)throw new o("network:undefined-validateArea","the network must have validateArea defined in the validate network topology parameters.");const[{validateNetworkTopology:r},{default:s}]=await Promise.all([import("../rest/networks/validateNetworkTopology.js"),import("../rest/networks/support/ValidateNetworkTopologyParameters.js")]),i=s.from(e);i.gdbVersion=this.gdbVersion;const a=this.networkServiceUrl,n=this.featureServiceUrl,l=f(n,null,null,!0),d=await r(a,i,{...t});if(d?.serviceEdits){const e=[];for(const t of d.serviceEdits){const{editedFeatures:r}=t,o=r?.spatialReference?new S(r.spatialReference):null;e.push({layerId:t.layerId,editedFeatures:{adds:r?.adds?.map((e=>this._createEditedFeature(e,o)))||[],updates:r?.updates?.map((e=>({original:this._createEditedFeature(e[0],o),current:this._createEditedFeature(e[1],o)})))||[],deletes:r?.deletes?.map((e=>this._createEditedFeature(e,o)))||[],spatialReference:o}})}l.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],editedFeatures:e,exceededTransferLimit:!1,historicMoment:d.moment})}return d}async submitTopologyValidationJob(e,t){if(!e.validateArea)throw new o("network:undefined-validateArea","the network must have validateArea defined in the validate network topology parameters.");if(!this.gdbVersion)throw new o("network:undefined-gdb-version","version must be defined");const[{submitValidateNetworkTopologyJob:r},{default:s}]=await Promise.all([import("../rest/networks/validateNetworkTopology.js"),import("../rest/networks/support/ValidateNetworkTopologyParameters.js")]),i=s.from(e);i.gdbVersion=this.gdbVersion;const a=this.networkServiceUrl,n=this.featureServiceUrl?f(this.featureServiceUrl,null,null,!0):void 0,l=await r(a,i,{...t});return new v({statusUrl:l,editsResolver:n})}_createEditedFeature(e,r){return new t({attributes:e.attributes,geometry:c({...e.geometry,spatialReference:r})})}async _fetchLayerMetaData(e,t){const o=await r(e,{responseType:"json",query:{f:"json"},...t});this.sourceJSON=o.data,this.read(o.data,{origin:"service"})}async _fetchDataElement(e,t,o){if(this.dataElement)return;const s=await r(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([t]),f:"json"},...o}).then((e=>e.data.layerDataElements?.[0]));s&&this.read(s,{origin:"service"})}};e([d({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}},service:{read:!0}},read:!1}})],U.prototype,"id",void 0),e([d({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}},service:{read:{source:"name"}}},read:!1}})],U.prototype,"title",void 0),e([d({type:String,nonNullable:!0,json:{origins:{"web-map":{read:{source:"url"},write:{target:"url",isRequired:!0}}},read:!1}})],U.prototype,"layerUrl",void 0),e([d({type:Object,json:{origins:{service:{read:!0}},read:!1}})],U.prototype,"dataElement",void 0),e([d({type:u,json:{origins:{service:{read:{source:"extent"}}},read:!1}})],U.prototype,"fullExtent",void 0),e([d({type:S,json:{origins:{service:{read:{source:"extent.spatialReference"}}},read:!1}})],U.prototype,"spatialReference",void 0),e([d({type:["utility","trace"],readOnly:!0,json:{read:!1,write:!1}})],U.prototype,"type",void 0),e([d({readOnly:!0})],U.prototype,"datasetName",null),e([d({readOnly:!0})],U.prototype,"owner",null),e([d({readOnly:!0})],U.prototype,"schemaGeneration",null),e([d({readOnly:!0})],U.prototype,"parsedUrl",null),e([d({readOnly:!0})],U.prototype,"featureServiceUrl",null),e([d({readOnly:!0})],U.prototype,"networkServiceUrl",null),e([d({readOnly:!0})],U.prototype,"layerId",null),e([d()],U.prototype,"sourceJSON",void 0),e([d({readOnly:!0})],U.prototype,"networkSystemLayers",null),e([d()],U.prototype,"gdbVersion",void 0),e([d({type:Date})],U.prototype,"historicMoment",void 0),U=e([p("esri.networks.Network")],U);const b=U;export{b as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../Graphic.js";import r from"../request.js";import o from"../core/Error.js";import s from"../core/Loadable.js";import i from"../core/Logger.js";import{MultiOriginJSONMixin as a}from"../core/MultiOriginJSONSupport.js";import{isAbortError as n}from"../core/promiseUtils.js";import{urlToObject as l}from"../core/urlUtils.js";import{property as d}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import p from"../geometry/Extent.js";import{fromJSON as c}from"../geometry/support/jsonUtils.js";import{versionMatches as m,onApplyEditsEvent as y,onUpdateMomentEvent as h,emitApplyEditsEvent as f}from"../layers/mixins/EditBusLayer.js";import{parse as g}from"../layers/support/arcgisLayerUrl.js";import v from"./support/TopologyValidationJobInfo.js";import{networkFromPortalItem as w}from"./support/utils.js";import{isVersionInEditSession as j,currentSessionId as S}from"../versionManagement/support/versionManagementUtils.js";import b from"../geometry/SpatialReference.js";let U=class extends(a(s)){static fromPortalItem(e){return w(e)}constructor(e){super(e),this.id=null,this.title=null,this.layerUrl=null,this.dataElement=null,this.fullExtent=null,this.spatialReference=null,this.type=null,this.sourceJSON=null,this.gdbVersion=null,this.historicMoment=null,this._applyEditsHandler=e=>{const{serviceUrl:t,gdbVersion:r,result:o}=e,s=t===this.featureServiceUrl,i=m(t,r,this.gdbVersion);s&&i&&o.then((e=>{j(t,r)&&(this.historicMoment=e.historicMoment)}))},this._updateMomentHandler=e=>{const{serviceUrl:t,gdbVersion:r,moment:o}=e,s=t===this.featureServiceUrl,i=m(t,r,this.gdbVersion);s&&i&&(this.historicMoment=o)},this.when().then((()=>{this.addHandles([y(this._applyEditsHandler),h(this._updateMomentHandler)])}),(()=>{}))}initialize(){this.when().catch((e=>{n(e)||i.getLogger(this).error("#load()",`Failed to load layer (title: '${this.title??"no title"}', id: '${this.id??"no id"}')`,{error:e})}))}get datasetName(){return this.dataElement?.name??null}get owner(){return this.dataElement?.userIdentity??null}get schemaGeneration(){return this.dataElement?.schemaGeneration??null}get parsedUrl(){return l(this.layerUrl)}get featureServiceUrl(){return g(this.parsedUrl.path).url.path}get networkServiceUrl(){return this.featureServiceUrl.replace(/\/FeatureServer/i,"/UtilityNetworkServer")}get layerId(){return g(this.parsedUrl.path).sublayer}get networkSystemLayers(){return null}async load(e){return this.addResolvingPromise(this._fetchDataElement(this.featureServiceUrl,this.layerId.toString(),e)),this.addResolvingPromise(this._fetchLayerMetaData(this.layerUrl,e)),this}getLayerIdBySourceId(e){if(this.dataElement){const t=this.dataElement.domainNetworks;for(const r of t){for(const t of r.edgeSources??[])if(t.sourceId===e)return t.layerId;for(const t of r.junctionSources??[])if(t.sourceId===e)return t.layerId}return null}return null}async queryNamedTraceConfigurations(e,t){const[{queryNamedTraceConfigurations:r},{default:o}]=await Promise.all([import("../rest/networks/queryNamedTraceConfigurations.js"),import("../rest/networks/support/QueryNamedTraceConfigurationsParameters.js")]),s=this.networkServiceUrl,i=o.from(e);return(await r(s,i,{...t}))?.namedTraceConfigurations}async validateTopology(e,t){if(!e.validateArea)throw new o("network:undefined-validateArea","the network must have validateArea defined in the validate network topology parameters.");const[{validateNetworkTopology:r},{default:s}]=await Promise.all([import("../rest/networks/validateNetworkTopology.js"),import("../rest/networks/support/ValidateNetworkTopologyParameters.js")]),i=s.from(e);j(this.featureServiceUrl,this.gdbVersion||null)&&(i.sessionID=S),i.gdbVersion=this.gdbVersion;const a=this.networkServiceUrl,n=this.featureServiceUrl,l=f(n,null,this.gdbVersion,!0),d=await r(a,i,{...t});if(d?.serviceEdits){const e=[];for(const t of d.serviceEdits){const{editedFeatures:r}=t,o=r?.spatialReference?new b(r.spatialReference):null;e.push({layerId:t.layerId,editedFeatures:{adds:r?.adds?.map((e=>this._createEditedFeature(e,o)))||[],updates:r?.updates?.map((e=>({original:this._createEditedFeature(e[0],o),current:this._createEditedFeature(e[1],o)})))||[],deletes:r?.deletes?.map((e=>this._createEditedFeature(e,o)))||[],spatialReference:o}})}l.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],editedFeatures:e,exceededTransferLimit:!1,historicMoment:d.moment})}return d}async submitTopologyValidationJob(e,t){if(!e.validateArea)throw new o("network:undefined-validateArea","the network must have validateArea defined in the validate network topology parameters.");if(!this.gdbVersion)throw new o("network:undefined-gdb-version","version must be defined");const[{submitValidateNetworkTopologyJob:r},{default:s}]=await Promise.all([import("../rest/networks/validateNetworkTopology.js"),import("../rest/networks/support/ValidateNetworkTopologyParameters.js")]),i=s.from(e);j(this.featureServiceUrl,this.gdbVersion||null)&&(i.sessionID=S),i.gdbVersion=this.gdbVersion;const a=this.networkServiceUrl,n=this.featureServiceUrl?f(this.featureServiceUrl,null,this.gdbVersion,!0):void 0,l=await r(a,i,{...t});return new v({statusUrl:l,editsResolver:n})}_createEditedFeature(e,r){return new t({attributes:e.attributes,geometry:c({...e.geometry,spatialReference:r})})}async _fetchLayerMetaData(e,t){const o=await r(e,{responseType:"json",query:{f:"json"},...t});this.sourceJSON=o.data,this.read(o.data,{origin:"service"})}async _fetchDataElement(e,t,o){if(this.dataElement)return;const s=await r(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([t]),f:"json"},...o}).then((e=>e.data.layerDataElements?.[0]));s&&this.read(s,{origin:"service"})}};e([d({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}},service:{read:!0}},read:!1}})],U.prototype,"id",void 0),e([d({type:String,nonNullable:!0,json:{origins:{"web-map":{read:!0,write:{isRequired:!0}},service:{read:{source:"name"}}},read:!1}})],U.prototype,"title",void 0),e([d({type:String,nonNullable:!0,json:{origins:{"web-map":{read:{source:"url"},write:{target:"url",isRequired:!0}}},read:!1}})],U.prototype,"layerUrl",void 0),e([d({type:Object,json:{origins:{service:{read:!0}},read:!1}})],U.prototype,"dataElement",void 0),e([d({type:p,json:{origins:{service:{read:{source:"extent"}}},read:!1}})],U.prototype,"fullExtent",void 0),e([d({type:b,json:{origins:{service:{read:{source:"extent.spatialReference"}}},read:!1}})],U.prototype,"spatialReference",void 0),e([d({type:["utility","trace"],readOnly:!0,json:{read:!1,write:!1}})],U.prototype,"type",void 0),e([d({readOnly:!0})],U.prototype,"datasetName",null),e([d({readOnly:!0})],U.prototype,"owner",null),e([d({readOnly:!0})],U.prototype,"schemaGeneration",null),e([d({readOnly:!0})],U.prototype,"parsedUrl",null),e([d({readOnly:!0})],U.prototype,"featureServiceUrl",null),e([d({readOnly:!0})],U.prototype,"networkServiceUrl",null),e([d({readOnly:!0})],U.prototype,"layerId",null),e([d()],U.prototype,"sourceJSON",void 0),e([d({readOnly:!0})],U.prototype,"networkSystemLayers",null),e([d()],U.prototype,"gdbVersion",void 0),e([d({type:Date})],U.prototype,"historicMoment",void 0),U=e([u("esri.networks.Network")],U);const k=U;export{k as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.28.0-rc.2",
3
+ "version": "4.28.0-rc.4",
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.28/esri/copyright.txt for details.
4
4
  */
5
- import{urlToObject as t}from"../../core/urlUtils.js";import r from"../Portal.js";function e(e){return{origin:"portal-item",url:t(e.itemUrl),portal:e.portal||r.getDefault(),portalItem:e,readResourcePaths:[]}}function l(e){return{origin:"portal-item",messages:[],writtenProperties:[],url:e.itemUrl?t(e.itemUrl):null,portal:e.portal||r.getDefault(),portalItem:e}}function o(e){return{origin:"web-map",url:t(e.itemUrl),portal:e.portal||r.getDefault(),portalItem:e,readResourcePaths:[]}}function a(e){return{origin:"web-map",messages:[],writtenProperties:[],url:e.itemUrl?t(e.itemUrl):null,portal:e.portal||r.getDefault(),portalItem:e}}export{o as createForGroupLayerItemRead,a as createForGroupLayerItemWrite,e as createForItemRead,l as createForItemWrite};
5
+ import{urlToObject as t}from"../../core/urlUtils.js";import r from"../Portal.js";function e(e){return{origin:"portal-item",url:t(e.itemUrl),portal:e.portal||r.getDefault(),portalItem:e,readResourcePaths:[]}}function o(e){const o=t(e.itemUrl);return{origin:"portal-item",messages:[],writtenProperties:[],url:o,portal:e.portal||r.getDefault(),portalItem:e,verifyItemRelativeUrls:o?{rootPath:o.path,writtenUrls:[]}:null,blockedRelativeUrls:[]}}function l(e){return{origin:"web-map",url:t(e.itemUrl),portal:e.portal||r.getDefault(),portalItem:e,readResourcePaths:[]}}function a(e,o){const l=t(e.itemUrl);return{origin:"web-map",messages:[],writtenProperties:[],url:l,portal:e.portal||r.getDefault(),portalItem:e,initiator:o,verifyItemRelativeUrls:l?{rootPath:l.path,writtenUrls:[]}:null,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}}export{l as createForGroupLayerItemRead,a as createForGroupLayerItemWrite,e as createForItemRead,o as createForItemWrite};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{OriginId as t}from"../../core/accessorSupport/PropertyOrigin.js";import{parse as r}from"../../layers/support/arcgisLayerUrl.js";import{fetchFeatureService as a}from"../../layers/support/fetchService.js";import{LayerLoadContext as n}from"../../layers/support/LayerLoadContext.js";import{populateGroupLayer as o}from"../../layers/support/layersCreator.js";import{layerLookupMap as s}from"../../layers/support/lazyLayerLoader.js";import i from"../Portal.js";import{createForItemRead as l,createForGroupLayerItemRead as p}from"./jsonContext.js";import{preprocessFSItemData as u,getSubtypeGroupLayerIds as c,getOrientedImageryLayerIds as y,populateSceneServiceItemData as f,getNumLayersAndTables as d,createSublayerData as m,getFirstLayerOrTableId as h}from"./loadUtils.js";import{hasTypeKeyword as w}from"./portalItemUtils.js";import{loadStyleRenderer as g}from"../../renderers/support/styleUtils.js";import{fetchArcGISServiceJSON as b}from"../../support/requestPresets.js";async function I(e,t){const r=e.instance.portalItem;if(r?.id)return await r.load(t),L(e),S(e,t)}function L(t){const r=t.instance.portalItem;if(!r?.type||!t.supportedTypes.includes(r.type))throw new e("portal:invalid-layer-item-type","Invalid layer item type '${type}', expected '${expectedType}'",{type:r?.type,expectedType:t.supportedTypes.join(", ")})}async function S(e,t){const r=e.instance,a=r.portalItem;if(!a)return;const{url:o,title:s}=a,i=l(a);if("group"===r.type)return j(r,i,e);o&&r.read({url:o},i);const p=new n,u=await C(e,p,t);return u&&r.read(u,i),r.resourceReferences={portalItem:a,paths:i.readResourcePaths??[]},"subtype-group"!==r.type&&r.read({title:s},i),g(r,i)}async function j(r,a,n){const o=r.portalItem;if(r.originIdOf("portalItem")!==t.USER)return;const{title:s,type:i}=o;if("Group Layer"===i){if(!w(o,"Map"))throw new e("portal:invalid-layer-item-typekeyword","'Group Layer' item without 'Map' type keyword is not supported");return T(r)}return r.read({title:s},a),v(r,n)}async function T(e){const t=e.portalItem,r=await t.fetchData("json");if(!r)return;const a=p(t);e.read(r,a),await o(e,r,{context:a})}async function v(t,r){let a;const{portalItem:o}=t;if(!o)return;const s=o.type,i=r.layerModuleTypeMap;switch(s){case"Feature Service":case"Feature Collection":a=i.FeatureLayer;break;case"Stream Service":a=i.StreamLayer;break;case"Scene Service":a=i.SceneLayer;break;default:throw new e("portal:unsupported-item-type-as-group",`The item type '${s}' is not supported as a 'IGroupLayer'`)}const l=new n;let[p,m]=await Promise.all([a(),C(r,l)]),h=()=>p;if("Feature Service"===s){m=o.url?await u(m,o.url,l):{};const e=c(m),r=y(m),a=[];if(e.length||r?.length){e.length&&a.push("SubtypeGroupLayer"),r?.length&&a.push("OrientedImageryLayer");const t=[];for(const e of a){const r=i[e];t.push(r())}const n=await Promise.all(t),o=new Map;a.forEach(((e,t)=>{o.set(e,n[t])})),h=e=>e.layerType?o.get(e.layerType)??p:p}const n=await k(o.url);return await x(t,h,m,n)}return"Scene Service"===s&&o.url&&(m=await f(o,m,l)),d(m)>0?await x(t,h,m):await M(t,h)}async function M(e,t){const{portalItem:r}=e;if(!r?.url)return;const a=await b(r.url);a&&x(e,t,{layers:a.layers?.map(m),tables:a.tables?.map(m)})}async function x(e,t,r,a){let n=r.layers||[];const o=r.tables||[];if("Feature Collection"===e.portalItem?.type?(n.forEach(((e,t)=>{e.id=t,"Table"===e?.layerDefinition?.type&&o.push(e)})),n=n.filter((e=>"Table"!==e?.layerDefinition?.type))):(n.reverse(),o.reverse()),n.forEach((n=>{const o=a?.(n);if(o||!a){const a=F(e,t(n),r,n,o);e.add(a)}})),o.length){const t=await s.FeatureLayer();o.forEach((n=>{const o=a?.(n);if(o||!a){const a=F(e,t,r,n,o);e.tables.add(a)}}))}}function F(e,t,r,a,n){const o=e.portalItem,s={portalItem:o.clone(),layerId:a.id};null!=a.url&&(s.url=a.url);const l=new t(s);if("sourceJSON"in l&&(l.sourceJSON=n),"subtype-group"!==l.type&&(l.sublayerTitleMode="service-name"),"Feature Collection"===o.type){const e={origin:"portal-item",portal:o.portal||i.getDefault()};l.read(a,e);const t=r.showLegend;null!=t&&l.read({showLegend:t},e)}return l}async function C(e,t,r){if(!1===e.supportsData)return;const a=e.instance,n=a.portalItem;if(!n)return;let o=null;try{o=await n.fetchData("json",r)}catch(s){}if(O(a)){let e=null;const r=await D(n,o,t);if((o?.layers||o?.tables)&&r>0){if(null==a.layerId){const e=c(o);a.layerId="subtype-group"===a.type?e?.[0]:h(o)}e=E(o,a),e&&null!=o.showLegend&&(e.showLegend=o.showLegend)}return r>1&&"sublayerTitleMode"in a&&"service-name"!==a.sublayerTitleMode&&(a.sublayerTitleMode="item-title-and-service-name"),e}return o}async function D(e,t,a){if(t?.layers&&t?.tables)return d(t);const n=r(e.url);if(!n)return 1;const o=await a.fetchServiceMetadata(n.url.path).catch((()=>null));return(t?.layers?.length??o?.layers?.length??0)+(t?.tables?.length??o?.tables?.length??0)}function E(e,t){const{layerId:r}=t,a=e.layers?.find((e=>e.id===r))||e.tables?.find((e=>e.id===r));return a&&P(a,t)?a:null}function O(e){return"stream"!==e.type&&"layerId"in e}function P(e,t){return!("feature"===t.type&&"layerType"in e&&"SubtypeGroupLayer"===e.layerType||"subtype-group"===t.type&&!("layerType"in e))}async function k(e){const{layersJSON:t}=await a(e);if(!t)return null;const r=[...t.layers,...t.tables];return e=>r.find((t=>t.id===e.id))}export{I as load};
5
+ import e from"../../core/Error.js";import{parse as t}from"../../layers/support/arcgisLayerUrl.js";import{fetchFeatureService as r}from"../../layers/support/fetchService.js";import{LayerLoadContext as a}from"../../layers/support/LayerLoadContext.js";import{populateGroupLayer as n}from"../../layers/support/layersCreator.js";import{layerLookupMap as o}from"../../layers/support/lazyLayerLoader.js";import s from"../Portal.js";import{createForItemRead as l,createForGroupLayerItemRead as i}from"./jsonContext.js";import{preprocessFSItemData as p,getSubtypeGroupLayerIds as u,getOrientedImageryLayerIds as c,populateSceneServiceItemData as y,getNumLayersAndTables as f,createSublayerData as d,getFirstLayerOrTableId as m}from"./loadUtils.js";import{hasTypeKeyword as h}from"./portalItemUtils.js";import{loadStyleRenderer as w}from"../../renderers/support/styleUtils.js";import{fetchArcGISServiceJSON as b}from"../../support/requestPresets.js";async function g(e,t){const r=e.instance.portalItem;if(r?.id)return await r.load(t),I(e),L(e,t)}function I(t){const r=t.instance.portalItem;if(!r?.type||!t.supportedTypes.includes(r.type))throw new e("portal:invalid-layer-item-type","Invalid layer item type '${type}', expected '${expectedType}'",{type:r?.type,expectedType:t.supportedTypes.join(", ")})}async function L(e,t){const r=e.instance,n=r.portalItem;if(!n)return;const{url:o,title:s}=n,i=l(n);if("group"===r.type)return S(r,i,e);o&&r.read({url:o},i);const p=new a,u=await F(e,p,t);return u&&r.read(u,i),r.resourceReferences={portalItem:n,paths:i.readResourcePaths??[]},"subtype-group"!==r.type&&r.read({title:s},i),w(r,i)}async function S(t,r,a){const n=t.portalItem;if(!t.sourceIsPortalItem)return;const{title:o,type:s}=n;if("Group Layer"===s){if(!h(n,"Map"))throw new e("portal:invalid-layer-item-typekeyword","'Group Layer' item without 'Map' type keyword is not supported");return T(t)}return t.read({title:o},r),j(t,a)}async function T(e){const t=e.portalItem,r=await t.fetchData("json");if(!r)return;const a=i(t);e.read(r,a),await n(e,r,{context:a}),e.resourceReferences={portalItem:t,paths:a.readResourcePaths??[]}}async function j(t,r){let n;const{portalItem:o}=t;if(!o)return;const s=o.type,l=r.layerModuleTypeMap;switch(s){case"Feature Service":case"Feature Collection":n=l.FeatureLayer;break;case"Stream Service":n=l.StreamLayer;break;case"Scene Service":n=l.SceneLayer;break;default:throw new e("portal:unsupported-item-type-as-group",`The item type '${s}' is not supported as a 'IGroupLayer'`)}const i=new a;let[d,m]=await Promise.all([n(),F(r,i)]),h=()=>d;if("Feature Service"===s){m=o.url?await p(m,o.url,i):{};const e=u(m),r=c(m),a=[];if(e.length||r?.length){e.length&&a.push("SubtypeGroupLayer"),r?.length&&a.push("OrientedImageryLayer");const t=[];for(const e of a){const r=l[e];t.push(r())}const n=await Promise.all(t),o=new Map;a.forEach(((e,t)=>{o.set(e,n[t])})),h=e=>e.layerType?o.get(e.layerType)??d:d}const n=await E(o.url);return await M(t,h,m,n)}return"Scene Service"===s&&o.url&&(m=await y(o,m,i)),f(m)>0?await M(t,h,m):await v(t,h)}async function v(e,t){const{portalItem:r}=e;if(!r?.url)return;const a=await b(r.url);a&&M(e,t,{layers:a.layers?.map(d),tables:a.tables?.map(d)})}async function M(e,t,r,a){let n=r.layers||[];const s=r.tables||[];if("Feature Collection"===e.portalItem?.type?(n.forEach(((e,t)=>{e.id=t,"Table"===e?.layerDefinition?.type&&s.push(e)})),n=n.filter((e=>"Table"!==e?.layerDefinition?.type))):(n.reverse(),s.reverse()),n.forEach((n=>{const o=a?.(n);if(o||!a){const a=x(e,t(n),r,n,o);e.add(a)}})),s.length){const t=await o.FeatureLayer();s.forEach((n=>{const o=a?.(n);if(o||!a){const a=x(e,t,r,n,o);e.tables.add(a)}}))}}function x(e,t,r,a,n){const o=e.portalItem,l={portalItem:o.clone(),layerId:a.id};null!=a.url&&(l.url=a.url);const i=new t(l);if("sourceJSON"in i&&(i.sourceJSON=n),"subtype-group"!==i.type&&(i.sublayerTitleMode="service-name"),"Feature Collection"===o.type){const e={origin:"portal-item",portal:o.portal||s.getDefault()};i.read(a,e);const t=r.showLegend;null!=t&&i.read({showLegend:t},e)}return i}async function F(e,t,r){if(!1===e.supportsData)return;const a=e.instance,n=a.portalItem;if(!n)return;let o=null;try{o=await n.fetchData("json",r)}catch(s){}if(D(a)){let e=null;const r=await P(n,o,t);if((o?.layers||o?.tables)&&r>0){if(null==a.layerId){const e=u(o);a.layerId="subtype-group"===a.type?e?.[0]:m(o)}e=C(o,a),e&&null!=o.showLegend&&(e.showLegend=o.showLegend)}return r>1&&"sublayerTitleMode"in a&&"service-name"!==a.sublayerTitleMode&&(a.sublayerTitleMode="item-title-and-service-name"),e}return o}async function P(e,r,a){if(r?.layers&&r?.tables)return f(r);const n=t(e.url);if(!n)return 1;const o=await a.fetchServiceMetadata(n.url.path).catch((()=>null));return(r?.layers?.length??o?.layers?.length??0)+(r?.tables?.length??o?.tables?.length??0)}function C(e,t){const{layerId:r}=t,a=e.layers?.find((e=>e.id===r))||e.tables?.find((e=>e.id===r));return a&&k(a,t)?a:null}function D(e){return"stream"!==e.type&&"layerId"in e}function k(e,t){return!("feature"===t.type&&"layerType"in e&&"SubtypeGroupLayer"===e.layerType||"subtype-group"===t.type&&!("layerType"in e))}async function E(e){const{layersJSON:t}=await r(e);if(!t)return null;const a=[...t.layers,...t.tables];return e=>a.find((t=>t.id===e.id))}export{g as load};
@@ -0,0 +1,4 @@
1
+ import "../../interfaces";
2
+
3
+ import FeatureService = __esri.FeatureService;
4
+ export default FeatureService;