import{generateInputPortId,generateOutputPortId,generateParamPortId}from"./NodeView.js";export class EdgeView{constructor(e,t){const o=generateEdgePortIdsByData(e,t);if(!o)throw new Error("Unable to generate edge port IDs");const{edgeId:r,sourcePortId:d,destinationPortId:n}=o;this.id=r,this.type=t,this.sourceId=e.sourceId,this.destinationId=e.destinationId,this.sourcePortId=d,this.destinationPortId=n}}export const generateEdgePortIdsByData=(e,t)=>{if(!e.sourceId||!e.destinationId)return console.error(`Undefined node message: ${JSON.stringify(e)}`),null;const o=generateOutputPortId(e.sourceId,e.sourceOutputIndex),r=function(e,t){if(t===EdgeTypes.NodeToNode){const t=e;return generateInputPortId(e.destinationId,t.destinationInputIndex)}if(t===EdgeTypes.NodeToParam){const t=e;return generateParamPortId(e.destinationId,t.destinationParamId)}return console.error(`Unknown edge type: ${t.toString()}`),""}(e,t);return{edgeId:`${o}->${r}`,sourcePortId:o,destinationPortId:r}};export const EdgeTypes={NodeToNode:Symbol("NodeToNode"),NodeToParam:Symbol("NodeToParam")};