import {
  font
} from "./chunk-SA7APTJR.js";
import "./chunk-HJ6L54YS.js";
import "./chunk-LSEFWW72.js";
import "./chunk-SKREEF3H.js";
import "./chunk-HYOEWQ5P.js";
import "./chunk-HBW42TDT.js";
import "./chunk-G6O3URDN.js";
import "./chunk-FN5XPUPH.js";
import "./chunk-IIT367QZ.js";
import "./chunk-RZGEKL77.js";
import "./chunk-UI7OCM2A.js";
import "./chunk-YZK37YCC.js";
import "./chunk-7EMWHCVW.js";
import "./chunk-7IYJZZQI.js";
import "./chunk-M3J4MINX.js";
import "./chunk-PF4DSFDR.js";
import "./chunk-QH6W3NVF.js";
import "./chunk-NOEAT6CX.js";
import {
  IN_frame,
  exoncolor
} from "./chunk-4UWS5Y3N.js";
import "./chunk-DD4R5P6W.js";
import "./chunk-JNITUVXP.js";
import "./chunk-KSGA62R2.js";
import "./chunk-LOZEKOES.js";
import "./chunk-TOU7EVFQ.js";
import "./chunk-OAWQ6LOO.js";
import "./chunk-TLT4YIG3.js";
import "./chunk-KYBIQBXE.js";
import "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import "./chunk-HFNDKYVF.js";

