'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var neetoAtoms = require('@bigbinary/neeto-atoms');
var primitives = require('@bigbinary/neeto-atoms/primitives');
var neetoCist = require('@bigbinary/neeto-cist');
var useHotkeys = require('@bigbinary/neeto-hotkeys');
var v2 = require('@bigbinary/neeto-team-members-frontend/v2');
var ramda = require('ramda');
var v2_KeyboardShortcuts = require('./KeyboardShortcuts.js');
var SubscriptionUpgradeRequestModal = require('../SubscriptionUpgradeRequestModal.js');
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
var classnames = require('classnames');
var reactI18next = require('react-i18next');
var Neeto = require('@bigbinary/neeto-icons/typeface-logos/Neeto');
var AppIcons = require('@bigbinary/neeto-icons/typeface-logos');
var jsxRuntime = require('react/jsx-runtime');
var reactQuery = require('@tanstack/react-query');
var axios = require('axios');
var search = require('../search-BBuFYdmG.js');
var useBreakpoints = require('@bigbinary/neeto-commons-frontend/react-utils/useBreakpoints');
var i18next = require('i18next');
var createLucideIcon = require('../createLucideIcon-DBDhE7kE.js');
var circleQuestionMark = require('../circle-question-mark-kxBMPyWQ.js');
var chevronRight = require('../chevron-right-DpleLIQp.js');
var user = require('../user-Ku5LVfLy.js');
var useLocalStorage = require('@bigbinary/neeto-commons-frontend/react-utils/useLocalStorage');
var utils = require('@bigbinary/neeto-commons-frontend/utils');
var axios$1 = require('@bigbinary/neeto-commons-frontend/utils/axios');
var general = require('@bigbinary/neeto-commons-frontend/utils/general');
var v2_CopyToClipboardButton = require('./CopyToClipboardButton.js');
require('../useKeyboardShortcutsPaneState-BG_xVteC.js');
require('zustand/shallow');
require('@bigbinary/neeto-commons-frontend/react-utils/withImmutableActions');
require('zustand');
require('@bigbinary/neetoui/managers');
require('../ua-parser-DgQ3nYoO.js');
require('../x-B38UX0_0.js');
require('@bigbinary/neetoui/Button');
require('@bigbinary/neetoui/Modal');
require('@bigbinary/neetoui/Typography');

