"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SideNavHeader = void 0;
var _Skeleton2 = _interopRequireDefault(require("@mui/material/Skeleton"));
var _styled = _interopRequireDefault(require("@emotion/styled"));
var _react = require("react");
var _OdysseyDesignTokensContext = require("../../OdysseyDesignTokensContext.cjs");
var _Typography = require("../../Typography.cjs");
var _UiShellProvider = require("../../ui-shell/UiShellProvider.cjs");
var _uiShellSharedConstants = require("../uiShellSharedConstants.cjs");
var _SideNavLogo = require("./SideNavLogo.cjs");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/*!
 * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */

const SideNavHeaderContainer = (0, _styled.default)("div")({
  position: "relative",
  display: "flex",
  flexDirection: "column",
  zIndex: _uiShellSharedConstants.UI_SHELL_BASE_Z_INDEX
});
const SideNavLogoContainer = (0, _styled.default)("div", {
  shouldForwardProp: prop => prop !== "headerBackgroundColor" && prop !== "isSameBackgroundAsMain" && prop !== "odysseyDesignTokens"
})(({
  headerBackgroundColor,
  isSameBackgroundAsMain,
  odysseyDesignTokens
}) => ({
  display: "flex",
  alignItems: "center",
  height: _uiShellSharedConstants.TOP_NAV_HEIGHT,
  paddingBlock: odysseyDesignTokens.Spacing4,
  paddingInline: odysseyDesignTokens.Spacing5,
  backgroundColor: isSameBackgroundAsMain ? headerBackgroundColor : odysseyDesignTokens.HueNeutralWhite,
  "svg, img": {
    maxHeight: "100%",
    width: "auto",
    maxWidth: "100%"
  }
}));
const SideNavHeadingContainer = (0, _styled.default)("div", {
  shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "contrastFontColor"
})(({
  contrastFontColor,
  odysseyDesignTokens
}) => ({
  display: "flex",
  justifyContent: "space-between",
  alignItems: "center",
  paddingBlock: odysseyDesignTokens.Spacing4,
  paddingInline: odysseyDesignTokens.Spacing5,
  width: "100%",
  ["& .MuiTypography-root"]: {
    margin: 0,
    width: "100%",
    color: contrastFontColor || "inherit"
  }
}));
const SideNavHeader = ({
  appName,
  isLoading,
  logoProps
}) => {
  const odysseyDesignTokens = (0, _OdysseyDesignTokensContext.useOdysseyDesignTokens)();
  const uiShellContext = (0, _UiShellProvider.useUiShellContext)();
  return (0, _jsxRuntime.jsxs)(SideNavHeaderContainer, {
    children: [(0, _jsxRuntime.jsx)(SideNavLogoContainer, {
      "data-se": "sidenav-header-logo-container",
      headerBackgroundColor: uiShellContext?.sideNavBackgroundColor,
      isSameBackgroundAsMain: logoProps?.isSameBackgroundAsMain,
      odysseyDesignTokens: odysseyDesignTokens,
      children: isLoading ? (0, _jsxRuntime.jsx)(_Skeleton2.default, {
        height: 24,
        variant: "rounded",
        width: 67
      }) : (0, _jsxRuntime.jsx)(_SideNavLogo.SideNavLogo, {
        ...logoProps
      })
    }), appName && (0, _jsxRuntime.jsx)(SideNavHeadingContainer, {
      contrastFontColor: uiShellContext?.sideNavContrastColors?.fontColor,
      odysseyDesignTokens: odysseyDesignTokens,
      children: (0, _jsxRuntime.jsx)(_Typography.Heading5, {
        component: "h2",
        children: isLoading ? (0, _jsxRuntime.jsx)(_Skeleton2.default, {}) : appName
      })
    })]
  });
};
const MemoizedSideNavHeader = exports.SideNavHeader = (0, _react.memo)(SideNavHeader);
MemoizedSideNavHeader.displayName = "SideNavHeader";
//# sourceMappingURL=SideNavHeader.cjs.map