import '@das-fed/upf-ui/packages/components/loading/style.css';
import { inject as D, ref as I, computed as x, unref as Z, openBlock as N, createElementBlock as V, createStaticVNode as R, createElementVNode as z, reactive as J, defineComponent as Q, h as _, Transition as W, withCtx as X, withDirectives as ee, createVNode as te, vShow as ne, createApp as se, toRefs as ae, nextTick as j, isRef as oe } from "vue";
import { setI18nRule as re, t as ce } from "@das-fed/upf-web/packages/i18n/index";
/**
* @vue/shared v3.5.25
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
process.env.NODE_ENV !== "production" && Object.freeze({});
process.env.NODE_ENV !== "production" && Object.freeze([]);
const K = (t) => typeof t == "string", F = (t) => t !== null && typeof t == "object", G = (t) => {
  const e = /* @__PURE__ */ Object.create(null);
  return (n) => e[n] || (e[n] = t(n));
}, de = /-\w/g, ie = G(
  (t) => t.replace(de, (e) => e.slice(1).toUpperCase())
), le = /\B([A-Z])/g, ue = G(
  (t) => t.replace(le, "-$1").toLowerCase()
), fe = (t) => typeof t == "number";
var B;
const A = typeof window < "u";
A && ((B = window == null ? void 0 : window.navigator) != null && B.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
const q = (t = "") => t.split(" ").filter((e) => !!e.trim()), E = (t, e) => {
  !t || !e.trim() || t.classList.add(...q(e));
}, $ = (t, e) => {
  !t || !e.trim() || t.classList.remove(...q(e));
}, b = (t, e) => {
  var s;
  if (!A || !t || !e) return "";
  let n = ie(e);
  n === "float" && (n = "cssFloat");
  try {
    const c = t.style[n];
    if (c) return c;
    const o = (s = document.defaultView) == null ? void 0 : s.getComputedStyle(t, "");
    return o ? o[n] : "";
  } catch {
    return t.style[n];
  }
}, L = "das", me = "is-", v = (t, e, n, s, c) => {
  let o = `${t}-${e}`;
  return n && (o += `-${n}`), s && (o += `__${s}`), c && (o += `--${c}`), o;
}, ve = Symbol("namespaceContextKey"), ge = (t) => {
  const e = t || D(ve, I(L));
  return x(() => Z(e) || L);
}, pe = (t, e) => {
  const n = ge(e);
  return {
    namespace: n,
    b: (a = "") => v(n.value, t, a, "", ""),
    e: (a) => a ? v(n.value, t, "", a, "") : "",
    m: (a) => a ? v(n.value, t, "", "", a) : "",
    be: (a, r) => a && r ? v(n.value, t, a, r, "") : "",
    em: (a, r) => a && r ? v(n.value, t, "", a, r) : "",
    bm: (a, r) => a && r ? v(n.value, t, a, "", r) : "",
    bem: (a, r, i) => a && r && i ? v(n.value, t, a, r, i) : "",
    is: (a, ...r) => {
      const i = r.length >= 1 ? r[0] : !0;
      return a && i ? `${me}${a}` : "";
    },
    // css
    cssVar: (a) => {
      const r = {};
      for (const i in a)
        a[i] && (r[`--${n.value}-${i}`] = a[i]);
      return r;
    },
    cssVarName: (a) => `--${n.value}-${a}`,
    cssVarBlock: (a) => {
      const r = {};
      for (const i in a)
        a[i] && (r[`--${n.value}-${t}-${i}`] = a[i]);
      return r;
    },
    cssVarBlockName: (a) => `--${n.value}-${t}-${a}`
  };
}, O = I(0), M = 2e3, ye = Symbol("zIndexContextKey"), be = (t) => {
  const e = t || D(ye, void 0), n = x(() => {
    const o = Z(e);
    return fe(o) ? o : M;
  }), s = x(() => n.value + O.value);
  return {
    initialZIndex: n,
    currentZIndex: s,
    nextZIndex: () => (O.value++, s.value)
  };
};
function xe(t) {
  const e = pe(
    t,
    x(() => L)
  ), n = be(
    x(() => M)
  );
  return {
    ns: e,
    zIndex: n
  };
}
const k = (t, e) => {
  const n = t.__vccOpts || t;
  for (const [s, c] of e)
    n[s] = c;
  return n;
}, _e = {}, Ce = { class: "das-loading-container das-loading-page" };
function $e(t, e) {
  return N(), V("div", Ce, [...e[0] || (e[0] = [
    R('<div class="das-loading-dot-loading" data-v-556fdb62><i class="das-loading-dot-item" data-v-556fdb62></i><i class="das-loading-dot-item" data-v-556fdb62></i><i class="das-loading-dot-item" data-v-556fdb62></i><i class="das-loading-dot-item" data-v-556fdb62></i></div>', 1)
  ])]);
}
const S = /* @__PURE__ */ k(_e, [["render", $e], ["__scopeId", "data-v-556fdb62"]]), Ie = {}, he = { class: "das-loading-container das-loading-component" };
function Le(t, e) {
  return N(), V("div", he, [...e[0] || (e[0] = [
    z(
      "div",
      { class: "das-loading-dot-loading" },
      [
        z("i", { class: "das-loading-dot-item" })
      ],
      -1
      /* CACHED */
    )
  ])]);
}
const we = /* @__PURE__ */ k(Ie, [["render", Le], ["__scopeId", "data-v-00355f8b"]]), Ne = {}, Ve = { class: "das-loading-container das-loading-containerload" };
function Ae(t, e) {
  return N(), V("div", Ve, [...e[0] || (e[0] = [
    R('<div class="das-loading-dot-loading" data-v-80a6a49a><i class="das-loading-dot-item" data-v-80a6a49a></i><i class="das-loading-dot-item" data-v-80a6a49a></i><i class="das-loading-dot-item" data-v-80a6a49a></i><i class="das-loading-dot-item" data-v-80a6a49a></i></div>', 1)
  ])]);
}
const ke = /* @__PURE__ */ k(Ne, [["render", Ae], ["__scopeId", "data-v-80a6a49a"]]);
function ze(t) {
  let e;
  const n = I(!1), s = J({
    ...t,
    originalPosition: "",
    originalOverflow: "",
    visible: !1
  });
  function c(d) {
    s.text = d;
  }
  function o() {
    const d = s.parent, m = p.ns;
    if (!d.vLoadingAddClassList) {
      let f = d.getAttribute("loading-number");
      f = Number.parseInt(f) - 1, f ? d.setAttribute("loading-number", f.toString()) : ($(d, m.bm("parent", "relative")), d.removeAttribute("loading-number")), $(d, m.bm("parent", "hidden"));
    }
    u(), h.unmount();
  }
  function u() {
    var d, m;
    (m = (d = p.$el) == null ? void 0 : d.parentNode) == null || m.removeChild(p.$el);
  }
  function y() {
    var d;
    t.beforeClose && !t.beforeClose() || (n.value = !0, clearTimeout(e), e = window.setTimeout(l, 400), s.visible = !1, (d = t.closed) == null || d.call(t));
  }
  function l() {
    if (!n.value) return;
    const d = s.parent;
    n.value = !1, d.vLoadingAddClassList = void 0, o();
  }
  const g = Q({
    name: "DasLoading",
    setup(d, { expose: m }) {
      const { ns: f, zIndex: a } = xe("loading");
      return m({
        ns: f,
        zIndex: a
      }), () => {
        let r = s.spinner || s.svg || S;
        const i = s.type;
        i == "page" && (r = S), i == "container" && (r = ke), i == "component" && (r = we);
        const Y = typeof r == "boolean" ? void 0 : _(r), H = s.text ? _("p", { class: f.b("text") }, [s.text]) : void 0;
        return _(
          W,
          {
            name: f.b("fade"),
            onAfterLeave: l
          },
          {
            default: X(() => [
              ee(
                te(
                  "div",
                  {
                    style: {
                      backgroundColor: s.background || ""
                    },
                    class: [
                      f.b("mask"),
                      s.customClass,
                      s.fullscreen ? "is-fullscreen" : ""
                    ]
                  },
                  [
                    _(
                      "div",
                      {
                        class: f.b("spinner")
                      },
                      [Y, H]
                    )
                  ]
                ),
                [[ne, s.visible]]
              )
            ])
          }
        );
      };
    }
  }), h = se(g), p = h.mount(document.createElement("div"));
  return {
    ...ae(s),
    setText: c,
    removeElLoadingChild: u,
    close: y,
    handleAfterLeave: l,
    vm: p,
    get $el() {
      return p.$el;
    }
  };
}
let C;
const U = function(t = {}) {
  if (!A) return;
  const e = Be(t);
  if (e.fullscreen && C)
    return C;
  const n = ze({
    ...e,
    closed: () => {
      var c;
      (c = e.closed) == null || c.call(e), e.fullscreen && (C = void 0);
    }
  });
  Ee(e, e.parent, n), P(e, e.parent, n), e.parent.vLoadingAddClassList = () => P(e, e.parent, n);
  let s = e.parent.getAttribute("loading-number");
  return s ? s = `${Number.parseInt(s) + 1}` : s = "1", e.parent.setAttribute("loading-number", s), e.parent.appendChild(n.$el), j(() => n.visible.value = e.visible), e.fullscreen && (C = n), n;
}, Be = (t) => {
  let e;
  return K(t.target) ? e = document.querySelector(t.target) ?? document.body : e = t.target || document.body, {
    parent: e === document.body || t.body ? document.body : e,
    background: t.background || "",
    svg: t.svg || "",
    svgViewBox: t.svgViewBox || "",
    spinner: t.spinner || !1,
    text: t.text || "",
    type: t.type || "",
    fullscreen: e === document.body && (t.fullscreen ?? !0),
    lock: t.lock ?? !1,
    customClass: t.customClass || "",
    visible: t.visible ?? !0,
    target: e
  };
}, Ee = async (t, e, n) => {
  const { nextZIndex: s } = n.vm.zIndex || n.vm._.exposed.zIndex, c = {};
  if (t.fullscreen)
    n.originalPosition.value = b(document.body, "position"), n.originalOverflow.value = b(document.body, "overflow"), c.zIndex = s();
  else if (t.parent === document.body) {
    n.originalPosition.value = b(document.body, "position"), await j();
    for (const o of ["top", "left"]) {
      const u = o === "top" ? "scrollTop" : "scrollLeft";
      c[o] = `${t.target.getBoundingClientRect()[o] + document.body[u] + document.documentElement[u] - Number.parseInt(b(document.body, `margin-${o}`), 10)}px`;
    }
    for (const o of ["height", "width"])
      c[o] = `${t.target.getBoundingClientRect()[o]}px`;
  } else
    n.originalPosition.value = b(e, "position");
  for (const [o, u] of Object.entries(c))
    n.$el.style[o] = u;
}, P = (t, e, n) => {
  const s = n.vm.ns || n.vm._.exposed.ns;
  ["absolute", "fixed", "sticky"].includes(n.originalPosition.value) ? $(e, s.bm("parent", "relative")) : E(e, s.bm("parent", "relative")), t.fullscreen && t.lock ? E(e, s.bm("parent", "hidden")) : $(e, s.bm("parent", "hidden"));
}, w = Symbol("DasLoading"), T = (t, e) => {
  const n = e.instance, s = (l) => F(e.value) ? e.value[l] : void 0, c = (l) => {
    const g = K(l) && (n == null ? void 0 : n[l]) || l;
    return g && I(g);
  }, o = (l) => c(
    s(l) || t.getAttribute(`das-loading-${ue(l)}`)
  ), u = s("fullscreen") ?? e.modifiers.fullscreen, y = {
    type: o("type"),
    text: o("text"),
    svg: o("svg"),
    svgViewBox: o("svgViewBox"),
    spinner: o("spinner"),
    background: o("background"),
    customClass: o("customClass"),
    fullscreen: u,
    target: s("target") ?? (u ? void 0 : t),
    body: s("body") ?? e.modifiers.body,
    lock: s("lock") ?? e.modifiers.lock
  };
  t[w] = {
    options: y,
    instance: U(y)
  };
}, Oe = (t, e) => {
  for (const n of Object.keys(e))
    oe(e[n]) && (e[n].value = t[n]);
}, De = {
  mounted(t, e) {
    e.value && T(t, e);
  },
  updated(t, e) {
    const n = t[w];
    e.oldValue !== e.value && (e.value && !e.oldValue ? T(t, e) : e.value && e.oldValue ? F(e.value) && Oe(e.value, n.options) : n == null || n.instance.close());
  },
  unmounted(t) {
    var e;
    (e = t[w]) == null || e.instance.close();
  }
}, Se = { 加载: { "zh-CN": "加载", en: "Loading", "zh-MO": "加載", _appCode: "framework" } };
re(Se);
const Ze = {
  service: U
}, Re = { name: `loading ${ce("加载")}` };
export {
  Ze as DasLoading,
  Re as default,
  De as vDasLoading
};
