/* 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';
const actionGroupStyles = null;
const safariStyles = null;
const FooterBlockResolvedView = props => {
  const {
    actions,
    testId,
    onActionMenuOpenChange,
    size = SmartLinkSize.Medium,
    hideProvider
  } = props;
  const context = useFlexibleUiContext();
  const hasActions = useMemo(() => {
    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
  const {
    safari = false
  } = useMemo(() => browser(), []);
  const onDropdownOpenChange = useCallback(isOpen => {
    if (onActionMenuOpenChange) {
      onActionMenuOpenChange({
        isOpen
      });
    }
  }, [onActionMenuOpenChange]);
  return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
    testId: `${testId}-resolved-view`
  }), !hideProvider && /*#__PURE__*/React.createElement(Provider, {
    appearance: "subtle",
    testId: `${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;