// src/spliceevent.a53ss.diagram.js
var junctionBcolor = "#990000";
var color_truncateexon = "#00A352";
function spliceevent_a53ss_diagram_default(arg) {
  const evt = arg.event;
  if (!evt) {
    arg.holder.text(".event missing");
    return;
  }
  if (evt.a5ss == void 0 && evt.a3ss == void 0) {
    arg.holder.text("not a5ss or a3ss");
    return;
  }
  const exonwidth = 30;
  const intronwidth = 30;
  const exonheight = 20;
  const distfontsize = exonheight - 5;
  const junctionheight = 20;
  const xpad = 30;
  const ypad = 20;
  const svg = arg.holder.append("svg");
  const g = svg.append("g").attr("transform", "translate(" + xpad + "," + ypad + ")");
  const distlabel = evt.sitedist + " nt";
  let distlabelw;
  g.append("text").text(distlabel).attr("font-size", distfontsize).attr("font-family", font).each(function() {
    distlabelw = this.getBBox().width;
  }).remove();
  const distlabelpad = 5;
  let leftinexon = false;
  let rightinexon = false;
  let leftinintron = false;
  let rightinintron = false;
  if (evt.a5ss) {
    if (evt.altinexon) leftinexon = true;
    else leftinintron = true;
  } else {
    if (evt.altinexon) rightinexon = true;
    else rightinintron = true;
  }
  let x = 0;
  let intronstart;
  let intronstop;
  g.append("rect").attr("fill", exoncolor).attr("stroke", exoncolor).attr("x", x).attr("y", junctionheight).attr("width", exonwidth).attr("height", exonheight).attr("shape-rendering", "crispEdges");
  g.append("text").text("e" + (evt.exon5idx + 1)).attr("text-anchor", "middle").attr("x", x + exonwidth / 2).attr("y", junctionheight + exonheight / 2).attr("fill", "white").attr("dominant-baseline", "central").attr("font-size", distfontsize).attr("font-family", font);
  x += exonwidth;
  if (leftinexon) {
    g.append("rect").attr("fill", color_truncateexon).attr("stroke", color_truncateexon).attr("x", x).attr("y", junctionheight).attr("width", distlabelw + distlabelpad * 2).attr("height", exonheight).attr("shape-rendering", "crispEdges");
    g.append("text").text(distlabel).attr("text-anchor", "middle").attr("x", x + distlabelw / 2 + distlabelpad).attr("y", junctionheight + exonheight / 2).attr("fill", "white").attr("dominant-baseline", "central").attr("font-size", distfontsize).attr("font-family", font);
    x += distlabelw + distlabelpad * 2;
  }
  intronstart = x;
  if (leftinintron || rightinintron) {
    if (leftinintron) {
    } else {
      x += intronwidth;
    }
    g.append("rect").attr("fill", "none").attr("stroke", exoncolor).attr("x", x).attr("y", junctionheight).attr("width", distlabelw + distlabelpad * 2).attr("height", exonheight).attr("shape-rendering", "crispEdges");
    g.append("text").text(distlabel).attr("text-anchor", "middle").attr("x", x + distlabelw / 2 + distlabelpad).attr("y", junctionheight + exonheight / 2).attr("font-size", distfontsize).attr("font-family", font).attr("dominant-baseline", "central");
    x += distlabelw + distlabelpad * 2;
    if (leftinintron) {
      x += intronwidth;
    }
  } else {
    x += intronwidth;
  }
  intronstop = x;
  g.append("line").attr("x1", intronstart + (leftinintron ? distlabelw + distlabelpad * 2 : 0)).attr("y1", junctionheight + exonheight / 2).attr("x2", intronstop - (rightinintron ? distlabelw + distlabelpad * 2 : 0)).attr("y2", junctionheight + exonheight / 2).attr("stroke", exoncolor).attr("shape-rendering", "crispEdges");
  if (rightinexon) {
    g.append("rect").attr("fill", color_truncateexon).attr("stroke", color_truncateexon).attr("x", x).attr("y", junctionheight).attr("width", distlabelw + distlabelpad * 2).attr("height", exonheight).attr("shape-rendering", "crispEdges");
    g.append("text").text(distlabel).attr("text-anchor", "middle").attr("x", x + distlabelw / 2 + distlabelpad).attr("y", junctionheight + exonheight / 2).attr("fill", "white").attr("dominant-baseline", "central").attr("font-size", distfontsize).attr("font-family", font);
    x += distlabelw + distlabelpad * 2;
  }
  g.append("rect").attr("fill", exoncolor).attr("stroke", exoncolor).attr("x", x).attr("y", junctionheight).attr("width", exonwidth).attr("height", exonheight).attr("shape-rendering", "crispEdges");
  g.append("text").text("e" + (evt.exon5idx + 1 + 1)).attr("text-anchor", "middle").attr("x", x + exonwidth / 2).attr("y", junctionheight + exonheight / 2).attr("fill", "white").attr("dominant-baseline", "central").attr("font-size", distfontsize).attr("font-family", font);
  {
    let x1, x2;
    if (leftinexon || leftinintron) {
      x2 = intronstop;
      if (leftinexon) {
        x1 = intronstart - distlabelw - distlabelpad * 2;
      } else {
        x1 = intronstart + distlabelw + distlabelpad * 2;
      }
    } else {
      x1 = intronstart;
      if (rightinintron) {
        x2 = intronstop - distlabelw - distlabelpad * 2;
      } else {
        x2 = intronstop + distlabelw + distlabelpad * 2;
      }
    }
    g.append("path").attr("d", "M" + x1 + "," + junctionheight + "L" + (x1 + x2) / 2 + ",0L" + x2 + "," + junctionheight).attr("stroke", junctionBcolor).attr("fill", "none");
    g.append("text").text(evt.junctionB.v + (evt.frame != void 0 ? evt.frame == IN_frame ? ", in frame" : ",out of frame" : "")).attr("x", (x1 + x2) / 2).attr("y", -1).attr("text-anchor", "middle").attr("font-size", distfontsize).attr("fill", junctionBcolor);
  }
  let jAreadcounttext;
  {
    const line = g.append("path").attr(
      "d",
      "M" + intronstart + "," + (junctionheight + exonheight) + "L" + (intronstart + intronstop) / 2 + "," + (junctionheight * 2 + exonheight) + "L" + intronstop + "," + (junctionheight + exonheight)
    ).attr("stroke", exoncolor).attr("fill", "none");
    const nj = evt.junctionA;
    if (nj) {
      jAreadcounttext = g.append("text").text(nj.v).attr("x", (intronstart + intronstop) / 2).attr("y", junctionheight * 2 + exonheight + 1).attr("text-anchor", "middle").attr("font-size", distfontsize).attr("dominant-baseline", "hanging");
    } else {
      line.attr("stroke-dasharray", "3,3");
    }
  }
  svg.attr("width", xpad * 2 + exonwidth * 2 + intronwidth + distlabelw + distlabelpad * 2).attr("height", ypad * 2 + junctionheight * 2 + exonheight);
  return jAreadcounttext;
}
export {
  spliceevent_a53ss_diagram_default as default
};
//# sourceMappingURL=spliceevent.a53ss.diagram-LLJSPV7M.js.map
