import { withInstall as D } from "@das-fed/utils/with-install/index";
import { defineComponent as L, ref as a, computed as H, onMounted as T, nextTick as V, createBlock as I, openBlock as O, Teleport as P, createElementVNode as W, normalizeStyle as E, toDisplayString as R } from "vue";
import { getVarValue as k } from "@das-fed/web/packages/theme/index";
const j = /* @__PURE__ */ L({
  __name: "index",
  props: {
    getEl: {},
    errorLabel: { default: "" },
    errorModelZIndex: { default: 2e3 },
    errorWidth: { default: void 0 }
  },
  setup(w) {
    const r = w, C = a(null), n = a(), l = a({
      x: 0,
      y: 0
    }), v = H(() => ({
      "box-sizing": "border-box",
      "font-size": "12px",
      "background-color": k("--das-ui-color-overlay-error").value,
      "box-shadow": "0px 4px 10px 0px rgba(0, 0, 0, 0.2)",
      "border-radius": "1px",
      padding: "2px 8px",
      "z-index": r.errorModelZIndex
    })), _ = H(() => ({
      ...v.value,
      width: n.value + "px",
      position: "fixed",
      visibility: "visible",
      top: l.value.y + "px",
      left: l.value.x + "px"
    })), u = a({
      // display: 'block',
      color: k("--das-ui-input-error-color").value,
      "white-space": "break-spaces"
    }), S = () => {
      const h = (c = 0) => {
        const o = document.createElement("div");
        for (let [m, x] of Object.entries({
          ...v.value,
          ...u.value,
          width: c + "px"
        }))
          o.style[m] = x;
        const t = document.createElement("span");
        for (let [m, x] of Object.entries(u.value))
          t.style[m] = x;
        t.textContent = r.errorLabel, o.appendChild(t), document.body.appendChild(o);
        const d = o.offsetHeight, B = t.offsetWidth;
        return document.body.removeChild(o), { height: d, textWidth: B };
      }, f = () => {
        const c = document.documentElement.clientHeight, t = document.documentElement.scrollHeight - c, d = c - t;
        return console.log("可视区域高度（不包括滚动条）：" + d), d;
      }, e = r.getEl(), i = (e == null ? void 0 : e.clientWidth) ?? 0, b = h(i), p = b.textWidth;
      console.log("inputTextWidth========" + p), console.log("inputElWidth========" + i), r.errorWidth ? n.value = r.errorWidth : p > i ? n.value = p + 2 + 8 + "px" : n.value = i + "px";
      const { left: y = 0, bottom: s = 0, height: M = 0 } = (e == null ? void 0 : e.getBoundingClientRect()) ?? {};
      console.log("left====", y), console.log("bottom====", s), console.log("height====", M);
      const z = f(), g = b.height;
      console.log("errorModelHeight====", g), l.value.y = Math.ceil(s + g) >= z ? s - M - g : s, l.value.x = y, console.log("errorModelPosition====", l.value);
    };
    return T(async () => {
      await V(), S();
    }), (h, f) => (O(), I(P, { to: "body" }, [
      W(
        "div",
        {
          ref_key: "$errorModel",
          ref: C,
          style: E(_.value)
        },
        [
          W(
            "span",
            {
              style: E(u.value)
            },
            R(h.errorLabel),
            5
            /* TEXT, STYLE */
          )
        ],
        4
        /* STYLE */
      )
    ]));
  }
}), N = D(j);
export {
  N as DasErrorOverlayModel
};
