"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.usePanelRef = usePanelRef;
exports.useProvideWatermark = void 0;
var _vue = require("vue");
const noop = () => {};
const watermarkContextKey = Symbol('watermarkContextKey');
const useProvideWatermark = props => {
  (0, _vue.provide)(watermarkContextKey, props);
};
exports.useProvideWatermark = useProvideWatermark;
function usePanelRef(panelSelector) {
  const watermark = (0, _vue.inject)(watermarkContextKey, {
    add: noop,
    remove: noop
  });
  let panelEleRef = null;
  const panelRef = ele => {
    if (ele) {
      const innerContentEle = panelSelector ? ele.querySelector(panelSelector) : ele;
      if (innerContentEle === panelEleRef) {
        return;
      }
      watermark.add(innerContentEle);
      panelEleRef = innerContentEle;
    } else {
      watermark.remove(panelEleRef);
    }
  };
  return panelRef;
}