@arcgis/core 4.32.0-next.20241219 → 4.32.0-next.20241221

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 (185) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{0da2aaca3f0b4fe910e3.js → 015285436ca965f94e17.js} +1 -1
  4. package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +1 -0
  5. package/assets/esri/core/workers/chunks/16530347bd78dc6c2fcd.js +1 -0
  6. package/assets/esri/core/workers/chunks/{5119811063bfc97fb725.js → 1a713cc601c6fcd97d2f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{48f6eb3b63fec1d3312d.js → 2d908c115ea18e813b95.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{11052103efe3d53a784e.js → 31d9f0a37a5d0a1c450b.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{e7c3199813070ff30a3d.js → 3bb94da29dac3367ecc6.js} +1 -1
  10. package/assets/esri/core/workers/chunks/3ed7c8138231de3a3b96.js +1 -0
  11. package/assets/esri/core/workers/chunks/{9cc9bac6e02ab241e852.js → 4746b7afa90ea3641e60.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{ce33d2b5f22a5c566661.js → 4b5dbdcad438cb2dd4bf.js} +1 -1
  13. package/assets/esri/core/workers/chunks/5a0eb9dfe668cf290462.js +1 -0
  14. package/assets/esri/core/workers/chunks/{ee1ddf56549bb169509c.js → 6332da54159d72a6ce66.js} +1 -1
  15. package/assets/esri/core/workers/chunks/648d7d8fa19a2e772c89.js +1 -0
  16. package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +1 -0
  17. package/assets/esri/core/workers/chunks/69efc716991a407c3d23.js +1 -0
  18. package/assets/esri/core/workers/chunks/88c68881cbdf4e911832.js +1 -0
  19. package/assets/esri/core/workers/chunks/8e60de347b209a753c73.js +1 -0
  20. package/assets/esri/core/workers/chunks/{fb43c44a7d6b61f31e75.js → 94432e04de01ee7adc0e.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{80ac74da0b0e45e74beb.js → 9a498f2c007f4d78d4dd.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{770d233254419b741616.js → 9ad7d095e614e7e8d7f5.js} +1 -1
  23. package/assets/esri/core/workers/chunks/9dd167db3f2e68b71cea.js +1 -0
  24. package/assets/esri/core/workers/chunks/{b15894bff153e0793ef4.js → 9f495ad57cdbfa90c5b8.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{d7b76bc7bff34abc2253.js → a0b3d70a1b0360084593.js} +1 -1
  26. package/assets/esri/core/workers/chunks/a90611cdc86190799560.js +1 -0
  27. package/assets/esri/core/workers/chunks/{e213f4a1c95a33f80cdc.js → aedff36d3fec86abb9fb.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{194013d377e7dd00845f.js → b611f46835edcd6eefcc.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{eddab4dc706e75c6637f.js → bff74200a0df0950cf08.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{8f2ffb6944c9028d3bea.js → c08cb75c3eef6c45f604.js} +1 -1
  31. package/assets/esri/core/workers/chunks/c1c216b0aebe86311fae.js +1 -0
  32. package/assets/esri/core/workers/chunks/{f2b195d04414417682d4.js → cbf57abb537e86c1dd7f.js} +1 -1
  33. package/assets/esri/core/workers/chunks/dce55e7f76adecc055c3.js +1 -0
  34. package/assets/esri/core/workers/chunks/f2cdb7be3fd65f65c30b.js +1 -0
  35. package/assets/esri/core/workers/chunks/f9af0473878d960a02f2.js +1 -0
  36. package/assets/esri/core/workers/chunks/fa1c68f2ffcdff7986b6.js +1 -0
  37. package/assets/esri/core/workers/chunks/{0f1a7aeec18db5323365.js → fdd8a5eb07466541f1f9.js} +1 -1
  38. package/assets/esri/themes/base/widgets/_FeatureTable.scss +3 -3
  39. package/assets/esri/themes/dark/main.css +1 -1
  40. package/assets/esri/themes/light/main.css +1 -1
  41. package/assets/esri/themes/light/view.css +1 -1
  42. package/chunks/OperatorProject.js +1 -1
  43. package/chunks/QuadraticBezier.js +1 -1
  44. package/form/elements/GroupElement.js +1 -1
  45. package/form/elements/UtilityNetworkAssociationsElement.d.ts +4 -0
  46. package/form/elements/{UtilityNetworkAssociationElement.js → UtilityNetworkAssociationsElement.js} +1 -1
  47. package/form/elements.js +1 -1
  48. package/form/support/formUtils.js +1 -1
  49. package/geometry/operators/affineTransformOperator.js +1 -1
  50. package/geometry/operators/alphaShapeOperator.js +1 -1
  51. package/geometry/operators/areaOperator.js +1 -1
  52. package/geometry/operators/autoCompleteOperator.js +1 -1
  53. package/geometry/operators/boundaryOperator.js +1 -1
  54. package/geometry/operators/bufferOperator.js +1 -1
  55. package/geometry/operators/centroidOperator.js +1 -1
  56. package/geometry/operators/clipOperator.js +1 -1
  57. package/geometry/operators/containsOperator.js +1 -1
  58. package/geometry/operators/convexHullOperator.js +1 -1
  59. package/geometry/operators/crossesOperator.js +1 -1
  60. package/geometry/operators/cutOperator.js +1 -1
  61. package/geometry/operators/densifyOperator.js +1 -1
  62. package/geometry/operators/differenceOperator.js +1 -1
  63. package/geometry/operators/disjointOperator.js +1 -1
  64. package/geometry/operators/distanceOperator.js +1 -1
  65. package/geometry/operators/equalsOperator.js +1 -1
  66. package/geometry/operators/extendOperator.js +1 -1
  67. package/geometry/operators/generalizeOperator.js +1 -1
  68. package/geometry/operators/geodesicBufferOperator.js +1 -1
  69. package/geometry/operators/geodesicProximityOperator.js +1 -1
  70. package/geometry/operators/geodeticAreaOperator.js +1 -1
  71. package/geometry/operators/geodeticDensifyOperator.js +1 -1
  72. package/geometry/operators/geodeticDistanceOperator.js +1 -1
  73. package/geometry/operators/geodeticLengthOperator.js +1 -1
  74. package/geometry/operators/graphicBufferOperator.js +1 -1
  75. package/geometry/operators/integrateOperator.js +1 -1
  76. package/geometry/operators/intersectionOperator.js +1 -1
  77. package/geometry/operators/intersectsOperator.js +1 -1
  78. package/geometry/operators/isNearOperator.js +1 -1
  79. package/geometry/operators/labelPointOperator.js +1 -1
  80. package/geometry/operators/lengthOperator.js +1 -1
  81. package/geometry/operators/linesToPolygonsOperator.js +1 -1
  82. package/geometry/operators/locateBetweenOperator.js +1 -1
  83. package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
  84. package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
  85. package/geometry/operators/offsetOperator.js +1 -1
  86. package/geometry/operators/overlapsOperator.js +1 -1
  87. package/geometry/operators/polygonOverlayOperator.js +1 -1
  88. package/geometry/operators/polygonSlicerOperator.js +1 -1
  89. package/geometry/operators/projectOperator.js +1 -1
  90. package/geometry/operators/proximityOperator.js +1 -1
  91. package/geometry/operators/relateOperator.js +1 -1
  92. package/geometry/operators/reshapeOperator.js +1 -1
  93. package/geometry/operators/simplifyOperator.js +1 -1
  94. package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
  95. package/geometry/operators/symmetricDifferenceOperator.js +1 -1
  96. package/geometry/operators/touchesOperator.js +1 -1
  97. package/geometry/operators/unionOperator.js +1 -1
  98. package/geometry/operators/withinOperator.js +1 -1
  99. package/interfaces.d.ts +231 -71
  100. package/layers/LinkChartLayer.js +1 -1
  101. package/layers/graphics/OptimizedFeature.js +1 -1
  102. package/layers/graphics/sources/geojson/geojson.js +1 -1
  103. package/layers/knowledgeGraph/supportUtils.js +1 -1
  104. package/layers/support/Sublayer.js +1 -1
  105. package/layers/support/VideoElement.js +1 -1
  106. package/layers/support/domainUtils.js +1 -1
  107. package/layers/support/fieldUtils.js +1 -1
  108. package/linkChart/OrganicLayoutSettings.js +1 -1
  109. package/package.json +1 -1
  110. package/portal/schemas/definitions.js +1 -1
  111. package/rest/knowledgeGraphService.js +1 -1
  112. package/rest/query/operations/pbfOptimizedFeatureSet.js +1 -1
  113. package/rest/support/fileFormat.js +1 -1
  114. package/support/revision.js +1 -1
  115. package/views/2d/engine/webgl/mesh/factories/ResourceProxy.js +1 -1
  116. package/views/2d/input/MapViewInputManager.js +1 -1
  117. package/views/2d/input/handlers/KeyRotate.js +1 -1
  118. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  119. package/views/2d/layers/features/FeatureContainer.js +1 -1
  120. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  121. package/views/2d/layers/features/Processor.js +1 -1
  122. package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
  123. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  124. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  125. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  126. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  127. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  128. package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
  129. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +5 -0
  130. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  131. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  132. package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
  133. package/views/2d/layers/support/DebouncedFeatureOverride.js +5 -0
  134. package/views/2d/layers/support/FeatureCommandQueue.js +1 -1
  135. package/views/3d/input/SceneInputManager.js +1 -1
  136. package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
  137. package/views/3d/terrain/TileTexture.js +1 -1
  138. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  139. package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
  140. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  141. package/views/3d/webgl-engine/lib/TextureCompressionWorker.js +1 -1
  142. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  143. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  144. package/views/layers/FeatureLayerView.js +1 -1
  145. package/views/support/TextureCompressionHelper.js +1 -1
  146. package/views/webgl/Texture.js +1 -1
  147. package/webscene/Slide.js +1 -1
  148. package/webscene/SlideLegend.d.ts +4 -0
  149. package/webscene/SlideLegend.js +5 -0
  150. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  151. package/widgets/FeatureForm.js +1 -1
  152. package/widgets/FeatureTable/FieldColumn.js +1 -1
  153. package/widgets/Features/FeaturesViewModel.js +1 -1
  154. package/widgets/Features.js +1 -1
  155. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  156. package/widgets/OrientedImageryViewer/adapters/sketch/DigitizationAdapter.js +1 -1
  157. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  158. package/widgets/OrientedImageryViewer/digitizationUtils.js +1 -1
  159. package/widgets/OrientedImageryViewer.js +1 -1
  160. package/widgets/Popup.js +1 -1
  161. package/widgets/Print/PrintViewModel.js +1 -1
  162. package/widgets/Print/TemplateOptions.js +1 -1
  163. package/widgets/Print.js +1 -1
  164. package/widgets/ShadowCast.js +1 -1
  165. package/widgets/support/forms/formUtils.js +1 -1
  166. package/assets/esri/core/workers/chunks/0e9bd990a8d0691fb9c8.js +0 -1
  167. package/assets/esri/core/workers/chunks/27933d6ffeebb5c13ab7.js +0 -1
  168. package/assets/esri/core/workers/chunks/3ef5002b21b1a5b97e11.js +0 -1
  169. package/assets/esri/core/workers/chunks/48266c87363e7dcaefb3.js +0 -1
  170. package/assets/esri/core/workers/chunks/5786b190ad3e2d933245.js +0 -1
  171. package/assets/esri/core/workers/chunks/668679baf519ada9ae28.js +0 -1
  172. package/assets/esri/core/workers/chunks/737f381f2cfeddb96d15.js +0 -1
  173. package/assets/esri/core/workers/chunks/84d26c6c805f5855ffd3.js +0 -1
  174. package/assets/esri/core/workers/chunks/8f2f2d497b875e2b4139.js +0 -1
  175. package/assets/esri/core/workers/chunks/a4c8b773283ea8f0e256.js +0 -1
  176. package/assets/esri/core/workers/chunks/a68068b3151a14c4a0ad.js +0 -1
  177. package/assets/esri/core/workers/chunks/ad99308fb9678cdce917.js +0 -1
  178. package/assets/esri/core/workers/chunks/cc427e8f1b17744b6ea4.js +0 -1
  179. package/assets/esri/core/workers/chunks/dd4bd96dfb7f9921b774.js +0 -1
  180. package/assets/esri/core/workers/chunks/e1a03231e24293e66418.js +0 -1
  181. package/assets/esri/core/workers/chunks/fce1158755f959730602.js +0 -1
  182. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +0 -5
  183. package/views/3d/input/handlers/SingleKey.js +0 -5
  184. package/views/3d/input/handlers/SingleKeyResetHeading.js +0 -5
  185. package/views/3d/input/handlers/SingleKeyResetTilt.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import"../geometry.js";import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import n from"./knowledgeGraph/GraphQueryResult.js";import o from"./knowledgeGraph/GraphQueryResultHeader.js";import i from"./knowledgeGraph/GraphQueryStreamingResult.js";import d from"./knowledgeGraph/KnowledgeGraph.js";import s from"./knowledgeGraph/ServiceDefinition.js";import{encodeClientDataAtKeysRequest as l}from"./knowledgeGraph/wasmInterface/clientDataToWasmEncodedFactories.js";import{getWasmInterface as c}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{setInputQuantizationParametersOnEncoder as p,setOutputQuantizationParametersOnEncoder as u,setProvenanceBehaviorOnEncoder as h,bindParamArrayToWasm as w,geometryToWasm as f,bindParamObjectToWasm as g}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{inputQuantizationParametersToWasmFormat as y,namedObjectToWasm as m}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmClientDataFetchResponseToClientData as _,wasmClientDataAllKeysResponseToClientDataKeys as k}from"./knowledgeGraph/wasmInterface/wasmToClientDataFactories.js";import{wasmToDataModel as b}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{wasmToGraphQueryResponseHeader as v,decodedWasmObjToQueryResponseObj as x}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as A}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import{checkWasmError as G}from"./knowledgeGraph/wasmInterface/wasmUtils.js";import S from"../geometry/SpatialReference.js";import T from"../geometry/Geometry.js";const D=new Map,E=()=>new Map(D.entries()),C={fetchKnowledgeGraph:async e=>{const t=new d({url:e}),r=[];return r.push(W(t)),r.push(L(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await ee(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new s(r),e.serviceDefinition},executeQueryStreaming:async(e,t,a)=>{const n="include",o=`${e.url}/graph/query`;await U(e);const d=await O(o,a);if(!e.serviceDefinition?.supportsProvenance&&t.provenanceBehavior===n)throw new r("knowledge-graph:provenance-not-supported","The Knowledge Graph Service definition indicated that provenance is not supported");d.data.body=await $(t,e);const s=await I(d.data.url,d.data);if(e.dataModel){const t=await Z(s,e.dataModel);return new i({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await U(e);const o=await O(n,a);o.data.body=await B(t,e);return V(await I(o.data.url,o.data))},executeQuery:async(e,a,o)=>{const i=`${e.url}/graph/query`,d=await t(i,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...o?.query},signal:o?.signal,timeout:o?.timeout}),s=d.getHeader?.("content-type"),l=d.data;if(s?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=X({wasmQueryDecoder:t,newArrayBufferToParse:l,dataModel:e.dataModel});return new n({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:s,data:d.data})},executeSearch:async(e,a,o)=>{const i=a.typeCategoryFilter,d=`${e.url}/graph/search`,s=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:i,...o?.query},signal:o?.signal,timeout:o?.timeout}),l=s.getHeader?.("content-type"),p=s.data;if(l?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=X({wasmQueryDecoder:t,newArrayBufferToParse:p,dataModel:e.dataModel});return new n({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:l,data:s.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await U(e);const o=await O(n,a);o.data.body=await N(t);const d=await I(o.data.url,o.data);if(e.dataModel){const t=await Z(d,e.dataModel);return new i({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},fetchClientDataAtKeys:async(e,t,a={ignoreCache:!1})=>{if(!t.length)return new Map;let n=D.get(e.url||"");n||(n=new Map,D.set(e.url||"",n));const o=new Map(n.entries()),i=`${e.url}/clientData/fetch`;t=Array.from(new Set(t));const d=await c(),s=l(t,n,d,a.ignoreCache),p=await O(i,a.requestOptions);p.data.body=s;const u=await I(p.data.url,p.data),h=u.headers.get("content-type");if(h?.includes("application/x-protobuf")){const e=new d.ClientDataFetchResponseDecoder;e.deleteLater();const t=await u.arrayBuffer();return e.decode(new Uint8Array(t)),e.has_error()&&G(e.error,"knowledge-graph:fetchClientDataAtKeys-decoding-error","An error occurred while decoding the client data keys response"),_(e,n,o,a.ignoreCache)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response when fetching client data",{responseType:h,data:u})},fetchAllClientDataKeys:async(e,a)=>{const n=`${e.url}/clientData`,o=await t(n,{responseType:"array-buffer",query:{f:"pbf"},signal:a?.signal,timeout:a?.timeout}),i=o.getHeader?.("content-type"),d=o.data;if(i?.includes("application/x-protobuf")){const e=new((await c()).ClientDataKeysResponseDecoder);return e.deleteLater(),e.decode(new Uint8Array(d)),e.has_error()&&G(e.error,"knowledge-graph:fetchAllClientDataKeys-decoding-error","An error occurred while decoding the client data keys response"),k(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:i,data:o.data})},clearClientDataCache:()=>D.clear(),_fetchWrapper:async(e,t)=>fetch(e,t)};async function M(e,t,r){return C.executeApplyEdits(e,t,r)}async function Q(e,t,r){return C.executeQuery(e,t,r)}async function R(e,t,r){return C.executeQueryStreaming(e,t,r)}async function q(e,t,r){return C.executeSearch(e,t,r)}async function j(e,t,r){return C.executeSearchStreaming(e,t,r)}function P(e,t){return C.fetchAllClientDataKeys(e,t)}function F(e,t,r){return C.fetchClientDataAtKeys(e,t,r)}async function H(e){return C.fetchKnowledgeGraph(e)}async function W(e){return C.refreshDataModel(e)}async function L(e){return C.refreshServiceDefinition(e)}function K(){return C.clearClientDataCache()}async function I(e,t){return C._fetchWrapper(e,t)}async function U(t){const r=e?.findCredential(t.url);r||(t.dataModel?await ee(t):await W(t))}function z(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof T?r.set_param_key_value(e,f(t,a)):Array.isArray(t)?r.set_param_key_value(e,w(t,a)):r.set_param_key_value(e,g(t,a))}async function B(e,t){if(t.dataModel||await W(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await c(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?y(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach((e=>{t=o.add_entity(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipAdds?.forEach((e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(m(e,a)),G(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach((e=>{t.delete_by_id(e)}))})),e.relationshipDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach((e=>{t.delete_by_id(e)}))})),o.encode()}catch(d){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:d})}const i=o.get_encoding_result();return G(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(i.get_byte_buffer())}async function $(e,t){const a=await c(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,d]of Object.entries(e.bindParameters))z(r,d,n,a);if(e.bindGeometryQuantizationParameters)p(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await W(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&u(e.outputQuantizationParameters,n,a),e.provenanceBehavior&&h(e.provenanceBehavior,n);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function N(e){const t=await c(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(w(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach((e=>{a.add_named_type_filter(e)}));try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function O(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function V(e){const t=e.headers.get("content-type");if(t?.includes("application/x-protobuf")){const t=await e.arrayBuffer(),r=new((await c()).GraphApplyEditsDecoder);return r.deleteLater(),r.decode(new Uint8Array(t)),A(r)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:t,data:e.text()})}let Y=50;function J(e){Y=e}function X({wasmQueryDecoder:e,newArrayBufferToParse:t,dataModel:a,decodedHeader:n,limitMaxProcessingTime:o=!1}){t&&e.push_buffer(new Uint8Array(t));const i=[];let d,s,l=0;const c=Date.now();let p=!0;for(;e.next_row();){d&&s||(d=n??v(e),s=d.outSpatialReference??new S({wkid:4326})),l||(l=e.get_header_keys().size());const t=new Array(l);for(let r=0;r<l;r++){const n=e.get_value(r);t[r]=x(n,a,s)}if(i.push(t),o&&Date.now()-c>Y){p=!1;break}}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - inner row decoding",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return{resultHeader:d,resultRows:i,parsedAllResultsFromBuffer:p}}async function Z(e,t){const n=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),n?.includes("application/x-protobuf")){const n=e.body?.getReader(),i=new((await c()).GraphQueryDecoder);let d,s,l;i.deleteLater();const p=new Promise(((e,t)=>{s=e,l=t}));let u=!1,h=null;const w=new ReadableStream({pull:async function e(c){if(!n){const e=new r("knowledge-graph:stream-decoding-error","Error reading from stream - reader is undefined");throw l(e),e}const{done:p,value:w}=h?{done:!1,value:null}:await n.read().catch((e=>{throw l(e),n.releaseLock(),e}));w&&(h=w);try{if(p){let e;if(i.has_error()?e=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - query stream done",{errorCode:i.error.error_code,errorMessage:i.error.error_message}):u||s(new o),n.releaseLock(),e)throw c.error(e),l(e),e;return void c.close()}const{resultHeader:a,resultRows:f,parsedAllResultsFromBuffer:g}=X({wasmQueryDecoder:i,newArrayBufferToParse:w,dataModel:t,decodedHeader:d,limitMaxProcessingTime:!0});return g&&(h=null),!d&&a&&(d=a,s(a),u=!0),f.length>0?void c.enqueue(f):await e(c)}catch(f){throw a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").error(f),l(f),n.releaseLock(),new r("knowledge-graph:unexpected-server-response","Error inside streaming data return parsing",{error:f})}}});return{readableStream:w,resultHeader:await p}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:n,data:e.text()})}async function ee(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),i=n.data;if(o?.includes("application/x-protobuf")){const e=(await c()).decode_data_model_from_protocol_buffer(new Uint8Array(i));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return b(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{I as _fetchWrapper,E as _getClientDataCacheCopy,J as _setMaxQueryParsingDurationForTesting,K as clearClientDataCache,D as clientDataCache,M as executeApplyEdits,Q as executeQuery,R as executeQueryStreaming,q as executeSearch,j as executeSearchStreaming,P as fetchAllClientDataKeys,F as fetchClientDataAtKeys,H as fetchKnowledgeGraph,C as kgRestServices,W as refreshDataModel,L as refreshServiceDefinition};
5
+ import"../geometry.js";import{id as e}from"../kernel.js";import t from"../request.js";import r from"../core/Error.js";import a from"../core/Logger.js";import{isAbortError as n}from"../core/promiseUtils.js";import o from"./knowledgeGraph/GraphQueryResult.js";import i from"./knowledgeGraph/GraphQueryResultHeader.js";import d from"./knowledgeGraph/GraphQueryStreamingResult.js";import s from"./knowledgeGraph/KnowledgeGraph.js";import l from"./knowledgeGraph/ServiceDefinition.js";import{encodeClientDataAtKeysRequest as p}from"./knowledgeGraph/wasmInterface/clientDataToWasmEncodedFactories.js";import{getWasmInterface as c}from"./knowledgeGraph/wasmInterface/knowledgeWasmAccess.js";import{setInputQuantizationParametersOnEncoder as u,setOutputQuantizationParametersOnEncoder as h,setProvenanceBehaviorOnEncoder as w,bindParamArrayToWasm as f,geometryToWasm as g,bindParamObjectToWasm as y}from"./knowledgeGraph/wasmInterface/queryToWasmEncodedFactories.js";import{inputQuantizationParametersToWasmFormat as m,namedObjectToWasm as _}from"./knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js";import{wasmClientDataFetchResponseToClientData as k,wasmClientDataAllKeysResponseToClientDataKeys as b}from"./knowledgeGraph/wasmInterface/wasmToClientDataFactories.js";import{wasmToDataModel as v}from"./knowledgeGraph/wasmInterface/wasmToDataModelFactories.js";import{wasmToGraphQueryResponseHeader as x,decodedWasmObjToQueryResponseObj as A}from"./knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js";import{decoderToApplyEditsResponse as G}from"./knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js";import{checkWasmError as S}from"./knowledgeGraph/wasmInterface/wasmUtils.js";import T from"../geometry/SpatialReference.js";import D from"../geometry/Geometry.js";const E=new Map,C=()=>new Map(E.entries()),M={fetchKnowledgeGraph:async e=>{const t=new s({url:e}),r=[];return r.push(L(t)),r.push(K(t)),await Promise.all(r),t},refreshDataModel:async e=>{e.dataModel=await te(e)},refreshServiceDefinition:async e=>{const r=(await t(e.url,{query:{f:"json"}})).data;return r.capabilities=r?.capabilities?.split(","),r.supportedQueryFormats=r?.supportedQueryFormats?.split(","),e.serviceDefinition=new l(r),e.serviceDefinition},executeQueryStreaming:async(e,t,a)=>{const n="include",o=`${e.url}/graph/query`;await z(e);const i=await V(o,a);if(!e.serviceDefinition?.supportsProvenance&&t.provenanceBehavior===n)throw new r("knowledge-graph:provenance-not-supported","The Knowledge Graph Service definition indicated that provenance is not supported");i.data.body=await N(t,e);const s=await U(i.data.url,i.data);if(e.dataModel){const t=await ee(s,e.dataModel);return new d({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},executeApplyEdits:async(e,t,a)=>{if(e.serviceDefinition?.dataEditingNotSupported)throw new r("knowledge-graph:data-editing-not-supported","The Knowledge Graph Service definition indicated that data editing is not supported");const n=`${e.url}/graph/applyEdits`;await z(e);const o=await V(n,a);o.data.body=await $(t,e);return Y(await U(o.data.url,o.data))},executeQuery:async(e,a,n)=>{const i=`${e.url}/graph/query`,d=await t(i,{responseType:"array-buffer",query:{f:"pbf",openCypherQuery:a.openCypherQuery,...n?.query},signal:n?.signal,timeout:n?.timeout}),s=d.getHeader?.("content-type"),l=d.data;if(s?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Z({wasmQueryDecoder:t,newArrayBufferToParse:l,dataModel:e.dataModel});return new o({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:s,data:d.data})},executeSearch:async(e,a,n)=>{const i=a.typeCategoryFilter,d=`${e.url}/graph/search`,s=await t(d,{responseType:"array-buffer",query:{f:"pbf",searchQuery:`"${a.searchQuery}"`,typeCategoryFilter:i,...n?.query},signal:n?.signal,timeout:n?.timeout}),l=s.getHeader?.("content-type"),p=s.data;if(l?.includes("application/x-protobuf")){const t=new((await c()).GraphQueryDecoder);if(t.deleteLater(),e.dataModel){const r=Z({wasmQueryDecoder:t,newArrayBufferToParse:p,dataModel:e.dataModel});return new o({resultRows:r.resultRows,resultHeader:r.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:l,data:s.data})},executeSearchStreaming:async(e,t,a)=>{const n=`${e.url}/graph/search`;await z(e);const o=await V(n,a);o.data.body=await O(t);const i=await U(o.data.url,o.data);if(e.dataModel){const t=await ee(i,e.dataModel);return new d({resultRowsStream:t.readableStream,resultHeader:t.resultHeader})}throw new r("knowledge-graph:undefined-data-model","The KnowledgeGraph supplied did not have a data model")},fetchClientDataAtKeys:async(e,t,a={ignoreCache:!1})=>{if(!t.length)return new Map;let n=E.get(e.url||"");n||(n=new Map,E.set(e.url||"",n));const o=new Map(n.entries()),i=`${e.url}/clientData/fetch`;t=Array.from(new Set(t));const d=await c(),s=p(t,n,d,a.ignoreCache),l=await V(i,a.requestOptions);l.data.body=s;const u=await U(l.data.url,l.data),h=u.headers.get("content-type");if(h?.includes("application/x-protobuf")){const e=new d.ClientDataFetchResponseDecoder;e.deleteLater();const t=await u.arrayBuffer();return e.decode(new Uint8Array(t)),e.has_error()&&S(e.error,"knowledge-graph:fetchClientDataAtKeys-decoding-error","An error occurred while decoding the client data keys response"),k(e,n,o,a.ignoreCache)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response when fetching client data",{responseType:h,data:u})},fetchAllClientDataKeys:async(e,a)=>{const n=`${e.url}/clientData`,o=await t(n,{responseType:"array-buffer",query:{f:"pbf"},signal:a?.signal,timeout:a?.timeout}),i=o.getHeader?.("content-type"),d=o.data;if(i?.includes("application/x-protobuf")){const e=new((await c()).ClientDataKeysResponseDecoder);return e.deleteLater(),e.decode(new Uint8Array(d)),e.has_error()&&S(e.error,"knowledge-graph:fetchAllClientDataKeys-decoding-error","An error occurred while decoding the client data keys response"),b(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:i,data:o.data})},clearClientDataCache:()=>E.clear(),_fetchWrapper:async(e,t)=>fetch(e,t)};async function Q(e,t,r){return M.executeApplyEdits(e,t,r)}async function R(e,t,r){return M.executeQuery(e,t,r)}async function q(e,t,r){return M.executeQueryStreaming(e,t,r)}async function j(e,t,r){return M.executeSearch(e,t,r)}async function P(e,t,r){return M.executeSearchStreaming(e,t,r)}function F(e,t){return M.fetchAllClientDataKeys(e,t)}function H(e,t,r){return M.fetchClientDataAtKeys(e,t,r)}async function W(e){return M.fetchKnowledgeGraph(e)}async function L(e){return M.refreshDataModel(e)}async function K(e){return M.refreshServiceDefinition(e)}function I(){return M.clearClientDataCache()}async function U(e,t){return M._fetchWrapper(e,t)}async function z(t){const r=e?.findCredential(t.url);r||(t.dataModel?await te(t):await L(t))}function B(e,t,r,a){null==t?r.set_param_key_value(e,""):"object"!=typeof t||t instanceof Date?r.set_param_key_value(e,t):t instanceof D?r.set_param_key_value(e,g(t,a)):Array.isArray(t)?r.set_param_key_value(e,f(t,a)):r.set_param_key_value(e,y(t,a))}async function $(e,t){if(t.dataModel||await L(t),!t.dataModel)throw new r("knowledge-graph:data-model-undefined","Encoding could not proceed because a data model was not provided and it could not be determined from the service");const a=await c(),n=!!e.options?.cascadeDelete,o=new a.GraphApplyEditsEncoder(a.SpatialReferenceUtil.WGS84(),e.options?.inputQuantizationParameters?m(e.options?.inputQuantizationParameters):a.InputQuantizationUtil.WGS84_lossless());o.deleteLater(),o.cascade_delete=n;try{let t;e.entityAdds?.forEach((e=>{t=o.add_entity(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipAdds?.forEach((e=>{if(!e.originId||!e.destinationId)throw new r("knowledge-graph:relationship-origin-destination-missing","When adding a new relationship, you must provide both an origin and destination id on the appropriate class property");t=o.add_relationship(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:entity-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_entity(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - an entity failed to be added to the encoder")})),e.relationshipUpdates?.forEach((e=>{if(!e.id)throw new r("knowledge-graph:relationship-id-missing","When updating an entity or relationship, you must specify the id on the class level property");t=o.update_relationship(_(e,a)),S(t,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits - a relationship failed to be added to the encoder")})),e.entityDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!0);t.deleteLater(),e.ids?.forEach((e=>{t.delete_by_id(e)}))})),e.relationshipDeletes?.forEach((e=>{if(!e.typeName)throw new r("knowledge-graph:no-type-name","You must indicate the entity/relationship named object type to apply edits - delete");const t=o.make_delete_helper(e.typeName,!1);e.ids?.forEach((e=>{t.delete_by_id(e)}))})),o.encode()}catch(d){throw new r("knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed",{error:d})}const i=o.get_encoding_result();return S(i.error,"knowledge-graph:applyEdits-encoding-failed","Attempting to encode the applyEdits failed"),structuredClone(i.get_byte_buffer())}async function N(e,t){const a=await c(),n=new a.GraphQueryRequestEncoder;if(n.deleteLater(),e.outputSpatialReference?n.output_spatial_reference={wkid:e.outputSpatialReference.wkid,latestWkid:e.outputSpatialReference.latestWkid,vcsWkid:e.outputSpatialReference.vcsWkid,latestVcsWkid:e.outputSpatialReference.latestVcsWkid,wkt:e.outputSpatialReference.wkt??""}:n.output_spatial_reference=a.SpatialReferenceUtil.WGS84(),n.open_cypher_query=e.openCypherQuery,e.bindParameters)for(const[r,d]of Object.entries(e.bindParameters))B(r,d,n,a);if(e.bindGeometryQuantizationParameters)u(e.bindGeometryQuantizationParameters,n);else{if(t.dataModel||await L(t),4326!==t.dataModel?.spatialReference?.wkid)throw new r("knowledge-graph:SR-quantization-mismatch","If the DataModel indicates a coordinate system other than WGS84, inputQuantizationParameters must be provided to the query encoder");n.input_quantization_parameters=a.InputQuantizationUtil.WGS84_lossless()}e.outputQuantizationParameters&&h(e.outputQuantizationParameters,n,a),e.provenanceBehavior&&w(e.provenanceBehavior,n);try{n.encode()}catch(i){throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{error:i})}const o=n.get_encoding_result();if(0!==o.error.error_code)throw new r("knowledge-graph:query-encoding-failed","Attempting to encode the query failed",{errorCode:o.error.error_code,errorMessage:o.error.error_message});return structuredClone(o.get_byte_buffer())}async function O(e){const t=await c(),a=new t.GraphSearchRequestEncoder;if(a.deleteLater(),a.search_query=e.searchQuery,a.type_category_filter=t.esriNamedTypeCategory[e.typeCategoryFilter],!0===e.returnSearchContext&&(a.return_search_context=e.returnSearchContext),null!=e.start&&e.start>0&&(a.start_index=e.start),null!=e.num&&(a.max_num_results=e.num),null!=e.idsFilter&&Array.isArray(e.idsFilter)&&e.idsFilter.length>0)try{a.set_ids_filter(f(e.idsFilter,t))}catch(o){throw new r("knowledge-graph:ids-format-error","Attempting to set ids filter failed. This is usually caused by an incorrectly formatted UUID string",{error:o})}e.namedTypesFilter?.forEach((e=>{a.add_named_type_filter(e)}));try{a.encode()}catch(o){throw new r("knowledge-graph:search-encoding-failed","Attempting to encode the search failed",{error:o})}const n=a.get_encoding_result();if(0!==n.error.error_code)throw new r("knowledge-graph:search-encoding-failed","Attempting to get encoding result from the query failed",{errorCode:n.error.error_code,errorMessage:n.error.error_message});return structuredClone(n.get_byte_buffer())}async function V(e,r){return t(e,{responseType:"native-request-init",method:"post",query:{f:"pbf",...r?.query},body:"x",headers:{"Content-Type":"application/octet-stream"},signal:r?.signal,timeout:r?.timeout})}async function Y(e){const t=e.headers.get("content-type");if(t?.includes("application/x-protobuf")){const t=await e.arrayBuffer(),r=new((await c()).GraphApplyEditsDecoder);return r.deleteLater(),r.decode(new Uint8Array(t)),G(r)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:t,data:e.text()})}let J=50;function X(e){J=e}function Z({wasmQueryDecoder:e,newArrayBufferToParse:t,dataModel:a,decodedHeader:n,limitMaxProcessingTime:o=!1}){t&&e.push_buffer(new Uint8Array(t));const i=[];let d,s,l=0;const p=Date.now();let c=!0;for(;e.next_row();){d&&s||(d=n??x(e),s=d.outSpatialReference??new T({wkid:4326})),l||(l=e.get_header_keys().size());const t=new Array(l);for(let r=0;r<l;r++){const n=e.get_value(r);t[r]=A(n,a,s)}if(i.push(t),o&&Date.now()-p>J){c=!1;break}}if(e.has_error())throw new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - inner row decoding",{errorCode:e.error.error_code,errorMessage:e.error.error_message});return{resultHeader:d,resultRows:i,parsedAllResultsFromBuffer:c}}async function ee(e,t){const o=e.headers.get("content-type");if(e.headers.get("content-length")&&a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").warnOnce("Found `Content-Length` header when expecting a streaming HTTP response! Please investigate whether all intermediate HTTP proxies and/or load balancers are configured such that they don't forcefully buffer the entire response before returning it to the client. A valid HTTP streaming response should use Chunked Transfer Encoding and not have a Content Length defined."),o?.includes("application/x-protobuf")){const o=e.body?.getReader(),d=new((await c()).GraphQueryDecoder);let s,l,p;d.deleteLater();const u=new Promise(((e,t)=>{l=e,p=t}));let h=!1,w=null;const f=new ReadableStream({pull:async function e(c){if(!o){const e=new r("knowledge-graph:stream-decoding-error","Error reading from stream - reader is undefined");throw p(e),e}const{done:u,value:f}=w?{done:!1,value:null}:await o.read().catch((e=>{throw p(e),o.releaseLock(),e}));f&&(w=f);try{if(u){let e;if(d.has_error()?e=new r("knowledge-graph:stream-decoding-error","One or more result rows were not successfully decoded - query stream done",{errorCode:d.error.error_code,errorMessage:d.error.error_message}):h||l(new i),o.releaseLock(),e)throw c.error(e),p(e),e;return void c.close()}const{resultHeader:a,resultRows:n,parsedAllResultsFromBuffer:g}=Z({wasmQueryDecoder:d,newArrayBufferToParse:f,dataModel:t,decodedHeader:s,limitMaxProcessingTime:!0});return g&&(w=null),!s&&a&&(s=a,l(a),h=!0),n.length>0?void c.enqueue(n):await e(c)}catch(g){throw a.getLogger("esri.rest.knowledgeGraph.knowledgeGraphService").error(g),p(g),o.releaseLock(),n(g)?g:new r("knowledge-graph:unexpected-server-response","Error inside streaming data return parsing",{error:g})}}});return{readableStream:f,resultHeader:await u}}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:e.text()})}async function te(e){const a=`${e.url}/dataModel/queryDataModel`,n=await t(a,{responseType:"array-buffer",query:{f:"pbf"}}),o=n.getHeader?.("content-type"),i=n.data;if(o?.includes("application/x-protobuf")){const e=(await c()).decode_data_model_from_protocol_buffer(new Uint8Array(i));if(!e)throw new r("knowledge-graph:data-model-decode-failure","The server responded to the data model query, but the response failed to be decoded. This typically occurs when the Knowledge JS API (4.26 or later) is used with an unsupported backend (11.0 or earlier)");return v(e)}throw new r("knowledge-graph:unexpected-server-response","server returned an unexpected response",{responseType:o,data:n.data})}export{U as _fetchWrapper,C as _getClientDataCacheCopy,X as _setMaxQueryParsingDurationForTesting,I as clearClientDataCache,E as clientDataCache,Q as executeApplyEdits,R as executeQuery,q as executeQueryStreaming,j as executeSearch,P as executeSearchStreaming,F as fetchAllClientDataKeys,H as fetchClientDataAtKeys,W as fetchKnowledgeGraph,M as kgRestServices,L as refreshDataModel,K as refreshServiceDefinition};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{getMetersPerVerticalUnitForSR as e}from"../../../core/unitUtils.js";import{equals as t}from"../../../geometry/support/spatialReferenceUtils.js";import{hasGeometry as r,OptimizedFeature as o}from"../../../layers/graphics/OptimizedFeature.js";import i from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";const n=["esriGeometryPoint","esriGeometryMultipoint","esriGeometryPolyline","esriGeometryPolygon"];class a{constructor(e){this._options=e,this.geometryTypes=n,this._coordinatePtr=0,this._vertexDimension=0}createFeatureResult(){return new i}prepareFeatures(e){this._vertexDimension=2,e.hasZ&&this._vertexDimension++,e.hasM&&this._vertexDimension++}finishFeatureResult(o){if(!o?.features||!o.hasZ||!this._options.sourceSpatialReference||!o.spatialReference||t(o.spatialReference,this._options.sourceSpatialReference)||o.spatialReference.vcsWkid)return;const i=e(this._options.sourceSpatialReference)/e(o.spatialReference);if(1!==i)for(const e of o.features){if(!r(e))continue;const t=e.geometry.coords;for(let e=2;e<t.length;e+=3)t[e]*=i}}addFeature(e,t){e.features.push(t)}createFeature(){return new o}createSpatialReference(){return{wkid:0}}createGeometry(){return new s}addField(e,t){e.fields.push(t)}allocateCoordinates(e){e.coords.length=e.lengths.reduce(((e,t)=>e+t),0)*this._vertexDimension,this._coordinatePtr=0}addCoordinate(e,t){e.coords[this._coordinatePtr++]=t}addCoordinatePoint(e,t){e.coords.push(t)}addLength(e,t){e.lengths.push(t)}addQueryGeometry(e,t){e.queryGeometry=t.queryGeometry,e.queryGeometryType=t.queryGeometryType}createPointGeometry(){return new s}}export{a as OptimizedFeatureSetParserContext,n as optimizedGeometryTypes};
5
+ import{getMetersPerVerticalUnitForSR as e}from"../../../core/unitUtils.js";import{equals as t}from"../../../geometry/support/spatialReferenceUtils.js";import{hasGeometry as r,OptimizedFeature as o}from"../../../layers/graphics/OptimizedFeature.js";import i from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";const n=["esriGeometryPoint","esriGeometryMultipoint","esriGeometryPolyline","esriGeometryPolygon"];class a{constructor(e){this._options=e,this.geometryTypes=n,this._coordinatePtr=0,this._vertexDimension=0}createFeatureResult(){return new i}prepareFeatures(e){this._vertexDimension=2,e.hasZ&&this._vertexDimension++,e.hasM&&this._vertexDimension++}finishFeatureResult(o){if(!o?.features||!o.hasZ||!this._options.sourceSpatialReference||!o.spatialReference||t(o.spatialReference,this._options.sourceSpatialReference)||o.spatialReference.vcsWkid)return;const i=e(this._options.sourceSpatialReference)/e(o.spatialReference);if(1!==i)for(const e of o.features){if(!r(e))continue;const t=e.geometry.coords;for(let e=2;e<t.length;e+=3)t[e]*=i}}addFeature(e,t){e.features.push(t)}createFeature(){return new o(null,{},null,0)}createSpatialReference(){return{wkid:0}}createGeometry(){return new s}addField(e,t){e.fields.push(t)}allocateCoordinates(e){e.coords.length=e.lengths.reduce(((e,t)=>e+t),0)*this._vertexDimension,this._coordinatePtr=0}addCoordinate(e,t){e.coords[this._coordinatePtr++]=t}addCoordinatePoint(e,t){e.coords.push(t)}addLength(e,t){e.lengths.push(t)}addQueryGeometry(e,t){e.queryGeometry=t.queryGeometry,e.queryGeometryType=t.queryGeometryType}createPointGeometry(){return new s}}export{a as OptimizedFeatureSetParserContext,n as optimizedGeometryTypes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{strict as p}from"../../core/jsonMap.js";const g=p()({AIX:"aix",EPS:"eps",GIF:"gif",JPG:"jpg",PDF:"pdf",PNG32:"png32",PNG8:"png8",SVG:"svg",SVGZ:"svgz",TIFF:"tiff"});export{g as formatJsonMap};
5
+ import{strict as n}from"../../core/jsonMap.js";const o=n()({AIX:"aix",EPS:"eps",GIF:"gif",JPG:"jpg",PDF:"pdf",PNG32:"png32",PNG8:"png8",SVG:"svg",SVGZ:"svgz",TIFF:"tiff"},{ignoreUnknown:!1});export{o as formatJsonMap};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const f="20241219",b="24cf0bafb4d9dfff669fcb3f0fc80d458b7b15a4";export{f as buildDate,b as commitHash};
5
+ const e="20241221",b="364e0177afd8e82777b3cd60be03f5708e113306";export{e 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{numericHash as e}from"../../../../../../core/string.js";import{discardUrlIfHasUrlHash as t}from"../../Utils.js";import{AResourceProxy as r}from"../../shaderGraph/techniques/mesh/AResourceProxy.js";class s extends r{constructor(e){super(),this._fetcher=e,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destroy(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(r){const s=t(r.resource),o=e(JSON.stringify(s));return this._pendingIds.has(o)||(this._pendingIds.add(o),this._pendingRequests.push({...r,resourceId:o})),o}async fetchEnqueuedResources(){const e=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const t=await this._fetcher.fetch(e,this._abortOptions);for(let r=0;r<t.length;r++){const s=e[r].resourceId;this._resourceIdToResource.set(s,t[r])}}async fetchResourceImmediate(e){const t=await this._fetcher.fetch([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return t[0]}async fetchDictionaryResourceImmediate(e){const t=await this._fetcher.fetchDictionary([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return t[0]}getResource(e){return this._resourceIdToResource.get(e)}}export{s as ResourceProxy};
5
+ import{numericHash as e}from"../../../../../../core/string.js";import{discardUrlIfHasUrlHash as t}from"../../Utils.js";import{AResourceProxy as r}from"../../shaderGraph/techniques/mesh/AResourceProxy.js";class s extends r{constructor(e){super(),this._fetcher=e,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destroy(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(r){const s=t(r.resource),o=e(JSON.stringify(s));return this._pendingIds.has(o)||(this._pendingIds.add(o),this._pendingRequests.push({...r,resourceId:o})),o}async fetchEnqueuedResources(){const e=this._pendingRequests;if(this._pendingIds.clear(),this._pendingRequests=[],0===e.length)return;const t=await this._fetcher.fetch(e,this._abortOptions);for(let r=0;r<t.length;r++){const s=e[r].resourceId;this._resourceIdToResource.set(s,t[r])}}async fetchResourceImmediate(e){const t=await this._fetcher.fetch([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return t[0]}async fetchDictionaryResourceImmediate(e){const t=await this._fetcher.fetchDictionary([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return t[0]}getResource(e){return this._resourceIdToResource.get(e)}}export{s as ResourceProxy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as i,watch as r,initial as n}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{DoubleClickZoom as c}from"./handlers/DoubleClickZoom.js";import{DoubleTapDragZoom as p}from"./handlers/DoubleTapDragZoom.js";import{DragPan as m}from"./handlers/DragPan.js";import{DragRotate as l}from"./handlers/DragRotate.js";import{GamepadNavigation as u}from"./handlers/GamepadNavigation.js";import{KeyPan as w}from"./handlers/KeyPan.js";import{KeyRotate as h}from"./handlers/KeyRotate.js";import{KeyZoom as d}from"./handlers/KeyZoom.js";import{MouseWheelZoom as v}from"./handlers/MouseWheelZoom.js";import{PinchRotateAndZoom as g}from"./handlers/PinchAction.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as j,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{DoubleTapDrag as D}from"../../input/recognizers/DoubleTapDrag.js";import{Drag as A}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as M}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as P}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as b}from"../../input/recognizers/SingleAndDoubleClick.js";const T={counter:"Control",pan:{left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown"},zoom:{zoomIn:["=","+"],zoomOut:["-","_"]},rotate:{clockwiseOption1:"a",clockwiseOption2:"A",counterClockwiseOption1:"d",counterClockwiseOption2:"D",resetOption1:"n",resetOption2:"N"}};let z=class extends t{initialize(){const e=()=>this.view?.ready;this.addHandles([i((()=>!e()),(()=>this._disconnect())),i(e,(()=>this._connect()))])}destroy(){this._disconnect()}get latestPointerType(){return this._inputManager?.latestPointerType}get latestPointerLocation(){return this._inputManager?.latestPointerLocation}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}isModifierKeyDown(e){return this._inputManager?.isModifierKeyDown(e)??!1}_disconnect(){this.view.viewEvents.disconnect(),this._inputManager=o(this._inputManager)}_connect(){const e=this.view.surface,t=new f(e,this.view.input),o=[new M,new P,new b,new A(this.view.navigation),new D],i=new j({eventSource:t,recognizers:o});i.installHandlers("prevent-context-menu",[new _],y.INTERNAL),i.installHandlers("navigation",[new g(this.view),new u(this.view),new v(this.view),new c(this.view),new c(this.view,[T.counter]),new m(this.view,"primary"),new w(this.view,T.pan),new d(this.view,T.zoom),new h(this.view,T.rotate),new l(this.view,"secondary"),new p(this.view,"touch")],y.INTERNAL),this.view.viewEvents.connect(i),this._source=t,this._inputManager=i,r((()=>this.view?.navigation?.browserTouchPanEnabled),(e=>{this._source&&(this._source.browserTouchPanningEnabled=!e)}),n)}get test(){}};e([s()],z.prototype,"view",void 0),e([s()],z.prototype,"latestPointerType",null),e([s()],z.prototype,"latestPointerLocation",null),e([s()],z.prototype,"multiTouchActive",null),z=e([a("esri.views.2d.input.MapViewInputManager")],z);const k=z;export{k as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{when as r,watch as i,initial as n}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{DoubleClickZoom as c}from"./handlers/DoubleClickZoom.js";import{DoubleTapDragZoom as p}from"./handlers/DoubleTapDragZoom.js";import{DragPan as m}from"./handlers/DragPan.js";import{DragRotate as u}from"./handlers/DragRotate.js";import{GamepadNavigation as l}from"./handlers/GamepadNavigation.js";import{KeyPan as h}from"./handlers/KeyPan.js";import{KeyRotate as w}from"./handlers/KeyRotate.js";import{KeyZoom as d}from"./handlers/KeyZoom.js";import{MouseWheelZoom as v}from"./handlers/MouseWheelZoom.js";import{PinchRotateAndZoom as g}from"./handlers/PinchAction.js";import{BrowserEventSource as f}from"../../input/BrowserEventSource.js";import{InputManager as j,ViewEventPriorities as y}from"../../input/InputManager.js";import{PreventContextMenu as _}from"../../input/handlers/PreventContextMenu.js";import{DoubleTapDrag as D}from"../../input/recognizers/DoubleTapDrag.js";import{Drag as A}from"../../input/recognizers/Drag.js";import{ImmediateDoubleClick as M}from"../../input/recognizers/ImmediateDoubleClick.js";import{PointerClickHoldAndDrag as P}from"../../input/recognizers/PointerClickHoldAndDrag.js";import{SingleAndDoubleClick as b}from"../../input/recognizers/SingleAndDoubleClick.js";const T={counter:"Control",pan:{left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown"},zoom:{zoomIn:["=","+"],zoomOut:["-","_"]},rotate:{clockwise:["a","A"],counterClockwise:["d","D"],reset:["n","N"]}};let z=class extends t{initialize(){const e=()=>this.view?.ready;this.addHandles([r((()=>!e()),(()=>this._disconnect())),r(e,(()=>this._connect()))])}destroy(){this._disconnect()}get latestPointerType(){return this._inputManager?.latestPointerType}get latestPointerLocation(){return this._inputManager?.latestPointerLocation}get multiTouchActive(){return this._inputManager?.multiTouchActive??!1}isModifierKeyDown(e){return this._inputManager?.isModifierKeyDown(e)??!1}_disconnect(){this.view.viewEvents.disconnect(),this._inputManager=o(this._inputManager)}_connect(){const e=this.view.surface,t=new f(e,this.view.input),o=[new M,new P,new b,new A(this.view.navigation),new D],r=new j({eventSource:t,recognizers:o});r.installHandlers("prevent-context-menu",[new _],y.INTERNAL),r.installHandlers("navigation",[new g(this.view),new l(this.view),new v(this.view),new c(this.view),new c(this.view,[T.counter]),new m(this.view,"primary"),new h(this.view,T.pan),new d(this.view,T.zoom),new w(this.view,T.rotate),new u(this.view,"secondary"),new p(this.view,"touch")],y.INTERNAL),this.view.viewEvents.connect(r),this._source=t,this._inputManager=r,i((()=>this.view?.navigation?.browserTouchPanEnabled),(e=>{this._source&&(this._source.browserTouchPanningEnabled=!e)}),n)}get test(){}};e([s()],z.prototype,"view",void 0),e([s()],z.prototype,"latestPointerType",null),e([s()],z.prototype,"latestPointerLocation",null),e([s()],z.prototype,"multiTouchActive",null),z=e([a("esri.views.2d.input.MapViewInputManager")],z);const C=z;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{InputHandler as e}from"../../../input/InputHandler.js";import{onVisibilityChange as i}from"../../../input/VisibilityChange.js";class t extends e{constructor(e,t,s){super(!0),this.view=e,this.keys=t,this._pressed=!1,this._keyToDirection={[t.clockwiseOption1]:"clockwise",[t.clockwiseOption2]:"clockwise",[t.counterClockwiseOption1]:"counterClockwise",[t.counterClockwiseOption2]:"counterClockwise",[t.resetOption1]:"reset",[t.resetOption2]:"reset"},this.registerIncoming("key-down",s,(e=>this._handleKeyDown(e))),this.registerIncoming("key-up",s,(e=>this._handleKeyUp(e))),this.registerIncoming("blur",s,(()=>this._handleStop())),this._visibilityHandle=i((e=>e?null:this._handleStop()))}onUninstall(){this._visibilityHandle?.remove(),this._handleStop()}_handleKeyDown(e){e.data.repeat||this._handleKey(e,!0)}_handleKeyUp(e){this._handleKey(e,!1)}_handleStop(){this._pressed&&(this._pressed=!1,this.view.mapViewNavigation.stop())}_handleKey(e,i){const t=e.modifiers;if(t.size>0&&!t.has("Shift")||!this.view.constraints.rotationEnabled)return;const s=this._keyToDirection[e.data.key];if(this._pressed=null!=s,this._pressed){if(e.preventDefault(),i)switch(this.view.mapViewNavigation.begin(),s){case"clockwise":this.view.mapViewNavigation.continuousRotateClockwise();break;case"counterClockwise":this.view.mapViewNavigation.continuousRotateCounterclockwise();break;case"reset":this.view.mapViewNavigation.resetRotation()}else this._pressed=!1,this.view.mapViewNavigation.stop();e.stopPropagation()}}}export{t as KeyRotate};
5
+ import{InputHandler as e}from"../../../input/InputHandler.js";import{onVisibilityChange as i}from"../../../input/VisibilityChange.js";class t extends e{constructor(e,t,s){super(!0),this.view=e,this.keys=t,this._keyToDirection=new Map,this._pressed=!1,this._addKeysMapping(t),this.registerIncoming("key-down",s,(e=>this._handleKeyDown(e))),this.registerIncoming("key-up",s,(e=>this._handleKeyUp(e))),this.registerIncoming("blur",s,(()=>this._handleStop())),this._visibilityHandle=i((e=>e?null:this._handleStop()))}onUninstall(){this._visibilityHandle?.remove(),this._handleStop()}_addKeysMapping(e){this._addKeyMapping(e.clockwise,"clockwise"),this._addKeyMapping(e.counterClockwise,"counterClockwise"),this._addKeyMapping(e.reset,"reset")}_addKeyMapping(e,i){for(const t of e)this._keyToDirection.set(t,i)}_handleKeyDown(e){e.data.repeat||this._handleKey(e,!0)}_handleKeyUp(e){this._handleKey(e,!1)}_handleStop(){this._pressed&&(this._pressed=!1,this.view.mapViewNavigation.stop())}_handleKey(e,i){const t=e.modifiers;if(t.size>0&&!t.has("Shift")||!this.view.constraints.rotationEnabled)return;const s=this._keyToDirection.get(e.data.key);if(this._pressed=null!=s,this._pressed){if(e.preventDefault(),i)switch(this.view.mapViewNavigation.begin(),s){case"clockwise":this.view.mapViewNavigation.continuousRotateClockwise();break;case"counterClockwise":this.view.mapViewNavigation.continuousRotateCounterclockwise();break;case"reset":this.view.mapViewNavigation.resetRotation()}else this._pressed=!1,this.view.mapViewNavigation.stop();e.stopPropagation()}}}export{t as KeyRotate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{notDeepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as p,ignoreAbortErrors as d,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import v from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as b}from"../../../layers/graphics/featureConversionUtils.js";import A from"../../../layers/support/FeatureFilter.js";import{checkCurrentUserSupport as F}from"../../../layers/support/featureLayerUtils.js";import{packFields as S}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as E}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as x}from"../../../layers/support/timeSupport.js";import j from"../../../rest/support/AggregateFeatureSet.js";import C from"../../../rest/support/FeatureSet.js";import V from"../../../rest/support/Query.js";import{LayerView2DMixin as U}from"./LayerView2D.js";import{FeatureContainer as k}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as q}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as R}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as Q}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as I}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as O}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as L}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as T}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{ParquetLayerAdapter as H}from"./features/layerAdapters/ParquetLayerAdapter.js";import{StreamLayerAdapter as W}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as M}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as D}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import N from"./support/FeatureCommandQueue.js";import{handleNoEngineError as J}from"./support/handleNoEngineError.js";import{HighlightCounter as G}from"./support/HighlightCounter.js";import{toJSONGeometryType as $}from"./support/util.js";import{FeatureTileSubscriptionManager as z}from"../tiling/FeatureTileSubscriptionManager.js";import B from"../../layers/FeatureLayerView.js";import Z from"../../layers/LayerView.js";import K from"../../layers/RefreshableLayerView.js";import X from"../../../geometry/Extent.js";function Y(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const ee=4294967294;let te=class extends(B(K(U(Z)))){constructor(){super(...arguments),this._commandsQueue=new N({process:e=>{switch(e.type){case"edit-by-feature":case"edit-by-id":return this._doEdit(e);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new G,this._lastAvailableFields=[],this._lastTargetState=null,this.eventLog=new R,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._fields=null,this.featureEffectView=new v}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=p(),d(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransition()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===E(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await q(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view?.featuresTilingScheme?.tileInfo?.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(c()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get hasAllFeatures(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&!this.suspended&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new O(this.layer):new I(this.layer);case"geojson":case"csv":case"wfs":return new O(this.layer);case"parquet":return new H(this.layer);case"subtype-group":return new M(this.layer);case"ogc-feature":return new T(this.layer);case"stream":return new W(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new L(this.layer);case"catalog-footprint":return new Q(this.layer);default:a(this.layer)}return null}get timeExtent(){return x(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="default"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return J(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return J(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return J(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=C.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await J(r,{features:[]}),s=C.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await J(r,{features:[]}),s=j.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return J(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return J(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return J(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return J(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return J(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return J(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await J(r,{count:0,extent:null});return{count:i.count,extent:X.fromJSON(i.extent)}}async queryAttributeBins(e,t){const r=(await this.getWorker()).features.executeAttributeBinsQuery(e.toJSON(),t),i=await J(r,{features:[]});return C.fromJSON(i)}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;this.view.animation&&!this._lastTargetState&&(this._lastTargetState=e.state.clone()),!this.view.animation&&this._lastTargetState&&(this._lastTargetState=null);const t=this._subscriptionManager.update(e.targetState,this._lastTargetState);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),d(this._updatingHandles.addPromise(this._workerAttached.promise)),d(this._attachProxy()),this.featureContainer=new k(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new z({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),d(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,viewTimeExtent:this.view.timeExtent,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())})),f((()=>this.visible),(e=>{this.view.labelManager.requestUpdate()}))]),"stream"!==this.layer.type&&"parquet"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._edit(e))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this.featureContainer=null,this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=p(),d(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("dataUpdating",e.data)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:async t=>{if(has("esri-2d-stabilize-glyphs")){const r=[];for(const i of t)r.push(await e.view.stage.painter.textureManager.rasterizeItem(i));return r}return Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t))))},fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await D(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=V.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=V.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this._getEffectiveEdit(e);return t?this._commandsQueue.push(t).catch(y):void 0}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%ee+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%ee+1}_getEffectiveEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,r=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),i=t&&this.availableFields.includes(t);if(r&&!i)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null;const s=this.layer,a=e.historicMoment?.getTime()??null,n="layerId"in s&&e.editedFeatures?.find((e=>e.layerId===s.layerId));if(n&&this._canEditByFeature(n)){const e=!1,r=!1,i=$(this.layer.geometryType),{adds:s,deletes:o,updates:u}=n.editedFeatures,l=this.layer.objectIdField,h=s.map((t=>b(t,i,e,r))),c=u.map((t=>b(t.current,i,e,r)));return{type:"edit-by-feature",added:h,removed:o.map((e=>"attributes"in e?{globalId:t?e.attributes[t]:null,objectId:l?e.attributes[l]:null}:e)),updated:c,historicMoment:a}}return{type:"edit-by-id",added:e.addedFeatures,updated:e.updatedFeatures,removed:e.deletedFeatures,historicMoment:a}}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every((e=>this.view.spatialReference.equals(e.geometry?.spatialReference)))&&r.every((e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference)))}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await Promise.allSettled([this._updateRequiredFields(),F(this.layer)]),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransition(),this.featureContainer.restartAllAnimations(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doEdit(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onEdits(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=Y(this._lastAvailableFields,e);return this._lastAvailableFields=t,S(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[re(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone,timeExtent:this.view.timeExtent}}_addHighlights(e,t){this._highlightCounter.addGroup(e,t),this._commandsQueue.push({type:"highlight"})}_removeHighlights(e,t){this._highlightCounter.deleteGroup(e,t),this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightGroups(i),r=this._getHighlightBits(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function re(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new A,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new A).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],te.prototype,"_commandsQueue",void 0),e([w()],te.prototype,"_sourceRefreshVersion",void 0),e([w()],te.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],te.prototype,"_pipelineUpdating",void 0),e([w({readOnly:!0})],te.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],te.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],te.prototype,"hasFullGeometries",null),e([w()],te.prototype,"featureEffectView",void 0),e([w()],te.prototype,"labelingCollisionInfos",null),e([w()],te.prototype,"layerAdapter",null),e([w({readOnly:!0})],te.prototype,"timeExtent",null),e([w()],te.prototype,"updating",void 0),te=e([_("esri.views.2d.layers.FeatureLayerView2D")],te);const ie=te;export{ie as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import r from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import{neverReached as a}from"../../../core/compilerUtils.js";import o from"../../../core/Error.js";import{makeHandle as n}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import u from"../../../core/Logger.js";import{destroyMaybe as l}from"../../../core/maybe.js";import{notDeepEqual as h}from"../../../core/object.js";import{createAbortError as c,createResolver as d,ignoreAbortErrors as p,throwIfNotAbortError as y,isAbortError as g}from"../../../core/promiseUtils.js";import{watch as f,initial as m}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as v}from"../../../core/support/UpdatingHandles.js";import b from"../../../layers/effects/FeatureEffectView.js";import{convertFromFeature as F}from"../../../layers/graphics/featureConversionUtils.js";import A from"../../../layers/support/FeatureFilter.js";import{checkCurrentUserSupport as S}from"../../../layers/support/featureLayerUtils.js";import{packFields as j}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as x}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as E}from"../../../layers/support/timeSupport.js";import I from"../../../rest/support/AggregateFeatureSet.js";import U from"../../../rest/support/FeatureSet.js";import k from"../../../rest/support/Query.js";import{LayerView2DMixin as C}from"./LayerView2D.js";import{FeatureContainer as V}from"./features/FeatureContainer.js";import{createFeaturePipelineWorkerProxy as q}from"./features/FeaturePipelineWorkerProxy.js";import{FeatureSourceEventLog as R}from"./features/FeatureSourceEventLog.js";import{CatalogFootprintLayerAdapter as O}from"./features/layerAdapters/CatalogFootprintLayerAdapter.js";import{FeatureLayerAdapter as Q}from"./features/layerAdapters/FeatureLayerAdapter.js";import{InMemoryLayerAdapter as L}from"./features/layerAdapters/InMemoryLayerAdapter.js";import{KnowledgeGraphSublayerAdapter as W}from"./features/layerAdapters/KnowledgeGraphSublayerAdapter.js";import{OGCFeatureLayerAdapter as H}from"./features/layerAdapters/OGCFeatureLayerAdapter.js";import{OrientedImageryLayerAdapter as P}from"./features/layerAdapters/OrientedImageryLayerAdapter.js";import{ParquetLayerAdapter as T}from"./features/layerAdapters/ParquetLayerAdapter.js";import{StreamLayerAdapter as M}from"./features/layerAdapters/StreamLayerAdapter.js";import{SubtypeGroupLayerAdapter as D}from"./features/layerAdapters/SubtypeGroupLayerAdapter.js";import{createComplexSymbolInstances as N}from"./features/schema/processor/symbols/ComplexSymbolSchema.js";import G from"./support/FeatureCommandQueue.js";import{handleNoEngineError as J}from"./support/handleNoEngineError.js";import{HighlightCounter as $}from"./support/HighlightCounter.js";import{toJSONGeometryType as z}from"./support/util.js";import{FeatureTileSubscriptionManager as B}from"../tiling/FeatureTileSubscriptionManager.js";import Z from"../../layers/FeatureLayerView.js";import K from"../../layers/LayerView.js";import X from"../../layers/RefreshableLayerView.js";import Y from"../../../geometry/Extent.js";function ee(e,t){const r=new Set;return e&&e.forEach((e=>r.add(e))),t&&t.forEach((e=>r.add(e))),r.has("*")?["*"]:Array.from(r)}const te=4294967294;let re=class extends(Z(X(C(K)))){constructor(){super(...arguments),this._commandsQueue=new G({process:e=>{switch(e.type){case"override":return this._doOverride(e.message);case"update":return this._doUpdate();case"highlight":return this._updateHighlights()}}}),this._visibilityOverrides=new Set,this._highlightCounter=new $,this._lastAvailableFields=[],this._lastTargetState=null,this.eventLog=new R,this._sourceRefreshVersion=1,this._displayRefreshVersion=1,this._pipelineUpdating=!1,this._editUpdatingHandles=new v,this._fields=null,this._sourceUpdating=!1,this.featureEffectView=new b}destroy(){this._workerProxy?.destroy(),this._workerAttached.reject(c()),this._commandsQueue.destroy()}initialize(){this._workerAttached=d(),p(this._workerAttached.promise),this.addResolvingPromise(this._initProxy()),this.featureEffectView.featureEffect=this.featureEffect,this.featureEffectView.endTransition()}async _initProxy(){const e=this.layer;if("isTable"in e&&e.isTable)throw new o("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:e});if("mesh"===e.geometryType)throw new o("featurelayerview:geometry-type-not-supported",`Geometry type of ${e.geometryType} is not supported`,{layer:e});if(("feature"===e.type||"subtype-group"===e.type)&&!1===x(e)?.operations.supportsQuery)throw new o("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:e});this._workerProxy&&this._workerProxy.destroy();const t=this._createClientOptions();this._workerProxy=await q(t)}async _attachProxy(){const e={service:await this.layerAdapter.createServiceOptions(this.view),tileInfoJSON:this.view?.featuresTilingScheme?.tileInfo?.toJSON()};let t=[];Array.isArray(e.service.source)&&(t=e.service.source);try{await this._workerProxy.pipeline.onAttach(e,{transferList:t}),this._workerAttached.resolve()}catch(r){this._workerAttached.reject(c()),y(r)}}async _detachProxy(){return this._workerProxy.pipeline.onDetach()}async getWorker(){return await this._workerAttached.promise,this._workerProxy}get dataUpdating(){return this._sourceUpdating||this._editUpdatingHandles.updating}get hasAllFeatures(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeatures}get hasAllFeaturesInView(){return this.layer.visible&&!this.suspended&&this.eventLog.hasAllFeaturesInView}get hasFullGeometries(){return this.layer.visible&&!this.suspended&&this.eventLog.hasFullGeometries}get labelingCollisionInfos(){const e=this.layerAdapter.getLabelingDeconflictionInfo(this.view),t=this.layer.geometryType,r=!this.suspended;return e.map((({vvEvaluators:e,deconflictionEnabled:i})=>({container:this.featureContainer,vvEvaluators:e,deconflictionEnabled:i,geometryType:t,visible:r})))}get layerAdapter(){switch(this.layer.type){case"feature":return"memory"===this.layer.source.type?new L(this.layer):new Q(this.layer);case"geojson":case"csv":case"wfs":return new L(this.layer);case"parquet":return new T(this.layer);case"subtype-group":return new D(this.layer);case"ogc-feature":return new H(this.layer);case"stream":return new M(this.layer);case"oriented-imagery":return new P(this.layer);case"knowledge-graph-sublayer":return new W(this.layer);case"catalog-footprint":return new O(this.layer);default:a(this.layer)}return null}get timeExtent(){return E(this.layerAdapter.timeOptions,this.view?.timeExtent,this._get("timeExtent"))}getDisplayStatistics(e,t){return this.featureContainer?.getDisplayStatistics(e,t)}async queryHeatmapStatistics(e){return(await this.getWorker()).pipeline.queryHeatmapStatistics(e)}highlight(e,t="default"){let a;e instanceof r?a=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?a=[e]:s.isCollection(e)&&e.length>0?a=e.map((e=>e?.getObjectId())).toArray():Array.isArray(e)&&e.length>0&&(a="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e?.getObjectId())));const o=a?.filter(i);return o?.length?(this._addHighlights(o,t),n((()=>this._removeHighlights(o,t)))):n()}getHighlightIds(){return Array.from(this._highlightCounter.ids())}hasHighlight(){return!this._highlightCounter.empty}async hitTest(e,i){const s=await this.featureContainer.hitTest(i);if(0===s.length)return null;const a=await this.getWorker(),{features:o,aggregates:n}=await a.pipeline.getDisplayFeatures(s),u=this.featureContainer.getSortKeys(s),l=({displayId:e},{displayId:t})=>u.has(e)&&u.has(t)?u.get(e)-u.get(t):e-t;return o.sort(l).reverse(),n.sort(l).reverse(),[...n.map((r=>this._createGraphicHit(e,t.fromJSON(r)))),...o.map((t=>this._createGraphicHit(e,r.fromJSON(t))))]}async queryStatistics(){const e=await this.getWorker();return J(e.pipeline.queryStatistics(),{featureCount:0,ringCount:0,vertexCount:0})}async querySummaryStatistics(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForSummaryStatistics(this._cleanUpQuery(e),s,r);return J(a,{})}async queryAggregateSummaryStatistics(e,t,r){const i={...t,scale:this.view.scale},s=(await this.getWorker()).aggregates.executeQueryForSummaryStatistics(this._cleanUpAggregateQuery(e),i,r);return J(s,{})}async queryUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForUniqueValues(this._cleanUpQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryAggregateUniqueValues(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForUniqueValues(this._cleanUpAggregateQuery(e),s,r);return J(a,{uniqueValueInfos:[]})}async queryClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForClassBreaks(this._cleanUpQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryAggregateClassBreaks(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForClassBreaks(this._cleanUpAggregateQuery(e),s,r);return J(a,{classBreakInfos:[]})}async queryHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.features.executeQueryForHistogram(this._cleanUpQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}async queryAggregateHistogram(e,t,r){const i=await this.getWorker(),s={...t,scale:this.view.scale},a=i.aggregates.executeQueryForHistogram(this._cleanUpAggregateQuery(e),s,r);return J(a,{bins:[],maxValue:null,minValue:null,normalizationTotal:null})}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=U.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}async queryVisibleFeatures(e,t){const r=(await this.getWorker()).pipeline.queryVisibleFeatures(this._cleanUpQuery(e),t),i=await J(r,{features:[]}),s=U.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregates(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t),i=await J(r,{features:[]}),s=I.fromJSON(i);return s.features.forEach((e=>this._setLayersForFeature(e))),s}async queryAggregateIds(e,t){const r=(await this.getWorker()).aggregates.executeQueryForIds(this._cleanUpAggregateQuery(e),t);return J(r,[])}async queryAggregateCount(e,t){const r=(await this.getWorker()).aggregates.executeQueryForCount(this._cleanUpAggregateQuery(e),t);return J(r,0)}async queryAggregateJSON(e,t){const r=(await this.getWorker()).aggregates.executeQuery(this._cleanUpAggregateQuery(e),t);return J(r,{features:[]})}async queryFeaturesJSON(e,t){const r=(await this.getWorker()).features.executeQuery(this._cleanUpQuery(e),t);return J(r,{features:[]})}async queryObjectIds(e,t){const r=(await this.getWorker()).features.executeQueryForIds(this._cleanUpQuery(e),t);return J(r,[])}async queryFeatureCount(e,t){const r=(await this.getWorker()).features.executeQueryForCount(this._cleanUpQuery(e),t);return J(r,0)}async queryExtent(e,t){const r=(await this.getWorker()).features.executeQueryForExtent(this._cleanUpQuery(e),t),i=await J(r,{count:0,extent:null});return{count:i.count,extent:Y.fromJSON(i.extent)}}async queryAttributeBins(e,t){const r=(await this.getWorker()).features.executeAttributeBinsQuery(e.toJSON(),t),i=await J(r,{features:[]});return U.fromJSON(i)}async getSampleFeatures(e){return(await this.getWorker()).pipeline.getSampleFeatures(e)}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._subscriptionManager)return;this.view.animation&&!this._lastTargetState&&(this._lastTargetState=e.state.clone()),!this.view.animation&&this._lastTargetState&&(this._lastTargetState=null);const t=this._subscriptionManager.update(e.targetState,this._lastTargetState);this.featureContainer.setVisibleTiles(t)}attach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.attach"),p(this._updatingHandles.addPromise(this._workerAttached.promise)),p(this._attachProxy()),this.featureContainer=new V(this),this.container.addChild(this.featureContainer),this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._subscriptionManager=new B({tileInfoView:this.view.featuresTilingScheme,updateSubscriptions:e=>{this.featureContainer.updateSubscriptions(e),p(this._updatingHandles.addPromise(this.getWorker().then((t=>t.pipeline.updateSubscriptions(e)))))},isDone:e=>this.featureContainer.isDone(e)}),this.requestUpdate(),this.addAttachHandles([f((()=>JSON.stringify({displayRefreshVersion:this._displayRefreshVersion,timeExtent:this.timeExtent,clips:this.clips,filter:this.filter,featureEffect:this.featureEffect,sourceRefreshVersion:this._sourceRefreshVersion,timeZone:this.view.timeZone,viewTimeExtent:this.view.timeExtent,effect:this.featureEffect,...this.layerAdapter.getUpdateHashProperties(this.view)})),(()=>this._update()),m),f((()=>this.updateSuspended),(e=>{e||(this._subscriptionManager.resume(),this.view.labelManager.requestUpdate())})),f((()=>this.visible),(e=>{this.view.labelManager.requestUpdate()}))]),"stream"!==this.layer.type&&"parquet"!==this.layer.type&&"catalog-footprint"!==this.layer.type&&this.addAttachHandles(this.layer.on("edits",(e=>this._editUpdatingHandles.addPromise(this._edit(e)))))}detach(){has("esri-2d-update-debug")&&console.debug("FeatureLayerView2D.detach"),this._detachProxy(),this._fields=null,this.featureContainer.destroy(),this.featureContainer=null,this._commandsQueue.clear(),this.container.removeAllChildren(),this._subscriptionManager=l(this._subscriptionManager),this._workerProxy.pipeline.onDetach(),this._workerAttached=d(),p(this._workerAttached.promise),this._lastAvailableFields=[],this._lastSchema=null}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){const e="renderer"in this.layer&&null!=this.layer.renderer,t=this._commandsQueue.updateTracking.updating,r=null!=this._updatingRequiredFieldsPromise,i=this.featureContainer.updatingHandles.updating,s=this.updateRequested||e&&(t||r)||i||this._pipelineUpdating||this.dataUpdating;if(has("esri-2d-log-updating")){console.log(`Updating FLV2D (${this.layer.id}): ${s}\n -> updateRequested ${this.updateRequested}\n -> hasRenderer ${e}\n -> updatingRequiredFields ${r}\n -> hasPendingCommand ${t}\n -> dataUpdating ${this.dataUpdating}\n -> processing ${this._pipelineUpdating}\n -> updatingContainer ${i}\n`);for(const e of this.featureContainer.subscriptions())console.log(` -> Tile[${e.id}] Done: ${e.done}`)}return s}_createClientOptions(){const e=this;return{get container(){return e.featureContainer},setUpdating:e=>{this._set("_pipelineUpdating",e.pipeline),this._set("_sourceUpdating",e.source)},emitEvent:e=>{this.emit(e.name,e.event)},get eventLog(){return e.eventLog},fetch:async t=>{if(has("esri-2d-stabilize-glyphs")){const r=[];for(const i of t)r.push(await e.view.stage.painter.textureManager.rasterizeItem(i));return r}return Promise.all(t.map((t=>e.view.stage.painter.textureManager.rasterizeItem(t))))},fetchDictionary:e=>Promise.all(e.map((e=>this._fetchDictionaryRequest(e))))}}async _fetchDictionaryRequest(e){try{if("subtype-group"===this.layer.type)throw new Error("InternalError: SubtypeGroupLayer does not support dictionary renderer");const t=this.layer.renderer;if(!t||"dictionary"!==t.type)throw new Error("InternalError: Expected layer to have a DictionaryRenderer");const r=this._lastSchema.processor.mesh.factory.symbology;if("dictionary"!==r.type)throw new Error("InternalError: Expected schema to be of type 'dictionary'");const i={cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,store:this.featureContainer.instanceStore,scaleExpression:r.scaleExpression};this._fields||(this._fields=this.layer.fields.map((e=>e.toJSON())));const s=r.visualVariableUniforms,a=await t.getSymbolAsync(e.feature,{fields:this._fields});if(!a||!a.data)return{type:"dictionary-response",meshes:[]};return{type:"dictionary-response",meshes:await N(a.data,{uniforms:s,path:"renderer",schemaOptions:i})}}catch(t){return{type:"dictionary-response",meshes:[]}}}_cleanUpQuery(e){const t=k.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t.toJSON()}_cleanUpAggregateQuery(e){const t=k.from(e)||this.createAggregateQuery();t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference);const r=t.objectIds??[];for(const i of t.aggregateIds??[])r.push(i);return t.objectIds=r,t.aggregateIds=[],t.toJSON()}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this.updateSuspended)return void this._subscriptionManager.suspend();const t=this.layer,r=e.historicMoment?.getTime()??null,i="layerId"in t&&e.editedFeatures?.find((e=>e.layerId===t.layerId));if(i&&this._canEditByFeature(i)){const{adds:e,deletes:t,updates:s}=i.editedFeatures,a=this.layer.objectIdField,o=s.map((e=>e.current)),n=t.map((e=>"attributes"in e?{objectId:a?e.attributes[a]:null}:e)),u=await this._resolveIdenifiers(n);return this.addOverrides({added:e,updated:o,removed:u,historicMoment:r,isWeak:!0})}const[s,a,o]=await Promise.all([this._resolveIdenifiers(e.addedFeatures),this._resolveIdenifiers(e.updatedFeatures),this._resolveIdenifiers(e.deletedFeatures)]),n=[...s,...a];return this._commandsQueue.push({type:"override-by-id",updates:n,removed:o,historicMoment:r,isWeak:!0}).catch(y)}async doRefresh(e){this.attached&&(this.updateSuspended&&e||(e?this.incrementSourceRefreshVersion():this.incrementDisplayRefreshVersion()))}incrementSourceRefreshVersion(){this._sourceRefreshVersion=(this._sourceRefreshVersion+1)%te+1}incrementDisplayRefreshVersion(){this._displayRefreshVersion=(this._displayRefreshVersion+1)%te+1}async _resolveIdenifiers(e){const t=[],r=[];for(const a of e)null==a.objectId||-1===a.objectId?null==a.globalId?u.getLogger(this).warn("mapview-apply-edits","A feature identifier must contain either a GlobalId or ObjectId. Ignoring",{identifier:a}):r.push(a.globalId):t.push(a.objectId);const i="globalIdField"in this.layer&&this.layer.globalIdField,s=i&&this.availableFields.includes(i);if(r.length&&!s)return u.getLogger(this).error(new o("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${i} to be included the layer's outFields for updates to be reflected on the map`)),t;if(r.length){const e=await this._workerProxy.pipeline.getObjectIdsFromGlobalIds(r);for(const r of e)t.push(r)}return t}async addOverrides(e){const t=!1,r=!1,i=z(this.layer.geometryType),s=this.layer.objectIdField,a=[];for(const n of e.added){const e=F(n,i,t,r,s);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.updated){const e=F(n,i,t,r,s);if(null==e.objectId)throw new o("featurelayerview:bad-override","Feature does not have an objectId",{feature:n});a.push(e)}for(const n of e.removed)if(null==n)throw new o("featurelayerview:bad-override","Tried to remove an invalid objectId",{objectId:n});return this._commandsQueue.push({type:"override",updates:a,removed:e.removed,release:[],isWeak:e.isWeak??!1,historicMoment:e.historicMoment??null})}async removeOverrides(e){for(const t of e)if(null==t)throw new o("featurelayerview:bad-override","Tried to remove an override for an invalid objectId",{objectId:t});return this._commandsQueue.push({type:"override",updates:[],removed:[],release:e,isWeak:!1,historicMoment:null})}_canEditByFeature(e){const{adds:t,updates:r}=e.editedFeatures;return t.every((e=>this.view.spatialReference.equals(e.geometry?.spatialReference)))&&r.every((e=>this.view.spatialReference.equals(e.current.geometry?.spatialReference)))}async _doUpdate(){"featureReduction"in this.layer&&this.layer.featureReduction&&this.layer.featureReduction!==this._lastFeatureReduction&&(this.layer.featureReduction=this.layer.featureReduction?.clone(),this._lastFeatureReduction=this.layer.featureReduction);try{if(await Promise.allSettled([this._updateRequiredFields(),S(this.layer)]),this.destroyed||!this.layerAdapter?.hasRequiredSupport||!this._subscriptionManager)return;const e=this.featureContainer.instanceStore;this.featureContainer.attributeView.lockTextureUploads(),e.updateStart();const t=this.featureEffect,r={store:e,cimAnalyzer:this.view.stage.cimAnalyzer,cimResourceManager:this.view.stage.painter.textureManager.resourceManager,scaleExpression:void 0},i=this._createViewSchemaConfig(),s={source:this.layerAdapter.createSourceSchema(i,this._sourceRefreshVersion),processor:await this.layerAdapter.createProcessorSchema(r,i,this._displayRefreshVersion)},a=h(this._lastSchema?.source.mutable,s.source.mutable)||h(this._lastSchema?.processor,s.processor);if(!a)return this.featureContainer.requestRender(),this.featureContainer.attributeView.unlockTextureUploads(),e.updateEnd(),void(this.featureEffectView.featureEffect=t);this._lastSchema=s,this._fields=null;const o=Math.round(performance.now());has("esri-2d-update-debug")&&console.debug(`Id[${this.layer.uid}] Version[${o}] FeatureLayerView2D._doUpdate`,{changes:a});const n=await this.getWorker();await n.pipeline.updateSchema(s,o),e.updateEnd(),this.featureEffectView.featureEffect=t,this.featureEffectView.endTransition(),this.featureContainer.restartAllAnimations(),this.featureContainer.attributeView.unlockTextureUploads(),this.featureContainer.swapRenderState(),this.featureContainer.requestRender(),has("esri-2d-update-debug")&&console.debug(`Version[${o}] FeatureLayerView2D.updateEnd`),this.requestUpdate()}catch(e){has("esri-2d-update-debug")&&console.error("Encountered an error during update",e)}}async _doOverride(e){const t=await this.getWorker();try{this.featureContainer.editStart(),await t.pipeline.onOverride(e),this.featureContainer.editEnd()}catch(r){g(r),0}}get hasFilter(){const e=this.layerAdapter.hasFilters?.(this.view)??!1;return null!=this.filter||null!=this.timeExtent||this._visibilityOverrides.size>0||e}_getEffectiveAvailableFields(e){const t=ee(this._lastAvailableFields,e);return this._lastAvailableFields=t,j(this.layer.fieldsIndex,t)}_createViewSchemaConfig(){const e=[ie(this.view,this.layerAdapter,this.timeExtent,this._visibilityOverrides,this.filter),this.featureEffect?.filter?.toJSON()??null];return{availableFields:this._getEffectiveAvailableFields(this.availableFields),filters:e,scale:this.view.scale,timeZone:this.view.timeZone,timeExtent:this.view.timeExtent}}_addHighlights(e,t){this._highlightCounter.addGroup(e,t),this._commandsQueue.push({type:"highlight"})}_removeHighlights(e,t){this._highlightCounter.deleteGroup(e,t),this._commandsQueue.push({type:"highlight"})}async _updateHighlights(){const e=[];for(const i of this._highlightCounter.ids()){const t=this._highlightCounter.getHighlightGroups(i),r=this._getHighlightBits(t);e.push({objectId:i,highlightFlags:r})}const t=await this.getWorker();if(this.destroyed)return;const r=t.pipeline.updateHighlight({highlights:e}).catch((e=>{g(e)||u.getLogger(this).error(e)}));this._updatingHandles.addPromise(r)}_setLayersForFeature(e){e.layer=e.sourceLayer=this.layer,this.layerAdapter.setGraphicOrigin&&this.layerAdapter.setGraphicOrigin(e)}_createGraphicHit(e,t){return this._setLayersForFeature(t),null!=t.geometry&&(t.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:t,layer:this.layer,mapPoint:e}}};function ie(e,t,r,i,s){s&&(s=s.clone());const a=null!=s?s.timeExtent:null,o=null!=r&&null!=a?r.intersection(a):r||a;o&&(s??=new A,s.timeExtent=o),s=t.addFilters?.(s,e)??s;let n=s?.toJSON()??null;return i.size&&(n??=(new A).toJSON(),n.hiddenIds=Array.from(i)),n}e([w()],re.prototype,"_commandsQueue",void 0),e([w()],re.prototype,"_sourceRefreshVersion",void 0),e([w()],re.prototype,"_displayRefreshVersion",void 0),e([w({readOnly:!0})],re.prototype,"_pipelineUpdating",void 0),e([w()],re.prototype,"_sourceUpdating",void 0),e([w({readOnly:!0})],re.prototype,"dataUpdating",null),e([w({readOnly:!0})],re.prototype,"hasAllFeatures",null),e([w({readOnly:!0})],re.prototype,"hasAllFeaturesInView",null),e([w({readOnly:!0})],re.prototype,"hasFullGeometries",null),e([w()],re.prototype,"featureEffectView",void 0),e([w()],re.prototype,"labelingCollisionInfos",null),e([w()],re.prototype,"layerAdapter",null),e([w({readOnly:!0})],re.prototype,"timeExtent",null),e([w()],re.prototype,"updating",void 0),re=e([_("esri.views.2d.layers.FeatureLayerView2D")],re);const se=re;export{se 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.32/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 r}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as i,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 p extends r{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._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),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.requestRender())}for(const t of this.children)t.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case i.MAP:return this._renderMapPhase(e);case i.HIGHLIGHT:return this._renderHighlightPhase(e);case i.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(_(t))return t;return null}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()}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.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 r of t)s.set(r.fieldName,{minValue:r.minValue,maxValue:r.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this.requestRender()}swapRenderState(){this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState&&this._renderState.flush(),this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){e(s);const r=t.inner;if(!this._subscriptions.has(r.id))return;const i=this._subscriptions.get(r.id);if(i.version!==r.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${r.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${r.id}] FeatureContainer - Dropping message, outdated version]`,r)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==r.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${r.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 r=t();return s?s.resolvers.push(r):(s={x:e.x,y:e.y,resolvers:[r]},this._hitTestsRequests.push(s)),this.requestRender(),r.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const r of this.children)if(r.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,r=e.state.scale;r<=(t||1/0)&&r>=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,r=t.getBoundFramebufferObject(),a=t.getViewport(),o=e.passOptions,h=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=i.HITTEST;const{distance:d,smallSymbolDistance:l}=e.passOptions,u=Math.max(d,l);for(const i of this.children)i.visible&&i.containsScreenPoint(e.state,e.passOptions.position,2*u)&&this._renderTile(i,e,n.All);s.draw(e),s.unbind(),t.bindFramebuffer(r),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 r of this.children)r.visible&&this._renderTile(r,e,t,d.Heatmap);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,r){const i=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,n=e.getDisplayList(this._instanceStore,i);t.selection=s,n?.render(t,r)}}function _(e){return e.techniqueRef.type===d.Heatmap}export{p 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 r}from"../../engine/AFeatureContainer.js";import{WGLDrawPhase as i,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 p extends r{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._layerView=e,this.addTransitionable(this._layerView.featureEffectView)}renderChildren(e){if(this._updateAttributeView(),this._renderState?.update(this.attributeView.currentEpoch),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.requestRender())}for(const t of this.children)t.setTransform(e.state);switch(super.renderChildren(e),e.drawPhase){case i.MAP:return this._renderMapPhase(e);case i.HIGHLIGHT:return this._renderHighlightPhase(e);case i.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(_(t))return t;return null}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()}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.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 r of t)s.set(r.fieldName,{minValue:r.minValue,maxValue:r.maxValue})}editStart(){this._renderState?.lockUploads(),this.attributeView.lockTextureUploads(),this._lockStatisticUpdates=!0}editEnd(){this._renderState?.unlockUploads(),this.attributeView.unlockTextureUploads(),this._lockStatisticUpdates=!1;for(const e of this._updateStatisticsRequests)this.updateStatistics(e.level,e.statistics);this._updateStatisticsRequests=[],this._renderState?.flush(),this.requestRender()}swapRenderState(){this._renderStateNext&&(has("esri-2d-update-debug")&&console.debug(`Version[${this._renderStateNext.version}] FeatureContainer.update.swapRenderState`),this._renderState?.destroy(),this._renderState=this._renderStateNext,this._renderStateNext=null),this._renderState&&this._renderState.flush(),this.requestRender()}setVisibleTiles(e){this._visibleTiles=e}async onMessage(t,s){e(s);const r=t.inner;if(!this._subscriptions.has(r.id))return;const i=this._subscriptions.get(r.id);if(i.version!==r.subscriptionVesrion){if(has("esri-2d-update-debug")){const e=`${r.subscriptionVesrion} != ${i.version}`;console.debug(`Version[${e}] Tile[${r.id}] FeatureContainer - Dropping message, outdated version]`,r)}return}const n=this._renderStateNext??this._renderState;if(!n)throw new Error("InternalError: No renderState defined");n.version!==r.version&&console.error(`InternalError: Version mismatch. [renderState: ${n.version}, message: ${r.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 r=t();return s?s.resolvers.push(r):(s={x:e.x,y:e.y,resolvers:[r]},this._hitTestsRequests.push(s)),this.requestRender(),r.promise}getSortKeys(e){const t=new Set(e),s=new Map;for(const r of this.children)if(r.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,r=e.state.scale;r<=(t||1/0)&&r>=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,r=t.getBoundFramebufferObject(),a=t.getViewport(),o=e.passOptions,h=e.drawPhase;s.bind(e),e.passOptions=s.createOptions(e,this._hitTestsRequests),e.drawPhase=i.HITTEST;const{distance:d,smallSymbolDistance:l}=e.passOptions,u=Math.max(d,l);for(const i of this.children)i.visible&&i.containsScreenPoint(e.state,e.passOptions.position,2*u)&&this._renderTile(i,e,n.All);s.draw(e),s.unbind(),t.bindFramebuffer(r),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 r of this.children)r.visible&&this._renderTile(r,e,t,d.Heatmap);s.techniqueRef.renderResolvePass(e,s)}_renderTile(e,t,s,r){const i=has("featurelayer-force-marker-text-draw-order")?a.STRICT_MARKERS_AND_TEXT:a.BATCHING,n=e.getDisplayList(this._instanceStore,i);t.selection=s,n?.render(t,r)}}function _(e){return e.techniqueRef.type===d.Heatmap}export{p 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.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{handlesGroup as t}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{nextTick as s}from"../../../../core/nextTick.js";import{throwIfNotAbortError as i,createResolver as r,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import n from"../../../../core/RandomLCG.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{ignoreConnectionErrors as d}from"../../../../core/workers/utils.js";import c from"../../../../layers/support/TileInfo.js";import p from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{tileSize as l}from"../../engine/webgl/definitions.js";import{PipelineConnectionHandlers as h}from"./PipelineConnectionHandlers.js";import g from"./Processor.js";import{FeatureSource as _}from"./sources/FeatureSource.js";import{FeatureTileSubscription as b}from"./sources/FeatureTileSubscription.js";import{Tile as f}from"./support/Tile.js";class m{constructor(e){this.inner=e,this.resolver=r()}}class y{constructor(){this._aggregateAdapter={getFeatureObjectIds:e=>this._processor.getFeatureObjectIdsForAggregate(e)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor?.destroy(),this._source?.destroy(),this._handles?.remove(),this._updateLocalEditsRequest=null,this._tileInfoView=null}onAttach(e){has("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const s=this._connection,i=c.fromJSON(e.tileInfoJSON);this._tileInfoView=new p(i),this._source=new _(e.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),s),this._processor=new g(s,this._source),this._handles=t([u((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),o(this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){has("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(e){this._connection=new h(e)}get features(){const t=this._source?.queryEngine;if(!t)throw new e("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new e("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(e){return this._processor.getDisplayFeatures(e)}getDisplayIds(e){return this._processor.getDisplayIds(e)}async updateSchema(e,t){return has("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new m({schema:e,version:t}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(e){const t=new m(e);return this._updateSubscriptionRequests.push(t),this._requestUpdate(),t.resolver.promise}updateHighlight(e){const t=new m(e);return this._updateHighlightRequests.push(t),this._requestUpdate(),t.resolver.promise}async addParquetFile(e){return this._source.addParquetFile(e)}async onEdits(t){if(null!=this._updateLocalEditsRequest)throw new e("InternalError - Already processing an edit");this._updateLocalEditsRequest=new m(t);const s=this._updateLocalEditsRequest.resolver.promise;return this._requestUpdate(),s}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(e,t){return this.features.executeQuery(e,t)}async queryHeatmapStatistics(e){const t=Math.round(a(e.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof e.fieldOffset,o=e.fieldOffset??0,n=Array.from(this._subscriptions.values()),u=this._source.chunks(),d=t**2,c=3/(Math.PI*d),p=2*t,h=Math.ceil(l/p);for(const a of n){const t=a.tile,n=new Float64Array(h*h);for(const s of u){const i=s.getTileReader(t);if(!i)continue;const u=i.getCursor();for(;u.next();){let t=1;if(null!=e.field){const s=u.readAttribute(e.field);t=r?-1*+s:+s+o}const s=u.readXForDisplay()/p,i=u.readYForDisplay()/p,a=Math.floor(s),l=Math.floor(i);if(a<0||l<0||a>=h||l>=h)continue;const g=((.5+a-s)*p)**2+((.5+l-i)*p)**2;if(g>d)continue;const _=t*(c*(1-g/d)**2);n[l+a*h]+=_}}for(let e=0;e<n.length;e++)s=Math.min(s,n[e]),i=Math.max(i,n[e])}return{max:i,min:s}}async getSampleFeatures(e){const t=this._source.chunks();if(t.reduce(((e,t)=>e+t.size()),0)<=e.minFeatureCount){if(!this._source.updateTracking.updating){const e=[];return this._source.store.forEachUnsafe((t=>e.push(t.readLegacyFeatureWorldSpace()))),e}return null}const s=new Set,i=[],r=t.map((e=>e.reader.getCursor())),o=new n,u=3*e.sampleSize;for(let n=0;n<u&&i.length<e.sampleSize;n++){const e=r[o.getIntRange(0,t.length-1)];if(0===e.getSize())continue;const n=o.getIntRange(0,e.getSize()-1);e.setIndex(n);const u=e.getObjectId();s.has(u)||(s.add(u),i.push(e.readLegacyFeatureWorldSpace()))}return i.length>=e.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,s((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=d(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(e){const t=e.tileId;if(this._subscriptions.has(t))return;has("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.subscribe`);const s=new f(this._tileInfoView,t),i=new b(s,e.version);this._subscriptions.set(t,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(e){const t=this._subscriptions.get(e);t&&(has("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.unsubscribe`),t.abort(),this._source.onUnsubscribe(t),this._processor.onUnsubscribe(t),this._subscriptions.delete(t.key.id))}async _doUpdate(){if(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const e=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const t of e)this._doUpdateSubscriptions(t.inner),t.resolver.resolve()}const e=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=e){const{schema:t,version:s}=e.inner;await this._doUpdateSchema(t,s)}const t=this._updateLocalEditsRequest;if(this._updateLocalEditsRequest=null,null!=t){has("esri-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",t.inner);const e=await this._source.getLocalEdit(t.inner);await this._processor.applyLocalEdit(e),this._source.applyLocalEdit(e),has("esri-2d-update-debug")&&console.debug("Pipeline.endEditOverride",t.inner)}if(this._updateHighlightRequests.length){const e=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const t of e)this._processor.updateHighlight(t.inner),t.resolver.resolve()}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(r){i(r)}null!=t&&t.resolver.resolve(),null!=e&&e.resolver.resolve(),this._updateRequested?(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})):(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(e,t){has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateStart`,{schema:e});const s={tileInfo:this._tileInfoView?.tileInfo},i=await this._source.update(e,t),r=Array.from(this._subscriptions.values());await this._processor.update(e,t,s,i,r),has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateEnd`)}_doUpdateSubscriptions(e){has("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",e);for(const t of e.subscribe)this._subscribe(t);for(const t of e.unsubscribe)this._unsubscribe(t)}}export{y as default};
5
+ import e from"../../../../core/Error.js";import{handlesGroup as t}from"../../../../core/handleUtils.js";import has from"../../../../core/has.js";import{nextTick as s}from"../../../../core/nextTick.js";import{throwIfNotAbortError as i,createResolver as r,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import n from"../../../../core/RandomLCG.js";import{watch as u}from"../../../../core/reactiveUtils.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{ignoreConnectionErrors as d}from"../../../../core/workers/utils.js";import c from"../../../../layers/support/TileInfo.js";import p from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{tileSize as l}from"../../engine/webgl/definitions.js";import{PipelineConnectionHandlers as h}from"./PipelineConnectionHandlers.js";import g from"./Processor.js";import{FeatureSource as _}from"./sources/FeatureSource.js";import{FeatureTileSubscription as b}from"./sources/FeatureTileSubscription.js";import{Tile as f}from"./support/Tile.js";class m{constructor(e){this.inner=e,this.resolver=r()}}class y{constructor(){this._aggregateAdapter={getFeatureObjectIds:e=>this._processor.getFeatureObjectIdsForAggregate(e)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor?.destroy(),this._source?.destroy(),this._handles?.remove(),this._updateOverridesRequest=null,this._tileInfoView=null}onAttach(e){has("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const s=this._connection,i=c.fromJSON(e.tileInfoJSON);this._tileInfoView=new p(i),this._source=new _(e.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),s),this._processor=new g(s,this._source),this._handles=t([u((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),o(this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){has("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(e){this._connection=new h(e)}get features(){const t=this._source?.queryEngine;if(!t)throw new e("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new e("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(e){return this._processor.getDisplayFeatures(e)}getDisplayIds(e){return this._processor.getDisplayIds(e)}getObjectIdsFromGlobalIds(e){return this._source.getObjectIdsFromGlobalIds(e)}async updateSchema(e,t){return has("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new m({schema:e,version:t}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(e){const t=new m(e);return this._updateSubscriptionRequests.push(t),this._requestUpdate(),t.resolver.promise}updateHighlight(e){const t=new m(e);return this._updateHighlightRequests.push(t),this._requestUpdate(),t.resolver.promise}async addParquetFile(e){return this._source.addParquetFile(e)}async onOverride(t){if(null!=this._updateOverridesRequest)throw new e("InternalError - Already processing an edit");this._updateOverridesRequest=new m(t);const s=this._updateOverridesRequest.resolver.promise;return this._requestUpdate(),s}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(e,t){return this.features.executeQuery(e,t)}async queryHeatmapStatistics(e){const t=Math.round(a(e.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof e.fieldOffset,o=e.fieldOffset??0,n=Array.from(this._subscriptions.values()),u=this._source.chunks(),d=t**2,c=3/(Math.PI*d),p=2*t,h=Math.ceil(l/p);for(const a of n){const t=a.tile,n=new Float64Array(h*h);for(const s of u){const i=s.getTileReader(t);if(!i)continue;const u=i.getCursor();for(;u.next();){let t=1;if(null!=e.field){const s=u.readAttribute(e.field);t=r?-1*+s:+s+o}const s=u.readXForDisplay()/p,i=u.readYForDisplay()/p,a=Math.floor(s),l=Math.floor(i);if(a<0||l<0||a>=h||l>=h)continue;const g=((.5+a-s)*p)**2+((.5+l-i)*p)**2;if(g>d)continue;const _=t*(c*(1-g/d)**2);n[l+a*h]+=_}}for(let e=0;e<n.length;e++)s=Math.min(s,n[e]),i=Math.max(i,n[e])}return{max:i,min:s}}async getSampleFeatures(e){const t=this._source.chunks();if(t.reduce(((e,t)=>e+t.size()),0)<=e.minFeatureCount){if(!this._source.updateTracking.updating){const e=[];return this._source.store.forEachUnsafe((t=>e.push(t.readLegacyFeatureWorldSpace()))),e}return null}const s=new Set,i=[],r=t.map((e=>e.reader.getCursor())),o=new n,u=3*e.sampleSize;for(let n=0;n<u&&i.length<e.sampleSize;n++){const e=r[o.getIntRange(0,t.length-1)];if(0===e.getSize())continue;const n=o.getIntRange(0,e.getSize()-1);e.setIndex(n);const u=e.getObjectId();s.has(u)||(s.add(u),i.push(e.readLegacyFeatureWorldSpace()))}return i.length>=e.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,s((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=d(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(e){const t=e.tileId;if(this._subscriptions.has(t))return;has("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.subscribe`);const s=new f(this._tileInfoView,t),i=new b(s,e.version);this._subscriptions.set(t,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(e){const t=this._subscriptions.get(e);t&&(has("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.unsubscribe`),t.abort(),this._source.onUnsubscribe(t),this._processor.onUnsubscribe(t),this._subscriptions.delete(t.key.id))}async _doUpdate(){if(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const e=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const t of e)this._doUpdateSubscriptions(t.inner),t.resolver.resolve()}const e=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=e){const{schema:t,version:s}=e.inner;await this._doUpdateSchema(t,s)}const t=this._updateOverridesRequest;if(this._updateOverridesRequest=null,null!=t){has("esri-2d-update-debug")&&console.debug("Pipeline.applyOverride",t.inner);const e=await this._source.normalizeOverrides(t.inner);null!=e.historicMoment&&this._source.unsafeSetQueryHistoricMoment(e.historicMoment),this._source.applyOverride(e),has("esri-2d-update-debug")&&console.debug("Pipeline.endOverride",t.inner)}if(this._updateHighlightRequests.length){const e=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const t of e)this._processor.updateHighlight(t.inner),t.resolver.resolve()}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{const e=this._source.takeOverrideUpdate();null!=e&&this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesStart"),await this._processor.applyOverrideUpdate(e),has("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesEnd")),this._subscriptions.size&&(has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),has("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(r){i(r)}null!=t&&t.resolver.resolve(),null!=e&&e.resolver.resolve(),this._updateRequested?(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0})):(has("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(e,t){has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateStart`,{schema:e});const s={tileInfo:this._tileInfoView?.tileInfo},i=await this._source.update(e,t),r=Array.from(this._subscriptions.values());await this._processor.update(e,t,s,i,r),has("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateEnd`)}_doUpdateSubscriptions(e){has("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",e);for(const t of e.subscribe)this._subscribe(t);for(const t of e.unsubscribe)this._unsubscribe(t)}}export{y 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.32/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{destroyMaybe as t}from"../../../../core/maybe.js";import{notDeepEqual as e}from"../../../../core/object.js";import{throwIfNotAbortError as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{diff as i}from"../../../../core/accessorSupport/diffUtils.js";import{ignoreConnectionErrors as a}from"../../../../core/workers/utils.js";import o from"../../../../geometry/SpatialReference.js";import{MultiTileMeshData as n}from"../../engine/webgl/mesh/MultiTileMeshData.js";import{FeatureMeshFactory as c}from"../../engine/webgl/mesh/factories/FeatureMeshFactory.js";import{ResourceProxy as h}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{MeshWriterRegistry as u}from"../../engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js";import{MatcherContext as g}from"../../engine/webgl/util/MatcherContext.js";import{ProcessorTileMessageQueue as p}from"./ProcessorTileMessageQueue.js";import{BinningStrategy as d}from"./processor/BinningStrategy.js";import{ClusterStrategy as y}from"./processor/ClusterStrategy.js";import{FeatureUpdateStrategy as _}from"./processor/FeatureUpdateStrategy.js";import{AttributeStore as l}from"./support/AttributeStore.js";import{ComputedAttributeStorage as m}from"./support/ComputedAttributeStorage.js";class f{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._registry=new u,this._proxy=new h({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new l({isLocal:!1,update:t=>a(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destroy(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getDisplayIds(t){const e={};return this._strategy?(this._strategy.displayMap(t,(t=>t),((t,s,r)=>{e[r]=t})),e):e}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,s,r,a,n){const h=t.processor,u=e(this._schema?.storage,h.storage),p=e(this._schema?.mesh.properties,h.mesh.properties),d=e(this._schema?.mesh.factory,h.mesh.factory),y=e(this._schema?.mesh.strategy,h.mesh.strategy),_=b(this._schema?.expressionProperties,h.expressionProperties),l=_.some((t=>this._attributeStore.hasArcadeDependency(t))),f=_.some((t=>this._factory?.hasArcadeDependency(t)??!1)),S=_.some((t=>this._strategy?.hasArcadeDependency(t)))||this._strategy?.isAggregate&&l,j=f||S,I=p||d||y;if(!(u||I||(f||l||S))&&!a)return;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:i(this._schema,h),schema:h}),this._schema=h;const x=o.fromJSON(this._source.service.outSpatialReference),v=new m({fields:this._source.metadata.fieldsIndex,spatialReference:x});if((u||I||l)&&(await this._attributeStore.update(h.storage,v,this._source.metadata,x,s),this._strategy?.invalidateAttributeData(w(h))),!a&&!I&&!j)return;(y||p||j)&&await this._updateStrategy(h.mesh.strategy,x,n,w(h)),this._updateSortKey(v,"sortKey"in h.mesh.properties?h.mesh.properties.sortKey:null);const M=new g(v,this._proxy,r,this._registry);return(d||"dictionary"===h.mesh.factory.symbology.type)&&(this._factory=await c.create(M,h.mesh.factory)),this._invalidate(),this._version=s,this._connection.container.updateRenderState(this._version)}async applyLocalEdit(t){if(!this._strategy)return;const e=this._strategy.applyLocalEdit(t);for await(const r of e)try{await this._process(r)}catch(s){}}async updateChunks(){this._strategy?.beforeUpdateChunks(),await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],r=new Map;for await(const a of t){let t=r.get(a.id);null==t&&(t=new p({concurrency:16,process:t=>this._process(t)}),r.set(a.id,t));const i=t.push(a).catch((t=>s(t)));e.push(i)}try{await Promise.all(e)}catch(i){}has("esri-2d-update-debug")&&console.log("SendUpdates"),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,r){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new _(this._source,this._attributeStore,r);break;case"binning":this._strategy=await d.create(t,e,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await y.create(this._connection,t,e,this._source,this._attributeStore,r)}for(const i of s)this._strategy.onSubscribe(i)}async _updateSortKey(e,s){if(this._sortInfo=t(this._sortInfo?.computed),null!=s){const t=s.byRenderer?null:await e.createComputedField(s);this._sortInfo={...s,computed:t}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if(has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),r(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(w(this._schema))),i=e.tile.tileInfoView.getLODInfoAt(e.tile.key),{message:a,transferList:o}=s.serialize(i),n={objectIdMap:null,inner:t.createMessage(a,this._version,this._attributeStore.epoch)};if(this._schema?.mesh.properties.returnMeshObjectId){n.objectIdMap={};const e=t.reader?.getCursor();if(e)for(;e.next();)n.objectIdMap[e.getDisplayId()]=e.getObjectId()}if(r(e.signal),await this._connection.container.onMessage(n,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(w(this._schema));for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,r=t.reader?.getCursor(),i=r?.getSize()??0,a=s.tileInfoView.tileInfo.isWrappable,o=s.tileInfoView.tileInfo.spatialReference.isWGS84,c=new n(s.key,this._strategy.enablePixelBuffering,a,o,i);if(!r)return c;const h=s.createArcadeEvaluationOptions(w(this._schema));for(;r.next();){const t=this._getSortKeyValue(r,e);c.entityStart(r.getDisplayId(),t),this._factory.write(c,this._proxy,r,h,s.level),c.entityEnd()}return c}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,a=i?this._factory.getSortKey(t,e):s?.read(t,e);return null==a||isNaN(a)?0:a*("asc"===r?-1:1)}}function b(t,e){const s=[];return t?.timeExtent?.start===e.timeExtent?.start&&t?.timeExtent?.end===e.timeExtent?.end||s.push("timeProperties"),s}function w(t){const{timeZone:e}=t?.mesh.properties??{},{timeExtent:s}=t?.expressionProperties??{};return{timeZone:e,timeExtent:s}}export{f as default};
5
+ import has from"../../../../core/has.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{notDeepEqual as t}from"../../../../core/object.js";import{throwIfNotAbortError as s,throwIfAborted as r}from"../../../../core/promiseUtils.js";import{diff as i}from"../../../../core/accessorSupport/diffUtils.js";import{ignoreConnectionErrors as a}from"../../../../core/workers/utils.js";import o from"../../../../geometry/SpatialReference.js";import{MultiTileMeshData as n}from"../../engine/webgl/mesh/MultiTileMeshData.js";import{FeatureMeshFactory as c}from"../../engine/webgl/mesh/factories/FeatureMeshFactory.js";import{ResourceProxy as h}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{MeshWriterRegistry as u}from"../../engine/webgl/shaderGraph/techniques/mesh/MeshWriterRegistry.js";import{MatcherContext as p}from"../../engine/webgl/util/MatcherContext.js";import{ProcessorTileMessageQueue as g}from"./ProcessorTileMessageQueue.js";import{BinningStrategy as d}from"./processor/BinningStrategy.js";import{ClusterStrategy as y}from"./processor/ClusterStrategy.js";import{FeatureUpdateStrategy as _}from"./processor/FeatureUpdateStrategy.js";import{AttributeStore as l}from"./support/AttributeStore.js";import{ComputedAttributeStorage as m}from"./support/ComputedAttributeStorage.js";class f{constructor(e,t){this._connection=e,this._source=t,this._version=1,this._registry=new u,this._proxy=new h({fetch:(e,t)=>this._connection.layerView.fetch(e,t),fetchDictionary:(e,t)=>this._connection.layerView.fetchDictionary(e,t)}),this._attributeStore=new l({isLocal:!1,update:e=>a(this._connection.container.updateAttributeView(e))})}destroy(){this._proxy.destroy(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(e){return this._strategy?this._strategy.getDisplayFeatures(e):{features:[],aggregates:[]}}getDisplayIds(e){const t={};return this._strategy?(this._strategy.displayMap(e,(e=>e),((e,s,r)=>{t[r]=e})),t):t}getFeatureObjectIdsForAggregate(e){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(e):[]}onSubscribe(e){this._strategy?.onSubscribe(e)}onUnsubscribe(e){this._strategy?.onUnsubscribe(e)}async update(e,s,r,a,n){const h=e.processor,u=t(this._schema?.storage,h.storage),g=t(this._schema?.mesh.properties,h.mesh.properties),d=t(this._schema?.mesh.factory,h.mesh.factory),y=t(this._schema?.mesh.strategy,h.mesh.strategy),_=b(this._schema?.expressionProperties,h.expressionProperties),l=_.some((e=>this._attributeStore.hasArcadeDependency(e))),f=_.some((e=>this._factory?.hasArcadeDependency(e)??!1)),S=_.some((e=>this._strategy?.hasArcadeDependency(e)))||this._strategy?.isAggregate&&l,j=f||S,I=g||d||y;if(!(u||I||(f||l||S))&&!a)return;has("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:i(this._schema,h),schema:h}),this._schema=h;const x=o.fromJSON(this._source.service.outSpatialReference),v=new m({fields:this._source.metadata.fieldsIndex,spatialReference:x});if((u||I||l)&&(await this._attributeStore.update(h.storage,v,this._source.metadata,x,s),this._strategy?.invalidateAttributeData(w(h))),!a&&!I&&!j)return;(y||g||j)&&await this._updateStrategy(h.mesh.strategy,x,n,w(h)),this._updateSortKey(v,"sortKey"in h.mesh.properties?h.mesh.properties.sortKey:null);const M=new p(v,this._proxy,r,this._registry);return(d||"dictionary"===h.mesh.factory.symbology.type)&&(this._factory=await c.create(M,h.mesh.factory)),this._invalidate(),this._version=s,this._connection.container.updateRenderState(this._version)}async applyOverrideUpdate(e){if(!this._strategy)return;const t=this._strategy.applyOverrideUpdate(e);for await(const r of t)try{await this._process(r)}catch(s){}}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(e){this._strategy?.removeChunks(e),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:e}){if(!this._strategy)return void this._attributeStore.setHighlight(e.map((({objectId:e,highlightFlags:t})=>({objectId:e,highlightFlags:t,displayId:-1}))),e);const t=this._strategy.displayMap(e,(({objectId:e})=>e),((e,{highlightFlags:t},s)=>({objectId:s,displayId:e,highlightFlags:t})));this._attributeStore.setHighlight(t,e)}async _doUpdateChunks(){if(!this._strategy)return;const e=this._strategy.updateChunks(),t=[],r=new Map;for await(const a of e){let e=r.get(a.id);null==e&&(e=new g({concurrency:16,process:e=>this._process(e)}),r.set(a.id,e));const i=e.push(a).catch((e=>s(e)));t.push(i)}try{await Promise.all(t)}catch(i){}has("esri-2d-update-debug")&&console.log("SendUpdates"),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(e,t,s,r){switch(this._strategy?.destroy(),e.type){case"feature":this._strategy=new _(this._source,this._attributeStore,r);break;case"binning":this._strategy=await d.create(e,t,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await y.create(this._connection,e,t,this._source,this._attributeStore,r)}for(const i of s)this._strategy.onSubscribe(i)}async _updateSortKey(t,s){if(this._sortInfo=e(this._sortInfo?.computed),null!=s){const e=s.byRenderer?null:await t.createComputedField(s);this._sortInfo={...s,computed:e}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(e){const t=e.subscription;if(has("esri-2d-update-debug")){const s=t.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${e.end}] Processor._process`)}await this._fetchResources(e),r(t.signal);const s=await this._write(e,t.tile.createArcadeEvaluationOptions(w(this._schema))),i=t.tile.tileInfoView.getLODInfoAt(t.tile.key),{message:a,transferList:o}=s.serialize(i),n={objectIdMap:null,inner:e.createMessage(a,this._version,this._attributeStore.epoch)};if(this._schema?.mesh.properties.returnMeshObjectId){n.objectIdMap={};const t=e.reader?.getCursor();if(t)for(;t.next();)n.objectIdMap[t.getDisplayId()]=t.getObjectId()}if(r(t.signal),await this._connection.container.onMessage(n,{signal:t.signal,transferList:o}),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")){const s=t.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${e.end}] Processor._process.await`)}}async _fetchResources(e){await this._fetchMatcherResources(e),await this._fetchWriterResources(e)}async _fetchMatcherResources(e){if(e.reader)return this._factory.enqueueMatcherRequests(this._proxy,e.reader)}async _fetchWriterResources(e){if(!e.reader)return;const t=e.reader.getCursor(),s=e.subscription.tile.createArcadeEvaluationOptions(w(this._schema));for(;t.next();)this._factory.enqueueWriterRequests(this._proxy,t,s);await this._proxy.fetchEnqueuedResources()}async _write(e,t){const s=e.subscription.tile,r=e.reader?.getCursor(),i=r?.getSize()??0,a=s.tileInfoView.tileInfo.isWrappable,o=s.tileInfoView.tileInfo.spatialReference.isWGS84,c=new n(s.key,this._strategy.enablePixelBuffering,a,o,i);if(!r)return c;const h=s.createArcadeEvaluationOptions(w(this._schema));for(;r.next();){const e=this._getSortKeyValue(r,t);c.entityStart(r.getDisplayId(),e),this._factory.write(c,this._proxy,r,h,s.level),c.entityEnd()}return c}_getSortKeyValue(e,t){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,a=i?this._factory.getSortKey(e,t):s?.read(e,t);return null==a||isNaN(a)?0:a*("asc"===r?-1:1)}}function b(e,t){const s=[];return e?.timeExtent?.start===t.timeExtent?.start&&e?.timeExtent?.end===t.timeExtent?.end||s.push("timeProperties"),s}function w(e){const{timeZone:t}=e?.mesh.properties??{},{timeExtent:s}=e?.expressionProperties??{};return{timeZone:t,timeExtent:s}}export{f 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.32/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class e{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}get isAggregate(){return!1}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(t){}hasArcadeDependency(t){return!1}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}beforeUpdateChunks(){}afterUpdateChunks(){}}export{e as AProcessorStrategy,t as ASendState};
5
+ class t{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class e{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}get isAggregate(){return!1}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(t){}hasArcadeDependency(t){return!1}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}afterUpdateChunks(){}}export{e as AProcessorStrategy,t as ASendState};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../geometry.js";import{unquantizeOptimizedGeometry as e,convertToFeature as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as s}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as a}from"../../../../../layers/graphics/data/projectionSupport.js";import r from"../../../../../layers/support/FieldsIndex.js";import{ComputedAggregateField as i}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as n}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as l,FeatureTileUpdateMessage as d}from"../sources/FeatureSourceMessage.js";import{isLocalEditChunk as c}from"../sources/strategies/chunks/OverrideChunk.js";import{ComputedAttributeStorage as u}from"../support/ComputedAttributeStorage.js";import f from"../support/FeatureFilter.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as h}from"../support/FeatureSetReaderJSON.js";import g from"../../../tiling/TileKey.js";import m from"../../../../../geometry/SpatialReference.js";class y extends n{constructor(e,t){super(e),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.done=!1}invaldateForLocalEditDropped(){this.handledChunks.clear(),this.bins.clear()}destroy(){const e=this.subscription.tile.key.level;for(const t of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${t}.${e}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const s=t.clone();s.geometry&&e(s.geometry,s.geometry,!1,!1,this.subscription.tile.transform),yield s}}}class I extends o{static async create(e,t,s,r,o){const n=new u({spatialReference:t}),l=await Promise.all(e.fields.map((async e=>i.create(n,e)))),d=e.featureFilter?await f.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return"geohash"===e.index.type&&await a(t,m.WGS84),new I(e,d,o,l,t,s,r)}constructor(e,t,s,a,i,o,n){super(o,n,i,a),this._schema=e,this._featureFilter=t,this._arcadeContextInfo=s,this._metadata=p.createFeature({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fieldsIndex:new r(e.fields).toJSON(),globalIdField:null,spatialReference:o.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new y(e,this._attributeStore)}async*applyLocalEdit(e){for(const t of this._sendStates.values()){t.reset();const e=new l(t.subscription,h.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const a=new Map(e.map((e=>[t(e),e]))),r=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace()){const{objectId:t,displayId:i}=e,o=a.get(t);if(null!=o){const e=s(i,o,t);r.push(e),a.delete(t)}}return r}getDisplayFeatures(e){const s=new Set(e),a=new Set,r=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace())s.has(e.displayId)&&!a.has(e.objectId)&&(e.geometry&&r.push({...t(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),a.add(e.objectId));return{features:[],aggregates:r}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.containedObjectIds);return[]}beforeUpdateChunks(){const e=this._source.chunks();if(!e.length)return;let t=!1;for(const s of e)c(s)&&s.lastLocalEditDropped!==this._lastHandledLocalEdit&&(this._lastHandledLocalEdit=s.lastLocalEditDropped,t=!0);if(t)for(const s of this._sendStates.values())s.invaldateForLocalEditDropped()}async*updateChunks(){for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){const t=new Set;for(const s of this._sendStates.values())for(const a of s.featuresWorldSpace())t.has(a.objectId)||(e(a),t.add(a.objectId))}_createIndexOptions(e){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:e.scale};case"grid":{const t=this._schema.index.fixedBinLevel,s=null!=t?e.tileInfoView.getLODInfoAt(t).scale:e.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:s}}}}async*_update(e,t){const{handledChunks:a,subscription:r,bins:i,featureCache:o}=e,n=r.tile;if(e.done)return;for(const s of t.chunks()){if(a.has(s.chunkId))continue;a.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new g(t.tileId);if(e.level!==n.level||e.world!==n.key.world)continue}s.getAggregateIndex(this._createIndexOptions(e.tile)).putBounded(i,e.tile.extent,e.tile.resolution)}const l=[],c=r.tile.transform,u=r.tile.key.level;for(const d of i.values()){let e=o.get(d.id);if(e)e.attributes=d.getAttributes();else{const t=d.getGeometry(this.spatialReference,c);e=new s(t,d.getAttributes(),null),t||(e.centroid=d.getGeometricCentroid(this.spatialReference,c)),e.objectId=d.id,e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${u}`),o.set(d.id,e)}l.push(e)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const f=h.fromOptimizedFeatures(l,this._metadata,c),p=f.getCursor(),m=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo);for(;p.next();)this._attributeStore.setAttributeData(p.getDisplayId(),p,m);const y=new d(e.subscription,f,[],e.done,{});yield y}}export{y as BinningState,I as BinningStrategy};
5
+ import"../../../../../geometry.js";import{unquantizeOptimizedGeometry as e,convertToFeature as t}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as s}from"../../../../../layers/graphics/OptimizedFeature.js";import{checkProjectionSupport as r}from"../../../../../layers/graphics/data/projectionSupport.js";import a from"../../../../../layers/support/FieldsIndex.js";import{ComputedAggregateField as i}from"../aggregation/ComputedAggregateField.js";import{AAggregateStrategy as o}from"./AAggregateStrategy.js";import{ASendState as n}from"./AProcessorStrategy.js";import{FeatureTileAppendMessage as l,FeatureTileUpdateMessage as d}from"../sources/FeatureSourceMessage.js";import{ComputedAttributeStorage as c}from"../support/ComputedAttributeStorage.js";import u from"../support/FeatureFilter.js";import{FeatureMetadata as f}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as p}from"../support/FeatureSetReaderJSON.js";import h from"../../../tiling/TileKey.js";import g from"../../../../../geometry/SpatialReference.js";class m extends n{constructor(e,t){super(e),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.done=!1}destroy(){const e=this.subscription.tile.key.level;for(const t of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${t}.${e}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const s=t.clone();s.geometry&&e(s.geometry,s.geometry,!1,!1,this.subscription.tile.transform),yield s}}}class y extends o{static async create(e,t,s,a,o){const n=new c({spatialReference:t}),l=await Promise.all(e.fields.map((async e=>i.create(n,e)))),d=e.featureFilter?await u.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return"geohash"===e.index.type&&await r(t,g.WGS84),new y(e,d,o,l,t,s,a)}constructor(e,t,s,r,i,o,n){super(o,n,i,r),this._schema=e,this._featureFilter=t,this._arcadeContextInfo=s,this._metadata=f.createFeature({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fieldsIndex:new a(e.fields).toJSON(),globalIdField:null,spatialReference:o.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new m(e,this._attributeStore)}async*applyOverrideUpdate(e){for(const t of this._sendStates.values()){t.reset();const e=new l(t.subscription,p.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(e,t,s){const r=new Map(e.map((e=>[t(e),e]))),a=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace()){const{objectId:t,displayId:i}=e,o=r.get(t);if(null!=o){const e=s(i,o,t);a.push(e),r.delete(t)}}return a}getDisplayFeatures(e){const s=new Set(e),r=new Set,a=[];for(const i of this._sendStates.values())for(const e of i.featuresWorldSpace())s.has(e.displayId)&&!r.has(e.objectId)&&(e.geometry&&a.push({...t(e,this._metadata.geometryType,!1,!1),displayId:e.displayId}),r.add(e.objectId));return{features:[],aggregates:a}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const s of t.bins.values())if(s.id===e)return Array.from(s.containedObjectIds);return[]}async*updateChunks(){for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){const t=new Set;for(const s of this._sendStates.values())for(const r of s.featuresWorldSpace())t.has(r.objectId)||(e(r),t.add(r.objectId))}_createIndexOptions(e){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:e.scale};case"grid":{const t=this._schema.index.fixedBinLevel,s=null!=t?e.tileInfoView.getLODInfoAt(t).scale:e.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:s}}}}async*_update(e,t){const{handledChunks:r,subscription:a,bins:i,featureCache:o}=e,n=a.tile;if(e.done)return;for(const s of t.chunks()){if(r.has(s.chunkId))continue;r.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new h(t.tileId);if(e.level!==n.level||e.world!==n.key.world)continue}s.getAggregateIndex(this._createIndexOptions(e.tile)).putBounded(i,e.tile.extent,e.tile.resolution)}const l=[],c=a.tile.transform,u=a.tile.key.level;for(const d of i.values()){let e=o.get(d.id);if(e)e.attributes=d.getAttributes();else{const t=d.getGeometry(this.spatialReference,c);e=new s(t,d.getAttributes(),null,d.id),t||(e.centroid=d.getGeometricCentroid(this.spatialReference,c)),e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${u}`),o.set(d.id,e)}l.push(e)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const f=p.fromOptimizedFeatures(l,this._metadata,c),g=f.getCursor(),m=e.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo);for(;g.next();)this._attributeStore.setAttributeData(g.getDisplayId(),g,m);const y=new d(e.subscription,f,[],e.done,{});yield y}}export{m as BinningState,y as BinningStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/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 c}from"./support/WithDisplayId.js";import{FeatureTileAppendMessage as u}from"../sources/FeatureSourceMessage.js";import{isLocalEditChunk as h}from"../sources/strategies/chunks/OverrideChunk.js";import{ComputedAttributeStorage as p}from"../support/ComputedAttributeStorage.js";import f from"../support/FeatureFilter.js";import{FeatureMetadata as g}from"../support/FeatureMetadata.js";import{FeatureSetReaderJSON as _}from"../support/FeatureSetReaderJSON.js";import m from"../../../tiling/TileKey.js";const y=128;class S extends d{constructor(e){super(e),this.didSend=!1,this.done=!1}}class I{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);i.objectId=e.inner.id,i.displayId=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 m(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,c=d.wrap?d.worldSize[0]:null,u=1===o.inner.count?o.inner.firstObjectId:o.inner.id,h=o.displayId;if(null!=c)if(1===c){const n=new s([],[e,i]),l=new t(n,o.inner.getAttributes(),null);l.geometry.coords[0]-=r,l.objectId=u,l.displayId=h,a.push(l);const d=new s([],[e,i]),c=new t(d,o.inner.getAttributes(),null);c.geometry.coords[0]+=r,c.objectId=u,c.displayId=h,a.push(c)}else e>r+r/2?e-=c*r:e<-r/2&&(e+=c*r);if(e<r+y&&e>=-y&&i<r+y&&i>=-y){const r=new s([],[e,i]),n=new t(r,o.inner.getAttributes(),null);n.objectId=u,n.displayId=h,a.push(n)}}return _.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 c(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 c=Math.abs(r.centroidXWorld-o),u=Math.abs(r.centroidYWorld-d);c<i&&u<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){const l=new p({spatialReference:s}),o={type:"grid",fields:await Promise.all(t.fields.map((async e=>n.create(l,e)))),spatialReference:s,featureFilter:t.featureFilter?await f.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};return new x(e,t.clusterRadius,o,t.fields,i,r)}constructor(e,t,s,r,n,a){super(n,a,s.spatialReference,s.fields),this._connection=e,this._clusterRadius=t,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=g.createFeature({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fieldsIndex:new i([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient: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 S(e)}async*applyLocalEdit(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}}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;for(const n of e)h(n)&&n.lastLocalEditDropped!==this._lastHandledLocalEdit&&(this.invalidate(),this._lastHandledLocalEdit=n.lastLocalEditDropped);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 I(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);const a=new u(e.subscription,i,!0,e.done,{});yield a}}export{S 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/FeatureFilter.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<-r/2&&(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){const l=new h({spatialReference:s}),o={type:"grid",fields:await Promise.all(t.fields.map((async e=>n.create(l,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};return new x(e,t.clusterRadius,o,t.fields,i,r)}constructor(e,t,s,r,n,a){super(n,a,s.spatialReference,s.fields),this._connection=e,this._clusterRadius=t,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=f.createFeature({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fieldsIndex:new i([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient: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}}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);const a=new c(e.subscription,i,!0,e.done,{});yield a}}export{y as ClusterState,x as ClusterStrategy};