/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{serializeInclusionDefinitionToEntitiesPbf as e,serializeInclusionDefinitionToRelationshipsPbf as r}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import{Clonable as i}from"../core/Clonable.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{join as s}from"../core/urlUtils.js";import{generateUUID as n}from"../core/uuid.js";import{property as l,subclass as a}from"../core/accessorSupport/decorators.js";import{nameToId as p}from"../core/accessorSupport/PropertyOrigin.js";import{getRelationshipEndNodeMap as u}from"../layers/knowledgeGraph/supportUtils.js";import{layoutTypes as c}from"./enums.js";import d from"./LayoutSettings.js";import m from"./NonspatialDataDisplay.js";import{f as h,t as y}from"../chunks/persistableUrlUtils.js";import{reader as g}from"../core/accessorSupport/decorators/reader.js";import{writer as U}from"../core/accessorSupport/decorators/writer.js";let f=class extends(o(i)){constructor(t){super(t),this.aggregatedEntitiesUrl=null,this.aggregatedRelationshipsUrl=null,this.autoCollapseRelationships=!0,this.centralityIsUpToDate=!0,this.entitiesUrl=null,this.layoutSettings=null,this.layoutType="organic-standard",this.nonspatialDataDisplay=null,this.relationshipsUrl=null}readEntitiesUrl(t,e,r){return h(t,r)}writeEntitiesUrl(t,e,r,i){const o=i?.portalItem,s=i?.resources,n=p(i?.origin),l=i?.webmap?.activeLinkChartLayer;o&&s&&null!=n&&l&&l.membershipModified?this._saveUrlAsNewResource(e,r,s,o,l):t&&(e[r]=y(t,i))}readRelationshipsUrl(t,e,r){return h(t,r)}writeRelationshipsUrl(t,e,r,i){const o=i?.portalItem,s=i?.resources,n=p(i?.origin),l=i?.webmap?.activeLinkChartLayer;o&&s&&null!=n&&l&&l.membershipModified?this._saveUrlAsNewResource(e,r,s,o,l):t&&(e[r]=y(t,i))}_saveUrlAsNewResource(t,e,r,i,o){t[e]="<pending>";const s=(o.knowledgeGraph.dataModel.relationshipTypes??[]).map(t=>t.name).reduce((t,e)=>{if(!e)return t;const{members:r}=o.dataManager.inclusionModeDefinition.namedTypeDefinitions.get(e)||{members:void 0};if(!r)return t;for(const[i]of r)t.push({id:i,typeName:e});return t},[]);r.pendingOperations.push(new Promise(n=>{u(s,o.knowledgeGraph).then(s=>{v(o.dataManager.inclusionModeDefinition,e,o.knowledgeGraph,s).then(o=>{const s=j(i,"entitiesUrl"===e?"entitiesUrl":"relationshipsUrl");t[e]=s.itemRelativeUrl,r.toAdd.push({resource:s,content:{type:"blob",blob:o},compress:!1,finish:t=>{"entitiesUrl"===e?this.entitiesUrl=t.url:this.relationshipsUrl=t.url}}),n()})})}))}};t([l({type:String,json:{write:!0}})],f.prototype,"aggregatedEntitiesUrl",void 0),t([l({type:String,json:{write:!0}})],f.prototype,"aggregatedRelationshipsUrl",void 0),t([l({type:Boolean,json:{write:!0}})],f.prototype,"autoCollapseRelationships",void 0),t([l({type:Boolean,json:{write:!0}})],f.prototype,"centralityIsUpToDate",void 0),t([l({type:String,json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],f.prototype,"entitiesUrl",void 0),t([g("entitiesUrl")],f.prototype,"readEntitiesUrl",null),t([U("entitiesUrl")],f.prototype,"writeEntitiesUrl",null),t([l({type:d,json:{write:!0}})],f.prototype,"layoutSettings",void 0),t([l({type:c,json:{write:!0}})],f.prototype,"layoutType",void 0),t([l({type:m,json:{write:!0}})],f.prototype,"nonspatialDataDisplay",void 0),t([l({type:String,json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],f.prototype,"relationshipsUrl",void 0),t([g("relationshipsUrl")],f.prototype,"readRelationshipsUrl",null),t([U("relationshipsUrl")],f.prototype,"writeRelationshipsUrl",null),f=t([a("esri.linkChart.LinkChartProperties")],f);const w=f;function j(t,e){const r=`${e}-${n()}.dat`,i=s("linkChart",r);return t.resourceFromPath(i)}async function v(t,i,o,s){let n;return n="entitiesUrl"===i?await e(t,o,s):await r(t,o,s),new Blob([n],{type:"application/x-protobuf"})}export{w as default};
