/* banner.tsx generated by @compiled/babel-plugin v0.38.1 */
import "./banner.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { useContext } from 'react';
import { fg } from '@atlaskit/platform-feature-flags';
import { useSkipLinkInternal } from '../../context/skip-links/skip-links-context';
import { useIsFhsEnabled } from '../fhs-rollout/use-is-fhs-enabled';
import { bannerMountedVar, localSlotLayers, UNSAFE_bannerVar } from './constants';
import { DangerouslyHoistSlotSizes } from './hoist-slot-sizes-context';
import { DangerouslyHoistCssVarToDocumentRoot, HoistCssVarToLocalGrid } from './hoist-utils';
import { useLayoutId } from './id-utils';
const styles = {
  root: "_nd5ldkfm _1reo15vq _18m915vq _4t3iutvi _152tidpf _kqsw1if8 _1pbyegat",
  fullHeightSidebarWithLayeringFixes: "_1pbycs5v"
};

/**
 * The banner layout area. It will always be displayed at the top of the screen.
 *
 * Should be used to render a `Banner` component from `@atlaskit/banner`.
 */
export function Banner({
  children,
  xcss,
  // 48px has been chosen to align with the height of the Banner component from `@atlaskit/banner`.
  height = 48,
  skipLinkLabel = 'Banner',
  testId,
  id: providedId
}) {
  const dangerouslyHoistSlotSizes = useContext(DangerouslyHoistSlotSizes);
  const id = useLayoutId({
    providedId
  });
  const isFhsEnabled = useIsFhsEnabled();

  /**
   * Don't show the skip link if the slot has 0 height.
   */
  useSkipLinkInternal({
    id,
    label: skipLinkLabel,
    isHidden: height === 0
  });
  return /*#__PURE__*/React.createElement("div", {
    id: id,
    "data-layout-slot": true,
    className: ax([styles.root, isFhsEnabled && fg('platform-dst-side-nav-layering-fixes') && styles.fullHeightSidebarWithLayeringFixes, xcss]),
    "data-testid": testId
  }, /*#__PURE__*/React.createElement(HoistCssVarToLocalGrid, {
    variableName: bannerMountedVar,
    value: height
  }), dangerouslyHoistSlotSizes &&
  /*#__PURE__*/
  // ------ START UNSAFE STYLES ------
  // These styles are only needed for the UNSAFE legacy use case for Jira + Confluence.
  // When they aren't needed anymore we can delete them wholesale.
  React.createElement(DangerouslyHoistCssVarToDocumentRoot, {
    variableName: UNSAFE_bannerVar,
    value: height
  })
  // ------ END UNSAFE STYLES ------
  , children);
}