// This program has been developed by students from the bachelor Computer Science at Utrecht
// University within the Software Project course.
// © Copyright Utrecht University (Department of Information and Computing Sciences)
import EndNode, {
  EndConnectionTarget,
  EndConnectionSource,
  EndDisconnectionTarget,
  EndDisconnectionSource,
  EndReduce,
  EndTooltip
} from "./nodes/EndNode";
import { EndNodeDefaults } from "./nodes/EndNode.default";
import StartNode, {
  StartConnectionTarget,
  StartConnectionSource,
  StartDisconnectionTarget,
  StartDisconnectionSource,
  StartReduce,
  StartTooltip
} from "./nodes/StartNode";
import { StartNodeDefaults } from "./nodes/StartNode.default";
import PhaseNode, {
  PhaseConnectionTarget,
  PhaseConnectionSource,
  PhaseDisconnectionTarget,
  PhaseDisconnectionSource,
  PhaseReduce,
  PhaseTooltip
} from "./nodes/PhaseNode";
import { PhaseNodeDefaults } from "./nodes/PhaseNode.default";
import NormNode, {
  NormConnectionTarget,
  NormConnectionSource,
  NormDisconnectionTarget,
  NormDisconnectionSource,
  NormReduce,
  NormTooltip
} from "./nodes/NormNode";
import { NormNodeDefaults } from "./nodes/NormNode.default";
import GoalNode, {
  GoalConnectionTarget,
  GoalConnectionSource,
  GoalDisconnectionTarget,
  GoalDisconnectionSource,
  GoalReduce,
  GoalTooltip
} from "./nodes/GoalNode";
import { GoalNodeDefaults } from "./nodes/GoalNode.default";
import TriggerNode, {
  TriggerConnectionTarget,
  TriggerConnectionSource,
  TriggerDisconnectionTarget,
  TriggerDisconnectionSource,
  TriggerReduce,
  TriggerTooltip
} from "./nodes/TriggerNode";
import { TriggerNodeDefaults } from "./nodes/TriggerNode.default";
import InferredBeliefNode, {
  InferredBeliefConnectionTarget,
  InferredBeliefConnectionSource,
  InferredBeliefDisconnectionTarget,
  InferredBeliefDisconnectionSource,
  InferredBeliefReduce, InferredBeliefTooltip
} from "./nodes/InferredBeliefNode";
import { InferredBeliefNodeDefaults } from "./nodes/InferredBeliefNode.default";
import BasicBeliefNode, {
  BasicBeliefConnectionSource,
  BasicBeliefConnectionTarget,
  BasicBeliefDisconnectionSource,
  BasicBeliefDisconnectionTarget,
  BasicBeliefReduce
,
  BasicBeliefTooltip
} from "./nodes/BasicBeliefNode.tsx";
import { BasicBeliefNodeDefaults } from "./nodes/BasicBeliefNode.default.ts";

/**
 * Registered node types in the visual programming system.
 * 
 * Key: the node type string used in the flow graph.
 * Value: the corresponding React component for rendering the node.
 */
export const NodeTypes = {
  start: StartNode,
  end: EndNode,
  phase: PhaseNode,
  norm: NormNode,
  goal: GoalNode,
  trigger: TriggerNode,
  basic_belief: BasicBeliefNode,
  inferred_belief: InferredBeliefNode,
};

/**
 * Default data and settings for each node type.
 * These are defined in the <node>.default.ts files.
 * These defaults are used when a new node is created to initialize its properties.
 */
export const NodeDefaults = {
  start: StartNodeDefaults,
  end: EndNodeDefaults,
  phase: PhaseNodeDefaults,
  norm: NormNodeDefaults,
  goal: GoalNodeDefaults,
  trigger: TriggerNodeDefaults,
  basic_belief: BasicBeliefNodeDefaults,
  inferred_belief: InferredBeliefNodeDefaults,
};


/**
 * Reduce functions for each node type.
 * 
 * A reduce function extracts the relevant data from a node and its children.
 * Used during graph evaluation or export.
 */
export const NodeReduces = {
  start: StartReduce,
  end: EndReduce,
  phase: PhaseReduce,
  norm: NormReduce,
  goal: GoalReduce,
  trigger: TriggerReduce,
  basic_belief: BasicBeliefReduce,
  inferred_belief: InferredBeliefReduce,
}


/**
 * Connection functions for each node type.
 * 
 * These functions define any additional actions a node may perform
 * when a new connection is made
 */
export const NodeConnections = {
  Targets: {
    start: StartConnectionTarget,
    end: EndConnectionTarget,
    phase: PhaseConnectionTarget,
    norm: NormConnectionTarget,
    goal: GoalConnectionTarget,
    trigger: TriggerConnectionTarget,
    basic_belief: BasicBeliefConnectionTarget,
    inferred_belief: InferredBeliefConnectionTarget,
  },
  Sources: {
    start: StartConnectionSource,
    end: EndConnectionSource,
    phase: PhaseConnectionSource,
    norm: NormConnectionSource,
    goal: GoalConnectionSource,
    trigger: TriggerConnectionSource,
    basic_belief: BasicBeliefConnectionSource,
    inferred_belief: InferredBeliefConnectionSource,
  }
}

/**
 * Disconnection functions for each node type.
 *
 * These functions define any additional actions a node may perform
 * when a connection is disconnected
 */
export const NodeDisconnections = {
  Targets: {
    start: StartDisconnectionTarget,
    end: EndDisconnectionTarget,
    phase: PhaseDisconnectionTarget,
    norm: NormDisconnectionTarget,
    goal: GoalDisconnectionTarget,
    trigger: TriggerDisconnectionTarget,
    basic_belief: BasicBeliefDisconnectionTarget,
    inferred_belief: InferredBeliefDisconnectionTarget,
  },
  Sources: {
    start: StartDisconnectionSource,
    end: EndDisconnectionSource,
    phase: PhaseDisconnectionSource,
    norm: NormDisconnectionSource,
    goal: GoalDisconnectionSource,
    trigger: TriggerDisconnectionSource,
    basic_belief: BasicBeliefDisconnectionSource,
    inferred_belief: InferredBeliefDisconnectionSource,
  },
}

/**
 * Defines whether a node type can be deleted.
 * 
 * Returns a function per node type. Nodes not explicitly listed are deletable by default.
 */
export const NodeDeletes = {
  start: () => false,
  end: () => false,
}

/**
 * Defines which node types are considered variables in a phase node.
 * 
 * Any node type not listed here is automatically treated as part of a phase.
 * This allows the system to dynamically group nodes under a phase node.
 */
export const NodesInPhase = {
  start: () => false,
  end: () => false,
  phase: () => false,
  basic_belief: () => false,
  inferred_belief: () => false,
}

/**
 * Collects the tooltips for all nodeTypes so they can be accessed by the tooltip component
 */
export const NodeTooltips = {
  start: StartTooltip,
  end: EndTooltip,
  phase: PhaseTooltip,
  norm: NormTooltip,
  goal: GoalTooltip,
  trigger: TriggerTooltip,
  basic_belief: BasicBeliefTooltip,
  inferred_belief: InferredBeliefTooltip,
}