/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');

function useResizeObserver(container, callback) {
  var isSupport = window && window.ResizeObserver;
  if (!isSupport) return;
  var containerObserver = null;
  var cleanupObserver = function cleanupObserver() {
    if (!containerObserver) return;
    containerObserver.unobserve(container.value);
    containerObserver.disconnect();
    containerObserver = null;
  };
  var addObserver = function addObserver(el) {
    containerObserver = new ResizeObserver(callback);
    containerObserver.observe(el);
  };
  if (container) {
    VueCompositionAPI.watch(container, function (el) {
      cleanupObserver();
      el && addObserver(el);
    }, {
      immediate: true,
      flush: "post"
    });
  }
  VueCompositionAPI.onBeforeUnmount(function () {
    cleanupObserver();
  });
}

exports["default"] = useResizeObserver;
//# sourceMappingURL=useResizeObserver.js.map
