import { EDGE } from '../shape/gengral-config';

// 默认线
export const defaultEdgeData = {
    attrs: {
        line: {
            // 虚线
            stroke: EDGE.stroke.connecting,
            'stroke-width': 1,
            targetMarker: {
                name: 'block',
                width: 12,
                height: 12
            }
        }
    },
    router: {
        // 直线路由
        name: 'manhattan'
    },
    connector: {
        // 圆角连接器
        name: 'rounded'
    },
    zIndex: 2
};

// 带条件
export const conditionEdgeData = {
    attrs: {
        line: {
            stroke: '#000000', // 你的颜色
            'stroke-width': 1,
            targetMarker: {
                name: 'block',
                width: 12,
                height: 12
            }
        }
    },
    labels: [
        {
            markup: [
                {
                    tagName: 'rect',
                    selector: 'labelBody'
                },
                {
                    tagName: 'text',
                    selector: 'labelText'
                }
            ],
            attrs: {
                labelBody: {
                    ref: 'labelText',
                    refX: -8,
                    refY: -15,
                    refWidth: '100%',
                    refHeight: '100%',
                    refWidth2: 20,
                    refHeight2: 20,
                    stroke: '#60666B',
                    fill: '#fff',
                    strokeWidth: 1,
                    rx: 0,
                    ry: 0,
                    transform: 'rotate(45)' // 旋转45度，中心点为(10, 10)
                }
            },
            position: {
                distance: 0.5,
                args: {
                    keepGradient: true,
                    ensureLegibility: true
                }
            }
        }
    ],
    zIndex: 2
};

// 无逻辑
export const IllogicalEdgeData = {
    attrs: {
        line: {
            // 虚线
            strokeDasharray: 5,
            stroke: EDGE.stroke.connecting,
            'stroke-width': 1,
            sourceMarker: {
                tagName: 'circle',
                r: 4,
                cx: 4,
                fill: '#ffffff',
                stroke: '#60666B'
            },
            targetMarker: {
                name: 'block',
                width: 12,
                height: 12
            }
        }
    },
    zIndex: 2
};

// 带消息
export const noticeEdgeData = {
    attrs: {
        line: {
            // 虚线
            strokeDasharray: '5, 5',
            stroke: EDGE.stroke.connecting,
            'stroke-width': 1,
            sourceMarker: {
                tagName: 'circle',
                r: 4,
                cx: 4,
                fill: '#ffffff',
                stroke: '#60666B'
            },
            targetMarker: {
                name: 'block',
                width: 12,
                height: 12
            }
        }
    },
    labels: [
        {
            markup: [
                {
                    tagName: 'rect',
                    selector: 'labelBody'
                },
                {
                    tagName: 'text',
                    selector: 'labelText'
                },
                {
                    tagName: 'path',
                    selector: 'inboxIcon'
                }
            ],
            attrs: {
                labelBody: {
                    ref: 'labelText',
                    refX: -15,
                    refY: -10,
                    refWidth: '100%',
                    refHeight: '100%',
                    refWidth2: 30,
                    refHeight2: 20,
                    stroke: '#60666B',
                    fill: '#fff',
                    strokeWidth: 1,
                    rx: 0,
                    ry: 0
                },
                labelText: {
                    text: '', // 如果需要文本，可以在这里设置
                    fill: '#000',
                    fontSize: 12,
                    textAnchor: 'middle',
                    yAlignment: 'middle'
                },
                inboxIcon: {
                    d: 'M -20 -15 L-5 -5 L10 -15', // 简单收件箱图标路径
                    fill: 'none',
                    stroke: '#60666B',
                    strokeWidth: 1,
                    transform: 'translate(5, 5)' // 调整图标位置
                }
            },
            position: {
                distance: 0.5,
                args: {
                    keepGradient: true,
                    ensureLegibility: true
                }
            }
        }
    ],
    zIndex: 2
};

// 关联1
export const relation1EdgeData = {
    attrs: {
        line: {
            // 虚线
            strokeDasharray: '5, 5',
            stroke: EDGE.stroke.connecting,
            'stroke-width': 1,
            targetMarker: {
                tagName: 'path',
                d: 'M 10 -5 0 0 10 5', // 箭头形状的路径
                fill: 'none', // 只绘制边框
                stroke: '#60666B', // 边框颜色
                strokeWidth: 1,
                offsetX: -6 // 调整箭头位置，使其在边框上对齐
            }
        }
    },
    zIndex: 2
};

// 关联2
export const relation2EdgeData = {
    attrs: {
        line: {
            // 虚线
            strokeDasharray: '5, 5',
            stroke: EDGE.stroke.connecting,
            'stroke-width': 1,
            sourceMarker: {
                width: 4,
                height: 4,
                name: 'circle',
                fill: '#ffffff', // 只绘制边框
                stroke: '#3F78DF' // 边框颜色
            },
            targetMarker: {
                width: 4,
                height: 4,
                name: 'circle',
                fill: '#ffffff', // 只绘制边框
                stroke: '#3F78DF' // 边框颜色
            }
        }
    },
    zIndex: 2
};
