import 'package:flutter/material.dart';
import 'package:equatable/equatable.dart';

class InspectionTopologyState extends Equatable {
  final bool isLoading;
  final String? error;
  final String deviceName;
  final String deviceModel;
  final List<TopologyNode> topologyNodes;
  final int deviceCount;
  final int connectionCount;
  final TopologyNode? selectedNode;
  final String statusText;

  const InspectionTopologyState({
    this.isLoading = false,
    this.error,
    this.deviceName = '',
    this.deviceModel = '',
    this.topologyNodes = const [],
    this.deviceCount = 0,
    this.connectionCount = 0,
    this.selectedNode,
    this.statusText = ''
  });

  InspectionTopologyState copyWith({
    bool? isLoading,
    String? error,
    String? deviceName,
    String? deviceModel,
    List<TopologyNode>? topologyNodes,
    int? deviceCount,
    int? connectionCount,
    TopologyNode? selectedNode,
    String? statusText,
  }) {
    return InspectionTopologyState(
      isLoading: isLoading ?? this.isLoading,
      error: error,
      deviceName: deviceName ?? this.deviceName,
      deviceModel: deviceModel ?? this.deviceModel,
      topologyNodes: topologyNodes ?? this.topologyNodes,
      deviceCount: deviceCount ?? this.deviceCount,
      connectionCount: connectionCount ?? this.connectionCount,
      selectedNode: selectedNode,
      statusText: statusText ?? this.statusText,
    );
  }

  @override
  List<Object?> get props => [
        isLoading,
        error,
        deviceName,
        deviceModel,
        topologyNodes,
        deviceCount,
        connectionCount,
        selectedNode,
        statusText
      ];
}

class TopologyNode extends Equatable {
  final String id;
  final String name;
  final String status;
  final List<TopologyNode> children;
  final double x;
  final double y;
  final String? gatewayId;
  final String? statusText;

  const TopologyNode({
    required this.id,
    required this.name,
    required this.status,
    required this.children,
    required this.x,
    required this.y,
    this.gatewayId,
    this.statusText,
  });

  @override
  List<Object?> get props => [id, name, status, children, x, y, gatewayId, statusText];
}