function _interopNamespaceDefault(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 AppIcons__namespace = /*#__PURE__*/_interopNamespaceDefault(AppIcons);

/**
 * @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.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.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.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.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.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.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.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.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.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.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$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 ProductLink$1 = 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__namespace["Neeto".concat(specialCase)] : AppIcons__namespace[appName];
  return /*#__PURE__*/jsxRuntime.jsxs("a", _objectSpread$7(_objectSpread$7({
    "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 max-md:gap-2 max-md:p-2", {
      "border-primary bg-primary/5": (_globalProps = globalProps) === null || _globalProps === void 0 || (_globalProps = _globalProps.appName) === null || _globalProps === void 0 ? void 0 : _globalProps.includes(name),
      "nv-product-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__*/jsxRuntime.jsx("div", {
      className: "shrink-0 grow [&>svg]:h-9 [&>svg]:w-auto max-md:[&>svg]:h-6",
      children: AppIcon ? /*#__PURE__*/jsxRuntime.jsx(AppIcon, {}) : /*#__PURE__*/jsxRuntime.jsx(Neeto, {
        className: "h-6 w-auto max-md:h-5"
      })
    }), /*#__PURE__*/jsxRuntime.jsx("div", {
      className: "shrink-0",
      children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
        color: "muted",
        variant: "caption",
        children: description
      })
    })]
  }));
};
var ProductLink = /*#__PURE__*/React.memo(ProductLink$1);

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 Content = function Content(_ref) {
  var highlightedIndex = _ref.highlightedIndex,
    filteredApps = _ref.filteredApps,
    isLoading = _ref.isLoading;
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  if (isLoading) {
    return /*#__PURE__*/jsxRuntime.jsx("div", {
      className: "flex h-full items-center justify-center",
      children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Spinner, {
        "data-testid": "neeto-ui-spinner"
      })
    });
  }
  return (filteredApps === null || filteredApps === void 0 ? void 0 : filteredApps.length) > 0 ? /*#__PURE__*/jsxRuntime.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__*/jsxRuntime.jsx(ProductLink, _objectSpread$6(_objectSpread$6({}, app), {}, {
        "data-highlighted-index": index,
        isHighlighted: index === highlightedIndex
      }), app.name);
    })
  }) : /*#__PURE__*/jsxRuntime.jsx("div", {
    className: "flex h-full items-center justify-center",
    "data-testid": "no-apps-found-title",
    children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
      color: "muted",
      variant: "body2",
      children: t("neetoMolecules.productSwitcher.noApps")
    })
  });
};

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

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 useFetchNeetoApps = function useFetchNeetoApps(options) {
  return reactQuery.useQuery(_objectSpread$5({
    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 = React.useState(0),
    _useState2 = _slicedToArray(_useState, 2),
    highlightedIndex = _useState2[0],
    setHighlightedIndex = _useState2[1];
  var scrollContainerRef = React.useRef(null);
  React.useEffect(function () {
    return setHighlightedIndex(0);
  }, [filteredApps]);
  React.useEffect(function () {
    if (!scrollContainerRef.current || ramda.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 (neetoCist.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 = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var _useState = React.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 = React.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__*/jsxRuntime.jsxs("div", {
    className: "flex h-full w-full max-w-full flex-col items-start p-6 transition-all max-md:p-1",
    "data-testid": "switcher-wrapper",
    children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
      "data-testid": "product-switcher-body-wrapper",
      className: classnames("mb-6 flex w-full shrink-0 items-center justify-between gap-8 pt-1 max-md:flex-col max-md:items-start max-md:gap-3", {
        "max-md:mb-4": isMobile
      }),
      children: [!isMobile && /*#__PURE__*/jsxRuntime.jsx("h1", {
        className: "text-2xl font-bold max-sm:text-xl",
        children: t("neetoMolecules.productSwitcher.chooseNeetoProduct")
      }), /*#__PURE__*/jsxRuntime.jsx("div", {
        className: "flex-grow lg:w-[296px] lg:flex-grow-0",
        children: /*#__PURE__*/jsxRuntime.jsxs("div", {
          className: "relative",
          children: [/*#__PURE__*/jsxRuntime.jsx(search.Search, {
            className: "text-muted-foreground absolute start-3 top-1/2 size-4 -translate-y-1/2"
          }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.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__*/jsxRuntime.jsx("div", {
      className: "flex min-h-0 w-full flex-1 flex-col gap-3 overflow-y-auto text-sm",
      ref: scrollContainerRef,
      children: /*#__PURE__*/jsxRuntime.jsx(Content, {
        filteredApps: filteredApps,
        highlightedIndex: highlightedIndex,
        isLoading: isLoading
      })
    })]
  }, "switcher-wrapper");
};

var Modal = reactUtils.withT(function (_ref) {
  var t = _ref.t,
    isOpen = _ref.isOpen,
    onClose = _ref.onClose;
  return /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Dialog, {
    isOpen: isOpen,
    onClose: onClose,
    "aria-describedby": undefined,
    className: "grid-rows-[1fr] sm:max-w-4xl",
    size: "fullScreen",
    children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Title, {
      className: "sr-only",
      children: t("neetoMolecules.productSwitcher.title")
    }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Dialog.Body, {
      className: "min-h-0 overflow-y-auto",
      children: /*#__PURE__*/jsxRuntime.jsx("div", {
        "data-testid": "product-switcher-modal",
        children: /*#__PURE__*/jsxRuntime.jsx(Menu, {})
      })
    })]
  });
});

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: i18next.t("neetoMolecules.sidebar.helpLinks.whatsNew"),
    "data-testid": "help-link-engage-button"
  },
  keyboardShortcutProps: {
    label: i18next.t("neetoMolecules.sidebar.helpLinks.keyboardShortcuts"),
    "data-testid": "help-link-keyboard-shortcut-button"
  }
};

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

// Legacy neetoUI theme classes — kept until full migration is complete.
var LEGACY_THEMES = {
  LIGHT: "neeto-ui-theme--light",
  DARK: "neeto-ui-theme--dark"
};
var NEETO_AUTH_BILLING_INFO_URL = "/neeto_sso/api/v1/subscription/billing";
var MENU_ITEM_CLASSES = "gap-2.5 px-2.5 py-2 font-medium [&>[data-slot=menu-item-prefix]>svg]:!size-[18px] [&>[data-slot=menu-item-suffix]>svg]:!size-[18px]";
var THEME_BUTTON_BASE = "relative z-10 flex items-center justify-center gap-1 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none";
var THEME_ICON_BASE = "transition-transform duration-300 ease-out";

var _excluded$2 = ["className"];
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 MenuItem = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
  var className = _ref.className,
    props = _objectWithoutProperties(_ref, _excluded$2);
  return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.DropdownMenu.MenuItem, _objectSpread$4({
    className: classnames(MENU_ITEM_CLASSES, className),
    ref: forwardedRef
  }, props));
});
MenuItem.displayName = "FloatingActionMenu.MenuItem";

var HelpItems = reactUtils.withT(function (_ref) {
  var _globalProps;
  var t = _ref.t;
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [/*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "help-link-help-articles-button",
      href: "https://help.".concat(ramda.toLower(((_globalProps = globalProps) === null || _globalProps === void 0 ? void 0 : _globalProps.appName) || ""), ".com/"),
      prefix: /*#__PURE__*/jsxRuntime.jsx(BookOpen, {
        size: 18
      }),
      rel: "noreferrer",
      target: "_blank",
      children: t("neetoMolecules.sidebar.helpLinks.helpArticles")
    }), /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "help-link-live-chat-button",
      prefix: /*#__PURE__*/jsxRuntime.jsx(MessageCircleQuestionMark, {
        size: 18
      }),
      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: t("neetoMolecules.sidebar.helpLinks.liveChat")
    }), /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "help-link-community-button",
      href: "https://www.launchpass.com/neetohq",
      prefix: /*#__PURE__*/jsxRuntime.jsx(Users, {
        size: 18
      }),
      rel: "noreferrer",
      target: "_blank",
      children: t("neetoMolecules.sidebar.helpLinks.askTheCommunity")
    }), /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "help-link-status-button",
      href: "https://neetostatus.com/",
      prefix: /*#__PURE__*/jsxRuntime.jsx(Activity, {
        size: 18
      }),
      rel: "noreferrer",
      target: "_blank",
      children: t("neetoMolecules.sidebar.helpLinks.systemStatus")
    })]
  });
});

