this.primereact = this.primereact || {};
this.primereact.overlaypanel = (function (exports, React, PrimeReact, csstransition, hooks, overlayservice, portal, ripple, utils) {
  'use strict';

  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

  function _interopNamespace(e) {
    if (e && e.__esModule) return e;
    var n = Object.create(null);
    if (e) {
      Object.keys(e).forEach(function (k) {
        if (k !== 'default') {
          var d = Object.getOwnPropertyDescriptor(e, k);
          Object.defineProperty(n, k, d.get ? d : {
            enumerable: true,
            get: function () { return e[k]; }
          });
        }
      });
    }
    n["default"] = e;
    return Object.freeze(n);
  }

  var React__namespace = /*#__PURE__*/_interopNamespace(React);
  var PrimeReact__default = /*#__PURE__*/_interopDefaultLegacy(PrimeReact);

  function _extends() {
    _extends = Object.assign || function (target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i];

        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }

      return target;
    };

    return _extends.apply(this, arguments);
  }

  function _arrayWithHoles(arr) {
    if (Array.isArray(arr)) return arr;
  }

  function _iterableToArrayLimit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];

    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;

    var _s, _e;

    try {
      for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
        _arr.push(_s.value);

        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"] != null) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }

    return _arr;
  }

  function _arrayLikeToArray(arr, len) {
    if (len == null || len > arr.length) len = arr.length;

    for (var i = 0, arr2 = new Array(len); i < len; i++) {
      arr2[i] = arr[i];
    }

    return arr2;
  }

  function _unsupportedIterableToArray(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _arrayLikeToArray(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(o);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  }

  function _nonIterableRest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }

  function _slicedToArray(arr, i) {
    return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  }

  var OverlayPanel = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
    var _React$useState = React__namespace.useState(false),
        _React$useState2 = _slicedToArray(_React$useState, 2),
        visibleState = _React$useState2[0],
        setVisibleState = _React$useState2[1];

    var attributeSelector = React__namespace.useRef('');
    var overlayRef = React__namespace.useRef(null);
    var currentTargetRef = React__namespace.useRef(null);
    var isPanelClicked = React__namespace.useRef(false);
    var styleElement = React__namespace.useRef(null);
    var overlayEventListener = React__namespace.useRef(null);

    var _useOverlayListener = hooks.useOverlayListener({
      target: currentTargetRef,
      overlay: overlayRef,
      listener: function listener(event, _ref) {
        var type = _ref.type,
            valid = _ref.valid;

        if (valid) {
          type === 'outside' ? !isPanelClicked.current && hide() : hide();
        }

        isPanelClicked.current = false;
      },
      when: visibleState
    }),
        _useOverlayListener2 = _slicedToArray(_useOverlayListener, 2),
        bindOverlayListener = _useOverlayListener2[0],
        unbindOverlayListener = _useOverlayListener2[1];

    var isOutsideClicked = function isOutsideClicked(target) {
      return overlayRef && overlayRef.current && !(overlayRef.current.isSameNode(target) || overlayRef.current.contains(target));
    };

    var hasTargetChanged = function hasTargetChanged(event, target) {
      return currentTargetRef.current != null && currentTargetRef.current !== (target || event.currentTarget || event.target);
    };

    var onCloseClick = function onCloseClick(event) {
      hide();
      event.preventDefault();
    };

    var onPanelClick = function onPanelClick(event) {
      isPanelClicked.current = true;
      overlayservice.OverlayService.emit('overlay-click', {
        originalEvent: event,
        target: currentTargetRef.current
      });
    };

    var onContentClick = function onContentClick() {
      isPanelClicked.current = true;
    };

    var toggle = function toggle(event, target) {
      if (visibleState) {
        hide();

        if (hasTargetChanged(event, target)) {
          currentTargetRef.current = target || event.currentTarget || event.target;
          setTimeout(function () {
            show(event, currentTargetRef.current);
          }, 200);
        }
      } else {
        show(event, target);
      }
    };

    var show = function show(event, target) {
      currentTargetRef.current = target || event.currentTarget || event.target;

      if (visibleState) {
        align();
      } else {
        setVisibleState(true);

        overlayEventListener.current = function (e) {
          !isOutsideClicked(e.target) && (isPanelClicked.current = true);
        };

        overlayservice.OverlayService.on('overlay-click', overlayEventListener.current);
      }
    };

    var hide = function hide() {
      setVisibleState(false);
      overlayservice.OverlayService.off('overlay-click', overlayEventListener.current);
      overlayEventListener.current = null;
    };

    var onEnter = function onEnter() {
      overlayRef.current.setAttribute(attributeSelector.current, '');
      utils.ZIndexUtils.set('overlay', overlayRef.current, PrimeReact__default["default"].autoZIndex, PrimeReact__default["default"].zIndex['overlay']);
      align();
    };

    var onEntered = function onEntered() {
      bindOverlayListener();
      props.onShow && props.onShow();
    };

    var onExit = function onExit() {
      unbindOverlayListener();
    };

    var onExited = function onExited() {
      utils.ZIndexUtils.clear(overlayRef.current);
      props.onHide && props.onHide();
    };

    var align = function align() {
      if (currentTargetRef.current) {
        utils.DomHandler.absolutePosition(overlayRef.current, currentTargetRef.current);
        var containerOffset = utils.DomHandler.getOffset(overlayRef.current);
        var targetOffset = utils.DomHandler.getOffset(currentTargetRef.current);
        var arrowLeft = 0;

        if (containerOffset.left < targetOffset.left) {
          arrowLeft = targetOffset.left - containerOffset.left;
        }

        overlayRef.current.style.setProperty('--overlayArrowLeft', "".concat(arrowLeft, "px"));

        if (containerOffset.top < targetOffset.top) {
          utils.DomHandler.addClass(overlayRef.current, 'p-overlaypanel-flipped');
        }
      }
    };

    var createStyle = function createStyle() {
      if (!styleElement.current) {
        styleElement.current = utils.DomHandler.createInlineStyle(PrimeReact__default["default"].nonce);
        var innerHTML = '';

        for (var breakpoint in props.breakpoints) {
          innerHTML += "\n                    @media screen and (max-width: ".concat(breakpoint, ") {\n                        .p-overlaypanel[").concat(attributeSelector.current, "] {\n                            width: ").concat(props.breakpoints[breakpoint], " !important;\n                        }\n                    }\n                ");
        }

        styleElement.innerHTML = innerHTML;
      }
    };

    hooks.useMountEffect(function () {
      attributeSelector.current = utils.UniqueComponentId();

      if (props.breakpoints) {
        createStyle();
      }
    });
    hooks.useUnmountEffect(function () {
      styleElement.current = utils.DomHandler.removeInlineStyle(styleElement.current);

      if (overlayEventListener.current) {
        overlayservice.OverlayService.off('overlay-click', overlayEventListener.current);
        overlayEventListener.current = null;
      }

      utils.ZIndexUtils.clear(overlayRef.current);
    });
    React__namespace.useImperativeHandle(ref, function () {
      return {
        toggle: toggle,
        show: show,
        hide: hide
      };
    });

    var createCloseIcon = function createCloseIcon() {
      if (props.showCloseIcon) {
        return /*#__PURE__*/React__namespace.createElement("button", {
          type: "button",
          className: "p-overlaypanel-close p-link",
          onClick: onCloseClick,
          "aria-label": props.ariaCloseLabel
        }, /*#__PURE__*/React__namespace.createElement("span", {
          className: "p-overlaypanel-close-icon pi pi-times"
        }), /*#__PURE__*/React__namespace.createElement(ripple.Ripple, null));
      }

      return null;
    };

    var createElement = function createElement() {
      var otherProps = utils.ObjectUtils.findDiffKeys(props, OverlayPanel.defaultProps);
      var className = utils.classNames('p-overlaypanel p-component', props.className);
      var closeIcon = createCloseIcon();
      return /*#__PURE__*/React__namespace.createElement(csstransition.CSSTransition, {
        nodeRef: overlayRef,
        classNames: "p-overlaypanel",
        "in": visibleState,
        timeout: {
          enter: 120,
          exit: 100
        },
        options: props.transitionOptions,
        unmountOnExit: true,
        onEnter: onEnter,
        onEntered: onEntered,
        onExit: onExit,
        onExited: onExited
      }, /*#__PURE__*/React__namespace.createElement("div", _extends({
        ref: overlayRef,
        id: props.id,
        className: className,
        style: props.style
      }, otherProps, {
        onClick: onPanelClick
      }), /*#__PURE__*/React__namespace.createElement("div", {
        className: "p-overlaypanel-content",
        onClick: onContentClick,
        onMouseDown: onContentClick
      }, props.children), closeIcon));
    };

    var element = createElement();
    return /*#__PURE__*/React__namespace.createElement(portal.Portal, {
      element: element,
      appendTo: props.appendTo
    });
  });
  OverlayPanel.displayName = 'OverlayPanel';
  OverlayPanel.defaultProps = {
    __TYPE: 'OverlayPanel',
    id: null,
    dismissable: true,
    showCloseIcon: false,
    style: null,
    className: null,
    appendTo: null,
    breakpoints: null,
    ariaCloseLabel: 'close',
    transitionOptions: null,
    onShow: null,
    onHide: null
  };

  exports.OverlayPanel = OverlayPanel;

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

  return exports;

})({}, React, primereact.api, primereact.csstransition, primereact.hooks, primereact.overlayservice, primereact.portal, primereact.ripple, primereact.utils);
