{"version":3,"file":"linkify-react-BLlLOFPL.js","sources":["../../node_modules/linkify-react/dist/linkify-react.es.js"],"sourcesContent":["import * as React from 'react';\nimport { Options, options, tokenize } from 'linkifyjs';\n\n/**\n * Given a string, converts to an array of valid React components\n * (which may include strings)\n * @param {string} str\n * @param {Options} opts\n * @param {{ [elementId: string]: number }} meta\n * @returns {React.ReactNodeArray}\n */\nfunction stringToElements(str, opts, meta) {\n const tokens = tokenize(str);\n const elements = [];\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token.t === 'nl' && opts.get('nl2br')) {\n const key = `__linkify-el-${meta.elementId++}`;\n elements.push(React.createElement('br', {\n key\n }));\n } else if (!token.isLink || !opts.check(token)) {\n // Regular text\n elements.push(token.toString());\n } else {\n let rendered = opts.render(token);\n if (!('key' in rendered.props)) {\n // Ensure generated element has unique key\n const key = `__linkify-el-${meta.elementId++}`;\n const props = options.assign({\n key\n }, rendered.props);\n rendered = React.cloneElement(rendered, props);\n }\n elements.push(rendered);\n }\n }\n return elements;\n}\n\n// Recursively linkify the contents of the given React Element instance\n/**\n * @template P\n * @template {string | React.JSXElementConstructor

} T\n * @param {React.ReactElement} element\n * @param {Options} opts\n * @param {{ [elementId: string]: number }} meta\n * @returns {React.ReactElement}\n */\nfunction linkifyReactElement(element, opts, meta) {\n if (React.Children.count(element.props.children) === 0) {\n // No need to clone if the element had no children\n return element;\n }\n const children = [];\n React.Children.forEach(element.props.children, child => {\n if (typeof child === 'string') {\n // ensure that we always generate unique element IDs for keys\n children.push.apply(children, stringToElements(child, opts, meta));\n } else if (React.isValidElement(child)) {\n if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) {\n // Don't linkify this element\n children.push(child);\n } else {\n children.push(linkifyReactElement(child, opts, meta));\n }\n } else {\n // Unknown element type, just push\n children.push(child);\n }\n });\n\n // Set a default unique key, copy over remaining props\n const key = `__linkify-el-${meta.elementId++}`;\n const newProps = options.assign({\n key\n }, element.props);\n return React.cloneElement(element, newProps, children);\n}\n\n/**\n * @template P\n * @template {string | React.JSXElementConstructor

} T\n * @param {P & { as?: T, tagName?: T, options?: import('linkifyjs').Opts, children?: React.ReactNode}} props\n * @returns {React.ReactElement}\n */\nconst Linkify = props => {\n // Copy over all non-linkify-specific props\n let linkId = 0;\n const defaultLinkRender = ({\n tagName,\n attributes,\n content\n }) => {\n attributes.key = `__linkify-lnk-${linkId++}`;\n if (attributes.class) {\n attributes.className = attributes.class;\n delete attributes.class;\n }\n return React.createElement(tagName, attributes, content);\n };\n const newProps = {\n key: '__linkify-wrapper'\n };\n for (const prop in props) {\n if (prop !== 'options' && prop !== 'as' && prop !== 'tagName' && prop !== 'children') {\n newProps[prop] = props[prop];\n }\n }\n const opts = new Options(props.options, defaultLinkRender);\n const as = props.as || props.tagName || React.Fragment || 'span';\n const children = props.children;\n const element = React.createElement(as, newProps, children);\n return linkifyReactElement(element, opts, {\n elementId: 0\n });\n};\n\nexport { Linkify as default };\n"],"names":["stringToElements","str","opts","meta","tokens","tokenize","elements","i","token","key","React.createElement","rendered","props","options","React.cloneElement","linkifyReactElement","element","React.Children","children","child","React.isValidElement","newProps","Linkify","linkId","defaultLinkRender","tagName","attributes","content","prop","Options","as","React.Fragment"],"mappings":"2aAWA,SAASA,EAAiBC,EAAKC,EAAMC,EAAM,CACzC,MAAMC,EAASC,EAASJ,CAAG,EACrBK,EAAW,CAAE,EACnB,QAASC,EAAI,EAAGA,EAAIH,EAAO,OAAQG,IAAK,CACtC,MAAMC,EAAQJ,EAAOG,CAAC,EACtB,GAAIC,EAAM,IAAM,MAAQN,EAAK,IAAI,OAAO,EAAG,CACzC,MAAMO,EAAM,gBAAgBN,EAAK,WAAW,GAC5CG,EAAS,KAAKI,EAAmB,cAAC,KAAM,CACtC,IAAAD,CACR,CAAO,CAAC,CACR,SAAe,CAACD,EAAM,QAAU,CAACN,EAAK,MAAMM,CAAK,EAE3CF,EAAS,KAAKE,EAAM,UAAU,MACzB,CACL,IAAI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