import { useCallback, useEffect, useRef, useState } from "react";
var noop = function noop() {};
var emptyObj = {};
export default (function (defaultExpanded, onChange) {
  if (defaultExpanded === void 0) {
    defaultExpanded = emptyObj;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var initialSetRef = useRef(false);
  var _useState = useState(function () {
      return defaultExpanded;
    }),
    expanded = _useState[0],
    setExpanded = _useState[1];
  useEffect(function () {
    if (!defaultExpanded || expanded === defaultExpanded) return;
    initialSetRef.current = true;
    setExpanded(defaultExpanded);
  }, [defaultExpanded]);
  var onExpand = useCallback(function (value) {
    onChange(value);
    setExpanded(value);
  }, []);
  return [expanded, onExpand];
});