import o from "../../../node_modules/bpmn-js/lib/NavigatedViewer.mjs";
import t from "./bpmnjs/renderer/index.mjs";
import m from "./bpmnjs/importer/index.mjs";
var s = Object.defineProperty;
var a = (r, e, t2) => e in r ? s(r, e, { enumerable: true, configurable: true, writable: true, value: t2 }) : r[e] = t2;
var n = (r, e, t2) => (a(r, e + "", t2), t2);
class w {
  constructor(e) {
    n(this, "addTestMarker", function() {
      if (document.querySelector("#testMarker"))
        return;
      let e2 = document.createElementNS(
        "http://www.w3.org/2000/svg",
        "marker"
      );
      e2.setAttribute("id", "testMarker"), e2.setAttribute("viewBox", "0 0 20 20"), e2.setAttribute("refX", "11"), e2.setAttribute("refY", "10"), e2.setAttribute("markerWidth", "10"), e2.setAttribute("markerHeight", "10"), e2.setAttribute("orient", "auto");
      let t2 = document.createElementNS("http://www.w3.org/2000/svg", "path");
      t2.setAttribute("d", "M 1 5 L 11 10 L 1 15 Z"), t2.setAttribute(
        "style",
        "fill: black; stroke-width: 1px; stroke-linecap: round; stroke-dasharray: 10000, 1; stroke: black;"
      ), e2.appendChild(t2);
      try {
        typeof this.container == "object" ? this.container.querySelector("defs").appendChild(e2) : document.querySelector(this.container).querySelector("defs").appendChild(e2);
      } catch {
        document.querySelector("defs").appendChild(e2);
      }
    });
    this.container = e, this.refresh(), this.bpmnViewer && this.bpmnViewer.destroy(), this.bpmnViewer = new o({
      container: this.container,
      additionalModules: [
        t,
        m,
        {
          // zoomScroll: ["value", ''],//禁用滚动
          // moveCanvas: ['value', ''],//禁用拖动整个流程图
          move: ["value", ""]
          //禁用单个图形拖动
        }
      ]
      // keyboard: {
      //   bindTo: document, // 或者window，注意与外部表单的键盘监听事件是否冲突
      // },
    });
  }
  refresh() {
    if (this.container)
      if (typeof this.container == "object")
        this.container.innerHTML = "";
      else {
        let e = document.querySelector(this.container);
        e && (e.innerHTML = "");
      }
  }
  import(e) {
    this.data = e, window.flowChartData = e, this.bpmnViewer.importXML(e.modelXml).then(() => {
      this.colorToFlow(e.highLightedFlows), this.bpmnViewer.get("canvas").zoom("fit-viewport", "auto");
    });
  }
  colorToFlow(e) {
    if (this.addTestMarker(), e.length > 0)
      for (var t2 in e) {
        var i = e[t2].id || e[t2];
        let o2 = document.querySelector(`g[data-element-id=${i}]`);
        o2 && o2.classList.contains("djs-connection") && o2.setAttribute("state", "highlight");
      }
  }
}
export {
  w as default
};