var MobileHelpMenu = function MobileHelpMenu() {
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.Collapsible, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleTrigger, {
      asChild: true,
      children: /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuItem, {
        className: classnames("group", MENU_ITEM_CLASSES),
        "data-testid": "help-menu-button",
        onSelect: function onSelect(e) {
          return e.preventDefault();
        },
        children: [/*#__PURE__*/jsxRuntime.jsx(circleQuestionMark.CircleQuestionMark, {
          className: "size-[18px] shrink-0"
        }), /*#__PURE__*/jsxRuntime.jsx("span", {
          className: "flex-1 truncate",
          children: t("neetoMolecules.sidebar.help")
        }), /*#__PURE__*/jsxRuntime.jsx(chevronRight.ChevronRight, {
          className: "ms-auto shrink-0 transition-transform group-data-[state=open]:rotate-90 rtl:scale-x-[-1]",
          size: 18
        })]
      })
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleContent, {
      className: "flex flex-col gap-0.5 ps-6 pt-1",
      children: /*#__PURE__*/jsxRuntime.jsx(HelpItems, {})
    })]
  });
};

var HelpMenu = function HelpMenu() {
  var _useBreakpoints = useBreakpoints(),
    isSize = _useBreakpoints.isSize;
  var isMobile = isSize("mobile");
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  if (isMobile) return /*#__PURE__*/jsxRuntime.jsx(MobileHelpMenu, {});
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuSub, {
    children: [/*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuSubTrigger, {
      className: MENU_ITEM_CLASSES,
      "data-testid": "help-menu-button",
      children: [/*#__PURE__*/jsxRuntime.jsx(circleQuestionMark.CircleQuestionMark, {
        className: "size-[18px]"
      }), /*#__PURE__*/jsxRuntime.jsx("span", {
        className: "flex-1",
        children: t("neetoMolecules.sidebar.help")
      })]
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubContent, {
      className: "z-[99999]",
      collisionPadding: 16,
      sideOffset: 8,
      children: /*#__PURE__*/jsxRuntime.jsx(HelpItems, {})
    })]
  });
};

var _excluded$1 = ["label", "icon", "changesCount", "href"];
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 LinkSection = function LinkSection(_ref) {
  var links = _ref.links;
  if (neetoCist.isNotPresent(links)) return null;
  return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
    children: links.map(function (_ref2, idx) {
      var label = _ref2.label,
        Icon = _ref2.icon,
        changesCount = _ref2.changesCount,
        href = _ref2.href,
        otherProps = _objectWithoutProperties(_ref2, _excluded$1);
      return /*#__PURE__*/jsxRuntime.jsx(MenuItem, _objectSpread$3(_objectSpread$3(_objectSpread$3({
        "data-testid": "floating-action-menu-link-section",
        prefix: Icon && /*#__PURE__*/jsxRuntime.jsx(Icon, {
          size: 18
        }),
        suffix: neetoCist.isPresent(changesCount) && /*#__PURE__*/jsxRuntime.jsx("span", {
          className: "bg-foreground text-background flex h-[1.125rem] min-w-[1.125rem] items-center justify-center rounded-full px-1 text-[10px] select-none [--accent-foreground:var(--background)]",
          "data-testid": "help-section-menu-changes-count",
          children: changesCount
        })
      }, href ? {
        href: href
      } : {}), otherProps), {}, {
        children: label
      }), 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 reactQuery.useQuery({
    queryKey: [LOGGED_IN_ORGANIZATIONS_LIST, email],
    queryFn: function queryFn() {
      return loggedInOrganizationsApi.fetch(email);
    }
  });
};

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;
  }
};

var OrganizationItems = reactUtils.withT(function (_ref) {
  var t = _ref.t,
    organizations = _ref.organizations,
    authAppUrl = _ref.authAppUrl;
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [organizations === null || organizations === void 0 ? void 0 : organizations.map(function (organization) {
      var isCurrent = isCurrentSubdomain(organization.organizationUrl);
      return /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
        className: classnames({
          "text-green-600": isCurrent
        }),
        href: organization.organizationUrl,
        rel: "noreferrer",
        target: "_blank",
        suffix: isCurrent && /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Badge, {
          variant: "default",
          children: [/*#__PURE__*/jsxRuntime.jsx(CircleCheck, {
            size: 12
          }), t("neetoMolecules.sidebar.organizationSwitcher.signedin")]
        }),
        children: organization.orgName
      }, organization.userId);
    }), /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      href: authAppUrl,
      rel: "noreferrer",
      target: "_blank",
      children: t("neetoMolecules.sidebar.organizationSwitcher.addAccount")
    })]
  });
});

