import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import { memo, useState, useRef, useEffect, useMemo, forwardRef, useCallback } from 'react';
import { globalProps as globalProps$1 } from '@bigbinary/neeto-commons-frontend/initializers';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import { Spinner, Input, Dialog, DialogContent, DialogTitle, Popover, PopoverAnchor, PopoverContent, Badge, Avatar, AvatarImage, AvatarFallback, Separator } from '@bigbinary/neeto-atoms';
import { isNotEmpty, isNotPresent, isPresent, truncate, humanize } from '@bigbinary/neeto-cist';
import useHotkeys from '@bigbinary/neeto-hotkeys';
import Profile from '@bigbinary/neeto-team-members-frontend/Profile';
import { isEmpty, toLower, mergeDeepLeft, not } from 'ramda';
import KeyboardShortcuts from '../KeyboardShortcuts.js';
import SubscriptionUpgradeRequestModal from '../SubscriptionUpgradeRequestModal.js';
import classnames from 'classnames';
import { useTranslation } from 'react-i18next';
import Neeto from '@bigbinary/neeto-icons/typeface-logos/Neeto';
import * as AppIcons from '@bigbinary/neeto-icons/typeface-logos';
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { S as Search } from '../search-DCgpNjip.js';
import { C as CircleQuestionMark } from '../circle-question-mark-Dib48f5Z.js';
import { C as ChevronRight } from '../chevron-right-DcaO-Hlu.js';
import { c as createLucideIcon } from '../createLucideIcon-mNMhCCpf.js';
import useBreakpoints from '@bigbinary/neeto-commons-frontend/react-utils/useBreakpoints';
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
import { t } from 'i18next';
import { U as User } from '../user-A843PT-q.js';
import useLocalStorage from '@bigbinary/neeto-commons-frontend/react-utils/useLocalStorage';
import { getFromLocalStorage } from '@bigbinary/neeto-commons-frontend/utils';
import { resetAuthTokens } from '@bigbinary/neeto-commons-frontend/utils/axios';
import { removeFromLocalStorage } from '@bigbinary/neeto-commons-frontend/utils/general';
import CopyToClipboardButton from '../CopyToClipboardButton.js';
import '../useKeyboardShortcutsPaneState-Ckzn5mVZ.js';
import 'zustand/shallow';
import '@bigbinary/neeto-commons-frontend/react-utils/withImmutableActions';
import 'zustand';
import '@bigbinary/neeto-icons/Close';
import '@bigbinary/neetoui/Typography';
import '@bigbinary/neetoui/Button';
import '@bigbinary/neetoui/managers';
import '@bigbinary/neeto-commons-frontend/react-utils';
import '@bigbinary/neetoui/Kbd';
import '../ua-parser-OzUiuIwt.js';
import '../inject-css-C2dztUxs.js';
import '@bigbinary/neetoui/Modal';
import '@bigbinary/neeto-icons/Copy';
import '@bigbinary/neeto-icons/Check';

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$9 = [
  [
    "path",
    {
      d: "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",
      key: "169zse"
    }
  ]
];
const Activity = createLucideIcon("activity", __iconNode$9);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$8 = [
  ["path", { d: "M12 7v14", key: "1akyts" }],
  [
    "path",
    {
      d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",
      key: "ruj8y"
    }
  ]
];
const BookOpen = createLucideIcon("book-open", __iconNode$8);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$7 = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
];
const CircleCheck = createLucideIcon("circle-check", __iconNode$7);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$6 = [
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
];
const CircleX = createLucideIcon("circle-x", __iconNode$6);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$5 = [
  [
    "path",
    {
      d: "M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",
      key: "1vdc57"
    }
  ],
  ["path", { d: "M5 21h14", key: "11awu3" }]
];
const Crown = createLucideIcon("crown", __iconNode$5);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$4 = [
  ["path", { d: "m16 17 5-5-5-5", key: "1bji2h" }],
  ["path", { d: "M21 12H9", key: "dn1m92" }],
  ["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", key: "1uf3rs" }]
];
const LogOut = createLucideIcon("log-out", __iconNode$4);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$3 = [
  [
    "path",
    {
      d: "M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",
      key: "1sd12s"
    }
  ],
  ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
  ["path", { d: "M12 17h.01", key: "p32p05" }]
];
const MessageCircleQuestionMark = createLucideIcon("message-circle-question-mark", __iconNode$3);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$2 = [
  [
    "path",
    {
      d: "M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",
      key: "kfwtm"
    }
  ]
];
const Moon = createLucideIcon("moon", __iconNode$2);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode$1 = [
  ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
  ["path", { d: "M12 2v2", key: "tus03m" }],
  ["path", { d: "M12 20v2", key: "1lh1kg" }],
  ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
  ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
  ["path", { d: "M2 12h2", key: "1t8f8n" }],
  ["path", { d: "M20 12h2", key: "1q8mjw" }],
  ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
  ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
];
const Sun = createLucideIcon("sun", __iconNode$1);

/**
 * @license lucide-react v1.7.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */


const __iconNode = [
  ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
  ["path", { d: "M16 3.128a4 4 0 0 1 0 7.744", key: "16gr8j" }],
  ["path", { d: "M22 21v-2a4 4 0 0 0-3-3.87", key: "kshegd" }],
  ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }]
];
const Users = createLucideIcon("users", __iconNode);

var QUERY_KEYS$1 = {
  NEETO_APPS_LIST: "neeto-apps-list"
};
var SPECIAL_APP_NAMES = {
  bugwatch: "BugWatch"
};

var _excluded$3 = ["name", "description", "url", "isHighlighted"];
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var ProductLink = function ProductLink(_ref) {
  var _globalProps, _globalProps2;
  var name = _ref.name,
    description = _ref.description,
    url = _ref.url,
    _ref$isHighlighted = _ref.isHighlighted,
    isHighlighted = _ref$isHighlighted === void 0 ? false : _ref$isHighlighted,
    props = _objectWithoutProperties(_ref, _excluded$3);
  var normalizedName = (name || "").toLowerCase();
  var specialCase = SPECIAL_APP_NAMES[normalizedName];
  var safeName = name || "";
  var appName = "Neeto".concat(safeName.charAt(0)).concat(safeName.slice(1).toLowerCase());
  var AppIcon = specialCase ? AppIcons["Neeto".concat(specialCase)] : AppIcons[appName];
  return /*#__PURE__*/jsxs("a", _objectSpread$b(_objectSpread$b({
    "data-testid": "".concat(normalizedName, "-app-link"),
    href: url,
    rel: "noreferrer",
    target: "_blank",
    className: classnames("bg-background focus-visible:bg-accent flex w-full max-w-full cursor-pointer flex-col gap-4 rounded-lg border p-2.5 no-underline transition-all outline-none", {
      "border-primary bg-primary/5": (_globalProps = globalProps) === null || _globalProps === void 0 || (_globalProps = _globalProps.appName) === null || _globalProps === void 0 ? void 0 : _globalProps.includes(name),
      "neeto-molecules-product-switcher-link--highlighted bg-accent": isHighlighted,
      "border-border hover:border-primary": !((_globalProps2 = globalProps) !== null && _globalProps2 !== void 0 && (_globalProps2 = _globalProps2.appName) !== null && _globalProps2 !== void 0 && _globalProps2.includes(name))
    })
  }, props), {}, {
    children: [/*#__PURE__*/jsx("div", {
      className: "shrink-0 grow [&>svg]:h-9 [&>svg]:w-auto",
      children: AppIcon ? /*#__PURE__*/jsx(AppIcon, {}) : /*#__PURE__*/jsx(Neeto, {
        className: "h-6 w-auto"
      })
    }), /*#__PURE__*/jsx("div", {
      className: "shrink-0",
      children: /*#__PURE__*/jsx("span", {
        className: "text-muted-foreground block text-xs",
        children: description
      })
    })]
  }));
};
var ProductLink$1 = /*#__PURE__*/memo(ProductLink);

