1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2928],{12928:(e,t,i)=>{i.r(t),i.d(t,{default:()=>R});var a=i(49493),s=i(52984),n=i(55114),o=i(64988),r=i(94839),l=i(92510),h=i(85314),d=i(23096),p=i(86858),y=i(4491),u=i(9491);i(74552),i(32243);var f=i(98285),c=i(44708),g=i(8705),m=i(41340),M=i(62408),w=i(30600),_=i(14294),b=i(30430),T=i(34565),S=i(62038),D=i(99422),A=i(7570),L=i(93115),v=i(73885),k=i(37226),N=i(92826),E=i(93479),C=i(542),G=i(82459);let I=class extends(0,D.dM)((0,N.j)((0,k.J)((0,S.b)((0,L.q)((0,v.A)((0,l.P)((0,A.d)(M.A)))))))){constructor(e){super(e),this._graphTypeLookup=new Map,this._namedTypesModified=!1,this.dataManager=null,this.definitionSetMap=null,this.knowledgeGraph=null,this.layers=new(s.A.ofType(_.A)),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="KnowledgeGraphLayer",this.sublayerIdsCache=new Map,this.tables=new(s.A.ofType(_.A)),this.type="knowledge-graph",this.url=null,this.addHandles((0,d.wB)(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),d.OH))}load(e){return this.addResolvingPromise(this._doLoad(e)),Promise.resolve(this)}async _doLoad(e){try{await this.loadFromPortal({supportedTypes:["Knowledge Graph Layer"]},e)}catch(e){(0,h.QP)(e)}await this._fetchMetadata(),await this._initializeLayerProperties(),this.loadLayerAssumingLocalCache(),await (0,b.qN)(this)}async _fetchMetadata(){if(!this.url)throw new n.A("knowledge-graph:missing-url","KnowledgeGraphLayer must be created with a url");let e=await (0,C.fetchKnowledgeGraph)(this.url);this.knowledgeGraph=e,this._forEachGraphType(e=>{e.name&&this._graphTypeLookup.set(e.name,e)})}async _initializeLayerProperties(){this.originIdOf("inclusionModeDefinition")===m.Gr.USER?this._validateInclusionModeDefinition():await this._initializeInclusionModeDefinition(),this._setMemberTypes(),this.dataManager=new w.P({knowledgeGraph:this.knowledgeGraph,inclusionModeDefinition:this.inclusionModeDefinition})}async _initializeInclusionModeDefinition(){let e=this.definitionSetMap?await (0,T._s)(this.definitionSetMap,!0):{generateAllSublayers:!0,namedTypeDefinitions:new Map};
1[...this.layers.toArray(),...this.tables.toArray()].forEach(t=>{let i=this._graphTypeLookup.get(t.graphTypeName);i&&!e.namedTypeDefinitions.has(i.name)&&e.namedTypeDefinitions.set(i.name,{useAllData:!0})}),this.setAtOrigin("inclusionModeDefinition",e,(0,m.OL)(this.originIdOf("definitionSetMap")))}_validateInclusionModeDefinition(){let{inclusionModeDefinition:e}=this;if(!e)return;let{namedTypeDefinitions:t}=e;if(t?.size>0)t.forEach((e,i)=>{let a=this._graphTypeLookup.get(i);if(!a)return o.A.getLogger(this).warn(`A named type, ${i}, was in the inclusion list that wasn't in the data model and will be removed`),void t.delete(i);"relationship"!==a.type&&"entity"!==a.type&&(o.A.getLogger(this).warn(`A named type, ${i}, was in the inclusion list that wasn't properly modeled and will be removed`),t.delete(i))});else if(!e.generateAllSublayers)throw new n.A("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined")}_setMemberTypes(){let e=[],t=[],{inclusionModeDefinition:i}=this,a=i?.namedTypeDefinitions;!i||i.generateAllSublayers?(e=this.knowledgeGraph.dataModel?.entityTypes??[],t=this.knowledgeGraph.dataModel?.relationshipTypes??[]):a&&a.size>0&&a.forEach((i,a)=>{let s=this._graphTypeLookup.get(a);switch(s?.type){case"relationship":t.push(s);break;case"entity":e.push(s)}}),this.memberEntityTypes=e,this.memberRelationshipTypes=t}_forEachGraphType(e){[...this.knowledgeGraph.dataModel?.entityTypes??[],...this.knowledgeGraph.dataModel?.relationshipTypes??[]].forEach(t=>{e(t)})}_refreshNamedTypes(){for(let e of(this._namedTypesModified=!0,this.layers))e.emit("refresh",{dataChanged:!0});for(let e of this.tables)e.emit("refresh",{dataChanged:!0})}async _handleNewRecords(e){let t=[];for(let i of(this.dataManager.addToLayer(e),e))this.sublayerIdsCache.has(i.typeName)||(this.sublayerIdsCache.set(i.typeName,new Set),t.push(i.typeName)),this.sublayerIdsCache.get(i.typeName).add(i.id);for(let e of t){let t=this._graphTypeLookup.get(e);t&&(this._addSublayer(t),"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.sublayerCaches.set(e,new Map))}await (0,b.qN)(this,t),this._refreshNamedTypes()}_createSublayers(e,t,i){e.forEach(e=>{let a=this._createSublayer(e);i(a)&&t.push(a),this._updateSublayerCaches(e)})}_addSublayer(e){let t=this._createSublayer(e);return t.geometryType?this.layers.push(t):this.tables.push(t),t}_createSublayer(e){return new _.A({objectType:e,parentCompositeLayer:this,graphType:e.type})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;let i=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);i&&(t.objectType=i,this._updateSublayerCaches(i))})}_updateSublayerCaches(e){let t=this.dataManager.sublayerCaches;t.has(e.name)||t.set(e.name,new Map)}_saveUrlAsNewResource(e,t,i,a){e[t]="<pending>",i.pendingOperations.push(O(this.inclusionModeDefinition).then(s=>{let n=function(e){let t=`definitionSetMap-${(0,y.lk)()}.dat`,i=(0,p.fj)("knowledgeGraphLayer",t);return e.resourceFromPath(i)}(a);e[t]=n.itemRelativeUrl,i.toAdd.push({resource:n,content:{type:"blob",blob:s},compress:!1,finish:e=>{this.definitionSetMap=e.url}})}))}_displaysAllRecords(e){for(let[,{useAllData:t}]of e.namedTypeDefinitions)if(!t)return!1;return!0}_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"))}readDefinitionSetMap(e,t,i){return(0,G.f)(e,i)}writeDefinitionSetMap(e,t,i,a){let s=a?.portalItem,n=a?.resources,o=(0,m.aB)(a?.origin);if(!s||!n||null==o)return void(e&&(t[i]=(0,G.t)(e,a)));let{inclusionModeDefinition:r}=this;if(!r||this._displaysAllRecords(r))return void(this.definitionSetMap=null);let l=this.originIdOf("inclusionModeDefinition");if(l===m.Gr.USER||this._namedTypesModified||o<l)this._saveUrlAsNewResource(t,i,n,s);else if(o===l&&e){let o=(0,G.t)(e,a);(0,p.oP)(o)?this._saveUrlAsNewResource(t,i,n,s):t[i]=o}}set inclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("inclusionModeDefinition",e):o.A.getLogger(this).error("#inclusionModeDefinition","inclusionModeDefinition cannot be changed after the layer is loaded.")}loadLayerAssumingLocalCache(){let e=[...this.memberEntityTypes,...this.memberRelationshipTypes];this.originIdOf("layers")===m.Gr.DEFAULTS?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers),this.originIdOf("tables")===m.Gr.DEFAULTS?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{let i=(0,r.tE)(this.sublayerIdsCache,t,()=>new Set);
1e.members?.forEach(e=>{i.add(e.id)})})}async addRecords(e){await this._handleNewRecords(e)}async removeRecords(e){let t=[];for(let i of e)!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(i.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(i.typeName)?.members?.has(i.id)&&t.push(i);for(let e of(this.dataManager.removeFromLayer(t),t))this.sublayerIdsCache.get(e.typeName)?.delete(e.id);return this._refreshNamedTypes(),t}};(0,a._)([(0,u.MZ)()],I.prototype,"dataManager",void 0),(0,a._)([(0,u.MZ)({json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],I.prototype,"definitionSetMap",void 0),(0,a._)([(0,f.w)("definitionSetMap")],I.prototype,"readDefinitionSetMap",null),(0,a._)([(0,g.K)("definitionSetMap")],I.prototype,"writeDefinitionSetMap",null),(0,a._)([(0,u.MZ)()],I.prototype,"inclusionModeDefinition",null),(0,a._)([(0,u.MZ)()],I.prototype,"knowledgeGraph",void 0),(0,a._)([(0,u.MZ)({type:s.A.ofType(_.A),json:{write:{ignoreOrigin:!0}}})],I.prototype,"layers",void 0),(0,a._)([(0,u.MZ)()],I.prototype,"memberEntityTypes",void 0),(0,a._)([(0,u.MZ)()],I.prototype,"memberRelationshipTypes",void 0),(0,a._)([(0,u.MZ)({type:["KnowledgeGraphLayer"]})],I.prototype,"operationalLayerType",void 0),(0,a._)([(0,u.MZ)()],I.prototype,"sublayerIdsCache",void 0),(0,a._)([(0,u.MZ)({type:s.A.ofType(_.A),json:{write:{ignoreOrigin:!0}}})],I.prototype,"tables",void 0),(0,a._)([(0,u.MZ)({json:{read:!1}})],I.prototype,"type",void 0),(0,a._)([(0,u.MZ)(E.OZ)],I.prototype,"url",void 0);let R=I=(0,a._)([(0,c.$)("esri.layers.KnowledgeGraphLayer")],I);async function O(e){return new Blob([await (0,T.fe)(e)],{type:"application/x-protobuf"})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.