var MobileOrganizationSwitcher = function MobileOrganizationSwitcher(_ref) {
  var organizations = _ref.organizations,
    authAppUrl = _ref.authAppUrl;
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.Collapsible, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleTrigger, {
      asChild: true,
      children: /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuItem, {
        className: classnames("group", MENU_ITEM_CLASSES),
        "data-testid": "organization-switcher-button",
        onSelect: function onSelect(e) {
          return e.preventDefault();
        },
        children: [/*#__PURE__*/jsxRuntime.jsx("span", {
          className: "flex-1 truncate",
          children: t("neetoMolecules.sidebar.organizationSwitcher.label")
        }), /*#__PURE__*/jsxRuntime.jsx(chevronRight.ChevronRight, {
          className: "ms-auto shrink-0 transition-transform group-data-[state=open]:rotate-90 rtl:scale-x-[-1]",
          size: 18
        })]
      })
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleContent, {
      className: "flex flex-col gap-0.5 ps-6 pt-1",
      children: /*#__PURE__*/jsxRuntime.jsx(OrganizationItems, {
        authAppUrl: authAppUrl,
        organizations: organizations
      })
    })]
  });
};

var OrganizationSwitcher = function OrganizationSwitcher() {
  var _globalProps$user;
  var _useBreakpoints = useBreakpoints(),
    isSize = _useBreakpoints.isSize;
  var isMobile = isSize("mobile");
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  var _useFetchLoggedInOrga = useFetchLoggedInOrganizations(initializers.globalProps === null || initializers.globalProps === void 0 || (_globalProps$user = initializers.globalProps.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;
  if (isMobile) {
    return /*#__PURE__*/jsxRuntime.jsx(MobileOrganizationSwitcher, {
      authAppUrl: authAppUrl,
      organizations: organizations
    });
  }
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuSub, {
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubTrigger, {
      className: MENU_ITEM_CLASSES,
      "data-testid": "organization-switcher-button",
      children: /*#__PURE__*/jsxRuntime.jsx("span", {
        className: "flex-1",
        children: t("neetoMolecules.sidebar.organizationSwitcher.label")
      })
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubContent, {
      className: "z-[99999]",
      collisionPadding: 16,
      sideOffset: 8,
      children: /*#__PURE__*/jsxRuntime.jsx(OrganizationItems, {
        authAppUrl: authAppUrl,
        organizations: organizations
      })
    })]
  });
};

var Dropdown = reactUtils.withT(function (_ref) {
  var t = _ref.t;
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuSub, {
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubTrigger, {
      className: MENU_ITEM_CLASSES,
      "data-testid": "product-switcher-button",
      children: t("neetoMolecules.sidebar.productSwitcher")
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubContent, {
      className: "z-[99999] flex h-[max(36rem,min(80vh,48rem))] w-[calc(100vw-25rem)] max-w-7xl flex-col overflow-hidden rounded-xl p-0",
      collisionPadding: 16,
      sideOffset: 8,
      children: /*#__PURE__*/jsxRuntime.jsx(Menu, {})
    })]
  });
});

var ProductSwitcher = function ProductSwitcher(_ref) {
  var toggleModal = _ref.toggleModal;
  var _useBreakpoints = useBreakpoints(),
    isSize = _useBreakpoints.isSize;
  var isMobile = isSize("mobile");
  var _useTranslation = reactI18next.useTranslation(),
    t = _useTranslation.t;
  if (isMobile) {
    return /*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "product-switcher-button",
      suffix: /*#__PURE__*/jsxRuntime.jsx(chevronRight.ChevronRight, {
        className: "rtl:scale-x-[-1]",
        size: 18
      }),
      onClick: function onClick() {
        return toggleModal(true);
      },
      children: t("neetoMolecules.sidebar.productSwitcher")
    });
  }
  return /*#__PURE__*/jsxRuntime.jsx(Dropdown, {});
};