function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Content = function Content(_ref) {
  var highlightedIndex = _ref.highlightedIndex,
    filteredApps = _ref.filteredApps,
    isLoading = _ref.isLoading;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  if (isLoading) {
    return /*#__PURE__*/jsx("div", {
      className: "flex items-center justify-center py-8",
      children: /*#__PURE__*/jsx(Spinner, {
        "data-testid": "neeto-ui-spinner"
      })
    });
  }
  return (filteredApps === null || filteredApps === void 0 ? void 0 : filteredApps.length) > 0 ? /*#__PURE__*/jsx("div", {
    className: "grid grid-cols-[repeat(auto-fill,minmax(288px,1fr))] gap-3 max-lg:grid-cols-[repeat(auto-fill,minmax(248px,1fr))] max-sm:grid-cols-1",
    children: filteredApps.map(function (app, index) {
      return /*#__PURE__*/jsx(ProductLink$1, _objectSpread$a(_objectSpread$a({}, app), {}, {
        "data-highlighted-index": index,
        isHighlighted: index === highlightedIndex
      }), app.name);
    })
  }) : /*#__PURE__*/jsx("p", {
    className: "text-center text-sm",
    "data-testid": "no-apps-found-title",
    children: t("neetoMolecules.productSwitcher.noApps")
  });
};

var fetch$1 = function fetch() {
  return axios.get("/api/v1/neeto_apps");
};
var neetoAppsApi = {
  fetch: fetch$1
};

function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var useFetchNeetoApps = function useFetchNeetoApps(options) {
  return useQuery(_objectSpread$9({
    queryKey: [QUERY_KEYS$1.NEETO_APPS_LIST],
    queryFn: neetoAppsApi.fetch,
    staleTime: 5 * 60 * 1000
  }, options));
};

var useProductSwitcherNavigation = function useProductSwitcherNavigation() {
  var filteredApps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var _useState = useState(0),
    _useState2 = _slicedToArray(_useState, 2),
    highlightedIndex = _useState2[0],
    setHighlightedIndex = _useState2[1];
  var scrollContainerRef = useRef(null);
  useEffect(function () {
    return setHighlightedIndex(0);
  }, [filteredApps]);
  useEffect(function () {
    if (!scrollContainerRef.current || isEmpty(filteredApps)) return;
    var container = scrollContainerRef.current;
    var highlightedElement = container.querySelector("[data-highlighted-index=\"".concat(highlightedIndex, "\"]"));
    if (!highlightedElement) return;
    var containerRect = container.getBoundingClientRect();
    var elRect = highlightedElement.getBoundingClientRect();
    if (elRect.top < containerRect.top) {
      container.scrollTop += elRect.top - containerRect.top;
    } else if (elRect.bottom > containerRect.bottom) {
      container.scrollTop += elRect.bottom - containerRect.bottom;
    }
  }, [highlightedIndex, filteredApps]);
  var getColumnsPerRow = function getColumnsPerRow() {
    var width = window.innerWidth;
    if (width < 768) return 1;
    if (width < 1024) return 2;
    if (width < 1536) return 3;
    return 4;
  };
  var handleOpenHighlightedApp = function handleOpenHighlightedApp() {
    var app = filteredApps[highlightedIndex];
    if (!(app !== null && app !== void 0 && app.url)) return;
    window.open(app.url, "_blank", "noopener,noreferrer");
  };
  var navigationHandlers = {
    left: function left(prev) {
      return prev === 0 ? filteredApps.length - 1 : prev - 1;
    },
    right: function right(prev) {
      return prev === filteredApps.length - 1 ? 0 : prev + 1;
    },
    up: function up(prev) {
      var columnsPerRow = getColumnsPerRow();
      var newIndex = prev - columnsPerRow;
      if (newIndex >= 0) return newIndex;
      var currentCol = prev % columnsPerRow;
      var lastIndex = filteredApps.length - 1;
      return lastIndex - (lastIndex - currentCol) % columnsPerRow;
    },
    down: function down(prev) {
      var columnsPerRow = getColumnsPerRow();
      var newIndex = prev + columnsPerRow;
      if (newIndex < filteredApps.length) return newIndex;
      return prev % columnsPerRow;
    }
  };
  var keyActions = {
    Enter: handleOpenHighlightedApp,
    ArrowLeft: function ArrowLeft() {
      return setHighlightedIndex(navigationHandlers["left"]);
    },
    ArrowRight: function ArrowRight() {
      return setHighlightedIndex(navigationHandlers["right"]);
    },
    ArrowUp: function ArrowUp() {
      return setHighlightedIndex(navigationHandlers["up"]);
    },
    ArrowDown: function ArrowDown() {
      return setHighlightedIndex(navigationHandlers["down"]);
    },
    Tab: function Tab(e) {
      return setHighlightedIndex(navigationHandlers[e.shiftKey ? "left" : "right"]);
    }
  };
  var handleKeyDown = function handleKeyDown(e) {
    var action = keyActions[e.key];
    if (!action) return;
    e.preventDefault();
    e.stopPropagation();
    if (isNotEmpty(filteredApps)) action(e);
  };
  return {
    highlightedIndex: highlightedIndex,
    handleKeyDown: handleKeyDown,
    scrollContainerRef: scrollContainerRef
  };
};

var Menu = function Menu(_ref) {
  var _ref$isMobile = _ref.isMobile,
    isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(""),
    _useState2 = _slicedToArray(_useState, 2),
    searchTerm = _useState2[0],
    setSearchTerm = _useState2[1];
  var _useFetchNeetoApps = useFetchNeetoApps(),
    data = _useFetchNeetoApps.data,
    isLoading = _useFetchNeetoApps.isLoading;
  var substring = searchTerm.replace(/ /g, "").toLowerCase();
  var filteredApps = useMemo(function () {
    var _data$neetoApps;
    if (!data) return [];
    return data === null || data === void 0 || (_data$neetoApps = data.neetoApps) === null || _data$neetoApps === void 0 ? void 0 : _data$neetoApps.filter(function (_ref2) {
      var name = _ref2.name;
      var nameLower = name.toLowerCase();
      var searchTermLower = substring.toLowerCase();
      var isNeetoPrefixMatch = searchTermLower.length <= 4 && "neeto".startsWith(searchTermLower);
      if (isNeetoPrefixMatch) return true;
      var productName = searchTermLower.startsWith("neeto") ? searchTermLower.replace("neeto", "") : searchTermLower;
      return nameLower.includes(productName);
    });
  }, [data, substring]);
  var _useProductSwitcherNa = useProductSwitcherNavigation(filteredApps),
    highlightedIndex = _useProductSwitcherNa.highlightedIndex,
    handleKeyDown = _useProductSwitcherNa.handleKeyDown,
    scrollContainerRef = _useProductSwitcherNa.scrollContainerRef;
  return /*#__PURE__*/jsxs("div", {
    className: "bg-background flex w-full max-w-full flex-col items-start overflow-y-auto p-6 transition-all max-md:p-4",
    "data-testid": "switcher-wrapper",
    children: [/*#__PURE__*/jsxs("div", {
      "data-testid": "product-switcher-body-wrapper",
      className: classnames("mb-8 flex w-full items-center justify-between gap-8 pt-1 max-md:flex-col max-md:items-start max-md:gap-6", {
        "max-md:mb-6": isMobile
      }),
      children: [!isMobile && /*#__PURE__*/jsx("h1", {
        className: "text-2xl font-bold max-sm:text-xl",
        children: t("neetoMolecules.productSwitcher.chooseNeetoProduct")
      }), /*#__PURE__*/jsx("div", {
        className: "flex-grow lg:w-[296px] lg:flex-grow-0",
        children: /*#__PURE__*/jsxs("div", {
          className: "relative",
          children: [/*#__PURE__*/jsx(Search, {
            className: "text-muted-foreground absolute start-3 top-1/2 size-4 -translate-y-1/2"
          }), /*#__PURE__*/jsx(Input, {
            autoFocus: true,
            className: "h-10 ps-9",
            "data-testid": "product-switcher-search-input",
            placeholder: t("neetoMolecules.productSwitcher.searchProducts"),
            type: "search",
            value: searchTerm,
            onChange: function onChange(e) {
              return setSearchTerm(e.target.value);
            },
            onKeyDown: handleKeyDown
          })]
        })
      })]
    }), /*#__PURE__*/jsx("div", {
      className: "mb-6 flex w-full flex-col gap-3 text-sm",
      ref: scrollContainerRef,
      children: /*#__PURE__*/jsx(Content, {
        filteredApps: filteredApps,
        highlightedIndex: highlightedIndex,
        isLoading: isLoading
      })
    })]
  }, "switcher-wrapper");
};

