"use strict";
const vue = require("vue");
const is = require("../_utils/is.js");
const useElementResize = require("../hooks/use-element-resize.js");
require("../_utils/global.js");
const vueUtils = require("../_utils/vue-utils.js");
const bindEvent = (child, vResizeObserver) => {
  if (vueUtils.isElement(child) || vueUtils.isComponent(child)) {
    return vue.withDirectives(vue.cloneVNode(child), [[vResizeObserver]]);
  } else if (is.isArray(child.children)) {
    child.children = child.children.map((item) => {
      return bindEvent(item, vResizeObserver);
    });
    return child;
  } else {
    return child;
  }
};
const OResizeObserver = vue.defineComponent({
  name: "OResizeObserver",
  emits: ["resize"],
  setup(_props, { emit, slots }) {
    const { vResizeObserver } = useElementResize.useReiszeObserverDirective((entry, isFirst) => {
      emit("resize", entry, isFirst);
    });
    return () => {
      var _a;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
      return children == null ? void 0 : children.map((item) => {
        return bindEvent(item, vResizeObserver);
      });
    };
  }
});
module.exports = OResizeObserver;
