<commit_before>import React, { useCallback } from 'react'
import PropTypes from 'prop-types'
import { FormattedMessage, useIntl } from 'react-intl'
import { useFormState } from 'informed'
import { isOnchain, isBolt11, isPubkey, decodePayReq } from '@zap/utils/crypto'
import { Message } from 'components/UI'
import TextArea from './TextArea'
import messages from './messages'

const mask = value => (value ? value.trim() : value)

const validate = (intl, network, chain, value) => {
  if (value) {
    let chainName = `${chain}/lightning`
    if (network !== 'mainnet') {
      chainName += ` (${network})`
    }
    const invalidRequestMessage = intl.formatMessage(
      { ...messages.invalid_request },
      { chain: chainName }
    )
    // If we have a LN invoice, ensure the invoice has an amount.
    if (isBolt11(value, chain, network)) {
      try {
        const invoice = decodePayReq(value)
        if (!invoice) {
          throw new Error('Invalid invoice')<commit_msg>fix(ui): trim host from keysend pubkey<commit_after>import React, { useCallback } from 'react'
import PropTypes from 'prop-types'
import { FormattedMessage, useIntl } from 'react-intl'
import { useFormState } from 'informed'
import { isOnchain, isBolt11, isPubkey, decodePayReq } from '@zap/utils/crypto'
import { Message } from 'components/UI'
import TextArea from './TextArea'
import messages from './messages'

const mask = value => (value ? value.split('@')[0].trim() : value)

const validate = (intl, network, chain, value) => {
  if (value) {
    let chainName = `${chain}/lightning`
    if (network !== 'mainnet') {
      chainName += ` (${network})`
    }
    const invalidRequestMessage = intl.formatMessage(
      { ...messages.invalid_request },
      { chain: chainName }
    )
    // If we have a LN invoice, ensure the invoice has an amount.
    if (isBolt11(value, chain, network)) {
      try {
        const invoice = decodePayReq(value)
        if (!invoice) {
          throw new Error('Invalid invoice')
{'fraction_non_alphanumeric': 0.13303437967115098, 'fraction_numerical': 0.004484304932735426, 'mean_word_length': 3.374727668845316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248204', 'n_tokens_mistral': 614, 'n_tokens_neox': 601, 'n_words': 186}