@arcgis/core 4.34.0-next.95 → 4.34.0-next.96

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 (113) hide show
  1. package/analysis/VolumeMeasurement/VolumeMeasurementCutFillOptions.js +1 -1
  2. package/analysis/VolumeMeasurement/volumeMeasurementConfiguration.js +5 -0
  3. package/analysis/VolumeMeasurementAnalysis.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/{3a2d4b78a48ebb181105.js → 02bc183e30e3392bb76d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{b8339c1d60847a9eed3e.js → 1b85967d1178956ee36b.js} +1 -1
  7. package/assets/esri/core/workers/chunks/24b97ba933324aea6a07.js +1 -0
  8. package/assets/esri/core/workers/chunks/{2e4dccee7ea387263f15.js → 2f9e79a67eae746d55d3.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{9834bc11586a2d8d6f35.js → 3495162f4608f5205d87.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{b13ccda702b714fe6161.js → 3ffdf73aaecc42448f8a.js} +1 -1
  11. package/assets/esri/core/workers/chunks/4239572007ecfac49dc1.js +1 -0
  12. package/assets/esri/core/workers/chunks/{2bf29faeb23120dc1916.js → 7fa324900c147ba51019.js} +1 -1
  13. package/assets/esri/core/workers/chunks/80c492f8fdab7698596a.js +1 -0
  14. package/assets/esri/core/workers/chunks/{9b0ea5e50aeeea615592.js → 9027f22a04ac2076ff0e.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{08ee3a97d2b8adb44ea9.js → 9e4f37367d61a2e13053.js} +1 -1
  16. package/assets/esri/core/workers/chunks/a16526adc0dbffdc1ffc.js +1 -0
  17. package/assets/esri/core/workers/chunks/a19063456ce21b471b69.js +1 -0
  18. package/assets/esri/core/workers/chunks/{135e270b4f03c4270870.js → a4db5c9a90107e097df8.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{04c30eec4387078cd38f.js → b54202dcab8df080e991.js} +1 -1
  20. package/assets/esri/core/workers/chunks/ba212ba895ccf573eedf.js +1 -0
  21. package/assets/esri/core/workers/chunks/c0849628a7fbc6869340.js +1 -0
  22. package/assets/esri/core/workers/chunks/e5bcc44f3dc6fc90835a.js +1 -0
  23. package/assets/esri/core/workers/chunks/f09242e97196ad177c10.js +1 -0
  24. package/assets/esri/core/workers/chunks/{24c14e4a1d2a2267097e.js → fe3f95fda29e4844b153.js} +1 -1
  25. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  26. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  27. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  28. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  29. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  30. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  31. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  32. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  33. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  34. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  35. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  36. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  37. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  38. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  39. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  40. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  41. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  42. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  43. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  44. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  45. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  46. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  47. package/assets/esri/widgets/Editor/t9n/Editor_no.json +1 -1
  48. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  50. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  51. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  52. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  53. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  54. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  62. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  63. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  64. package/config.js +1 -1
  65. package/core/dedupeResult.js +5 -0
  66. package/interfaces.d.ts +3 -59
  67. package/kernel.js +1 -1
  68. package/layers/FeatureLayer.js +1 -1
  69. package/layers/KnowledgeGraphLayer.js +1 -1
  70. package/layers/LinkChartLayer.js +1 -1
  71. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  72. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  73. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  74. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  75. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  76. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  77. package/layers/knowledgeGraph/layerUtils.js +1 -1
  78. package/layers/mixins/ArcGISImageService.js +1 -1
  79. package/layers/support/Sublayer.js +1 -1
  80. package/layers/support/capabilities.js +1 -1
  81. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  82. package/package.json +1 -1
  83. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  84. package/support/basemapDefinitions.js +1 -1
  85. package/support/revision.js +1 -1
  86. package/views/2d/GoToManager.js +1 -1
  87. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  88. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  89. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  90. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  91. package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +5 -0
  92. package/views/3d/layers/graphics/Labeler.js +1 -1
  93. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  94. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  95. package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
  96. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
  97. package/views/analysis/ElevationProfile/ElevationProfileLineInputComputation.js +1 -1
  98. package/views/analysis/ElevationProfile/elevationProfileLayerUtils.js +5 -0
  99. package/widgets/Daylight/DaylightViewModel.js +1 -1
  100. package/widgets/Daylight.js +1 -1
  101. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  102. package/widgets/Legend/LegendViewModel.js +1 -1
  103. package/widgets/Legend.js +1 -1
  104. package/assets/esri/core/workers/chunks/0a7efed82d8e47290147.js +0 -1
  105. package/assets/esri/core/workers/chunks/0d94a08769727875bf0e.js +0 -1
  106. package/assets/esri/core/workers/chunks/3c78208a97c4cbd8d6d1.js +0 -1
  107. package/assets/esri/core/workers/chunks/6e5b3bbee054d072b594.js +0 -1
  108. package/assets/esri/core/workers/chunks/8ad8fe758c615fcf2185.js +0 -1
  109. package/assets/esri/core/workers/chunks/bae0dfe9a2f5aabae42c.js +0 -1
  110. package/assets/esri/core/workers/chunks/d28ea91f7458daa67fae.js +0 -1
  111. package/assets/esri/core/workers/chunks/d4f16c2b9297a479731e.js +0 -1
  112. package/assets/esri/core/workers/chunks/dff8e15958423e0212e5.js +0 -1
  113. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementConfiguration.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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{serializationUtilsModuleWrapper as t}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import a from"../core/Collection.js";import i from"../core/Error.js";import n from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAborted as r,isAbortError as l,createAbortError as h}from"../core/promiseUtils.js";import{watch as d,sync as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{idToName as y}from"../core/accessorSupport/PropertyOrigin.js";import g from"../geometry/Extent.js";import m from"../geometry/Point.js";import f from"../geometry/Polyline.js";import{polygonCentroidPoint as w}from"../geometry/support/centroid.js";import L from"./Layer.js";import{convertFromGeometry as b}from"./graphics/featureConversionUtils.js";import{systemOidFieldName as M,systemOriginIdFieldName as k,systemDestinationIdFieldName as C,systemLayoutGeometryFieldName as T,systemAggregationCountFieldName as N}from"./knowledgeGraph/constants.js";import{IdealEdgeLengthTypeOptions as D}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as x}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import v from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{initializeLayersFromClientData as I}from"./knowledgeGraph/layerUtils.js";import E from"./knowledgeGraph/SessionMemoryStorage.js";import{convertLayoutTypeToWebSupportedFormat as S,getRelationshipEndNodeIds as _}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as A}from"./mixins/BlendLayer.js";import{OperationalLayer as R}from"./mixins/OperationalLayer.js";import{ScaleRangeLayer as j}from"./mixins/ScaleRangeLayer.js";import{url as G}from"./support/commonProperties.js";import{LCChronologicalLayout as z,LCSimpleLayout as O,LCSmartTreeLayout as P,LCRadialTreeLayout as F,LCHierarchicalLayout as B,LCCommunityLayout as U,LCForceDirectedLayout as Q,load as W}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as $}from"../rest/knowledgeGraphService.js";let H=class extends(R(A(j(s(L))))){constructor(e){if(super(e),this.url=null,this.dataPreloadedInLocalCache=!1,this.initializationLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"organic-standard"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(a.ofType(v)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(a.ofType(v)),this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.initializationInclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.initializationInclusionModeDefinition)throw new i("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles(d(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),p))}normalizeCtorArgs(e){if(!e)return{};const{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}=e;return{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let a=[],o=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new i("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach((i,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(s);"relationship"===r.type?t.has(s)||(t.add(s),o.push(r)):"entity"===r.type?t.has(s)||(t.add(s),a.push(r)):(n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(s))}):(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new x({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=a,this.memberRelationshipTypes=o,this.dataManager=s}load(e){const a=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),this._layersLoadedFromAuthoritativeItem()||await I(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(e=>{e.useAllData=!1}),await this._initializeDiagram(),this.layers.forEach(a=>{t.push(a.refreshCachedQueryEngine()),e.push(new Promise(e=>{a.on("layerview-create",()=>{e(null)})}))}),this.tables.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t)};return this.addResolvingPromise(new Promise(i=>{$(this.url).then(async n=>{n.dataModel.entityTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)}),n.dataModel.relationshipTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)});const s=this.linkChart?.linkChartProperties;if(6===s?.originIdOf("entitiesUrl")&&(this.membershipModified=!1,this._originalInclusionList=await t.fetchAndConvertSerializedLinkChart({entitiesUrl:s?.entitiesUrl,relationshipsUrl:s?.relationshipsUrl}),this._alignLayersDataModelAndInclusionDefinition(n.dataModel),this.initializationLinkChartConfig={layoutSettings:s?.layoutSettings??void 0,layoutMode:S(s.layoutType)}),this._initializeLayerProperties({knowledgeGraph:n,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataPreloadedInLocalCache){const e=E.getInstance();for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const i of a.members?.values()??[]){const a=e.readFromStoreById(`${t}__${i.id}`);if(a){o(this.dataManager.sublayerCaches,t,()=>new Map).set(i.id,a)}}await a()}else{const t="geographic-organic-standard"===this.initializationLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then(async()=>{r(e),await a()}))}i(null)})})),Promise.resolve(this)}set initializationInclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("initializationInclusionModeDefinition",e):n.getLogger(this).error("#initializationInclusionModeDefinition","initializationInclusionModeDefinition cannot be changed after the layer is loaded.")}get linkChart(){return this.parent}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await _(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id));i.length>0&&(this.membershipModified=!0),await this._handleNewRecords(i,t)}async createSublayerForNamedType(e){await this.load();const t=this._graphTypeLookup.get(e);if(!t)throw new i("knowledge-graph:missing-type","The specified type does not exist in the knowledge graph.");if(this.dataManager.sublayerCaches.has(e))throw new i("knowledge-graph:duplicate-type","The specified type already exists as a sublayer.");this.dataManager.sublayerCaches.set(e,new Map),o(this.sublayerIdsCache,e,()=>new Set);const a=this._createSublayer(t);return"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.set(e,{useAllData:!1,members:new Map}),a.geometryType?this.layers.push(a):this.tables.push(a),await I(this,[e]),this._refreshNamedTypes(),a}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1,overrideMembershipCheck:i=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const r of e)(i||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.members?.has(r.id))&&n.push(r);if(t){const e=new Set,t=[];for(const a of n)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});n=n.concat(t)}this.dataManager.removeFromLayer(n);for(const r of n)this.sublayerIdsCache.get(r.typeName)?.delete(r.id),this.dataManager.relationshipTypeNames.has(r.typeName)?this.relationshipLinkChartDiagramLookup.delete(r.id):this.entityLinkChartDiagramLookup.delete(r.id);const o=a?void 0:this.getCurrentNodeLocations();await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:o}),n.length>0&&(this.membershipModified=!0);const s=[];return this.layers.forEach(e=>{s.push(e.refreshCachedQueryEngine())}),await Promise.all(s),this._refreshNamedTypes(),n}async expand(e,t){let a=[];try{const i=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);a=i.filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)),await this._handleNewRecords(a,t),i.length>0&&(this.membershipModified=!0),r(t?.signal)}catch(i){throw l(i)&&a.length>0&&await this.removeRecords(a,{overrideMembershipCheck:!0}),i}return{records:a}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.layers.length||0===this.originIdOf("tables")?0===this.originIdOf("layers")?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers):this.layers=new a,this.tables.length||0===this.originIdOf("layers")?0===this.originIdOf("tables")?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables):this.tables=new a,this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{const a=o(this.sublayerIdsCache,t,()=>new Set);e.members?.forEach(({id:e,linkChartLocation:i})=>{if(a.add(e),i){const a="coords"in i&&"lengths"in i?i:b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,a):this.entityLinkChartDiagramLookup.set(e,a)}})})}async calculateLinkChartLayout(e="organic-standard",t){const a=[],s=[],l=[];this.dataManager.sublayerCaches.forEach((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach(e=>{a.push({typeName:t,feature:e})}):this.dataManager.relationshipTypeNames.has(t)&&e.forEach(e=>{s.push({typeName:t,feature:e})})}),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const d=new Map,p=new Map,c=new Map,u=new Map,y=new Uint8Array(a.length),L=new Float64Array(a.length),D=new Float64Array(a.length),x=new Float64Array(a.length),v=new Float64Array(a.length),I=new Uint32Array(s.length),E=new Uint32Array(s.length),S=new Float64Array(s.length),_=new Float64Array(s.length),A=[],R="organic-standard";let j=!1;const G=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let $,H="organic-standard",K=0,J=0;const V=z.apply;switch(H="geographic-organic-standard"===e?R:e,H){case"organic-standard":$=Q.apply;break;case"organic-community":$=U.apply;break;case"hierarchical-bottom-to-top":$=B.apply;break;case"radial-root-centric":$=F.apply;break;case"tree-left-to-right":$=P.apply;break;default:$=O.apply}let q=!1;a.forEach(({typeName:a,feature:i})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedNodeLocations?.has(i.attributes[M])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)?y[K]=2:y[K]=0;const n=t.lockedNodeLocations.get(i.attributes[M]);L[K]=n.x,D[K]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)){y[K]=2;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":L[K]=t?.x,D[K]=t?.y;break;case"esriGeometryPolygon":{const a=w(t);e=a?m.fromJSON(a):null,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break}case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break;default:y[K]=1}(null==L[K]||null==D[K]||Number.isNaN(L[K])||Number.isNaN(D[K]))&&(y[K]=1,L[K]=0,D[K]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!q&&t?.lockedNodeLocations?.has(i.attributes[M])&&(q=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;x[K]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;v[K]=r?new Date(r).getTime():NaN,L[K]=0,D[K]=0,y[K]=1}else y[K]=1,L[K]=0,D[K]=0;u.set(i.attributes[M],K),A[K]={feature:i,typeName:a},K++}),q&&n.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let X=!1;const Y=new Map;s.forEach(a=>{const i=a.feature.attributes[k],n=a.feature.attributes[C],o=u.get(i),s=u.get(n),r=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?r?.startField:null,d=h?a.feature.attributes[h]:null,p=r?.endField,c=p?a.feature.attributes[p]:null;if(void 0!==o&&void 0!==s){let t=i+"-"+n;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+c);const r=Y.get(t),h=r?.has(a.typeName);h||(I[J]=o,E[J]=s,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(S[J]=d?new Date(d).getTime():NaN,_[J]=c?new Date(c).getTime():NaN),void 0===r?Y.set(t,new Map([[a.typeName,J]])):r.set(a.typeName,J),J++),l.push(a)}else X=!0,this.relationshipLinkChartDiagramLookup.set(i,null)}),X&&n.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const Z=this._validateOrganicLayoutSettings(e,t?.layoutSettings?.organicLayoutSettings),ee=this._convertValidatedOrganicSettingsToCalculationSettings(Z);await W();let te=1,ae=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let a;({status:te,links:ae,graphics:a}=V(()=>t?.signal?.aborted??!1,y,L,D,x,v,I.subarray(0,J),E.subarray(0,J),S.subarray(0,J),_.subarray(0,J),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings)),0===te&&(this.chronologicalAuxiliaryGraphics=a)}else({status:te,links:ae}=$(()=>t?.signal?.aborted??!1,y,L,D,I.subarray(0,J),E.subarray(0,J),ee.computationBudgetTime,ee.idealEdgeLengthMultiplier,ee.repulsionRadiusMultiplier));if(r(t?.signal),1===te)throw new i("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(2===te)throw h();for(let i=0;i<A.length;i++){if(D[i]>84.9999?D[i]=84.9999:D[i]<-84.9999&&(D[i]=-84.9999),L[i]>179.9999?L[i]=179.9999:L[i]<-179.9999&&(L[i]=-179.9999),A[i].feature.attributes[T]=new m(L[i],D[i]),d.has(A[i].typeName)){const e=d.get(A[i].typeName);e?.set(A[i].feature.attributes[M],A[i].feature)}else{const e=new Map;e.set(A[i].feature.attributes[M],A[i].feature),d.set(A[i].typeName,e)}c.set(A[i].feature.attributes[M],A[i].feature);const e=b(A[i].feature.attributes[T]);this.entityLinkChartDiagramLookup.set(A[i].feature.attributes[M],A[i].feature.attributes[T]?e:null);const t=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,A[i].typeName,()=>({useAllData:!1,members:new Map}));o(t.members,A[i].feature.attributes[M],()=>({id:A[i].feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=A[i].feature.attributes[T];const{x:a,y:n}=A[i].feature.attributes[T];if(j)G.xmin=Math.min(G.xmin,a),G.xmax=Math.max(G.xmax,a),G.ymin=Math.min(G.ymin,n),G.ymax=Math.max(G.ymax,n);else{const e=1e-7;G.xmin=a-e,G.xmax=a+e,G.ymin=n-e,G.ymax=n+e,j=!0}}if(this.linkChartExtent.xmin=G.xmin,this.linkChartExtent.xmax=G.xmax,this.linkChartExtent.ymin=G.ymin,this.linkChartExtent.ymax=G.ymax,!ae)throw new i("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ie=new Map,ne=new Map,oe=new Map,se=new Set;for(let i=0;i<l.length;i++){const a=[],s=l[i],r=s.feature.attributes[k],h=s.feature.attributes[C];let d=r+"-"+h;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(s.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?s.feature.attributes[a]:null,n=e?.endField;d+="-"+i+"-"+(n?s.feature.attributes[n]:null)}const y=Y.get(d).get(s.typeName),g=0===y?0:ae?.vertexEndIndex[y-1];if(!se.has(y)){if(se.add(y),2===ae.types[y]){const e=[ae.vertices[2*g],ae.vertices[2*g+1]],t=[ae.vertices[2*(g+1)],ae.vertices[2*(g+1)+1]],i=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[i[0]-e[0],i[1]-e[1]],o=[i[0]+n[1],i[1]-n[0]],s=[i[0]-n[1],i[1]+n[0]];a.push(e),a.push(o),a.push(t),a.push(s),a.push(e)}else{if(0!==ae.types[y]){n.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<ae.vertexEndIndex[y];e++)a.push([ae.vertices[2*e],ae.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=A[u.get(r)]?.feature.attributes[T],t=A[u.get(h)]?.feature.attributes[T];a[0][0]===e.x&&a[0][1]===e.y||(a[0]=[e.x,e.y]),a[a.length-1][0]===t.x&&a[a.length-1][1]===t.y||(a[a.length-1]=[t.x,t.y])}for(let e=1;e<a.length-1;e++)a[e][1]>85.5?a[e][1]=85.5:a[e][1]<-85.5&&(a[e][1]=-85.5),a[e][0]>179.9999?a[e][0]=179.9999:a[e][0]<-179.9999&&(a[e][0]=-179.9999);ie.has(d)?ie.get(d).push(a):ie.set(d,[a])}const m=ie.get(d);ne.has(d)||(ne.set(d,new Map),oe.set(d,new Map));const w=ne.get(d),L=oe.get(d);w.has(s.typeName)||(w.set(s.typeName,m.shift()),L.set(s.typeName,0));const N=w.get(s.typeName);L.set(s.typeName,L.get(s.typeName)+1);const D=new f({paths:[N]});if(s.feature.attributes[T]=D,p.has(s.typeName)){const e=p.get(s.typeName);e?.set(s.feature.attributes[M],s.feature)}else{const e=new Map;e.set(s.feature.attributes[M],s.feature),p.set(s.typeName,e)}c.set(s.feature.attributes[M],s.feature);const x=b(s.feature.attributes[T]);this.relationshipLinkChartDiagramLookup.set(s.feature.attributes[M],s.feature.attributes[T]?x:null);const v=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,s.typeName,()=>({useAllData:!1,members:new Map}));o(v.members,s.feature.attributes[M],()=>({id:s.feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=x}for(const i of l)i.feature.attributes[N]=oe.get(i.feature.attributes[k]+"-"+i.feature.attributes[C])?.get(i.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:t?.layoutSettings?.clone()},{nodes:d,links:p,idMap:c}}async applyNewLinkChartLayout(e="organic-standard",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach(e=>{a.push(e.refreshCachedQueryEngine())}),this.membershipModified=!0,await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||a?.members?.forEach(t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new m({x:i.x,y:i.y})))});return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}a=await this.dataManager.getRelationshipsBetweenNodes(e,i,t),await this._handleNewRecords(a,t),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}a=await this.dataManager.getRelationshipsFromNodes(e,n,i,t),await this._handleNewRecords(a,t),a.length>0&&(this.membershipModified=!0),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="organic-standard",t){const a=new Map;this.layers.forEach(e=>{a.set(e.objectType.name,e.timeInfo)}),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t}),this.linkChart?.handleChronologicalOverlay()}async _handleNewRecords(e,t){const a=new Set,i=[],n=this.layers.concat(this.tables);for(const r of e){if(!this._graphTypeLookup.has(r.typeName))continue;!1===n.some(e=>e.objectType.name===r.typeName)&&(this.dataManager.sublayerCaches.set(r.typeName,new Map),a.add(r.typeName));o(this.sublayerIdsCache,r.typeName,()=>new Set).add(r.id),i.push(r)}this.dataManager.addToLayer(i);for(const o of a){const e=this._graphTypeLookup.get(o);if(e){const t=this._createSublayer(e);"entity"===e.type?this.dataManager.entityTypeNames.add(o):this.dataManager.relationshipTypeNames.add(o),t.geometryType?this.layers.push(t):this.tables.push(t)}}await I(this,Array.from(a),t),await this.dataManager.refreshCacheContent(e.map(e=>e.id),void 0,void 0,void 0,t);const s={layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:new Map};for(const[o,r]of this.entityLinkChartDiagramLookup.entries())r&&s.lockedNodeLocations.set(o,new m(r.coords[0],r.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,s)}_createSublayers(e,t,a){e.forEach(e=>{const i=this._createSublayer(e);a(i)&&t.push(i),this._updateSublayerCaches(e)})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;const a=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);a&&(t.objectType=a,t.read({title:a.name},{origin:"service"}),this._updateSublayerCaches(a))})}_updateSublayerCaches({name:e}){if(!e)return;const t=this.dataManager.sublayerCaches;t.has(e)||t.set(e,new Map)}_layersLoadedFromAuthoritativeItem(){const e=this.originIdOf("layers");return e>=3&&e<7}async _initializeDiagram(){this.initializationLinkChartConfig?this.initializationLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{e?.members?.forEach(e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)})}),this.memberRelationshipTypes.forEach(e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach(e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[k]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[C]);if(t&&a){const i=b(new f({paths:[[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[M],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[M],null)})})):await this._calculateLayoutWithSublayerTimeInfo(this.initializationLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.initializationLinkChartConfig}):await this._calculateLayoutWithSublayerTimeInfo("organic-standard",{lockedNodeLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateOrganicLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),i=e=>a(e)&&e>=1,o=e=>a(e)&&e>=1,s=e=>Object.values(D).includes(e),r=e=>a(e)&&e>=0,l={};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return l;const{computationBudgetTime:h,autoRepulsionRadius:d,repulsionRadiusMultiplier:p,absoluteIdealEdgeLength:c,multiplicativeIdealEdgeLength:u,idealEdgeLengthType:y}=t;return o(h)?l.computationBudgetTime=h:h&&n.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),l.autoRepulsionRadius=d,!d&&i(p)?l.repulsionRadiusMultiplier=p:d||(l.autoRepulsionRadius=!0,n.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting")),"geographic-organic-standard"===e&&(s(y)?l.idealEdgeLengthType=y:void 0!==y&&n.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===y&&r(c)?l.absoluteIdealEdgeLength=c:"absolute-value"===y&&void 0!==c?n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===y&&r(u)?l.multiplicativeIdealEdgeLength=u:"multiplier"===y&&void 0!==u&&n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),l}_convertValidatedOrganicSettingsToCalculationSettings(e){let t=e.idealEdgeLengthType===D.ABSOLUTE?e.absoluteIdealEdgeLength:e.multiplicativeIdealEdgeLength;return e.idealEdgeLengthType===D.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier&&!e.autoRepulsionRadius?e.repulsionRadiusMultiplier:void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new v({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner")),e&&(e.forEach(e=>{e.parent=this}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this}),e.on("after-remove",({item:e})=>{e.parent=null})],"sublayers-owner"))}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map(e=>e.name).concat((e.relationshipTypes??[]).map(e=>e.name))),i=new Set((e.entityTypes??[]).map(e=>e.name)),o=new Set((e.relationshipTypes??[]).map(e=>e.name));if(this.layers){for(const a of this.layers)!a.graphType&&t.has(a.graphTypeName)&&(a.graphType=i.has(a.graphTypeName)?"entity":"relationship");const e=this.layers.filter(e=>t.has(e.graphTypeName)&&("entity"===e.graphType?i.has(e.graphTypeName):o.has(e.graphTypeName)));this.setAtOrigin("layers",e,y(this.originIdOf("layers")))}else this.layers=new a;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map(e=>e.graphTypeName)??[],a=this.layers.map(e=>e.graphTypeName).concat(t);for(const n of a)e.has(n)||this._originalInclusionList.namedTypeDefinitions.set(n,{useAllData:!1,members:new Map});const i=[];for(const o of this._originalInclusionList.namedTypeDefinitions.keys())a.includes(o)||(n.getLogger(this).warn(`A named type, ${o}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),i.push(o));for(const n of i)this._originalInclusionList.namedTypeDefinitions.delete(n)}}};e([c(G)],H.prototype,"url",void 0),e([c()],H.prototype,"dataPreloadedInLocalCache",void 0),e([c()],H.prototype,"initializationLinkChartConfig",void 0),e([c()],H.prototype,"membershipModified",void 0),e([c()],H.prototype,"dataManager",void 0),e([c()],H.prototype,"initializationInclusionModeDefinition",null),e([c()],H.prototype,"knowledgeGraph",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],H.prototype,"layers",void 0),e([c({readOnly:!0})],H.prototype,"linkChart",null),e([c()],H.prototype,"entityLinkChartDiagramLookup",void 0),e([c()],H.prototype,"relationshipLinkChartDiagramLookup",void 0),e([c()],H.prototype,"linkChartExtent",void 0),e([c()],H.prototype,"memberEntityTypes",void 0),e([c()],H.prototype,"memberRelationshipTypes",void 0),e([c({type:["LinkChartLayer"]})],H.prototype,"operationalLayerType",void 0),e([c()],H.prototype,"sublayerIdsCache",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],H.prototype,"tables",void 0),e([c({json:{read:!1}})],H.prototype,"type",void 0),e([c({json:{read:!1}})],H.prototype,"chronologicalAuxiliaryGraphics",void 0),H=e([u("esri.layers.LinkChartLayer")],H);const K=H;export{K as default};
5
+ import{__decorate as e}from"tslib";import{serializationUtilsModuleWrapper as t}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import a from"../core/Collection.js";import i from"../core/Error.js";import n from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAborted as r,isAbortError as l,createAbortError as h}from"../core/promiseUtils.js";import{watch as d,sync as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{idToName as y}from"../core/accessorSupport/PropertyOrigin.js";import g from"../geometry/Extent.js";import m from"../geometry/Point.js";import f from"../geometry/Polyline.js";import{polygonCentroidPoint as w}from"../geometry/support/centroid.js";import L from"./Layer.js";import{convertFromGeometry as b}from"./graphics/featureConversionUtils.js";import{systemOidFieldName as M,systemOriginIdFieldName as k,systemDestinationIdFieldName as C,systemLayoutGeometryFieldName as T,systemAggregationCountFieldName as N}from"./knowledgeGraph/constants.js";import{IdealEdgeLengthTypeOptions as D}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as x}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import v from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{createCapabilitiesFromKnowledgeGraph as I,initializeLayersFromClientData as E}from"./knowledgeGraph/layerUtils.js";import S from"./knowledgeGraph/SessionMemoryStorage.js";import{convertLayoutTypeToWebSupportedFormat as _,getRelationshipEndNodeIds as A}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as R}from"./mixins/BlendLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{ScaleRangeLayer as G}from"./mixins/ScaleRangeLayer.js";import{url as z}from"./support/commonProperties.js";import{LCChronologicalLayout as O,LCSimpleLayout as P,LCSmartTreeLayout as F,LCRadialTreeLayout as B,LCHierarchicalLayout as U,LCCommunityLayout as Q,LCForceDirectedLayout as W,load as $}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as H}from"../rest/knowledgeGraphService.js";let K=class extends(j(R(G(s(L))))){constructor(e){if(super(e),this.url=null,this.dataPreloadedInLocalCache=!1,this.initializationLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"organic-standard"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(a.ofType(v)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(a.ofType(v)),this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.initializationInclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.initializationInclusionModeDefinition)throw new i("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles(d(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),p))}normalizeCtorArgs(e){if(!e)return{};const{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}=e;return{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let a=[],o=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new i("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach((i,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(s);"relationship"===r.type?t.has(s)||(t.add(s),o.push(r)):"entity"===r.type?t.has(s)||(t.add(s),a.push(r)):(n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(s))}):(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new x({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=a,this.memberRelationshipTypes=o,this.dataManager=s}load(e){const a=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),this._layersLoadedFromAuthoritativeItem()||await E(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(e=>{e.useAllData=!1}),await this._initializeDiagram(),this.layers.forEach(a=>{t.push(a.refreshCachedQueryEngine()),e.push(new Promise(e=>{a.on("layerview-create",()=>{e(null)})}))}),this.tables.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t)};return this.addResolvingPromise(new Promise(i=>{H(this.url).then(async n=>{n.dataModel.entityTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)}),n.dataModel.relationshipTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)});const s=this.linkChart?.linkChartProperties;if(6===s?.originIdOf("entitiesUrl")&&(this.membershipModified=!1,this._originalInclusionList=await t.fetchAndConvertSerializedLinkChart({entitiesUrl:s?.entitiesUrl,relationshipsUrl:s?.relationshipsUrl}),this._alignLayersDataModelAndInclusionDefinition(n.dataModel),this.initializationLinkChartConfig={layoutSettings:s?.layoutSettings??void 0,layoutMode:_(s.layoutType)}),this._initializeLayerProperties({knowledgeGraph:n,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataPreloadedInLocalCache){const e=S.getInstance();for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const i of a.members?.values()??[]){const a=e.readFromStoreById(`${t}__${i.id}`);if(a){o(this.dataManager.sublayerCaches,t,()=>new Map).set(i.id,a)}}await a()}else{const t="geographic-organic-standard"===this.initializationLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then(async()=>{r(e),await a()}))}i(null)})})),Promise.resolve(this)}set initializationInclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("initializationInclusionModeDefinition",e):n.getLogger(this).error("#initializationInclusionModeDefinition","initializationInclusionModeDefinition cannot be changed after the layer is loaded.")}get linkChart(){return this.parent}get sublayerCapabilities(){return I(this.knowledgeGraph)}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await A(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id));i.length>0&&(this.membershipModified=!0),await this._handleNewRecords(i,t)}async createSublayerForNamedType(e){await this.load();const t=this._graphTypeLookup.get(e);if(!t)throw new i("knowledge-graph:missing-type","The specified type does not exist in the knowledge graph.");if(this.dataManager.sublayerCaches.has(e))throw new i("knowledge-graph:duplicate-type","The specified type already exists as a sublayer.");this.dataManager.sublayerCaches.set(e,new Map),o(this.sublayerIdsCache,e,()=>new Set);const a=this._createSublayer(t);return"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.set(e,{useAllData:!1,members:new Map}),a.geometryType?this.layers.push(a):this.tables.push(a),await E(this,[e]),this._refreshNamedTypes(),a}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1,overrideMembershipCheck:i=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const r of e)(i||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.members?.has(r.id))&&n.push(r);if(t){const e=new Set,t=[];for(const a of n)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});n=n.concat(t)}this.dataManager.removeFromLayer(n);for(const r of n)this.sublayerIdsCache.get(r.typeName)?.delete(r.id),this.dataManager.relationshipTypeNames.has(r.typeName)?this.relationshipLinkChartDiagramLookup.delete(r.id):this.entityLinkChartDiagramLookup.delete(r.id);const o=a?void 0:this.getCurrentNodeLocations();await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:o}),n.length>0&&(this.membershipModified=!0);const s=[];return this.layers.forEach(e=>{s.push(e.refreshCachedQueryEngine())}),await Promise.all(s),this._refreshNamedTypes(),n}async expand(e,t){let a=[];try{const i=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);a=i.filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)),await this._handleNewRecords(a,t),i.length>0&&(this.membershipModified=!0),r(t?.signal)}catch(i){throw l(i)&&a.length>0&&await this.removeRecords(a,{overrideMembershipCheck:!0}),i}return{records:a}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.layers.length||0===this.originIdOf("tables")?0===this.originIdOf("layers")?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers):this.layers=new a,this.tables.length||0===this.originIdOf("layers")?0===this.originIdOf("tables")?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables):this.tables=new a,this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{const a=o(this.sublayerIdsCache,t,()=>new Set);e.members?.forEach(({id:e,linkChartLocation:i})=>{if(a.add(e),i){const a="coords"in i&&"lengths"in i?i:b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,a):this.entityLinkChartDiagramLookup.set(e,a)}})})}async calculateLinkChartLayout(e="organic-standard",t){const a=[],s=[],l=[];this.dataManager.sublayerCaches.forEach((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach(e=>{a.push({typeName:t,feature:e})}):this.dataManager.relationshipTypeNames.has(t)&&e.forEach(e=>{s.push({typeName:t,feature:e})})}),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const d=new Map,p=new Map,c=new Map,u=new Map,y=new Uint8Array(a.length),L=new Float64Array(a.length),D=new Float64Array(a.length),x=new Float64Array(a.length),v=new Float64Array(a.length),I=new Uint32Array(s.length),E=new Uint32Array(s.length),S=new Float64Array(s.length),_=new Float64Array(s.length),A=[],R="organic-standard";let j=!1;const G=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let z,H="organic-standard",K=0,J=0;const V=O.apply;switch(H="geographic-organic-standard"===e?R:e,H){case"organic-standard":z=W.apply;break;case"organic-community":z=Q.apply;break;case"hierarchical-bottom-to-top":z=U.apply;break;case"radial-root-centric":z=B.apply;break;case"tree-left-to-right":z=F.apply;break;default:z=P.apply}let q=!1;a.forEach(({typeName:a,feature:i})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedNodeLocations?.has(i.attributes[M])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)?y[K]=2:y[K]=0;const n=t.lockedNodeLocations.get(i.attributes[M]);L[K]=n.x,D[K]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)){y[K]=2;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":L[K]=t?.x,D[K]=t?.y;break;case"esriGeometryPolygon":{const a=w(t);e=a?m.fromJSON(a):null,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break}case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break;default:y[K]=1}(null==L[K]||null==D[K]||Number.isNaN(L[K])||Number.isNaN(D[K]))&&(y[K]=1,L[K]=0,D[K]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!q&&t?.lockedNodeLocations?.has(i.attributes[M])&&(q=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;x[K]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;v[K]=r?new Date(r).getTime():NaN,L[K]=0,D[K]=0,y[K]=1}else y[K]=1,L[K]=0,D[K]=0;u.set(i.attributes[M],K),A[K]={feature:i,typeName:a},K++}),q&&n.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let X=!1;const Y=new Map;s.forEach(a=>{const i=a.feature.attributes[k],n=a.feature.attributes[C],o=u.get(i),s=u.get(n),r=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?r?.startField:null,d=h?a.feature.attributes[h]:null,p=r?.endField,c=p?a.feature.attributes[p]:null;if(void 0!==o&&void 0!==s){let t=i+"-"+n;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+c);const r=Y.get(t),h=r?.has(a.typeName);h||(I[J]=o,E[J]=s,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(S[J]=d?new Date(d).getTime():NaN,_[J]=c?new Date(c).getTime():NaN),void 0===r?Y.set(t,new Map([[a.typeName,J]])):r.set(a.typeName,J),J++),l.push(a)}else X=!0,this.relationshipLinkChartDiagramLookup.set(i,null)}),X&&n.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const Z=this._validateOrganicLayoutSettings(e,t?.layoutSettings?.organicLayoutSettings),ee=this._convertValidatedOrganicSettingsToCalculationSettings(Z);await $();let te=1,ae=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let a;({status:te,links:ae,graphics:a}=V(()=>t?.signal?.aborted??!1,y,L,D,x,v,I.subarray(0,J),E.subarray(0,J),S.subarray(0,J),_.subarray(0,J),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings)),0===te&&(this.chronologicalAuxiliaryGraphics=a)}else({status:te,links:ae}=z(()=>t?.signal?.aborted??!1,y,L,D,I.subarray(0,J),E.subarray(0,J),ee.computationBudgetTime,ee.idealEdgeLengthMultiplier,ee.repulsionRadiusMultiplier));if(r(t?.signal),1===te)throw new i("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(2===te)throw h();for(let i=0;i<A.length;i++){if(D[i]>84.9999?D[i]=84.9999:D[i]<-84.9999&&(D[i]=-84.9999),L[i]>179.9999?L[i]=179.9999:L[i]<-179.9999&&(L[i]=-179.9999),A[i].feature.attributes[T]=new m(L[i],D[i]),d.has(A[i].typeName)){const e=d.get(A[i].typeName);e?.set(A[i].feature.attributes[M],A[i].feature)}else{const e=new Map;e.set(A[i].feature.attributes[M],A[i].feature),d.set(A[i].typeName,e)}c.set(A[i].feature.attributes[M],A[i].feature);const e=b(A[i].feature.attributes[T]);this.entityLinkChartDiagramLookup.set(A[i].feature.attributes[M],A[i].feature.attributes[T]?e:null);const t=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,A[i].typeName,()=>({useAllData:!1,members:new Map}));o(t.members,A[i].feature.attributes[M],()=>({id:A[i].feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=A[i].feature.attributes[T];const{x:a,y:n}=A[i].feature.attributes[T];if(j)G.xmin=Math.min(G.xmin,a),G.xmax=Math.max(G.xmax,a),G.ymin=Math.min(G.ymin,n),G.ymax=Math.max(G.ymax,n);else{const e=1e-7;G.xmin=a-e,G.xmax=a+e,G.ymin=n-e,G.ymax=n+e,j=!0}}if(this.linkChartExtent.xmin=G.xmin,this.linkChartExtent.xmax=G.xmax,this.linkChartExtent.ymin=G.ymin,this.linkChartExtent.ymax=G.ymax,!ae)throw new i("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ie=new Map,ne=new Map,oe=new Map,se=new Set;for(let i=0;i<l.length;i++){const a=[],s=l[i],r=s.feature.attributes[k],h=s.feature.attributes[C];let d=r+"-"+h;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(s.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?s.feature.attributes[a]:null,n=e?.endField;d+="-"+i+"-"+(n?s.feature.attributes[n]:null)}const y=Y.get(d).get(s.typeName),g=0===y?0:ae?.vertexEndIndex[y-1];if(!se.has(y)){if(se.add(y),2===ae.types[y]){const e=[ae.vertices[2*g],ae.vertices[2*g+1]],t=[ae.vertices[2*(g+1)],ae.vertices[2*(g+1)+1]],i=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[i[0]-e[0],i[1]-e[1]],o=[i[0]+n[1],i[1]-n[0]],s=[i[0]-n[1],i[1]+n[0]];a.push(e),a.push(o),a.push(t),a.push(s),a.push(e)}else{if(0!==ae.types[y]){n.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<ae.vertexEndIndex[y];e++)a.push([ae.vertices[2*e],ae.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=A[u.get(r)]?.feature.attributes[T],t=A[u.get(h)]?.feature.attributes[T];a[0][0]===e.x&&a[0][1]===e.y||(a[0]=[e.x,e.y]),a[a.length-1][0]===t.x&&a[a.length-1][1]===t.y||(a[a.length-1]=[t.x,t.y])}for(let e=1;e<a.length-1;e++)a[e][1]>85.5?a[e][1]=85.5:a[e][1]<-85.5&&(a[e][1]=-85.5),a[e][0]>179.9999?a[e][0]=179.9999:a[e][0]<-179.9999&&(a[e][0]=-179.9999);ie.has(d)?ie.get(d).push(a):ie.set(d,[a])}const m=ie.get(d);ne.has(d)||(ne.set(d,new Map),oe.set(d,new Map));const w=ne.get(d),L=oe.get(d);w.has(s.typeName)||(w.set(s.typeName,m.shift()),L.set(s.typeName,0));const N=w.get(s.typeName);L.set(s.typeName,L.get(s.typeName)+1);const D=new f({paths:[N]});if(s.feature.attributes[T]=D,p.has(s.typeName)){const e=p.get(s.typeName);e?.set(s.feature.attributes[M],s.feature)}else{const e=new Map;e.set(s.feature.attributes[M],s.feature),p.set(s.typeName,e)}c.set(s.feature.attributes[M],s.feature);const x=b(s.feature.attributes[T]);this.relationshipLinkChartDiagramLookup.set(s.feature.attributes[M],s.feature.attributes[T]?x:null);const v=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,s.typeName,()=>({useAllData:!1,members:new Map}));o(v.members,s.feature.attributes[M],()=>({id:s.feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=x}for(const i of l)i.feature.attributes[N]=oe.get(i.feature.attributes[k]+"-"+i.feature.attributes[C])?.get(i.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:t?.layoutSettings?.clone()},{nodes:d,links:p,idMap:c}}async applyNewLinkChartLayout(e="organic-standard",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach(e=>{a.push(e.refreshCachedQueryEngine())}),this.membershipModified=!0,await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||a?.members?.forEach(t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new m({x:i.x,y:i.y})))});return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}a=await this.dataManager.getRelationshipsBetweenNodes(e,i,t),await this._handleNewRecords(a,t),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}a=await this.dataManager.getRelationshipsFromNodes(e,n,i,t),await this._handleNewRecords(a,t),a.length>0&&(this.membershipModified=!0),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="organic-standard",t){const a=new Map;this.layers.forEach(e=>{a.set(e.objectType.name,e.timeInfo)}),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t}),this.linkChart?.handleChronologicalOverlay()}async _handleNewRecords(e,t){const a=new Set,i=[],n=this.layers.concat(this.tables);for(const r of e){if(!this._graphTypeLookup.has(r.typeName))continue;!1===n.some(e=>e.objectType.name===r.typeName)&&(this.dataManager.sublayerCaches.set(r.typeName,new Map),a.add(r.typeName));o(this.sublayerIdsCache,r.typeName,()=>new Set).add(r.id),i.push(r)}this.dataManager.addToLayer(i);for(const o of a){const e=this._graphTypeLookup.get(o);if(e){const t=this._createSublayer(e);"entity"===e.type?this.dataManager.entityTypeNames.add(o):this.dataManager.relationshipTypeNames.add(o),t.geometryType?this.layers.push(t):this.tables.push(t)}}await E(this,Array.from(a),t),await this.dataManager.refreshCacheContent(e.map(e=>e.id),void 0,void 0,void 0,t);const s={layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:new Map};for(const[o,r]of this.entityLinkChartDiagramLookup.entries())r&&s.lockedNodeLocations.set(o,new m(r.coords[0],r.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,s)}_createSublayers(e,t,a){e.forEach(e=>{const i=this._createSublayer(e);a(i)&&t.push(i),this._updateSublayerCaches(e)})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;const a=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);a&&(t.objectType=a,t.read({title:a.name},{origin:"service"}),this._updateSublayerCaches(a))})}_updateSublayerCaches({name:e}){if(!e)return;const t=this.dataManager.sublayerCaches;t.has(e)||t.set(e,new Map)}_layersLoadedFromAuthoritativeItem(){const e=this.originIdOf("layers");return e>=3&&e<7}async _initializeDiagram(){this.initializationLinkChartConfig?this.initializationLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{e?.members?.forEach(e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)})}),this.memberRelationshipTypes.forEach(e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach(e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[k]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[C]);if(t&&a){const i=b(new f({paths:[[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[M],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[M],null)})})):await this._calculateLayoutWithSublayerTimeInfo(this.initializationLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.initializationLinkChartConfig}):await this._calculateLayoutWithSublayerTimeInfo("organic-standard",{lockedNodeLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateOrganicLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),i=e=>a(e)&&e>=1,o=e=>a(e)&&e>=1,s=e=>Object.values(D).includes(e),r=e=>a(e)&&e>=0,l={};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return l;const{computationBudgetTime:h,autoRepulsionRadius:d,repulsionRadiusMultiplier:p,absoluteIdealEdgeLength:c,multiplicativeIdealEdgeLength:u,idealEdgeLengthType:y}=t;return o(h)?l.computationBudgetTime=h:h&&n.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),l.autoRepulsionRadius=d,!d&&i(p)?l.repulsionRadiusMultiplier=p:d||(l.autoRepulsionRadius=!0,n.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting")),"geographic-organic-standard"===e&&(s(y)?l.idealEdgeLengthType=y:void 0!==y&&n.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===y&&r(c)?l.absoluteIdealEdgeLength=c:"absolute-value"===y&&void 0!==c?n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===y&&r(u)?l.multiplicativeIdealEdgeLength=u:"multiplier"===y&&void 0!==u&&n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),l}_convertValidatedOrganicSettingsToCalculationSettings(e){let t=e.idealEdgeLengthType===D.ABSOLUTE?e.absoluteIdealEdgeLength:e.multiplicativeIdealEdgeLength;return e.idealEdgeLengthType===D.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier&&!e.autoRepulsionRadius?e.repulsionRadiusMultiplier:void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new v({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner")),e&&(e.forEach(e=>{e.parent=this}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this}),e.on("after-remove",({item:e})=>{e.parent=null})],"sublayers-owner"))}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map(e=>e.name).concat((e.relationshipTypes??[]).map(e=>e.name))),i=new Set((e.entityTypes??[]).map(e=>e.name)),o=new Set((e.relationshipTypes??[]).map(e=>e.name));if(this.layers){for(const a of this.layers)!a.graphType&&t.has(a.graphTypeName)&&(a.graphType=i.has(a.graphTypeName)?"entity":"relationship");const e=this.layers.filter(e=>t.has(e.graphTypeName)&&("entity"===e.graphType?i.has(e.graphTypeName):o.has(e.graphTypeName)));this.setAtOrigin("layers",e,y(this.originIdOf("layers")))}else this.layers=new a;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map(e=>e.graphTypeName)??[],a=this.layers.map(e=>e.graphTypeName).concat(t);for(const n of a)e.has(n)||this._originalInclusionList.namedTypeDefinitions.set(n,{useAllData:!1,members:new Map});const i=[];for(const o of this._originalInclusionList.namedTypeDefinitions.keys())a.includes(o)||(n.getLogger(this).warn(`A named type, ${o}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),i.push(o));for(const n of i)this._originalInclusionList.namedTypeDefinitions.delete(n)}}};e([c(z)],K.prototype,"url",void 0),e([c()],K.prototype,"dataPreloadedInLocalCache",void 0),e([c()],K.prototype,"initializationLinkChartConfig",void 0),e([c()],K.prototype,"membershipModified",void 0),e([c()],K.prototype,"dataManager",void 0),e([c()],K.prototype,"initializationInclusionModeDefinition",null),e([c()],K.prototype,"knowledgeGraph",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],K.prototype,"layers",void 0),e([c({readOnly:!0})],K.prototype,"linkChart",null),e([c()],K.prototype,"entityLinkChartDiagramLookup",void 0),e([c()],K.prototype,"relationshipLinkChartDiagramLookup",void 0),e([c()],K.prototype,"linkChartExtent",void 0),e([c()],K.prototype,"memberEntityTypes",void 0),e([c()],K.prototype,"memberRelationshipTypes",void 0),e([c({type:["LinkChartLayer"]})],K.prototype,"operationalLayerType",void 0),e([c()],K.prototype,"sublayerCapabilities",null),e([c()],K.prototype,"sublayerIdsCache",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],K.prototype,"tables",void 0),e([c({json:{read:!1}})],K.prototype,"type",void 0),e([c({json:{read:!1}})],K.prototype,"chronologicalAuxiliaryGraphics",void 0),K=e([u("esri.layers.LinkChartLayer")],K);const J=K;export{J as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{Loadable as s}from"../../../core/Loadable.js";import{escapeRegExpString as r}from"../../../core/string.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../../geometry/SpatialReference.js";import{typeKebabDictionary as a}from"../../../geometry/support/typeUtils.js";import{queryFeatureSetJSON as u,crsDefault as n,getSpatialReferenceWkid as c,getServerLandingPage as l,getServerConformance as d,getServerCollections as m,getServerOpenApi as y,getCollectionDefinition as f,crsPrefix as g}from"../../ogc/ogcFeatureUtils.js";import{zeroQueryBins as h}from"../../support/capabilities.js";import S from"../../../rest/support/FeatureSet.js";let C=class extends s{constructor(){super(...arguments),this.featureDefinition=null,this.type="ogc-feature"}load(e){return this.addResolvingPromise(this._loadOGCServices(this.layer,e)),this.when()}getSource(){const{featureDefinition:{collection:e,layerDefinition:t,spatialReference:s,supportedCrs:r},layer:{apiKey:o,customParameters:p,effectiveMaxRecordCount:i}}=this;return{type:"ogc-source",collection:e,layerDefinition:t,maxRecordCount:i,queryParameters:{apiKey:o,customParameters:p},spatialReference:s,supportedCrs:r}}queryExtent(e,t={}){return null}queryFeatureCount(e,t={}){return null}queryFeatures(e,t={}){return this.queryFeaturesJSON(e,t).then(e=>S.fromJSON(e))}queryFeaturesJSON(e,t={}){const s=this.getSource();return this.load(t).then(()=>u(s,e,t))}queryObjectIds(e,t={}){return null}serviceSupportsSpatialReference(e){return!(!e.isWGS84&&!e.isWebMercator)||!!this.featureDefinition.supportedCrs[e.wkid]}_conformsToType(e,t){const s=new RegExp(`^${r(t)}$`,"i");return e.conformsTo.some(e=>s.test(e))??!1}_getCapabilities(e,t){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryBins:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:t,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!1,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:h,editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}_getMaxRecordCount(e){const t=e?.components?.parameters;return t?.limit?.schema?.maximum??t?.limitFeatures?.schema?.maximum}_getStorageSpatialReference(e){const t=e.storageCrs??n,s=c(t);return null==s?i.WGS84:new i({wkid:s})}_getSupportedSpatialReferences(e,t){const s="#/crs",r=e.crs??[n],o=r.includes(s)?r.filter(e=>e!==s).concat(t.crs??[]):r,p=/^http:\/\/www\.opengis.net\/def\/crs\/epsg\/.*\/3785$/i;return o.filter(e=>!p.test(e))}async _loadOGCServices(e,s){const o=null!=s?s.signal:null,{apiKey:p,collectionId:i,customParameters:u,fields:n,geometryType:h,hasZ:S,objectIdField:C,timeInfo:R,url:w}=e,v={fields:n?.map(e=>e.toJSON()),geometryType:a.toJSON(h),hasZ:S??!1,objectIdField:C,timeInfo:R?.toJSON()},x={apiKey:p,customParameters:u,signal:o},O=await l(w,x),[j,D]=await Promise.all([d(O,x),m(O,x)]);if(!this._conformsToType(j,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson"))throw new t("ogc-feature-layer:no-geojson-support","Server does not support geojson");const F=D.collections.find(({id:e})=>e===i);if(!F)throw new t("ogc-feature-layer:collection-not-found","Server does not contain the named collection");const T=this._conformsToType(j,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30")?await y(O,x):null,A=await f(F,v,x),Q=this._getMaxRecordCount(T),b=this._getCapabilities(A.hasZ,Q),q=this._getStorageSpatialReference(F).toJSON(),P=this._getSupportedSpatialReferences(F,D),G=new RegExp(`^${r(g)}`,"i"),_={};for(const t of P){const e=c(t);null!=e&&(_[e]||(_[e]=t.replace(G,"")))}this.featureDefinition={capabilities:b,collection:F,layerDefinition:A,spatialReference:q,supportedCrs:_}}};e([o()],C.prototype,"featureDefinition",void 0),e([o({constructOnly:!0})],C.prototype,"layer",void 0),e([o()],C.prototype,"type",void 0),C=e([p("esri.layers.graphics.sources.OGCFeatureSource")],C);export{C as OGCFeatureSource};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{Loadable as s}from"../../../core/Loadable.js";import{escapeRegExpString as r}from"../../../core/string.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../../geometry/SpatialReference.js";import{typeKebabDictionary as a}from"../../../geometry/support/typeUtils.js";import{queryFeatureSetJSON as u,crsDefault as n,getSpatialReferenceWkid as c,getServerLandingPage as l,getServerConformance as d,getServerCollections as m,getServerOpenApi as y,getCollectionDefinition as f,crsPrefix as g}from"../../ogc/ogcFeatureUtils.js";import{zeroQueryBins as h}from"../../support/capabilities.js";import S from"../../../rest/support/FeatureSet.js";let C=class extends s{constructor(){super(...arguments),this.featureDefinition=null,this.type="ogc-feature"}load(e){return this.addResolvingPromise(this._loadOGCServices(this.layer,e)),this.when()}getSource(){const{featureDefinition:{collection:e,layerDefinition:t,spatialReference:s,supportedCrs:r},layer:{apiKey:o,customParameters:p,effectiveMaxRecordCount:i}}=this;return{type:"ogc-source",collection:e,layerDefinition:t,maxRecordCount:i,queryParameters:{apiKey:o,customParameters:p},spatialReference:s,supportedCrs:r}}queryExtent(e,t={}){return null}queryFeatureCount(e,t={}){return null}queryFeatures(e,t={}){return this.queryFeaturesJSON(e,t).then(e=>S.fromJSON(e))}queryFeaturesJSON(e,t={}){const s=this.getSource();return this.load(t).then(()=>u(s,e,t))}queryObjectIds(e,t={}){return null}serviceSupportsSpatialReference(e){return!(!e.isWGS84&&!e.isWebMercator)||!!this.featureDefinition.supportedCrs[e.wkid]}_conformsToType(e,t){const s=new RegExp(`^${r(t)}$`,"i");return e.conformsTo.some(e=>s.test(e))??!1}_getCapabilities(e,t){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:e},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:t,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!1,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:h,editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}_getMaxRecordCount(e){const t=e?.components?.parameters;return t?.limit?.schema?.maximum??t?.limitFeatures?.schema?.maximum}_getStorageSpatialReference(e){const t=e.storageCrs??n,s=c(t);return null==s?i.WGS84:new i({wkid:s})}_getSupportedSpatialReferences(e,t){const s="#/crs",r=e.crs??[n],o=r.includes(s)?r.filter(e=>e!==s).concat(t.crs??[]):r,p=/^http:\/\/www\.opengis.net\/def\/crs\/epsg\/.*\/3785$/i;return o.filter(e=>!p.test(e))}async _loadOGCServices(e,s){const o=null!=s?s.signal:null,{apiKey:p,collectionId:i,customParameters:u,fields:n,geometryType:h,hasZ:S,objectIdField:C,timeInfo:R,url:v}=e,w={fields:n?.map(e=>e.toJSON()),geometryType:a.toJSON(h),hasZ:S??!1,objectIdField:C,timeInfo:R?.toJSON()},x={apiKey:p,customParameters:u,signal:o},O=await l(v,x),[j,D]=await Promise.all([d(O,x),m(O,x)]);if(!this._conformsToType(j,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson"))throw new t("ogc-feature-layer:no-geojson-support","Server does not support geojson");const F=D.collections.find(({id:e})=>e===i);if(!F)throw new t("ogc-feature-layer:collection-not-found","Server does not contain the named collection");const T=this._conformsToType(j,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30")?await y(O,x):null,A=await f(F,w,x),Q=this._getMaxRecordCount(T),P=this._getCapabilities(A.hasZ,Q),b=this._getStorageSpatialReference(F).toJSON(),q=this._getSupportedSpatialReferences(F,D),G=new RegExp(`^${r(g)}`,"i"),_={};for(const t of q){const e=c(t);null!=e&&(_[e]||(_[e]=t.replace(G,"")))}this.featureDefinition={capabilities:P,collection:F,layerDefinition:A,spatialReference:b,supportedCrs:_}}};e([o()],C.prototype,"featureDefinition",void 0),e([o({constructOnly:!0})],C.prototype,"layer",void 0),e([o()],C.prototype,"type",void 0),C=e([p("esri.layers.graphics.sources.OGCFeatureSource")],C);export{C as OGCFeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import s from"../../../../core/Error.js";import i from"../../../../core/Logger.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{getJsonType as n}from"../../../../geometry/support/jsonUtils.js";import{wgs84 as a,equals as o}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as u,convertToGeometry as l,convertFromFeatures as d,convertToFeature as p,convertFromFeature as c}from"../../featureConversionUtils.js";import y from"../../data/FeatureStore.js";import{checkProjectionSupport as m,project as h}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{inferLayerProperties as g,createOptimizedFeatures as _,validateGeoJSON as I}from"./geojson.js";import{createDefaultTemplate as j,createDefaultAttributesFunction as F,createDrawingInfo as E}from"../support/clientSideDefaults.js";import{queryBinsCapabilities as b,loadGeometryEngineForSimplify as T,mixAttributes as w,createFeatureEditSuccessResult as q,createFeatureEditErrorResult as x,simplify as S}from"../support/sourceUtils.js";import R from"../../../support/FieldsIndex.js";import{kebabDict as C}from"../../../support/fieldType.js";import{getFieldDefaultValue as O,getFieldDefaultLength as Q}from"../../../support/fieldUtils.js";import{utc as k}from"../../../../time/constants.js";const D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsQueryWithResultType:!0,supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0},queryBinsCapabilities:b};class A{constructor(){this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e,t={}){this._loadOptions={url:e.url,customParameters:e.customParameters};const i=[],[r]=await Promise.all([e.url?this._fetch(t?.signal):null,this._checkProjection(e.spatialReference)]),n=g(r,{geometryType:e.geometryType}),o=e.fields||n.fields||[],u=null!=e.hasZ?e.hasZ:n.hasZ,l=n.geometryType;let d=e.objectIdField||n.objectIdFieldName||"__OBJECTID";const p=e.spatialReference||a;let c=e.timeInfo;o===n.fields&&n.unknownFields.length>0&&i.push({name:"geojson-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:n.unknownFields}});const m=new R(o);let h=m.get(d);h?("esriFieldTypeString"!==h.type&&(h.type="esriFieldTypeOID"),h.editable=!1,h.nullable=!1,d=h.name):(h={alias:d,name:d,type:"string"===n.objectIdFieldType?"esriFieldTypeString":"esriFieldTypeOID",editable:!1,nullable:!1},o.unshift(h));const _={};for(const a of o){if(null==a.name&&(a.name=a.alias),null==a.alias&&(a.alias=a.name),!a.name)throw new s("geojson-layer:invalid-field-name","field name is missing",{field:a});if(!C.jsonValues.includes(a.type))throw new s("geojson-layer:invalid-field-type",`invalid type for field "${a.name}"`,{field:a});if(a.name!==h.name){const e=O(a);void 0!==e&&(_[a.name]=e)}null==a.length&&(a.length=Q(a))}if(c){if(c.startTimeField){const e=m.get(c.startTimeField);e?(c.startTimeField=e.name,e.type="esriFieldTypeDate"):c.startTimeField=null}if(c.endTimeField){const e=m.get(c.endTimeField);e?(c.endTimeField=e.name,e.type="esriFieldTypeDate"):c.endTimeField=null}if(c.trackIdField){const e=m.get(c.trackIdField);e?c.trackIdField=e.name:(c.trackIdField=null,i.push({name:"geojson-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:c}}))}c.startTimeField||c.endTimeField||(i.push({name:"geojson-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:c}}),c=null)}const I=l?E(l):void 0,b=m.dateFields.length?{timeZoneIANA:k}:null,T={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:I??void 0,templates:j(_),extent:void 0,geometryType:l,objectIdField:d,fields:o,hasZ:!!u,timeInfo:c,dateFieldsTimeReference:b}},w={type:"object-id",fieldName:d};this._queryEngine=new f({fieldsIndex:R.fromLayerJSON({fields:o,timeInfo:c,dateFieldsTimeReference:b}),geometryType:l,hasM:!1,hasZ:u,featureIdInfo:w,spatialReference:p,timeInfo:c,featureStore:new y({geometryType:l,hasM:!1,hasZ:u})});const q=this._queryEngine.fieldsIndex.requiredFields.indexOf(h);q>-1&&this._queryEngine.fieldsIndex.requiredFields.splice(q,1),this._createDefaultAttributes=F(_,d);const x=this._createFeatures(r);this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,x);const S=this._normalizeFeatures(x,T.featureErrors);this._queryEngine.featureStore.addMany(S);const{fullExtent:A,timeExtent:v}=await this._queryEngine.fetchRecomputedExtents();if(T.layerDefinition.extent=A,v){const{start:e,end:t}=v;T.layerDefinition.timeInfo.timeExtent=[e,t]}return T}async applyEdits(e){const{spatialReference:t,geometryType:s}=this._queryEngine;return await Promise.all([T(t,s),m(e.adds,t),m(e.updates,t)]),await this._waitSnapshotComplete(),this._applyEdits(e)}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,e);const t=this._normalizeFeatures(e);t&&this._queryEngine.featureStore.addMany(t)},e=>{this._queryEngine.featureStore.clear(),r(e)||i.getLogger("esri.layers.GeoJSONLayer").error(new s("geojson-layer:refresh","An error occurred during refresh",{error:e}))}),await this._waitSnapshotComplete();const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a}}_createFeatures(e){if(null==e)return[];const{geometryType:t,hasZ:s,objectIdField:i}=this._queryEngine,r=_(e,{geometryType:t,hasZ:s,objectIdField:i});if(!o(this._queryEngine.spatialReference,a))for(const n of r)null!=n.geometry&&(n.geometry=u(h(l(n.geometry,this._queryEngine.geometryType,this._queryEngine.hasZ,!1),a,this._queryEngine.spatialReference)));return r}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:s,customParameters:i}=this._loadOptions,r=(await e(s??"",{responseType:"json",query:{...i},signal:t})).data;return I(r),r}_normalizeFeatures(e,t){const{objectIdField:s,fieldsIndex:i}=this._queryEngine,r=[];for(const n of e){const e=this._createDefaultAttributes(),a=w(i,e,n.attributes,!0);a?t?.push(a):(this._assignObjectId(e,n.attributes,!0),n.attributes=e,n.objectId=e[s],r.push(n))}return r}async _applyEdits(e){const{adds:t,updates:s,deletes:i}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),s?.length&&this._applyUpdateEdits(r,s),i?.length){for(const e of i)r.deleteResults.push(q(e));this._queryEngine.featureStore.removeManyById(i)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,t){const{addResults:s}=e,{geometryType:i,hasM:r,hasZ:a,objectIdField:o,spatialReference:u,featureStore:l,fieldsIndex:p}=this._queryEngine,c=[],y={type:"object-id",fieldName:o};for(const d of t){if(d.geometry&&i!==n(d.geometry)){s.push(x("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),r=w(p,t,d.attributes);if(r)s.push(r);else{if(this._assignObjectId(t,d.attributes),d.attributes=t,null!=d.uid){const t=d.attributes[o];e.uidToObjectId[d.uid]=t}if(null!=d.geometry){const e=d.geometry.spatialReference??u;d.geometry=h(S(d.geometry,e),e,u)}c.push(d),s.push(q(d.attributes[o]))}}l.addMany(d([],c,i,a,r,y))}_applyUpdateEdits({updateResults:e},t){const{geometryType:s,hasM:i,hasZ:r,objectIdField:a,spatialReference:o,featureStore:u,fieldsIndex:l}=this._queryEngine,d={type:"object-id",fieldName:a};for(const y of t){const{attributes:t,geometry:m}=y,f=t?.[a];if(null==f){e.push(x(`Identifier field ${a} missing`));continue}if(!u.has(f)){e.push(x(`Feature with object id ${f} missing`));continue}const g=p(u.getFeature(f),s,r,i);if(null!=m){if(s!==n(m)){e.push(x("Incorrect geometry type."));continue}const t=m.spatialReference??o;g.geometry=h(S(m,t),t,o)}if(t){const s=w(l,g.attributes,t);if(s){e.push(s);continue}}u.add(c(g,s,r,i,d)),e.push(q(f))}}_createObjectIdGenerator(e,t){const s=e.fieldsIndex.get(e.objectIdField);if("esriFieldTypeString"===s.type)return()=>s.name+"-"+Date.now().toString(16);let i=Number.NEGATIVE_INFINITY;for(const r of t)r.objectId&&(i=Math.max(i,r.objectId));return i=Math.max(0,i)+1,()=>i++}_assignObjectId(e,t,s=!1){const i=this._queryEngine.objectIdField;e[i]=s&&i in t?t[i]:this._objectIdGenerator()}async _checkProjection(e){try{await m(a,e)}catch{throw new s("geojson-layer","Projection not supported")}}}export{A as default};
5
+ import e from"../../../../request.js";import{createTask as t}from"../../../../core/asyncUtils.js";import s from"../../../../core/Error.js";import i from"../../../../core/Logger.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{getJsonType as n}from"../../../../geometry/support/jsonUtils.js";import{wgs84 as a,equals as o}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromGeometry as u,convertToGeometry as l,convertFromFeatures as d,convertToFeature as p,convertFromFeature as c}from"../../featureConversionUtils.js";import y from"../../data/FeatureStore.js";import{checkProjectionSupport as m,project as h}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{inferLayerProperties as g,createOptimizedFeatures as _,validateGeoJSON as I}from"./geojson.js";import{createDefaultTemplate as j,createDefaultAttributesFunction as F,createDrawingInfo as E}from"../support/clientSideDefaults.js";import{queryBinsCapabilities as b,loadGeometryEngineForSimplify as T,mixAttributes as w,createFeatureEditSuccessResult as q,createFeatureEditErrorResult as x,simplify as S}from"../support/sourceUtils.js";import R from"../../../support/FieldsIndex.js";import{kebabDict as C}from"../../../support/fieldType.js";import{getFieldDefaultValue as O,getFieldDefaultLength as Q}from"../../../support/fieldUtils.js";import{utc as k}from"../../../../time/constants.js";const D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryWithCacheHint:!0,supportsQueryWithDistance:!0,supportsQueryWithResultType:!0,supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0},queryBinsCapabilities:b};class A{constructor(){this._queryEngine=null,this._snapshotFeatures=async e=>{const t=await this._fetch(e);return this._createFeatures(t)}}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(e,t={}){this._loadOptions={url:e.url,customParameters:e.customParameters};const i=[],[r]=await Promise.all([e.url?this._fetch(t?.signal):null,this._checkProjection(e.spatialReference)]),n=g(r,{geometryType:e.geometryType}),o=e.fields||n.fields||[],u=null!=e.hasZ?e.hasZ:n.hasZ,l=n.geometryType;let d=e.objectIdField||n.objectIdFieldName||"__OBJECTID";const p=e.spatialReference||a;let c=e.timeInfo;o===n.fields&&n.unknownFields.length>0&&i.push({name:"geojson-layer:unknown-field-types",message:"Some fields types couldn't be inferred from the features and were dropped",details:{unknownFields:n.unknownFields}});const m=new R(o);let h=m.get(d);h?("esriFieldTypeString"!==h.type&&(h.type="esriFieldTypeOID"),h.editable=!1,h.nullable=!1,d=h.name):(h={alias:d,name:d,type:"string"===n.objectIdFieldType?"esriFieldTypeString":"esriFieldTypeOID",editable:!1,nullable:!1},o.unshift(h));const _={};for(const a of o){if(null==a.name&&(a.name=a.alias),null==a.alias&&(a.alias=a.name),!a.name)throw new s("geojson-layer:invalid-field-name","field name is missing",{field:a});if(!C.jsonValues.includes(a.type))throw new s("geojson-layer:invalid-field-type",`invalid type for field "${a.name}"`,{field:a});if(a.name!==h.name){const e=O(a);void 0!==e&&(_[a.name]=e)}null==a.length&&(a.length=Q(a))}if(c){if(c.startTimeField){const e=m.get(c.startTimeField);e?(c.startTimeField=e.name,e.type="esriFieldTypeDate"):c.startTimeField=null}if(c.endTimeField){const e=m.get(c.endTimeField);e?(c.endTimeField=e.name,e.type="esriFieldTypeDate"):c.endTimeField=null}if(c.trackIdField){const e=m.get(c.trackIdField);e?c.trackIdField=e.name:(c.trackIdField=null,i.push({name:"geojson-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:c}}))}c.startTimeField||c.endTimeField||(i.push({name:"geojson-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing",details:{timeInfo:c}}),c=null)}const I=l?E(l):void 0,b=m.dateFields.length?{timeZoneIANA:k}:null,T={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:I??void 0,templates:j(_),extent:void 0,geometryType:l,objectIdField:d,fields:o,hasZ:!!u,timeInfo:c,dateFieldsTimeReference:b}},w={type:"object-id",fieldName:d};this._queryEngine=new f({fieldsIndex:R.fromLayerJSON({fields:o,timeInfo:c,dateFieldsTimeReference:b}),geometryType:l,hasM:!1,hasZ:u,featureIdInfo:w,spatialReference:p,timeInfo:c,featureStore:new y({geometryType:l,hasM:!1,hasZ:u})});const q=this._queryEngine.fieldsIndex.requiredFields.indexOf(h);q>-1&&this._queryEngine.fieldsIndex.requiredFields.splice(q,1),this._createDefaultAttributes=F(_,d);const x=this._createFeatures(r);this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,x);const S=this._normalizeFeatures(x,T.featureErrors);this._queryEngine.featureStore.addMany(S);const{fullExtent:A,timeExtent:v}=await this._queryEngine.fetchRecomputedExtents();if(T.layerDefinition.extent=A,v){const{start:e,end:t}=v;T.layerDefinition.timeInfo.timeExtent=[e,t]}return T}async applyEdits(e){const{spatialReference:t,geometryType:s}=this._queryEngine;return await Promise.all([T(t,s),m(e.adds,t),m(e.updates,t)]),await this._waitSnapshotComplete(),this._applyEdits(e)}async queryFeatures(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQuery(e,t.signal)}async queryFeatureCount(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForCount(e,t.signal)}async queryObjectIds(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForIds(e,t.signal)}async queryExtent(e={},t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeQueryForExtent(e,t.signal)}async querySnapping(e,t={}){return await this._waitSnapshotComplete(),await this._queryEngine.executeQueryForSnapping(e,t.signal)}async queryAttributeBins(e,t={}){return await this._waitSnapshotComplete(),this._queryEngine.executeAttributeBinsQuery(e,t.signal)}async refresh(e){this._loadOptions.customParameters=e,this._snapshotTask?.abort(),this._snapshotTask=t(this._snapshotFeatures),this._snapshotTask.promise.then(e=>{this._queryEngine.featureStore.clear(),this._objectIdGenerator=this._createObjectIdGenerator(this._queryEngine,e);const t=this._normalizeFeatures(e);t&&this._queryEngine.featureStore.addMany(t)},e=>{this._queryEngine.featureStore.clear(),r(e)||i.getLogger("esri.layers.GeoJSONLayer").error(new s("geojson-layer:refresh","An error occurred during refresh",{error:e}))}),await this._waitSnapshotComplete();const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a}}_createFeatures(e){if(null==e)return[];const{geometryType:t,hasZ:s,objectIdField:i}=this._queryEngine,r=_(e,{geometryType:t,hasZ:s,objectIdField:i});if(!o(this._queryEngine.spatialReference,a))for(const n of r)null!=n.geometry&&(n.geometry=u(h(l(n.geometry,this._queryEngine.geometryType,this._queryEngine.hasZ,!1),a,this._queryEngine.spatialReference)));return r}async _waitSnapshotComplete(){if(this._snapshotTask&&!this._snapshotTask.finished){try{await this._snapshotTask.promise}catch{}return this._waitSnapshotComplete()}}async _fetch(t){const{url:s,customParameters:i}=this._loadOptions,r=(await e(s??"",{responseType:"json",query:{...i},signal:t})).data;return I(r),r}_normalizeFeatures(e,t){const{objectIdField:s,fieldsIndex:i}=this._queryEngine,r=[];for(const n of e){const e=this._createDefaultAttributes(),a=w(i,e,n.attributes,!0);a?t?.push(a):(this._assignObjectId(e,n.attributes,!0),n.attributes=e,n.objectId=e[s],r.push(n))}return r}async _applyEdits(e){const{adds:t,updates:s,deletes:i}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),s?.length&&this._applyUpdateEdits(r,s),i?.length){for(const e of i)r.deleteResults.push(q(e));this._queryEngine.featureStore.removeManyById(i)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,t){const{addResults:s}=e,{geometryType:i,hasM:r,hasZ:a,objectIdField:o,spatialReference:u,featureStore:l,fieldsIndex:p}=this._queryEngine,c=[],y={type:"object-id",fieldName:o};for(const d of t){if(d.geometry&&i!==n(d.geometry)){s.push(x("Incorrect geometry type."));continue}const t=this._createDefaultAttributes(),r=w(p,t,d.attributes);if(r)s.push(r);else{if(this._assignObjectId(t,d.attributes),d.attributes=t,null!=d.uid){const t=d.attributes[o];e.uidToObjectId[d.uid]=t}if(null!=d.geometry){const e=d.geometry.spatialReference??u;d.geometry=h(S(d.geometry,e),e,u)}c.push(d),s.push(q(d.attributes[o]))}}l.addMany(d([],c,i,a,r,y))}_applyUpdateEdits({updateResults:e},t){const{geometryType:s,hasM:i,hasZ:r,objectIdField:a,spatialReference:o,featureStore:u,fieldsIndex:l}=this._queryEngine,d={type:"object-id",fieldName:a};for(const y of t){const{attributes:t,geometry:m}=y,f=t?.[a];if(null==f){e.push(x(`Identifier field ${a} missing`));continue}if(!u.has(f)){e.push(x(`Feature with object id ${f} missing`));continue}const g=p(u.getFeature(f),s,r,i);if(null!=m){if(s!==n(m)){e.push(x("Incorrect geometry type."));continue}const t=m.spatialReference??o;g.geometry=h(S(m,t),t,o)}if(t){const s=w(l,g.attributes,t);if(s){e.push(s);continue}}u.add(c(g,s,r,i,d)),e.push(q(f))}}_createObjectIdGenerator(e,t){const s=e.fieldsIndex.get(e.objectIdField);if("esriFieldTypeString"===s.type)return()=>s.name+"-"+Date.now().toString(16);let i=Number.NEGATIVE_INFINITY;for(const r of t)r.objectId&&(i=Math.max(i,r.objectId));return i=Math.max(0,i)+1,()=>i++}_assignObjectId(e,t,s=!1){const i=this._queryEngine.objectIdField;e[i]=s&&i in t?t[i]:this._objectIdGenerator()}async _checkProjection(e){try{await m(a,e)}catch{throw new s("geojson-layer","Projection not supported")}}}export{A as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{getJsonType as t,isPoint as i}from"../../../../geometry/support/jsonUtils.js";import{wgs84 as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as r,convertToFeature as n,convertFromFeature as a}from"../../featureConversionUtils.js";import{initialObjectId as o,findLastObjectIdFromFeatures as l}from"../../objectIdUtils.js";import u from"../../data/FeatureStore.js";import{checkProjectionSupport as d,project as p}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as c,createDefaultTemplate as y,createDrawingInfo as m}from"./clientSideDefaults.js";import{queryBinsCapabilities as h,loadGeometryEngineForSimplify as g,createFeatureEditErrorResult as I,mixAttributes as b,createFeatureEditSuccessResult as F,simplify as j}from"./sourceUtils.js";import E from"../../../support/FieldsIndex.js";import{kebabDict as T}from"../../../support/fieldType.js";import{getFieldDefaultLength as _,getFieldDefaultValue as x}from"../../../support/fieldUtils.js";import{utc as R}from"../../../../time/constants.js";const q=s,O={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:s},D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0,supportsQueryWithCacheHint:!0},queryBinsCapabilities:h};function w(e){return i(e)?null!=e.z:!!e.hasZ}function Q(e){return i(e)?null!=e.m:!!e.hasM}class S{constructor(){this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(t){const i=[],{features:s}=t,r=this._inferLayerProperties(s,t.fields),n=t.fields||[],a=null!=t.hasM?t.hasM:!!r.hasM,p=null!=t.hasZ?t.hasZ:!!r.hasZ,h=!t.spatialReference&&!r.spatialReference,g=h?q:t.spatialReference||r.spatialReference,I=h?O:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,w=t.timeInfo;const Q=new E(n);if(!F&&(h&&i.push({name:"feature-layer:spatial-reference-not-found",message:"Spatial reference not provided or found in features. Defaults to WGS84"}),!b))throw new e("feature-layer:missing-property","geometryType not set and couldn't be inferred from the provided features");if(!j)throw new e("feature-layer:missing-property","objectIdField not set and couldn't be found in the provided fields");if(r.objectIdField&&j!==r.objectIdField&&(i.push({name:"feature-layer:duplicated-oid-field",message:`Provided objectIdField "${j}" doesn't match the field name "${r.objectIdField}", found in the provided fields`}),j=r.objectIdField),j&&!r.objectIdField){const e=Q.get(j);e?(j=e.name,e.type="esriFieldTypeOID",e.editable=!1,e.nullable=!1):n.unshift({alias:j,name:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}for(const o of n){if(null==o.name&&(o.name=o.alias),null==o.alias&&(o.alias=o.name),!o.name)throw new e("feature-layer:invalid-field-name","field name is missing",{field:o});if(o.name===j&&(o.type="esriFieldTypeOID"),!T.jsonValues.includes(o.type))throw new e("feature-layer:invalid-field-type",`invalid type for field "${o.name}"`,{field:o});null==o.length&&(o.length=_(o))}const S={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=x(e);void 0!==t&&(S[e.name]=t)}if(w){if(w.startTimeField){const e=Q.get(w.startTimeField);e?(w.startTimeField=e.name,e.type="esriFieldTypeDate"):w.startTimeField=null}if(w.endTimeField){const e=Q.get(w.endTimeField);e?(w.endTimeField=e.name,e.type="esriFieldTypeDate"):w.endTimeField=null}if(w.trackIdField){const e=Q.get(w.trackIdField);e?w.trackIdField=e.name:(w.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:w}}))}w.startTimeField||w.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:w}}),w=null)}const v=Q.dateFields.length?{timeZoneIANA:t.dateFieldsTimeZone??R}:null;this._createDefaultAttributes=c(S,j);const A={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:m(b),templates:y(S),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:p,hasM:a,timeInfo:w,dateFieldsTimeReference:v},assignedObjectIds:{}},M={type:"object-id",fieldName:j};if(this._queryEngine=new f({fieldsIndex:E.fromLayerJSON({fields:n,timeInfo:w,dateFieldsTimeReference:v}),geometryType:b,hasM:a,hasZ:p,featureIdInfo:M,spatialReference:g,featureStore:new u({geometryType:b,hasM:a,hasZ:p}),timeInfo:w}),!s?.length)return this._nextObjectId=o,A;const Z=l(j,s);return this._nextObjectId=Z+1,await d(s,g),this._loadInitialFeatures(A,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([g(t,i),d(e.adds,t),d(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}queryAttributeBins(e,t={}){return this._queryEngine.executeAttributeBinsQuery(e,t.signal)}_inferLayerProperties(e,i){let s,r,n=null,a=null,o=null;for(const l of e){const e=l.geometry;if(null!=e&&(n||(n=t(e)),a||(a=e.spatialReference),null==s&&(s=w(e)),null==r&&(r=Q(e)),n&&a&&null!=s&&null!=r))break}if(i&&i.length){let e=null;i.some(t=>{const i="esriFieldTypeOID"===t.type,s=!t.type&&t.name&&"objectid"===t.name.toLowerCase();return e=t,i||s})&&(o=e.name)}return{geometryType:n,spatialReference:a,objectIdField:o,hasM:r,hasZ:s}}async _loadInitialFeatures(e,i){const{geometryType:s,hasM:n,hasZ:a,objectIdField:o,spatialReference:l,featureStore:u,fieldsIndex:d}=this._queryEngine,f=[],c={type:"object-id",fieldName:o};for(const r of i){if(null!=r.uid&&(e.assignedObjectIds[r.uid]=-1),r.geometry&&s!==t(r.geometry)){e.featureErrors.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),n=b(d,i,r.attributes,!0);n?e.featureErrors.push(n):(this._assignObjectId(i,r.attributes,!0),r.attributes=i,null!=r.uid&&(e.assignedObjectIds[r.uid]=r.attributes[o]),null!=r.geometry&&(r.geometry=p(r.geometry,r.geometry.spatialReference,l)),f.push(r))}u.addMany(r([],f,s,a,n,c));const{fullExtent:y,timeExtent:m}=await this._queryEngine.fetchRecomputedExtents();if(e.layerDefinition.extent=y,m){const{start:t,end:i}=m;e.layerDefinition.timeInfo.timeExtent=[t,i]}return e}async _applyEdits(e){const{adds:t,updates:i,deletes:s}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),i?.length&&this._applyUpdateEdits(r,i),s?.length){for(const e of s)r.deleteResults.push(F(e));this._queryEngine.featureStore.removeManyById(s)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,i){const{addResults:s}=e,{geometryType:n,hasM:a,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,featureIdInfo:f,fieldsIndex:c}=this._queryEngine,y=[];for(const r of i){if(r.geometry&&n!==t(r.geometry)){s.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),a=b(c,i,r.attributes);if(a)s.push(a);else{if(this._assignObjectId(i,r.attributes),r.attributes=i,null!=r.uid){const t=r.attributes[l];e.uidToObjectId[r.uid]=t}if(null!=r.geometry){const e=r.geometry.spatialReference??u;r.geometry=p(j(r.geometry,e),e,u)}y.push(r),s.push(F(r.attributes[l]))}}d.addMany(r([],y,n,o,a,f))}_applyUpdateEdits({updateResults:e},i){const{geometryType:s,hasM:r,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,fieldsIndex:f,featureIdInfo:c}=this._queryEngine;for(const y of i){const{attributes:i,geometry:m}=y,h=i?.[l];if(null==h){e.push(I(`Identifier field ${l} missing`));continue}if(!d.has(h)){e.push(I(`Feature with object id ${h} missing`));continue}const g=n(d.getFeature(h),s,o,r);if(null!=m){if(s!==t(m)){e.push(I("Incorrect geometry type."));continue}const i=m.spatialReference??u;g.geometry=p(j(m,i),i,u)}if(i){const t=b(f,g.attributes,i);if(t){e.push(t);continue}}d.add(a(g,s,o,r,c)),e.push(F(h))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{S as default};
5
+ import e from"../../../../core/Error.js";import{getJsonType as t,isPoint as i}from"../../../../geometry/support/jsonUtils.js";import{wgs84 as s}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertFromFeatures as r,convertToFeature as n,convertFromFeature as a}from"../../featureConversionUtils.js";import{initialObjectId as o,findLastObjectIdFromFeatures as l}from"../../objectIdUtils.js";import u from"../../data/FeatureStore.js";import{checkProjectionSupport as d,project as p}from"../../data/projectionSupport.js";import{QueryEngine as f}from"../../data/QueryEngine.js";import{createDefaultAttributesFunction as c,createDefaultTemplate as y,createDrawingInfo as m}from"./clientSideDefaults.js";import{queryBinsCapabilities as h,loadGeometryEngineForSimplify as g,createFeatureEditErrorResult as I,mixAttributes as b,createFeatureEditSuccessResult as F,simplify as j}from"./sourceUtils.js";import E from"../../../support/FieldsIndex.js";import{kebabDict as T}from"../../../support/fieldType.js";import{getFieldDefaultLength as _,getFieldDefaultValue as x}from"../../../support/fieldUtils.js";import{utc as R}from"../../../../time/constants.js";const q=s,O={xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:s},D={hasAttachments:!1,capabilities:"query, editing, create, delete, update",useStandardizedQueries:!0,supportsCoordinatesQuantization:!0,supportsReturningQueryGeometry:!0,advancedQueryCapabilities:{supportsQueryAttachments:!1,supportsQueryAttachmentOrderByFields:!1,supportsQueryAttachmentWithTypeWildcard:!1,supportsQueryBins:!0,supportsQueryPivot:!1,supportsStatistics:!0,supportsPercentileStatistics:!0,supportsReturningGeometryCentroid:!0,supportsQueryWithDistance:!0,supportsDistinct:!0,supportsReturningQueryExtent:!0,supportsReturningGeometryProperties:!1,supportsHavingClause:!0,supportsOrderBy:!0,supportsPagination:!0,supportsQueryWithResultType:!0,supportsSqlExpression:!0,supportsDisjointSpatialRel:!0,supportsQueryWithCacheHint:!0},queryBinsCapabilities:h};function Q(e){return i(e)?null!=e.z:!!e.hasZ}function w(e){return i(e)?null!=e.m:!!e.hasM}class S{constructor(){this._queryEngine=null,this._nextObjectId=null}destroy(){this._queryEngine?.destroy(),this._queryEngine=this._createDefaultAttributes=null}async load(t){const i=[],{features:s}=t,r=this._inferLayerProperties(s,t.fields),n=t.fields||[],a=null!=t.hasM?t.hasM:!!r.hasM,p=null!=t.hasZ?t.hasZ:!!r.hasZ,h=!t.spatialReference&&!r.spatialReference,g=h?q:t.spatialReference||r.spatialReference,I=h?O:null,b=t.geometryType||r.geometryType,F=!b;let j=t.objectIdField||r.objectIdField,Q=t.timeInfo;const w=new E(n);if(!F&&(h&&i.push({name:"feature-layer:spatial-reference-not-found",message:"Spatial reference not provided or found in features. Defaults to WGS84"}),!b))throw new e("feature-layer:missing-property","geometryType not set and couldn't be inferred from the provided features");if(!j)throw new e("feature-layer:missing-property","objectIdField not set and couldn't be found in the provided fields");if(r.objectIdField&&j!==r.objectIdField&&(i.push({name:"feature-layer:duplicated-oid-field",message:`Provided objectIdField "${j}" doesn't match the field name "${r.objectIdField}", found in the provided fields`}),j=r.objectIdField),j&&!r.objectIdField){const e=w.get(j);e?(j=e.name,e.type="esriFieldTypeOID",e.editable=!1,e.nullable=!1):n.unshift({alias:j,name:j,type:"esriFieldTypeOID",editable:!1,nullable:!1})}for(const o of n){if(null==o.name&&(o.name=o.alias),null==o.alias&&(o.alias=o.name),!o.name)throw new e("feature-layer:invalid-field-name","field name is missing",{field:o});if(o.name===j&&(o.type="esriFieldTypeOID"),!T.jsonValues.includes(o.type))throw new e("feature-layer:invalid-field-type",`invalid type for field "${o.name}"`,{field:o});null==o.length&&(o.length=_(o))}const S={};for(const e of n)if("esriFieldTypeOID"!==e.type&&"esriFieldTypeGlobalID"!==e.type){const t=x(e);void 0!==t&&(S[e.name]=t)}if(Q){if(Q.startTimeField){const e=w.get(Q.startTimeField);e?(Q.startTimeField=e.name,e.type="esriFieldTypeDate"):Q.startTimeField=null}if(Q.endTimeField){const e=w.get(Q.endTimeField);e?(Q.endTimeField=e.name,e.type="esriFieldTypeDate"):Q.endTimeField=null}if(Q.trackIdField){const e=w.get(Q.trackIdField);e?Q.trackIdField=e.name:(Q.trackIdField=null,i.push({name:"feature-layer:invalid-timeInfo-trackIdField",message:"trackIdField is missing",details:{timeInfo:Q}}))}Q.startTimeField||Q.endTimeField||(i.push({name:"feature-layer:invalid-timeInfo",message:"startTimeField and endTimeField are missing or invalid",details:{timeInfo:Q}}),Q=null)}const v=w.dateFields.length?{timeZoneIANA:t.dateFieldsTimeZone??R}:null;this._createDefaultAttributes=c(S,j);const A={warnings:i,featureErrors:[],layerDefinition:{...D,drawingInfo:m(b),templates:y(S),extent:I,geometryType:b,objectIdField:j,fields:n,hasZ:p,hasM:a,timeInfo:Q,dateFieldsTimeReference:v},assignedObjectIds:{}},M={type:"object-id",fieldName:j};if(this._queryEngine=new f({fieldsIndex:E.fromLayerJSON({fields:n,timeInfo:Q,dateFieldsTimeReference:v}),geometryType:b,hasM:a,hasZ:p,featureIdInfo:M,spatialReference:g,featureStore:new u({geometryType:b,hasM:a,hasZ:p}),timeInfo:Q}),!s?.length)return this._nextObjectId=o,A;const Z=l(j,s);return this._nextObjectId=Z+1,await d(s,g),this._loadInitialFeatures(A,s)}async applyEdits(e){const{spatialReference:t,geometryType:i}=this._queryEngine;return await Promise.all([g(t,i),d(e.adds,t),d(e.updates,t)]),this._applyEdits(e)}queryFeatures(e,t={}){return this._queryEngine.executeQuery(e,t.signal)}queryFeatureCount(e,t={}){return this._queryEngine.executeQueryForCount(e,t.signal)}queryObjectIds(e,t={}){return this._queryEngine.executeQueryForIds(e,t.signal)}queryExtent(e,t={}){return this._queryEngine.executeQueryForExtent(e,t.signal)}querySnapping(e,t={}){return this._queryEngine.executeQueryForSnapping(e,t.signal)}queryAttributeBins(e,t={}){return this._queryEngine.executeAttributeBinsQuery(e,t.signal)}_inferLayerProperties(e,i){let s,r,n=null,a=null,o=null;for(const l of e){const e=l.geometry;if(null!=e&&(n||(n=t(e)),a||(a=e.spatialReference),null==s&&(s=Q(e)),null==r&&(r=w(e)),n&&a&&null!=s&&null!=r))break}if(i&&i.length){let e=null;i.some(t=>{const i="esriFieldTypeOID"===t.type,s=!t.type&&t.name&&"objectid"===t.name.toLowerCase();return e=t,i||s})&&(o=e.name)}return{geometryType:n,spatialReference:a,objectIdField:o,hasM:r,hasZ:s}}async _loadInitialFeatures(e,i){const{geometryType:s,hasM:n,hasZ:a,objectIdField:o,spatialReference:l,featureStore:u,fieldsIndex:d}=this._queryEngine,f=[],c={type:"object-id",fieldName:o};for(const r of i){if(null!=r.uid&&(e.assignedObjectIds[r.uid]=-1),r.geometry&&s!==t(r.geometry)){e.featureErrors.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),n=b(d,i,r.attributes,!0);n?e.featureErrors.push(n):(this._assignObjectId(i,r.attributes,!0),r.attributes=i,null!=r.uid&&(e.assignedObjectIds[r.uid]=r.attributes[o]),null!=r.geometry&&(r.geometry=p(r.geometry,r.geometry.spatialReference,l)),f.push(r))}u.addMany(r([],f,s,a,n,c));const{fullExtent:y,timeExtent:m}=await this._queryEngine.fetchRecomputedExtents();if(e.layerDefinition.extent=y,m){const{start:t,end:i}=m;e.layerDefinition.timeInfo.timeExtent=[t,i]}return e}async _applyEdits(e){const{adds:t,updates:i,deletes:s}=e,r={addResults:[],deleteResults:[],updateResults:[],uidToObjectId:{}};if(t?.length&&this._applyAddEdits(r,t),i?.length&&this._applyUpdateEdits(r,i),s?.length){for(const e of s)r.deleteResults.push(F(e));this._queryEngine.featureStore.removeManyById(s)}const{fullExtent:n,timeExtent:a}=await this._queryEngine.fetchRecomputedExtents();return{extent:n,timeExtent:a,featureEditResults:r}}_applyAddEdits(e,i){const{addResults:s}=e,{geometryType:n,hasM:a,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,featureIdInfo:f,fieldsIndex:c}=this._queryEngine,y=[];for(const r of i){if(r.geometry&&n!==t(r.geometry)){s.push(I("Incorrect geometry type."));continue}const i=this._createDefaultAttributes(),a=b(c,i,r.attributes);if(a)s.push(a);else{if(this._assignObjectId(i,r.attributes),r.attributes=i,null!=r.uid){const t=r.attributes[l];e.uidToObjectId[r.uid]=t}if(null!=r.geometry){const e=r.geometry.spatialReference??u;r.geometry=p(j(r.geometry,e),e,u)}y.push(r),s.push(F(r.attributes[l]))}}d.addMany(r([],y,n,o,a,f))}_applyUpdateEdits({updateResults:e},i){const{geometryType:s,hasM:r,hasZ:o,objectIdField:l,spatialReference:u,featureStore:d,fieldsIndex:f,featureIdInfo:c}=this._queryEngine;for(const y of i){const{attributes:i,geometry:m}=y,h=i?.[l];if(null==h){e.push(I(`Identifier field ${l} missing`));continue}if(!d.has(h)){e.push(I(`Feature with object id ${h} missing`));continue}const g=n(d.getFeature(h),s,o,r);if(null!=m){if(s!==t(m)){e.push(I("Incorrect geometry type."));continue}const i=m.spatialReference??u;g.geometry=p(j(m,i),i,u)}if(i){const t=b(f,g.attributes,i);if(t){e.push(t);continue}}d.add(a(g,s,o,r,c)),e.push(F(h))}}_assignObjectId(e,t,i=!1){const s=this._queryEngine.objectIdField;i&&t&&isFinite(t[s])?e[s]=t[s]:e[s]=this._nextObjectId++}}export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import s from"../../../../core/Collection.js";import{toConst as r}from"../../../../core/compilerUtils.js";import o from"../../../../core/Error.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{QueueProcessor as n}from"../../../../core/QueueProcessor.js";import a from"../../../../geometry/SpatialReference.js";import{set as u,create as p,expandWithRect as l,expandWithAABB as c,negativeInfinity as d,fromRect as f}from"../../../../geometry/support/aaBoundingBox.js";import{getQueryResultExtent as m,QueryEngine as y}from"../../data/QueryEngine.js";import{QueryEngineResult as h}from"../../data/QueryEngineResult.js";import{createDrawingInfo as g}from"./clientSideDefaults.js";import _ from"../../../support/Field.js";import w from"../../../support/FieldsIndex.js";import{collectSQLFieldNames as I}from"../../../support/fieldUtils.js";import{fromParquetEncodingJSON as R}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as x,fromParquetJSONGeometryType as S,toParquetJSONGeometryType as F}from"../../../support/parquetUtils.js";import{createParquetFile as C,readGeoMetadata as q}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as b}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as v}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as O}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as j}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as Q}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const A=new b,B=8e3,T="__OBJECTID";class G{constructor(){this._fileInfos=new Map,this._queue=new n({concurrency:1,process:(e,t)=>this._executeQuery(e,t)})}async load(r){const n=r.spatialReference?a.fromJSON(r.spatialReference):void 0;if(n&&!n.isWGS84&&!n.isWebMercator)throw new o("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");const c=await x({urls:new s(r.urls),fields:r.fields?.map(e=>_.fromJSON(e)),encoding:r.encoding?R(r.encoding):r.encoding,geometryType:r.geometryType?S(r.geometryType):null,spatialReference:n},{customParameters:r.customParameters});let f;if(c.geometryType&&c.encoding){if(!c.spatialReference)throw new o("parquet:unsupported","SpatialReference must be defined");if(!c.spatialReference.isGeographic&&!c.spatialReference.isWebMercator)throw new o("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");c.spatialReference.isGeographic&&!c.spatialReference.isWGS84&&(i.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:c.spatialReference}),c.spatialReference=a.WGS84),f={geometryType:F(c.geometryType),spatialReference:c.spatialReference.toJSON(),encoding:c.encoding.toJSON(),displayOptimization:c.displayOptimization}}this.setCustomParameters(r.customParameters),this._geometryInfo=f;for(const e of r.urls){const t=await C(e,{geometryInfo:f,outSpatialReference:null,getCustomParameters:()=>this._customParameters});this._fileInfos.set(e,{index:this._fileInfos.size,file:t})}this._capabilities=k(await this.getFileStatistics());const m=this._fileInfos.values().next().value?.file;if(!m)return{layerDefinition:{},capabilities:k(null)};const{fields:y}=c;if(null==y)throw new o("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",y);y.push(new _({name:T,type:"oid",alias:T}));const h={fields:y.map(e=>({...e.toJSON(),column:m.columnForFieldName(e.name)})),timeZoneByFieldName:null},I=w.fromJSON(h);this._fieldsIndex=I;const q=F(c.geometryType??"point");if(this._metadata=j.createFeature({fieldsIndex:h,geometryType:q,featureIdInfo:{type:"object-id",fieldName:"rowId"},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:c.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:f?.geometryType??"esriGeometryPoint",featureIdInfo:{type:"object-id",fieldName:"rowId"},hasM:!1,hasZ:!1,spatialReference:f?.spatialReference??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},c.spatialReference&&(this._fullExtent=U(this._fileInfos.values(),c.spatialReference.toJSON())),null==this._fullExtent&&"location"===c.encoding?.type){const{latitudeFieldName:s,longitudeFieldName:r}=c.encoding,o=this._fieldsIndex.get(s)?.column,i=this._fieldsIndex.get(r)?.column,n=u(p(),d);for(const a of this._fileInfos.values())for(const s of a.file.rowGroups()){const r={stack:[],error:void 0,hasError:!1};try{const t=e(r,s.columnDescriptorForAttribute(o),!1),a=e(r,s.columnDescriptorForAttribute(i),!1),u=[a.minValue(),t.minValue(),a.maxValue(),t.maxValue()];l(n,u),s.free()}catch(b){r.error=b,r.hasError=!0}finally{t(r)}}this._fullExtent={xmin:n[0],ymin:n[1],xmax:n[3],ymax:n[4],spatialReference:c.spatialReference?.toJSON()}}return{capabilities:this._capabilities,layerDefinition:{fields:c.fields?.map(e=>e.toJSON()),drawingInfo:g(q),extent:this._fullExtent??void 0,geometryType:q,encoding:c.encoding?.toJSON(),displayOptimization:c.displayOptimization}}}destroy(){for(const e of this._fileInfos.values())e.file.free();this._fileInfos.clear(),this._queue.destroy()}setCustomParameters(e){this._customParameters=e}getFileStatistics(){if(!this._fileInfos.size)return null;const e=Array.from(this._fileInfos.values()).reduce((e,t)=>e+t.file.byteLength(),0);return{featureCount:this._getFeatureCount(),byteLength:e}}async updateFiles(e){const t=new Set(e);for(const[s,r]of this._fileInfos.entries())t.has(s)?t.delete(s):(r.file.free(),this._fileInfos.delete(s));for(const s of t){const e=await C(s,{geometryInfo:this._geometryInfo,outSpatialReference:null,getCustomParameters:()=>this._customParameters});this._fileInfos.set(s,{index:this._fileInfos.size,file:e})}}async queryFeatures(e,t){this._validateQuery(e),N(e)||(e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0),(e.outStatistics||e.returnDistinctValues)&&delete e.returnGeometry;return(await this._enqueueQuery(e,t)).createQueryResponse()}async queryFeatureCount(e,t){if(this._validateQuery(e),!D(e))return this._getFeatureCount();delete e.outFields,delete e.returnGeometry;return(await this._enqueueQuery(e,t)).createQueryResponseForCount()}async queryObjectIds(e,t){if(this._validateQuery(e),!D(e))return Array.from({length:this._getFeatureCount()},(e,t)=>t);e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0,delete e.returnGeometry,delete e.outFields;return(await this._enqueueQuery(e,t)).items.map(e=>e.getObjectId())}async queryExtent(e,t){if(this._validateQuery(e),this._fullExtent&&!D(e))return{count:this._getFeatureCount(),extent:this._fullExtent};const s=r(this._metadata.spatialReference);e.returnGeometry=!0,delete e.outFields;const o=u(p(),d),i=p(),n=await this._enqueueQuery(e,t);let a=0;for(const r of n.items)r.getBounds(i)&&(c(o,i),a+=1);return{count:a,extent:m(o,s,e.outSR?r(e.outSR):s,s,!1)}}_getFeatureCount(){return Array.from(this._fileInfos.values()).reduce((e,t)=>e+t.file.numRows(),0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new o("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new o("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new o("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async*_fetchChunks(e,t){for(const s of this._fileInfos.values()){const r=s.file.numRows(),o=Math.ceil(r/B);for(let i=0;i<o;i++){const r=i*B,o=await s.file.readChunk(r,B,e.fields,e.returnGeometry,t);for(const e of o){const t=new Q(this._metadata,this._fieldsIndex,e,0,s.index),r=new v(t,null,0,!1),o=P(this._metadata,[r],this._queryEngineParams);yield o}}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){const s=await this._getReadParams(e);if(e.objectIds?.length)for(const n of this._fileInfos.values()){const r=[],o=(await n.file.readChunksByRowId(new Uint32Array(e.objectIds),s.fields,s.returnGeometry,t)).map((e,t)=>new Q(this._metadata,this._fieldsIndex,e,t,n.index)).map((e,t)=>new v(e,null,t,!1)),i=P(this._metadata,o,this._queryEngineParams),a=await i.executeQueryForOpaqueFeatures(e,t);for(const e of a)r.push(e);return new h(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._metadata.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:A})}let r=e.resultRecordCount??this._getFeatureCount(),o=e.resultOffset??0;delete e.resultRecordCount,delete e.resultOffset;const i=[];for await(const n of this._fetchChunks(s,t)){const s=await n.executeQueryForOpaqueFeatures(e,t);if(s.length>o){const t=s.slice(o,Math.min(o+r,s.length));for(const e of t)i.push(e);if(o=0,r-=t.length,0===r)return new h(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._metadata.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:A})}else o-=s.length}return new h(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._metadata.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:A})}async _getReadParams(e){const t=new Set;if(e.where&&await I(t,this._fieldsIndex,e.where),e.outStatistics)for(const s of e.outStatistics)null!=s.onStatisticField&&t.add(s.onStatisticField);if(e.outFields)for(const s of e.outFields)t.add(s);return{fields:this._getAttributeIds(Array.from(t)),returnGeometry:!!e.returnGeometry||!!e.geometry}}_getAttributeIds(e){if(null==e)return new Uint32Array;if(e.includes("*"))return new Uint32Array(this._fieldsIndex.fields.map(e=>e.column).filter(e=>null!=e));const t=[];for(const s of e){const e=this._fieldsIndex.get(s);if(null==e)throw new o("unknown-field",`Field ${s} does not exist`);null==e.column||t.push(e.column)}return new Uint32Array(t)}}function D(e){return Object.keys(e).some(e=>E(e))}function E(e){switch(e){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"where":case"objectIds":case"historicMoment":return!0;default:return!1}}function P(e,t,s){const r=new O(()=>e);for(const o of t)r.insert(o);return new y({...s,featureStore:r})}function M(e){switch(e.length){case 4:return f(p(),e);case 6:return e;default:throw new o("parquet:protocol-violation","Invalid Geoparquet file. BoundingBox size must be 4 or 6.",{bbox:e})}}function U(e,t){const s=u(p(),d);for(const r of e){const e=q(r.file);if(!e)return null;const t=e.columns[e.primary_column];if(!t.bbox)return null;const o=M(t.bbox);c(s,o)}return{xmin:s[0],ymin:s[1],xmax:s[3],ymax:s[4],spatialReference:t}}function k(e){const t=e?.featureCount;let s=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(s=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:8e3,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!0,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:s,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:s,supportsPagination:!0,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:s,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function N(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{G as default};
5
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import s from"../../../../core/Collection.js";import{toConst as r}from"../../../../core/compilerUtils.js";import o from"../../../../core/Error.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{QueueProcessor as n}from"../../../../core/QueueProcessor.js";import a from"../../../../geometry/SpatialReference.js";import{set as u,create as p,expandWithRect as l,expandWithAABB as c,negativeInfinity as d,fromRect as f}from"../../../../geometry/support/aaBoundingBox.js";import{getQueryResultExtent as m,QueryEngine as y}from"../../data/QueryEngine.js";import{QueryEngineResult as h}from"../../data/QueryEngineResult.js";import{createDrawingInfo as g}from"./clientSideDefaults.js";import _ from"../../../support/Field.js";import w from"../../../support/FieldsIndex.js";import{collectSQLFieldNames as I}from"../../../support/fieldUtils.js";import{fromParquetEncodingJSON as R}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as x,fromParquetJSONGeometryType as S,toParquetJSONGeometryType as F}from"../../../support/parquetUtils.js";import{createParquetFile as C,readGeoMetadata as q}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as b}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as v}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as O}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as j}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as Q}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const A=new b,B=8e3,T="__OBJECTID";class G{constructor(){this._fileInfos=new Map,this._queue=new n({concurrency:1,process:(e,t)=>this._executeQuery(e,t)})}async load(r){const n=r.spatialReference?a.fromJSON(r.spatialReference):void 0;if(n&&!n.isWGS84&&!n.isWebMercator)throw new o("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");const c=await x({urls:new s(r.urls),fields:r.fields?.map(e=>_.fromJSON(e)),encoding:r.encoding?R(r.encoding):r.encoding,geometryType:r.geometryType?S(r.geometryType):null,spatialReference:n},{customParameters:r.customParameters});let f;if(c.geometryType&&c.encoding){if(!c.spatialReference)throw new o("parquet:unsupported","SpatialReference must be defined");if(!c.spatialReference.isGeographic&&!c.spatialReference.isWebMercator)throw new o("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");c.spatialReference.isGeographic&&!c.spatialReference.isWGS84&&(i.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:c.spatialReference}),c.spatialReference=a.WGS84),f={geometryType:F(c.geometryType),spatialReference:c.spatialReference.toJSON(),encoding:c.encoding.toJSON(),displayOptimization:c.displayOptimization}}this.setCustomParameters(r.customParameters),this._geometryInfo=f;for(const e of r.urls){const t=await C(e,{geometryInfo:f,outSpatialReference:null,getCustomParameters:()=>this._customParameters});this._fileInfos.set(e,{index:this._fileInfos.size,file:t})}this._capabilities=k(await this.getFileStatistics());const m=this._fileInfos.values().next().value?.file;if(!m)return{layerDefinition:{},capabilities:k(null)};const{fields:y}=c;if(null==y)throw new o("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",y);y.push(new _({name:T,type:"oid",alias:T}));const h={fields:y.map(e=>({...e.toJSON(),column:m.columnForFieldName(e.name)})),timeZoneByFieldName:null},I=w.fromJSON(h);this._fieldsIndex=I;const q=F(c.geometryType??"point");if(this._metadata=j.createFeature({fieldsIndex:h,geometryType:q,featureIdInfo:{type:"object-id",fieldName:"rowId"},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:c.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:f?.geometryType??"esriGeometryPoint",featureIdInfo:{type:"object-id",fieldName:"rowId"},hasM:!1,hasZ:!1,spatialReference:f?.spatialReference??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},c.spatialReference&&(this._fullExtent=U(this._fileInfos.values(),c.spatialReference.toJSON())),null==this._fullExtent&&"location"===c.encoding?.type){const{latitudeFieldName:s,longitudeFieldName:r}=c.encoding,o=this._fieldsIndex.get(s)?.column,i=this._fieldsIndex.get(r)?.column,n=u(p(),d);for(const a of this._fileInfos.values())for(const s of a.file.rowGroups()){const r={stack:[],error:void 0,hasError:!1};try{const t=e(r,s.columnDescriptorForAttribute(o),!1),a=e(r,s.columnDescriptorForAttribute(i),!1),u=[a.minValue(),t.minValue(),a.maxValue(),t.maxValue()];l(n,u),s.free()}catch(b){r.error=b,r.hasError=!0}finally{t(r)}}this._fullExtent={xmin:n[0],ymin:n[1],xmax:n[3],ymax:n[4],spatialReference:c.spatialReference?.toJSON()}}return{capabilities:this._capabilities,layerDefinition:{fields:c.fields?.map(e=>e.toJSON()),drawingInfo:g(q),extent:this._fullExtent??void 0,geometryType:q,encoding:c.encoding?.toJSON(),displayOptimization:c.displayOptimization}}}destroy(){for(const e of this._fileInfos.values())e.file.free();this._fileInfos.clear(),this._queue.destroy()}setCustomParameters(e){this._customParameters=e}getFileStatistics(){if(!this._fileInfos.size)return null;const e=Array.from(this._fileInfos.values()).reduce((e,t)=>e+t.file.byteLength(),0);return{featureCount:this._getFeatureCount(),byteLength:e}}async updateFiles(e){const t=new Set(e);for(const[s,r]of this._fileInfos.entries())t.has(s)?t.delete(s):(r.file.free(),this._fileInfos.delete(s));for(const s of t){const e=await C(s,{geometryInfo:this._geometryInfo,outSpatialReference:null,getCustomParameters:()=>this._customParameters});this._fileInfos.set(s,{index:this._fileInfos.size,file:e})}}async queryFeatures(e,t){this._validateQuery(e),N(e)||(e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0),(e.outStatistics||e.returnDistinctValues)&&delete e.returnGeometry;return(await this._enqueueQuery(e,t)).createQueryResponse()}async queryFeatureCount(e,t){if(this._validateQuery(e),!D(e))return this._getFeatureCount();delete e.outFields,delete e.returnGeometry;return(await this._enqueueQuery(e,t)).createQueryResponseForCount()}async queryObjectIds(e,t){if(this._validateQuery(e),!D(e))return Array.from({length:this._getFeatureCount()},(e,t)=>t);e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0,delete e.returnGeometry,delete e.outFields;return(await this._enqueueQuery(e,t)).items.map(e=>e.getObjectId())}async queryExtent(e,t){if(this._validateQuery(e),this._fullExtent&&!D(e))return{count:this._getFeatureCount(),extent:this._fullExtent};const s=r(this._metadata.spatialReference);e.returnGeometry=!0,delete e.outFields;const o=u(p(),d),i=p(),n=await this._enqueueQuery(e,t);let a=0;for(const r of n.items)r.getBounds(i)&&(c(o,i),a+=1);return{count:a,extent:m(o,s,e.outSR?r(e.outSR):s,s,!1)}}_getFeatureCount(){return Array.from(this._fileInfos.values()).reduce((e,t)=>e+t.file.numRows(),0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new o("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new o("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new o("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async*_fetchChunks(e,t){for(const s of this._fileInfos.values()){const r=s.file.numRows(),o=Math.ceil(r/B);for(let i=0;i<o;i++){const r=i*B,o=await s.file.readChunk(r,B,e.fields,e.returnGeometry,t);for(const e of o){const t=new Q(this._metadata,this._fieldsIndex,e,0,s.index),r=new v(t,null,0,!1),o=P(this._metadata,[r],this._queryEngineParams);yield o}}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){const s=await this._getReadParams(e);if(e.objectIds?.length)for(const n of this._fileInfos.values()){const r=[],o=(await n.file.readChunksByRowId(new Uint32Array(e.objectIds),s.fields,s.returnGeometry,t)).map((e,t)=>new Q(this._metadata,this._fieldsIndex,e,t,n.index)).map((e,t)=>new v(e,null,t,!1)),i=P(this._metadata,o,this._queryEngineParams),a=await i.executeQueryForOpaqueFeatures(e,t);for(const e of a)r.push(e);return new h(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._metadata.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:A})}let r=e.resultRecordCount??this._getFeatureCount(),o=e.resultOffset??0;delete e.resultRecordCount,delete e.resultOffset;const i=[];for await(const n of this._fetchChunks(s,t)){const s=await n.executeQueryForOpaqueFeatures(e,t);if(s.length>o){const t=s.slice(o,Math.min(o+r,s.length));for(const e of t)i.push(e);if(o=0,r-=t.length,0===r)return new h(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._metadata.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:A})}else o-=s.length}return new h(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._metadata.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:A})}async _getReadParams(e){const t=new Set;if(e.where&&await I(t,this._fieldsIndex,e.where),e.outStatistics)for(const s of e.outStatistics)null!=s.onStatisticField&&t.add(s.onStatisticField);if(e.outFields)for(const s of e.outFields)t.add(s);return{fields:this._getAttributeIds(Array.from(t)),returnGeometry:!!e.returnGeometry||!!e.geometry}}_getAttributeIds(e){if(null==e)return new Uint32Array;if(e.includes("*"))return new Uint32Array(this._fieldsIndex.fields.map(e=>e.column).filter(e=>null!=e));const t=[];for(const s of e){const e=this._fieldsIndex.get(s);if(null==e)throw new o("unknown-field",`Field ${s} does not exist`);null==e.column||t.push(e.column)}return new Uint32Array(t)}}function D(e){return Object.keys(e).some(e=>E(e))}function E(e){switch(e){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"where":case"objectIds":case"historicMoment":return!0;default:return!1}}function P(e,t,s){const r=new O(()=>e);for(const o of t)r.insert(o);return new y({...s,featureStore:r})}function M(e){switch(e.length){case 4:return f(p(),e);case 6:return e;default:throw new o("parquet:protocol-violation","Invalid Geoparquet file. BoundingBox size must be 4 or 6.",{bbox:e})}}function U(e,t){const s=u(p(),d);for(const r of e){const e=q(r.file);if(!e)return null;const t=e.columns[e.primary_column];if(!t.bbox)return null;const o=M(t.bbox);c(s,o)}return{xmin:s[0],ymin:s[1],xmax:s[3],ymax:s[4],spatialReference:t}}function k(e){const t=e?.featureCount;let s=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(s=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:8e3,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!0,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:s,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:s,supportsPagination:!0,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:s,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function N(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{G as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{queryBinsCapabilities as s,queryCapabilities as r}from"../../data/QueryEngineCapabilities.js";import{defaultPointSymbolJSON as e,defaultPolylineSymbolJSON as p,defaultPolygonSymbolJSON as o}from"../../../../symbols/support/defaultsJSON.js";function u(t){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?e:"esriGeometryPolyline"===t?p:o}}}const n=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let i=1;function a(t,s){if(has("esri-csp-restrictions"))return()=>({[s]:null,...t});try{let r=`this${c(s)} = null;`;for(const s in t){r+=`this${c(s)} = ${JSON.stringify(t[s])};`}const e=new Function(`\n return class AttributesClass$${i++} {\n constructor() {\n ${r};\n }\n }\n `)();return()=>new e}catch(r){return()=>({[s]:null,...t})}}function c(t){return n.test(t)?`.${t}`:`["${t}"]`}function l(s={}){return[{name:"New Feature",description:"",prototype:{attributes:t(s)}}]}function y(t,e){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:e,supportsDelete:e,supportsEditing:e,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!0,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:e,supportsExceedsLimitStatistics:!0,supportsAsyncConvert3D:!1},query:r,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:s,editing:{supportsGeometryUpdate:e,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}export{y as createCapabilities,a as createDefaultAttributesFunction,l as createDefaultTemplate,u as createDrawingInfo};
5
+ import has from"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{queryBinsCapabilities as s,queryCapabilities as r}from"../../data/QueryEngineCapabilities.js";import{defaultPointSymbolJSON as e,defaultPolylineSymbolJSON as p,defaultPolygonSymbolJSON as o}from"../../../../symbols/support/defaultsJSON.js";function u(t){return{renderer:{type:"simple",symbol:"esriGeometryPoint"===t||"esriGeometryMultipoint"===t?e:"esriGeometryPolyline"===t?p:o}}}const n=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;let i=1;function a(t,s){if(has("esri-csp-restrictions"))return()=>({[s]:null,...t});try{let r=`this${c(s)} = null;`;for(const s in t){r+=`this${c(s)} = ${JSON.stringify(t[s])};`}const e=new Function(`\n return class AttributesClass$${i++} {\n constructor() {\n ${r};\n }\n }\n `)();return()=>new e}catch(r){return()=>({[s]:null,...t})}}function c(t){return n.test(t)?`.${t}`:`["${t}"]`}function l(s={}){return[{name:"New Feature",description:"",prototype:{attributes:t(s)}}]}function y(t,e){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:e,supportsDelete:e,supportsEditing:e,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!0,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:e,supportsExceedsLimitStatistics:!0,supportsAsyncConvert3D:!1},query:r,queryRelated:{supportsCount:!0,supportsOrderBy:!0,supportsPagination:!0,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:s,editing:{supportsGeometryUpdate:e,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}export{y as createCapabilities,a as createDefaultAttributesFunction,l as createDefaultTemplate,u as createDrawingInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../PopupTemplate.js";import r from"../../core/Error.js";import{clone as i}from"../../core/lang.js";import o from"../../core/Logger.js";import{MultiOriginJSONMixin as s}from"../../core/MultiOriginJSONSupport.js";import"../../core/workers/workers.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import l from"../../geometry/Extent.js";import y from"../../geometry/Point.js";import u from"../../geometry/Polygon.js";import d from"../../geometry/Polyline.js";import{initializeProjection as m,project as h}from"../../geometry/projectionUtils.js";import c from"../../geometry/SpatialReference.js";import{wgs84 as g}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import b from"../../graphic/KnowledgeGraphGraphicOrigin.js";import j from"../../graphic/LinkChartGraphicOrigin.js";import w from"../Layer.js";import T from"../graphics/data/FeatureStore.js";import{QueryEngine as v}from"../graphics/data/QueryEngine.js";import{createDrawingInfo as I,createCapabilities as O}from"../graphics/sources/support/clientSideDefaults.js";import{systemOidFieldName as E,systemAggregationCountFieldName as S,systemIsSpatialFieldName as x,systemLayoutGeometryFieldName as N,systemOriginIdFieldName as L,systemDestinationIdFieldName as F}from"./constants.js";import{KnowledgeGraphSublayerBase as R}from"./KnowledgeGraphSublayerBase.js";import{getDisplayLabelProperty as _,getLinkChartDefaultLabelingInfo as k,getMapDefaultLabelingInfo as C,getKGSublayerSymbolColor as Q,getDefaultLCRelationshipSublayerSymbol as M,convertLayerEditsToGraphEdits as P,convertGraphEditsResultToFeatureEdits as G}from"./layerUtils.js";import{BlendLayer as D,blendModeProperty as J,effectProperty as q}from"../mixins/BlendLayer.js";import{DisplayFilteredLayer as U,displayFilterEnabledProperty as A,displayFilterInfoProperty as B}from"../mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as Z,featureEffectProperty as K}from"../mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as V}from"../mixins/FeatureReductionLayer.js";import{OrderedLayer as H,orderByProperty as W}from"../mixins/OrderedLayer.js";import{RefreshableLayer as Y}from"../mixins/RefreshableLayer.js";import{ScaleRangeLayer as z}from"../mixins/ScaleRangeLayer.js";import{TemporalLayer as X,useViewTimeProperty as $}from"../mixins/TemporalLayer.js";import{legendEnabled as ee,maxScale as te,minScale as re,opacity as ie,popupEnabled as oe}from"../support/commonProperties.js";import{featureReductionProperty as se}from"../support/featureReductionUtils.js";import ne from"../support/Field.js";import{fixRendererFields as ae,fixTimeInfoFields as pe}from"../support/fieldUtils.js";import le from"../support/LabelClass.js";import{reader as ye}from"../support/labelingInfo.js";import ue from"../support/TimeInfo.js";import de from"../../renderers/SimpleRenderer.js";import{fromJSON as me}from"../../renderers/support/jsonUtils.js";import{rendererTypes as he}from"../../renderers/support/typeUtils.js";import{executeApplyEdits as ce}from"../../rest/knowledgeGraphService.js";import ge from"../../rest/support/FeatureSet.js";import fe from"../../rest/support/Query.js";import{createPopupTemplate as be}from"../../support/popupUtils.js";import{applyColorToSymbol as je}from"../../symbols/support/utils.js";import we from"../../core/workers/RemoteClient.js";function Te(e){if(!e.json)return e;e.json.write=ve(e.json.write);const t=e.json.origins;if(!t)return e;let r;for(r in t){const e=t[r];e&&(e.write=ve(e.write))}return e}function ve(e){return"object"==typeof e&&e?(!1!==e.enabled&&(e.overridePolicy=Ie(e)),e):!0===e?Oe():e}function Ie(e){const{target:t,writer:r,overridePolicy:i,...o}=e;return function(e,t){const r=Ee.call(this,e,t);return r.enabled?{...o,...r}:r}}function Oe(){return{overridePolicy:Ee}}function Ee(e,t){const r=!!this.geometryType;let i={enabled:r};return r&&(i={...i,...Se.call(this,e,t)}),i}function Se(e,t){return{ignoreOrigin:this.originIdOf(t)>0}}function xe(){const e=O(!1,!0);return e.editing.supportsDeleteByOthers=!0,e.editing.supportsGeometryUpdate=!0,e.editing.supportsUpdateByOthers=!0,e}let Ne=class extends(R(U(V(Z(D(H(X(z(Y(s(w))))))))))){constructor(e){super(e),this.blendMode="normal",this.capabilities=xe(),this.editingEnabled=!0,this.charts=null,this.definitionExpression=null,this.displayFilterEnabled=!0,this.displayFilterInfo=null,this.effect=null,this.elevationInfo=null,this.featureEffect=null,this.graphType=null,this.labelsVisible=!0,this.layerType=null,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.objectIdField=E,this.objectType=null,this.opacity=1,this.orderBy=null,this.parent=null,this.parentCompositeLayer=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.refreshInterval=0,this.source={openPorts:()=>this.load().then(()=>{const e=new MessageChannel;return new we(e.port1,{channel:e,client:{queryFeatures:(e,t={})=>{const r=fe.fromJSON(e);return this.queryFeaturesJSON(r,t)}}}),[e.port2]})},this.type="knowledge-graph-sublayer",this.useViewTime=!0,this.visible=!0}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}get isTable(){return"link-chart"!==this.parentCompositeLayer.type&&null==this.geometryFieldName}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}get fields(){const e=[];return this.objectType?.properties?.forEach(t=>{const r="esriFieldTypeOID"===t.fieldType?"esriFieldTypeInteger":t.fieldType;e.push(ne.fromJSON({name:t.name,type:r,alias:t.alias,defaultValue:t.defaultValue,editable:t.editable,nullable:t.nullable}))}),e.push(ne.fromJSON({name:this.objectIdField,type:"esriFieldTypeString",alias:this.objectIdField,editable:!1}),ne.fromJSON({name:S,type:"esriFieldTypeInteger",alias:S,editable:!1}),ne.fromJSON({name:x,type:"esriFieldTypeInteger",alias:x,editable:!1})),e}get geometryType(){if("link-chart"===this.parentCompositeLayer?.type)return"relationship"===this.graphType?"polyline":"point";const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.geometryType;return t&&"esriGeometryNull"!==t?f.fromJSON(t):null}get geometryFieldName(){if("link-chart"===this.parentCompositeLayer?.type)return N;const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name);return e?.name??null}get graphicOrigin(){if(!this.parent)return null;switch(this.parent.type){case"knowledge-graph":return new b(this.parent,this);case"link-chart":return new j(this.parent,this)}}get graphTypeName(){return this.objectType?.name}set graphTypeName(e){this._set("graphTypeName",e)}get hasM(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasM??!1}get hasZ(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasZ??!1}set labelingInfo(e){this._set("labelingInfo",e)}get labelingInfo(){if(this._isOverridden("labelingInfo"))return this._get("labelingInfo");if(!this.objectType||!this.parentCompositeLayer||!this.graphTypeName)return null;const e=this.objectType.properties?_(this.objectType.properties):"ESRI__ID";return"link-chart"===this.parentCompositeLayer.type?k(this.graphType,this.graphTypeName,e):C(this.graphTypeName,this.geometryType,e)}set renderer(e){ae(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const e=this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel,t=[...e?.entityTypes??[],...e?.relationshipTypes??[]].map(e=>e.name).indexOf(this.graphTypeName),r=Q(t);if("link-chart"===this.parentCompositeLayer?.type){if("relationship"===this.graphType)return new de({type:"simple",symbol:M(r)});const e=me(I(f.toJSON("point")).renderer);return je(e.symbol,r),e}const i=me(I(f.toJSON(this.geometryType)).renderer);return je(i.symbol,r),i}get spatialReference(){return this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel?.spatialReference??c.WGS84}set timeInfo(e){this._set("timeInfo",e)}get title(){return this._isOverridden("title")?this._get("title"):this.graphTypeName}set title(e){this._set("title",e)}writeTitle(e,t){t.title=e??"Layer"}createPopupTemplate(e){return be(this,e)}createQuery(){return new fe({where:"1=1",outFields:["*"]})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){return null}async queryFeatures(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e),o=this.graphicOrigin,s=ge.fromJSON(await i.executeQuery(r.toJSON(),t?.signal));return s.features.forEach(e=>{e.sourceLayer=this,e.origin=o}),s}async queryFeaturesJSON(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return await i.executeQuery(r.toJSON(),t?.signal)}async queryFeatureCount(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return i.executeQueryForCount(r.toJSON(),t?.signal)}async queryExtent(e={},t){await this.load();const r={...e,returnGeometry:!0},{resolvedQuery:i,queryEngine:o}=await this._setupQueryObjects(r),s=await o.executeQueryForExtent(i.toJSON(),t?.signal);let n;return n=null!=s.extent?.xmin&&null!=s.extent?.xmax&&null!=s.extent?.ymin&&null!=s.extent?.ymax?new l(s.extent):new l,{count:s.count,extent:n}}async queryObjectIds(e,t){await this.load();const r=fe.from(e);let i;if("link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)i=this._cachedQueryEngine;else{const e=await this.parentCompositeLayer.dataManager.getData(r,this,t);i=this.loadQueryEngine(e)}return await i.executeQueryForIds(r.toJSON(),t?.signal)}async applyEdits(e){if(!this.parentCompositeLayer.dataManager.knowledgeGraph)throw new r("knowledge-graph-sublayer:no-knowledge-graph","ApplyEdits cannot be executed because the parent does not have a Knowledge Graph model. This is usually caused by the layer not yet being loaded");const t=P(e,this);t.options={cascadeDelete:!0,cascadeProvenanceDelete:!!this.parent?.knowledgeGraph.serviceDefinition.supportsProvenance||void 0};const i=await ce(this.parentCompositeLayer.dataManager.knowledgeGraph,t),o=G(i,this.graphTypeName),s={addedFeatures:o.addFeatureResults,updatedFeatures:o.updateFeatureResults,deletedFeatures:o.deleteFeatureResults,addedAttachments:o.addAttachmentResults,deletedAttachments:o.deleteAttachmentResults,updatedAttachments:o.updateAttachmentResults,exceededTransferLimit:!1,historicMoment:new Date,edits:void 0};return this.emit("edits",s),this.emit("apply-edits",{result:Promise.resolve(s)}),o}loadQueryEngine(e){const t=new T({geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ}),r=new v({fieldsIndex:this.fieldsIndex.toJSON(),geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ,featureIdInfo:{type:"object-id",fieldName:this.objectIdField},spatialReference:this.spatialReference.toJSON(),timeInfo:this.timeInfo?.toJSON(),featureStore:t});return r.featureStore.addMany(e),r}async refreshCachedQueryEngine(){const e=await this.parentCompositeLayer.dataManager.getData(new fe({where:"1=1",outFields:[E]}),this);this._cachedQueryEngine=this.loadQueryEngine(e)}load(e){return this.addResolvingPromise(this.parent.load(e).then(()=>pe(this.timeInfo,this.fieldsIndex))),Promise.resolve(this)}async _setupQueryObjects(e,t){const r=fe.from(e),i=r.geometry;if(i&&!i.spatialReference?.isWGS84&&(await m(i.spatialReference,g),r.geometry=h(i instanceof u||i instanceof d||i instanceof y?i:i.extent,g)),"link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)return{resolvedQuery:r,queryEngine:this._cachedQueryEngine};const o=await this.parentCompositeLayer.dataManager.getData(r,this,t);return{resolvedQuery:r,queryEngine:this.loadQueryEngine(o)}}};function Le(e,t,r){const i=[["ESRI__AGGREGATION_COUNT",S],["ESRI__ORIGIN_ID",L],["ESRI__DESTINATION_ID",F],["ESRI__LAYOUT_GEOMETRY",N]];try{for(const t of e)for(const[e,r]of i)t.labelExpression=t.labelExpression?.replaceAll(e,r),t.labelExpressionInfo?.expression&&(t.labelExpressionInfo.expression=t.labelExpressionInfo.expression.replaceAll(e,r))}catch(s){o.getLogger(this).warn("Error updating labelingInfo",s)}return ye(e,t,r)}e([n(Te(i(J)))],Ne.prototype,"blendMode",void 0),e([n()],Ne.prototype,"capabilities",void 0),e([n({readOnly:!0})],Ne.prototype,"userHasUpdateItemPrivileges",null),e([n()],Ne.prototype,"editingEnabled",void 0),e([n()],Ne.prototype,"isTable",null),e([n({json:{origins:{"web-scene":{write:!1}},write:Oe()}})],Ne.prototype,"charts",void 0),e([n({readOnly:!0})],Ne.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{origins:{service:{read:!1}},name:"layerDefinition.definitionExpression",write:{ignoreOrigin:!0}}})],Ne.prototype,"definitionExpression",void 0),e([n(Te(i(A)))],Ne.prototype,"displayFilterEnabled",void 0),e([n(Te(i(B)))],Ne.prototype,"displayFilterInfo",void 0),e([n(Te(i(q)))],Ne.prototype,"effect",void 0),e([n()],Ne.prototype,"elevationInfo",void 0),e([n(Te(i(K)))],Ne.prototype,"featureEffect",void 0),e([n(Te(i(se)))],Ne.prototype,"featureReduction",null),e([n()],Ne.prototype,"fields",null),e([n()],Ne.prototype,"geometryType",null),e([n()],Ne.prototype,"geometryFieldName",null),e([n({readOnly:!0})],Ne.prototype,"graphicOrigin",null),e([n({type:["entity","relationship"],nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ne.prototype,"graphType",void 0),e([n({type:String,nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ne.prototype,"graphTypeName",null),e([n()],Ne.prototype,"hasM",null),e([n()],Ne.prototype,"hasZ",null),e([n({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],Ne.prototype,"id",void 0),e([n({type:Boolean,value:!0,nonNullable:!0,json:{name:"showLabels",default:!1,write:{overridePolicy(){return{enabled:!!this.geometryType,alwaysWriteDefaults:!0,ignoreOrigin:!0}}}}})],Ne.prototype,"labelsVisible",void 0),e([n({type:[le],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:Le,write:Oe()}})],Ne.prototype,"labelingInfo",null),e([n({readOnly:!0,json:{read:!1,write:{writer(e,t){switch(this.parentCompositeLayer?.type){case"link-chart":t.layerType="LinkChartSubLayer";break;case"knowledge-graph":t.layerType=this.geometryType?"KnowledgeGraphSubLayer":"KnowledgeGraphSubTable"}},isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ne.prototype,"layerType",void 0),e([n(Te(i(ee)))],Ne.prototype,"legendEnabled",void 0),e([n(Te(i(te)))],Ne.prototype,"maxScale",void 0),e([n(Te(i(re)))],Ne.prototype,"minScale",void 0),e([n()],Ne.prototype,"objectIdField",void 0),e([n()],Ne.prototype,"objectType",void 0),e([n(Te(i(ie)))],Ne.prototype,"opacity",void 0),e([n(Te(i(W)))],Ne.prototype,"orderBy",void 0),e([n({clonable:!1})],Ne.prototype,"parent",void 0),e([n()],Ne.prototype,"parentCompositeLayer",void 0),e([n(Te(i(oe)))],Ne.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],Ne.prototype,"popupTemplate",void 0),e([n({type:Number,json:{write:{overridePolicy:Se}}})],Ne.prototype,"refreshInterval",void 0),e([n({types:he,json:{name:"layerDefinition.drawingInfo.renderer",write:Oe()}})],Ne.prototype,"renderer",null),e([n()],Ne.prototype,"source",void 0),e([n()],Ne.prototype,"spatialReference",null),e([n({type:ue,json:{name:"layerDefinition.timeInfo",write:{overridePolicy:Se},origins:{"web-document":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Se}},"portal-item":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Se}}}}})],Ne.prototype,"timeInfo",null),e([n({type:String,json:{write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ne.prototype,"title",null),e([p("title")],Ne.prototype,"writeTitle",null),e([n({json:{read:!1}})],Ne.prototype,"type",void 0),e([n(Te(i($)))],Ne.prototype,"useViewTime",void 0),e([n({type:Boolean,json:{name:"visibility",write:Oe()}})],Ne.prototype,"visible",void 0),Ne=e([a("esri.layers.knowledgeGraph.KnowledgeGraphSublayer")],Ne);export{Ne as default};
5
+ import{__decorate as e}from"tslib";import t from"../../PopupTemplate.js";import r from"../../core/Error.js";import{clone as i}from"../../core/lang.js";import o from"../../core/Logger.js";import{MultiOriginJSONMixin as n}from"../../core/MultiOriginJSONSupport.js";import"../../core/workers/workers.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import l from"../../geometry/Extent.js";import y from"../../geometry/Point.js";import u from"../../geometry/Polygon.js";import d from"../../geometry/Polyline.js";import{initializeProjection as h,project as m}from"../../geometry/projectionUtils.js";import c from"../../geometry/SpatialReference.js";import{wgs84 as g}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import b from"../../graphic/KnowledgeGraphGraphicOrigin.js";import j from"../../graphic/LinkChartGraphicOrigin.js";import w from"../Layer.js";import T from"../graphics/data/FeatureStore.js";import{QueryEngine as v}from"../graphics/data/QueryEngine.js";import{createDrawingInfo as I}from"../graphics/sources/support/clientSideDefaults.js";import{systemOidFieldName as E,systemAggregationCountFieldName as O,systemIsSpatialFieldName as S,systemLayoutGeometryFieldName as x,systemOriginIdFieldName as N,systemDestinationIdFieldName as L}from"./constants.js";import{KnowledgeGraphSublayerBase as F}from"./KnowledgeGraphSublayerBase.js";import{createCapabilitiesFromKnowledgeGraph as _,getDisplayLabelProperty as R,getLinkChartDefaultLabelingInfo as C,getMapDefaultLabelingInfo as k,getKGSublayerSymbolColor as Q,getDefaultLCRelationshipSublayerSymbol as M,convertLayerEditsToGraphEdits as P,convertGraphEditsResultToFeatureEdits as G}from"./layerUtils.js";import{BlendLayer as D,blendModeProperty as J,effectProperty as q}from"../mixins/BlendLayer.js";import{DisplayFilteredLayer as U,displayFilterEnabledProperty as A,displayFilterInfoProperty as B}from"../mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as Z,featureEffectProperty as K}from"../mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as V}from"../mixins/FeatureReductionLayer.js";import{OrderedLayer as H,orderByProperty as W}from"../mixins/OrderedLayer.js";import{RefreshableLayer as Y}from"../mixins/RefreshableLayer.js";import{ScaleRangeLayer as z}from"../mixins/ScaleRangeLayer.js";import{TemporalLayer as X,useViewTimeProperty as $}from"../mixins/TemporalLayer.js";import{legendEnabled as ee,maxScale as te,minScale as re,opacity as ie,popupEnabled as oe}from"../support/commonProperties.js";import{featureReductionProperty as ne}from"../support/featureReductionUtils.js";import se from"../support/Field.js";import{fixRendererFields as ae,fixTimeInfoFields as pe}from"../support/fieldUtils.js";import le from"../support/LabelClass.js";import{reader as ye}from"../support/labelingInfo.js";import ue from"../support/TimeInfo.js";import de from"../../renderers/SimpleRenderer.js";import{fromJSON as he}from"../../renderers/support/jsonUtils.js";import{rendererTypes as me}from"../../renderers/support/typeUtils.js";import{executeApplyEdits as ce}from"../../rest/knowledgeGraphService.js";import ge from"../../rest/support/FeatureSet.js";import fe from"../../rest/support/Query.js";import{createPopupTemplate as be}from"../../support/popupUtils.js";import{applyColorToSymbol as je}from"../../symbols/support/utils.js";import we from"../../core/workers/RemoteClient.js";function Te(e){if(!e.json)return e;e.json.write=ve(e.json.write);const t=e.json.origins;if(!t)return e;let r;for(r in t){const e=t[r];e&&(e.write=ve(e.write))}return e}function ve(e){return"object"==typeof e&&e?(!1!==e.enabled&&(e.overridePolicy=Ie(e)),e):!0===e?Ee():e}function Ie(e){const{target:t,writer:r,overridePolicy:i,...o}=e;return function(e,t){const r=Oe.call(this,e,t);return r.enabled?{...o,...r}:r}}function Ee(){return{overridePolicy:Oe}}function Oe(e,t){const r=!!this.geometryType;let i={enabled:r};return r&&(i={...i,...Se.call(this,e,t)}),i}function Se(e,t){return{ignoreOrigin:this.originIdOf(t)>0}}let xe=class extends(F(U(V(Z(D(H(X(z(Y(n(w))))))))))){constructor(e){super(e),this.blendMode="normal",this.charts=null,this.definitionExpression=null,this.displayFilterEnabled=!0,this.displayFilterInfo=null,this.effect=null,this.elevationInfo=null,this.featureEffect=null,this.graphType=null,this.labelsVisible=!0,this.layerType=null,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.objectIdField=E,this.objectType=null,this.opacity=1,this.orderBy=null,this.parent=null,this.parentCompositeLayer=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.refreshInterval=0,this.source={openPorts:()=>this.load().then(()=>{const e=new MessageChannel;return new we(e.port1,{channel:e,client:{queryFeatures:(e,t={})=>{const r=fe.fromJSON(e);return this.queryFeaturesJSON(r,t)}}}),[e.port2]})},this.type="knowledge-graph-sublayer",this.useViewTime=!0,this.visible=!0}get capabilities(){return this.parent?this.parent.sublayerCapabilities:_(null)}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.capabilities.operations.supportsEditing}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get isTable(){return"link-chart"!==this.parentCompositeLayer.type&&null==this.geometryFieldName}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}get fields(){const e=[];return this.objectType?.properties?.forEach(t=>{const r="esriFieldTypeOID"===t.fieldType?"esriFieldTypeInteger":t.fieldType;e.push(se.fromJSON({name:t.name,type:r,alias:t.alias,defaultValue:t.defaultValue,editable:t.editable,nullable:t.nullable}))}),e.push(se.fromJSON({name:this.objectIdField,type:"esriFieldTypeString",alias:this.objectIdField,editable:!1}),se.fromJSON({name:O,type:"esriFieldTypeInteger",alias:O,editable:!1}),se.fromJSON({name:S,type:"esriFieldTypeInteger",alias:S,editable:!1})),e}get geometryType(){if("link-chart"===this.parentCompositeLayer?.type)return"relationship"===this.graphType?"polyline":"point";const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.geometryType;return t&&"esriGeometryNull"!==t?f.fromJSON(t):null}get geometryFieldName(){if("link-chart"===this.parentCompositeLayer?.type)return x;const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name);return e?.name??null}get graphicOrigin(){if(!this.parent)return null;switch(this.parent.type){case"knowledge-graph":return new b(this.parent,this);case"link-chart":return new j(this.parent,this)}}get graphTypeName(){return this.objectType?.name}set graphTypeName(e){this._set("graphTypeName",e)}get hasM(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasM??!1}get hasZ(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasZ??!1}set labelingInfo(e){this._set("labelingInfo",e)}get labelingInfo(){if(this._isOverridden("labelingInfo"))return this._get("labelingInfo");if(!this.objectType||!this.parentCompositeLayer||!this.graphTypeName)return null;const e=this.objectType.properties?R(this.objectType.properties):"ESRI__ID";return"link-chart"===this.parentCompositeLayer.type?C(this.graphType,this.graphTypeName,e):k(this.graphTypeName,this.geometryType,e)}set renderer(e){ae(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const e=this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel,t=[...e?.entityTypes??[],...e?.relationshipTypes??[]].map(e=>e.name).indexOf(this.graphTypeName),r=Q(t);if("link-chart"===this.parentCompositeLayer?.type){if("relationship"===this.graphType)return new de({type:"simple",symbol:M(r)});const e=he(I(f.toJSON("point")).renderer);return je(e.symbol,r),e}const i=he(I(f.toJSON(this.geometryType)).renderer);return je(i.symbol,r),i}get spatialReference(){return this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel?.spatialReference??c.WGS84}set timeInfo(e){this._set("timeInfo",e)}get title(){return this._isOverridden("title")?this._get("title"):this.graphTypeName}set title(e){this._set("title",e)}writeTitle(e,t){t.title=e??"Layer"}createPopupTemplate(e){return be(this,e)}createQuery(){return new fe({where:"1=1",outFields:["*"]})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){return null}async queryFeatures(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e),o=this.graphicOrigin,n=ge.fromJSON(await i.executeQuery(r.toJSON(),t?.signal));return n.features.forEach(e=>{e.sourceLayer=this,e.origin=o}),n}async queryFeaturesJSON(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return await i.executeQuery(r.toJSON(),t?.signal)}async queryFeatureCount(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return i.executeQueryForCount(r.toJSON(),t?.signal)}async queryExtent(e={},t){await this.load();const r={...e,returnGeometry:!0},{resolvedQuery:i,queryEngine:o}=await this._setupQueryObjects(r),n=await o.executeQueryForExtent(i.toJSON(),t?.signal);let s;return s=null!=n.extent?.xmin&&null!=n.extent?.xmax&&null!=n.extent?.ymin&&null!=n.extent?.ymax?new l(n.extent):new l,{count:n.count,extent:s}}async queryObjectIds(e,t){await this.load();const r=fe.from(e);let i;if("link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)i=this._cachedQueryEngine;else{const e=await this.parentCompositeLayer.dataManager.getData(r,this,t);i=this.loadQueryEngine(e)}return await i.executeQueryForIds(r.toJSON(),t?.signal)}async applyEdits(e){if(!this.parentCompositeLayer.dataManager.knowledgeGraph)throw new r("knowledge-graph-sublayer:no-knowledge-graph","ApplyEdits cannot be executed because the parent does not have a Knowledge Graph model. This is usually caused by the layer not yet being loaded");const t=P(e,this);t.options={cascadeDelete:!0,cascadeProvenanceDelete:!!this.parent?.knowledgeGraph.serviceDefinition.supportsProvenance||void 0};const i=await ce(this.parentCompositeLayer.dataManager.knowledgeGraph,t),o=G(i,this.graphTypeName),n={addedFeatures:o.addFeatureResults,updatedFeatures:o.updateFeatureResults,deletedFeatures:o.deleteFeatureResults,addedAttachments:o.addAttachmentResults,deletedAttachments:o.deleteAttachmentResults,updatedAttachments:o.updateAttachmentResults,exceededTransferLimit:!1,historicMoment:new Date,edits:void 0};return this.emit("edits",n),this.emit("apply-edits",{result:Promise.resolve(n)}),o}loadQueryEngine(e){const t=new T({geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ}),r=new v({fieldsIndex:this.fieldsIndex.toJSON(),geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ,featureIdInfo:{type:"object-id",fieldName:this.objectIdField},spatialReference:this.spatialReference.toJSON(),timeInfo:this.timeInfo?.toJSON(),featureStore:t});return r.featureStore.addMany(e),r}async refreshCachedQueryEngine(){const e=await this.parentCompositeLayer.dataManager.getData(new fe({where:"1=1",outFields:[E]}),this);this._cachedQueryEngine=this.loadQueryEngine(e)}load(e){return this.addResolvingPromise(this.parent.load(e).then(()=>pe(this.timeInfo,this.fieldsIndex))),Promise.resolve(this)}async _setupQueryObjects(e,t){const r=fe.from(e),i=r.geometry;if(i&&!i.spatialReference?.isWGS84&&(await h(i.spatialReference,g),r.geometry=m(i instanceof u||i instanceof d||i instanceof y?i:i.extent,g)),"link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)return{resolvedQuery:r,queryEngine:this._cachedQueryEngine};const o=await this.parentCompositeLayer.dataManager.getData(r,this,t);return{resolvedQuery:r,queryEngine:this.loadQueryEngine(o)}}};function Ne(e,t,r){const i=[["ESRI__AGGREGATION_COUNT",O],["ESRI__ORIGIN_ID",N],["ESRI__DESTINATION_ID",L],["ESRI__LAYOUT_GEOMETRY",x]];try{for(const t of e)for(const[e,r]of i)t.labelExpression=t.labelExpression?.replaceAll(e,r),t.labelExpressionInfo?.expression&&(t.labelExpressionInfo.expression=t.labelExpressionInfo.expression.replaceAll(e,r))}catch(n){o.getLogger(this).warn("Error updating labelingInfo",n)}return ye(e,t,r)}e([s(Te(i(J)))],xe.prototype,"blendMode",void 0),e([s({readOnly:!0})],xe.prototype,"capabilities",null),e([s({readOnly:!0})],xe.prototype,"userHasUpdateItemPrivileges",null),e([s({type:Boolean})],xe.prototype,"editingEnabled",null),e([s()],xe.prototype,"isTable",null),e([s({json:{origins:{"web-scene":{write:!1}},write:Ee()}})],xe.prototype,"charts",void 0),e([s({readOnly:!0})],xe.prototype,"defaultPopupTemplate",null),e([s({type:String,json:{origins:{service:{read:!1}},name:"layerDefinition.definitionExpression",write:{ignoreOrigin:!0}}})],xe.prototype,"definitionExpression",void 0),e([s(Te(i(A)))],xe.prototype,"displayFilterEnabled",void 0),e([s(Te(i(B)))],xe.prototype,"displayFilterInfo",void 0),e([s(Te(i(q)))],xe.prototype,"effect",void 0),e([s()],xe.prototype,"elevationInfo",void 0),e([s(Te(i(K)))],xe.prototype,"featureEffect",void 0),e([s(Te(i(ne)))],xe.prototype,"featureReduction",null),e([s()],xe.prototype,"fields",null),e([s()],xe.prototype,"geometryType",null),e([s()],xe.prototype,"geometryFieldName",null),e([s({readOnly:!0})],xe.prototype,"graphicOrigin",null),e([s({type:["entity","relationship"],nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],xe.prototype,"graphType",void 0),e([s({type:String,nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],xe.prototype,"graphTypeName",null),e([s()],xe.prototype,"hasM",null),e([s()],xe.prototype,"hasZ",null),e([s({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],xe.prototype,"id",void 0),e([s({type:Boolean,value:!0,nonNullable:!0,json:{name:"showLabels",default:!1,write:{overridePolicy(){return{enabled:!!this.geometryType,alwaysWriteDefaults:!0,ignoreOrigin:!0}}}}})],xe.prototype,"labelsVisible",void 0),e([s({type:[le],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:Ne,write:Ee()}})],xe.prototype,"labelingInfo",null),e([s({readOnly:!0,json:{read:!1,write:{writer(e,t){switch(this.parentCompositeLayer?.type){case"link-chart":t.layerType="LinkChartSubLayer";break;case"knowledge-graph":t.layerType=this.geometryType?"KnowledgeGraphSubLayer":"KnowledgeGraphSubTable"}},isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],xe.prototype,"layerType",void 0),e([s(Te(i(ee)))],xe.prototype,"legendEnabled",void 0),e([s(Te(i(te)))],xe.prototype,"maxScale",void 0),e([s(Te(i(re)))],xe.prototype,"minScale",void 0),e([s()],xe.prototype,"objectIdField",void 0),e([s()],xe.prototype,"objectType",void 0),e([s(Te(i(ie)))],xe.prototype,"opacity",void 0),e([s(Te(i(W)))],xe.prototype,"orderBy",void 0),e([s({clonable:!1})],xe.prototype,"parent",void 0),e([s()],xe.prototype,"parentCompositeLayer",void 0),e([s(Te(i(oe)))],xe.prototype,"popupEnabled",void 0),e([s({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],xe.prototype,"popupTemplate",void 0),e([s({type:Number,json:{write:{overridePolicy:Se}}})],xe.prototype,"refreshInterval",void 0),e([s({types:me,json:{name:"layerDefinition.drawingInfo.renderer",write:Ee()}})],xe.prototype,"renderer",null),e([s()],xe.prototype,"source",void 0),e([s()],xe.prototype,"spatialReference",null),e([s({type:ue,json:{name:"layerDefinition.timeInfo",write:{overridePolicy:Se},origins:{"web-document":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Se}},"portal-item":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Se}}}}})],xe.prototype,"timeInfo",null),e([s({type:String,json:{write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],xe.prototype,"title",null),e([p("title")],xe.prototype,"writeTitle",null),e([s({json:{read:!1}})],xe.prototype,"type",void 0),e([s(Te(i($)))],xe.prototype,"useViewTime",void 0),e([s({type:Boolean,json:{name:"visibility",write:Ee()}})],xe.prototype,"visible",void 0),xe=e([a("esri.layers.knowledgeGraph.KnowledgeGraphSublayer")],xe);export{xe as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import{getOrCreateMapValue as t}from"../../core/MapUtils.js";import{systemOidFieldName as o}from"./constants.js";import s from"../support/LabelClass.js";import a from"../support/LabelExpressionInfo.js";import{fetchClientDataAtKeys as r}from"../../rest/knowledgeGraphService.js";import n from"../../rest/knowledgeGraph/Entity.js";import i from"../../rest/knowledgeGraph/GraphApplyEdits.js";import l from"../../rest/knowledgeGraph/Relationship.js";import{isGraphic as p}from"../../support/guards.js";import d from"../../symbols/CIMSymbol.js";import c from"../../symbols/TextSymbol.js";const f={initializeLayersFromClientData:async(e,t,o)=>{if(t||(t=[...e.layers,...e.tables].map(e=>e.graphTypeName)),0===t?.length)return;const s=new Map;for(const r of t)s.set(r,m(e,r));const a=await r(e.dataManager.knowledgeGraph,Array.from(s.values()),{requestOptions:{signal:o?.signal}});for(const r of[...e.layers,...e.tables]){const t=r.objectType.name;if(null==t)continue;const o=a.get(m(e,t));if(o){const e=JSON.parse(o);null===e||"object"!=typeof e||e.hasOwnProperty("showLabels")||(e.showLabels=!1),r.read(e,{origin:"service"})}}}},m=(e,t)=>"knowledge-graph"===e.type?`${t}/Map`:`${t}/LinkChart/LinkChartSubLayer`;async function y(e,t,o){return f.initializeLayersFromClientData(e,t,o)}const b=["#4a0932","#b31515","#18382e","#a64f1b","#102432","#8c213f","#ed9310","#2c6954","#144d59","#ffc730","#75351e","#454f4b","#78b1c2","#191921","#8f8f82","#9be0c0","#dbb658","#87b051","#11495c","#c43541","#9c5596","#44498b","#ad9d63","#86afb3","#5c98ca","#b0bfa2","#73241f","#b86b53","#d9d78c","#3e756d","#f260a1","#a0d17d","#c27c30","#eb82eb","#ffdf3c","#ffb259","#ab52b3","#3cccb4","#0095ba","#d92b30"],u="#8f8f82";function h(t){return t<0||t>=b.length?new e(u):new e(b[t])}function g(e){const t=e.toArray();return new d({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,style:"solid",width:.75,color:t},{type:"CIMVectorMarker",enable:!0,size:6,markerPlacement:{type:"CIMMarkerPlacementOnLine",angleToLine:!0,relativeTo:"LineMiddle"},frame:{xmin:-10,ymin:-5,xmax:0,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[-12,-3.47],[-12,3.6],[1.96,-.03],[-12,-3.47]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:t}]}}]}]}}})}function w(e){let t="ESRI__ID",o=4;for(const s of e)if(s.name){if("name"===s.name.toLowerCase()){t=s.name;break}s.name.toLowerCase().includes("name")?(t=s.name,o=2):"esriFieldTypeString"===s.fieldType&&o>3&&(t=s.name,o=3)}return t}function I(e,t,o){const r={color:[80,80,80],haloColor:[255,255,255],haloSize:.7,font:{size:10,weight:"normal"}},n=new s({labelExpressionInfo:new a({expression:"ESRI__ID"===o?`${t}`:`$feature.${o}`}),labelPlacement:"above-center",symbol:new c(r)}),i=new s({labelExpressionInfo:new a({expression:`'${t}' + IIf($feature.ESRI__AggregationCount>1, ' (' + $feature.ESRI__AggregationCount + ')', '')`}),labelPlacement:"center-along",labelPosition:"parallel",repeatLabel:!1,symbol:new c({...r,yoffset:"12px"})});return"entity"===e?[n]:[i]}function L(e,t,o){const r={color:[255,255,255],haloColor:[0,0,0],haloSize:.7,font:{size:10,weight:"bold"}},n="ESRI__ID"===o?`${e}`:`$feature.${o}`;return"point"===t?[new s({labelExpressionInfo:new a({expression:n}),labelPlacement:"above-center",symbol:new c(r)})]:"polyline"===t?[new s({labelExpressionInfo:new a({expression:n}),labelPlacement:"center-along",repeatLabel:!0,symbol:new c(r)})]:"polygon"===t?[new s({labelExpressionInfo:new a({expression:n}),labelPlacement:"always-horizontal",symbol:new c(r)})]:null}function j(e,s){const a=new i,r=s.graphTypeName,d=s.graphType,c=e=>{for(const t of s.fields)t.editable||delete e[t.name];for(const t of Object.keys(e))t.includes("ESRI__")&&delete e[t]};for(const t of e.addFeatures??[])c(t.attributes),t.sourceLayer.graphTypeName===r&&("entity"===d?(a.entityAdds||(a.entityAdds=[]),a.entityAdds.push(new n({properties:t.attributes,typeName:r}))):(a.relationshipAdds||(a.relationshipAdds=[]),a.relationshipAdds.push(new l({properties:t.attributes,typeName:r}))));for(const t of e.updateFeatures??[]){const e=t.attributes[o];c(t.attributes),t.sourceLayer.graphTypeName===r&&("entity"===d?(a.entityUpdates||(a.entityUpdates=[]),a.entityUpdates.push(new n({id:e,properties:t.attributes,typeName:r}))):(a.relationshipUpdates||(a.relationshipUpdates=[]),a.relationshipUpdates.push(new l({id:e,properties:t.attributes,typeName:r}))))}const f=new Map;for(const n of e.deleteFeatures??[])if(p(n)){const e=n,s=t(f,e.sourceLayer.graphTypeName,()=>({typeName:e.sourceLayer.graphTypeName,ids:[]}));e.sourceLayer.graphTypeName===r&&s.ids.push(e.attributes[o])}else if(n.objectId&&"string"==typeof n.objectId){t(f,r,()=>({typeName:r,ids:[]})).ids.push(n.objectId)}for(const t of f.values())t.ids.length>0&&("entity"===d?(a.entityDeletes||(a.entityDeletes=[]),a.entityDeletes.push({typeName:t.typeName,ids:t.ids})):(a.relationshipDeletes||(a.relationshipDeletes=[]),a.relationshipDeletes.push({typeName:t.typeName,ids:t.ids})));return a}function C(e,t){const o={addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]};for(const s of e.editResults)if(s.typeName===t){for(const e of s.adds)o.addFeatureResults.push({objectId:e.id,globalId:e.id});for(const e of s.updates)o.updateFeatureResults.push({objectId:e.id,globalId:e.id});for(const e of s.deletes)o.deleteFeatureResults.push({objectId:e.id,globalId:e.id})}return o}export{C as convertGraphEditsResultToFeatureEdits,j as convertLayerEditsToGraphEdits,u as fallbackKGSublayerSymbolHexColor,g as getDefaultLCRelationshipSublayerSymbol,w as getDisplayLabelProperty,h as getKGSublayerSymbolColor,I as getLinkChartDefaultLabelingInfo,L as getMapDefaultLabelingInfo,y as initializeLayersFromClientData,f as layerUtils};
5
+ import e from"../../Color.js";import{getOrCreateMapValue as t}from"../../core/MapUtils.js";import{queryBinsCapabilities as s,queryCapabilities as a}from"../graphics/data/QueryEngineCapabilities.js";import{systemOidFieldName as o}from"./constants.js";import r from"../support/LabelClass.js";import n from"../support/LabelExpressionInfo.js";import{fetchClientDataAtKeys as p}from"../../rest/knowledgeGraphService.js";import i from"../../rest/knowledgeGraph/Entity.js";import l from"../../rest/knowledgeGraph/GraphApplyEdits.js";import u from"../../rest/knowledgeGraph/Relationship.js";import{isGraphic as d}from"../../support/guards.js";import c from"../../symbols/CIMSymbol.js";import y from"../../symbols/TextSymbol.js";const m={initializeLayersFromClientData:async(e,t,s)=>{if(t||(t=[...e.layers,...e.tables].map(e=>e.graphTypeName)),0===t?.length)return;const a=new Map;for(const r of t)a.set(r,f(e,r));const o=await p(e.dataManager.knowledgeGraph,Array.from(a.values()),{requestOptions:{signal:s?.signal}});for(const r of[...e.layers,...e.tables]){const t=r.objectType.name;if(null==t)continue;const s=o.get(f(e,t));if(s){const e=JSON.parse(s);null===e||"object"!=typeof e||e.hasOwnProperty("showLabels")||(e.showLabels=!1),r.read(e,{origin:"service"})}}}},f=(e,t)=>"knowledge-graph"===e.type?`${t}/Map`:`${t}/LinkChart/LinkChartSubLayer`;async function b(e,t,s){return m.initializeLayersFromClientData(e,t,s)}const h=["#4a0932","#b31515","#18382e","#a64f1b","#102432","#8c213f","#ed9310","#2c6954","#144d59","#ffc730","#75351e","#454f4b","#78b1c2","#191921","#8f8f82","#9be0c0","#dbb658","#87b051","#11495c","#c43541","#9c5596","#44498b","#ad9d63","#86afb3","#5c98ca","#b0bfa2","#73241f","#b86b53","#d9d78c","#3e756d","#f260a1","#a0d17d","#c27c30","#eb82eb","#ffdf3c","#ffb259","#ab52b3","#3cccb4","#0095ba","#d92b30"],g="#8f8f82";function w(t){return t<0||t>=h.length?new e(g):new e(h[t])}function I(e){const t=e.toArray();return new c({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,style:"solid",width:.75,color:t},{type:"CIMVectorMarker",enable:!0,size:6,markerPlacement:{type:"CIMMarkerPlacementOnLine",angleToLine:!0,relativeTo:"LineMiddle"},frame:{xmin:-10,ymin:-5,xmax:0,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{rings:[[[-12,-3.47],[-12,3.6],[1.96,-.03],[-12,-3.47]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:t}]}}]}]}}})}function C(e){let t="ESRI__ID",s=4;for(const a of e)if(a.name){if("name"===a.name.toLowerCase()){t=a.name;break}a.name.toLowerCase().includes("name")?(t=a.name,s=2):"esriFieldTypeString"===a.fieldType&&s>3&&(t=a.name,s=3)}return t}function S(e,t,s){const a={color:[80,80,80],haloColor:[255,255,255],haloSize:.7,font:{size:10,weight:"normal"}},o=new r({labelExpressionInfo:new n({expression:"ESRI__ID"===s?`${t}`:`$feature.${s}`}),labelPlacement:"above-center",symbol:new y(a)}),p=new r({labelExpressionInfo:new n({expression:`'${t}' + IIf($feature.ESRI__AggregationCount>1, ' (' + $feature.ESRI__AggregationCount + ')', '')`}),labelPlacement:"center-along",labelPosition:"parallel",repeatLabel:!1,symbol:new y({...a,yoffset:"12px"})});return"entity"===e?[o]:[p]}function A(e,t,s){const a={color:[255,255,255],haloColor:[0,0,0],haloSize:.7,font:{size:10,weight:"bold"}},o="ESRI__ID"===s?`${e}`:`$feature.${s}`;return"point"===t?[new r({labelExpressionInfo:new n({expression:o}),labelPlacement:"above-center",symbol:new y(a)})]:"polyline"===t?[new r({labelExpressionInfo:new n({expression:o}),labelPlacement:"center-along",repeatLabel:!0,symbol:new y(a)})]:"polygon"===t?[new r({labelExpressionInfo:new n({expression:o}),labelPlacement:"always-horizontal",symbol:new y(a)})]:null}const M={capabilities:[],allowGeometryUpdates:!1,serviceCapabilities:{geometryCapabilities:{supportsZValues:!1,supportsMValues:!1}}};function L(e){const{capabilities:t,allowGeometryUpdates:o,serviceCapabilities:{geometryCapabilities:{supportsZValues:r,supportsMValues:n}}}=e?.serviceDefinition||M,p=e?.dataModel.arcgisManaged?t:t.filter(e=>"Query"===e),i=new Set(p);return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:n,supportsZ:r},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:i.has("Create"),supportsDelete:i.has("Delete"),supportsEditing:i.has("Editing"),supportsChangeTracking:!1,supportsQuery:i.has("Query"),supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:i.has("Update"),supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:a,queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:s,editing:{supportsGeometryUpdate:!!e?.dataModel.arcgisManaged&&o,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateWithoutM:!1,supportsUploadWithItemId:!1,supportsDeleteByAnonymous:!1,supportsDeleteByOthers:i.has("Delete"),supportsUpdateByAnonymous:!1,supportsUpdateByOthers:i.has("Update"),supportsAsyncApplyEdits:!1,zDefault:void 0}}}function R(e,s){const a=new l,r=s.graphTypeName,n=s.graphType,p=e=>{for(const t of s.fields)t.editable||delete e[t.name];for(const t of Object.keys(e))t.includes("ESRI__")&&delete e[t]};for(const t of e.addFeatures??[])p(t.attributes),t.sourceLayer.graphTypeName===r&&("entity"===n?(a.entityAdds||(a.entityAdds=[]),a.entityAdds.push(new i({properties:t.attributes,typeName:r}))):(a.relationshipAdds||(a.relationshipAdds=[]),a.relationshipAdds.push(new u({properties:t.attributes,typeName:r}))));for(const t of e.updateFeatures??[]){const e=t.attributes[o];p(t.attributes),t.sourceLayer.graphTypeName===r&&("entity"===n?(a.entityUpdates||(a.entityUpdates=[]),a.entityUpdates.push(new i({id:e,properties:t.attributes,typeName:r}))):(a.relationshipUpdates||(a.relationshipUpdates=[]),a.relationshipUpdates.push(new u({id:e,properties:t.attributes,typeName:r}))))}const c=new Map;for(const i of e.deleteFeatures??[])if(d(i)){const e=i,s=t(c,e.sourceLayer.graphTypeName,()=>({typeName:e.sourceLayer.graphTypeName,ids:[]}));e.sourceLayer.graphTypeName===r&&s.ids.push(e.attributes[o])}else if(i.objectId&&"string"==typeof i.objectId){t(c,r,()=>({typeName:r,ids:[]})).ids.push(i.objectId)}for(const t of c.values())t.ids.length>0&&("entity"===n?(a.entityDeletes||(a.entityDeletes=[]),a.entityDeletes.push({typeName:t.typeName,ids:t.ids})):(a.relationshipDeletes||(a.relationshipDeletes=[]),a.relationshipDeletes.push({typeName:t.typeName,ids:t.ids})));return a}function j(e,t){const s={addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]};for(const a of e.editResults)if(a.typeName===t){for(const e of a.adds)s.addFeatureResults.push({objectId:e.id,globalId:e.id});for(const e of a.updates)s.updateFeatureResults.push({objectId:e.id,globalId:e.id});for(const e of a.deletes)s.deleteFeatureResults.push({objectId:e.id,globalId:e.id})}return s}export{j as convertGraphEditsResultToFeatureEdits,R as convertLayerEditsToGraphEdits,L as createCapabilitiesFromKnowledgeGraph,g as fallbackKGSublayerSymbolHexColor,I as getDefaultLCRelationshipSublayerSymbol,C as getDisplayLabelProperty,w as getKGSublayerSymbolColor,S as getLinkChartDefaultLabelingInfo,A as getMapDefaultLabelingInfo,b as initializeLayersFromClientData,m as layerUtils};