var ProfileItems = reactUtils.withT(function (_ref) {
  var _window$globalProps;
  var t = _ref.t,
    onProfileClick = _ref.onProfileClick;
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [/*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "profile-my-profile-button",
      prefix: /*#__PURE__*/jsxRuntime.jsx(user.User, {
        size: 18
      }),
      onClick: onProfileClick,
      children: 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__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "profile-cancel-account-button",
      href: DELETE_WORKSPACE_URL,
      prefix: /*#__PURE__*/jsxRuntime.jsx(CircleX, {
        size: 18
      }),
      rel: "noreferrer",
      target: "_blank",
      children: t("neetoMolecules.sidebar.cancelAccount")
    })]
  });
});

var ProfileHeader = function ProfileHeader(_ref) {
  var profileInfo = _ref.profileInfo;
  var name = profileInfo.name,
    email = profileInfo.email,
    imageUrl = profileInfo.imageUrl;
  return /*#__PURE__*/jsxRuntime.jsxs("span", {
    className: "flex w-full min-w-0 items-center gap-2 text-start",
    "data-testid": "floating-action-menu-profile-header",
    children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Avatar, {
      className: "size-8 shrink-0",
      "data-testid": "floating-action-menu-header-profile-icon",
      user: {
        name: name,
        imageUrl: imageUrl
      }
    }), /*#__PURE__*/jsxRuntime.jsxs("span", {
      className: "flex min-w-0 flex-grow flex-col gap-1",
      children: [/*#__PURE__*/jsxRuntime.jsx("span", {
        className: "text-sm leading-tight font-semibold",
        "data-testid": "floating-action-menu-header-user-name",
        title: name,
        children: neetoCist.truncate(name, 18)
      }), email && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
        asChild: true,
        className: "w-full truncate leading-tight",
        color: "muted",
        variant: "caption",
        children: /*#__PURE__*/jsxRuntime.jsx("span", {
          "data-testid": "floating-action-menu-header-user-email",
          children: email
        })
      })]
    })]
  });
};

var MobileProfileExpandMenu = function MobileProfileExpandMenu(_ref) {
  var profileInfo = _ref.profileInfo,
    onProfileClick = _ref.onProfileClick;
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.Collapsible, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleTrigger, {
      asChild: true,
      children: /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuItem, {
        className: classnames("group", MENU_ITEM_CLASSES),
        "data-testid": "profile-expand-menu-button",
        onSelect: function onSelect(e) {
          return e.preventDefault();
        },
        children: [/*#__PURE__*/jsxRuntime.jsx(ProfileHeader, {
          profileInfo: profileInfo
        }), /*#__PURE__*/jsxRuntime.jsx(chevronRight.ChevronRight, {
          className: "ms-auto shrink-0 transition-transform group-data-[state=open]:rotate-90 rtl:scale-x-[-1]",
          size: 18
        })]
      })
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleContent, {
      className: "flex flex-col gap-0.5 ps-6 pt-1",
      children: /*#__PURE__*/jsxRuntime.jsx(ProfileItems, {
        onProfileClick: onProfileClick
      })
    })]
  });
};

var ProfileExpandMenu = function ProfileExpandMenu(_ref) {
  var profileInfo = _ref.profileInfo;
  var _Profile$usePaneState = v2.Profile.usePaneState(),
    _Profile$usePaneState2 = _slicedToArray(_Profile$usePaneState, 2),
    setIsProfilePaneOpen = _Profile$usePaneState2[1];
  var _useBreakpoints = useBreakpoints(),
    isSize = _useBreakpoints.isSize;
  var isMobile = isSize("mobile");
  var onProfileClick = function onProfileClick() {
    return setIsProfilePaneOpen(true);
  };
  if (isMobile) {
    return /*#__PURE__*/jsxRuntime.jsx(MobileProfileExpandMenu, {
      onProfileClick: onProfileClick,
      profileInfo: profileInfo
    });
  }
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuSub, {
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubTrigger, {
      className: classnames("group items-center", MENU_ITEM_CLASSES),
      "data-testid": "profile-expand-menu-button",
      children: /*#__PURE__*/jsxRuntime.jsx(ProfileHeader, {
        profileInfo: profileInfo
      })
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubContent, {
      className: "z-[99999]",
      collisionPadding: 16,
      sideOffset: 8,
      children: /*#__PURE__*/jsxRuntime.jsx(ProfileItems, {
        onProfileClick: onProfileClick
      })
    })]
  });
};

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: i18next.t("neetoMolecules.sidebar.logout"),
    icon: LogOut,
    onClick: function onClick() {
      axios$1.resetAuthTokens();
      general.removeFromLocalStorage(getSidebarStateLocalStorageKey());
      isConsumer ? window.location.href = "/consumers/logout?redirect_uri=".concat(window.location.href) : window.location.href = "/logout";
    },
    "data-testid": "profile-logout-button"
  } : {
    label: i18next.t("neetoMolecules.sidebar.login"),
    onClick: function onClick() {
      window.location.href = "/login";
    },
    "data-testid": "profile-login-button"
  }];
};
var getProfileInfo = function getProfileInfo(profileInfoOverrides, isConsumer) {
  return ramda.mergeDeepLeft(profileInfoOverrides, isConsumer ? getConsumerProfileInfo() : getUserProfileInfo());
};

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

