@arcgis/core 4.34.0-next.23 → 4.34.0-next.24

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 (102) hide show
  1. package/arcade/parser.js +1 -1
  2. package/arcade/validation/arcadeValidator.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/026fbeb0ff5b9e6c74df.js +1 -0
  5. package/assets/esri/core/workers/chunks/234cbc290b074eeb5dd6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{00eef04fd026adaf0df8.js → 36a2a8b6547604bad2ab.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{63cc4647b7775ff8aedf.js → 44d28849e59f62616e72.js} +1 -1
  8. package/assets/esri/core/workers/chunks/4c47d327815e281c457e.js +1 -0
  9. package/assets/esri/core/workers/chunks/{6bb1ecaa0afc2c7de79e.js → 4cc3eeb0b824c53793d0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{19ae76283a0cb0fe4dee.js → 4ea96aff38bb301dc40d.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{cab1a1067f44ce374673.js → 7d7f8f2936ddee65e3da.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{b57c0ef7bc57e3c91257.js → 865fccacf44ae5b70eba.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{f43110391f124b8a179c.js → 909a6218db87cba2c9ba.js} +1 -1
  14. package/assets/esri/core/workers/chunks/a273f80298417edecc07.js +1 -0
  15. package/assets/esri/core/workers/chunks/{496e02cfe3d84010f675.js → a2ed7a3cd518dd136ec7.js} +1 -1
  16. package/assets/esri/core/workers/chunks/b32c1b60896a72e0ae90.js +1 -0
  17. package/assets/esri/core/workers/chunks/{6782114a752b9cc59168.js → b6b8272a74a5c24a6b86.js} +1 -1
  18. package/assets/esri/core/workers/chunks/b9f66d735a7e63417b3d.js +1 -0
  19. package/assets/esri/core/workers/chunks/d2ce360961ca4b58666c.js +1 -0
  20. package/assets/esri/core/workers/chunks/fe1902d63f610cebd947.js +1 -0
  21. package/chunks/Bufferer-Dw9Qi4T1.js +1 -1
  22. package/chunks/Envelope.js +1 -1
  23. package/chunks/MultiPathImpl.js +1 -1
  24. package/chunks/OperatorClip.js +1 -1
  25. package/chunks/ProjectionTransformation.js +1 -1
  26. package/chunks/index.js +1 -1
  27. package/config.js +1 -1
  28. package/core/MemCachePool.js +1 -1
  29. package/core/accessorSupport/overrideDefaultsFrom.js +1 -1
  30. package/geometry/operators/gx/operatorOffset.js +1 -1
  31. package/geometry/operators/support/jsonConverter.js +1 -1
  32. package/interfaces.d.ts +70 -2
  33. package/kernel.js +1 -1
  34. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  35. package/layers/orientedImagery/core/bestImageUtils.js +1 -1
  36. package/layers/support/ControlPointsGeoreference.js +1 -1
  37. package/layers/support/PixelBlock.js +1 -1
  38. package/layers/support/RasterJobHandler.js +1 -1
  39. package/layers/support/RasterWorker.js +1 -1
  40. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  41. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  42. package/layers/video/VideoController.js +1 -1
  43. package/networks/support/UtilityNetworkLookupHelper.js +1 -1
  44. package/package.json +1 -1
  45. package/renderers/support/DictionaryControlString.js +1 -1
  46. package/support/revision.js +1 -1
  47. package/symbols/cim/cimAnalyzer.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
  49. package/views/2d/layers/features/FeatureContainer.js +1 -1
  50. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  51. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  52. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  53. package/views/2d/layers/features/support/FeatureFilterEvaluator.js +1 -1
  54. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  55. package/views/3d/analysis/images/heading-rotate-svg.js +1 -1
  56. package/views/3d/analysis/images/tilt-rotate-svg.js +1 -1
  57. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  58. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  59. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  60. package/views/3d/state/ViewStateManager.js +1 -1
  61. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  62. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  63. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  64. package/views/VideoView.js +1 -1
  65. package/views/draw/MultipointDrawAction.js +1 -1
  66. package/views/draw/PointDrawAction.js +1 -1
  67. package/views/draw/PolygonDrawAction.js +1 -1
  68. package/views/draw/PolylineDrawAction.js +1 -1
  69. package/views/magnifier/mask-svg.js +1 -1
  70. package/views/magnifier/overlay-svg.js +1 -1
  71. package/webmap/Bookmark.js +1 -1
  72. package/webscene/spec-certification/spec.js +1 -1
  73. package/widgets/BasemapLayerList.js +1 -1
  74. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  75. package/widgets/Editor/support/SketchController.js +1 -1
  76. package/widgets/Editor/workflowUtils.js +1 -1
  77. package/widgets/Editor.js +1 -1
  78. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  79. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  80. package/widgets/LayerList.js +1 -1
  81. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  82. package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
  83. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  84. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  85. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
  86. package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
  87. package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
  88. package/widgets/OrientedImageryViewer.js +1 -1
  89. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  90. package/widgets/PanoramicViewer.js +1 -1
  91. package/widgets/Print.js +1 -1
  92. package/widgets/Sketch/SketchViewModel.js +1 -1
  93. package/widgets/Slider/SliderViewModel.js +1 -1
  94. package/widgets/support/SelectionList.js +1 -1
  95. package/assets/esri/core/workers/chunks/0ba6177ba118a0f032e2.js +0 -1
  96. package/assets/esri/core/workers/chunks/573a8393bec916dcf16f.js +0 -1
  97. package/assets/esri/core/workers/chunks/81006d9eed65bbb82962.js +0 -1
  98. package/assets/esri/core/workers/chunks/9f91d519da67714f915f.js +0 -1
  99. package/assets/esri/core/workers/chunks/ad3871f497ecea1a08c9.js +0 -1
  100. package/assets/esri/core/workers/chunks/cd64181298d82c8d0e9d.js +0 -1
  101. package/assets/esri/core/workers/chunks/def8a854a05f17d3538e.js +0 -1
  102. package/assets/esri/core/workers/chunks/f3d5d92e0aefc2593208.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import o from"../../core/Error.js";import t from"../../core/Loadable.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import r from"../../core/Promise.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import n from"../../core/ReactiveMap.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as p}from"../../layers/support/layerUtils.js";import{RuleType as l}from"./typeUtils.js";function c(e){return`${e.networkSource?.sourceId??""}-${e.assetGroup?.assetGroupCode??""}-${e.assetType?.assetTypeCode??""}`}let d=class extends(t.LoadableMixin(r)){constructor(e){super(e),this.layerIdToSourceIdLookup=new n,this.sourceIdToLayerIdLookup=new n,this.sourceIdToNetworkInfo=new n,this._rulesBySourceId=new Map,this._terminalConfigurationsBySourceId=new Map}async load(e){return this.addResolvingPromise(this._load(e)),this}agatFromRule(e,o){let t;switch(o){case"to":t={networkSource:e.toNetworkSource??null,assetGroup:e.toAssetGroup??null,assetType:e.toAssetType??null};break;case"from":t={networkSource:e.fromNetworkSource??null,assetGroup:e.fromAssetGroup??null,assetType:e.fromAssetType??null};break;case"via":t={networkSource:e.viaNetworkSource??null,assetGroup:e.viaAssetGroup??null,assetType:e.viaAssetType??null}}return null===t.networkSource?null:t}agatToFullDefinition({assetGroup:e,assetType:o,networkSourceId:t}){if(null===t||null===e||null===o)return null;const s={networkSource:null,assetGroup:null,assetType:null},r=this.sourceIdToNetworkInfo.get(t);if(!r)return null;s.networkSource=r;const u=r.assetGroupLookup.get(e);return u?(s.assetGroup=u,s.assetType=u.assetTypeLookup.get(o)??null,null===s.assetType?null:s):null}findAgat(e,t){const s=p(t)?t.parent:t;if(!s)throw new o("utility-network:missing-layer","Unable to find asset group/asset type for layer. The given layer is a `SubtypeSublayer` with no parent.");if(this.utilityNetwork.featureServiceUrl!==s.url)return null;const r=this.getNetworkSourceIdForLayer(s);if(null===r)return null;const u=s.fieldsIndex.get("assettype")?.name??"";if(""===u)return null;const n=s.fieldsIndex.get("assetgroup")?.name??"";if(""===n)return null;const a=e.attributes[u],i=e.attributes[n];return null==a||null==i?null:{assetGroup:i,assetType:a,networkSourceId:r}}findAgatFullDefinition(e,o){const t=this.findAgat(e,o);return t?this.agatToFullDefinition(t):null}findRules({networkSourceId:e,assetGroup:o,assetType:t}){const s=[];if(null===e||null===o)return s;const r=this._rulesBySourceId.get(e)?.get(o);if(!r)return s;for(const u of r.generalRules)s.push(u);if(null!=t){const e=r.typeSpecificRules.get(t);if(e)for(const o of e)s.push(o)}return s}getNetworkSourceIdForLayer(e){const o=p(e)?e.parent:e;return o&&this.utilityNetwork.featureServiceUrl===o.url?this.layerIdToSourceIdLookup.get(o.layerId)??null:null}ruleMatchesAgat(e,o,t){switch(t){case"to":return!(e.toNetworkSource?.sourceId!==o.networkSourceId||e.toAssetGroup&&e.toAssetGroup.assetGroupCode!==o.assetGroup||e.toAssetType&&e.toAssetType.assetTypeCode!==o.assetType);case"from":return!(e.fromNetworkSource?.sourceId!==o.networkSourceId||e.fromAssetGroup&&e.fromAssetGroup.assetGroupCode!==o.assetGroup||e.fromAssetType&&e.fromAssetType.assetTypeCode!==o.assetType);case"via":return!(e.viaNetworkSource?.sourceId!==o.networkSourceId||e.viaAssetGroup&&e.viaAssetGroup.assetGroupCode!==o.assetGroup||e.viaAssetType&&e.viaAssetType.assetTypeCode!==o.assetType)}}ruleMatchesFullDefinitionAgat(e,o,t){switch(t){case"to":return!(e.toNetworkSource?.sourceId!==o.networkSource?.sourceId||e.toAssetGroup&&e.toAssetGroup.assetGroupCode!==o.assetGroup?.assetGroupCode||e.toAssetType&&e.toAssetType.assetTypeCode!==o.assetType?.assetTypeCode);case"from":return!(e.fromNetworkSource?.sourceId!==o.networkSource?.sourceId||e.fromAssetGroup&&e.fromAssetGroup.assetGroupCode!==o.assetGroup?.assetGroupCode||e.fromAssetType&&e.fromAssetType.assetTypeCode!==o.assetType?.assetTypeCode);case"via":return!(e.viaNetworkSource?.sourceId!==o.networkSource?.sourceId||e.viaAssetGroup&&e.viaAssetGroup.assetGroupCode!==o.assetGroup?.assetGroupCode||e.viaAssetType&&e.viaAssetType.assetTypeCode!==o.assetType?.assetTypeCode)}}terminalConfiguration(e,o,t){const s=this._terminalConfigurationsBySourceId.get(e);if(!s)return null;const r=s.get(o);if(!r)return null;const u=r.get(t);return u||null}async _load(e){await this.utilityNetwork.load(),u(e);const{dataElement:t}=this.utilityNetwork;if(!t)throw new o("utility-network:no-data-element","No data element found on utility network");for(const o of t.domainNetworks)for(const e of[...o.edgeSources??[],...o.junctionSources??[]]){this.layerIdToSourceIdLookup.set(e.layerId,e.sourceId),this.sourceIdToLayerIdLookup.set(e.sourceId,e.layerId);const o=(e.assetGroups??[]).map(e=>{const o=new n;for(const t of e.assetTypes??[])o.set(t.assetTypeCode,t);return{...e,assetTypeLookup:o}}),t=new n;for(const e of o)t.set(e.assetGroupCode,e);const s={...e,assetGroupLookup:t,assetGroups:o};this.sourceIdToNetworkInfo.set(s.sourceId,s)}const s=await this.utilityNetwork.getRulesTable();u(e);for(const o of s?.rules??[])switch(o.ruleType){case l.RTAttachment:case l.RTContainment:this._registerRule(o.fromNetworkSource.sourceId,o.fromAssetGroup.assetGroupCode,o.fromAssetType.assetTypeCode,o),this._registerRule(o.toNetworkSource.sourceId,o.toAssetGroup.assetGroupCode,o.toAssetType.assetTypeCode,o);break;case l.RTEdgeJunctionEdgeConnectivity:this._registerRule(o.fromNetworkSource.sourceId,o.fromAssetGroup.assetGroupCode,o.fromAssetType.assetTypeCode,o),this._registerRule(o.toNetworkSource.sourceId,o.toAssetGroup.assetGroupCode,o.toAssetType.assetTypeCode,o),this._registerRule(o.viaNetworkSource.sourceId,o.viaAssetGroup.assetGroupCode,o.viaAssetType.assetTypeCode,o);break;case l.RTJunctionEdgeConnectivity:case l.RTJunctionJunctionConnectivity:this._registerRule(o.fromNetworkSource.sourceId,o.fromAssetGroup.assetGroupCode,o.fromAssetType.assetTypeCode,o),this._registerRule(o.toNetworkSource.sourceId,o.toAssetGroup.assetGroupCode,o.toAssetType.assetTypeCode,o)}this._makeTerminalConfigurationLookups(t)}_makeTerminalConfigurationLookups(e){const o={};for(const t of e.terminalConfigurations??[])o[t.terminalConfigurationId]=t;for(const t of e.domainNetworks??[])for(const e of t.junctionSources)if("esriUNFCUTJunctionObject"===e.utilityNetworkFeatureClassUsageType||"esriUNFCUTDevice"===e.utilityNetworkFeatureClassUsageType)for(const t of e.assetGroups??[])for(const r of t.assetTypes??[])if(null!=r.terminalConfigurationId&&r.terminalConfigurationId>=0){const u=o[r.terminalConfigurationId];if(u){const o=s(this._terminalConfigurationsBySourceId,e.sourceId,()=>new Map);s(o,t.assetGroupCode,()=>new Map).set(r.assetTypeCode,u)}}}_registerRule(e,o,t,r){const u=s(this._rulesBySourceId,e,()=>new Map),n=s(u,o,()=>({generalRules:[],typeSpecificRules:new Map}));if(-1===t)n.generalRules.push(r);else{s(n.typeSpecificRules,t,()=>[]).push(r)}}};e([a()],d.prototype,"layerIdToSourceIdLookup",void 0),e([a()],d.prototype,"sourceIdToLayerIdLookup",void 0),e([a()],d.prototype,"sourceIdToNetworkInfo",void 0),e([a()],d.prototype,"utilityNetwork",void 0),d=e([i("esri.networks.support.UtilityNetworkLookupHelper")],d);export{d as UtilityNetworkLookupHelper,c as hashAgat};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import o from"../../core/Error.js";import t from"../../core/Loadable.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import r from"../../core/Promise.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import n from"../../core/ReactiveMap.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as p}from"../../layers/support/layerUtils.js";import{RuleType as l}from"./typeUtils.js";function c(e){return`${e.networkSource?.sourceId??""}-${e.assetGroup?.assetGroupCode??""}-${e.assetType?.assetTypeCode??""}`}let d=class extends(t.LoadableMixin(r)){constructor(e){super(e),this.layerIdToSourceIdLookup=new n,this.sourceIdToLayerIdLookup=new n,this.sourceIdToNetworkInfo=new n,this._rulesBySourceId=new Map,this._terminalConfigurationsBySourceId=new Map}async load(e){return this.addResolvingPromise(this._load(e)),this}agatFromRule(e,o){let t;switch(o){case"to":t={networkSource:e.toNetworkSource??null,assetGroup:e.toAssetGroup??null,assetType:e.toAssetType??null};break;case"from":t={networkSource:e.fromNetworkSource??null,assetGroup:e.fromAssetGroup??null,assetType:e.fromAssetType??null};break;case"via":t={networkSource:e.viaNetworkSource??null,assetGroup:e.viaAssetGroup??null,assetType:e.viaAssetType??null}}return null===t.networkSource?null:t}agatToFullDefinition({assetGroup:e,assetType:o,networkSourceId:t}){if(null===t||null===e||null===o)return null;const s={networkSource:null,assetGroup:null,assetType:null},r=this.sourceIdToNetworkInfo.get(t);if(!r)return null;s.networkSource=r;const u=r.assetGroupLookup.get(e);return u?(s.assetGroup=u,s.assetType=u.assetTypeLookup.get(o)??null,null===s.assetType?null:s):null}findAgat(e,t){const s=p(t)?t.parent:t;if(!s)throw new o("utility-network:missing-layer","Unable to find asset group/asset type for layer. The given layer is a `SubtypeSublayer` with no parent.");if(this.utilityNetwork.featureServiceUrl!==s.url)return null;const r=this.getNetworkSourceIdForLayer(s);if(null===r)return null;const u=s.fieldsIndex.get("assettype")?.name??"";if(""===u)return null;const n=s.fieldsIndex.get("assetgroup")?.name??"";if(""===n)return null;const a=e.attributes[u],i=e.attributes[n];return null==a||null==i?null:{assetGroup:i,assetType:a,networkSourceId:r}}findAgatFullDefinition(e,o){const t=this.findAgat(e,o);return t?this.agatToFullDefinition(t):null}findRules({networkSourceId:e,assetGroup:o,assetType:t}){const s=[];if(null===e||null===o)return s;const r=this._rulesBySourceId.get(e)?.get(o);if(!r)return s;for(const u of r.generalRules)s.push(u);if(null!=t){const e=r.typeSpecificRules.get(t);if(e)for(const o of e)s.push(o)}return s}getNetworkSourceIdForLayer(e){const o=p(e)?e.parent:e;return o&&this.utilityNetwork.featureServiceUrl===o.url?this.layerIdToSourceIdLookup.get(o.layerId)??null:null}ruleMatchesAgat(e,o,t){switch(t){case"to":return!(e.toNetworkSource?.sourceId!==o.networkSourceId||e.toAssetGroup&&e.toAssetGroup.assetGroupCode!==o.assetGroup||e.toAssetType&&e.toAssetType.assetTypeCode!==o.assetType);case"from":return!(e.fromNetworkSource?.sourceId!==o.networkSourceId||e.fromAssetGroup&&e.fromAssetGroup.assetGroupCode!==o.assetGroup||e.fromAssetType&&e.fromAssetType.assetTypeCode!==o.assetType);case"via":return!(e.viaNetworkSource?.sourceId!==o.networkSourceId||e.viaAssetGroup&&e.viaAssetGroup.assetGroupCode!==o.assetGroup||e.viaAssetType&&e.viaAssetType.assetTypeCode!==o.assetType)}}ruleMatchesFullDefinitionAgat(e,o,t){switch(t){case"to":return!(e.toNetworkSource?.sourceId!==o.networkSource?.sourceId||e.toAssetGroup&&e.toAssetGroup.assetGroupCode!==o.assetGroup?.assetGroupCode||e.toAssetType&&e.toAssetType.assetTypeCode!==o.assetType?.assetTypeCode);case"from":return!(e.fromNetworkSource?.sourceId!==o.networkSource?.sourceId||e.fromAssetGroup&&e.fromAssetGroup.assetGroupCode!==o.assetGroup?.assetGroupCode||e.fromAssetType&&e.fromAssetType.assetTypeCode!==o.assetType?.assetTypeCode);case"via":return!(e.viaNetworkSource?.sourceId!==o.networkSource?.sourceId||e.viaAssetGroup&&e.viaAssetGroup.assetGroupCode!==o.assetGroup?.assetGroupCode||e.viaAssetType&&e.viaAssetType.assetTypeCode!==o.assetType?.assetTypeCode)}}terminalConfiguration(e,o,t){const s=this._terminalConfigurationsBySourceId.get(e);if(!s)return null;const r=s.get(o);if(!r)return null;const u=r.get(t);return u||null}async _load(e){await this.utilityNetwork.load(),u(e);const{dataElement:t}=this.utilityNetwork;if(!t)throw new o("utility-network:no-data-element","No data element found on utility network");for(const o of t.domainNetworks)for(const e of[...o.edgeSources??[],...o.junctionSources??[]]){this.layerIdToSourceIdLookup.set(e.layerId,e.sourceId),this.sourceIdToLayerIdLookup.set(e.sourceId,e.layerId);const o=(e.assetGroups??[]).map(e=>{const o=new n;for(const t of e.assetTypes??[])o.set(t.assetTypeCode,t);return{...e,assetTypeLookup:o}}),t=new n;for(const e of o)t.set(e.assetGroupCode,e);const s={...e,assetGroupLookup:t,assetGroups:o};this.sourceIdToNetworkInfo.set(s.sourceId,s)}const s=await this.utilityNetwork.getRulesTable();u(e);for(const o of s?.rules??[])switch(o.ruleType){case l.RTAttachment:case l.RTContainment:this._registerRule(o.fromNetworkSource.sourceId,o.fromAssetGroup.assetGroupCode,o.fromAssetType.assetTypeCode,o),this._registerRule(o.toNetworkSource.sourceId,o.toAssetGroup.assetGroupCode,o.toAssetType.assetTypeCode,o);break;case l.RTEdgeJunctionEdgeConnectivity:this._registerRule(o.fromNetworkSource.sourceId,o.fromAssetGroup.assetGroupCode,o.fromAssetType.assetTypeCode,o),this._registerRule(o.toNetworkSource.sourceId,o.toAssetGroup.assetGroupCode,o.toAssetType.assetTypeCode,o),this._registerRule(o.viaNetworkSource.sourceId,o.viaAssetGroup.assetGroupCode,o.viaAssetType.assetTypeCode,o);break;case l.RTJunctionEdgeConnectivity:case l.RTJunctionJunctionConnectivity:this._registerRule(o.fromNetworkSource.sourceId,o.fromAssetGroup.assetGroupCode,o.fromAssetType.assetTypeCode,o),this._registerRule(o.toNetworkSource.sourceId,o.toAssetGroup.assetGroupCode,o.toAssetType.assetTypeCode,o)}this._makeTerminalConfigurationLookups(t)}_makeTerminalConfigurationLookups(e){const o={};for(const t of e.terminalConfigurations??[])o[t.terminalConfigurationId]=t;for(const t of e.domainNetworks??[])for(const e of t.junctionSources)if("esriUNFCUTJunctionObject"===e.utilityNetworkFeatureClassUsageType||"esriUNFCUTDevice"===e.utilityNetworkFeatureClassUsageType)for(const t of e.assetGroups??[])for(const r of t.assetTypes??[])if(null!=r.terminalConfigurationId&&r.terminalConfigurationId>=0){const u=o[r.terminalConfigurationId];if(u){const o=s(this._terminalConfigurationsBySourceId,e.sourceId,()=>new Map);s(o,t.assetGroupCode,()=>new Map).set(r.assetTypeCode,u)}}}_registerRule(e,o,t,r){const u=s(this._rulesBySourceId,e,()=>new Map),n=s(u,o,()=>({generalRules:[],typeSpecificRules:new Map}));if(-1!==t){return void s(n.typeSpecificRules,t,()=>[]).push(r)}n.generalRules.push(r)}};e([a()],d.prototype,"layerIdToSourceIdLookup",void 0),e([a()],d.prototype,"sourceIdToLayerIdLookup",void 0),e([a()],d.prototype,"sourceIdToNetworkInfo",void 0),e([a()],d.prototype,"utilityNetwork",void 0),d=e([i("esri.networks.support.UtilityNetworkLookupHelper")],d);export{d as UtilityNetworkLookupHelper,c as hashAgat};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.34.0-next.23",
3
+ "version": "4.34.0-next.24",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";class t{static parse(e,r,n){const l=[],o=[],u=e.split(";");for(let t=0;t<u.length;t++){const e=u[t];if(e)if(e.includes("po:")){const t=e.slice(3).split("|");if(3===t.length){const[e,r,i]=t,n=s(e,r,i);n&&o.push(n)}}else if(e.includes("|")){for(const t of e.split("|"))if(r.has(t)){l.push(t);break}}else if(r.has(e))l.push(e);else if(0===t){l.length=0,l.push(i(n));break}}return new t(l,o)}constructor(e,t){this.partNames=e,this.overrides=t}}function r(t,r){if("DashTemplate"===t)return r.split(" ").map(e=>Number(e));if("Color"===t){const t=new e(r).toRgba();return[t[0],t[1],t[2],255*t[3]]}return Number(r)}function s(e,t,s){return{primitiveName:e,propertyName:t,value:r(t,s),defaultValue:null}}function i(e){switch(e){case"esriGeometryPolyline":return"Invalid_L";case"esriGeometryPolygon":return"Invalid_A";default:return"Invalid_P"}}export{t as DictionaryControlString};
5
+ import e from"../../Color.js";class t{static parse(e,r,i){const o=[],l=[],u=e.split(";");for(let t=0;t<u.length;t++){const e=u[t];if(e){if(e.includes("po:")){const t=e.slice(3).split("|");if(3===t.length){const[e,r,n]=t,i=s(e,r,n);i&&l.push(i)}continue}if(e.includes("|")){for(const t of e.split("|"))if(r.has(t)){o.push(t);break}}else if(r.has(e))o.push(e);else if(0===t){o.length=0,o.push(n(i));break}}}return new t(o,l)}constructor(e,t){this.partNames=e,this.overrides=t}}function r(t,r){if("DashTemplate"===t)return r.split(" ").map(e=>Number(e));if("Color"===t){const t=new e(r).toRgba();return[t[0],t[1],t[2],255*t[3]]}return Number(r)}function s(e,t,s){return{primitiveName:e,propertyName:t,value:r(t,s),defaultValue:null}}function n(e){switch(e){case"esriGeometryPolyline":return"Invalid_L";case"esriGeometryPolygon":return"Invalid_A";default:return"Invalid_P"}}export{t as DictionaryControlString};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- const a="20250621",c="ea00436b45a50c3f8afd9a8a4c601a1640a36508";export{a as buildDate,c as commitHash};
5
+ const d="20250624",b="bbc458d452dd1d67fe9b453d6566eb5a4d9bd351";export{d as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as t}from"../../core/fontUtils.js";import"../../core/has.js";import{clone as r}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAbsoluteAnchor as p,handleMarker as c,handleRelativeAnchor as m,getFrameTranslation as y,translate as d,getStaticParam as h,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as u}from"./CIMSymbolHelper.js";import{antialiasingOutlineFillSettings as v}from"./constants.js";import{defaultCIMValues as O}from"./defaultCIMValues.js";import{Alignment as g,SymbolUnits as _}from"./enums.js";import{fitVectorMarker as S}from"./fitVectorMarker.js";import{OverrideHelper as M}from"./OverrideHelper.js";import{getExtent as k,getSDFMetrics as C,getSDFDimensions as b}from"./SDFHelper.js";import{colorToArray as x,normalizeAlpha as P,getSize as z,isCIMMarkerStrokePlacement as E,hasStrokeLayer as I,getTintColor as L,getNumericValue as V,normalizePrimitiveOverrideProps as N,getDefaultCIMValue as R,getEnum as A,getStrokeWidth as w,getFillColor as G,getStrokeColor as T,fromCIMFontDecoration as F,fromCIMFontStyle as X,fromCIMVerticalAlignment as j,fromCIMHorizontalAlignment as Y,getTextCasing as W,isValidCIMValue as D,uncapitalize as U}from"./utils.js";import{CIMEffectHelper as H}from"./effects/CIMEffectHelper.js";import{rasterizedVectorMarkerMinSize as J,randomInsidePolygonTextureSize as B}from"../../views/2d/engine/webgl/definitions.js";const q=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function K(e){const t=e.markerPlacement;return t&&t.angleToLine?g.MAP:g.SCREEN}class Q{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._hasTextStringTemplates=!1,e&&(this._resourceManager=e)}analyzeSymbolReference(t,r,i){if(this._cimLayers=i??[],!t)return this._cimLayers;if(this._reset(),this._hasTextStringTemplates=t.hasTextStringTemplates??!1,t.primitiveOverrides){this._primitiveOverrides=t.primitiveOverrides;for(const t of this._primitiveOverrides){const r=t.valueExpressionInfo;if(r)this._setPoMap(t.primitiveName,t.propertyName,r);else if(null!=t.value){let r=t.value;t.propertyName.includes("Color")&&(e(r)&&(r=x(r)),r=P(r)),this._setPoMap(t.primitiveName,t.propertyName,r)}}}return this._analyzeSymbol(t.symbol,r),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t)}}_analyzeMultiLayerSymbol(e,t){const r=e?.symbolLayers;if(!r)return;for(let l=0;l<r.length;l++){const e=r[l];"CIMVectorMarker"===e.type&&(r[l]=S(e,this._resourceManager.geometryEngine))}const i=e.effects;let o=g.SCREEN;const a=z(e)??0;if("CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=g.MAP),oe(r,i))return this._analyzeCompositeOutlineFill(r,i,a);let s={transform:[0,0,0,1],fromColor:[1,1,1,1],toColor:[1,1,1,1],colorMix:[0,0,0,0],toOpacity:[1,1,1,1],opacityMix:[0,0,0,0],shift:[1,1,1,1],hasAnimations:l(e),hasShiftAnimation:!1,hasMotionAnimations:!1};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=r.length;for(;c--;){const l=r[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let y=null;if(n){y=[];for(const e of n){const t=M.findEffectOverrides(e,this._primitiveOverrides);t&&y.push(t)}}const d=[];switch(M.findApplicableOverrides(l,this._primitiveOverrides,d),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,y,s,I(r));break;case"CIMPictureFill":this._analyzePictureFill(l,y,s);break;case"CIMHatchFill":this._analyzeHatchFill(l,y);break;case"CIMGradientFill":this._analyzeGradientFill(l,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,y,p,a,s);break;case"CIMPictureStroke":this._analyzePictureStroke(l,y,p,a,s);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,y,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=K(l));const r=[],i=l.primitiveName;i&&r.push(i);const n=p&&E(l.markerPlacement);this._analyzeMarker(l,y,null,r,o,a,t,[],s,!1,n);break}default:q().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,t,r,i){const{primitiveName:o,type:a}=e,s=P(e.color),l=n(this._poMap,e,r);if(i||!t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.effect.type))this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(a,o,"Color",s),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1,animationParams:se(l)});else{const r=this._getValueOrOverrideExpression(a,o,"Color",s);this._cimLayers.push({type:"outlineFill",colorLocked:!!e.colorLocked,color:r,effects:t,outlineColor:r,outlineColorLocked:!!e.colorLocked,...v,outlineEffects:t})}}_analyzePictureFill(e,t,r){const{primitiveName:i,type:o}=e,a=L(e),s=V(e.height,O.CIMPictureFill.height);let l=V(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height),l/=r*(s/t)}const p={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(i,o)},c=n(this._poMap,e,r);this._cimLayers.push({type:"fill",spriteRasterizationParam:p,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(o,i,"TintColor",a),height:this._getValueOrOverrideExpression(o,i,"Height",s),scaleX:this._getValueOrOverrideExpression(o,i,"ScaleX",l),angle:this._getValueOrOverrideExpression(o,i,"Rotation",V(e.rotation)),offsetX:this._getValueOrOverrideExpression(o,i,"OffsetX",V(e.offsetX)),offsetY:this._getValueOrOverrideExpression(o,i,"OffsetY",V(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1,animationParams:se(c)})}_analyzeHatchFill(e,t){const{primitiveName:r,type:i}=e,o=this._analyzeMaterialOverrides(r,["Rotation","OffsetX","OffsetY"]),a=N(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??r;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=P(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const t=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(t){let r=null,o=null;"number"==typeof t?r=t:o=t.valueExpressionInfo;let s=a.find(e=>"strokeWidth"===e.propertyName);s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:r,defaultValue:R(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:t,color:s,height:this._getValueOrOverrideExpression(i,r,"Separation",V(e.separation,O.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,r,"Rotation",V(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,r,"OffsetX",V(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,r,"OffsetY",V(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,t){const{angle:r,gradientMethod:i,gradientSize:o,gradientSizeUnits:a,gradientType:s,interval:l,primitiveName:n,type:p}=e,c=O.CIMGradientFill,m=e.colorRamp;this._cimLayers.push({type:"gradientFill",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(n,p)},colorLocked:!1,effects:t,color:[255,255,255,1],gradientMethod:this._getValueOrOverrideExpression(p,n,"GradientMethod",i??"Linear"),angle:this._getValueOrOverrideExpression(p,n,"Angle",V(r,c.angle)),gradientType:this._getValueOrOverrideExpression(p,n,"GradientType",s??c.gradientType),interval:this._getValueOrOverrideExpression(p,n,"Interval",V(l,"CIMFixedColorRamp"===m.type?m.colors.length:c.interval)),gradientSize:this._getValueOrOverrideExpression(p,n,"GradientSize",V(o,c.gradientSize)),gradientSizeUnits:"Absolute"===a?_.Absolute:"Relative"===a?_.Relative:c.gradientSizeUnits})}_analyzeCompositeOutlineFill(e,t,r){const i=e.find(e=>"CIMSolidFill"===e.type),o=e.find(e=>"CIMSolidStroke"===e.type);if(null==i||null==o)return;const a=[...t??[],...i.effects??[]].map(e=>M.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),s=[...t??[],...o.effects??[]].map(e=>M.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),l=V(o.width,O.CIMSolidStroke.width),n=A(o.capStyle,O.CIMSolidStroke.capstyle),p=A(o.joinStyle,O.CIMSolidStroke.joinstyle),c=o.miterLimit;this._cimLayers.push({type:"outlineFill",colorLocked:!!i.colorLocked,color:this._getValueOrOverrideExpression(i.type,i.primitiveName,"Color",P(i.color)),effects:a,outlineColorLocked:!!o.colorLocked,outlineColor:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Color",P(o.color)),outlineWidth:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Width",l),cap:this._getValueOrOverrideExpression(o.type,o.primitiveName,"CapStyle",n),join:this._getValueOrOverrideExpression(o.type,o.primitiveName,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(o.type,o.primitiveName,"MiterLimit",c),referenceWidth:r,outlineEffects:s})}_analyzeSolidStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=P(e.color),p=V(e.width,O.CIMSolidStroke.width),c=A(e.capStyle,O.CIMSolidStroke.capstyle),m=A(e.joinStyle,O.CIMSolidStroke.joinstyle),y=e.miterLimit;let d,h,f,u,v=[];if(this._analyzePrimitiveOverrides(a,t,null,null)&&(v=this._getPrimitiveMaterialOverrides(a,s)),t&&Array.isArray(t)&&t.length>0){const e=t[t.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(d=e.dashTemplate,h=e.scaleDash,f=e.offsetAlongLine,u=e.primitiveName,(t=[...t]).pop())}null!=u&&v.push(...this._getPrimitiveMaterialOverrides(u,s).filter(e=>"dashTemplate"===e.propertyName));const g=void 0!==d?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:d,primitiveName:u},overrides:v}:null,_=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:g,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"Color",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:$(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(u,"DashTemplate")??d,offsetAlongLine:this._getValueOrOverrideExpression(s,u,"OffsetAlongLine",f??0),scaleDash:h,sampleAlphaOnly:!0,animationParams:se(_)})}_analyzePictureStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=L(e),p=V(e.width,O.CIMPictureStroke.width),c=A(e.capStyle,O.CIMPictureStroke.capstyle),m=A(e.joinStyle,O.CIMPictureStroke.joinstyle),y=e.miterLimit,d={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(a,s)},h=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:d,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"TintColor",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:$(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1,animationParams:se(h)})}_analyzeGradientStroke(e,t,r,i){const{gradientMethod:o,gradientSize:a,gradientSizeUnits:s,gradientType:l,interval:n,primitiveName:p,type:c}=e,m=O.CIMGradientStroke,y=V(e.width,m.width),d=A(e.capStyle,m.capstyle),h=A(e.joinStyle,m.joinstyle),f=e.miterLimit,u=e.colorRamp;this._cimLayers.push({type:"gradientStroke",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(p,c)},colorLocked:!!e.colorLocked,effects:t,color:[255,255,255,1],width:this._getValueOrOverrideExpression(c,p,"Width",y),cap:this._getValueOrOverrideExpression(c,p,"CapStyle",d),join:this._getValueOrOverrideExpression(c,p,"JoinStyle",h),miterLimit:f&&this._getValueOrOverrideExpression(c,p,"MiterLimit",f),referenceWidth:i,isOutline:r,gradientMethod:this._getValueOrOverrideExpression(c,p,"GradientMethod",o??m.gradientMethod),gradientType:this._getValueOrOverrideExpression(c,p,"GradientType",l??m.gradientType),interval:this._getValueOrOverrideExpression(c,p,"Interval",V(n,"CIMFixedColorRamp"===u.type?u.colors.length:m.interval)),gradientSize:this._getValueOrOverrideExpression(c,p,"GradientSize",V(a,m.gradientSize)),gradientSizeUnits:"Absolute"===s?_.Absolute:"Relative"===s?_.Relative:m.gradientSizeUnits})}_analyzeMarker(e,t,r,i,o,a,s,l,y,d=!1,h=!1){d||=!!e.colorLocked;let f=y;if(f=p(e,f),f=c(this._poMap,e,f),f=m(e,f),f=n(this._poMap,e,f),this._analyzeMarkerInsidePolygon(e,t,d,f))return;const u=V(e.size,O.CIMVectorMarker.size),v=V(e.rotation),g=V(e.offsetX),_=V(e.offsetY),{primitiveName:S,type:M}=e,k=this._getValueOrOverrideExpression(M,S,"Size",u),C=this._getValueOrOverrideExpression(M,S,"Rotation",v),b=this._getValueOrOverrideExpression(M,S,"OffsetX",g),x=this._getValueOrOverrideExpression(M,S,"OffsetY",_);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,r,i,o,a,k,C,b,x,l,f,d,h);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,r,i,o,a,k,C,b,x,l,f,s,d,h)}}_analyzeMarkerInsidePolygon(e,t,r,i){const{markerPlacement:o,type:s}=e;if(!o||"CIMMarkerPlacementInsidePolygon"!==o.type||i.hasMotionAnimations)return!1;if("CIMVectorMarker"===s||"CIMPictureMarker"===s){const r=e.primitiveName;if(r&&this._analyzePrimitiveOverrides([r],t,null,null))return!1;const i=o.primitiveName;if(i&&this._analyzePrimitiveOverrides([i],t,null,null))return!1;if("CIMVectorMarker"===s){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const l=Math.abs(o.stepX),n=Math.abs(o.stepY);if(0===l||0===n)return!0;let p,c;if("Random"===o.gridType){const e=a(B),t=Math.max(Math.floor(e/l),1);p=n*Math.max(Math.floor(e/n),1);c=t*l/p}else o.shiftOddRows?(p=2*n,c=l/n*.5):(p=n,c=l/n);const m=L(e),y="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:y,colorLocked:r,effects:t,color:m,height:p,scaleX:c,angle:o.gridAngle,offsetX:V(o.offsetX),offsetY:V(o.offsetY),applyRandomOffset:"Random"===o.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,t,i,o,a,l,n,p,c,m,y,d,h,f){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let g=V(e.scaleX,1);const _=L(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),M=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height);g/=r*(V(e.size)/t)}const k=[...o];let C;e.primitiveName&&k.push(e.primitiveName),u||S?C={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(C=r(e),C.markerPlacement=null);const b={type:"sprite-rasterization-param",resource:C,overrides:this._getMaterialOverrides(k,O)};S&&b.overrides.push(...S.overrides);const x=n;this._cimLayers.push({type:"marker",spriteRasterizationParam:b,colorLocked:h,effects:t,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",g),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(O,v,"TintColor",_),anchorPoint:{x:M.x,y:M.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:f,markerPlacement:i,animationParams:se(d),baseSize:x})}_analyzeVectorMarker(e,t,r,i,o,a,s,l,p,c,m,f,u,v,O){const g=e.markerGraphics;if(!g)return;const _=e.frame;let S=0;S=_?_.ymax-_.ymin:a;const M=!!e.scaleSymbolsProportionally;if(S){const t={offsetX:p,offsetY:c,rotation:l,size:s,frameHeight:S,rotateClockWise:!!e.rotateClockwise,absoluteAnchorPoint:!1,scaleSymbolsProportionally:M};m=[...m,t]}r||(r=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const k of g)if(k){const s=k.symbol;if(!s)continue;const l=k.primitiveName;l&&i.push(l);let p,c=f;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let t=0,r=0;const i=k.geometry;"x"in i&&"y"in i&&(t+=i.x-.5*(_.xmin+_.xmax),r+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;let a=!1;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,r-=o.y,a=!0):_&&(t-=(_.xmax-_.xmin)*o.x,r-=(_.ymax-_.ymin)*o.y));const s={offsetX:t,offsetY:r,rotation:0,size:0,frameHeight:0,rotateClockWise:!1,absoluteAnchorPoint:a,scaleSymbolsProportionally:M};p=[...m,s]}const g=k.geometry,[C,b]=y(g,_);switch(0===C&&0===b||(c=d(c,C,b)),"CIMPointSymbol"===s.type&&(c=n(this._poMap,s,c)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":u||re(s)?(c={...c,transform:{type:"AnimatedTransform",relativeTranslation:!1,absoluteScale:!0,translation:h([0,0]),rotation:h(0),scale:h(S),parent:f.transform}},this._analyzeMultiLayerGraphicNonSDF(e,t,r,k,i,o,a,p??m,c,S,v,O)):this._analyzeMultiLayerGraphic(e,t,r,k,i,o,a,p??m,c,S,v,O);break;case"CIMTextSymbol":this._analyzeTextGraphic(t,r,k,i,o,a,p??m,v)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,t,r,i,o,a,s,l,n,p,c,m){const y=i.symbol.symbolLayers;y&&(!te(y)||f(n)?ie(y)?this._analyzeMultiLayerGraphicNonSDF(e,t,r,i,o,a,s,l,n,p,!!c,m):this._analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,n,p,c,m):this._analyzeCompositeMarkerGraphic(e,t,r,i,y,a,s,l,p,c,m))}_analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,p,c,m,y){const d=i.symbol,h=d.symbolLayers;if(!h)return;const f=this._resourceManager.geometryEngine,u=H.applyEffects(d.effects,i.geometry,f);if(!u)return;let v=h.length;for(;v--;){const d=h[v];if(!d||!1===d.enable)continue;const g=d.primitiveName;switch(g&&o.push(g),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=H.applyEffects(d.effects,u,f),h=k(o);if(!h)continue;const v="Relative"!==e.anchorPointUnits,_=w(d)??0,{frameSizeRatio:S,anchorX:M,anchorY:x,widthRatio:z,sdfPaddingRatio:E}=C(h,e.frame,e.size,e.anchorPoint,v,_,e.scaleSymbolsProportionally),I="CIMSolidFill"===d.type,L={type:"sdf",geom:o,sdfPaddingRatio:E,asFill:I},{path:N}=d,R=I?P(G(d)):null==N?P(T(d)):[0,0,0,0],A=I?[0,0,0,0]:P(T(d));if(!I&&!_)break;const F=i.primitiveName;let X=null;I&&!d.colorLocked&&(X=this._maybeGetValueOrOverrideExpression(F,"FillColor"));let j=null;I||d.colorLocked||(j=this._maybeGetValueOrOverrideExpression(F,"StrokeColor"));const Y=X??this._getValueOrOverrideExpression(d.type,g,"Color",R),W=j??this._getValueOrOverrideExpression(d.type,g,"Color",A),D=this._maybeGetValueOrOverrideExpression(F,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,g,"Width",_),U=N?{type:"sprite-rasterization-param",resource:{type:"path",path:N,asFill:I},overrides:[]}:{type:"sprite-rasterization-param",resource:L,overrides:[]},J=n(this._poMap,d,p),B=V(e.size,O.CIMVectorMarker.size),q=this._getValueOrOverrideExpression(e.type,e.primitiveName,"Size",B);this._cimLayers.push({type:"marker",spriteRasterizationParam:U,colorLocked:!!d.colorLocked||!!m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:M,y:x},isAbsoluteAnchorPoint:v,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:z,rotateClockwise:!1,referenceSize:s,sizeRatio:S,color:Y,outlineColor:W,outlineWidth:D,isOutline:y,markerPlacement:r,animationParams:se(J),isStroke:"CIMSolidFill"!==d.type,baseSize:q,...b(o,E)});break}case"CIMPictureMarker":case"CIMVectorMarker":if(d.markerPlacement){q().error("Error analyzing CIM, got unexpected marker placement");break}this._analyzeMarker(d,t,r,o,a,s,!1,l,p,m,y)}g&&o.pop()}}_analyzeTextGraphic(e,r,i,o,a,s,l,n){const p=[];M.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,y=F(m),d=X(m.fontStyleName),h=t(m.fontFamilyName);m.font={family:h,decoration:y,...d};const f=V(m.height,O.CIMTextSymbol.height),u=V(m.angle),v=V(m.offsetX),g=V(m.offsetY),{haloSymbol:_}=m,S=V(m.haloSize,0);let k=[0,0,0,0];if(_?.symbolLayers?.length){const e=_.symbolLayers;for(const t of e)if(t.color){k=this._getValueOrOverrideExpression(m?.haloSymbol?.type??"CIMPolygonSymbol",t.primitiveName,"Color",P(t.color));break}}const C=i.primitiveName;let b=[0,0,0,1],x=[0,0,0,0],z=0,E=!1;if(m.symbol?.symbolLayers)for(const t of m.symbol.symbolLayers){const e=t.primitiveName;if("CIMSolidStroke"===t.type)x=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Color",P(t.color)),z=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Width",w(t)??0);else if("CIMSolidFill"===t.type){const r=P(t.color);E=E??!!t.colorLocked,b=this._getValueOrOverrideExpression("CIMSolidFill",e??C,"Color",r)}}let I=null,L=null,N=null,R=null,A=null;C&&(I=this._maybeGetValueOrOverrideExpression(C,"TextSize"),L=this._maybeGetValueOrOverrideExpression(C,"TextAngle"),N=this._maybeGetValueOrOverrideExpression(C,"TextOffsetX"),R=this._maybeGetValueOrOverrideExpression(C,"TextOffsetY"),E||(A=this._maybeGetValueOrOverrideExpression(C,"FillColor")));const G=A??b;let T=null,W=null,D=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?T=P(e.color):"CIMSolidStroke"===e.type&&(W=P(e.color),D=V(e.width,O.CIMSolidStroke.width))}}const U=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==U)return;const{fontStyleName:H}=m,J=h+(H?"-"+H.toLowerCase():"-regular"),B=this._getMaterialOverrides(o,m.type);B.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type)),this._collectDictionaryTemplateOverrides(B,i);const q={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:B};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:q,colorLocked:!!n||!!E,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:J,decoration:y,haloSize:S,haloColor:k,weight:d.weight,style:d.style,size:I??f,angle:L??u,offsetX:N??v,offsetY:R??g,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:Y(m.horizontalAlignment),verticalAlignment:j(m.verticalAlignment),text:U,color:G,outlineColor:x,outlineSize:z,backgroundColor:T,borderLineColor:W,borderLineWidth:D,referenceSize:s,sizeRatio:1,markerPlacement:r})}_collectDictionaryTemplateOverrides(e,t){if(t.textString&&this._hasTextStringTemplates){const r=W(t.symbol);e.push({propertyName:"textString",defaultValue:"",valueExpressionInfo:{type:"dictionary-template",textCase:r,template:t.textString},primitiveName:t.primitiveName})}}_analyzeMultiLayerGraphicNonSDF(e,t,r,i,a,s,l,n,p,c,m,y){const d=Z(e,i),h=e.primitiveName,f=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),v=N(f),[g,_,S]=u.getTextureAnchor(d,this._resourceManager,J),M=this._getMaterialOverrides(a,e.type);M.push(...v);const k={type:"sprite-rasterization-param",resource:{...d,avoidSDFRasterization:!0},overrides:M},C=V(e.size,O.CIMVectorMarker.size),b=this._getValueOrOverrideExpression(e.type,h,"Size",C);this._cimLayers.push({type:"marker",spriteRasterizationParam:k,colorLocked:m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:!1,size:c,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:c,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:S/o(e.size),isOutline:y,markerPlacement:r,animationParams:se(p),baseSize:b})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const t=[];return M.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-marker-placement-param",placement:e,overrides:ae(t)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const t=[];return M.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-gif-animation-params",animation:e,overrides:ae(t)}}_analyzeCompositeMarkerGraphic(e,t,r,i,o,a,s,l,n,p,c){const m=i.geometry,y=o[0],d=o[1],h=k(m);if(!h)return;const f="Relative"!==e.anchorPointUnits,u=V(y.width,O.CIMSolidStroke.width),{frameSizeRatio:v,anchorX:g,anchorY:_,widthRatio:S,sdfPaddingRatio:M}=C(h,e.frame,e.size,e.anchorPoint,f,u,e.scaleSymbolsProportionally),{path:b}=d,x=d.primitiveName,z=y.primitiveName,E=i.primitiveName;let I=null;d.colorLocked||p||(I=this._maybeGetValueOrOverrideExpression(E,"FillColor"));const L=I??this._getValueOrOverrideExpression(d.type,x,"Color",P(d.color));let N=null;y.colorLocked||p||(N=this._maybeGetValueOrOverrideExpression(E,"StrokeColor"));const R=N??this._getValueOrOverrideExpression(y.type,z,"Color",P(y.color)),A=this._maybeGetValueOrOverrideExpression(E,"StrokeWidth")??this._getValueOrOverrideExpression(y.type,z,"Width",u),w={type:"sprite-rasterization-param",resource:b?{type:"path",path:b,asFill:!0}:{type:"sdf",geom:m,sdfPaddingRatio:M,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:w,colorLocked:p,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:f,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:S,rotateClockwise:!1,referenceSize:s,sizeRatio:v,color:L,outlineColor:R,outlineWidth:A,isOutline:c,markerPlacement:r})}_setPoMap(e,t,r){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[t]=r}_maybeGetValueOrOverrideExpression(e,t,r){return this._getValueOrOverrideExpression("",e,t,r,!1)}_getValueOrOverrideExpression(e,t,r,i,o=!0){if(o&&!D(i)&&(i=R(e,r.toLowerCase())),null==t)return i;const a=this._poMap[t];if(null==a)return i;const s=a[r];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,t,r,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,t){if(!e)return[];const r=[];for(const i of e)r.push(...this._getPrimitiveMaterialOverrides(i,t));return r}_getPrimitiveMaterialOverrides(e,t){if(!e)return[];const r=N(this._primitiveOverrides.filter(t=>t.primitiveName===e));return r.forEach(e=>e.defaultValue=R(t,e.propertyName.toLowerCase())),r}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter(r=>r.primitiveName!==e||!t.includes(r.propertyName))}}function Z(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function $(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.slice(6),10);if(!isNaN(t))return t}return 0}function ee(e,t){if(!t||0===t.length)return e;const i=r(e);return M.applyOverrides(i,t),i}const te=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function re(e){const t=e.symbolLayers;if(!t)return!1;const r=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)),i=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectAddControlPoints"===e.type));return!!r||!!i}function ie(e){return e.some(e=>"CIMSolidFill"!==e.type&&"CIMSolidStroke"!==e.type&&("CIMVectorMarker"!==e.type&&"CIMPictureMarker"!==e.type||null!=e.markerPlacement))}function oe(e,t){if(t?.some(e=>"CIMGeometricEffectRadial"===e.type)&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.type)&&2===e.length){const t=e.find(e=>"CIMSolidFill"===e.type),r=e.find(e=>"CIMSolidStroke"===e.type),i=r?.effects?.some(e=>"CIMGeometricEffectDashes"===e.type);if(null!=t&&null!=r&&!i)return!0}return!1}function ae(e){return r(e).map(e=>({...e,propertyName:U(e.propertyName)}))}function se(e){return f(e)?{type:"animation-params",params:e}:null}export{Q as CIMAnalyzer,ee as analyzeCIMResource};
5
+ import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as t}from"../../core/fontUtils.js";import"../../core/has.js";import{clone as r}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAbsoluteAnchor as p,handleMarker as c,handleRelativeAnchor as m,getFrameTranslation as y,translate as d,getStaticParam as h,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as u}from"./CIMSymbolHelper.js";import{antialiasingOutlineFillSettings as v}from"./constants.js";import{defaultCIMValues as O}from"./defaultCIMValues.js";import{Alignment as g,SymbolUnits as _}from"./enums.js";import{fitVectorMarker as S}from"./fitVectorMarker.js";import{OverrideHelper as M}from"./OverrideHelper.js";import{getExtent as k,getSDFMetrics as C,getSDFDimensions as b}from"./SDFHelper.js";import{colorToArray as x,normalizeAlpha as P,getSize as z,isCIMMarkerStrokePlacement as E,hasStrokeLayer as I,getTintColor as L,getNumericValue as V,normalizePrimitiveOverrideProps as N,getDefaultCIMValue as R,getEnum as A,getStrokeWidth as w,getFillColor as G,getStrokeColor as T,fromCIMFontDecoration as F,fromCIMFontStyle as X,fromCIMVerticalAlignment as j,fromCIMHorizontalAlignment as Y,getTextCasing as W,isValidCIMValue as D,uncapitalize as U}from"./utils.js";import{CIMEffectHelper as H}from"./effects/CIMEffectHelper.js";import{rasterizedVectorMarkerMinSize as J,randomInsidePolygonTextureSize as B}from"../../views/2d/engine/webgl/definitions.js";const q=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function K(e){const t=e.markerPlacement;return t&&t.angleToLine?g.MAP:g.SCREEN}class Q{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._hasTextStringTemplates=!1,e&&(this._resourceManager=e)}analyzeSymbolReference(t,r,i){if(this._cimLayers=i??[],!t)return this._cimLayers;if(this._reset(),this._hasTextStringTemplates=t.hasTextStringTemplates??!1,t.primitiveOverrides){this._primitiveOverrides=t.primitiveOverrides;for(const t of this._primitiveOverrides){const r=t.valueExpressionInfo;if(r)this._setPoMap(t.primitiveName,t.propertyName,r);else if(null!=t.value){let r=t.value;t.propertyName.includes("Color")&&(e(r)&&(r=x(r)),r=P(r)),this._setPoMap(t.primitiveName,t.propertyName,r)}}}return this._analyzeSymbol(t.symbol,r),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t)}}_analyzeMultiLayerSymbol(e,t){const r=e?.symbolLayers;if(!r)return;for(let l=0;l<r.length;l++){const e=r[l];"CIMVectorMarker"===e.type&&(r[l]=S(e,this._resourceManager.geometryEngine))}const i=e.effects;let o=g.SCREEN;const a=z(e)??0;if("CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=g.MAP),oe(r,i))return this._analyzeCompositeOutlineFill(r,i,a);let s={transform:[0,0,0,1],fromColor:[1,1,1,1],toColor:[1,1,1,1],colorMix:[0,0,0,0],toOpacity:[1,1,1,1],opacityMix:[0,0,0,0],shift:[1,1,1,1],hasAnimations:l(e),hasShiftAnimation:!1,hasMotionAnimations:!1};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=r.length;for(;c--;){const l=r[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let y=null;if(n){y=[];for(const e of n){const t=M.findEffectOverrides(e,this._primitiveOverrides);t&&y.push(t)}}const d=[];switch(M.findApplicableOverrides(l,this._primitiveOverrides,d),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,y,s,I(r));break;case"CIMPictureFill":this._analyzePictureFill(l,y,s);break;case"CIMHatchFill":this._analyzeHatchFill(l,y);break;case"CIMGradientFill":this._analyzeGradientFill(l,y);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,y,p,a,s);break;case"CIMPictureStroke":this._analyzePictureStroke(l,y,p,a,s);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,y,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=K(l));const r=[],i=l.primitiveName;i&&r.push(i);const n=p&&E(l.markerPlacement);this._analyzeMarker(l,y,null,r,o,a,t,[],s,!1,n);break}default:q().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,t,r,i){const{primitiveName:o,type:a}=e,s=P(e.color),l=n(this._poMap,e,r);if(!i&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.effect.type)){const r=this._getValueOrOverrideExpression(a,o,"Color",s);return void this._cimLayers.push({type:"outlineFill",colorLocked:!!e.colorLocked,color:r,effects:t,outlineColor:r,outlineColorLocked:!!e.colorLocked,...v,outlineEffects:t})}this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(a,o,"Color",s),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1,animationParams:se(l)})}_analyzePictureFill(e,t,r){const{primitiveName:i,type:o}=e,a=L(e),s=V(e.height,O.CIMPictureFill.height);let l=V(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height),l/=r*(s/t)}const p={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(i,o)},c=n(this._poMap,e,r);this._cimLayers.push({type:"fill",spriteRasterizationParam:p,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(o,i,"TintColor",a),height:this._getValueOrOverrideExpression(o,i,"Height",s),scaleX:this._getValueOrOverrideExpression(o,i,"ScaleX",l),angle:this._getValueOrOverrideExpression(o,i,"Rotation",V(e.rotation)),offsetX:this._getValueOrOverrideExpression(o,i,"OffsetX",V(e.offsetX)),offsetY:this._getValueOrOverrideExpression(o,i,"OffsetY",V(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1,animationParams:se(c)})}_analyzeHatchFill(e,t){const{primitiveName:r,type:i}=e,o=this._analyzeMaterialOverrides(r,["Rotation","OffsetX","OffsetY"]),a=N(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??r;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=P(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const t=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(t){let r=null,o=null;"number"==typeof t?r=t:o=t.valueExpressionInfo;let s=a.find(e=>"strokeWidth"===e.propertyName);s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:r,defaultValue:R(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:t,color:s,height:this._getValueOrOverrideExpression(i,r,"Separation",V(e.separation,O.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,r,"Rotation",V(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,r,"OffsetX",V(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,r,"OffsetY",V(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,t){const{angle:r,gradientMethod:i,gradientSize:o,gradientSizeUnits:a,gradientType:s,interval:l,primitiveName:n,type:p}=e,c=O.CIMGradientFill,m=e.colorRamp;this._cimLayers.push({type:"gradientFill",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(n,p)},colorLocked:!1,effects:t,color:[255,255,255,1],gradientMethod:this._getValueOrOverrideExpression(p,n,"GradientMethod",i??"Linear"),angle:this._getValueOrOverrideExpression(p,n,"Angle",V(r,c.angle)),gradientType:this._getValueOrOverrideExpression(p,n,"GradientType",s??c.gradientType),interval:this._getValueOrOverrideExpression(p,n,"Interval",V(l,"CIMFixedColorRamp"===m.type?m.colors.length:c.interval)),gradientSize:this._getValueOrOverrideExpression(p,n,"GradientSize",V(o,c.gradientSize)),gradientSizeUnits:"Absolute"===a?_.Absolute:"Relative"===a?_.Relative:c.gradientSizeUnits})}_analyzeCompositeOutlineFill(e,t,r){const i=e.find(e=>"CIMSolidFill"===e.type),o=e.find(e=>"CIMSolidStroke"===e.type);if(null==i||null==o)return;const a=[...t??[],...i.effects??[]].map(e=>M.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),s=[...t??[],...o.effects??[]].map(e=>M.findEffectOverrides(e,this._primitiveOverrides)).filter(e=>null!=e),l=V(o.width,O.CIMSolidStroke.width),n=A(o.capStyle,O.CIMSolidStroke.capstyle),p=A(o.joinStyle,O.CIMSolidStroke.joinstyle),c=o.miterLimit;this._cimLayers.push({type:"outlineFill",colorLocked:!!i.colorLocked,color:this._getValueOrOverrideExpression(i.type,i.primitiveName,"Color",P(i.color)),effects:a,outlineColorLocked:!!o.colorLocked,outlineColor:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Color",P(o.color)),outlineWidth:this._getValueOrOverrideExpression(o.type,o.primitiveName,"Width",l),cap:this._getValueOrOverrideExpression(o.type,o.primitiveName,"CapStyle",n),join:this._getValueOrOverrideExpression(o.type,o.primitiveName,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(o.type,o.primitiveName,"MiterLimit",c),referenceWidth:r,outlineEffects:s})}_analyzeSolidStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=P(e.color),p=V(e.width,O.CIMSolidStroke.width),c=A(e.capStyle,O.CIMSolidStroke.capstyle),m=A(e.joinStyle,O.CIMSolidStroke.joinstyle),y=e.miterLimit;let d,h,f,u,v=[];if(this._analyzePrimitiveOverrides(a,t,null,null)&&(v=this._getPrimitiveMaterialOverrides(a,s)),t&&Array.isArray(t)&&t.length>0){const e=t[t.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(d=e.dashTemplate,h=e.scaleDash,f=e.offsetAlongLine,u=e.primitiveName,(t=[...t]).pop())}null!=u&&v.push(...this._getPrimitiveMaterialOverrides(u,s).filter(e=>"dashTemplate"===e.propertyName));const g=void 0!==d?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:d,primitiveName:u},overrides:v}:null,_=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:g,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"Color",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:$(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(u,"DashTemplate")??d,offsetAlongLine:this._getValueOrOverrideExpression(s,u,"OffsetAlongLine",f??0),scaleDash:h,sampleAlphaOnly:!0,animationParams:se(_)})}_analyzePictureStroke(e,t,r,i,o){const{primitiveName:a,type:s}=e,l=L(e),p=V(e.width,O.CIMPictureStroke.width),c=A(e.capStyle,O.CIMPictureStroke.capstyle),m=A(e.joinStyle,O.CIMPictureStroke.joinstyle),y=e.miterLimit,d={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(a,s)},h=n(this._poMap,e,o);this._cimLayers.push({type:"line",spriteRasterizationParam:d,isOutline:r,colorLocked:!!e.colorLocked,effects:t,color:this._getValueOrOverrideExpression(s,a,"TintColor",l),width:this._getValueOrOverrideExpression(s,a,"Width",p),cap:this._getValueOrOverrideExpression(s,a,"CapStyle",c),join:this._getValueOrOverrideExpression(s,a,"JoinStyle",m),miterLimit:y&&this._getValueOrOverrideExpression(s,a,"MiterLimit",y),referenceWidth:i,zOrder:$(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1,animationParams:se(h)})}_analyzeGradientStroke(e,t,r,i){const{gradientMethod:o,gradientSize:a,gradientSizeUnits:s,gradientType:l,interval:n,primitiveName:p,type:c}=e,m=O.CIMGradientStroke,y=V(e.width,m.width),d=A(e.capStyle,m.capstyle),h=A(e.joinStyle,m.joinstyle),f=e.miterLimit,u=e.colorRamp;this._cimLayers.push({type:"gradientStroke",spriteRasterizationParam:{type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(p,c)},colorLocked:!!e.colorLocked,effects:t,color:[255,255,255,1],width:this._getValueOrOverrideExpression(c,p,"Width",y),cap:this._getValueOrOverrideExpression(c,p,"CapStyle",d),join:this._getValueOrOverrideExpression(c,p,"JoinStyle",h),miterLimit:f&&this._getValueOrOverrideExpression(c,p,"MiterLimit",f),referenceWidth:i,isOutline:r,gradientMethod:this._getValueOrOverrideExpression(c,p,"GradientMethod",o??m.gradientMethod),gradientType:this._getValueOrOverrideExpression(c,p,"GradientType",l??m.gradientType),interval:this._getValueOrOverrideExpression(c,p,"Interval",V(n,"CIMFixedColorRamp"===u.type?u.colors.length:m.interval)),gradientSize:this._getValueOrOverrideExpression(c,p,"GradientSize",V(a,m.gradientSize)),gradientSizeUnits:"Absolute"===s?_.Absolute:"Relative"===s?_.Relative:m.gradientSizeUnits})}_analyzeMarker(e,t,r,i,o,a,s,l,y,d=!1,h=!1){d||=!!e.colorLocked;let f=y;if(f=p(e,f),f=c(this._poMap,e,f),f=m(e,f),f=n(this._poMap,e,f),this._analyzeMarkerInsidePolygon(e,t,d,f))return;const u=V(e.size,O.CIMVectorMarker.size),v=V(e.rotation),g=V(e.offsetX),_=V(e.offsetY),{primitiveName:S,type:M}=e,k=this._getValueOrOverrideExpression(M,S,"Size",u),C=this._getValueOrOverrideExpression(M,S,"Rotation",v),b=this._getValueOrOverrideExpression(M,S,"OffsetX",g),x=this._getValueOrOverrideExpression(M,S,"OffsetY",_);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,r,i,o,a,k,C,b,x,l,f,d,h);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,r,i,o,a,k,C,b,x,l,f,s,d,h)}}_analyzeMarkerInsidePolygon(e,t,r,i){const{markerPlacement:o,type:s}=e;if(!o||"CIMMarkerPlacementInsidePolygon"!==o.type||i.hasMotionAnimations)return!1;if("CIMVectorMarker"===s||"CIMPictureMarker"===s){const r=e.primitiveName;if(r&&this._analyzePrimitiveOverrides([r],t,null,null))return!1;const i=o.primitiveName;if(i&&this._analyzePrimitiveOverrides([i],t,null,null))return!1;if("CIMVectorMarker"===s){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const l=Math.abs(o.stepX),n=Math.abs(o.stepY);if(0===l||0===n)return!0;let p,c;if("Random"===o.gridType){const e=a(B),t=Math.max(Math.floor(e/l),1);p=n*Math.max(Math.floor(e/n),1);c=t*l/p}else o.shiftOddRows?(p=2*n,c=l/n*.5):(p=n,c=l/n);const m=L(e),y="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:y,colorLocked:r,effects:t,color:m,height:p,scaleX:c,angle:o.gridAngle,offsetX:V(o.offsetX),offsetY:V(o.offsetY),applyRandomOffset:"Random"===o.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,t,i,o,a,l,n,p,c,m,y,d,h,f){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let g=V(e.scaleX,1);const _=L(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const S=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),M=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let r=1;const i=this._resourceManager.getResource(e.url);null!=i&&(r=i.width/i.height);g/=r*(V(e.size)/t)}const k=[...o];let C;e.primitiveName&&k.push(e.primitiveName),u||S?C={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(C=r(e),C.markerPlacement=null);const b={type:"sprite-rasterization-param",resource:C,overrides:this._getMaterialOverrides(k,O)};S&&b.overrides.push(...S.overrides);const x=n;this._cimLayers.push({type:"marker",spriteRasterizationParam:b,colorLocked:h,effects:t,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",g),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:y},color:this._getValueOrOverrideExpression(O,v,"TintColor",_),anchorPoint:{x:M.x,y:M.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:f,markerPlacement:i,animationParams:se(d),baseSize:x})}_analyzeVectorMarker(e,t,r,i,o,a,s,l,p,c,m,f,u,v,O){const g=e.markerGraphics;if(!g)return;const _=e.frame;let S=0;S=_?_.ymax-_.ymin:a;const M=!!e.scaleSymbolsProportionally;if(S){const t={offsetX:p,offsetY:c,rotation:l,size:s,frameHeight:S,rotateClockWise:!!e.rotateClockwise,absoluteAnchorPoint:!1,scaleSymbolsProportionally:M};m=[...m,t]}r||(r=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const k of g)if(k){const s=k.symbol;if(!s)continue;const l=k.primitiveName;l&&i.push(l);let p,c=f;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let t=0,r=0;const i=k.geometry;"x"in i&&"y"in i&&(t+=i.x-.5*(_.xmin+_.xmax),r+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;let a=!1;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,r-=o.y,a=!0):_&&(t-=(_.xmax-_.xmin)*o.x,r-=(_.ymax-_.ymin)*o.y));const s={offsetX:t,offsetY:r,rotation:0,size:0,frameHeight:0,rotateClockWise:!1,absoluteAnchorPoint:a,scaleSymbolsProportionally:M};p=[...m,s]}const g=k.geometry,[C,b]=y(g,_);switch(0===C&&0===b||(c=d(c,C,b)),"CIMPointSymbol"===s.type&&(c=n(this._poMap,s,c)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":u||re(s)?(c={...c,transform:{type:"AnimatedTransform",relativeTranslation:!1,absoluteScale:!0,translation:h([0,0]),rotation:h(0),scale:h(S),parent:f.transform}},this._analyzeMultiLayerGraphicNonSDF(e,t,r,k,i,o,a,p??m,c,S,v,O)):this._analyzeMultiLayerGraphic(e,t,r,k,i,o,a,p??m,c,S,v,O);break;case"CIMTextSymbol":this._analyzeTextGraphic(t,r,k,i,o,a,p??m,v)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,t,r,i,o,a,s,l,n,p,c,m){const y=i.symbol.symbolLayers;y&&(!te(y)||f(n)?ie(y)?this._analyzeMultiLayerGraphicNonSDF(e,t,r,i,o,a,s,l,n,p,!!c,m):this._analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,n,p,c,m):this._analyzeCompositeMarkerGraphic(e,t,r,i,y,a,s,l,p,c,m))}_analyzeMarkerGraphicSymbolLayers(e,t,r,i,o,a,s,l,p,c,m,y){const d=i.symbol,h=d.symbolLayers;if(!h)return;const f=this._resourceManager.geometryEngine,u=H.applyEffects(d.effects,i.geometry,f);if(!u)return;let v=h.length;for(;v--;){const d=h[v];if(!d||!1===d.enable)continue;const g=d.primitiveName;switch(g&&o.push(g),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=H.applyEffects(d.effects,u,f),h=k(o);if(!h)continue;const v="Relative"!==e.anchorPointUnits,_=w(d)??0,{frameSizeRatio:S,anchorX:M,anchorY:x,widthRatio:z,sdfPaddingRatio:E}=C(h,e.frame,e.size,e.anchorPoint,v,_,e.scaleSymbolsProportionally),I="CIMSolidFill"===d.type,L={type:"sdf",geom:o,sdfPaddingRatio:E,asFill:I},{path:N}=d,R=I?P(G(d)):null==N?P(T(d)):[0,0,0,0],A=I?[0,0,0,0]:P(T(d));if(!I&&!_)break;const F=i.primitiveName;let X=null;I&&!d.colorLocked&&(X=this._maybeGetValueOrOverrideExpression(F,"FillColor"));let j=null;I||d.colorLocked||(j=this._maybeGetValueOrOverrideExpression(F,"StrokeColor"));const Y=X??this._getValueOrOverrideExpression(d.type,g,"Color",R),W=j??this._getValueOrOverrideExpression(d.type,g,"Color",A),D=this._maybeGetValueOrOverrideExpression(F,"StrokeWidth")??this._getValueOrOverrideExpression(d.type,g,"Width",_),U=N?{type:"sprite-rasterization-param",resource:{type:"path",path:N,asFill:I},overrides:[]}:{type:"sprite-rasterization-param",resource:L,overrides:[]},J=n(this._poMap,d,p),B=V(e.size,O.CIMVectorMarker.size),q=this._getValueOrOverrideExpression(e.type,e.primitiveName,"Size",B);this._cimLayers.push({type:"marker",spriteRasterizationParam:U,colorLocked:!!d.colorLocked||!!m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:M,y:x},isAbsoluteAnchorPoint:v,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:z,rotateClockwise:!1,referenceSize:s,sizeRatio:S,color:Y,outlineColor:W,outlineWidth:D,isOutline:y,markerPlacement:r,animationParams:se(J),isStroke:"CIMSolidFill"!==d.type,baseSize:q,...b(o,E)});break}case"CIMPictureMarker":case"CIMVectorMarker":if(d.markerPlacement){q().error("Error analyzing CIM, got unexpected marker placement");break}this._analyzeMarker(d,t,r,o,a,s,!1,l,p,m,y)}g&&o.pop()}}_analyzeTextGraphic(e,r,i,o,a,s,l,n){const p=[];M.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,y=F(m),d=X(m.fontStyleName),h=t(m.fontFamilyName);m.font={family:h,decoration:y,...d};const f=V(m.height,O.CIMTextSymbol.height),u=V(m.angle),v=V(m.offsetX),g=V(m.offsetY),{haloSymbol:_}=m,S=V(m.haloSize,0);let k=[0,0,0,0];if(_?.symbolLayers?.length){const e=_.symbolLayers;for(const t of e)if(t.color){k=this._getValueOrOverrideExpression(m?.haloSymbol?.type??"CIMPolygonSymbol",t.primitiveName,"Color",P(t.color));break}}const C=i.primitiveName;let b=[0,0,0,1],x=[0,0,0,0],z=0,E=!1;if(m.symbol?.symbolLayers)for(const t of m.symbol.symbolLayers){const e=t.primitiveName;if("CIMSolidStroke"===t.type)x=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Color",P(t.color)),z=this._getValueOrOverrideExpression("CIMSolidStroke",e,"Width",w(t)??0);else if("CIMSolidFill"===t.type){const r=P(t.color);E=E??!!t.colorLocked,b=this._getValueOrOverrideExpression("CIMSolidFill",e??C,"Color",r)}}let I=null,L=null,N=null,R=null,A=null;C&&(I=this._maybeGetValueOrOverrideExpression(C,"TextSize"),L=this._maybeGetValueOrOverrideExpression(C,"TextAngle"),N=this._maybeGetValueOrOverrideExpression(C,"TextOffsetX"),R=this._maybeGetValueOrOverrideExpression(C,"TextOffsetY"),E||(A=this._maybeGetValueOrOverrideExpression(C,"FillColor")));const G=A??b;let T=null,W=null,D=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?T=P(e.color):"CIMSolidStroke"===e.type&&(W=P(e.color),D=V(e.width,O.CIMSolidStroke.width))}}const U=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==U)return;const{fontStyleName:H}=m,J=h+(H?"-"+H.toLowerCase():"-regular"),B=this._getMaterialOverrides(o,m.type);B.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type)),this._collectDictionaryTemplateOverrides(B,i);const q={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:B};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:q,colorLocked:!!n||!!E,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:J,decoration:y,haloSize:S,haloColor:k,weight:d.weight,style:d.style,size:I??f,angle:L??u,offsetX:N??v,offsetY:R??g,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:Y(m.horizontalAlignment),verticalAlignment:j(m.verticalAlignment),text:U,color:G,outlineColor:x,outlineSize:z,backgroundColor:T,borderLineColor:W,borderLineWidth:D,referenceSize:s,sizeRatio:1,markerPlacement:r})}_collectDictionaryTemplateOverrides(e,t){if(t.textString&&this._hasTextStringTemplates){const r=W(t.symbol);e.push({propertyName:"textString",defaultValue:"",valueExpressionInfo:{type:"dictionary-template",textCase:r,template:t.textString},primitiveName:t.primitiveName})}}_analyzeMultiLayerGraphicNonSDF(e,t,r,i,a,s,l,n,p,c,m,y){const d=Z(e,i),h=e.primitiveName,f=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),v=N(f),[g,_,S]=u.getTextureAnchor(d,this._resourceManager,J),M=this._getMaterialOverrides(a,e.type);M.push(...v);const k={type:"sprite-rasterization-param",resource:{...d,avoidSDFRasterization:!0},overrides:M},C=V(e.size,O.CIMVectorMarker.size),b=this._getValueOrOverrideExpression(e.type,h,"Size",C);this._cimLayers.push({type:"marker",spriteRasterizationParam:k,colorLocked:m,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:!1,size:c,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:c,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:S/o(e.size),isOutline:y,markerPlacement:r,animationParams:se(p),baseSize:b})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const t=[];return M.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-marker-placement-param",placement:e,overrides:ae(t)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const t=[];return M.findApplicableOverrides(e,this._primitiveOverrides,t),{type:"cim-gif-animation-params",animation:e,overrides:ae(t)}}_analyzeCompositeMarkerGraphic(e,t,r,i,o,a,s,l,n,p,c){const m=i.geometry,y=o[0],d=o[1],h=k(m);if(!h)return;const f="Relative"!==e.anchorPointUnits,u=V(y.width,O.CIMSolidStroke.width),{frameSizeRatio:v,anchorX:g,anchorY:_,widthRatio:S,sdfPaddingRatio:M}=C(h,e.frame,e.size,e.anchorPoint,f,u,e.scaleSymbolsProportionally),{path:b}=d,x=d.primitiveName,z=y.primitiveName,E=i.primitiveName;let I=null;d.colorLocked||p||(I=this._maybeGetValueOrOverrideExpression(E,"FillColor"));const L=I??this._getValueOrOverrideExpression(d.type,x,"Color",P(d.color));let N=null;y.colorLocked||p||(N=this._maybeGetValueOrOverrideExpression(E,"StrokeColor"));const R=N??this._getValueOrOverrideExpression(y.type,z,"Color",P(y.color)),A=this._maybeGetValueOrOverrideExpression(E,"StrokeWidth")??this._getValueOrOverrideExpression(y.type,z,"Width",u),w={type:"sprite-rasterization-param",resource:b?{type:"path",path:b,asFill:!0}:{type:"sdf",geom:m,sdfPaddingRatio:M,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:w,colorLocked:p,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:g,y:_},isAbsoluteAnchorPoint:f,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:S,rotateClockwise:!1,referenceSize:s,sizeRatio:v,color:L,outlineColor:R,outlineWidth:A,isOutline:c,markerPlacement:r})}_setPoMap(e,t,r){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[t]=r}_maybeGetValueOrOverrideExpression(e,t,r){return this._getValueOrOverrideExpression("",e,t,r,!1)}_getValueOrOverrideExpression(e,t,r,i,o=!0){if(o&&!D(i)&&(i=R(e,r.toLowerCase())),null==t)return i;const a=this._poMap[t];if(null==a)return i;const s=a[r];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,t,r,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,t){if(!e)return[];const r=[];for(const i of e)r.push(...this._getPrimitiveMaterialOverrides(i,t));return r}_getPrimitiveMaterialOverrides(e,t){if(!e)return[];const r=N(this._primitiveOverrides.filter(t=>t.primitiveName===e));return r.forEach(e=>e.defaultValue=R(t,e.propertyName.toLowerCase())),r}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter(r=>r.primitiveName!==e||!t.includes(r.propertyName))}}function Z(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function $(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.slice(6),10);if(!isNaN(t))return t}return 0}function ee(e,t){if(!t||0===t.length)return e;const i=r(e);return M.applyOverrides(i,t),i}const te=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function re(e){const t=e.symbolLayers;if(!t)return!1;const r=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)),i=t.find(e=>e.effects?.find(e=>"CIMGeometricEffectAddControlPoints"===e.type));return!!r||!!i}function ie(e){return e.some(e=>"CIMSolidFill"!==e.type&&"CIMSolidStroke"!==e.type&&("CIMVectorMarker"!==e.type&&"CIMPictureMarker"!==e.type||null!=e.markerPlacement))}function oe(e,t){if(t?.some(e=>"CIMGeometricEffectRadial"===e.type)&&t?.some(e=>"CIMGeometricEffectTaperedPolygon"===e.type)&&2===e.length){const t=e.find(e=>"CIMSolidFill"===e.type),r=e.find(e=>"CIMSolidStroke"===e.type),i=r?.effects?.some(e=>"CIMGeometricEffectDashes"===e.type);if(null!=t&&null!=r&&!i)return!0}return!1}function ae(e){return r(e).map(e=>({...e,propertyName:U(e.propertyName)}))}function se(e){return f(e)?{type:"animation-params",params:e}:null}export{Q as CIMAnalyzer,ee as analyzeCIMResource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../../../../../../core/arrayUtils.js";import r from"../../../../../../../core/Error.js";import{clone as t}from"../../../../../../../core/lang.js";import s from"../../../../../../../core/Logger.js";import{collectExpressionDependencies as o}from"../../../../../../../support/ArcadeExpression.js";import{getStartGroup as a}from"../../../grouping.js";import{hydrate as i}from"../../../animations/infos.js";import{createParamList as n,compileAnimationParam as c,fromJSON as p,resolveToAnimationInfo as m,encodeParamList as f,getAnimationExpressions as l}from"../../../animations/utils.js";import{applyComputedValue as d}from"./utils.js";import{DictionaryValue as u}from"../../../../../layers/features/support/DictionaryValue.js";const y=()=>s.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator");async function h(e,r,t,s){const{defaultValue:o,valueExpressionInfo:a,value:i}=r;if(a){if("dictionary-template"===a.type)return{...r,computed:e.createDictionaryTemplateField(a,t),defaultValue:o};const{expression:i}=a,n=await e.createComputedField({expression:i},s);return n?{...r,computed:n,defaultValue:o}:null}return{...r,computed:new u(i),defaultValue:o}}async function v(e,r,t){const{valueExpressionInfo:s}=r,o="dictionary-template"===s.type?e.createDictionaryTemplateField(s,t):await e.createComputedField({expression:s.expression});return o?{...r,computed:o}:null}function P(e){return"object"==typeof e&&null!=e&&(!(!("valueExpressionInfo"in e)||!e.valueExpressionInfo)||"type"in e&&"Process"===e.type&&"op"in e&&"Random"===e.op)}function _(e){if(Array.isArray(e))for(const r of e)if(_(r))return!0;if("object"==typeof e){if(P(e))return!0;for(const r in e){if(_(e[r]))return!0}}return!1}class I{static async create(r,t,s,o){const a={},i=new Map,m=new Map,f=new Map,l=new Map,d=new Map,u=new Map;for(const y in s){const I=s[y];if(null!=I&&"object"==typeof I)if(Array.isArray(I)){if("object"==typeof I[0])throw new Error(`InternalError: Cannot handle ${y}. Nested array params are not supported`);a[y]=I}else if("valueExpressionInfo"in I){if(I.value){a[y]=I.value;continue}const e=await v(r,I,o);if(!e){a[y]=I.defaultValue;continue}i.set(y,e),a[y]=null}else switch(I.type){case"cim-effect-infos":if(I.effectInfos.some(e=>e.overrides.length)){m.set(y,{effects:await Promise.all(I.effectInfos.map(async t=>{const s=t.overrides.map(e=>h(r,e,o,!1));return{effect:t.effect,compiledOverrides:(await Promise.all(s)).filter(e)}}))});break}a[y]=I.effectInfos.map(e=>e.effect);break;case"cim-marker-placement-param":I.overrides.length&&f.set(y,{placementInfo:I,compiledOverrides:(await Promise.all(I.overrides.map(e=>h(r,e,o,!1)))).filter(e)}),a[y]=I.placement;break;case"text-rasterization-param":{if(I.overrides.length){const t=I.overrides.map(e=>h(r,e,o,I.useLegacyLabelEvaluationRules??!1));l.set(y,{compiledOverrides:(await Promise.all(t)).filter(e),rasterizationParam:I,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:I.resource};a[y]=await t.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(I.overrides.length){const t=I.overrides.map(e=>h(r,e,o,!1));l.set(y,{compiledOverrides:(await Promise.all(t)).filter(e),rasterizationParam:I,objectIdToResourceId:new Map});continue}if("animated"===I.resource.type){l.set(y,{compiledOverrides:[],rasterizationParam:I,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:I.resource};a[y]=await t.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=I;if(_(e)){const t={compiledMarkerInfos:[]};await Promise.all(e.map(async e=>{const s={props:{}};for(const t in e)if(P(e[t])){const a=await v(r,e[t],o);s.compiledExpressionMap||(s.compiledExpressionMap=new Map);const i=s.compiledExpressionMap;a&&i.set(t,a)}else s.props[t]=e[t];t.compiledMarkerInfos.push(s)})),d.set(y,t)}else a[y]={type:"cim-marker-transform-info",infos:e};break}case"animation-params":{const{params:e}=I,s=n(e);if(_(s)){const e=await Promise.all(s.map(e=>c(e,r)));u.set(y,{params:e,propertyIdToResourceId:new Map,key:y})}else{const e=p(s),r=await t.fetchResourceImmediate({type:"animation-info",resource:e});null!=r&&"sprite"===r.type&&(a[y]={dataRow:r.rect.y,dataColumn:r.rect.x})}break}default:a[y]=I}else a[y]=I}return new I(s,a,i,m,f,l,d,u)}constructor(e,r,t,s,a,i,n,c){this.inputMeshParams=e,this._resolvedMeshParams=r,this._dynamicProperties=t,this._dynamicEffectProperties=s,this._dynamicPlacementProperties=a,this._dynamicAsyncProperties=i,this._dynamicTransformProperties=n,this._dynamicAsyncAnimations=c,this.evaluator=e=>e,this._arcadeDependencies=new Set;for(const p of this._expressions())o(this._arcadeDependencies,p)}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size||this._dynamicAsyncAnimations.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(e,s,o){for(const i of this._dynamicAsyncProperties.values()){const c=t(i.rasterizationParam.resource);"animated"===i.rasterizationParam.resource.type&&i.rasterizationParam.resource.randomizeStartTime&&(c.primitiveName="__RESERVED__PRIMITIVE__NAME__",c.startGroup=a(s.getObjectId()||0));for(const{primitiveName:e,propertyName:t,computed:a,defaultValue:m,valueExpressionInfo:f}of i.compiledOverrides)try{const r="animated"===i.rasterizationParam.resource.type?c.primitiveName:e;d(c,r,t,a,s,o,m)}catch(n){y().errorOnce(new r("invalid-arcade-expression","Encountered an error when evaluating the arcade expression",{error:n,valueExpressionInfo:f}))}const p=e.enqueueRequest({type:"cim-rasterization-info",resource:c});i.objectIdToResourceId.set(s.getObjectId(),p)}for(const r of this._dynamicAsyncAnimations.values()){const t=r.params.map(e=>m(e,s,o)).map(i).map(e=>e.simplify()),a=f(t),n=e.enqueueRequest({type:"animation-info",resource:a});r.propertyIdToResourceId.set(s.getObjectId()+"."+r.key,n)}}evaluateMeshParams(e,r,t){for(const[s,o]of this._dynamicProperties.entries())this._resolvedMeshParams[s]=o.computed.readWithDefault(r,t,o.defaultValue);for(const[s,o]of this._dynamicPlacementProperties.entries())for(const{computed:e,defaultValue:a,propertyName:i}of o.compiledOverrides){const n=e.readWithDefault(r,t,a);o.placementInfo.placement[i]=n,this._resolvedMeshParams[s]=o.placementInfo.placement}for(const[s,o]of this._dynamicEffectProperties.entries())for(const e of o.effects){for(const{computed:s,defaultValue:o,propertyName:a}of e.compiledOverrides){const i=s.readWithDefault(r,t,o);e.effect[a]=i}this._resolvedMeshParams[s]=o.effects.map(e=>e.effect)}for(const[s,o]of this._dynamicTransformProperties.entries()){const e={type:"cim-marker-transform-info",infos:[]};for(const s of o.compiledMarkerInfos){const o={...s.props};if(s.compiledExpressionMap)for(const[e,a]of s.compiledExpressionMap){const s=a.computed.readWithDefault(r,t,a.defaultValue);o[e]="number"==typeof s||"boolean"==typeof s?s:a.defaultValue}e.infos.push(o)}this._resolvedMeshParams[s]=e}for(const[s,o]of this._dynamicAsyncProperties.entries()){const t=o.objectIdToResourceId.get(r.getObjectId());if(null==t)continue;const a=e.getResource(t);this._resolvedMeshParams[s]=a}for(const[s,o]of this._dynamicAsyncAnimations.entries()){const t=o.propertyIdToResourceId.get(r.getObjectId()+"."+s);if(null==t)continue;const a=e.getResource(t);this._resolvedMeshParams[s]={dataRow:a.rect.y,dataColumn:a.rect.x}}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}hasArcadeDependency(e){return this._arcadeDependencies.has(e)}*_expressions(){for(const e of this._dynamicProperties.values())yield e.computed;for(const e of this._dynamicEffectProperties.values())for(const r of e.effects)for(const e of r.compiledOverrides)yield e.computed;for(const e of this._dynamicPlacementProperties.values())for(const r of e.compiledOverrides)yield r.computed;for(const e of this._dynamicAsyncProperties.values())for(const r of e.compiledOverrides)yield r.computed;for(const e of this._dynamicTransformProperties.values())for(const r of e.compiledMarkerInfos)if(null!=r.compiledExpressionMap)for(const e of r.compiledExpressionMap.values())yield e.computed;for(const e of this._dynamicAsyncAnimations.values())for(const r of e.params)yield*l(r)}}export{I as MeshWriterInputEvaluator,P as hasExpression};
5
+ import{isSome as e}from"../../../../../../../core/arrayUtils.js";import r from"../../../../../../../core/Error.js";import{clone as t}from"../../../../../../../core/lang.js";import s from"../../../../../../../core/Logger.js";import{collectExpressionDependencies as o}from"../../../../../../../support/ArcadeExpression.js";import{getStartGroup as a}from"../../../grouping.js";import{hydrate as i}from"../../../animations/infos.js";import{createParamList as n,compileAnimationParam as c,fromJSON as p,resolveToAnimationInfo as m,encodeParamList as f,getAnimationExpressions as l}from"../../../animations/utils.js";import{applyComputedValue as d}from"./utils.js";import{DictionaryValue as u}from"../../../../../layers/features/support/DictionaryValue.js";const y=()=>s.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator");async function h(e,r,t,s){const{defaultValue:o,valueExpressionInfo:a,value:i}=r;if(a){if("dictionary-template"===a.type)return{...r,computed:e.createDictionaryTemplateField(a,t),defaultValue:o};const{expression:i}=a,n=await e.createComputedField({expression:i},s);return n?{...r,computed:n,defaultValue:o}:null}return{...r,computed:new u(i),defaultValue:o}}async function v(e,r,t){const{valueExpressionInfo:s}=r,o="dictionary-template"===s.type?e.createDictionaryTemplateField(s,t):await e.createComputedField({expression:s.expression});return o?{...r,computed:o}:null}function P(e){return"object"==typeof e&&null!=e&&(!(!("valueExpressionInfo"in e)||!e.valueExpressionInfo)||"type"in e&&"Process"===e.type&&"op"in e&&"Random"===e.op)}function _(e){if(Array.isArray(e))for(const r of e)if(_(r))return!0;if("object"==typeof e){if(P(e))return!0;for(const r in e){if(_(e[r]))return!0}}return!1}class I{static async create(r,t,s,o){const a={},i=new Map,m=new Map,f=new Map,l=new Map,d=new Map,u=new Map;for(const y in s){const I=s[y];if(null!=I&&"object"==typeof I)if(Array.isArray(I)){if("object"==typeof I[0])throw new Error(`InternalError: Cannot handle ${y}. Nested array params are not supported`);a[y]=I}else{if("valueExpressionInfo"in I){if(I.value){a[y]=I.value;continue}const e=await v(r,I,o);if(!e){a[y]=I.defaultValue;continue}i.set(y,e),a[y]=null;continue}switch(I.type){case"cim-effect-infos":if(I.effectInfos.some(e=>e.overrides.length)){m.set(y,{effects:await Promise.all(I.effectInfos.map(async t=>{const s=t.overrides.map(e=>h(r,e,o,!1));return{effect:t.effect,compiledOverrides:(await Promise.all(s)).filter(e)}}))});break}a[y]=I.effectInfos.map(e=>e.effect);break;case"cim-marker-placement-param":I.overrides.length&&f.set(y,{placementInfo:I,compiledOverrides:(await Promise.all(I.overrides.map(e=>h(r,e,o,!1)))).filter(e)}),a[y]=I.placement;break;case"text-rasterization-param":{if(I.overrides.length){const t=I.overrides.map(e=>h(r,e,o,I.useLegacyLabelEvaluationRules??!1));l.set(y,{compiledOverrides:(await Promise.all(t)).filter(e),rasterizationParam:I,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:I.resource};a[y]=await t.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(I.overrides.length){const t=I.overrides.map(e=>h(r,e,o,!1));l.set(y,{compiledOverrides:(await Promise.all(t)).filter(e),rasterizationParam:I,objectIdToResourceId:new Map});continue}if("animated"===I.resource.type){l.set(y,{compiledOverrides:[],rasterizationParam:I,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:I.resource};a[y]=await t.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=I;if(_(e)){const t={compiledMarkerInfos:[]};await Promise.all(e.map(async e=>{const s={props:{}};for(const t in e)if(P(e[t])){const a=await v(r,e[t],o);s.compiledExpressionMap||(s.compiledExpressionMap=new Map);const i=s.compiledExpressionMap;a&&i.set(t,a)}else s.props[t]=e[t];t.compiledMarkerInfos.push(s)})),d.set(y,t)}else a[y]={type:"cim-marker-transform-info",infos:e};break}case"animation-params":{const{params:e}=I,s=n(e);if(_(s)){const e=await Promise.all(s.map(e=>c(e,r)));u.set(y,{params:e,propertyIdToResourceId:new Map,key:y})}else{const e=p(s),r=await t.fetchResourceImmediate({type:"animation-info",resource:e});null!=r&&"sprite"===r.type&&(a[y]={dataRow:r.rect.y,dataColumn:r.rect.x})}break}default:a[y]=I}}else a[y]=I}return new I(s,a,i,m,f,l,d,u)}constructor(e,r,t,s,a,i,n,c){this.inputMeshParams=e,this._resolvedMeshParams=r,this._dynamicProperties=t,this._dynamicEffectProperties=s,this._dynamicPlacementProperties=a,this._dynamicAsyncProperties=i,this._dynamicTransformProperties=n,this._dynamicAsyncAnimations=c,this.evaluator=e=>e,this._arcadeDependencies=new Set;for(const p of this._expressions())o(this._arcadeDependencies,p)}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size||this._dynamicAsyncAnimations.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(e,s,o){for(const i of this._dynamicAsyncProperties.values()){const c=t(i.rasterizationParam.resource);"animated"===i.rasterizationParam.resource.type&&i.rasterizationParam.resource.randomizeStartTime&&(c.primitiveName="__RESERVED__PRIMITIVE__NAME__",c.startGroup=a(s.getObjectId()||0));for(const{primitiveName:e,propertyName:t,computed:a,defaultValue:m,valueExpressionInfo:f}of i.compiledOverrides)try{const r="animated"===i.rasterizationParam.resource.type?c.primitiveName:e;d(c,r,t,a,s,o,m)}catch(n){y().errorOnce(new r("invalid-arcade-expression","Encountered an error when evaluating the arcade expression",{error:n,valueExpressionInfo:f}))}const p=e.enqueueRequest({type:"cim-rasterization-info",resource:c});i.objectIdToResourceId.set(s.getObjectId(),p)}for(const r of this._dynamicAsyncAnimations.values()){const t=r.params.map(e=>m(e,s,o)).map(i).map(e=>e.simplify()),a=f(t),n=e.enqueueRequest({type:"animation-info",resource:a});r.propertyIdToResourceId.set(s.getObjectId()+"."+r.key,n)}}evaluateMeshParams(e,r,t){for(const[s,o]of this._dynamicProperties.entries())this._resolvedMeshParams[s]=o.computed.readWithDefault(r,t,o.defaultValue);for(const[s,o]of this._dynamicPlacementProperties.entries())for(const{computed:e,defaultValue:a,propertyName:i}of o.compiledOverrides){const n=e.readWithDefault(r,t,a);o.placementInfo.placement[i]=n,this._resolvedMeshParams[s]=o.placementInfo.placement}for(const[s,o]of this._dynamicEffectProperties.entries())for(const e of o.effects){for(const{computed:s,defaultValue:o,propertyName:a}of e.compiledOverrides){const i=s.readWithDefault(r,t,o);e.effect[a]=i}this._resolvedMeshParams[s]=o.effects.map(e=>e.effect)}for(const[s,o]of this._dynamicTransformProperties.entries()){const e={type:"cim-marker-transform-info",infos:[]};for(const s of o.compiledMarkerInfos){const o={...s.props};if(s.compiledExpressionMap)for(const[e,a]of s.compiledExpressionMap){const s=a.computed.readWithDefault(r,t,a.defaultValue);o[e]="number"==typeof s||"boolean"==typeof s?s:a.defaultValue}e.infos.push(o)}this._resolvedMeshParams[s]=e}for(const[s,o]of this._dynamicAsyncProperties.entries()){const t=o.objectIdToResourceId.get(r.getObjectId());if(null==t)continue;const a=e.getResource(t);this._resolvedMeshParams[s]=a}for(const[s,o]of this._dynamicAsyncAnimations.entries()){const t=o.propertyIdToResourceId.get(r.getObjectId()+"."+s);if(null==t)continue;const a=e.getResource(t);this._resolvedMeshParams[s]={dataRow:a.rect.y,dataColumn:a.rect.x}}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}hasArcadeDependency(e){return this._arcadeDependencies.has(e)}*_expressions(){for(const e of this._dynamicProperties.values())yield e.computed;for(const e of this._dynamicEffectProperties.values())for(const r of e.effects)for(const e of r.compiledOverrides)yield e.computed;for(const e of this._dynamicPlacementProperties.values())for(const r of e.compiledOverrides)yield r.computed;for(const e of this._dynamicAsyncProperties.values())for(const r of e.compiledOverrides)yield r.computed;for(const e of this._dynamicTransformProperties.values())for(const r of e.compiledMarkerInfos)if(null!=r.compiledExpressionMap)for(const e of r.compiledExpressionMap.values())yield e.computed;for(const e of this._dynamicAsyncAnimations.values())for(const r of e.params)yield*l(r)}}export{I as MeshWriterInputEvaluator,P as hasExpression};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as r,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js";import{Techniques as h}from"../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{TechniqueType as d}from"../../engine/webgl/shaderGraph/techniques/TechniqueType.js";import{RenderState as l}from"./RenderState.js";import{renderHighlight as u}from"../support/util.js";class c{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class _ extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._shouldUnlockAttributeView=!1,this._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),this._layerView.requestUpdate(),this._renderState){const e=Array.from(this._renderState.tiles()).filter(e=>e.needsUpload);if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._subscriptions.get(t.key.id)?.end(),this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter(),this.requestRender())}const t=this._layerView.subscriptionManager.updateVisibility();this.setVisibleTiles(t);for(const s of this.children)s.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case r.MAP:return this._renderMapPhase(e);case r.HIGHLIGHT:return this._renderHighlightPhase(e);case r.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight}get _layer(){return this._layerView.layer}_getHeatmapInstance(e){if(null==this._instanceStore||!(e.drawPhase&h.heatmap.drawPhase))return null;for(const t of this._instanceStore.values())if(p(t))return t;return null}get tiles(){return this._renderState?.tiles()}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter(e=>this._visibleTiles.has(e.key.id)):[]}updateAttributeView(e){this.requestRender(),this.attributeView.requestUpdate(e),this.hasLabels&&(this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter())}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe)if(this._subscriptions.has(t))this._subscriptions.get(t).version=s;else{const e=new c(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise)}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new l(()=>this._stage,e=>this._subscriptions.get(e)?.version,e,this.layerView.view.labelManager.symbolFader,this,this.tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const i of t)s.set(i.fieldName,{minValue:i.minValue,maxValue:i.maxValue})}lockForOverrides(){this._renderState?.lockUploads(),this._lockStatisticUpdates=!0,this.attributeView.locked||(this.attributeView.lockTextureUploads(),this._shouldUnlockAttributeView=!0)}unlockForOverrides(){this._renderState?.unlockUploads(),this._shouldUnlockAttributeView&&(this.attributeView.unlockTextureUploads(),this._shouldUnlockAttributeView=!1),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this._renderState?.flush(),this.requestRender()}trySwapRenderState(){if(this._renderStateNext){has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`);const e=new Map;for(const t of this._renderState?.tiles()||[])e.set(t.id,t.metricsVisibility);this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderState.flush();for(const t of this._renderState.tiles())t.copyMetricsVisibility(e.get(t.id)||new Set);this._renderStateNext=null}this.requestRender()}setVisibleTiles(e){this._visibleTiles=e;for(const t of this.tiles??[])t.rendering=e.has(t.key.id)}async onMessage(t,s){e(s);const i=t.inner;if(!this._subscriptions.has(i.id))return;const r=this._subscriptions.get(i.id);if(r.version!==i.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${i.subscriptionVesrion} != ${r.version}`;console.debug(`Version[${e}] Tile[${i.id}] FeatureContainer - Dropping message, outdated version]`,i)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==i.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${i.version}]`),n.enqueueUpdate(t),this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find(({x:t,y:s})=>t===e.x&&s===e.y);const i=t();return s?s.resolvers.push(i):(s={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(s)),this.requestRender(),i.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const i of this.children)if(i.getSortKeys(t).forEach((e,t)=>s.set(t,e)),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,i=e.state.scale;i<=(t||1/0)&&i>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){if(null==this._getHeatmapInstance(e))super.setStencilReference(e);else for(const t of this.children)t.stencilRef=h.heatmap.getStencilReference(t)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&u(e,!1,e=>{this._renderFeatures(e,n.Highlight)})}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,i=t.getBoundFramebufferObject(),a=t.getViewport(),o=e.passOptions,h=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=r.HITTEST;const{distance:d,smallSymbolDistance:l}=e.passOptions,u=Math.max(d,l);for(const r of this.children)r.visible&&r.containsScreenPoint(e.state,e.passOptions.position,2*u)&&this._renderTile(r,e,n.All);s.draw(e),s.unbind(),t.bindFramebuffer(i),t.restoreViewport(a),e.passOptions=o,e.drawPhase=h}_renderFeatures(e,t){const s=this._getHeatmapInstance(e);null!=s?this._renderHeatmapFeatures(e,t,s):this._renderGeometryFeatures(e,t)}_renderGeometryFeatures(e,t){for(const s of this.children)s.visible&&this._renderTile(s,e,t)}_renderHeatmapFeatures(e,t,s){for(const i of this.children)i.visible&&this._renderTile(i,e,t,d.Heatmap);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,i){const r=has("featurelayer-strict-draw-order")?a.STRICT_ORDER:has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,n=e.getDisplayList(this._instanceStore,r);t.selection=s,n?.render(t,i)}}function p(e){return e.techniqueRef.type===d.Heatmap}export{_ as FeatureContainer};
5
+ import has from"../../../../core/has.js";import{throwIfAborted as e,createResolver as t}from"../../../../core/promiseUtils.js";import{UpdatingHandles as s}from"../../../../core/support/UpdatingHandles.js";import{AFeatureContainer as i}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as r,FeatureSelection as n,FeatureBatchingStrategy as a}from"../../engine/webgl/enums.js";import o from"../../engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js";import{Techniques as h}from"../../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import{TechniqueType as d}from"../../engine/webgl/shaderGraph/techniques/TechniqueType.js";import{RenderState as l}from"./RenderState.js";import{renderHighlight as u}from"../support/util.js";class c{constructor(e,s){this.id=e,this.version=s,this._resolver=t(),this._done=!1}get done(){return this._done}get promise(){return this._resolver.promise}end(){this._resolver.resolve(),this._done=!0}destroy(){this._resolver.reject()}}class _ extends i{constructor(e){super(e.view.featuresTilingScheme),this.updatingHandles=new s,this._hitTestsRequests=[],this._store=new o,this._visibleTiles=new Set,this._subscriptions=new Map,this._updateStatisticsRequests=[],this._lockStatisticUpdates=!1,this._shouldUnlockAttributeView=!1,this._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),this._layerView.requestUpdate(),this._renderState){const e=Array.from(this._renderState.tiles()).filter(e=>e.needsUpload);if(e.length){e[Math.floor(Math.random()*e.length)].upload(),e.length>=2&&this.requestRender()}for(const t of this._renderState.tiles())t.tryReady(this.attributeView.currentEpoch)&&(this._subscriptions.get(t.key.id)?.end(),this._layerView.requestUpdate(),this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter(),this.requestRender())}const t=this._layerView.subscriptionManager.updateVisibility();this.setVisibleTiles(t);for(const s of this.children)s.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case r.MAP:return this._renderMapPhase(e);case r.HIGHLIGHT:return this._renderHighlightPhase(e);case r.LABEL:return this._renderLabelPhase(e)}}subscriptions(){return this._subscriptions.values()}get _instanceStore(){return this._store}get instanceStore(){return this._store}get layerView(){return this._layerView}get hasLabels(){return this._layerView.labelingCollisionInfos.length>0}get hasHighlight(){return this._layerView.hasHighlight}get _layer(){return this._layerView.layer}_getHeatmapInstance(e){if(null==this._instanceStore||!(e.drawPhase&h.heatmap.drawPhase))return null;for(const t of this._instanceStore.values())if(p(t))return t;return null}get tiles(){return this._renderState?.tiles()}get children(){return this._renderState?Array.from(this._renderState.tiles()).filter(e=>this._visibleTiles.has(e.key.id)):[]}updateAttributeView(e){this.requestRender(),this.attributeView.requestUpdate(e),this.hasLabels&&(this._layerView.view.labelManager.requestUpdate(),this._layerView.view.labelManager.symbolFader.restartDeclutter())}updateSubscriptions(e){for(const{tileId:t,version:s}of e.subscribe){if(!this._subscriptions.has(t)){const e=new c(t,s);this._subscriptions.set(t,e),this.updatingHandles.addPromise(e.promise);continue}this._subscriptions.get(t).version=s}for(const t of e.unsubscribe){const e=this._subscriptions.get(t);e?.destroy(),this._subscriptions.delete(t),this.removeTile(t)}}isDone(e){return!!this._renderState&&this._renderState.isTileDone(e)}async updateRenderState(e){has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureContainer.updateRenderState`),this._renderStateNext=new l(()=>this._stage,e=>this._subscriptions.get(e)?.version,e,this.layerView.view.labelManager.symbolFader,this,this.tileInfoView)}getDisplayStatistics(e,t){const s=this._statisticsByLevel.get(e);return s?s.get(t):null}updateStatistics(e,t){if(this._lockStatisticUpdates)return void this._updateStatisticsRequests.push({level:e,statistics:t});let s=this._statisticsByLevel.get(e);s||(s=new Map,this._statisticsByLevel.set(e,s));for(const i of t)s.set(i.fieldName,{minValue:i.minValue,maxValue:i.maxValue})}lockForOverrides(){this._renderState?.lockUploads(),this._lockStatisticUpdates=!0,this.attributeView.locked||(this.attributeView.lockTextureUploads(),this._shouldUnlockAttributeView=!0)}unlockForOverrides(){this._renderState?.unlockUploads(),this._shouldUnlockAttributeView&&(this.attributeView.unlockTextureUploads(),this._shouldUnlockAttributeView=!1),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this._renderState?.flush(),this.requestRender()}trySwapRenderState(){if(this._renderStateNext){has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`);const e=new Map;for(const t of this._renderState?.tiles()||[])e.set(t.id,t.metricsVisibility);this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderState.flush();for(const t of this._renderState.tiles())t.copyMetricsVisibility(e.get(t.id)||new Set);this._renderStateNext=null}this.requestRender()}setVisibleTiles(e){this._visibleTiles=e;for(const t of this.tiles??[])t.rendering=e.has(t.key.id)}async onMessage(t,s){e(s);const i=t.inner;if(!this._subscriptions.has(i.id))return;const r=this._subscriptions.get(i.id);if(r.version!==i.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${i.subscriptionVesrion} != ${r.version}`;console.debug(`Version[${e}] Tile[${i.id}] FeatureContainer - Dropping message, outdated version]`,i)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==i.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${i.version}]`),n.enqueueUpdate(t),this.requestRender(),this._layerView.view.labelManager.requestUpdate(),this._layerView.requestUpdate()}removeTile(e){(this._renderState||this._renderStateNext)&&(this._renderState&&this._renderState.removeTile(e),this._renderStateNext&&this._renderStateNext.removeTile(e))}hitTest(e){let s=this._hitTestsRequests.find(({x:t,y:s})=>t===e.x&&s===e.y);const i=t();return s?s.resolvers.push(i):(s={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(s)),this.requestRender(),i.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const i of this.children)if(i.getSortKeys(t).forEach((e,t)=>s.set(t,e)),s.size===t.size)break;return s}get hasAnimation(){return this.hasLabels}doRender(e){const{minScale:t,maxScale:s}=this._layer.effectiveScaleRange,i=e.state.scale;i<=(t||1/0)&&i>=s&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}setStencilReference(e){if(null==this._getHeatmapInstance(e))super.setStencilReference(e);else for(const t of this.children)t.stencilRef=h.heatmap.getStencilReference(t)}_renderMapPhase(e){this._layerView.featureEffectView.hasEffects?(this._renderOutsideEffect(e),this._renderInsideEffect(e)):this._renderFeatures(e,n.All),this._hitTestsRequests.length>0&&this._renderHittest(e)}_renderHighlightPhase(e){this.hasHighlight&&u(e,!1,e=>{this._renderFeatures(e,n.Highlight)})}_renderLabelPhase(e){this._renderFeatures(e,n.All)}_renderInsideEffect(e){const t=e.painter.effects.insideEffect;t.bind(e),this._renderFeatures(e,n.InsideEffect),t.draw(e,this._layerView.featureEffectView.includedEffects),t.unbind()}_renderOutsideEffect(e){const t=e.painter.effects.outsideEffect;t.bind(e),this._renderFeatures(e,n.OutsideEffect),t.draw(e,this._layerView.featureEffectView.excludedEffects),t.unbind()}_renderHittest(e){const{context:t}=e,s=e.painter.effects.hittest,i=t.getBoundFramebufferObject(),a=t.getViewport(),o=e.passOptions,h=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=r.HITTEST;const{distance:d,smallSymbolDistance:l}=e.passOptions,u=Math.max(d,l);for(const r of this.children)r.visible&&r.containsScreenPoint(e.state,e.passOptions.position,2*u)&&this._renderTile(r,e,n.All);s.draw(e),s.unbind(),t.bindFramebuffer(i),t.restoreViewport(a),e.passOptions=o,e.drawPhase=h}_renderFeatures(e,t){const s=this._getHeatmapInstance(e);null!=s?this._renderHeatmapFeatures(e,t,s):this._renderGeometryFeatures(e,t)}_renderGeometryFeatures(e,t){for(const s of this.children)s.visible&&this._renderTile(s,e,t)}_renderHeatmapFeatures(e,t,s){for(const i of this.children)i.visible&&this._renderTile(i,e,t,d.Heatmap);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,i){const r=has("featurelayer-strict-draw-order")?a.STRICT_ORDER:has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,n=e.getDisplayList(this._instanceStore,r);t.selection=s,n?.render(t,i)}}function p(e){return e.techniqueRef.type===d.Heatmap}export{_ as FeatureContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{convertToFeature as e}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as t}from"../../../../../layers/graphics/OptimizedFeature.js";import s from"../../../../../layers/graphics/OptimizedGeometry.js";import i from"../../../../../layers/support/FieldsIndex.js";import{tileSize as r}from"../../../engine/webgl/definitions.js";import{ComputedAggregateField as n}from"../aggregation/ComputedAggregateField.js";import{GridCell as a}from"../aggregation/GridCell.js";import{pixelsPerMapUnit as l}from"../aggregation/GridSpatialIndex.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as d}from"./AProcessorStrategy.js";import{WithDisplayId as u}from"./support/WithDisplayId.js";import{FeatureTileAppendMessage as c}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as h}from"../support/ComputedAttributeStorage.js";import p from"../support/FeatureFilterEvaluator.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as g}from"../support/FeatureSetReaderJSON.js";import _ from"../../../tiling/TileKey.js";const m=128;class y extends d{constructor(e){super(e),this.didSend=!1,this.done=!1}}class S{constructor(e,t,s,i,r){this._level=e,this._scale=t,this._indexOptions=s,this._clusterRadius=i,this._store=r,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const e of this._clusters.values())this._store.releaseDisplayIdForObjectId(e.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const e of this._clusters.values()){const s=e.inner.getCentroid(null),i=new t(s,e.inner.getAttributes(),null,e.inner.id,e.displayId);yield i}}clusters(){return this._clusters.values()}updateChunks(e,t){let s=!1;for(const a of e){const e=a.queryInfo;if("tileId"in e){if(new _(e.tileId).level!==this._level)continue}if(!this._handledChunks.has(a.normalizedChunkId)){this._handledChunks.add(a.normalizedChunkId),s=!0;a.getAggregateIndex({...this._indexOptions,scale:this._scale}).put(this._cells)}}const i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=l(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:a}of t){const e=a.tile.bounds,t=Math.floor(e[0]*r/n),s=Math.floor(e[1]*r/n),l=Math.ceil(e[2]*r/n),o=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,t),i.yMin=Math.min(i.yMin,s),i.xMax=Math.max(i.xMax,l),i.yMax=Math.max(i.yMax,o)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),s}async updateStatistics(e){let t=!1;for(const s of this._clusters.values())s.inner.count>1&&(t=this._updateAggregateStatistics(this._statistics,s.inner)||t);if(t){const t=Array.from(this._statistics.entries()).map(([e,t])=>({fieldName:e,minValue:t.minValue,maxValue:t.maxValue}));await e.container.updateStatistics(this._level,t)}}createAggregateFeatures(e,i){const n=e.subscription,a=[],l=n.tile.transform;for(const o of this._clusters.values()){let e=o.inner.getCentroidX(l);const i=o.inner.getCentroidY(l),d=n.tile.lod,u=d.wrap?d.worldSize[0]:null,c=1===o.inner.count?o.inner.firstObjectId:o.inner.id,h=o.displayId;if(null!=u)if(1===u){const n=new s([],[e,i]),l=new t(n,o.inner.getAttributes(),null,c,h);l.geometry.coords[0]-=r,a.push(l);const d=new s([],[e,i]),u=new t(d,o.inner.getAttributes(),null,c,h);u.geometry.coords[0]+=r,a.push(u)}else e>r+r/2?e-=u*r:e<-256&&(e+=u*r);if(e<r+m&&e>=-m&&i<r+m&&i>=-m){const r=new s([],[e,i]),n=new t(r,o.inner.getAttributes(),null,c,h);a.push(n)}}return g.fromOptimizedFeatures(a,i,n.tile.transform)}_clusterCells(e){let t=Array.from(this._cells.values());t=t.sort((e,t)=>t.count-e.count);const s=[];for(const a of this._clusters.values())s.push(a.inner.id);this._clusters.clear();const i=this._clusterRadius*(1/l(this._indexOptions.spatialReference,this._scale)),r=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const l of t){if(n.has(l.id))continue;if(l.gridX<e.xMin||l.gridX>e.xMax||l.gridY<e.yMin||l.gridY>e.yMax)continue;const t=this._store.createDisplayIdForObjectId(l.id),s=new u(l.clone(),t);n.add(l.id),this._clusters.set(l.id,s);const o=l.centroidXWorld,d=l.centroidYWorld;for(let e=l.gridY-r;e<=l.gridY+r;e++)for(let t=l.gridX-r;t<=l.gridX+r;t++){if(e===l.gridY&&t===l.gridX)continue;const r=this._cells.get(a.createId(t,e));if(!r||n.has(r.id))continue;const u=Math.abs(r.centroidXWorld-o),c=Math.abs(r.centroidYWorld-d);u<i&&c<i&&(s.inner.merge(r),n.add(r.id))}}for(const a of s)this._store.releaseDisplayIdForObjectId(a)}_updateAggregateStatistics(e,t){let s=!1;for(const i of t.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const t=i.value,r=i.field,n=e.get(r.name);if(n){const{minValue:e,maxValue:i}=n,r=Math.min(n.minValue,t),a=Math.max(n.maxValue,t);e===r&&i===a||(n.minValue=r,n.maxValue=a,s=!0)}else e.set(r.name,{minValue:t,maxValue:t}),s=!0}return s}}class x extends o{static async create(e,t,s,i,r,a,l){const o=new h({spatialReference:s}),d={type:"grid",fields:await Promise.all(t.fields.map(async e=>n.create(o,e))),spatialReference:s,featureFilter:t.featureFilter?await p.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:t.featureFilter}):null,cellSize:t.clusterRadius/4,arcadeContextInfo:a,sqlOptions:l};return new x(e,t.clusterRadius,d,t.fields,i,r,l)}constructor(e,t,s,r,n,a,l){super(n,a,s.spatialReference,s.fields,l),this._connection=e,this._clusterRadius=t,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=f.createFeature({geometryType:"esriGeometryPoint",featureIdInfo:{type:"object-id",fieldName:"aggregateId"},fieldsIndex:new i([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,outSpatialReference:n.metadata.outSpatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const e of this._cellsPerScale.values())e.destroy();this._cellsPerScale.clear()}onSubscribe(e){super.onSubscribe(e),this._requiredLevel=e.tile.level,this._requiredScale=e.tile.scale}createState(e){return new y(e)}async*applyOverrideUpdate(e){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(e,t,s){const i=new Map(e.map(e=>[t(e),e])),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const a of n.clusters()){const e=i.get(a.inner.id);if(null==e){if(1===a.inner.count){const{firstObjectId:e}=a.inner,t=e?i.get(e):null;if(null!=t){const n=s(a.displayId,t,e);r.push(n),i.delete(e)}}}else{const t=s(a.displayId,e,a.inner.id);r.push(t),i.delete(a.inner.id)}}return r}getDisplayFeatures(t){const s=new Set(t),i=new Set,r=[],n=[],a=this._getClusterState(this._requiredLevel,this._requiredScale);for(const l of a.aggregatesWorldSpace())if(s.has(l.displayId)&&!i.has(l.displayId)){const t=e(l,this._metadata.geometryType,!1,!1);if(i.add(l.displayId),1===t.attributes.cluster_count){r.push({...t,displayId:l.displayId});continue}n.push({...t,displayId:l.displayId})}return{features:r,aggregates:n,tracks:[]}}getFeatureObjectIdsForAggregate(e){const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.clusters())if(s.inner.id===e)return Array.from(s.inner.containedObjectIds);return[]}async*updateChunks(){const e=this._source.chunks();if(!e.length)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter(e=>e.subscription.tile.level===this._requiredLevel);if(t.updateChunks(e,s)||!this._source.updateTracking.updating)for(const n of s)n.subscription.tile.level===this._requiredLevel&&(n.didSend=!1,n.done=!1);const i=Array.from(this._sendStates.values()).filter(e=>e.done).map(e=>e.subscription.tile.key),r=new Set(i);for(const n of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some(e=>e.containsChild(n.subscription.tile.key)))continue;if(n.subscription.tile.key.getChildKeys().every(e=>r.has(e)))continue}n.didSend||n.subscription.tile.level!==this._requiredLevel||(n.didSend=!0,yield*this._update(n,t,this._source))}await t.updateStatistics(this._connection)}forEachAggregateWorldSpace(e){if(null==this._requiredLevel||null==this._requiredScale)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.aggregatesWorldSpace())e(s)}_getClusterState(e,t){if(null==e||null==t)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(t);return s||(s=new S(e,t,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(t,s)),s}async*_update(e,t,s){if(e.done)return;const i=t.createAggregateFeatures(e,this._metadata);this.events.emit("changed"),e.done=!s.updateTracking.updating;const r=i.getCursor(),n=e.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.arcadeContextInfo);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n,this._sqlOptions);const a=new c(e.subscription,i,!0,e.done,{});yield a}}export{y as ClusterState,x as ClusterStrategy};
5
+ import{convertToFeature as e}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as t}from"../../../../../layers/graphics/OptimizedFeature.js";import s from"../../../../../layers/graphics/OptimizedGeometry.js";import i from"../../../../../layers/support/FieldsIndex.js";import{tileSize as r}from"../../../engine/webgl/definitions.js";import{ComputedAggregateField as n}from"../aggregation/ComputedAggregateField.js";import{GridCell as a}from"../aggregation/GridCell.js";import{pixelsPerMapUnit as l}from"../aggregation/GridSpatialIndex.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as d}from"./AProcessorStrategy.js";import{WithDisplayId as u}from"./support/WithDisplayId.js";import{FeatureTileAppendMessage as c}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as h}from"../support/ComputedAttributeStorage.js";import p from"../support/FeatureFilterEvaluator.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as g}from"../support/FeatureSetReaderJSON.js";import _ from"../../../tiling/TileKey.js";const m=128;class y extends d{constructor(e){super(e),this.didSend=!1,this.done=!1}}class S{constructor(e,t,s,i,r){this._level=e,this._scale=t,this._indexOptions=s,this._clusterRadius=i,this._store=r,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const e of this._clusters.values())this._store.releaseDisplayIdForObjectId(e.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const e of this._clusters.values()){const s=e.inner.getCentroid(null),i=new t(s,e.inner.getAttributes(),null,e.inner.id,e.displayId);yield i}}clusters(){return this._clusters.values()}updateChunks(e,t){let s=!1;for(const a of e){const e=a.queryInfo;if("tileId"in e){if(new _(e.tileId).level!==this._level)continue}if(!this._handledChunks.has(a.normalizedChunkId)){this._handledChunks.add(a.normalizedChunkId),s=!0;a.getAggregateIndex({...this._indexOptions,scale:this._scale}).put(this._cells)}}const i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=l(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:a}of t){const e=a.tile.bounds,t=Math.floor(e[0]*r/n),s=Math.floor(e[1]*r/n),l=Math.ceil(e[2]*r/n),o=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,t),i.yMin=Math.min(i.yMin,s),i.xMax=Math.max(i.xMax,l),i.yMax=Math.max(i.yMax,o)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),s}async updateStatistics(e){let t=!1;for(const s of this._clusters.values())s.inner.count>1&&(t=this._updateAggregateStatistics(this._statistics,s.inner)||t);if(t){const t=Array.from(this._statistics.entries()).map(([e,t])=>({fieldName:e,minValue:t.minValue,maxValue:t.maxValue}));await e.container.updateStatistics(this._level,t)}}createAggregateFeatures(e,i){const n=e.subscription,a=[],l=n.tile.transform;for(const o of this._clusters.values()){let e=o.inner.getCentroidX(l);const i=o.inner.getCentroidY(l),d=n.tile.lod,u=d.wrap?d.worldSize[0]:null,c=1===o.inner.count?o.inner.firstObjectId:o.inner.id,h=o.displayId;if(null!=u)if(1===u){const n=new s([],[e,i]),l=new t(n,o.inner.getAttributes(),null,c,h);l.geometry.coords[0]-=r,a.push(l);const d=new s([],[e,i]),u=new t(d,o.inner.getAttributes(),null,c,h);u.geometry.coords[0]+=r,a.push(u)}else e>r+r/2?e-=u*r:e<-256&&(e+=u*r);if(e<r+m&&e>=-m&&i<r+m&&i>=-m){const r=new s([],[e,i]),n=new t(r,o.inner.getAttributes(),null,c,h);a.push(n)}}return g.fromOptimizedFeatures(a,i,n.tile.transform)}_clusterCells(e){let t=Array.from(this._cells.values());t=t.sort((e,t)=>t.count-e.count);const s=[];for(const a of this._clusters.values())s.push(a.inner.id);this._clusters.clear();const i=this._clusterRadius*(1/l(this._indexOptions.spatialReference,this._scale)),r=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const l of t){if(n.has(l.id))continue;if(l.gridX<e.xMin||l.gridX>e.xMax||l.gridY<e.yMin||l.gridY>e.yMax)continue;const t=this._store.createDisplayIdForObjectId(l.id),s=new u(l.clone(),t);n.add(l.id),this._clusters.set(l.id,s);const o=l.centroidXWorld,d=l.centroidYWorld;for(let e=l.gridY-r;e<=l.gridY+r;e++)for(let t=l.gridX-r;t<=l.gridX+r;t++){if(e===l.gridY&&t===l.gridX)continue;const r=this._cells.get(a.createId(t,e));if(!r||n.has(r.id))continue;const u=Math.abs(r.centroidXWorld-o),c=Math.abs(r.centroidYWorld-d);u<i&&c<i&&(s.inner.merge(r),n.add(r.id))}}for(const a of s)this._store.releaseDisplayIdForObjectId(a)}_updateAggregateStatistics(e,t){let s=!1;for(const i of t.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const t=i.value,r=i.field,n=e.get(r.name);if(n){const{minValue:e,maxValue:i}=n,r=Math.min(n.minValue,t),a=Math.max(n.maxValue,t);e===r&&i===a||(n.minValue=r,n.maxValue=a,s=!0);continue}e.set(r.name,{minValue:t,maxValue:t}),s=!0}return s}}class x extends o{static async create(e,t,s,i,r,a,l){const o=new h({spatialReference:s}),d={type:"grid",fields:await Promise.all(t.fields.map(async e=>n.create(o,e))),spatialReference:s,featureFilter:t.featureFilter?await p.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:t.featureFilter}):null,cellSize:t.clusterRadius/4,arcadeContextInfo:a,sqlOptions:l};return new x(e,t.clusterRadius,d,t.fields,i,r,l)}constructor(e,t,s,r,n,a,l){super(n,a,s.spatialReference,s.fields,l),this._connection=e,this._clusterRadius=t,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=f.createFeature({geometryType:"esriGeometryPoint",featureIdInfo:{type:"object-id",fieldName:"aggregateId"},fieldsIndex:new i([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,outSpatialReference:n.metadata.outSpatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const e of this._cellsPerScale.values())e.destroy();this._cellsPerScale.clear()}onSubscribe(e){super.onSubscribe(e),this._requiredLevel=e.tile.level,this._requiredScale=e.tile.scale}createState(e){return new y(e)}async*applyOverrideUpdate(e){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(e,t,s){const i=new Map(e.map(e=>[t(e),e])),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const a of n.clusters()){const e=i.get(a.inner.id);if(null!=e){const t=s(a.displayId,e,a.inner.id);r.push(t),i.delete(a.inner.id);continue}if(1===a.inner.count){const{firstObjectId:e}=a.inner,t=e?i.get(e):null;if(null!=t){const n=s(a.displayId,t,e);r.push(n),i.delete(e)}}}return r}getDisplayFeatures(t){const s=new Set(t),i=new Set,r=[],n=[],a=this._getClusterState(this._requiredLevel,this._requiredScale);for(const l of a.aggregatesWorldSpace())if(s.has(l.displayId)&&!i.has(l.displayId)){const t=e(l,this._metadata.geometryType,!1,!1);if(i.add(l.displayId),1===t.attributes.cluster_count){r.push({...t,displayId:l.displayId});continue}n.push({...t,displayId:l.displayId})}return{features:r,aggregates:n,tracks:[]}}getFeatureObjectIdsForAggregate(e){const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.clusters())if(s.inner.id===e)return Array.from(s.inner.containedObjectIds);return[]}async*updateChunks(){const e=this._source.chunks();if(!e.length)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter(e=>e.subscription.tile.level===this._requiredLevel);if(t.updateChunks(e,s)||!this._source.updateTracking.updating)for(const n of s)n.subscription.tile.level===this._requiredLevel&&(n.didSend=!1,n.done=!1);const i=Array.from(this._sendStates.values()).filter(e=>e.done).map(e=>e.subscription.tile.key),r=new Set(i);for(const n of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some(e=>e.containsChild(n.subscription.tile.key)))continue;if(n.subscription.tile.key.getChildKeys().every(e=>r.has(e)))continue}n.didSend||n.subscription.tile.level!==this._requiredLevel||(n.didSend=!0,yield*this._update(n,t,this._source))}await t.updateStatistics(this._connection)}forEachAggregateWorldSpace(e){if(null==this._requiredLevel||null==this._requiredScale)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of t.aggregatesWorldSpace())e(s)}_getClusterState(e,t){if(null==e||null==t)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(t);return s||(s=new S(e,t,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(t,s)),s}async*_update(e,t,s){if(e.done)return;const i=t.createAggregateFeatures(e,this._metadata);this.events.emit("changed"),e.done=!s.updateTracking.updating;const r=i.getCursor(),n=e.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.arcadeContextInfo);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n,this._sqlOptions);const a=new c(e.subscription,i,!0,e.done,{});yield a}}export{y as ClusterState,x as ClusterStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../../../core/arrayUtils.js";import e from"../../../../../core/Logger.js";import{assertIsSome as s}from"../../../../../core/maybe.js";import{isLoaded as r,load as i,execute as a}from"../../../../../geometry/operators/gx/operatorGeodeticDensify.js";import{geodeticCurveType as o}from"../../../../../geometry/operators/support/geodeticCurveType.js";import{intersectsWithMargin as n,fromValues as l,intersects as c,empty as d,expandPointInPlace as u}from"../../../../../geometry/support/aaBoundingRect.js";import{getClosestDenormalizedXToReference as h}from"../../../../../geometry/support/normalizeUtils.js";import{normalizeCentralMeridianForDisplay as m}from"../../../../../geometry/support/normalizeUtilsSync.js";import{quantizeOptimizedGeometry as p,convertToGeometry as f,convertFromNestedArray as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as _}from"../../../../../layers/graphics/OptimizedFeature.js";import b from"../../../../../layers/graphics/OptimizedGeometry.js";import{internalTrackPartField as y,TrackPart as I,externalTrackLineOidPrefix as k,internalTimeReceivedField as v}from"../../../../../layers/support/streamLayerUtils.js";import{tileSize as F}from"../../../engine/webgl/definitions.js";import{AccumulatedStatistics as j}from"../aggregation/AccumulatedStatistics.js";import{ComputedAggregateField as O}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as T}from"./AAggregateStrategy.js";import{ASendState as x}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as S}from"../sources/FeatureSourceMessage.js";import{createArcadeEvaluationOptions as R}from"../support/arcadeUtils.js";import{ComputedAttributeStorage as w}from"../support/ComputedAttributeStorage.js";import D from"../support/FeatureFilterEvaluator.js";import{FeatureMetadata as L}from"../support/FeatureMetadata.js";import{FeatureSetReaderIndirect as A}from"../support/FeatureSetReaderIndirect.js";import{FeatureSetReaderJSON as C}from"../support/FeatureSetReaderJSON.js";let G;const P=()=>e.getLogger("esri.views.2d.layers.features.processor.TrackStrategy"),z=32;class M{constructor(t,e,s,r,i){this.chunkIndex=t,this.featureIndex=e,this.objectId=s,this.displayId=r,this.time=i}}class W{static getOid(t){return k+t}constructor(t,e,s,r,i,a,o,n){this._schema=t,this.trackId=e,this.objectId=s,this.displayId=r,this._fields=i,this._spatialReference=a,this._metadata=o,this._isStream=n,this._maxDisplayDuration=this._schema.maxDisplayDuration>0?this._schema.maxDisplayDuration:1/0,this._maxDisplayObservationsPerTrack=this._schema.maxDisplayObservationsPerTrack>=1?this._schema.maxDisplayObservationsPerTrack:1/0,this._observationRecords=[],this._nextObservationRecords=[],this._trackLinePath=[],this._bounds=[],this._trackLineGeometry=new b}get _trackLineAttributes(){const t={...this._latestObservationFeature?.attributes??{},aggregateId:this.objectId,[y]:I.TrackLine};if(null!=this._statistics)for(const e of this._statistics.values())t[e.field.name]=e.value;return t}get _startTimeField(){return this._metadata.timeInfo?.startTimeField}get length(){return this._observationRecords.length}*observations(){yield*this._observationRecords}*previousObservations(){for(let t=0;t<this._observationRecords.length-1;t++)yield this._observationRecords[t]}stageObservation(t,e){this._nextObservationRecords.push(new M(t,e.getIndex(),e.getObjectId(),e.getDisplayId(),null!=this._startTimeField?e.readAttributeAsTimestamp(this._startTimeField):null))}commitObservations(t,e){const r=new Set(this._nextObservationRecords.map(t=>t.objectId)),i=this._observationRecords.filter(t=>!r.has(t.objectId)).map(t=>t.objectId);let a,o;switch(this._observationRecords=[],this._trackLinePath=[],this._isStream||null==this._startTimeField||this._nextObservationRecords.sort((t,e)=>{const s=t.time,r=e.time;return null!=s&&null!=r?s-r:0}),this._schema.timeField){case"startTimeField":a=this._metadata.timeInfo?.startTimeField;break;case"endTimeField":a=this._metadata.timeInfo?.endTimeField;break;case"timeReceived":a=this._isStream?v:null}o=this._isStream?e?.end??Date.now():e?.end??-1/0;const n=t.map(t=>t.reader.getCursor());let l;for(let c=this._nextObservationRecords.length-1;c>=0&&!(this._observationRecords.length>=this._maxDisplayObservationsPerTrack);c--){const t=this._nextObservationRecords[c],e=n[t.chunkIndex];s(e),e.setIndex(t.featureIndex);const r=null!=a?e.readAttributeAsTimestamp(a):null;(null!=r?o-r:0)>=this._maxDisplayDuration||(this._commitObservation(t,e),l??=t)}if(null!=l){const{chunkIndex:t,featureIndex:e,objectId:r,displayId:i}=l,a=n[t];s(a),a.setIndex(e);const o=new _(a.readGeometryWorldSpace(),{...a.readAttributes(),[y]:I.LatestObservation},null,r,i);this._latestObservationFeature=o}else this._latestObservationFeature=null;return this._trackLineGeometry=E(this._trackLineGeometry,this._trackLinePath,this._spatialReference),this._bounds=X(this._trackLineGeometry),this._nextObservationRecords=[],i}updateStatistics(t,e){this._statistics=j.create(this._fields);const r=t.map(t=>t.reader.getCursor());for(const{chunkIndex:i,featureIndex:a}of this._observationRecords){const t=r[i];s(t),t.setIndex(a),this._statistics.insert(t,e)}}overlapsTile(t){for(const e of this._bounds)if(n(e,t.bounds,z))return!0;return!1}getLatestObservationFeatureForTile(t){if(null==this._latestObservationFeature)return null;const{objectId:e,displayId:s,geometry:r,attributes:i}=this._latestObservationFeature,a=new b;p(a,r,!1,!1,this._metadata.geometryType,t.subscription.tile.transform);const o=l(1/0,1/0,-1/0,-1/0);N(a,(t,e)=>u(o,[t,e]));if(!c(o,l(0,0,F,F)))return null;return new _(a,i,null,e,s)}getTrackLineFeatureForTile(t){const e=new b;p(e,this._trackLineGeometry,!1,!1,"esriGeometryPolyline",t.subscription.tile.transform);return new _(e,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineOptimizedFeature(){return new _(this._trackLineGeometry,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineDisplayFeature(){const{_trackLineGeometry:t,_trackLineAttributes:e,displayId:s}=this;return{geometry:f(t,"esriGeometryPolyline",!1,!1),attributes:e,displayId:s}}_commitObservation(t,e){const s=e.readCentroidWorldSpace();let r=s?.coords[0],i=s?.coords[1];null==s&&(r=e.readXWorldSpace(),i=e.readYWorldSpace()),null!=r&&null!=i&&(this._observationRecords.unshift(t),this._trackLinePath.unshift([r,i]))}}class U extends x{constructor(t){super(t),this.done=!1}}class q extends T{static async create(t,e,s,a,o,n){const l=new w({spatialReference:e}),c=await Promise.all(t.fields.map(async t=>O.create(l,t))),d=t.featureFilter?await D.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:e,filterJSON:t.featureFilter}):null;return e.isWrappable||r()||await Promise.all([import("../../../../../geometry/operators/support/apiConverter.js"),import("../../../../../geometry/operators/support/jsonConverter.js"),i()]).then(([t,e,s])=>{G={fromGeometryToGXGeometry:e.fromGeometryToGXGeometry,toGeometry:e.toGeometry,fromSpatialReference:t.fromSpatialReference}}),new q(t,s,a,e,c,d,o,n)}constructor(t,e,s,r,i,a,o,n){super(e,s,r,i,n),this._schema=t,this._featureFilter=a,this._arcadeContextInfo=o,this._tracks=new Map,this._handledChunks=new Set,this._metadata=e.metadata.weakCloneWithAdditionalFields([{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"}]),this._trackLineMetadata=L.createFeature({geometryType:"esriGeometryPolyline",featureIdInfo:{type:"object-id",fieldName:"aggregateId"},fieldsIndex:{fields:[...this._source.metadata.fieldsIndex.fields,...this.aggregateFields,{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"},{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],timeZoneByFieldName:null},globalIdField:null,spatialReference:e.metadata.spatialReference,outSpatialReference:e.metadata.outSpatialReference,subtypeField:null,subtypes:null,timeInfo:e.metadata.timeInfo,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null})}get _isStream(){return this._source.isStream}get enablePixelBuffering(){return!0}get isAggregate(){return!1}requiresInvalidation(){const t=new Set(this._source.chunks().map(t=>t.chunkId));for(const e of t)if(!this._handledChunks.has(e))return!0;for(const e of this._handledChunks)if(!t.has(e))return!0;return!1}invalidate(){this._handledChunks.clear(),super.invalidate()}createState(t){return new U(t)}async*applyOverrideUpdate(t){P().error("Applying override to tracks is not supported")}displayMap(t,e,s){const r=new Map(t.map(t=>[e(t),t])),i=[];for(const a of this._tracks.values()){const t=r.get(a.objectId);if(null==t)for(const e of a.observations()){const t=r.get(e.objectId);if(null!=t){const a=s(e.displayId,t,e.objectId);i.push(a),r.delete(e.objectId)}}else{const e=s(a.displayId,t,a.objectId);i.push(e),r.delete(a.objectId)}}return i}getDisplayFeatures(t){const e=new Set(t),s=[],r=[],i=this._source.chunks().map(t=>t.reader.getCursor());for(const a of this._tracks.values()){e.has(a.displayId)&&r.push(a.getTrackLineDisplayFeature());for(const{displayId:t,chunkIndex:r,featureIndex:o}of a.observations())if(e.has(t)){const e=i[r];e.setIndex(o),s.push({displayId:t,attributes:{},...e.readLegacyFeatureWorldSpace()})}}return{features:s,aggregates:[],tracks:r}}getFeatureObjectIdsForAggregate(t){for(const e of this._tracks.values())if(e.objectId===t)return Array.from(e.observations(),t=>t.objectId);return[]}async*updateChunks(){0===this._handledChunks.size&&this._rebuildTracks();for(const t of this._sendStates.values())yield*this._update(t)}forEachAggregateWorldSpace(t){for(const e of this._tracks.values())t(e.getTrackLineOptimizedFeature())}_rebuildTracks(){const t=this._source.chunks();if(!t.length)return;const e=this._metadata.timeInfo?.trackIdField;if(null==e)return;const s=new Set;for(let r=0;r<t.length;r++){const i=t[r];this._handledChunks.add(i.chunkId);const a=i.reader.getCursor();for(;a.next();){const t=a.readAttribute(e),i=a.getObjectId();if(null!=t&&null!=i&&(null===this._featureFilter||this._featureFilter.check(a,this._sqlOptions))){if(a.getDisplayId()||a.setDisplayId(this._attributeStore.createDisplayIdForObjectId(i)),!this._tracks.has(t)){const e=W.getOid(t),s=this._attributeStore.createDisplayIdForObjectId(e),r=new W(this._schema,t,e,s,this.aggregateFields,this.spatialReference,this._source.metadata,this._isStream);this._tracks.set(t,r)}this._tracks.get(t).stageObservation(r,a),s.add(t)}}}for(const r of this._tracks.values())if(s.has(r.trackId)){const e=r.commitObservations(t,this._featureFilter?.timeExtent);for(const t of e)this._attributeStore.releaseDisplayIdForObjectId(t);r.updateStatistics(t,R(1,this._arcadeContextInfo))}else this._removeTrack(r)}_removeTrack(t){this._tracks.delete(t.trackId),this._attributeStore.releaseDisplayIdForObjectId(t.objectId);for(const{objectId:e}of t.observations())this._attributeStore.releaseDisplayIdForObjectId(e)}*_update(e){if(e.done)return;e.done=!this._source.updateTracking.updating;const s=[],r=[];for(const t of this._tracks.values())if(t.length>0){if(this._schema.showLatestObservation){const r=t.getLatestObservationFeatureForTile(e);null!=r&&s.push(r)}this._schema.showTrackLine&&t.overlapsTile(e.subscription.tile)&&r.push(t.getTrackLineFeatureForTile(e))}const i=C.fromOptimizedFeatures(s,this._metadata,e.subscription.tile.transform),a=C.fromOptimizedFeatures(r,this._trackLineMetadata,e.subscription.tile.transform);let o=[];if(this._schema.showPreviousObservations){const s=this._source.chunks().map(()=>[]);for(const t of this._tracks.values())for(const{chunkIndex:e,featureIndex:r}of t.previousObservations())s[e].push(r);o=this._source.chunks().map((t,r)=>{const i=t.getTileReader(e.subscription.tile);if(null==i)return null;const a=A.from(i,s[r]);return a.setProcessorAttributes({[y]:I.PreviousObservation}),"esriGeometryPoint"!==a.geometryType&&null!=a.getInTransform()||a.setTransformForDisplay(e.subscription.tile.transform),a}).filter(t)}this.events.emit("changed");const n=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo),l=a.getCursor();for(;l.next();)this._attributeStore.setAttributeData(l.getDisplayId(),l,n,this._sqlOptions);for(const t of o){const e=t.getCursor();for(;e.next();)this._attributeStore.setAttributeData(e.getDisplayId(),e,n,this._sqlOptions)}const c=i.getCursor();for(;c.next();)this._attributeStore.setAttributeData(c.getDisplayId(),c,n,this._sqlOptions);yield new S(e.subscription,a,!1,!1,{});for(const t of o)yield new S(e.subscription,t,!1,!1,{});yield new S(e.subscription,i,!1,e.done,{})}}function E(t,e,s){if(e.length<2)return g(t,[e],!1,!1);if(s.isWrappable){let r=!1;for(let t=1;t<e.length;t++){const i=e[t][0],a=h(i,e[t-1][0],s);i!==a&&(e[t][0]=a,r=!0)}if(r){const r=m({paths:[e],spatialReference:s});if(null!=r)return g(t,r.paths,!1,!1)}return g(t,[e],!1,!1)}const r=G.fromGeometryToGXGeometry({hasM:!1,hasZ:!1,paths:[e]}),i=G.fromSpatialReference(s);if(null!=i){const e=a(r,1e6,i,o.geodesic);if(null!=e){const s=G.toGeometry(e,i);if(null!=s&&"paths"in s)return g(t,s.paths,!1,!1)}}return g(t,[e],!1,!1)}function N(t,e){const s=2,{coords:r,lengths:i}=t;if(!i.length)return void e(r[0],r[1]);let a=0;for(let o=0;o<i.length;o++){const t=i[o];let n=0,l=0;for(let i=0;i<t;i++)n+=r[s*(i+a)],l+=r[s*(i+a)+1],e(n,l);a+=t}}function X(t){const{lengths:e,coords:s}=t,r=2;if(!e.length)return[d()];const i=[];let a=0;for(let o=0;o<e.length;o++){const t=e[o],n=d();i.push(n);for(let e=0;e<t;e++){const t=s[r*(e+a)],i=s[r*(e+a)+1];u(n,[t,i])}a+=t}return i}export{q as TrackStrategy};
5
+ import{isSome as t}from"../../../../../core/arrayUtils.js";import e from"../../../../../core/Logger.js";import{assertIsSome as s}from"../../../../../core/maybe.js";import{isLoaded as r,load as i,execute as a}from"../../../../../geometry/operators/gx/operatorGeodeticDensify.js";import{geodeticCurveType as o}from"../../../../../geometry/operators/support/geodeticCurveType.js";import{intersectsWithMargin as n,fromValues as l,intersects as c,empty as d,expandPointInPlace as u}from"../../../../../geometry/support/aaBoundingRect.js";import{getClosestDenormalizedXToReference as h}from"../../../../../geometry/support/normalizeUtils.js";import{normalizeCentralMeridianForDisplay as m}from"../../../../../geometry/support/normalizeUtilsSync.js";import{quantizeOptimizedGeometry as p,convertToGeometry as f,convertFromNestedArray as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as _}from"../../../../../layers/graphics/OptimizedFeature.js";import b from"../../../../../layers/graphics/OptimizedGeometry.js";import{internalTrackPartField as y,TrackPart as I,externalTrackLineOidPrefix as k,internalTimeReceivedField as v}from"../../../../../layers/support/streamLayerUtils.js";import{tileSize as F}from"../../../engine/webgl/definitions.js";import{AccumulatedStatistics as j}from"../aggregation/AccumulatedStatistics.js";import{ComputedAggregateField as O}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as T}from"./AAggregateStrategy.js";import{ASendState as x}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as S}from"../sources/FeatureSourceMessage.js";import{createArcadeEvaluationOptions as R}from"../support/arcadeUtils.js";import{ComputedAttributeStorage as w}from"../support/ComputedAttributeStorage.js";import D from"../support/FeatureFilterEvaluator.js";import{FeatureMetadata as L}from"../support/FeatureMetadata.js";import{FeatureSetReaderIndirect as A}from"../support/FeatureSetReaderIndirect.js";import{FeatureSetReaderJSON as C}from"../support/FeatureSetReaderJSON.js";let G;const P=()=>e.getLogger("esri.views.2d.layers.features.processor.TrackStrategy"),z=32;class M{constructor(t,e,s,r,i){this.chunkIndex=t,this.featureIndex=e,this.objectId=s,this.displayId=r,this.time=i}}class W{static getOid(t){return k+t}constructor(t,e,s,r,i,a,o,n){this._schema=t,this.trackId=e,this.objectId=s,this.displayId=r,this._fields=i,this._spatialReference=a,this._metadata=o,this._isStream=n,this._maxDisplayDuration=this._schema.maxDisplayDuration>0?this._schema.maxDisplayDuration:1/0,this._maxDisplayObservationsPerTrack=this._schema.maxDisplayObservationsPerTrack>=1?this._schema.maxDisplayObservationsPerTrack:1/0,this._observationRecords=[],this._nextObservationRecords=[],this._trackLinePath=[],this._bounds=[],this._trackLineGeometry=new b}get _trackLineAttributes(){const t={...this._latestObservationFeature?.attributes??{},aggregateId:this.objectId,[y]:I.TrackLine};if(null!=this._statistics)for(const e of this._statistics.values())t[e.field.name]=e.value;return t}get _startTimeField(){return this._metadata.timeInfo?.startTimeField}get length(){return this._observationRecords.length}*observations(){yield*this._observationRecords}*previousObservations(){for(let t=0;t<this._observationRecords.length-1;t++)yield this._observationRecords[t]}stageObservation(t,e){this._nextObservationRecords.push(new M(t,e.getIndex(),e.getObjectId(),e.getDisplayId(),null!=this._startTimeField?e.readAttributeAsTimestamp(this._startTimeField):null))}commitObservations(t,e){const r=new Set(this._nextObservationRecords.map(t=>t.objectId)),i=this._observationRecords.filter(t=>!r.has(t.objectId)).map(t=>t.objectId);let a,o;switch(this._observationRecords=[],this._trackLinePath=[],this._isStream||null==this._startTimeField||this._nextObservationRecords.sort((t,e)=>{const s=t.time,r=e.time;return null!=s&&null!=r?s-r:0}),this._schema.timeField){case"startTimeField":a=this._metadata.timeInfo?.startTimeField;break;case"endTimeField":a=this._metadata.timeInfo?.endTimeField;break;case"timeReceived":a=this._isStream?v:null}o=this._isStream?e?.end??Date.now():e?.end??-1/0;const n=t.map(t=>t.reader.getCursor());let l;for(let c=this._nextObservationRecords.length-1;c>=0&&!(this._observationRecords.length>=this._maxDisplayObservationsPerTrack);c--){const t=this._nextObservationRecords[c],e=n[t.chunkIndex];s(e),e.setIndex(t.featureIndex);const r=null!=a?e.readAttributeAsTimestamp(a):null;(null!=r?o-r:0)>=this._maxDisplayDuration||(this._commitObservation(t,e),l??=t)}if(null!=l){const{chunkIndex:t,featureIndex:e,objectId:r,displayId:i}=l,a=n[t];s(a),a.setIndex(e);const o=new _(a.readGeometryWorldSpace(),{...a.readAttributes(),[y]:I.LatestObservation},null,r,i);this._latestObservationFeature=o}else this._latestObservationFeature=null;return this._trackLineGeometry=E(this._trackLineGeometry,this._trackLinePath,this._spatialReference),this._bounds=X(this._trackLineGeometry),this._nextObservationRecords=[],i}updateStatistics(t,e){this._statistics=j.create(this._fields);const r=t.map(t=>t.reader.getCursor());for(const{chunkIndex:i,featureIndex:a}of this._observationRecords){const t=r[i];s(t),t.setIndex(a),this._statistics.insert(t,e)}}overlapsTile(t){for(const e of this._bounds)if(n(e,t.bounds,z))return!0;return!1}getLatestObservationFeatureForTile(t){if(null==this._latestObservationFeature)return null;const{objectId:e,displayId:s,geometry:r,attributes:i}=this._latestObservationFeature,a=new b;p(a,r,!1,!1,this._metadata.geometryType,t.subscription.tile.transform);const o=l(1/0,1/0,-1/0,-1/0);N(a,(t,e)=>u(o,[t,e]));if(!c(o,l(0,0,F,F)))return null;return new _(a,i,null,e,s)}getTrackLineFeatureForTile(t){const e=new b;p(e,this._trackLineGeometry,!1,!1,"esriGeometryPolyline",t.subscription.tile.transform);return new _(e,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineOptimizedFeature(){return new _(this._trackLineGeometry,this._trackLineAttributes,null,this.objectId,this.displayId)}getTrackLineDisplayFeature(){const{_trackLineGeometry:t,_trackLineAttributes:e,displayId:s}=this;return{geometry:f(t,"esriGeometryPolyline",!1,!1),attributes:e,displayId:s}}_commitObservation(t,e){const s=e.readCentroidWorldSpace();let r=s?.coords[0],i=s?.coords[1];null==s&&(r=e.readXWorldSpace(),i=e.readYWorldSpace()),null!=r&&null!=i&&(this._observationRecords.unshift(t),this._trackLinePath.unshift([r,i]))}}class U extends x{constructor(t){super(t),this.done=!1}}class q extends T{static async create(t,e,s,a,o,n){const l=new w({spatialReference:e}),c=await Promise.all(t.fields.map(async t=>O.create(l,t))),d=t.featureFilter?await D.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:e,filterJSON:t.featureFilter}):null;return e.isWrappable||r()||await Promise.all([import("../../../../../geometry/operators/support/apiConverter.js"),import("../../../../../geometry/operators/support/jsonConverter.js"),i()]).then(([t,e,s])=>{G={fromGeometryToGXGeometry:e.fromGeometryToGXGeometry,toGeometry:e.toGeometry,fromSpatialReference:t.fromSpatialReference}}),new q(t,s,a,e,c,d,o,n)}constructor(t,e,s,r,i,a,o,n){super(e,s,r,i,n),this._schema=t,this._featureFilter=a,this._arcadeContextInfo=o,this._tracks=new Map,this._handledChunks=new Set,this._metadata=e.metadata.weakCloneWithAdditionalFields([{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"}]),this._trackLineMetadata=L.createFeature({geometryType:"esriGeometryPolyline",featureIdInfo:{type:"object-id",fieldName:"aggregateId"},fieldsIndex:{fields:[...this._source.metadata.fieldsIndex.fields,...this.aggregateFields,{name:y,alias:"trackPart",type:"esriFieldTypeSmallInteger"},{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],timeZoneByFieldName:null},globalIdField:null,spatialReference:e.metadata.spatialReference,outSpatialReference:e.metadata.outSpatialReference,subtypeField:null,subtypes:null,timeInfo:e.metadata.timeInfo,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null})}get _isStream(){return this._source.isStream}get enablePixelBuffering(){return!0}get isAggregate(){return!1}requiresInvalidation(){const t=new Set(this._source.chunks().map(t=>t.chunkId));for(const e of t)if(!this._handledChunks.has(e))return!0;for(const e of this._handledChunks)if(!t.has(e))return!0;return!1}invalidate(){this._handledChunks.clear(),super.invalidate()}createState(t){return new U(t)}async*applyOverrideUpdate(t){P().error("Applying override to tracks is not supported")}displayMap(t,e,s){const r=new Map(t.map(t=>[e(t),t])),i=[];for(const a of this._tracks.values()){const t=r.get(a.objectId);if(null!=t){const e=s(a.displayId,t,a.objectId);i.push(e),r.delete(a.objectId);continue}for(const e of a.observations()){const t=r.get(e.objectId);if(null!=t){const a=s(e.displayId,t,e.objectId);i.push(a),r.delete(e.objectId)}}}return i}getDisplayFeatures(t){const e=new Set(t),s=[],r=[],i=this._source.chunks().map(t=>t.reader.getCursor());for(const a of this._tracks.values()){e.has(a.displayId)&&r.push(a.getTrackLineDisplayFeature());for(const{displayId:t,chunkIndex:r,featureIndex:o}of a.observations())if(e.has(t)){const e=i[r];e.setIndex(o),s.push({displayId:t,attributes:{},...e.readLegacyFeatureWorldSpace()})}}return{features:s,aggregates:[],tracks:r}}getFeatureObjectIdsForAggregate(t){for(const e of this._tracks.values())if(e.objectId===t)return Array.from(e.observations(),t=>t.objectId);return[]}async*updateChunks(){0===this._handledChunks.size&&this._rebuildTracks();for(const t of this._sendStates.values())yield*this._update(t)}forEachAggregateWorldSpace(t){for(const e of this._tracks.values())t(e.getTrackLineOptimizedFeature())}_rebuildTracks(){const t=this._source.chunks();if(!t.length)return;const e=this._metadata.timeInfo?.trackIdField;if(null==e)return;const s=new Set;for(let r=0;r<t.length;r++){const i=t[r];this._handledChunks.add(i.chunkId);const a=i.reader.getCursor();for(;a.next();){const t=a.readAttribute(e),i=a.getObjectId();if(null!=t&&null!=i&&(null===this._featureFilter||this._featureFilter.check(a,this._sqlOptions))){if(a.getDisplayId()||a.setDisplayId(this._attributeStore.createDisplayIdForObjectId(i)),!this._tracks.has(t)){const e=W.getOid(t),s=this._attributeStore.createDisplayIdForObjectId(e),r=new W(this._schema,t,e,s,this.aggregateFields,this.spatialReference,this._source.metadata,this._isStream);this._tracks.set(t,r)}this._tracks.get(t).stageObservation(r,a),s.add(t)}}}for(const r of this._tracks.values())if(s.has(r.trackId)){const e=r.commitObservations(t,this._featureFilter?.timeExtent);for(const t of e)this._attributeStore.releaseDisplayIdForObjectId(t);r.updateStatistics(t,R(1,this._arcadeContextInfo))}else this._removeTrack(r)}_removeTrack(t){this._tracks.delete(t.trackId),this._attributeStore.releaseDisplayIdForObjectId(t.objectId);for(const{objectId:e}of t.observations())this._attributeStore.releaseDisplayIdForObjectId(e)}*_update(e){if(e.done)return;e.done=!this._source.updateTracking.updating;const s=[],r=[];for(const t of this._tracks.values())if(t.length>0){if(this._schema.showLatestObservation){const r=t.getLatestObservationFeatureForTile(e);null!=r&&s.push(r)}this._schema.showTrackLine&&t.overlapsTile(e.subscription.tile)&&r.push(t.getTrackLineFeatureForTile(e))}const i=C.fromOptimizedFeatures(s,this._metadata,e.subscription.tile.transform),a=C.fromOptimizedFeatures(r,this._trackLineMetadata,e.subscription.tile.transform);let o=[];if(this._schema.showPreviousObservations){const s=this._source.chunks().map(()=>[]);for(const t of this._tracks.values())for(const{chunkIndex:e,featureIndex:r}of t.previousObservations())s[e].push(r);o=this._source.chunks().map((t,r)=>{const i=t.getTileReader(e.subscription.tile);if(null==i)return null;const a=A.from(i,s[r]);return a.setProcessorAttributes({[y]:I.PreviousObservation}),"esriGeometryPoint"!==a.geometryType&&null!=a.getInTransform()||a.setTransformForDisplay(e.subscription.tile.transform),a}).filter(t)}this.events.emit("changed");const n=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo),l=a.getCursor();for(;l.next();)this._attributeStore.setAttributeData(l.getDisplayId(),l,n,this._sqlOptions);for(const t of o){const e=t.getCursor();for(;e.next();)this._attributeStore.setAttributeData(e.getDisplayId(),e,n,this._sqlOptions)}const c=i.getCursor();for(;c.next();)this._attributeStore.setAttributeData(c.getDisplayId(),c,n,this._sqlOptions);yield new S(e.subscription,a,!1,!1,{});for(const t of o)yield new S(e.subscription,t,!1,!1,{});yield new S(e.subscription,i,!1,e.done,{})}}function E(t,e,s){if(e.length<2)return g(t,[e],!1,!1);if(s.isWrappable){let r=!1;for(let t=1;t<e.length;t++){const i=e[t][0],a=h(i,e[t-1][0],s);i!==a&&(e[t][0]=a,r=!0)}if(r){const r=m({paths:[e],spatialReference:s});if(null!=r)return g(t,r.paths,!1,!1)}return g(t,[e],!1,!1)}const r=G.fromGeometryToGXGeometry({hasM:!1,hasZ:!1,paths:[e]}),i=G.fromSpatialReference(s);if(null!=i){const e=a(r,1e6,i,o.geodesic);if(null!=e){const s=G.toGeometry(e,i);if(null!=s&&"paths"in s)return g(t,s.paths,!1,!1)}}return g(t,[e],!1,!1)}function N(t,e){const s=2,{coords:r,lengths:i}=t;if(!i.length)return void e(r[0],r[1]);let a=0;for(let o=0;o<i.length;o++){const t=i[o];let n=0,l=0;for(let i=0;i<t;i++)n+=r[s*(i+a)],l+=r[s*(i+a)+1],e(n,l);a+=t}}function X(t){const{lengths:e,coords:s}=t,r=2;if(!e.length)return[d()];const i=[];let a=0;for(let o=0;o<e.length;o++){const t=e[o],n=d();i.push(n);for(let e=0;e<t;e++){const t=s[r*(e+a)],i=s[r*(e+a)+1];u(n,[t,i])}a+=t}return i}export{q as TrackStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as t}from"../../../support/FeatureSetReaderJSON.js";const s=1e4,r=1e3;class i{constructor(){this.modified=[],this.removed=[]}modify(e){this.modified.push(e)}remove(e){this.removed.push(e)}get isEmpty(){return 0===this.modified.length&&0===this.removed.length}}class o extends e{constructor(e){super(),this._reader=e,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(e,s){const r=t.fromOptimizedFeatures(e,s);return new o(r)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(e){if(!this._reader.getSize())return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class n{constructor(e,t){this.inner=e,this.isWeak=t,this.lastWeak=null}get isStrong(){return!this.isWeak}}class a{constructor(){this._overrides=new Map,this._update=new i,this._lastCleanup=0}hasOverride(e){return this._overrides.has(e)}onChunkInsert(e){if(this._overrides.size){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),s=this._overrides.get(e);if(s?.lastWeak&&(s.lastWeak=null),s?.isWeak){const e=t.readOptimizedFeatureWorldSpace();s.inner=e,this._update.modify(e),this.invalidate()}}}e.registerOverrides(this)}apply(e,t){const{updateWeak:s,removeWeak:r,update:i,remove:o,release:a}=e.commands;this.invalidate();for(const d of s){const e=new n(d,!0),t=this._overrides.get(d.objectId);t?.isStrong?t.lastWeak=e:(this._overrides.set(d.objectId,e),this._update.modify(d))}for(const d of i){const e=new n(d,!1),t=this._overrides.get(d.objectId);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(d.objectId,e),this._update.modify(d)}for(const d of r){const e=new n(null,!0),t=this._overrides.get(d);t?.isStrong?t.lastWeak=e:(this._overrides.set(d,e),this._update.remove(d))}for(const d of o){const e=new n(null,!1),t=this._overrides.get(d);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(d,e),this._update.remove(d)}if(a.length){const e=new Set;for(const t of a){const s=this._overrides.get(t);s?.lastWeak?(this._overrides.set(t,s.lastWeak),null==s.lastWeak.inner?this._update.remove(t):this._update.modify(s.lastWeak.inner)):s&&!s.isWeak&&(this._overrides.delete(t),e.add(t))}t.forEachUnsafe(t=>{const s=t.getObjectId();e.has(s)&&(this._update.modify(t.readOptimizedFeatureWorldSpace()),e.delete(s))});for(const t of e.values())this._update.remove(t)}}clearWeakOverrides(){for(const[e,t]of this._overrides.entries())t.isWeak&&this._overrides.delete(e);this.invalidate()}cleanup(e){if(this._overrides.size<s)return;const t=performance.now();if(t-this._lastCleanup<r)return;this._lastCleanup=t;const i=this._getWeakDeletions();if(!(i.size<s)){for(const t of e){const e=t.reader.withoutOverrides().getCursor();for(;e.next();){const t=e.getObjectId();i.delete(t)}}for(const e of i)this._overrides.delete(e);i.size&&this.invalidate()}}takeOverrideUpdate(){const e=this._update;return e.isEmpty?null:(this._update=new i,e)}asChunk(e){if(!this._chunk){const t=[];for(const e of this._overrides.values())null!=e.inner&&t.push(e.inner);this._chunk=o.fromFeatures(t,e)}return this._chunk}invalidate(){this._chunk=null}putWeakObjectIdsFromGlobalIds(e,t,s){for(const[r,i]of this._overrides.entries())if(i.isWeak&&null!=i.inner){const o=i.inner.attributes[s];o&&t.has(o)&&!e.has(o)&&e.set(o,r)}else if(null!=i.lastWeak&&null!=i.lastWeak.inner){const o=i.lastWeak.inner.attributes[s];o&&t.has(o)&&!e.has(o)&&e.set(o,r)}}_getWeakDeletions(){const e=new Set;for(const[t,s]of this._overrides.entries())s.isWeak&&null==s.inner&&e.add(t);return e}}export{o as OverrideChunk,a as OverrideState,i as OverrideUpdate};
5
+ import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as t}from"../../../support/FeatureSetReaderJSON.js";const s=1e4,r=1e3;class i{constructor(){this.modified=[],this.removed=[]}modify(e){this.modified.push(e)}remove(e){this.removed.push(e)}get isEmpty(){return 0===this.modified.length&&0===this.removed.length}}class o extends e{constructor(e){super(),this._reader=e,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(e,s){const r=t.fromOptimizedFeatures(e,s);return new o(r)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(e){if(!this._reader.getSize())return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class n{constructor(e,t){this.inner=e,this.isWeak=t,this.lastWeak=null}get isStrong(){return!this.isWeak}}class a{constructor(){this._overrides=new Map,this._update=new i,this._lastCleanup=0}hasOverride(e){return this._overrides.has(e)}onChunkInsert(e){if(this._overrides.size){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),s=this._overrides.get(e);if(s?.lastWeak&&(s.lastWeak=null),s?.isWeak){const e=t.readOptimizedFeatureWorldSpace();s.inner=e,this._update.modify(e),this.invalidate()}}}e.registerOverrides(this)}apply(e,t){const{updateWeak:s,removeWeak:r,update:i,remove:o,release:a}=e.commands;this.invalidate();for(const d of s){const e=new n(d,!0),t=this._overrides.get(d.objectId);t?.isStrong?t.lastWeak=e:(this._overrides.set(d.objectId,e),this._update.modify(d))}for(const d of i){const e=new n(d,!1),t=this._overrides.get(d.objectId);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(d.objectId,e),this._update.modify(d)}for(const d of r){const e=new n(null,!0),t=this._overrides.get(d);t?.isStrong?t.lastWeak=e:(this._overrides.set(d,e),this._update.remove(d))}for(const d of o){const e=new n(null,!1),t=this._overrides.get(d);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(d,e),this._update.remove(d)}if(a.length){const e=new Set;for(const t of a){const s=this._overrides.get(t);s?.lastWeak?(this._overrides.set(t,s.lastWeak),null==s.lastWeak.inner?this._update.remove(t):this._update.modify(s.lastWeak.inner)):s&&!s.isWeak&&(this._overrides.delete(t),e.add(t))}t.forEachUnsafe(t=>{const s=t.getObjectId();e.has(s)&&(this._update.modify(t.readOptimizedFeatureWorldSpace()),e.delete(s))});for(const t of e.values())this._update.remove(t)}}clearWeakOverrides(){for(const[e,t]of this._overrides.entries())t.isWeak&&this._overrides.delete(e);this.invalidate()}cleanup(e){if(this._overrides.size<s)return;const t=performance.now();if(t-this._lastCleanup<r)return;this._lastCleanup=t;const i=this._getWeakDeletions();if(!(i.size<s)){for(const t of e){const e=t.reader.withoutOverrides().getCursor();for(;e.next();){const t=e.getObjectId();i.delete(t)}}for(const e of i)this._overrides.delete(e);i.size&&this.invalidate()}}takeOverrideUpdate(){const e=this._update;return e.isEmpty?null:(this._update=new i,e)}asChunk(e){if(!this._chunk){const t=[];for(const e of this._overrides.values())null!=e.inner&&t.push(e.inner);this._chunk=o.fromFeatures(t,e)}return this._chunk}invalidate(){this._chunk=null}putWeakObjectIdsFromGlobalIds(e,t,s){for(const[r,i]of this._overrides.entries()){if(i.isWeak&&null!=i.inner){const o=i.inner.attributes[s];o&&t.has(o)&&!e.has(o)&&e.set(o,r);continue}if(null!=i.lastWeak&&null!=i.lastWeak.inner){const o=i.lastWeak.inner.attributes[s];o&&t.has(o)&&!e.has(o)&&e.set(o,r)}}}_getWeakDeletions(){const e=new Set;for(const[t,s]of this._overrides.entries())s.isWeak&&null==s.inner&&e.add(t);return e}}export{o as OverrideChunk,a as OverrideState,i as OverrideUpdate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../core/Error.js";import e from"../../../../../core/Logger.js";import{create as i}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as s}from"../../../../../geometry/support/boundsUtils.js";import{normalizeQueryLike as r}from"../../../../../layers/graphics/data/queryUtils.js";import{getSpatialQueryOperator as o}from"../../../../../layers/graphics/data/spatialQuerySupport.js";import{getTimeOperator as a}from"../../../../../layers/graphics/data/timeSupport.js";import h from"../../../../../rest/support/Query.js";import{FeatureStoreQueryAdapter as l}from"../FeatureStoreQueryAdapter.js";import{createWhereClause as n}from"./whereUtils.js";const m=1,d=2;class p{constructor(t){this._geometryBounds=i(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new p(t);return await e.update(t.filterJSON,t.spatialReference),e}get hash(){return this._hash}check(t,e){return this._applyFilter(t,e)}invalidate(){this._idToVisibility.forEach((t,e)=>{this._idToVisibility.set(e,0)})}setKnownIds(t){for(const e of t)this._idToVisibility.set(e,m)}setTrue(t){const e=[],i=[],s=new Set(t);return this._idToVisibility.forEach((t,r)=>{const o=!!(this._idToVisibility.get(r)&m),a=s.has(r);!o&&a?e.push(r):o&&!a&&i.push(r),this._idToVisibility.set(r,a?m|d:0)}),{show:e,hide:i}}createQuery(){const{geometry:t,spatialRel:e,where:i,timeExtent:s,objectIds:r}=this;return h.fromJSON({geometry:t,spatialRel:e,where:i,timeExtent:s,objectIds:r})}async update(t,e){this._hash=JSON.stringify(t);const i=await r(t,null,e);await Promise.all([this._setGeometryFilter(i),this._setIdFilter(i),this._setAttributeFilter(i),this._setTimeFilter(i)])}async _setAttributeFilter(t){if(!t?.where)return this._clause=null,void(this.where=null);this._clause=await n(t.where,this._serviceInfo.fieldsIndex),this.where=t.where}_setIdFilter(t){this._idsToShow=t?.objectIds&&new Set(t.objectIds),this._idsToHide=t?.hiddenIds&&new Set(t.hiddenIds),this.objectIds=t?.objectIds}async _setGeometryFilter(t){if(!t?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const e=t.geometry,i=t.spatialRel??"esriSpatialRelIntersects",r=await o(i,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);s(this._geometryBounds,e),this._spatialQueryOperator=r,this.geometry=e,this.spatialRel=i}_setTimeFilter(i){if(this.timeExtent=this._timeOperator=null,i?.timeExtent)if(this._serviceInfo.timeInfo)this.timeExtent=i.timeExtent,this._timeOperator=a(this._serviceInfo.timeInfo,i.timeExtent,l.Shared);else{const s=new t("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",i.timeExtent);e.getLogger("esri.views.2d.layers.features.controllers.FeatureFilter").error(s)}}_applyFilter(t,e){return this._filterByGeometry(t)&&this._filterById(t)&&this._filterByTime(t)&&this._filterByExpression(t,e)}_filterByExpression(t,e){return!this.where||this._clause(t,e)}_filterById(t){return(!this._idsToHide?.size||!this._idsToHide.has(t.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(t.getObjectId()))}_filterByGeometry(t){if(!this.geometry)return!0;const e=t.readGeometryWorldSpace();return!!e&&this._spatialQueryOperator(e)}_filterByTime(t){return null==this._timeOperator||this._timeOperator(t)}}export{p as default};
5
+ import t from"../../../../../core/Error.js";import e from"../../../../../core/Logger.js";import{create as i}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as s}from"../../../../../geometry/support/boundsUtils.js";import{normalizeQueryLike as r}from"../../../../../layers/graphics/data/queryUtils.js";import{getSpatialQueryOperator as o}from"../../../../../layers/graphics/data/spatialQuerySupport.js";import{getTimeOperator as a}from"../../../../../layers/graphics/data/timeSupport.js";import h from"../../../../../rest/support/Query.js";import{FeatureStoreQueryAdapter as l}from"../FeatureStoreQueryAdapter.js";import{createWhereClause as n}from"./whereUtils.js";const m=1,d=2;class p{constructor(t){this._geometryBounds=i(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new p(t);return await e.update(t.filterJSON,t.spatialReference),e}get hash(){return this._hash}check(t,e){return this._applyFilter(t,e)}invalidate(){this._idToVisibility.forEach((t,e)=>{this._idToVisibility.set(e,0)})}setKnownIds(t){for(const e of t)this._idToVisibility.set(e,m)}setTrue(t){const e=[],i=[],s=new Set(t);return this._idToVisibility.forEach((t,r)=>{const o=!!(this._idToVisibility.get(r)&m),a=s.has(r);!o&&a?e.push(r):o&&!a&&i.push(r),this._idToVisibility.set(r,a?m|d:0)}),{show:e,hide:i}}createQuery(){const{geometry:t,spatialRel:e,where:i,timeExtent:s,objectIds:r}=this;return h.fromJSON({geometry:t,spatialRel:e,where:i,timeExtent:s,objectIds:r})}async update(t,e){this._hash=JSON.stringify(t);const i=await r(t,null,e);await Promise.all([this._setGeometryFilter(i),this._setIdFilter(i),this._setAttributeFilter(i),this._setTimeFilter(i)])}async _setAttributeFilter(t){if(!t?.where)return this._clause=null,void(this.where=null);this._clause=await n(t.where,this._serviceInfo.fieldsIndex),this.where=t.where}_setIdFilter(t){this._idsToShow=t?.objectIds&&new Set(t.objectIds),this._idsToHide=t?.hiddenIds&&new Set(t.hiddenIds),this.objectIds=t?.objectIds}async _setGeometryFilter(t){if(!t?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const e=t.geometry,i=t.spatialRel??"esriSpatialRelIntersects",r=await o(i,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);s(this._geometryBounds,e),this._spatialQueryOperator=r,this.geometry=e,this.spatialRel=i}_setTimeFilter(i){if(this.timeExtent=this._timeOperator=null,i?.timeExtent){if(!this._serviceInfo.timeInfo){const s=new t("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",i.timeExtent);return void e.getLogger("esri.views.2d.layers.features.controllers.FeatureFilter").error(s)}this.timeExtent=i.timeExtent,this._timeOperator=a(this._serviceInfo.timeInfo,i.timeExtent,l.Shared)}}_applyFilter(t,e){return this._filterByGeometry(t)&&this._filterById(t)&&this._filterByTime(t)&&this._filterByExpression(t,e)}_filterByExpression(t,e){return!this.where||this._clause(t,e)}_filterById(t){return(!this._idsToHide?.size||!this._idsToHide.has(t.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(t.getObjectId()))}_filterByGeometry(t){if(!this.geometry)return!0;const e=t.readGeometryWorldSpace();return!!e&&this._spatialQueryOperator(e)}_filterByTime(t){return null==this._timeOperator||this._timeOperator(t)}}export{p as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import r from"../../../../core/Identifiable.js";import{assertIsSome as i}from"../../../../core/maybe.js";import{ignoreAbortErrors as o,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as c}from"../../../../geometry/support/aaBoundingRect.js";import{isPolyline as l,isPolygon as p,isExtent as u,getJsonType as m}from"../../../../geometry/support/jsonUtils.js";import g from"../../../../layers/support/FieldsIndex.js";import{symbolToCIM as f,CIMSymbolHelper as y}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as _}from"../../../../symbols/cim/OverrideHelper.js";import{errorPointSymbol2D as b,errorPolylineSymbol2D as w,errorPolygonSymbol2D as S}from"../../../../symbols/support/defaults.js";import{filterFlag0 as I}from"../../engine/webgl/definitions.js";import{FeatureTile as v}from"../../engine/webgl/FeatureTile.js";import{MeshData as T}from"../../engine/webgl/mesh/MeshData.js";import{ResourceProxy as M}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{createGraphicSymbolMeshSchemas as R}from"../../engine/webgl/shaderGraph/techniques/createGraphicSymbolMeshSchemas.js";import{createStorageSchema as j}from"../features/schema/processor/StorageSchema.js";import{AttributeStore as x}from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as U}from"../features/support/ComputedAttributeStorage.js";import{GraphicsMetadata as C}from"../features/support/FeatureMetadata.js";import{GraphicsReader as q}from"../features/support/GraphicsReader.js";import G from"./GraphicStore.js";import{FeatureCommandQueue as k}from"../support/FeatureCommandQueue.js";import{UpdateTracking2D as P}from"../support/UpdateTracking2D.js";class F{static getOrCreate(e,t,s){let r=t.get(e.id);return r||(r=new F(e,s),t.set(e.id,r)),r}static fromItems(e,t,s){const r=new F(e,s);for(const i of t)r.append(i);return r}constructor(e,t){this.tile=e,this.metadata=t,this.addedOrModified=[],this.removed=[],this.objectIdMap=null}get reader(){return this._reader||(this._reader=q.from(this.addedOrModified,this.tile,this.metadata)),this._reader}append(e){this.addedOrModified.push(e),e.hasAnimations&&(this.objectIdMap=this.objectIdMap||{},this.objectIdMap[e.displayId]=e.objectId)}}let O=class extends(r.IdentifiableMixin(t)){constructor(e){super(e),this._attached=!1,this._tiles=new Map,this._controller=new AbortController,this._hashToSymbolInfo=new Map,this._lastCleanup=performance.now(),this._cleanupRequired=!0,this.lastUpdateId=-1,this.renderer=null,this._updateTracking=new P({debugName:"GraphicsView2D"}),this.updateRequested=!1,this.defaultPointSymbolEnabled=!0,this._commandQueue=new k({process:e=>{if("update"===e.type)return this._update();throw new Error("InternalError: Unsupported command")}}),this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this.container.destroy(),this.view=null,this.renderer=null,this._set("graphics",null),this._controller.abort(),this._graphicStore.clear(),this._graphicStore.destroy(),this._attributeStore=null,this._hashToSymbolInfo.clear(),this._updateTracking.destroy(),this._commandQueue.destroy()}_initAttributeStore(){this._storage=new U({spatialReference:this.view.spatialReference,fields:new g}),this._attributeStore=new x({isLocal:!0,update:e=>{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateStart`,{message:e}),this.container.attributeView.requestUpdate(e),this.container.requestRender(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateEnd`,{message:e})}});const e=j(null,[]);this._attributeStore.update(e,this._storage,null),this.container.checkHighlight=()=>this._attributeStore.hasHighlight}initialize(){this._initAttributeStore(),this._metadata=C.createGraphics(this.view.spatialReference),this._resourceProxy=new M({fetch:e=>Promise.all(e.map(e=>this.view.stage.textureManager.rasterizeItem(e))),fetchDictionary:e=>{throw new Error("InternalError: Graphics do not support Dictionary requests")}}),this.addHandles([n(()=>this._effectiveRenderer,()=>this._pushUpdate()),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",()=>{this.addHandles([this.graphics.on("change",()=>this._pushUpdate())]),this._graphicStore?.destroy(),this._graphicStore=new G(this.view.spatialReference,this._cimResourceManager,this.view.featuresTilingScheme,this.view.state.scale,this._attributeStore),this._attached=!0,this.requestUpdate(),this._pushUpdate()})]),this._updateTracking.addUpdateTracking("CommandQueue",this._commandQueue.updateTracking);const e=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:e,removed:[]})}get _effectiveRenderer(){return"function"==typeof this.renderer?this.renderer():this.renderer}get _cimResourceManager(){return this.view.stage.textureManager.resourceManager}get updating(){const e=!this._attached||this._updateTracking.updating;return has("esri-2d-log-updating")&&console.log(`Updating GraphicsView2D: ${e}\n -> attaching ${!this._attached}\n -> updateTracking ${this._updateTracking.updating}`),e}hitTest(e){if(!this.view||this.view.suspended)return[];const{resolution:t,rotation:r}=this.view.state,i=this._graphicStore.hitTest(e.x,e.y,2,t,r),o=new Set(i),a=this.graphics.items.reduce((e,t)=>(o.has(t.uid)&&e.set(t.uid,t),e),new Map);return i.map(e=>a.get(e)).filter(s)}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback()),this.notifyChange("updating")}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}viewChange(){this.requestUpdate()}setHighlight(e){const t=[];for(const{objectId:s,highlightFlags:r}of e){const e=this._graphicStore.getItem(s)?.displayId;t.push({objectId:s,highlightFlags:r,displayId:e})}this._attributeStore.setHighlight(t,e),this._pushUpdate()}graphicUpdateHandler(e){this._pushUpdate()}update(e){this.updateRequested=!1,this._attached&&this._graphicStore.updateLevel(e.state.resolution)&&this.pushUpdate()}pushUpdate(){this._pushUpdate()}_pushUpdate(){o(this._commandQueue.push({type:"update"}))}async _update(){try{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView._update start`);const e=await this._graphicStore.update(this.graphics,e=>this._getSymbolForGraphic(e),e=>this._ensureSymbolResource(e));for(const s of e.updated)this.container.restartAnimation(s.objectId);if(!e.hasAnyUpdate())return void this._attributeStore.sendUpdates();e.removed.length&&(this._cleanupRequired=!0),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView updateMessage`,e);const t=this._createTileMessages(e);await this._densifyItemsForDisplay(t),await this._fetchResources(t),this._write(t);for(const s of e.added)this._setFilterState(s);for(const s of e.updated)this._setFilterState(s);has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate`,e),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate.await`,e)}catch(e){}this._cleanupSharedResources()}_createTileMessages(e){const t=new Map;for(const s of e.added){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).append(s)}}for(const s of e.updated){const e=this.view.graphicsTileStore.getIntersectingTiles(s.prevSymbolBounds),r=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const i of e){F.getOrCreate(i,t,this._metadata).removed.push(s.displayId)}for(const i of r){F.getOrCreate(i,t,this._metadata).append(s)}}for(const s of e.removed){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).removed.push(s.displayId)}}return Array.from(t.values())}async _densifyItemsForDisplay(e){const t=new Map;for(const s of e)for(const e of s.addedOrModified)t.has(e)||t.set(e,e.densifyCurvedGeometryForDisplay(this.view.spatialReference));await Promise.all(t.values())}async _fetchResources(e){const t={timeZone:null,timeExtent:null};for(const{tile:s,reader:r}of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${s.id}] GraphicsView fetchResources`,e);const i=r.getCursor();for(;i.next();)for(const e of i.getMeshWriters())e.enqueueRequest(this._resourceProxy,i,s.createArcadeEvaluationOptions(t))}await this._resourceProxy.fetchEnqueuedResources()}_write(e){for(const t of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView write`,t);const e=this._writeMeshes(t);let s=this._tiles.get(t.tile.key);s||(s=this._createFeatureTile(t.tile.key)),has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView onTileData`,t),this.container.onTileData(s,{type:"update",modify:e,remove:t.removed,end:!1,attributeEpoch:this._attributeStore.epoch,objectIdMap:t.objectIdMap}),this.container.requestRender()}}_writeMeshes(e){const t={timeZone:null,timeExtent:null},s=new T(e.tile.id),r=e.reader.getCursor();for(;r.next();){s.entityStart(r.getDisplayId(),r.getZOrder());for(const i of r.getMeshWriters())i.write(s,this._resourceProxy,r,e.tile.createArcadeEvaluationOptions(t),e.tile.level);s.entityEnd()}return{...s.serialize().message,tileId:e.tile.id}}_setFilterState(e){const t=e.displayId,s=this._attributeStore.getHighlightFlags(e.objectId);this._attributeStore.setData(t,0,0,s|(e.visible?I:0))}_getSymbolForGraphic(e){return null!=e.symbol?e.symbol:null!=this._effectiveRenderer?this._effectiveRenderer.getSymbol(e):this._getNullSymbol(e)}async _ensureSymbolResource(e){if(!e.symbol)return;const t=await this._getSymbolInfo(e.symbol);if(!t)return;const s=t.linearCIM.filter(e=>"text"===e.type);if(s.length>0){const r=await this._getTextResources(e,s);e.symbolResource={symbolInfo:t,textInfo:r}}else e.symbolResource={symbolInfo:t}}_getSymbolInfo(e){const t=e.hash();return this._hashToSymbolInfo.has(t)||this._hashToSymbolInfo.set(t,this._createSymbolInfo(t,e).catch(e=>null)),this._hashToSymbolInfo.get(t)}async _createSymbolInfo(e,t){const s=await this._convertToCIMSymbol(t),r=await this._createLinearCIM(s);return{hash:e,cimSymbol:s,linearCIM:r,meshWriters:await this._createMeshWriters(s,r)}}async _convertToCIMSymbol(e){const t=f(e);return"web-style"===t.type?this._convertToCIMSymbol(await t.fetchSymbol({acceptedFormats:["cim","web"]})):t}async _createLinearCIM(e){return await Promise.all(y.fetchResources(e.symbol,this._cimResourceManager,[])),this.view.stage.cimAnalyzer.analyzeSymbolReference(e,!1)}async _createMeshWriters(e,t){a(this._controller.signal);const s=this.container.instanceStore,r=this.view.stage.meshWriterRegistry,i=await R(e,t,s);return Promise.all(i.map(e=>r.createMeshWriter(this._storage,this._resourceProxy,{tileInfo:this.view.featuresTilingScheme.tileInfo},e,null)))}_onTileUpdate(e){if(e.added&&e.added.length>0)for(const t of e.added)this._updateTracking.addPromise(this._addTile(t));if(e.removed&&e.removed.length>0)for(const t of e.removed)this._removeTile(t.key)}_createFeatureTile(e){const t=this.view.featuresTilingScheme.getTileBounds(c(),e),s=this.view.featuresTilingScheme.getTileResolution(e.level),r=new v(e,s,t[0],t[3]);return this._tiles.set(e,r),this.container.addChild(r),r}async _addTile(e){if(!this._attached)return;const t=this._graphicStore.queryItems(e);if(!t.length)return;const s=this._createFeatureTile(e.key),r=F.fromItems(e,t,this._metadata);await this._densifyItemsForDisplay([r]),await this._fetchResources([r]);const i=this._writeMeshes(r);s.onMessage({type:"append",append:i,clear:!1,end:!0,attributeEpoch:this._attributeStore.epoch,objectIdMap:r.objectIdMap})}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_getNullSymbol(e){const t=e.geometry;return t?l(t)?w:p(t)||u(t)?S:this.defaultPointSymbolEnabled?b:null:this.defaultPointSymbolEnabled?b:null}async _getTextResources(e,t){const s=new Array,r=new Array;for(let i=0;i<t.length;i++){const o=t[i],{resource:a,overrides:n}=o.textRasterizationParam;if(n?.length>0){const t=_.resolveSymbolOverrides({type:"CIMSymbolReference",primitiveOverrides:n,symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:a.symbol.height,anchorPointUnits:"Relative",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:a.symbol,textString:a.textString}],scaleSymbolsProportionally:!0,respectFrame:!0}]}},e,this.view.spatialReference,null,m(e.projectedGeometry),null,null);t.then(e=>{const t=e.symbolLayers[0],{textString:s}=t.markerGraphics[0];r.push({type:"cim-rasterization-info",resource:{type:"text",textString:s||"",font:a.font}}),o.text=a.textString=s||""}),s.push(t)}else r.push({type:"cim-rasterization-info",resource:a})}s.length>0&&await Promise.all(s);const o=r.map(e=>this.view.stage.textureManager.rasterizeItem(e)),a=await Promise.all(o);i(a);const n=new Map;for(let i=0;i<t.length;i++){const e=t[i];n.set(e.textRasterizationParam.resource.symbol,{text:e.text,glyphMosaicItems:a[i]})}return n}_cleanupSharedResources(){if(!this._cleanupRequired)return;const e=performance.now();if(e-this._lastCleanup<5e3)return;this._cleanupRequired=!1,this._lastCleanup=e;const t=new Set;for(const r of this._graphicStore.items()){const e=r.symbolResource?.symbolInfo.hash;t.add(e)}const s=new Set(this._hashToSymbolInfo.keys());for(const r of s.values())t.has(r)||this._hashToSymbolInfo.delete(r)}};e([h()],O.prototype,"_effectiveRenderer",null),e([h({constructOnly:!0})],O.prototype,"layerId",void 0),e([h({constructOnly:!0})],O.prototype,"requestUpdateCallback",void 0),e([h()],O.prototype,"container",void 0),e([h({constructOnly:!0})],O.prototype,"graphics",void 0),e([h()],O.prototype,"renderer",void 0),e([h()],O.prototype,"_updateTracking",void 0),e([h()],O.prototype,"updating",null),e([h()],O.prototype,"view",void 0),e([h()],O.prototype,"updateRequested",void 0),e([h()],O.prototype,"defaultPointSymbolEnabled",void 0),O=e([d("esri.views.2d.layers.graphics.GraphicsView2D")],O);export{O as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import r from"../../../../core/Identifiable.js";import{assertIsSome as i}from"../../../../core/maybe.js";import{ignoreAbortErrors as o,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as c}from"../../../../geometry/support/aaBoundingRect.js";import{isPolyline as l,isPolygon as p,isExtent as u,getJsonType as m}from"../../../../geometry/support/jsonUtils.js";import g from"../../../../layers/support/FieldsIndex.js";import{symbolToCIM as f,CIMSymbolHelper as y}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as _}from"../../../../symbols/cim/OverrideHelper.js";import{errorPointSymbol2D as b,errorPolylineSymbol2D as w,errorPolygonSymbol2D as S}from"../../../../symbols/support/defaults.js";import{filterFlag0 as I}from"../../engine/webgl/definitions.js";import{FeatureTile as v}from"../../engine/webgl/FeatureTile.js";import{MeshData as T}from"../../engine/webgl/mesh/MeshData.js";import{ResourceProxy as M}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{createGraphicSymbolMeshSchemas as R}from"../../engine/webgl/shaderGraph/techniques/createGraphicSymbolMeshSchemas.js";import{createStorageSchema as j}from"../features/schema/processor/StorageSchema.js";import{AttributeStore as x}from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as U}from"../features/support/ComputedAttributeStorage.js";import{GraphicsMetadata as C}from"../features/support/FeatureMetadata.js";import{GraphicsReader as q}from"../features/support/GraphicsReader.js";import G from"./GraphicStore.js";import{FeatureCommandQueue as k}from"../support/FeatureCommandQueue.js";import{UpdateTracking2D as P}from"../support/UpdateTracking2D.js";class F{static getOrCreate(e,t,s){let r=t.get(e.id);return r||(r=new F(e,s),t.set(e.id,r)),r}static fromItems(e,t,s){const r=new F(e,s);for(const i of t)r.append(i);return r}constructor(e,t){this.tile=e,this.metadata=t,this.addedOrModified=[],this.removed=[],this.objectIdMap=null}get reader(){return this._reader||(this._reader=q.from(this.addedOrModified,this.tile,this.metadata)),this._reader}append(e){this.addedOrModified.push(e),e.hasAnimations&&(this.objectIdMap=this.objectIdMap||{},this.objectIdMap[e.displayId]=e.objectId)}}let O=class extends(r.IdentifiableMixin(t)){constructor(e){super(e),this._attached=!1,this._tiles=new Map,this._controller=new AbortController,this._hashToSymbolInfo=new Map,this._lastCleanup=performance.now(),this._cleanupRequired=!0,this.lastUpdateId=-1,this.renderer=null,this._updateTracking=new P({debugName:"GraphicsView2D"}),this.updateRequested=!1,this.defaultPointSymbolEnabled=!0,this._commandQueue=new k({process:e=>{if("update"===e.type)return this._update();throw new Error("InternalError: Unsupported command")}}),this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this.container.destroy(),this.view=null,this.renderer=null,this._set("graphics",null),this._controller.abort(),this._graphicStore.clear(),this._graphicStore.destroy(),this._attributeStore=null,this._hashToSymbolInfo.clear(),this._updateTracking.destroy(),this._commandQueue.destroy()}_initAttributeStore(){this._storage=new U({spatialReference:this.view.spatialReference,fields:new g}),this._attributeStore=new x({isLocal:!0,update:e=>{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateStart`,{message:e}),this.container.attributeView.requestUpdate(e),this.container.requestRender(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateEnd`,{message:e})}});const e=j(null,[]);this._attributeStore.update(e,this._storage,null),this.container.checkHighlight=()=>this._attributeStore.hasHighlight}initialize(){this._initAttributeStore(),this._metadata=C.createGraphics(this.view.spatialReference),this._resourceProxy=new M({fetch:e=>Promise.all(e.map(e=>this.view.stage.textureManager.rasterizeItem(e))),fetchDictionary:e=>{throw new Error("InternalError: Graphics do not support Dictionary requests")}}),this.addHandles([n(()=>this._effectiveRenderer,()=>this._pushUpdate()),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",()=>{this.addHandles([this.graphics.on("change",()=>this._pushUpdate())]),this._graphicStore?.destroy(),this._graphicStore=new G(this.view.spatialReference,this._cimResourceManager,this.view.featuresTilingScheme,this.view.state.scale,this._attributeStore),this._attached=!0,this.requestUpdate(),this._pushUpdate()})]),this._updateTracking.addUpdateTracking("CommandQueue",this._commandQueue.updateTracking);const e=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:e,removed:[]})}get _effectiveRenderer(){return"function"==typeof this.renderer?this.renderer():this.renderer}get _cimResourceManager(){return this.view.stage.textureManager.resourceManager}get updating(){const e=!this._attached||this._updateTracking.updating;return has("esri-2d-log-updating")&&console.log(`Updating GraphicsView2D: ${e}\n -> attaching ${!this._attached}\n -> updateTracking ${this._updateTracking.updating}`),e}hitTest(e){if(!this.view||this.view.suspended)return[];const{resolution:t,rotation:r}=this.view.state,i=this._graphicStore.hitTest(e.x,e.y,2,t,r),o=new Set(i),a=this.graphics.items.reduce((e,t)=>(o.has(t.uid)&&e.set(t.uid,t),e),new Map);return i.map(e=>a.get(e)).filter(s)}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback()),this.notifyChange("updating")}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}viewChange(){this.requestUpdate()}setHighlight(e){const t=[];for(const{objectId:s,highlightFlags:r}of e){const e=this._graphicStore.getItem(s)?.displayId;t.push({objectId:s,highlightFlags:r,displayId:e})}this._attributeStore.setHighlight(t,e),this._pushUpdate()}graphicUpdateHandler(e){this._pushUpdate()}update(e){this.updateRequested=!1,this._attached&&this._graphicStore.updateLevel(e.state.resolution)&&this.pushUpdate()}pushUpdate(){this._pushUpdate()}_pushUpdate(){o(this._commandQueue.push({type:"update"}))}async _update(){try{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView._update start`);const e=await this._graphicStore.update(this.graphics,e=>this._getSymbolForGraphic(e),e=>this._ensureSymbolResource(e));for(const s of e.updated)this.container.restartAnimation(s.objectId);if(!e.hasAnyUpdate())return void this._attributeStore.sendUpdates();e.removed.length&&(this._cleanupRequired=!0),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView updateMessage`,e);const t=this._createTileMessages(e);await this._densifyItemsForDisplay(t),await this._fetchResources(t),this._write(t);for(const s of e.added)this._setFilterState(s);for(const s of e.updated)this._setFilterState(s);has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate`,e),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate.await`,e)}catch(e){}this._cleanupSharedResources()}_createTileMessages(e){const t=new Map;for(const s of e.added){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).append(s)}}for(const s of e.updated){const e=this.view.graphicsTileStore.getIntersectingTiles(s.prevSymbolBounds),r=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const i of e){F.getOrCreate(i,t,this._metadata).removed.push(s.displayId)}for(const i of r){F.getOrCreate(i,t,this._metadata).append(s)}}for(const s of e.removed){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).removed.push(s.displayId)}}return Array.from(t.values())}async _densifyItemsForDisplay(e){const t=new Map;for(const s of e)for(const e of s.addedOrModified)t.has(e)||t.set(e,e.densifyCurvedGeometryForDisplay(this.view.spatialReference));await Promise.all(t.values())}async _fetchResources(e){const t={timeZone:null,timeExtent:null};for(const{tile:s,reader:r}of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${s.id}] GraphicsView fetchResources`,e);const i=r.getCursor();for(;i.next();)for(const e of i.getMeshWriters())e.enqueueRequest(this._resourceProxy,i,s.createArcadeEvaluationOptions(t))}await this._resourceProxy.fetchEnqueuedResources()}_write(e){for(const t of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView write`,t);const e=this._writeMeshes(t);let s=this._tiles.get(t.tile.key);s||(s=this._createFeatureTile(t.tile.key)),has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView onTileData`,t),this.container.onTileData(s,{type:"update",modify:e,remove:t.removed,end:!1,attributeEpoch:this._attributeStore.epoch,objectIdMap:t.objectIdMap}),this.container.requestRender()}}_writeMeshes(e){const t={timeZone:null,timeExtent:null},s=new T(e.tile.id),r=e.reader.getCursor();for(;r.next();){s.entityStart(r.getDisplayId(),r.getZOrder());for(const i of r.getMeshWriters())i.write(s,this._resourceProxy,r,e.tile.createArcadeEvaluationOptions(t),e.tile.level);s.entityEnd()}return{...s.serialize().message,tileId:e.tile.id}}_setFilterState(e){const t=e.displayId,s=this._attributeStore.getHighlightFlags(e.objectId);this._attributeStore.setData(t,0,0,s|(e.visible?I:0))}_getSymbolForGraphic(e){return null!=e.symbol?e.symbol:null!=this._effectiveRenderer?this._effectiveRenderer.getSymbol(e):this._getNullSymbol(e)}async _ensureSymbolResource(e){if(!e.symbol)return;const t=await this._getSymbolInfo(e.symbol);if(!t)return;const s=t.linearCIM.filter(e=>"text"===e.type);if(s.length>0){const r=await this._getTextResources(e,s);return void(e.symbolResource={symbolInfo:t,textInfo:r})}e.symbolResource={symbolInfo:t}}_getSymbolInfo(e){const t=e.hash();return this._hashToSymbolInfo.has(t)||this._hashToSymbolInfo.set(t,this._createSymbolInfo(t,e).catch(e=>null)),this._hashToSymbolInfo.get(t)}async _createSymbolInfo(e,t){const s=await this._convertToCIMSymbol(t),r=await this._createLinearCIM(s);return{hash:e,cimSymbol:s,linearCIM:r,meshWriters:await this._createMeshWriters(s,r)}}async _convertToCIMSymbol(e){const t=f(e);return"web-style"===t.type?this._convertToCIMSymbol(await t.fetchSymbol({acceptedFormats:["cim","web"]})):t}async _createLinearCIM(e){return await Promise.all(y.fetchResources(e.symbol,this._cimResourceManager,[])),this.view.stage.cimAnalyzer.analyzeSymbolReference(e,!1)}async _createMeshWriters(e,t){a(this._controller.signal);const s=this.container.instanceStore,r=this.view.stage.meshWriterRegistry,i=await R(e,t,s);return Promise.all(i.map(e=>r.createMeshWriter(this._storage,this._resourceProxy,{tileInfo:this.view.featuresTilingScheme.tileInfo},e,null)))}_onTileUpdate(e){if(e.added&&e.added.length>0)for(const t of e.added)this._updateTracking.addPromise(this._addTile(t));if(e.removed&&e.removed.length>0)for(const t of e.removed)this._removeTile(t.key)}_createFeatureTile(e){const t=this.view.featuresTilingScheme.getTileBounds(c(),e),s=this.view.featuresTilingScheme.getTileResolution(e.level),r=new v(e,s,t[0],t[3]);return this._tiles.set(e,r),this.container.addChild(r),r}async _addTile(e){if(!this._attached)return;const t=this._graphicStore.queryItems(e);if(!t.length)return;const s=this._createFeatureTile(e.key),r=F.fromItems(e,t,this._metadata);await this._densifyItemsForDisplay([r]),await this._fetchResources([r]);const i=this._writeMeshes(r);s.onMessage({type:"append",append:i,clear:!1,end:!0,attributeEpoch:this._attributeStore.epoch,objectIdMap:r.objectIdMap})}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_getNullSymbol(e){const t=e.geometry;return t?l(t)?w:p(t)||u(t)?S:this.defaultPointSymbolEnabled?b:null:this.defaultPointSymbolEnabled?b:null}async _getTextResources(e,t){const s=new Array,r=new Array;for(let i=0;i<t.length;i++){const o=t[i],{resource:a,overrides:n}=o.textRasterizationParam;if(n?.length>0){const t=_.resolveSymbolOverrides({type:"CIMSymbolReference",primitiveOverrides:n,symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:a.symbol.height,anchorPointUnits:"Relative",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:a.symbol,textString:a.textString}],scaleSymbolsProportionally:!0,respectFrame:!0}]}},e,this.view.spatialReference,null,m(e.projectedGeometry),null,null);t.then(e=>{const t=e.symbolLayers[0],{textString:s}=t.markerGraphics[0];r.push({type:"cim-rasterization-info",resource:{type:"text",textString:s||"",font:a.font}}),o.text=a.textString=s||""}),s.push(t)}else r.push({type:"cim-rasterization-info",resource:a})}s.length>0&&await Promise.all(s);const o=r.map(e=>this.view.stage.textureManager.rasterizeItem(e)),a=await Promise.all(o);i(a);const n=new Map;for(let i=0;i<t.length;i++){const e=t[i];n.set(e.textRasterizationParam.resource.symbol,{text:e.text,glyphMosaicItems:a[i]})}return n}_cleanupSharedResources(){if(!this._cleanupRequired)return;const e=performance.now();if(e-this._lastCleanup<5e3)return;this._cleanupRequired=!1,this._lastCleanup=e;const t=new Set;for(const r of this._graphicStore.items()){const e=r.symbolResource?.symbolInfo.hash;t.add(e)}const s=new Set(this._hashToSymbolInfo.keys());for(const r of s.values())t.has(r)||this._hashToSymbolInfo.delete(r)}};e([h()],O.prototype,"_effectiveRenderer",null),e([h({constructOnly:!0})],O.prototype,"layerId",void 0),e([h({constructOnly:!0})],O.prototype,"requestUpdateCallback",void 0),e([h()],O.prototype,"container",void 0),e([h({constructOnly:!0})],O.prototype,"graphics",void 0),e([h()],O.prototype,"renderer",void 0),e([h()],O.prototype,"_updateTracking",void 0),e([h()],O.prototype,"updating",null),e([h()],O.prototype,"view",void 0),e([h()],O.prototype,"updateRequested",void 0),e([h()],O.prototype,"defaultPointSymbolEnabled",void 0),O=e([d("esri.views.2d.layers.graphics.GraphicsView2D")],O);export{O as default};