import { readable, writable } from 'svelte/store'; import { SelectionMode, type D3ZoomInstance, type D3SelectionInstance, ConnectionMode, ConnectionLineType, type SelectionRect, type Transform, type SnapGrid, type MarkerProps } from '@reactflow/system'; import DefaultNode from '$lib/components/nodes/DefaultNode.svelte'; import InputNode from '$lib/components/nodes/InputNode.svelte'; import OutputNode from '$lib/components/nodes/OutputNode.svelte'; import BezierEdge from '$lib/components/edges/BezierEdge.svelte'; import StraightEdge from '$lib/components/edges/StraightEdge.svelte'; import SmoothStepEdge from '$lib/components/edges/SmoothStepEdge.svelte'; import StepEdge from '$lib/components/edges/StepEdge.svelte'; import type { ConnectionData, NodeTypes, EdgeTypes, EdgeLayouted, Edge, Node, IsValidConnection } from '$lib/types'; export const initConnectionData = { nodeId: null, handleId: null, handleType: null, position: null, status: null }; export const initialNodeTypes = { input: InputNode, output: OutputNode, default: DefaultNode }; export const initialEdgeTypes = { straight: StraightEdge, smoothstep: SmoothStepEdge, default: BezierEdge, step: StepEdge }; export const initialStoreState = { flowId: writable(null), nodes: writable([]), edges: writable([]), edgesLayouted: readable([]), height: writable(500), width: writable(500), minZoom: writable(0.5), maxZoom: writable(2), fitViewOnInit: writable(false), fitViewOnInitDone: writable(false), d3: writable<{ zoom: D3ZoomInstance | null; selection: D3SelectionInstance | null }>({ zoom: null, selection: null }), snapGrid: writable(null), dragging: writable(false), selectionRect: writable(null), selectionKeyPressed: writable(false), multiselectionKeyPressed: writable(false), deleteKeyPressed: writable(false), selectionRectMode: writable(null), selectionMode: writable(SelectionMode.Partial), nodeTypes: writable(initialNodeTypes), edgeTypes: writable(initialEdgeTypes), transform: writable([0, 0, 1]), connectionMode: writable(ConnectionMode.Strict), domNode: writable(null), connectionPath: readable(null), connection: writable(initConnectionData), connectionRadius: writable(25), connectionLineType: writable(ConnectionLineType.Bezier), isValidConnection: writable(() => true), nodesDraggable: writable(true), nodesConnectable: writable(true), elementsSelectable: writable(true), markers: readable([]), defaultMarkerColor: writable('#b1b1b7') };