"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.parseMessageBody = void 0;
var _jsxRuntime = require("react/jsx-runtime");
const parseMessageBody = text => {
  if (typeof text !== 'string') {
    return [text];
  }
  const urlRegex = /(https:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+)/g;
  const parts = [];
  let lastIndex = 0;
  let match;
  while ((match = urlRegex.exec(text)) !== null) {
    const index = match.index;
    const url = match[0];
    if (index > lastIndex) {
      parts.push(text.substring(lastIndex, index));
    }
    parts.push(/*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
      href: url,
      target: "_blank",
      rel: "noopener noreferrer",
      style: {
        color: 'blue',
        textDecoration: 'underline'
      },
      children: url
    }, index));
    lastIndex = index + url.length;
  }
  if (lastIndex < text.length) {
    parts.push(text.substring(lastIndex));
  }
  if (parts.length === 0 && lastIndex === 0) {
    return [text];
  }
  return parts;
};
exports.parseMessageBody = parseMessageBody;
//# sourceMappingURL=parseUrls.js.map