var Modal = function Modal(_ref) {
  var isOpen = _ref.isOpen,
    onClose = _ref.onClose;
  return /*#__PURE__*/jsx(Dialog, {
    open: isOpen,
    onOpenChange: function onOpenChange(open) {
      return !open && onClose();
    },
    children: /*#__PURE__*/jsxs(DialogContent, {
      "aria-describedby": undefined,
      className: "sm:max-w-4xl",
      showCloseButton: false,
      children: [/*#__PURE__*/jsx(DialogTitle, {
        className: "sr-only",
        children: "Product Switcher"
      }), /*#__PURE__*/jsx("div", {
        "data-testid": "product-switcher-modal",
        children: /*#__PURE__*/jsx(Menu, {})
      })]
    })
  });
};

var MENU_ITEM_CLASS$1 = "flex h-9 w-full items-center gap-2 neeto-ui-rounded-md px-2.5 text-sm font-medium hover:bg-accent";

function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MenuButton$4 = /*#__PURE__*/forwardRef(function (props, ref) {
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  return /*#__PURE__*/jsxs("button", _objectSpread$8(_objectSpread$8({
    ref: ref,
    className: "hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium",
    "data-testid": "help-menu-button",
    type: "button"
  }, props), {}, {
    children: [/*#__PURE__*/jsx(CircleQuestionMark, {
      size: 18
    }), /*#__PURE__*/jsx("span", {
      className: "flex-grow text-start",
      children: t("neetoMolecules.sidebar.help")
    }), /*#__PURE__*/jsx(ChevronRight, {
      className: "rtl:scale-x-[-1]",
      size: 18
    })]
  }));
});
MenuButton$4.displayName = "HelpMenuButton";

var HelpMenu = function HelpMenu() {
  var _globalProps;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var timeoutRef = useRef(null);
  var handleMouseEnter = useCallback(function () {
    clearTimeout(timeoutRef.current);
    setOpen(true);
  }, []);
  var handleMouseLeave = useCallback(function () {
    timeoutRef.current = setTimeout(function () {
      return setOpen(false);
    }, 150);
  }, []);
  return /*#__PURE__*/jsxs(Popover, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsx(PopoverAnchor, {
      asChild: true,
      children: /*#__PURE__*/jsx(MenuButton$4, {
        onClick: function onClick() {
          return setOpen(function (prev) {
            return !prev;
          });
        },
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave
      })
    }), /*#__PURE__*/jsxs(PopoverContent, {
      align: "center",
      className: "z-[99999] w-56 gap-0.5 p-1",
      side: "right",
      sideOffset: 8,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave,
      children: [/*#__PURE__*/jsxs("a", {
        className: MENU_ITEM_CLASS$1,
        "data-testid": "help-link-help-articles-button",
        href: "https://help.".concat(toLower(((_globalProps = globalProps) === null || _globalProps === void 0 ? void 0 : _globalProps.appName) || ""), ".com/"),
        rel: "noreferrer",
        target: "_blank",
        children: [/*#__PURE__*/jsx(BookOpen, {
          size: 18
        }), t("neetoMolecules.sidebar.helpLinks.helpArticles")]
      }), /*#__PURE__*/jsxs("button", {
        className: MENU_ITEM_CLASS$1,
        "data-testid": "help-link-live-chat-button",
        type: "button",
        onClick: function onClick() {
          var _window$NeetoChat, _window$NeetoChat2;
          (_window$NeetoChat = window.NeetoChat) === null || _window$NeetoChat === void 0 || (_window$NeetoChat = _window$NeetoChat.contextualHelp) === null || _window$NeetoChat === void 0 || _window$NeetoChat.maximizeWidget();
          (_window$NeetoChat2 = window.NeetoChat) === null || _window$NeetoChat2 === void 0 || (_window$NeetoChat2 = _window$NeetoChat2.contextualHelp) === null || _window$NeetoChat2 === void 0 || _window$NeetoChat2.openWidget();
        },
        children: [/*#__PURE__*/jsx(MessageCircleQuestionMark, {
          size: 18
        }), t("neetoMolecules.sidebar.helpLinks.liveChat")]
      }), /*#__PURE__*/jsxs("a", {
        className: MENU_ITEM_CLASS$1,
        "data-testid": "help-link-community-button",
        href: "https://www.launchpass.com/neetohq",
        rel: "noreferrer",
        target: "_blank",
        children: [/*#__PURE__*/jsx(Users, {
          size: 18
        }), t("neetoMolecules.sidebar.helpLinks.askTheCommunity")]
      }), /*#__PURE__*/jsxs("a", {
        className: MENU_ITEM_CLASS$1,
        "data-testid": "help-link-status-button",
        href: "https://neetostatus.com/",
        rel: "noreferrer",
        target: "_blank",
        children: [/*#__PURE__*/jsx(Activity, {
          size: 18
        }), t("neetoMolecules.sidebar.helpLinks.systemStatus")]
      })]
    })]
  });
};

var _excluded$2 = ["label", "icon", "changesCount", "href"];
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var LinkSection = function LinkSection(_ref) {
  var links = _ref.links;
  if (isNotPresent(links)) return null;
  return /*#__PURE__*/jsx(Fragment, {
    children: links.map(function (_ref2, idx) {
      var label = _ref2.label,
        Icon = _ref2.icon,
        changesCount = _ref2.changesCount,
        href = _ref2.href,
        otherProps = _objectWithoutProperties(_ref2, _excluded$2);
      var Tag = href ? "a" : "button";
      return /*#__PURE__*/jsxs(Tag, _objectSpread$7(_objectSpread$7(_objectSpread$7({
        className: "hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium",
        "data-testid": "floating-action-menu-link-section",
        type: href ? undefined : "button"
      }, href ? {
        href: href
      } : {}), otherProps), {}, {
        children: [Icon && /*#__PURE__*/jsx(Icon, {
          size: 18
        }), /*#__PURE__*/jsxs("span", {
          className: "flex flex-grow items-center gap-2",
          children: [label, isPresent(changesCount) && /*#__PURE__*/jsx("span", {
            className: "bg-accent-foreground flex h-[1.125rem] min-w-[1.125rem] shrink-0 items-center justify-center rounded-full px-1 text-[10px] text-white select-none",
            "data-testid": "help-section-menu-changes-count",
            children: changesCount
          })]
        })]
      }), idx);
    })
  });
};

