
import { register } from "@antv/x6-react-shape";
import { Node } from "@antv/x6";
import CustomInput from "../../CustomInput";
import { useSizeHook, useShapeProps } from "../../../hooks";
const component = ({ node }: { node: Node }) => {
  const { label, text, fill, stroke, opacity } = node.getData();
  const { size, ref } = useSizeHook();
  const {
    fillContent,
    defsContent,
    strokeColor,
    strokeWidth,
    strokeDasharray,
  } = useShapeProps(fill, size, stroke);
 const { width, height } = size || { width: 0, height: 0 };
  return (
    <>
      <div
        className="relative text-0 w-full h-full"
        ref={ref}
        style={{ opacity: opacity / 100 }}
      >
        <CustomInput value={label} styles={text} node={node} />
        <svg
          className="w-full h-full"
          viewBox={`0 0 ${width} ${height}`}
          xmlns="http://www.w3.org/2000/svg"
        >
          <defs>{defsContent}</defs>
          <rect
            x={strokeWidth + 8}
            y={strokeWidth}
            width={width - 2*strokeWidth - 8}
            height={height - strokeWidth - 8}
            rx={4}
            ry={4}
            fill={fillContent}
            stroke={strokeColor}
            strokeDasharray={strokeDasharray}
            strokeWidth={strokeWidth}
          />
          <rect
            x={strokeWidth}
            y={strokeWidth + 8}
            width={width - strokeWidth - 8}
            height={height - 2 * strokeWidth - 8}
            rx={4}
            ry={4}
            fill={fillContent}
            stroke={strokeColor}
            strokeDasharray={strokeDasharray}
            strokeWidth={strokeWidth}
          />
        </svg>
      </div>
    </>
  );
};

register({
  shape: "custom-react-multiplictyClass",
  width: 100,
  height: 70,
  effect: ["data"],
  component: component,
});

const multiplictyClass = {
  name: "多例类",
  icon: require("./image/multiplictyClass.png"),
  node: {
    shape: "custom-react-multiplictyClass",
    data: {
      label: "",
    },
  },
};

export default multiplictyClass;
