"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.CollectionSectionHeaderActionBar = void 0;
var _designSystem = require("@wix/design-system");
var _react = _interopRequireDefault(require("react"));
var _ToolbarCollectionContext = require("../ToolbarCollectionContext");
var _bexCore = require("@wix/bex-core");
var _bi = require("@wix/bex-core/bi");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CollectionSectionHeader/CollectionSectionHeaderActionBar.tsx";
const CollectionSectionHeaderActionBar = ({
  sectionId,
  sectionIndex,
  section,
  biComponentType,
  collapsible,
  onToggleCollapse
}) => {
  const {
    toolbarBIReporter
  } = (0, _ToolbarCollectionContext.useToolbarCollectionContext)();
  const {
    primaryAction,
    collapsed
  } = section;
  const handlePrimaryActionClick = () => {
    toolbarBIReporter.reportBi((0, _bi.wixPatternsSectionHeaderPrimaryActionClicked)({
      sectionId,
      cta: primaryAction == null ? void 0 : primaryAction.id,
      componentType: biComponentType
    }));
    primaryAction == null || primaryAction.onClick == null || primaryAction.onClick();
  };
  const handleCollapseActionClick = () => {
    toolbarBIReporter.reportBi((0, _bexCore.withoutDefaults)(_bi.cairoSectionCtaClicked)({
      location: 'Section Toolbar',
      sectionType: 'table',
      ctaName: collapsed ? 'expand' : 'collapse',
      sectionIndex
    }));
    onToggleCollapse == null || onToggleCollapse(sectionId);
  };
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "horizontal",
    gap: "SP2",
    placeItems: "center",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 56,
      columnNumber: 5
    }
  }, primaryAction && /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
    prefixIcon: primaryAction.prefixIcon,
    dataHook: "collection-section-header-primary-action",
    onClick: handlePrimaryActionClick,
    size: "small",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 58,
      columnNumber: 9
    }
  }, primaryAction.label), collapsible && /*#__PURE__*/_react.default.createElement(_designSystem.IconButton, {
    size: "tiny",
    dataHook: "collection-section-header-collapse-action",
    skin: "light",
    priority: "primary",
    onClick: handleCollapseActionClick,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 68,
      columnNumber: 9
    }
  }, collapsed ? /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChevronDown, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 75,
      columnNumber: 24
    }
  }) : /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChevronUp, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 75,
      columnNumber: 42
    }
  })));
};
exports.CollectionSectionHeaderActionBar = CollectionSectionHeaderActionBar;
//# sourceMappingURL=CollectionSectionHeaderActionBar.js.map