var fetch = function fetch(email) {
  return axios.get("/logged_in_organizations", {
    params: {
      email: email
    }
  });
};
var loggedInOrganizationsApi = {
  fetch: fetch
};

var QUERY_KEYS = {
  LOGGED_IN_ORGANIZATIONS_LIST: "logged-in-organizations-list"
};

var LOGGED_IN_ORGANIZATIONS_LIST = QUERY_KEYS.LOGGED_IN_ORGANIZATIONS_LIST;
var useFetchLoggedInOrganizations = function useFetchLoggedInOrganizations(email) {
  return useQuery({
    queryKey: [LOGGED_IN_ORGANIZATIONS_LIST, email],
    queryFn: function queryFn() {
      return loggedInOrganizationsApi.fetch(email);
    }
  });
};

function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MenuButton$3 = /*#__PURE__*/forwardRef(function (props, ref) {
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  return /*#__PURE__*/jsxs("button", _objectSpread$6(_objectSpread$6({
    ref: ref,
    className: "hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium",
    "data-testid": "organization-switcher-button",
    type: "button"
  }, props), {}, {
    children: [/*#__PURE__*/jsx("span", {
      className: "flex-grow text-start",
      children: t("neetoMolecules.sidebar.organizationSwitcher.label")
    }), /*#__PURE__*/jsx(ChevronRight, {
      className: "rtl:scale-x-[-1]",
      size: 18
    })]
  }));
});
MenuButton$3.displayName = "OrganizationSwitcherMenuButton";

var OrganizationSwitcher = function OrganizationSwitcher() {
  var _globalProps$user;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var timeoutRef = useRef(null);
  var _useFetchLoggedInOrga = useFetchLoggedInOrganizations(globalProps$1 === null || globalProps$1 === void 0 || (_globalProps$user = globalProps$1.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email),
    _useFetchLoggedInOrga2 = _useFetchLoggedInOrga.data,
    _useFetchLoggedInOrga3 = _useFetchLoggedInOrga2 === void 0 ? {} : _useFetchLoggedInOrga2,
    organizations = _useFetchLoggedInOrga3.organizations,
    authAppUrl = _useFetchLoggedInOrga3.authAppUrl;
  var handleMouseEnter = useCallback(function () {
    clearTimeout(timeoutRef.current);
    setOpen(true);
  }, []);
  var handleMouseLeave = useCallback(function () {
    timeoutRef.current = setTimeout(function () {
      return setOpen(false);
    }, 150);
  }, []);
  var isCurrentSubdomain = function isCurrentSubdomain(link) {
    try {
      var currentSubdomain = window.location.hostname.split(".")[0];
      var linkSubdomain = new URL(link).hostname.split(".")[0];
      return currentSubdomain === linkSubdomain;
    } catch (_unused) {
      return false;
    }
  };
  return /*#__PURE__*/jsxs(Popover, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsx(PopoverAnchor, {
      asChild: true,
      children: /*#__PURE__*/jsx(MenuButton$3, {
        onClick: function onClick() {
          return setOpen(function (prev) {
            return !prev;
          });
        },
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave
      })
    }), /*#__PURE__*/jsxs(PopoverContent, {
      align: "center",
      className: "z-[99999] w-56 gap-0.5 p-1",
      side: "right",
      sideOffset: 8,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave,
      children: [organizations === null || organizations === void 0 ? void 0 : organizations.map(function (organization) {
        return /*#__PURE__*/jsxs("a", {
          href: organization.organizationUrl,
          rel: "noreferrer",
          target: "_blank",
          className: classnames("hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium", {
            "text-green-600": isCurrentSubdomain(organization.organizationUrl)
          }),
          children: [organization.orgName, isCurrentSubdomain(organization.organizationUrl) && /*#__PURE__*/jsxs(Badge, {
            variant: "default",
            children: [/*#__PURE__*/jsx(CircleCheck, {
              size: 12
            }), t("neetoMolecules.sidebar.organizationSwitcher.signedin")]
          })]
        }, organization.userId);
      }), /*#__PURE__*/jsx("a", {
        className: "hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium",
        href: authAppUrl,
        rel: "noreferrer",
        target: "_blank",
        children: t("neetoMolecules.sidebar.organizationSwitcher.addAccount")
      })]
    })]
  });
};

function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MenuButton$2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var otherProps = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  return /*#__PURE__*/jsxs("button", _objectSpread$5(_objectSpread$5({
    ref: ref,
    className: "hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium",
    "data-testid": "product-switcher-button",
    type: "button"
  }, otherProps), {}, {
    children: [/*#__PURE__*/jsx("span", {
      className: "flex-grow text-start",
      children: t("neetoMolecules.sidebar.productSwitcher")
    }), /*#__PURE__*/jsx(ChevronRight, {
      className: "rtl:scale-x-[-1]",
      size: 18
    })]
  }));
});
MenuButton$2.displayName = "ProductSwitcherMenuButton";

var Dropdown = function Dropdown() {
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var timeoutRef = useRef(null);
  var handleMouseEnter = useCallback(function () {
    clearTimeout(timeoutRef.current);
    setOpen(true);
  }, []);
  var handleMouseLeave = useCallback(function () {
    timeoutRef.current = setTimeout(function () {
      return setOpen(false);
    }, 150);
  }, []);
  return /*#__PURE__*/jsxs(Popover, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsx(PopoverAnchor, {
      asChild: true,
      children: /*#__PURE__*/jsx(MenuButton$2, {
        onClick: function onClick() {
          return setOpen(function (prev) {
            return !prev;
          });
        },
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave
      })
    }), /*#__PURE__*/jsx(PopoverContent, {
      align: "start",
      className: "z-[99999] w-[calc(100vw-25rem)] max-w-none overflow-y-auto rounded-xl p-0",
      collisionPadding: 16,
      side: "right",
      sideOffset: 8,
      style: {
        maxHeight: "var(--radix-popover-content-available-height)"
      },
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave,
      children: /*#__PURE__*/jsx(Menu, {})
    })]
  });
};

var ProductSwitcher = function ProductSwitcher(_ref) {
  var toggleModal = _ref.toggleModal;
  var _useBreakpoints = useBreakpoints(),
    isSize = _useBreakpoints.isSize;
  var isMobile = isSize("mobile");
  return isMobile ? /*#__PURE__*/jsx(MenuButton$2, {
    onClick: function onClick() {
      return toggleModal(true);
    }
  }) : /*#__PURE__*/jsx(Dropdown, {});
};

var MENU_ITEM_CLASS = "flex h-9 w-full items-center gap-2 neeto-ui-rounded-md px-2.5 text-sm font-medium hover:bg-accent";

