import { E as C, ad as V, c as P, s as G, g as H, M as O, ac as h, ae as X, G as z, J as F, L as k, T as w, C as v, R as y, m as g, b as E, w as Y, d as j, aj as q, q as b, P as B, h as M, j as A } from "./am-chart.H2jnOzFc.js";
let x;
function J(r, e, t) {
  const i = e.interfaceColors, a = i.get("secondaryButton").toCSS(), n = i.get("text").toCSS(), o = i.get("alternativeBackground").toCSS(0.45);
  if (!x) {
    const s = new O([
      new h(r, ".am5-modal", {
        width: "100%",
        height: "100%",
        position: "absolute",
        "z-index": "100000",
        top: "0",
        left: "0"
      }, e.nonce),
      new h(r, ".am5-modal-curtain", {
        top: "0",
        left: "0",
        width: "100%",
        height: "100%",
        position: "absolute",
        background: i.get("background").toCSS(0.5),
        "z-index": "100"
      }, e.nonce),
      new h(r, ".am5-modal-wrapper", {
        top: "0",
        left: "0",
        width: "100%",
        height: "100%",
        position: "absolute",
        "text-align": "center",
        "white-space": "nowrap",
        background: i.get("background").toCSS(0.5),
        "z-index": "101"
      }, e.nonce),
      new h(r, ".am5-modal-wrapper:before", {
        content: "''",
        display: "inline-block",
        height: "100%",
        "vertical-align": "middle",
        "margin-right": "-0.25em"
      }, e.nonce),
      new h(r, ".am5-modal-content", {
        display: "inline-block",
        padding: "1.2em",
        "vertical-align": "middle",
        "text-align": "start",
        "white-space": "normal",
        background: i.get("background").toCSS(),
        //"border": "1px solid " + ic.get("alternativeBackground")!.toCSS(),
        "border-radius": "4px",
        "-webkit-box-shadow": "0px 0px 36px 0px " + o,
        "box-shadow": "0px 0px 36px 0px " + o,
        color: n
      }, e.nonce),
      new h(r, ".am5-modal-content h1", {
        "font-size": "1em",
        margin: "0 0 0.5em 0"
      }, e.nonce),
      new h(r, ".am5-modal-table", {
        display: "table",
        margin: "1em 0"
      }, e.nonce),
      new h(r, ".am5-modal-table-row", {
        display: "table-row"
      }, e.nonce),
      new h(r, ".am5-modal-table-heading", {
        display: "table-heading",
        padding: "3px 10px 3px 0"
      }, e.nonce),
      new h(r, ".am5-modal-table-cell", {
        display: "table-cell",
        padding: "3px 0 3px 0"
      }, e.nonce),
      new h(r, ".am5-modal-table-cell > *", {
        "vertical-align": "middle"
      }, e.nonce),
      new h(r, ".am5-modal-content input[type=text], .am5-modal-content input[type=number], .am5-modal-content select", {
        border: "1px solid " + a,
        "border-radius": "4px",
        padding: "3px 5px",
        margin: "2px"
      }, e.nonce),
      new h(r, ".am5-modal-input-narrow", {
        width: "50px"
      }, e.nonce),
      new h(r, ".am5-modal-button", {
        "font-weight": "400",
        color: i.get("secondaryButtonText").toCSS(),
        "line-height": "1.5",
        "text-align": "center",
        "text-decoration": "none",
        "vertical-align": "middle",
        cursor: "pointer",
        padding: "0.2em 0.8em",
        "font-size": "1em",
        "border-radius": "0.25em",
        margin: "0 0.25em 0 0",
        border: "1px solid " + i.get("secondaryButtonStroke").toCSS(),
        background: i.get("secondaryButton").toCSS()
      }, e.nonce),
      new h(r, ".am5-modal-button:hover", {
        background: i.get("secondaryButtonHover").toCSS()
      }, e.nonce),
      new h(r, ".am5-modal-button.am5-modal-primary", {
        color: i.get("primaryButtonText").toCSS(),
        border: "1px solid " + i.get("primaryButtonStroke").toCSS(),
        background: i.get("primaryButton").toCSS()
      }, e.nonce),
      new h(r, ".am5-modal-button.am5-modal-primary:hover", {
        background: i.get("primaryButtonHover").toCSS()
      }, e.nonce)
    ]);
    x = new X(() => {
      x = void 0, s.dispose();
    });
  }
  return x.increment();
}
class S extends C {
  //protected _currentPass: number = 0;
  _afterNew() {
    super._afterNewApplyThemes(), this._setRawDefault("deactivateRoot", !0), J(V(this._root.dom), this._root);
    const e = document.createElement("div");
    e.className = "am5-modal", e.style.display = "none", this.root._inner.appendChild(e), this.setPrivate("container", e);
    const t = document.createElement("div");
    t.className = "am5-modal-curtain", e.appendChild(t), this.setPrivate("curtain", t), this._disposers.push(P(t, "click", () => {
      this.cancel();
    }));
    const i = document.createElement("div");
    i.className = "am5-modal-wrapper", e.appendChild(i), this.setPrivate("wrapper", i);
    const a = document.createElement("div");
    a.className = "am5-modal-content", i.appendChild(a), this.setPrivate("content", a);
    const n = this.get("content");
    n && (a.innerHTML = n), G("keyboardevents") && this._disposers.push(P(document, "keydown", (o) => {
      this.isOpen() && H(o) == "Escape" && this.cancel();
    }));
  }
  _beforeChanged() {
    super._beforeChanged(), this.isDirty("content") && (this.getPrivate("content").innerHTML = this.get("content", ""));
  }
  /**
   * Returns `true` if modal is currently open.
   *
   * @return  Modal open?
   */
  isOpen() {
    return this.getPrivate("container").style.display != "none";
  }
  /**
   * Opens modal.
   */
  open() {
    this.getPrivate("container").style.display = "block", this.get("deactivateRoot") && this.setTimeout(() => {
      this._root._renderer.interactionsEnabled = !1;
    }, 10), this.events.dispatch("opened", {
      type: "opened",
      target: this
    });
  }
  /**
   * Closes modal.
   */
  close() {
    this.getPrivate("container").style.display = "none", this.get("deactivateRoot") && (this._root._renderer.interactionsEnabled = !0), this.events.dispatch("closed", {
      type: "closed",
      target: this
    });
  }
  /**
   * Closes modal and invokes `cancelled` event.
   */
  cancel() {
    this.getPrivate("container").style.display = "none", this.get("deactivateRoot") && (this._root._renderer.interactionsEnabled = !0), this.events.dispatch("cancelled", {
      type: "cancelled",
      target: this
    });
  }
  /**
   * Disposes modal.
   */
  _dispose() {
    super._dispose();
    const e = this.getPrivate("container");
    e.parentElement && e.parentElement.removeChild(e);
  }
}
S.className = "Modal";
S.classNames = C.classNames.concat([S.className]);
class T extends C {
  _afterNew() {
    super._afterNewApplyThemes();
  }
  _beforeChanged() {
    if (super._beforeChanged(), this.isDirty("sprite")) {
      const e = this.get("sprite");
      e && (e.setAll({ position: "absolute", role: "figure" }), this._disposers.push(e));
    }
    (this.isDirty("locationX") || this.isDirty("locationY")) && this.series && this.series._positionBullet(this);
  }
}
T.className = "Bullet";
T.classNames = C.classNames.concat([T.className]);
class D extends z {
  _beforeChanged() {
    super._beforeChanged(), (this.isDirty("radiusX") || this.isDirty("radiusY") || this.isDirty("rotation")) && (this._clear = !0);
  }
  _changed() {
    super._changed(), this._clear && this._display.drawEllipse(0, 0, Math.abs(this.get("radiusX")), Math.abs(this.get("radiusY")));
  }
}
D.className = "Ellipse";
D.classNames = z.classNames.concat([D.className]);
class L extends F {
  constructor() {
    super(...arguments), this.itemContainers = this.addDisposer(new k(w.new({}), () => v._new(this._root, {
      themeTags: g(this.itemContainers.template.get("themeTags", []), ["legend", "item"]),
      themeTagsSelf: g(this.itemContainers.template.get("themeTagsSelf", []), ["itemcontainer"]),
      background: y.new(this._root, {
        themeTags: g(this.itemContainers.template.get("themeTags", []), ["legend", "item", "background"]),
        themeTagsSelf: g(this.itemContainers.template.get("themeTagsSelf", []), ["itemcontainer"])
      })
    }, [this.itemContainers.template]))), this.markers = this.addDisposer(new k(w.new({}), () => v._new(this._root, {
      themeTags: g(this.markers.template.get("themeTags", []), ["legend", "marker"])
    }, [this.markers.template]))), this.labels = this.addDisposer(new k(w.new({}), () => E._new(this._root, {
      themeTags: g(this.labels.template.get("themeTags", []), ["legend", "label"])
    }, [this.labels.template]))), this.valueLabels = this.addDisposer(new k(w.new({}), () => E._new(this._root, {
      themeTags: g(this.valueLabels.template.get("themeTags", []), ["legend", "label", "value"])
    }, [this.valueLabels.template]))), this.markerRectangles = this.addDisposer(new k(w.new({}), () => y._new(this._root, {
      themeTags: g(this.markerRectangles.template.get("themeTags", []), ["legend", "marker", "rectangle"])
    }, [this.markerRectangles.template])));
  }
  _afterNew() {
    this._settings.themeTags = g(this._settings.themeTags, ["legend"]), this.fields.push("name", "stroke", "fill"), super._afterNew();
  }
  /**
   * @ignore
   */
  makeItemContainer(e) {
    const t = this.children.push(this.itemContainers.make());
    return t._setDataItem(e), this.itemContainers.push(t), t.states.create("disabled", {}), t;
  }
  /**
   * @ignore
   */
  makeMarker() {
    const e = this.markers.make();
    return this.markers.push(e), e.states.create("disabled", {}), e;
  }
  /**
   * @ignore
   */
  makeLabel() {
    const e = this.labels.make();
    return e.states.create("disabled", {}), e;
  }
  /**
   * @ignore
   */
  makeValueLabel() {
    const e = this.valueLabels.make();
    return e.states.create("disabled", {}), e;
  }
  /**
   * @ignore
   */
  makeMarkerRectangle() {
    const e = this.markerRectangles.make();
    return e.states.create("disabled", {}), e;
  }
  processDataItem(e) {
    super.processDataItem(e);
    const t = this.makeItemContainer(e), i = this.get("nameField"), a = this.get("fillField"), n = this.get("strokeField");
    if (t) {
      const o = this.get("clickTarget", "itemContainer"), s = e.dataContext;
      s && s.set && s.set("legendDataItem", e), t._setDataItem(e), e.set("itemContainer", t);
      const p = this.makeMarker();
      if (p) {
        t.children.push(p), p._setDataItem(e), e.set("marker", p);
        const l = this.get("useDefaultMarker"), c = p.children.push(this.makeMarkerRectangle());
        let f = e.get("fill"), u = e.get("stroke");
        e.set("markerRectangle", c), s && s.get && (f = s.get(a, f), u = s.get(n, u)), u || (u = f), l ? s.on && (s.on(a, () => {
          c.set("fill", s.get(a));
        }), s.on(n, () => {
          c.set("stroke", s.get(n));
        })) : s && s.createLegendMarker && s.createLegendMarker(), c.setAll({ fill: f, stroke: u });
        const _ = s.component;
        _ && _.updateLegendMarker && _.updateLegendMarker(s);
      }
      const d = this.makeLabel();
      if (d) {
        t.children.push(d), d._setDataItem(e), e.set("label", d), d.text.on("text", () => {
          t.setRaw("ariaLabel", d.text._getText() + (this.get("clickTarget") !== "none" ? "; " + this._t("Press ENTER to toggle") : "")), t.markDirtyAccessibility();
        }), s && s.get && e.set("name", s.get(i));
        let l = e.get("name");
        l && d.set("text", l);
      }
      const m = this.makeValueLabel();
      if (m && (t.children.push(m), m._setDataItem(e), e.set("valueLabel", m)), s && s.show && (s.on("visible", (l) => {
        t.set("disabled", !l);
      }), s.get("visible") || t.set("disabled", !0), o != "none")) {
        let l = t;
        o == "marker" && (l = p), this._addClickEvents(l, s, e);
      }
      this.children.values.sort((l, c) => {
        const f = l.dataItem.dataContext, u = c.dataItem.dataContext;
        if (f && u) {
          const _ = this.data.indexOf(f), R = this.data.indexOf(u);
          if (_ > R)
            return 1;
          if (_ < R)
            return -1;
        }
        return 0;
      }), s && s.updateLegendValue && s.updateLegendValue();
    }
  }
  _addClickEvents(e, t, i) {
    e.set("cursorOverStyle", "pointer"), e.events.on("pointerover", () => {
      const a = t.component;
      a && a.hoverDataItem && a.hoverDataItem(t);
    }), e.events.on("pointerout", () => {
      const a = t.component;
      a && a.hoverDataItem && a.unhoverDataItem(t);
    }), e.events.on("click", () => {
      const a = i.get("label").text._getText();
      t.show && t.isHidden && (t.isHidden() || t.get("visible") === !1) ? (t.show(), e.set("disabled", !1), this._root.readerAlert(this._t("%1 shown", this._root.locale, a))) : t.hide && (t.hide(), e.set("disabled", !0), this._root.readerAlert(this._t("%1 hidden", this._root.locale, a)));
    });
  }
  /**
   * @ignore
   */
  disposeDataItem(e) {
    super.disposeDataItem(e);
    const t = e.dataContext;
    t && t.get && t.get("legendDataItem") == e && t.set("legendDataItem", void 0);
    let i = e.get("itemContainer");
    i && (this.itemContainers.removeValue(i), i.dispose());
    let a = e.get("marker");
    a && (this.markers.removeValue(a), a.dispose());
    let n = e.get("markerRectangle");
    n && (this.markerRectangles.removeValue(n), n.dispose());
    let o = e.get("label");
    o && (this.labels.removeValue(o), o.dispose());
    let s = e.get("valueLabel");
    s && (this.valueLabels.removeValue(s), s.dispose());
  }
}
L.className = "Legend";
L.classNames = F.classNames.concat([L.className]);
class N extends v {
  constructor() {
    super(...arguments), this.rectangle = this.children.push(Y.new(this._root, { themeTags: ["rectangle"], fillOpacity: 0, fill: j(16777215) })), this.gripL = this._createGrip("left"), this.gripR = this._createGrip("right"), this.gripT = this._createGrip("top"), this.gripB = this._createGrip("bottom"), this._is = 1, this._ix = 0, this._iw = 0, this._isHover = !1;
  }
  _afterNew() {
    super._afterNew(), this.addTag("resizer"), this.set("visible", !1), this.gripL.events.on("dragged", (e) => {
      this._resize(e.target, -1);
    }), this.gripR.events.on("dragged", (e) => {
      this._resize(e.target, 1);
    }), this.gripL.events.on("dragstart", (e) => {
      this._resizeStart(e.target);
    }), this.gripR.events.on("dragstart", (e) => {
      this._resizeStart(e.target);
    }), this.gripT.events.on("dragged", (e) => {
      this._rotate(e, 90);
    }), this.gripB.events.on("dragged", (e) => {
      this._rotate(e, -90);
    }), this.gripT.events.on("dragstart", (e) => {
      this._resizeStart(e.target);
    }), this.gripB.events.on("dragstart", (e) => {
      this._resizeStart(e.target);
    });
  }
  _resizeStart(e) {
    const t = this.get("sprite");
    t && (this._is = t.get("scale", 1), this._ix = e.x(), this._iw = this.width() / 2);
  }
  _resize(e, t) {
    const i = this.get("sprite"), a = this.get("spriteTemplate");
    if (i) {
      const n = Math.max(0.01, this._is * (1 + t * (e.x() - this._ix) / this._iw));
      a ? a.set("scale", n) : i.set("scale", n), i.states.lookup("default").set("scale", n), this._updatePositions();
    }
  }
  _rotate(e, t) {
    const i = this.get("sprite"), a = this.get("spriteTemplate");
    if (i) {
      const n = this.parent;
      if (n) {
        const o = this.get("rotationStep", 10);
        let s = Math.round((q({ x: this.x(), y: this.y() }, n.toLocal(e.point)) + t) / o) * o;
        a ? a.set("rotation", s) : i.set("rotation", s), i.states.lookup("default").set("rotation", s), this._updatePositions();
      }
    }
  }
  _createGrip(e) {
    const t = this.children.push(v.new(this._root, {
      themeTags: ["grip", e],
      setStateOnChildren: !0,
      draggable: !0
    }));
    return t.children.push(y.new(this._root, {
      themeTags: ["outline"],
      centerX: b,
      centerY: b
    })), t.children.push(y.new(this._root, {
      centerX: b,
      centerY: b
    })), t;
  }
  _updateChildren() {
    if (super._updateChildren(), this.isDirty("sprite")) {
      const e = this.get("sprite");
      if (e) {
        this.show(0), this.setPrivate("visible", !0), this._updatePositions();
        const t = e.parent;
        t && t.children.moveValue(this, 0), this._positionDP = e.events.on("positionchanged", () => {
          this._updatePositions();
        }), this._positionDP = e.events.on("boundschanged", () => {
          this._updatePositions();
        });
      } else
        this.hide(0), this.setPrivate("visible", !1), this._positionDP && this._positionDP.dispose();
    }
    (this.isDirty("width") || this.isDirty("height") || this.isDirty("rotation")) && this._updatePositions();
  }
  _updatePositions() {
    const e = this.get("sprite");
    if (e) {
      let t = e.localBounds(), i = e.get("scale", 1), a = 20, n = (t.right - t.left) * i + a, o = (t.bottom - t.top) * i + a, s = e.get("rotation", 0);
      const p = this.rectangle;
      let d = e.get("centerX", b), m = e.get("centerY", b), l = 0;
      d instanceof B && (l = d.value);
      let c = 0;
      m instanceof B && (c = m.value), p.setAll({ centerX: d, centerY: m, width: n, height: o }), this.setAll({ x: e.x() + a * (l - 0.5) * M(s) - a * (c - 0.5) * A(s), y: e.y() + a * (c - 0.5) * M(s) + a * (l - 0.5) * A(s), width: n, height: o, rotation: s }), this.gripT.setAll({ x: (0.5 - l) * n, y: -c * o }), this.gripB.setAll({ x: (0.5 - l) * n, y: (1 - c) * o }), this.gripL.setAll({ x: -l * n, y: (0.5 - c) * o }), this.gripR.setAll({ x: (1 - l) * n, y: (0.5 - c) * o }), this.rectangle.setAll({ width: n, height: o });
    }
  }
}
N.className = "SpriteResizer";
N.classNames = v.classNames.concat([N.className]);
export {
  T as B,
  D as E,
  L,
  S as M,
  N as S
};
