import { n as h, C as c } from "../chunks/lib-cortex-element.CVMmyPMC.js";
import { c as d } from "../chunks/component.styles.CRO4Odto.js";
import { c as b } from "../chunks/custom-element.L4WJXn1j.js";
import { w as p } from "../chunks/watch.BCJD77bD.js";
import { i as v, x as m } from "../chunks/lit-element.jLBm65_O.js";
const f = v`:host{display:contents}`;
var u = Object.defineProperty, O = Object.getOwnPropertyDescriptor, n = (s, r, e, i) => {
  for (var t = i > 1 ? void 0 : i ? O(r, e) : r, l = s.length - 1, a; l >= 0; l--)
    (a = s[l]) && (t = (i ? a(r, e, t) : a(t)) || t);
  return i && t && u(r, e, t), t;
};
let o = class extends c {
  constructor() {
    super(...arguments), this.observedElements = [], this.disabled = !1;
  }
  connectedCallback() {
    super.connectedCallback(), this.resizeObserver = new ResizeObserver(
      (s) => {
        this.emit("cx-resize", { detail: { entries: s } });
      }
    ), this.disabled || this.startObserver();
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.stopObserver();
  }
  handleSlotChange() {
    this.disabled || this.startObserver();
  }
  startObserver() {
    const s = this.shadowRoot.querySelector("slot");
    if (s !== null) {
      const r = s.assignedElements({
        flatten: !0
      });
      this.observedElements.forEach((e) => this.resizeObserver.unobserve(e)), this.observedElements = [], r.forEach((e) => {
        this.resizeObserver.observe(e), this.observedElements.push(e);
      });
    }
  }
  stopObserver() {
    this.resizeObserver.disconnect();
  }
  handleDisabledChange() {
    this.disabled ? this.stopObserver() : this.startObserver();
  }
  render() {
    return m`<slot @slotchange=${this.handleSlotChange}></slot>`;
  }
};
o.styles = [d, f];
n([
  h({ reflect: !0, type: Boolean })
], o.prototype, "disabled", 2);
n([
  p("disabled", { waitUntilFirstUpdate: !0 })
], o.prototype, "handleDisabledChange", 1);
o = n([
  b("cx-resize-observer")
], o);
export {
  o as default
};
