"use strict";

exports.__esModule = true;
exports.TagsAssignButton = void 0;
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _ToolbarCollectionContext = require("../ToolbarCollectionContext");
var _ = require("../..");
var _BulkAssignTagsPopover = require("../Tags/BulkAssignTagsPopover");
var _DisabledTooltip = require("../DisabledTooltip");
var _mobxReactLite = require("mobx-react-lite");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/TagsAssignButton/TagsAssignButton.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (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 (const 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); }
const _TagsAssignButton = () => {
  const toolbarCollectionState = (0, _ToolbarCollectionContext.useToolbarCollectionContext)();
  const {
    translate: t
  } = (0, _.useWixPatternsContainer)();
  const buttonRef = (0, _react.useRef)(null);
  const {
    tagsBulkAssignPopoverState
  } = toolbarCollectionState.tagsCollectionState ?? {};
  const setButtonRef = (0, _react.useCallback)(element => {
    if (!element || !tagsBulkAssignPopoverState) {
      return;
    }
    const el = element.querySelector('button');
    if (!el) {
      return;
    }
    buttonRef.current = el;
    tagsBulkAssignPopoverState.triggerButtonRef = buttonRef;
  }, [tagsBulkAssignPopoverState]);
  if (!tagsBulkAssignPopoverState) {
    return null;
  }
  const {
    tagsBulkAssignButtonState
  } = tagsBulkAssignPopoverState;
  return /*#__PURE__*/_react.default.createElement(_BulkAssignTagsPopover.BulkAssignTagsPopover, {
    state: tagsBulkAssignPopoverState,
    popoverElement: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 43,
        columnNumber: 9
      }
    }, /*#__PURE__*/_react.default.createElement("div", {
      ref: setButtonRef,
      style: {
        display: 'contents'
      },
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 44,
        columnNumber: 11
      }
    }, /*#__PURE__*/_react.default.createElement(_DisabledTooltip.DisabledTooltip, {
      content: tagsBulkAssignButtonState.tooltipContent,
      disabled: !tagsBulkAssignButtonState.isDisabled,
      dataHook: "tags-assign-button-disabled-tooltip",
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 45,
        columnNumber: 13
      }
    }, /*#__PURE__*/_react.default.createElement(_designSystem.Button, {
      skin: "standard",
      priority: "secondary",
      size: "small",
      ellipsis: true,
      prefixIcon: /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.TagSmall, {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 55,
          columnNumber: 29
        }
      }),
      dataHook: "tags-assign-button",
      onClick: () => {
        tagsBulkAssignPopoverState.showPopover();
      },
      disabled: tagsBulkAssignButtonState.isDisabled,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 50,
        columnNumber: 15
      }
    }, t('cairo.tags.collectionPage.add.CTA'))))),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 40,
      columnNumber: 5
    }
  });
};
const TagsAssignButton = exports.TagsAssignButton = (0, _mobxReactLite.observer)(_TagsAssignButton);
//# sourceMappingURL=TagsAssignButton.js.map