use serde::{Deserialize, Serialize};

use jellyflow_core::core::{Edge, EdgeId, EdgeKind, EdgeReconnectable, EdgeViewDescriptor, PortId};

/// Changes targeting edges (graph-owned).
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum EdgeChange {
    Add {
        id: EdgeId,
        edge: Edge,
    },
    Remove {
        id: EdgeId,
    },

    Kind {
        id: EdgeId,
        kind: EdgeKind,
    },
    Selectable {
        id: EdgeId,
        selectable: Option<bool>,
    },
    Focusable {
        id: EdgeId,
        focusable: Option<bool>,
    },
    Hidden {
        id: EdgeId,
        hidden: bool,
    },
    InteractionWidth {
        id: EdgeId,
        interaction_width: Option<f32>,
    },
    Deletable {
        id: EdgeId,
        deletable: Option<bool>,
    },
    Reconnectable {
        id: EdgeId,
        reconnectable: Option<EdgeReconnectable>,
    },
    Data {
        id: EdgeId,
        data: serde_json::Value,
    },
    View {
        id: EdgeId,
        view: EdgeViewDescriptor,
    },
    Endpoints {
        id: EdgeId,
        from: PortId,
        to: PortId,
    },
}
