/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./index.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { useCallback, useMemo } from 'react';
import { browser } from '@atlaskit/linking-common/user-agent';
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../../constants';
import { useFlexibleUiContext } from '../../../../../../state/flexible-ui-context';
import { Provider } from '../../../elements';
import ActionGroup from '../../action-group';
import Block from '../../block';
import ElementGroup from '../../element-group';
import { filterActionItems } from '../../utils';
var actionGroupStyles = null;
var safariStyles = null;
var FooterBlockResolvedView = function FooterBlockResolvedView(props) {
  var actions = props.actions,
    testId = props.testId,
    onActionMenuOpenChange = props.onActionMenuOpenChange,
    _props$size = props.size,
    size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
    hideProvider = props.hideProvider;
  var context = useFlexibleUiContext();
  var hasActions = useMemo(function () {
    var _filterActionItems;
    return ((_filterActionItems = filterActionItems(actions, context)) === null || _filterActionItems === void 0 ? void 0 : _filterActionItems.length) > 0;
  }, [actions, context]);

  // eslint-disable-next-line react-hooks/rules-of-hooks
  var _useMemo = useMemo(function () {
      return browser();
    }, []),
    _useMemo$safari = _useMemo.safari,
    safari = _useMemo$safari === void 0 ? false : _useMemo$safari;
  var onDropdownOpenChange = useCallback(function (isOpen) {
    if (onActionMenuOpenChange) {
      onActionMenuOpenChange({
        isOpen: isOpen
      });
    }
  }, [onActionMenuOpenChange]);
  return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
    testId: "".concat(testId, "-resolved-view")
  }), !hideProvider && /*#__PURE__*/React.createElement(Provider, {
    appearance: "subtle",
    testId: "".concat(testId, "-provider")
  }), actions && hasActions ? /*#__PURE__*/React.createElement(ElementGroup, {
    testId: "smart-element-group-actions",
    align: SmartLinkAlignment.Right,
    direction: SmartLinkDirection.Horizontal,
    width: SmartLinkWidth.Flexible,
    className: ax([size === SmartLinkSize.XLarge && "_c71lxy5q", safari && "_4t3i1osq"])
  }, /*#__PURE__*/React.createElement(ActionGroup, {
    onDropdownOpenChange: onDropdownOpenChange,
    items: actions,
    appearance: "default",
    size: size
  })) : null);
};
export default FooterBlockResolvedView;