var ThemeSwitcher = function ThemeSwitcher() {
  var _useTranslation = reactI18next.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 || appTheme === LEGACY_THEMES.DARK;
  var switchTheme = function switchTheme(theme) {
    theme === THEMES.LIGHT ? setLightTheme() : setDarkTheme();
    setAppTheme(theme);
  };
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
    className: "bg-muted/40 flex items-center justify-between gap-3 rounded-b-xl px-4 py-3",
    children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
      color: "muted",
      variant: "caption",
      weight: "medium",
      children: t("neetoMolecules.sidebar.themeSwitcher.label")
    }), /*#__PURE__*/jsxRuntime.jsxs("div", {
      "aria-label": t("neetoMolecules.sidebar.themeSwitcher.label"),
      className: "bg-muted relative grid grid-cols-2 rounded-lg p-0.5",
      "data-testid": "theme-switcher-button",
      role: "group",
      children: [/*#__PURE__*/jsxRuntime.jsx("span", {
        "aria-hidden": true,
        className: "bg-background ring-border absolute inset-y-0.5 left-0.5 w-[calc(50%-2px)] rounded-md shadow-md ring-1 transition-transform duration-300 ease-out ring-inset",
        style: {
          transform: "translateX(".concat(isDarkThemeSelected ? "100%" : "0", ")")
        }
      }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuItem, {
        asChild: true,
        onSelect: function onSelect(e) {
          e.preventDefault();
          switchTheme(THEMES.LIGHT);
        },
        children: /*#__PURE__*/jsxRuntime.jsxs("button", {
          "aria-checked": !isDarkThemeSelected,
          "data-testid": "theme-switcher-light-button",
          role: "menuitemradio",
          type: "button",
          className: classnames(THEME_BUTTON_BASE, isDarkThemeSelected ? "text-muted-foreground hover:text-foreground" : "text-foreground"),
          children: [/*#__PURE__*/jsxRuntime.jsx(Sun, {
            size: 13,
            className: classnames(THEME_ICON_BASE, isDarkThemeSelected ? "scale-90 -rotate-45" : "rotate-0")
          }), t("neetoMolecules.sidebar.themeSwitcher.light")]
        })
      }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuItem, {
        asChild: true,
        onSelect: function onSelect(e) {
          e.preventDefault();
          switchTheme(THEMES.DARK);
        },
        children: /*#__PURE__*/jsxRuntime.jsxs("button", {
          "aria-checked": isDarkThemeSelected,
          "data-testid": "theme-switcher-dark-button",
          role: "menuitemradio",
          type: "button",
          className: classnames(THEME_BUTTON_BASE, isDarkThemeSelected ? "text-foreground" : "text-muted-foreground hover:text-foreground"),
          children: [/*#__PURE__*/jsxRuntime.jsx(Moon, {
            size: 13,
            className: classnames(THEME_ICON_BASE, isDarkThemeSelected ? "rotate-0" : "scale-90 rotate-45")
          }), t("neetoMolecules.sidebar.themeSwitcher.dark")]
        })
      })]
    })]
  });
};

var TriggerContent = reactUtils.withT(function (_ref) {
  var _globalProps$organiza;
  var t = _ref.t;
  return /*#__PURE__*/jsxRuntime.jsxs("span", {
    className: "flex flex-grow flex-col gap-1.5",
    children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
      asChild: true,
      variant: "body3",
      weight: "medium",
      children: /*#__PURE__*/jsxRuntime.jsx("span", {
        children: t("neetoMolecules.sidebar.workspace")
      })
    }), ((_globalProps$organiza = initializers.globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.name) && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
      asChild: true,
      color: "muted",
      variant: "caption",
      children: /*#__PURE__*/jsxRuntime.jsx("span", {
        children: initializers.globalProps.organization.name
      })
    })]
  });
});

var WorkspaceItems = reactUtils.withT(function (_ref) {
  var _globalProps$organiza;
  var t = _ref.t;
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [/*#__PURE__*/jsxRuntime.jsx(MenuItem, {
      "data-testid": "profile-organization-settings-button",
      href: MY_ORGANIZATION_URL,
      rel: "noreferrer",
      target: "_blank",
      children: t("neetoMolecules.sidebar.workspaceMenu.settings")
    }), ((_globalProps$organiza = initializers.globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain) && /*#__PURE__*/jsxRuntime.jsx("div", {
      className: "px-2.5 py-2",
      children: /*#__PURE__*/jsxRuntime.jsxs("span", {
        className: "flex flex-col gap-0.5 text-start",
        children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
          asChild: true,
          variant: "body3",
          weight: "medium",
          children: /*#__PURE__*/jsxRuntime.jsx("span", {
            children: t("neetoMolecules.sidebar.workspaceMenu.subdomain")
          })
        }), /*#__PURE__*/jsxRuntime.jsxs("span", {
          className: "flex items-center gap-1",
          children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
            asChild: true,
            color: "muted",
            variant: "caption",
            children: /*#__PURE__*/jsxRuntime.jsx("span", {
              className: "min-w-0 truncate",
              children: initializers.globalProps.organization.subdomain
            })
          }), /*#__PURE__*/jsxRuntime.jsx(v2_CopyToClipboardButton, {
            className: "flex-shrink-0",
            value: initializers.globalProps.organization.subdomain,
            variant: "ghost"
          })]
        })]
      })
    })]
  });
});

