"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.PageSubTitle = void 0;
var _react = _interopRequireDefault(require("react"));
var _designSystem = require("@wix/design-system");
var _react2 = require("@wix/bex-core/react");
var _useSelector = require("../../useSelector");
var _bexCore = require("@wix/bex-core");
var _bi = require("@wix/bex-core/bi");
var _useIsMobile = require("../../hooks/useIsMobile");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/PageSubTitle/PageSubTitle.tsx";
/**
 * Props for the PageSubTitle component.
 * @property {string} text The subtitle text.
 * @property {Object} [learnMore] An object with a `url` (required) for displaying a link button on the subtitle.
 * @property {string} learnMore.url where the link should navigate to
 * @property {string} [learnMore.label ="Learn more"] - the label of the link button. defaults to "Learn More"
 */

/**
 * Renders a page subtitle with an optional learn more button
 * @component
 * @param {PageSubTitleProps} props The props for the component.
 * @example
 * ```jsx
 * <PageSubTitle text="Welcome to my page" learnMore={{ url: "/learn-more", label: "Learn More" }} />
 * ```
 */
const PageSubTitle = ({
  text,
  learnMore
}) => {
  const {
    translate: t,
    initTask
  } = (0, _react2.useWixPatternsContainer)();
  const {
    bi
  } = (0, _react2.useCollectionPageContext)();
  (0, _useSelector.useSelector)(() => initTask.status);
  const isMobile = (0, _useIsMobile.useIsMobile)();
  const learnMoreSuffix = learnMore ? /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
    dataHook: "subtitle-learn-more-cta",
    as: "a",
    rel: "noopener",
    target: "_blank",
    href: learnMore.url,
    size: isMobile ? 'small' : 'medium',
    style: {
      marginLeft: '6px'
    },
    onClick: () => {
      bi == null || bi.reportBI((0, _bexCore.withoutDefaults)(_bi.cairoPageCtaClicked)({
        location: 'Collection Page Header',
        ctaType: 'link',
        ctaName: 'Learn more'
      }));
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 44,
      columnNumber: 5
    }
  }, learnMore.label ?? t('cairo.subtitle.learnMore')) : undefined;
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    dataHook: "page-subtitle",
    width: "100%",
    minWidth: 0,
    verticalAlign: "bottom",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 67,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    ellipsis: true,
    secondary: true,
    maxLines: 2,
    suffix: learnMoreSuffix,
    tooltipProps: {
      placement: 'auto'
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 73,
      columnNumber: 7
    }
  }, text));
};
exports.PageSubTitle = PageSubTitle;
//# sourceMappingURL=PageSubTitle.js.map