"use strict";

Liferay.Loader.define("@frontend-taglib-clay$clayui/link@3.128.0/lib/Link", ['module', 'exports', 'require', 'frontend-taglib-clay$classnames', 'frontend-js-react-web$react', './Context'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(o) {
      "@babel/helpers - typeof";
      return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
        return typeof o;
      } : function (o) {
        return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
      }, _typeof(o);
    }
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;
    var _classnames = _interopRequireDefault(require("frontend-taglib-clay$classnames"));
    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));
    var _Context = _interopRequireDefault(require("./Context"));
    var _excluded = ["block", "borderless", "button", "children", "className", "decoration", "displayType", "fontSize", "messages", "monospaced", "outline", "rel", "small", "target", "weight"];
    /**
     * SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com>
     * SPDX-License-Identifier: BSD-3-Clause
     */
    function _interopRequireDefault(e) {
      return e && e.__esModule ? e : { default: e };
    }
    function _extends() {
      return _extends = Object.assign ? Object.assign.bind() : function (n) {
        for (var e = 1; e < arguments.length; e++) {
          var t = arguments[e];for (var r in t) {
            ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
          }
        }return n;
      }, _extends.apply(null, arguments);
    }
    function _defineProperty(e, r, t) {
      return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e;
    }
    function _toPropertyKey(t) {
      var i = _toPrimitive(t, "string");return "symbol" == _typeof(i) ? i : i + "";
    }
    function _toPrimitive(t, r) {
      if ("object" != _typeof(t) || !t) return t;var e = t[Symbol.toPrimitive];if (void 0 !== e) {
        var i = e.call(t, r || "default");if ("object" != _typeof(i)) return i;throw new TypeError("@@toPrimitive must return a primitive value.");
      }return ("string" === r ? String : Number)(t);
    }
    function _objectWithoutProperties(e, t) {
      if (null == e) return {};var o,
          r,
          i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {
        var s = Object.getOwnPropertySymbols(e);for (r = 0; r < s.length; r++) {
          o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
        }
      }return i;
    }
    function _objectWithoutPropertiesLoose(r, e) {
      if (null == r) return {};var t = {};for (var n in r) {
        if ({}.hasOwnProperty.call(r, n)) {
          if (e.includes(n)) continue;t[n] = r[n];
        }
      }return t;
    }
    var LINK_PRESETS = {
      danger: {
        base: 'c-link text-danger',
        decoration: 'underline'
      },
      primary: {
        base: 'c-link link-primary',
        decoration: 'underline'
      },
      secondary: {
        base: 'c-link link-secondary',
        decoration: 'underline'
      },
      tertiary: {
        base: 'c-link text-tertiary',
        decoration: null
      },
      unstyled: {
        base: 'link-unstyled',
        decoration: null
      }
    };
    var FONT_WEIGHTS = {
      normal: 'font-weight-normal',
      'semi-bold': 'font-weight-semi-bold'
    };
    var defaultMessages = {
      opensNewWindow: '(Opens a new window)'
    };
    var Link = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
      var block = _ref.block,
          borderless = _ref.borderless,
          button = _ref.button,
          children = _ref.children,
          className = _ref.className,
          decoration = _ref.decoration,
          displayType = _ref.displayType,
          fontSize = _ref.fontSize,
          _ref$messages = _ref.messages,
          messages = _ref$messages === void 0 ? defaultMessages : _ref$messages,
          monospaced = _ref.monospaced,
          outline = _ref.outline,
          rel = _ref.rel,
          small = _ref.small,
          target = _ref.target,
          weight = _ref.weight,
          otherProps = _objectWithoutProperties(_ref, _excluded);
      var TagOrComponent = _react.default.useContext(_Context.default);
      var classes;
      if (button) {
        var _classes;
        button = button === true ? {} : button;
        classes = (_classes = {
          btn: !!button,
          'btn-block': button.block || block,
          'btn-monospaced': button.monospaced || monospaced,
          'btn-outline-borderless': borderless,
          'btn-sm': button.small || small
        }, _defineProperty(_classes, "btn-".concat(displayType), displayType && !outline && !borderless), _defineProperty(_classes, "btn-outline-".concat(displayType), displayType && (outline || borderless)), _defineProperty(_classes, FONT_WEIGHTS[weight], weight), _defineProperty(_classes, "text-".concat(fontSize), fontSize), _defineProperty(_classes, "text-decoration-".concat(decoration), decoration), _classes);
      } else {
        var _LINK_PRESETS, _LINK_PRESETS2, _classes2;
        decoration = decoration === null || outline ? undefined : decoration || ((_LINK_PRESETS = LINK_PRESETS[displayType]) === null || _LINK_PRESETS === void 0 ? void 0 : _LINK_PRESETS.decoration);
        classes = (_classes2 = {
          'link-monospaced': monospaced,
          'link-outline': outline,
          'link-outline-borderless': borderless
        }, _defineProperty(_classes2, (_LINK_PRESETS2 = LINK_PRESETS[displayType]) === null || _LINK_PRESETS2 === void 0 ? void 0 : _LINK_PRESETS2.base, displayType && !outline), _defineProperty(_classes2, "link-outline-".concat(displayType), displayType && outline), _defineProperty(_classes2, FONT_WEIGHTS[weight], weight), _defineProperty(_classes2, "text-".concat(fontSize), fontSize), _defineProperty(_classes2, "text-decoration-".concat(decoration), decoration), _classes2);
      }
      if (target && !rel) {
        rel = 'noreferrer noopener';
      }
      return (/*#__PURE__*/_react.default.createElement(TagOrComponent, _extends({
          className: (0, _classnames.default)(className, classes),
          ref: ref,
          rel: rel,
          target: target
        }, otherProps), children, target === '_blank' && /*#__PURE__*/_react.default.createElement("span", {
          className: "sr-only"
        }, messages.opensNewWindow))
      );
    });
    Link.displayName = 'ClayLink';
    var _default = exports.default = Link;
  }
});
//# sourceMappingURL=Link.js.map