var MobileWorkspaceMenu = function MobileWorkspaceMenu() {
  var _useState = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    open = _useState2[0],
    setOpen = _useState2[1];
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.Collapsible, {
    open: open,
    onOpenChange: setOpen,
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleTrigger, {
      asChild: true,
      children: /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuItem, {
        className: classnames("group items-center", MENU_ITEM_CLASSES),
        "data-testid": "workspace-display",
        onSelect: function onSelect(e) {
          return e.preventDefault();
        },
        children: [/*#__PURE__*/jsxRuntime.jsx(TriggerContent, {}), /*#__PURE__*/jsxRuntime.jsx(chevronRight.ChevronRight, {
          className: "ms-auto shrink-0 transition-transform group-data-[state=open]:rotate-90 rtl:scale-x-[-1]",
          size: 18
        })]
      })
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.CollapsibleContent, {
      className: "flex flex-col gap-0.5 ps-6 pt-1",
      children: /*#__PURE__*/jsxRuntime.jsx(WorkspaceItems, {})
    })]
  });
};

var WorkspaceMenu = function WorkspaceMenu() {
  var _useBreakpoints = useBreakpoints(),
    isSize = _useBreakpoints.isSize;
  var isMobile = isSize("mobile");
  if (isMobile) return /*#__PURE__*/jsxRuntime.jsx(MobileWorkspaceMenu, {});
  return /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenuSub, {
    children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubTrigger, {
      className: classnames("group items-center", MENU_ITEM_CLASSES),
      "data-testid": "workspace-display",
      children: /*#__PURE__*/jsxRuntime.jsx(TriggerContent, {})
    }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSubContent, {
      className: "z-[99999]",
      collisionPadding: 16,
      sideOffset: 8,
      children: /*#__PURE__*/jsxRuntime.jsx(WorkspaceItems, {})
    })]
  });
};

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 = reactI18next.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 isProPlan = normalizedPlan === "pro";
  var subscriptionPlanLink = _objectSpread$2({
    label: /*#__PURE__*/jsxRuntime.jsxs("span", {
      className: "flex items-center gap-2",
      children: [globalProps.appName, isProPlan ? /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Badge, {
        label: neetoCist.humanize((_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.subscriptionPlan),
        style: {
          "--accent-foreground": "var(--color-amber-950)"
        },
        variant: "amber"
      }) : /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Badge, {
        icon: /*#__PURE__*/jsxRuntime.jsx(Crown, {
          className: "size-3"
        }),
        label: t("neetoMolecules.sidebar.upgradePlan"),
        style: {
          "--accent-foreground": "var(--primary-foreground)"
        }
      })]
    }),
    "data-testid": "subscription-plan"
  }, getSubscriptionPlanAction());
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
    className: "p-1.5",
    children: [!isConsumer && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
      children: [/*#__PURE__*/jsxRuntime.jsx(LinkSection, {
        links: defaultLinks
      }), neetoCist.isNotEmpty(topLinks) && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
        children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSeparator, {
          className: "my-2"
        }), /*#__PURE__*/jsxRuntime.jsx(LinkSection, {
          links: topLinks
        })]
      }), neetoCist.isPresent(customContent) && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
        children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSeparator, {
          className: "my-2"
        }), /*#__PURE__*/jsxRuntime.jsx("div", {
          className: "px-3 py-1",
          children: customContent
        })]
      }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSeparator, {
        className: "my-2"
      }), ((_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.isOwner) && /*#__PURE__*/jsxRuntime.jsx(WorkspaceMenu, {}), isOrganizationSwitcherEnabled && /*#__PURE__*/jsxRuntime.jsx(OrganizationSwitcher, {}), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSeparator, {
        className: "my-2"
      }), neetoCist.isPresent((_globalProps$user5 = globalProps.user) === null || _globalProps$user5 === void 0 ? void 0 : _globalProps$user5.subscriptionPlan) && /*#__PURE__*/jsxRuntime.jsx(LinkSection, {
        links: [subscriptionPlanLink]
      }), showProductSwitcher && /*#__PURE__*/jsxRuntime.jsx(ProductSwitcher, {
        toggleModal: toggleModal
      }), /*#__PURE__*/jsxRuntime.jsx(HelpMenu, {}), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSeparator, {
        className: "my-2"
      })]
    }), isAuthenticated && !isConsumer && /*#__PURE__*/jsxRuntime.jsx(ProfileExpandMenu, {
      profileInfo: profileInfo
    }), /*#__PURE__*/jsxRuntime.jsx(LinkSection, {
      links: bottomLinks
    }), isThemeSwitcherEnabled && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
      children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuSeparator, {
        className: "my-2"
      }), /*#__PURE__*/jsxRuntime.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 ProfileButton = function ProfileButton(_ref) {
  var _globalProps$user;
  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 = React.useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isModalOpen = _useState2[0],
    setIsModalOpen = _useState2[1];
  var _useState3 = React.useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    isUpgradeModalOpen = _useState4[0],
    setIsUpgradeModalOpen = _useState4[1];
  var _useState5 = React.useState(false),
    _useState6 = _slicedToArray(_useState5, 2),
    isMenuOpen = _useState6[0],
    setIsMenuOpen = _useState6[1];
  var _useState7 = React.useState(null),
    _useState8 = _slicedToArray(_useState7, 2),
    changesCount = _useState8[0],
    setChangesCount = _useState8[1];
  var _KeyboardShortcuts$us = v2_KeyboardShortcuts.usePaneState(),
    _KeyboardShortcuts$us2 = _slicedToArray(_KeyboardShortcuts$us, 2),
    setIsOpen = _KeyboardShortcuts$us2[1];
  useHotkeys(["ctrl+u", "command+u"], function () {
    return setIsModalOpen(ramda.not);
  }, {
    mode: "global"
  });
  var profileInfo = getProfileInfo(profileInfoOverrides, isConsumer);
  React.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;
  }, []);
  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__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
    children: [/*#__PURE__*/jsxRuntime.jsx(v2.Profile.Pane, {
      popoverProps: profilePopoverProps
    }), isMenuOpen && /*#__PURE__*/jsxRuntime.jsx("div", {
      className: "pointer-events-none fixed inset-0 z-[99998] bg-black/[0.27]"
    }), /*#__PURE__*/jsxRuntime.jsxs(primitives.DropdownMenu, {
      open: isMenuOpen,
      onOpenChange: setIsMenuOpen,
      children: [/*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuTrigger, {
        asChild: true,
        children: /*#__PURE__*/jsxRuntime.jsxs("button", {
          className: "bg-primary flex flex-col items-center justify-center gap-1.5 rounded-e-2xl p-1",
          type: "button",
          children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Avatar, {
            className: "border-background size-[1.625rem] shrink-0 rounded-full border-2",
            "data-testid": "profile-avatar",
            user: {
              name: profileInfo.name,
              imageUrl: profileInfo.imageUrl
            }
          }), /*#__PURE__*/jsxRuntime.jsx("span", {
            className: "bg-background text-foreground flex size-[1.625rem] items-center justify-center rounded-full",
            children: /*#__PURE__*/jsxRuntime.jsx(circleQuestionMark.CircleQuestionMark, {
              size: 20
            })
          })]
        })
      }), /*#__PURE__*/jsxRuntime.jsx(primitives.DropdownMenuContent, {
        align: "end",
        className: "z-[99999] max-h-[var(--radix-dropdown-menu-content-available-height)] w-64 overflow-y-auto rounded-xl p-0",
        collisionPadding: 16,
        side: "right",
        sideOffset: 8,
        onCloseAutoFocus: function onCloseAutoFocus(e) {
          return e.preventDefault();
        },
        children: /*#__PURE__*/jsxRuntime.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
        })
      })]
    }), neetoCist.isPresent(changesCount) && /*#__PURE__*/jsxRuntime.jsx("span", {
      className: "bg-foreground text-background 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] select-none",
      "data-testid": "help-icon-changes-count",
      children: changesCount
    }), /*#__PURE__*/jsxRuntime.jsx(Modal, {
      isOpen: isModalOpen,
      onClose: function onClose() {
        return setIsModalOpen(false);
      }
    }), enableSubscriptionUpgradeRequest && !((_globalProps$user = globalProps.user) !== null && _globalProps$user !== void 0 && _globalProps$user.isOwner) && /*#__PURE__*/jsxRuntime.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__*/React.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);
  React.useEffect(function () {
    isThemeSwitcherEnabled && setAppTheme();
  }, [isThemeSwitcherEnabled]);
  var isBigBinaryEmail = initializers.globalProps === null || initializers.globalProps === void 0 || (_globalProps$user = initializers.globalProps.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__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
    ref: ref,
    className: "bg-popover border-border fixed start-0 bottom-4 z-[99999] rounded-e-[1.0625rem] border border-s-0",
    "data-testid": "floating-action-menu-container"
  }, otherProps), {}, {
    children: /*#__PURE__*/jsxRuntime.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";

module.exports = FloatingActionMenu;
//# sourceMappingURL=FloatingActionMenu.js.map
