import React from "react";
import shouldFlipText from "./shouldFlipText";
import { getComplementSequenceString } from "@teselagen/sequence-utils";
import { getDnaColor } from "../constants/dnaToColor";
export function CircularDnaSequence(_ref) {
  var rotationRadians = _ref.rotationRadians,
    _ref$textHeightOffset = _ref.textHeightOffset,
    textHeightOffset = _ref$textHeightOffset === void 0 ? -5 : _ref$textHeightOffset,
    annotation = _ref.annotation,
    showReverseSequence = _ref.showReverseSequence,
    showDnaColors = _ref.showDnaColors,
    showSeqText = _ref.showSeqText,
    totalAngle = _ref.totalAngle,
    radius = _ref.radius;
  var shouldFlip = shouldFlipText(annotation.startAngle + rotationRadians);
  var getShared = function getShared(_ref2) {
    var textHeightOffset = _ref2.textHeightOffset,
      isReverse = _ref2.isReverse;
    return {
      className: "ve-monospace-font " + (isReverse ? "ve-sequence-reverse" : ""),
      transform: (shouldFlip ? "rotate(180)" : "") + (" translate(0, " + (shouldFlip ? -textHeightOffset : textHeightOffset) + ")"),
      style: {
        fontSize: 12,
        textAnchor: "middle",
        dominantBaseline: "central"
      }
    };
  };
  var forward = null;
  var reverse = null;
  var dnaColors = null;
  if (showSeqText) {
    forward = /*#__PURE__*/React.createElement("text", getShared({
      textHeightOffset: showReverseSequence ? textHeightOffset - 15 : textHeightOffset
    }), annotation.letter);
  }
  if (showSeqText && showReverseSequence) {
    reverse = /*#__PURE__*/React.createElement("text", getShared({
      textHeightOffset: textHeightOffset,
      isReverse: true
    }), getComplementSequenceString(annotation.letter));
  }
  if (!showSeqText || showDnaColors) {
    var height = showReverseSequence ? 30 : 15;
    var width = Math.max(totalAngle * radius);
    dnaColors = /*#__PURE__*/React.createElement("rect", {
      fill: getDnaColor(annotation.letter),
      height: height,
      width: width,
      transform: "translate(-" + width / 2 + ", -" + (height - 3) + ")",
      className: "veDnaColor"
    });
  }
  return /*#__PURE__*/React.createElement("g", null, dnaColors, forward, reverse);
}