function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/* eslint-disable css-modules/no-unused-class */

/* eslint-disable import/no-cycle */

/* eslint-disable @zohodesk/zsecurity/no-protocol-check */

/* eslint-disable react/forbid-prop-types */
import React from 'react';
import PropTypes from 'prop-types';
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
import defaultStyle from './Link.module.css';
import linkPropTypes, { defaultProps, propsDescription } from './Link.propTypes';
import constantProps from './Link.constantProps';
import useLinkAriaProps from './useLinkAriaProps';
import linkCssJSLogic from './Link.cssJSLogic';
export default function LinkSkeleton(prop) {
  const {
    target,
    rel,
    href,
    title,
    download,
    children,
    text,
    wordWrap,
    disabled,
    onClick,
    customStyle,
    customId,
    customIdPrefix,
    customIdSuffix,
    startIcon,
    endIcon,
    tagAttributes,
    tagGeneralAttributes,
    onHandlePreventDefault,
    hasPreventDefaultBehaviour
  } = prop;
  const style = useMergeStyle(defaultStyle, customStyle);
  const hasIcon = startIcon || endIcon;
  const className = linkCssJSLogic(prop, style);
  const {
    linkProps
  } = useLinkAriaProps(prop);
  return /*#__PURE__*/React.createElement("a", _extends({}, tagGeneralAttributes, {
    className: className,
    href: href,
    target: target,
    rel: rel,
    onClick: onClick && !disabled && hasPreventDefaultBehaviour ? onHandlePreventDefault : onClick,
    disabled: disabled,
    "data-id": customId.link`${customIdPrefix}${customIdSuffix}`,
    title: title,
    download: download
  }, linkProps, tagAttributes), /*#__PURE__*/React.createElement(RenderAsIcon, {
    icon: startIcon,
    className: style.start_icon
  }), text && hasIcon ? /*#__PURE__*/React.createElement("span", {
    className: wordWrap ? style.linktext : null
  }, text) : text || null, !text && children ? children : null, /*#__PURE__*/React.createElement(RenderAsIcon, {
    icon: endIcon,
    className: style.end_icon
  }));
} // LinkSkeleton.propTypes = linkPropTypes;
// LinkSkeleton.defaultProps = defaultProps;
// LinkSkeleton.propsDescription = propsDescription;
// LinkSkeleton.constantProps = constantProps;

const RenderAsIcon = props => {
  const {
    className,
    icon
  } = props;
  return icon ? /*#__PURE__*/React.createElement("span", {
    className: className
  }, icon) : null;
};

RenderAsIcon.propTypes = {
  icon: PropTypes.any,
  className: PropTypes.string
};