/* custom-logo.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CustomLogo = void 0;
require("./custom-logo.compiled.css");
var _runtime = require("@compiled/react/runtime");
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@compiled/react");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _primitives = require("@atlaskit/primitives");
var _hasCustomThemeContext = require("../themed/has-custom-theme-context");
var _logoRenderer = require("./logo-renderer");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
var anchorStyles = {
  root: "_2rkofajl _1e0c1txw _4cvr1h6o _4t3izwfg",
  customLogoBorderRadius: "_2rkofajl",
  newMargin: "_ahbq1b66",
  newInteractionStates: "_irr3166n _1di61wwy",
  newInteractionStatesCustomTheming: "_irr31rps _1di6yhlj"
};
var sharedIconOrLogoContainerStyles = {
  root: "_1reo15vq _18m915vq _bna71tcg _rtys1kw7 _1jpx1f51",
  appIconTilePaddingFlagged: "_18zr1b66"
};
var iconContainerStyles = {
  root: "_18zr1b66 _1e0c1txw _p12f1tcg _vchh1ntv _10y4glyw"
};
var logoContainerStyles = {
  root: "_18zru2gc _1e0cglyw _p12fnklw _vchh1ntv _10y41txw"
};

/**
 * __Custom logo__
 *
 * Custom logo for the top navigation.
 *
 * To provide a responsive experience, it requires both a logo and an icon component.
 * The logo component will be used for large viewports, and the icon component will be used for small viewports.
 */
var CustomLogo = exports.CustomLogo = function CustomLogo(_ref) {
  var href = _ref.href,
    logo = _ref.logo,
    icon = _ref.icon,
    onClick = _ref.onClick,
    label = _ref.label;
  var ref = (0, _react.useRef)(null);
  (0, _react.useEffect)(function () {
    var _img$parentElement, _img$parentElement2;
    if (process.env.NODE_ENV === 'production') {
      return;
    }
    if (!ref.current) {
      return;
    }
    var img = ref.current.querySelector('img');
    if (!img) {
      return;
    }

    /**
     * We want custom logo components to render the image as the immediate child
     */
    var hasExpectedStructure = ((_img$parentElement = img.parentElement) === null || _img$parentElement === void 0 ? void 0 : _img$parentElement.parentElement) === ref.current;
    /**
     * We want custom logo components to render only one image
     */
    var isOnlyChild = ((_img$parentElement2 = img.parentElement) === null || _img$parentElement2 === void 0 ? void 0 : _img$parentElement2.childElementCount) === 1;
    if (!hasExpectedStructure || !isOnlyChild) {
      // eslint-disable-next-line no-console
      console.error('Custom logos should render only a single image tag with no wrappers.');
    }
    if (img.getAttribute('width') !== null || img.getAttribute('height') !== null || img.style.width !== '' || img.style.height !== '') {
      // eslint-disable-next-line no-console
      console.error('Do not set explicit dimensions on custom logo images. The container will resize the image to fit.');
    }
  }, []);
  var hasCustomTheme = (0, _hasCustomThemeContext.useHasCustomTheme)();
  return /*#__PURE__*/_react.default.createElement(_primitives.Anchor, {
    ref: ref,
    "aria-label": label,
    href: href
    // @ts-expect-error - non-standard values for `borderRadius` and the custom theming interaction states
    // eslint-disable-next-line @compiled/no-suppress-xcss
    ,
    xcss: (0, _react2.cx)(anchorStyles.root, anchorStyles.customLogoBorderRadius, anchorStyles.newMargin, hasCustomTheme ? anchorStyles.newInteractionStatesCustomTheming : anchorStyles.newInteractionStates),
    onClick: onClick
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _runtime.ax)([sharedIconOrLogoContainerStyles.root, iconContainerStyles.root, (0, _platformFeatureFlags.fg)('platform-team25-app-icon-tiles') && sharedIconOrLogoContainerStyles.appIconTilePaddingFlagged])
  }, /*#__PURE__*/_react.default.createElement(_logoRenderer.LogoRenderer, {
    logoOrIcon: icon
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _runtime.ax)([sharedIconOrLogoContainerStyles.root, logoContainerStyles.root, (0, _platformFeatureFlags.fg)('platform-team25-app-icon-tiles') && sharedIconOrLogoContainerStyles.appIconTilePaddingFlagged])
  }, /*#__PURE__*/_react.default.createElement(_logoRenderer.LogoRenderer, {
    logoOrIcon: logo
  })));
};