import './Link_1n93y72.css';
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { cx } from '../../utils/index.js';
import { base as base$1 } from './_view/base.js';
import { base as base$2 } from './_disabled/base.js';
import { base as base$3 } from './_focused/base.js';
import { classes } from './Link.tokens.js';

var _excluded = ["className", "children", "disabled", "underline", "target", "href", "rel"];
var base = "bozgdm1";
var underlineClassMap = {
  always: classes.linkUnderlineAlways,
  hover: classes.linkUnderlineHover,
  none: undefined
};
var linkRoot = function linkRoot(Root) {
  return /*#__PURE__*/forwardRef(function (props, ref) {
    var className = props.className,
      children = props.children,
      disabled = props.disabled,
      _props$underline = props.underline,
      underline = _props$underline === void 0 ? 'none' : _props$underline,
      target = props.target,
      href = props.href,
      rel = props.rel,
      rest = _objectWithoutProperties(props, _excluded);
    var underlineClass = underlineClassMap[underline];
    var forwardProps = {
      disabled: disabled,
      target: target,
      href: disabled ? undefined : href,
      // NOTE: https://developer.chrome.com/docs/lighthouse/best-practices/external-anchors-use-rel-noopener/
      rel: target === '_blank' ? 'noopener noreferrer' : rel
    };
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      className: cx(underlineClass, className),
      ref: ref
    }, forwardProps, rest), children);
  });
};
var linkConfig = {
  name: 'Link',
  tag: 'a',
  layout: linkRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    },
    disabled: {
      css: base$2,
      attrs: true
    },
    focused: {
      css: base$3
    }
  },
  defaults: {
    view: 'primary',
    size: 'm'
  }
};

export { linkConfig, linkRoot };
