import { o as C } from "./rolldown-runtime.js";
import { i as N, n as E, t as j } from "./vendor/react.js";
import { t as d } from "./dist.js";
import { t as a } from "./utils.js";
import { t as k } from "./LoadingIndicator.js";
var s = j(), x = d("relative", {
  variants: { fill: {
    content: "",
    container: "h-full w-full"
  } },
  defaultVariants: { fill: "content" }
}), O = d("absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-200 ease-smooth motion-reduce:transition-none", {
  variants: {
    blur: {
      none: "",
      sm: "supports-backdrop-filter:backdrop-blur-sm",
      md: "supports-backdrop-filter:backdrop-blur-md"
    },
    background: {
      transparent: "",
      light: "bg-card/80",
      solid: "bg-card"
    }
  },
  defaultVariants: {
    blur: "none",
    background: "light"
  }
});
function p({ loading: t = !1, size: e = "md", variant: r = "line-simple", showText: n = !0, text: o, color: u, fill: f, blur: m, background: _, className: b, children: g, ...y }) {
  return /* @__PURE__ */ (0, s.jsxs)("div", {
    className: a(x({ fill: f }), b),
    "aria-busy": t,
    ...y,
    children: [g, t && /* @__PURE__ */ (0, s.jsx)("div", {
      className: a(O({
        blur: m,
        background: _
      })),
      "data-slot": "loading-overlay",
      children: /* @__PURE__ */ (0, s.jsx)(k, {
        size: e,
        variant: r,
        showText: n,
        text: o,
        color: u
      })
    })]
  });
}
p.displayName = "LoadingOverlay";
var l = /* @__PURE__ */ C(N(), 1), T = E(), i = {
  variant: "string",
  size: "string",
  loading: "boolean",
  showText: "boolean",
  text: "string",
  color: "string"
};
function c(t, e) {
  if (t !== null)
    switch (e) {
      case "number":
        return Number(t);
      case "boolean":
        return t !== "false" && t !== "0";
      case "json":
        try {
          return JSON.parse(t);
        } catch {
          return t;
        }
      default:
        return t;
    }
}
var h = class extends HTMLElement {
  _root = null;
  _childrenContainer = null;
  _props = {};
  _initialized = !1;
  connectedCallback() {
    setTimeout(() => this._initialize(), 0);
  }
  _initialize() {
    if (this._initialized) return;
    this._initialized = !0;
    const t = [];
    for (const r of Array.from(this.childNodes))
      r.nodeType === Node.TEXT_NODE && !r.textContent?.trim() || t.push(r);
    const e = document.createElement("div");
    for (e.style.display = "contents", this._childrenContainer = document.createElement("div"), this._childrenContainer.style.display = "contents", t.forEach((r) => this._childrenContainer.appendChild(r)); this.firstChild; ) this.removeChild(this.firstChild);
    this.appendChild(e), this._root = (0, T.createRoot)(e), this._render();
  }
  disconnectedCallback() {
    this._root?.unmount(), this._root = null;
  }
  attributeChangedCallback(t, e, r) {
    this._render();
  }
  static get observedAttributes() {
    return Object.keys(i).map((t) => t.replace(/([A-Z])/g, "-$1").toLowerCase());
  }
  _setProp(t, e) {
    const r = i[t] || "string";
    this._props[t] = this._parseValue(e, r), this._render();
  }
  _parseValue(t, e) {
    if (e === "boolean" && typeof t == "boolean" || e === "number" && typeof t == "number" || e === "string" && typeof t == "string") return t;
    if (typeof t == "string") switch (e) {
      case "boolean":
        return t !== "false" && t !== "0" && t !== "";
      case "number":
        return Number(t);
      case "json":
        try {
          return JSON.parse(t);
        } catch {
          return t;
        }
      default:
        return t;
    }
    return t;
  }
  _getProp(t) {
    if (t in this._props) return this._props[t];
    const e = t.replace(/([A-Z])/g, "-$1").toLowerCase(), r = i[t] || "string";
    return c(this.getAttribute(e), r);
  }
  _render() {
    if (!this._root || !this._childrenContainer) return;
    const t = {};
    for (const [r, n] of Object.entries(i)) if (r in this._props) t[r] = this._props[r];
    else {
      const o = r.replace(/([A-Z])/g, "-$1").toLowerCase();
      t[r] = c(this.getAttribute(o), n);
    }
    const e = l.createElement(p, {
      ...t,
      _hostElement: this
    }, l.createElement("span", {
      ref: (r) => {
        r && this._childrenContainer && r.replaceWith(this._childrenContainer);
      },
      style: { display: "contents" }
    }));
    this._root.render(e);
  }
};
for (const t of Object.keys(i)) Object.defineProperty(h.prototype, t, {
  get() {
    return this._getProp(t);
  },
  set(e) {
    this._setProp(t, e);
  },
  enumerable: !0,
  configurable: !0
});
typeof customElements < "u" && !customElements.get("hf-loading-overlay") && customElements.define("hf-loading-overlay", h);
export {
  h as LoadingOverlayWC,
  h as default
};

//# sourceMappingURL=hf-loading-overlay.js.map