import { o as l } from "./rolldown-runtime.js";
import { i as p, n as u } from "./vendor/react.js";
import { n as h } from "./AIScrollButton.js";
var i = /* @__PURE__ */ l(p(), 1), d = u();
function f(t) {
  return { onClick: (e) => {
    t.dispatchEvent(new CustomEvent("click", {
      detail: e,
      bubbles: !0,
      composed: !0
    }));
  } };
}
function m(t) {
  const { _hostElement: e, ...r } = t, o = i.useMemo(() => e ? f(e) : {}, [e]);
  return i.createElement(h, {
    ...r,
    ...o
  });
}
var n = {
  variant: "string",
  size: "string",
  scrollRef: "json",
  containerRef: "json",
  threshold: "number",
  visible: "boolean",
  label: "string",
  unreadCount: "number",
  className: "string"
};
function s(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 c = 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, d.createRoot)(e), this._render();
  }
  disconnectedCallback() {
    this._root?.unmount(), this._root = null;
  }
  attributeChangedCallback(t, e, r) {
    this._render();
  }
  static get observedAttributes() {
    return Object.keys(n).map((t) => t.replace(/([A-Z])/g, "-$1").toLowerCase());
  }
  _setProp(t, e) {
    const r = n[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 = n[t] || "string";
    return s(this.getAttribute(e), r);
  }
  _render() {
    if (!this._root) return;
    const t = {};
    for (const [r, o] of Object.entries(n)) if (r in this._props) t[r] = this._props[r];
    else {
      const a = r.replace(/([A-Z])/g, "-$1").toLowerCase();
      t[r] = s(this.getAttribute(a), o);
    }
    const e = i.createElement(m, {
      ...t,
      _hostElement: this
    });
    this._root.render(e);
  }
};
for (const t of Object.keys(n)) Object.defineProperty(c.prototype, t, {
  get() {
    return this._getProp(t);
  },
  set(e) {
    this._setProp(t, e);
  },
  enumerable: !0,
  configurable: !0
});
typeof customElements < "u" && !customElements.get("hf-ai-scroll-button") && customElements.define("hf-ai-scroll-button", c);
export {
  c as AIScrollButtonWC,
  c as default
};

//# sourceMappingURL=hf-ai-scroll-button.js.map