import { navigation, useTick, useUserIdentity, } from "@saasquatch/component-boilerplate";
import { useEffect, useRef } from "@saasquatch/universal-hooks";
function handleMenu(e) {
  navigation.push(e.detail.item.value);
}
export function useNavigationMenu(props) {
  const ref = useRef();
  const [, rerender] = useTick();
  const user = useUserIdentity();
  useEffect(() => {
    var _a;
    (_a = ref.current) === null || _a === void 0 ? void 0 : _a.addEventListener("sl-select", (e) => handleMenu(e));
  }, [ref.current]);
  return {
    states: {
      includeDropdown: ((user === null || user === void 0 ? void 0 : user.id) || (user === null || user === void 0 ? void 0 : user.accountId) || (user === null || user === void 0 ? void 0 : user.jwt)) !== undefined,
      styles: {
        menuLabel: props.menuLabel,
      },
    },
    callbacks: {
      rerender,
    },
    ref,
  };
}