var getInitials$1 = function getInitials(name) {
  return (name || "").split(" ").filter(Boolean).map(function (n) {
    return n[0];
  }).join("").toUpperCase().slice(0, 2);
};
var ProfileHeader = function ProfileHeader(_ref) {
  var profileInfo = _ref.profileInfo;
  var name = profileInfo.name,
    email = profileInfo.email,
    imageUrl = profileInfo.imageUrl;
  return /*#__PURE__*/jsxs("span", {
    className: "flex w-full min-w-0 items-center gap-2 text-start",
    "data-testid": "floating-action-menu-profile-header",
    children: [/*#__PURE__*/jsxs(Avatar, {
      className: "size-8 shrink-0",
      "data-testid": "floating-action-menu-header-profile-icon",
      children: [/*#__PURE__*/jsx(AvatarImage, {
        alt: name,
        src: imageUrl
      }), /*#__PURE__*/jsx(AvatarFallback, {
        children: getInitials$1(name)
      })]
    }), /*#__PURE__*/jsxs("span", {
      className: "flex min-w-0 flex-grow flex-col gap-1",
      children: [/*#__PURE__*/jsx("span", {
        className: "text-sm leading-tight font-semibold",
        "data-testid": "floating-action-menu-header-user-name",
        title: name,
        children: truncate(name, 18)
      }), email && /*#__PURE__*/jsx("span", {
        className: "text-muted-foreground w-full truncate text-xs leading-tight",
        "data-testid": "floating-action-menu-header-user-email",
        children: email
      })]
    })]
  });
};

var _excluded$1 = ["profileInfo"];
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MenuButton$1 = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var profileInfo = _ref.profileInfo,
    otherProps = _objectWithoutProperties(_ref, _excluded$1);
  return /*#__PURE__*/jsxs("button", _objectSpread$4(_objectSpread$4({
    ref: ref,
    className: "hover:bg-accent flex w-full items-center gap-2 rounded-md px-2.5 py-2 transition-colors",
    "data-testid": "profile-expand-menu-button",
    type: "button"
  }, otherProps), {}, {
    children: [/*#__PURE__*/jsx(ProfileHeader, {
      profileInfo: profileInfo
    }), /*#__PURE__*/jsx(ChevronRight, {
      className: "shrink-0 rtl:scale-x-[-1]",
      size: 18
    })]
  }));
});
MenuButton$1.displayName = "ProfileExpandMenuButton";

var MY_ORGANIZATION_URL = "/auth/organization/edit";
var DELETE_WORKSPACE_URL = "/auth/organization/delete";
var ENGAGE_WIDGET_TRIGGER_ID = "neetoengage-trigger";
var DEFAULT_MENU_LINK_PROPS = {
  engageProps: {
    id: ENGAGE_WIDGET_TRIGGER_ID,
    label: t("neetoMolecules.sidebar.helpLinks.whatsNew"),
    "data-testid": "help-link-engage-button"
  },
  keyboardShortcutProps: {
    label: t("neetoMolecules.sidebar.helpLinks.keyboardShortcuts"),
    "data-testid": "help-link-keyboard-shortcut-button"
  }
};

// Theme switcher
var APP_THEME_LOCALSTORAGE_KEY = "appTheme";
var THEMES = {
  LIGHT: "neeto-ui-theme--light",
  DARK: "neeto-ui-theme--dark"
};

// Shadcn uses `.dark` class for dark mode via @custom-variant dark (&:is(.dark *))
var SHADCN_DARK_CLASS = "dark";
var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";

var ProfileExpandMenu = function ProfileExpandMenu(_ref) {
  var _window$globalProps;
  var profileInfo = _ref.profileInfo;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var _Profile$usePaneState = Profile.usePaneState(),
    _Profile$usePaneState2 = _slicedToArray(_Profile$usePaneState, 2),
    setIsProfilePaneOpen = _Profile$usePaneState2[1];
  var timeoutRef = useRef(null);
  var handleMouseEnter = useCallback(function () {
    clearTimeout(timeoutRef.current);
    setOpen(true);
  }, []);
  var handleMouseLeave = useCallback(function () {
    timeoutRef.current = setTimeout(function () {
      return setOpen(false);
    }, 150);
  }, []);
  return /*#__PURE__*/jsxs(Popover, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsx(PopoverAnchor, {
      asChild: true,
      children: /*#__PURE__*/jsx(MenuButton$1, {
        profileInfo: profileInfo,
        onClick: function onClick() {
          return setOpen(function (prev) {
            return !prev;
          });
        },
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave
      })
    }), /*#__PURE__*/jsxs(PopoverContent, {
      align: "center",
      className: "z-[99999] w-56 gap-0.5 p-1",
      side: "right",
      sideOffset: 8,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave,
      children: [/*#__PURE__*/jsxs("button", {
        className: MENU_ITEM_CLASS,
        "data-testid": "profile-my-profile-button",
        type: "button",
        onClick: function onClick() {
          return setIsProfilePaneOpen(true);
        },
        children: [/*#__PURE__*/jsx(User, {
          size: 18
        }), t("neetoMolecules.sidebar.myProfile")]
      }), ((_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 || (_window$globalProps = _window$globalProps.user) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.isOwner) && /*#__PURE__*/jsxs("a", {
        className: MENU_ITEM_CLASS,
        "data-testid": "profile-cancel-account-button",
        href: DELETE_WORKSPACE_URL,
        rel: "noreferrer",
        target: "_blank",
        children: [/*#__PURE__*/jsx(CircleX, {
          size: 18
        }), t("neetoMolecules.sidebar.cancelAccount")]
      })]
    })]
  });
};

