<template>
  <v-line
    :config="{
      ...data,
      zIndex: undefined,
      closed: true,
      points: flatPositions(data.points),
      opacity: addMode ? 0.3 : data.opacity,
    }"
    ref="shape"
  />
</template>

<script lang="ts" setup>
import { DC } from "@/deconstruction.js";
import { defaultStyle, TriangleData } from "./index.ts";
import { Line } from "konva/lib/shapes/Line";
import { computed, ref } from "vue";
import { flatPositions } from "@/utils/shared.ts";
const props = defineProps<{ data: TriangleData; addMode?: boolean }>();
const data = computed(() => ({ ...defaultStyle, ...props.data }));

const shape = ref<DC<Line>>();
defineExpose({
  get shape() {
    return shape.value;
  },
});
</script>