var getSidebarStateLocalStorageKey = function getSidebarStateLocalStorageKey() {
  var _globalProps$user, _globalProps$user2;
  var user = ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email) || ((_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.phoneNumber);
  return "sidebarState-".concat(user);
};
var getUserProfileInfo = function getUserProfileInfo() {
  var _globalProps$user$fir, _globalProps$user3, _globalProps$user$las, _globalProps$user4, _globalProps$user5, _globalProps$user6, _globalProps$user7;
  return {
    name: "".concat((_globalProps$user$fir = (_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.firstName) !== null && _globalProps$user$fir !== void 0 ? _globalProps$user$fir : "", " ").concat((_globalProps$user$las = (_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.lastName) !== null && _globalProps$user$las !== void 0 ? _globalProps$user$las : ""),
    imageUrl: globalProps.authenticated ? (_globalProps$user5 = globalProps.user) === null || _globalProps$user5 === void 0 ? void 0 : _globalProps$user5.profileImageUrl : "https://d2v7kzglnr2dnh.cloudfront.net/others/profile-pic.jpg",
    email: ((_globalProps$user6 = globalProps.user) === null || _globalProps$user6 === void 0 ? void 0 : _globalProps$user6.email) || ((_globalProps$user7 = globalProps.user) === null || _globalProps$user7 === void 0 ? void 0 : _globalProps$user7.phoneNumber),
    isAuthenticated: globalProps.authenticated
  };
};
var getConsumerProfileInfo = function getConsumerProfileInfo() {
  var _globalProps$consumer, _globalProps$consumer2, _globalProps$consumer3, _globalProps$consumer4, _globalProps$consumer5, _globalProps$consumer6, _globalProps$consumer7;
  return {
    name: "".concat((_globalProps$consumer = (_globalProps$consumer2 = globalProps.consumer) === null || _globalProps$consumer2 === void 0 ? void 0 : _globalProps$consumer2.firstName) !== null && _globalProps$consumer !== void 0 ? _globalProps$consumer : "", " ").concat((_globalProps$consumer3 = (_globalProps$consumer4 = globalProps.consumer) === null || _globalProps$consumer4 === void 0 ? void 0 : _globalProps$consumer4.lastName) !== null && _globalProps$consumer3 !== void 0 ? _globalProps$consumer3 : ""),
    imageUrl: ((_globalProps$consumer5 = globalProps.consumer) === null || _globalProps$consumer5 === void 0 ? void 0 : _globalProps$consumer5.profileImageUrl) || "https://d2v7kzglnr2dnh.cloudfront.net/others/profile-pic.jpg",
    email: ((_globalProps$consumer6 = globalProps.consumer) === null || _globalProps$consumer6 === void 0 ? void 0 : _globalProps$consumer6.email) || ((_globalProps$consumer7 = globalProps.consumer) === null || _globalProps$consumer7 === void 0 ? void 0 : _globalProps$consumer7.phoneNumber),
    isAuthenticated: globalProps.isConsumer
  };
};
var getDefaultBottomLinks = function getDefaultBottomLinks(isAuthenticated, isConsumer) {
  return [isAuthenticated ? {
    label: t("neetoMolecules.sidebar.logout"),
    icon: LogOut,
    onClick: function onClick() {
      resetAuthTokens();
      removeFromLocalStorage(getSidebarStateLocalStorageKey());
      isConsumer ? window.location.href = "/consumers/logout?redirect_uri=".concat(window.location.href) : window.location.href = "/logout";
    },
    "data-testid": "profile-logout-button"
  } : {
    label: t("neetoMolecules.sidebar.login"),
    onClick: function onClick() {
      window.location.href = "/login";
    },
    "data-testid": "profile-login-button"
  }];
};
var getProfileInfo = function getProfileInfo(profileInfoOverrides, isConsumer) {
  return mergeDeepLeft(profileInfoOverrides, isConsumer ? getConsumerProfileInfo() : getUserProfileInfo());
};

// Theme switcher utils.
var setDarkTheme = function setDarkTheme() {
  if (!document.body) return;
  document.body.classList.remove(THEMES.LIGHT);
  document.body.classList.add(THEMES.DARK, SHADCN_DARK_CLASS);
};
var setLightTheme = function setLightTheme() {
  if (!document.body) return;
  document.body.classList.remove(THEMES.DARK, SHADCN_DARK_CLASS);
  document.body.classList.add(THEMES.LIGHT);
};
var setAppTheme = function setAppTheme() {
  var isDarkTheme = getFromLocalStorage(APP_THEME_LOCALSTORAGE_KEY) === THEMES.DARK;
  isDarkTheme ? setDarkTheme() : setLightTheme();
};

var ThemeSwitcher = function ThemeSwitcher() {
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useLocalStorage = useLocalStorage(APP_THEME_LOCALSTORAGE_KEY, THEMES.LIGHT),
    _useLocalStorage2 = _slicedToArray(_useLocalStorage, 2),
    appTheme = _useLocalStorage2[0],
    setAppTheme = _useLocalStorage2[1];
  var isDarkThemeSelected = appTheme === THEMES.DARK;
  var switchTheme = function switchTheme(theme) {
    theme === THEMES.LIGHT ? setLightTheme() : setDarkTheme();
    setAppTheme(theme);
  };
  return /*#__PURE__*/jsxs("div", {
    className: "bg-muted/40 flex items-center justify-between gap-3 rounded-b-xl px-4 py-3",
    children: [/*#__PURE__*/jsx("span", {
      className: "text-muted-foreground text-xs font-medium",
      children: t("neetoMolecules.sidebar.themeSwitcher.label")
    }), /*#__PURE__*/jsxs("div", {
      className: "bg-muted flex rounded-lg p-0.5",
      "data-testid": "theme-switcher-button",
      children: [/*#__PURE__*/jsxs("button", {
        "data-testid": "theme-switcher-light-button",
        type: "button",
        className: classnames("flex items-center gap-1 rounded-md px-2.5 py-1.5 text-xs font-medium transition-all", isDarkThemeSelected ? "text-muted-foreground hover:text-foreground" : "bg-background text-foreground ring-border shadow-sm ring-1"),
        onClick: function onClick() {
          return switchTheme(THEMES.LIGHT);
        },
        children: [/*#__PURE__*/jsx(Sun, {
          size: 13
        }), t("neetoMolecules.sidebar.themeSwitcher.light")]
      }), /*#__PURE__*/jsxs("button", {
        "data-testid": "theme-switcher-dark-button",
        type: "button",
        className: classnames("flex items-center gap-1 rounded-md px-2.5 py-1.5 text-xs font-medium transition-all", isDarkThemeSelected ? "bg-background text-foreground ring-border shadow-sm ring-1" : "text-muted-foreground hover:text-foreground"),
        onClick: function onClick() {
          return switchTheme(THEMES.DARK);
        },
        children: [/*#__PURE__*/jsx(Moon, {
          size: 13
        }), t("neetoMolecules.sidebar.themeSwitcher.dark")]
      })]
    })]
  });
};

function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MenuButton = /*#__PURE__*/forwardRef(function (props, ref) {
  var _globalProps$organiza;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  return /*#__PURE__*/jsxs("button", _objectSpread$3(_objectSpread$3({
    ref: ref,
    className: "hover:bg-accent flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-start",
    "data-testid": "workspace-display",
    type: "button"
  }, props), {}, {
    children: [/*#__PURE__*/jsxs("span", {
      className: "flex flex-grow flex-col gap-1.5",
      children: [/*#__PURE__*/jsx("span", {
        className: "text-sm font-medium",
        children: t("neetoMolecules.sidebar.workspace")
      }), ((_globalProps$organiza = globalProps$1.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.name) && /*#__PURE__*/jsx("span", {
        className: "text-muted-foreground text-xs",
        children: globalProps$1.organization.name
      })]
    }), /*#__PURE__*/jsx(ChevronRight, {
      className: "shrink-0 rtl:scale-x-[-1]",
      size: 18
    })]
  }));
});
MenuButton.displayName = "WorkspaceMenuButton";

var WorkspaceMenu = function WorkspaceMenu() {
  var _globalProps$organiza;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  var timeoutRef = useRef(null);
  var handleMouseEnter = useCallback(function () {
    clearTimeout(timeoutRef.current);
    setOpen(true);
  }, []);
  var handleMouseLeave = useCallback(function () {
    timeoutRef.current = setTimeout(function () {
      return setOpen(false);
    }, 150);
  }, []);
  return /*#__PURE__*/jsxs(Popover, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsx(PopoverAnchor, {
      asChild: true,
      children: /*#__PURE__*/jsx(MenuButton, {
        onClick: function onClick() {
          return setOpen(function (prev) {
            return !prev;
          });
        },
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave
      })
    }), /*#__PURE__*/jsxs(PopoverContent, {
      align: "center",
      className: "z-[99999] w-56 gap-0.5 p-1",
      side: "right",
      sideOffset: 8,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave,
      children: [/*#__PURE__*/jsx("a", {
        className: "hover:bg-accent flex h-9 w-full items-center gap-2 rounded-md px-2.5 text-sm font-medium",
        "data-testid": "profile-organization-settings-button",
        href: MY_ORGANIZATION_URL,
        rel: "noreferrer",
        target: "_blank",
        children: t("neetoMolecules.sidebar.workspaceMenu.settings")
      }), ((_globalProps$organiza = globalProps$1.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain) && /*#__PURE__*/jsx("div", {
        className: "px-3 py-2",
        children: /*#__PURE__*/jsxs("span", {
          className: "flex flex-col gap-0.5 text-start",
          children: [/*#__PURE__*/jsx("span", {
            className: "text-sm font-medium",
            children: t("neetoMolecules.sidebar.workspaceMenu.subdomain")
          }), /*#__PURE__*/jsxs("span", {
            className: "text-muted-foreground flex items-center gap-1 text-xs",
            children: [/*#__PURE__*/jsx("span", {
              className: "min-w-0 truncate",
              children: globalProps$1.organization.subdomain
            }), /*#__PURE__*/jsx(CopyToClipboardButton, {
              className: "flex-shrink-0",
              size: "small",
              style: "text",
              value: globalProps$1.organization.subdomain
            })]
          })]
        })
      })]
    })]
  });
};

function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var ProfileMenu = function ProfileMenu(_ref) {
  var _globalProps$user, _globalProps$user2, _globalProps$user3, _globalProps$user4, _globalProps$user5;
  var profileInfo = _ref.profileInfo,
    showProductSwitcher = _ref.showProductSwitcher,
    defaultLinks = _ref.defaultLinks,
    topLinks = _ref.topLinks,
    bottomLinks = _ref.bottomLinks,
    customContent = _ref.customContent,
    toggleModal = _ref.toggleModal,
    isThemeSwitcherEnabled = _ref.isThemeSwitcherEnabled,
    isOrganizationSwitcherEnabled = _ref.isOrganizationSwitcherEnabled,
    isConsumer = _ref.isConsumer,
    enableSubscriptionUpgradeRequest = _ref.enableSubscriptionUpgradeRequest,
    openUpgradeModal = _ref.openUpgradeModal;
  var isAuthenticated = profileInfo.isAuthenticated;
  var _useTranslation = useTranslation(),
    t = _useTranslation.t;
  var normalizedPlan = (((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.subscriptionPlan) || "").toLowerCase();
  var isFreePlan = normalizedPlan === "free";
  var isOwner = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.isOwner;
  var showUpgradeModal = isFreePlan && enableSubscriptionUpgradeRequest && !isOwner;
  var getSubscriptionPlanAction = function getSubscriptionPlanAction() {
    if (showUpgradeModal) return {
      onClick: openUpgradeModal
    };
    if (isFreePlan && isOwner && enableSubscriptionUpgradeRequest) {
      var _globalProps$organiza;
      return {
        href: "".concat((_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.authAppUrl, "/admin/billing/overview")
      };
    }
    return {
      href: NEETO_AUTH_BILLING_INFO_URL
    };
  };
  var subscriptionPlanLink = _objectSpread$2({
    label: /*#__PURE__*/jsxs(Fragment, {
      children: [globalProps.appName, " ", /*#__PURE__*/jsx("span", {
        className: classnames("inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[10px] leading-tight font-semibold", {
          "bg-[#FFE44A] text-black": normalizedPlan === "pro",
          "bg-primary text-primary-foreground": isFreePlan
        }),
        children: normalizedPlan === "pro" ? humanize((_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.subscriptionPlan) : /*#__PURE__*/jsxs(Fragment, {
          children: [/*#__PURE__*/jsx(Crown, {
            size: 12
          }), t("neetoMolecules.sidebar.upgradePlan")]
        })
      })]
    }),
    "data-testid": "subscription-plan"
  }, getSubscriptionPlanAction());
  return /*#__PURE__*/jsxs("div", {
    className: "p-1.5",
    children: [!isConsumer && /*#__PURE__*/jsxs(Fragment, {
      children: [/*#__PURE__*/jsx(LinkSection, {
        links: defaultLinks
      }), isNotEmpty(topLinks) && /*#__PURE__*/jsxs(Fragment, {
        children: [/*#__PURE__*/jsx(Separator, {
          className: "my-2"
        }), /*#__PURE__*/jsx(LinkSection, {
          links: topLinks
        })]
      }), isPresent(customContent) && /*#__PURE__*/jsxs(Fragment, {
        children: [/*#__PURE__*/jsx(Separator, {
          className: "my-2"
        }), /*#__PURE__*/jsx("div", {
          className: "px-3 py-1",
          children: customContent
        })]
      }), /*#__PURE__*/jsx(Separator, {
        className: "my-2"
      }), ((_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.isOwner) && /*#__PURE__*/jsx(WorkspaceMenu, {}), isOrganizationSwitcherEnabled && /*#__PURE__*/jsx(OrganizationSwitcher, {}), /*#__PURE__*/jsx(Separator, {
        className: "my-2"
      }), isPresent((_globalProps$user5 = globalProps.user) === null || _globalProps$user5 === void 0 ? void 0 : _globalProps$user5.subscriptionPlan) && /*#__PURE__*/jsx(LinkSection, {
        links: [subscriptionPlanLink]
      }), showProductSwitcher && /*#__PURE__*/jsx(ProductSwitcher, {
        toggleModal: toggleModal
      }), /*#__PURE__*/jsx(HelpMenu, {}), /*#__PURE__*/jsx(Separator, {
        className: "my-2"
      })]
    }), isAuthenticated && !isConsumer && /*#__PURE__*/jsx(ProfileExpandMenu, {
      profileInfo: profileInfo
    }), /*#__PURE__*/jsx(LinkSection, {
      links: bottomLinks
    }), isThemeSwitcherEnabled && /*#__PURE__*/jsxs(Fragment, {
      children: [/*#__PURE__*/jsx(Separator, {
        className: "my-2"
      }), /*#__PURE__*/jsx(ThemeSwitcher, {})]
    })]
  });
};

function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var getInitials = function getInitials(name) {
  return (name || "").split(" ").filter(Boolean).map(function (n) {
    return n[0];
  }).join("").toUpperCase().slice(0, 2);
};
var ProfileButton = function ProfileButton(_ref) {
  var profileInfoOverrides = _ref.profileInfoOverrides,
    showProductSwitcher = _ref.showProductSwitcher,
    bottomLinks = _ref.bottomLinks,
    topLinks = _ref.topLinks,
    customContent = _ref.customContent,
    isThemeSwitcherEnabled = _ref.isThemeSwitcherEnabled,
    isOrganizationSwitcherEnabled = _ref.isOrganizationSwitcherEnabled,
    profilePopoverProps = _ref.profilePopoverProps,
    isConsumer = _ref.isConsumer,
    enableSubscriptionUpgradeRequest = _ref.enableSubscriptionUpgradeRequest;
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isModalOpen = _useState2[0],
    setIsModalOpen = _useState2[1];
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    isUpgradeModalOpen = _useState4[0],
    setIsUpgradeModalOpen = _useState4[1];
  var _useState5 = useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    isPopoverOpen = _useState6[0],
    setIsPopoverOpen = _useState6[1];
  var _useState7 = useState(null),
    _useState8 = _slicedToArray(_useState7, 2),
    changesCount = _useState8[0],
    setChangesCount = _useState8[1];
  var timeoutRef = useRef(null);
  var _KeyboardShortcuts$us = KeyboardShortcuts.usePaneState(),
    _KeyboardShortcuts$us2 = _slicedToArray(_KeyboardShortcuts$us, 2),
    setIsOpen = _KeyboardShortcuts$us2[1];
  useHotkeys(["ctrl+u", "command+u"], function () {
    return setIsModalOpen(not);
  }, {
    mode: "global"
  });
  var profileInfo = getProfileInfo(profileInfoOverrides, isConsumer);
  useEffect(function () {
    var Nv = {
      onReceiveData: function onReceiveData(data) {
        if (!data.unreadCount) return;
        setChangesCount(data.unreadCount);
      },
      onShow: function onShow() {
        setChangesCount(null);
      }
    };
    window.Nv = window.Nv ? Object.assign(window.Nv, Nv) : Nv;
  }, []);
  useEffect(function () {
    return function () {
      return clearTimeout(timeoutRef.current);
    };
  }, []);
  var handleMouseEnter = useCallback(function () {
    clearTimeout(timeoutRef.current);
    setIsPopoverOpen(true);
  }, []);
  var handleMouseLeave = useCallback(function () {
    timeoutRef.current = setTimeout(function () {
      return setIsPopoverOpen(false);
    }, 150);
  }, []);
  var newBottomLinks = [].concat(_toConsumableArray(getDefaultBottomLinks(profileInfo.isAuthenticated, isConsumer)), _toConsumableArray(bottomLinks));
  var defaultLinks = Object.keys(DEFAULT_MENU_LINK_PROPS).map(function (key) {
    return _objectSpread$1(_objectSpread$1(_objectSpread$1({}, DEFAULT_MENU_LINK_PROPS[key]), key === "keyboardShortcutProps" && {
      onClick: function onClick() {
        return setIsOpen(function (prev) {
          return !prev;
        });
      }
    }), key === "engageProps" && changesCount && {
      changesCount: changesCount
    });
  }).filter(function (_ref2) {
    var hide = _ref2.hide;
    return !hide;
  });
  return /*#__PURE__*/jsxs(Fragment, {
    children: [/*#__PURE__*/jsx(Profile.Pane, {
      popoverProps: profilePopoverProps
    }), isPopoverOpen && /*#__PURE__*/jsx("div", {
      className: "pointer-events-none fixed inset-0 z-[99998] bg-black/[0.27]"
    }), /*#__PURE__*/jsxs(Popover, {
      open: isPopoverOpen,
      onOpenChange: setIsPopoverOpen,
      children: [/*#__PURE__*/jsx(PopoverAnchor, {
        asChild: true,
        children: /*#__PURE__*/jsxs("button", {
          className: "bg-primary flex flex-col items-center justify-center gap-1.5 rounded-e-2xl p-1",
          type: "button",
          onMouseEnter: handleMouseEnter,
          onMouseLeave: handleMouseLeave,
          children: [/*#__PURE__*/jsxs(Avatar, {
            className: "size-[1.625rem] shrink-0 rounded-full border-2 border-white",
            "data-testid": "profile-avatar",
            children: [/*#__PURE__*/jsx(AvatarImage, {
              alt: profileInfo.name,
              src: profileInfo.imageUrl
            }), /*#__PURE__*/jsx(AvatarFallback, {
              className: "text-[10px]",
              children: getInitials(profileInfo.name)
            })]
          }), /*#__PURE__*/jsx("span", {
            className: "flex size-[1.625rem] items-center justify-center rounded-full bg-white",
            children: /*#__PURE__*/jsx(CircleQuestionMark, {
              size: 20
            })
          })]
        })
      }), /*#__PURE__*/jsx(PopoverContent, {
        align: "end",
        className: "z-[99999] max-h-[var(--radix-popover-content-available-height)] w-64 overflow-y-auto rounded-xl p-0",
        collisionPadding: 16,
        side: "right",
        sideOffset: 8,
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave,
        children: /*#__PURE__*/jsx(ProfileMenu, {
          customContent: customContent,
          defaultLinks: defaultLinks,
          enableSubscriptionUpgradeRequest: enableSubscriptionUpgradeRequest,
          isConsumer: isConsumer,
          isOrganizationSwitcherEnabled: isOrganizationSwitcherEnabled,
          isThemeSwitcherEnabled: isThemeSwitcherEnabled,
          profileInfo: profileInfo,
          showProductSwitcher: showProductSwitcher,
          topLinks: topLinks,
          bottomLinks: newBottomLinks,
          openUpgradeModal: function openUpgradeModal() {
            return setIsUpgradeModalOpen(true);
          },
          toggleModal: setIsModalOpen
        })
      })]
    }), isPresent(changesCount) && /*#__PURE__*/jsx("span", {
      className: "bg-accent-foreground pointer-events-none absolute end-0 top-0 z-[3] flex h-[0.9375rem] min-w-[0.9375rem] items-center justify-center rounded-full border border-white px-1 text-[10px] text-white select-none",
      "data-testid": "help-icon-changes-count",
      children: changesCount
    }), /*#__PURE__*/jsx(Modal, {
      isOpen: isModalOpen,
      onClose: function onClose() {
        return setIsModalOpen(false);
      }
    }), enableSubscriptionUpgradeRequest && /*#__PURE__*/jsx(SubscriptionUpgradeRequestModal, {
      isOpen: isUpgradeModalOpen,
      onClose: function onClose() {
        return setIsUpgradeModalOpen(false);
      }
    })]
  });
};

var _excluded = ["profileInfoOverrides", "topLinks", "bottomLinks", "showProductSwitcher", "isThemeSwitcherEnabled", "isOrganizationSwitcherEnabled", "customContent", "profilePopoverProps", "isConsumer", "enableSubscriptionUpgradeRequest"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var FloatingActionMenu = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var _globalProps$user;
  var _ref$profileInfoOverr = _ref.profileInfoOverrides,
    profileInfoOverrides = _ref$profileInfoOverr === void 0 ? {} : _ref$profileInfoOverr,
    _ref$topLinks = _ref.topLinks,
    topLinks = _ref$topLinks === void 0 ? [] : _ref$topLinks,
    _ref$bottomLinks = _ref.bottomLinks,
    bottomLinks = _ref$bottomLinks === void 0 ? [] : _ref$bottomLinks,
    _ref$showProductSwitc = _ref.showProductSwitcher,
    showProductSwitcher = _ref$showProductSwitc === void 0 ? true : _ref$showProductSwitc,
    _ref$isThemeSwitcherE = _ref.isThemeSwitcherEnabled,
    isThemeSwitcherEnabled = _ref$isThemeSwitcherE === void 0 ? false : _ref$isThemeSwitcherE,
    _ref$isOrganizationSw = _ref.isOrganizationSwitcherEnabled,
    isOrganizationSwitcherEnabled = _ref$isOrganizationSw === void 0 ? false : _ref$isOrganizationSw,
    customContent = _ref.customContent,
    _ref$profilePopoverPr = _ref.profilePopoverProps,
    profilePopoverProps = _ref$profilePopoverPr === void 0 ? {} : _ref$profilePopoverPr,
    _ref$isConsumer = _ref.isConsumer,
    isConsumer = _ref$isConsumer === void 0 ? false : _ref$isConsumer,
    _ref$enableSubscripti = _ref.enableSubscriptionUpgradeRequest,
    enableSubscriptionUpgradeRequest = _ref$enableSubscripti === void 0 ? true : _ref$enableSubscripti,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  useEffect(function () {
    isThemeSwitcherEnabled && setAppTheme();
  }, [isThemeSwitcherEnabled]);
  var isBigBinaryEmail = globalProps$1 === null || globalProps$1 === void 0 || (_globalProps$user = globalProps$1.user) === null || _globalProps$user === void 0 || (_globalProps$user = _globalProps$user.email) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.endsWith("@bigbinary.com");
  return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
    ref: ref,
    className: "fixed start-0 bottom-4 z-[99999] rounded-e-[1.0625rem] border border-s-0 border-white bg-white",
    "data-testid": "floating-action-menu-container"
  }, otherProps), {}, {
    children: /*#__PURE__*/jsx(ProfileButton, _defineProperty({
      bottomLinks: bottomLinks,
      customContent: customContent,
      enableSubscriptionUpgradeRequest: enableSubscriptionUpgradeRequest,
      isConsumer: isConsumer,
      isOrganizationSwitcherEnabled: isOrganizationSwitcherEnabled,
      isThemeSwitcherEnabled: isThemeSwitcherEnabled,
      profileInfoOverrides: profileInfoOverrides,
      profilePopoverProps: profilePopoverProps,
      showProductSwitcher: showProductSwitcher,
      topLinks: topLinks
    }, "isOrganizationSwitcherEnabled", isBigBinaryEmail || isOrganizationSwitcherEnabled))
  }));
});
FloatingActionMenu.displayName = "FloatingActionMenu";

export { FloatingActionMenu as default };
//# sourceMappingURL=FloatingActionMenu.js.map
