UNPKG

react-from-dom

Version:

Convert HTML/XML source code or DOM nodes to React elements

1 lines 31.2 kB
{"version":3,"sources":["../src/index.ts","../src/helpers.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { noTextChildNodes, possibleStandardNames, randomString, styleToObject } from './helpers';\n\ninterface Attributes {\n [index: string]: any;\n\n key: string;\n}\n\ninterface GetReactNodeOptions extends Options {\n key: string;\n level: number;\n}\n\nexport type Output = React.ReactNode | Node | NodeList;\n\nexport interface Action {\n // If this returns true, the two following functions are called if they are defined\n condition: (node: Node, key: string, level: number) => boolean;\n\n // Use this to inject a component or remove the node\n // It must return something that can be rendered by React\n post?: (node: Node, key: string, level: number) => React.ReactNode;\n\n // Use this to update or replace the node\n // e.g. for removing or adding attributes, changing the node type\n pre?: (node: Node, key: string, level: number) => Node;\n}\n\nexport interface Options {\n /**\n * An array of actions to modify the nodes before converting them to ReactNodes.\n */\n actions?: Action[];\n /**\n * Don't remove white spaces in the output.\n */\n allowWhiteSpaces?: boolean;\n /**\n * Parse all nodes instead of just a single parent node.\n * This will return a ReactNode array (or a NodeList if `nodeOnly` is true).\n */\n includeAllNodes?: boolean;\n /**\n * The index to start the React key identification.\n * @default 0\n */\n index?: number;\n /**\n * The level to start the React key identification.\n * @default 0\n */\n level?: number;\n /**\n * Only return the node (or NodeList) without converting it to a ReactNode.\n */\n nodeOnly?: boolean;\n /**\n * Add a random key to the root element.\n * @default false\n */\n randomKey?: boolean;\n /**\n * The selector to use in the `document.querySelector` method.\n * @default 'body > *'\n */\n selector?: string;\n /**\n * The mimeType to use in the DOMParser's parseFromString.\n * @default 'text/html'\n */\n type?: DOMParserSupportedType;\n}\n\nfunction getReactNode(node: Node, options: GetReactNodeOptions): React.ReactNode {\n const { key, level, ...rest } = options;\n\n switch (node.nodeType) {\n case 1: {\n // regular dom-node\n return React.createElement(\n parseName(node.nodeName),\n parseAttributes(node, key),\n parseChildren(node.childNodes, level, rest),\n );\n }\n case 3: {\n // textnode\n const nodeText = node.nodeValue?.toString() ?? '';\n\n if (!rest.allowWhiteSpaces && /^\\s+$/.test(nodeText) && !/[\\u00A0\\u202F]/.test(nodeText)) {\n return null;\n }\n\n /* c8 ignore next 3 */\n if (!node.parentNode) {\n return nodeText;\n }\n\n const parentNodeName = node.parentNode.nodeName.toLowerCase();\n\n if (noTextChildNodes.includes(parentNodeName)) {\n if (/\\S/.test(nodeText)) {\n // eslint-disable-next-line no-console\n console.warn(\n `A textNode is not allowed inside '${parentNodeName}'. Your text \"${nodeText}\" will be ignored`,\n );\n }\n\n return null;\n }\n\n return nodeText;\n }\n case 8: {\n // html-comment\n return null;\n }\n case 11: {\n // fragment\n\n return parseChildren(node.childNodes, level, options);\n }\n /* c8 ignore next 3 */\n default: {\n return null;\n }\n }\n}\n\nfunction parseAttributes(node: Node, reactKey: string): Attributes {\n const attributes: Attributes = {\n key: reactKey,\n };\n\n if (node instanceof Element) {\n const nodeClassNames = node.getAttribute('class');\n\n if (nodeClassNames) {\n attributes.className = nodeClassNames;\n }\n\n [...node.attributes].forEach(d => {\n switch (d.name) {\n // this is manually handled above, so break;\n case 'class':\n break;\n case 'style':\n attributes[d.name] = styleToObject(d.value);\n break;\n case 'allowfullscreen':\n case 'allowpaymentrequest':\n case 'async':\n case 'autofocus':\n case 'autoplay':\n case 'checked':\n case 'controls':\n case 'default':\n case 'defer':\n case 'disabled':\n case 'formnovalidate':\n case 'hidden':\n case 'ismap':\n case 'itemscope':\n case 'loop':\n case 'multiple':\n case 'muted':\n case 'nomodule':\n case 'novalidate':\n case 'open':\n case 'readonly':\n case 'required':\n case 'reversed':\n case 'selected':\n case 'typemustmatch':\n attributes[possibleStandardNames[d.name] || d.name] = true;\n break;\n default:\n attributes[possibleStandardNames[d.name] || d.name] = d.value;\n }\n });\n }\n\n return attributes;\n}\n\nfunction parseChildren(childNodeList: NodeList, level: number, options: Options) {\n const children: React.ReactNode[] = [...childNodeList]\n .map((node, index) =>\n convertFromNode(node, {\n ...options,\n index,\n level: level + 1,\n }),\n )\n .filter(Boolean);\n\n if (!children.length) {\n return null;\n }\n\n return children;\n}\n\nfunction parseName(nodeName: string) {\n if (/[a-z]+[A-Z]+[a-z]+/.test(nodeName)) {\n return nodeName;\n }\n\n return nodeName.toLowerCase();\n}\n\nexport default function convert(input: Node | string, options: Options = {}): Output {\n if (typeof input === 'string') {\n return convertFromString(input, options);\n }\n\n if (input instanceof Node) {\n return convertFromNode(input, options);\n }\n\n return null;\n}\n\nexport function convertFromNode(input: Node, options: Options = {}): React.ReactNode {\n if (!input || !(input instanceof Node)) {\n return null;\n }\n\n const { actions = [], index = 0, level = 0, randomKey } = options;\n\n let node = input;\n let key = `${level}-${index}`;\n const result: React.ReactNode[] = [];\n\n if (randomKey && level === 0) {\n key = `${randomString()}-${key}`;\n }\n\n if (Array.isArray(actions)) {\n actions.forEach((action: Action) => {\n if (action.condition(node, key, level)) {\n if (typeof action.pre === 'function') {\n node = action.pre(node, key, level);\n\n if (!(node instanceof Node)) {\n node = input;\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n 'The `pre` method always must return a valid DomNode (instanceof Node) - your modification will be ignored (Hint: if you want to render a React-component, use the `post` method instead)',\n );\n }\n }\n }\n\n if (typeof action.post === 'function') {\n result.push(action.post(node, key, level));\n }\n }\n });\n }\n\n if (result.length) {\n return result;\n }\n\n return getReactNode(node, { key, level, ...options });\n}\n\nexport function convertFromString(input: string, options: Options = {}): Output {\n if (!input || typeof input !== 'string') {\n return null;\n }\n\n const {\n includeAllNodes = false,\n nodeOnly = false,\n selector = 'body > *',\n type = 'text/html',\n } = options;\n\n try {\n const parser = new DOMParser();\n const document = parser.parseFromString(input, type);\n\n if (includeAllNodes) {\n const { childNodes } = document.body;\n\n if (nodeOnly) {\n return childNodes;\n }\n\n return [...childNodes].map(node => convertFromNode(node, options));\n }\n\n const node = document.querySelector(selector) || document.body.childNodes[0];\n\n /* c8 ignore next 3 */\n if (!(node instanceof Node)) {\n throw new TypeError('Error parsing input');\n }\n\n if (nodeOnly) {\n return node;\n }\n\n return convertFromNode(node, options);\n /* c8 ignore start */\n } catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error(error);\n }\n }\n\n return null;\n /* c8 ignore stop */\n}\n","export const styleToObject = (input: string): Record<string, any> => {\n /* c8 ignore next 3 */\n if (typeof input !== 'string') {\n return {};\n }\n\n return input.split(/ ?; ?/).reduce<Record<string, string | number>>((acc, item: string) => {\n const [key, value] = item\n .split(/ ?: ?/)\n .map((d, index) => (index === 0 ? d.replace(/\\s+/g, '') : d.trim()));\n\n if (key && value) {\n const nextKey = key.replace(/(\\w)-(\\w)/g, (_$0, $1, $2) => `${$1}${$2.toUpperCase()}`);\n let nextValue: string | number = value.trim();\n\n if (!Number.isNaN(Number(value))) {\n nextValue = Number(value);\n }\n\n acc[key.startsWith('-') ? key : nextKey] = nextValue;\n }\n\n return acc;\n }, {});\n};\n\nexport function randomString(length = 6): string {\n const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n let result = '';\n\n for (let index = length; index > 0; --index) {\n result += characters[Math.round(Math.random() * (characters.length - 1))];\n }\n\n return result;\n}\n\nexport const noTextChildNodes = [\n 'br',\n 'col',\n 'colgroup',\n 'dl',\n 'hr',\n 'iframe',\n 'img',\n 'input',\n 'link',\n 'menuitem',\n 'meta',\n 'ol',\n 'param',\n 'select',\n 'table',\n 'tbody',\n 'tfoot',\n 'thead',\n 'tr',\n 'ul',\n 'wbr',\n];\n\n/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// Taken from https://raw.githubusercontent.com/facebook/react/baff5cc2f69d30589a5dc65b089e47765437294b/packages/react-dom/src/shared/possibleStandardNames.js\n// tslint:disable:object-literal-sort-keys\nexport const possibleStandardNames: Record<string, any> = {\n // HTML\n 'accept-charset': 'acceptCharset',\n acceptcharset: 'acceptCharset',\n accesskey: 'accessKey',\n allowfullscreen: 'allowFullScreen',\n autocapitalize: 'autoCapitalize',\n autocomplete: 'autoComplete',\n autocorrect: 'autoCorrect',\n autofocus: 'autoFocus',\n autoplay: 'autoPlay',\n autosave: 'autoSave',\n cellpadding: 'cellPadding',\n cellspacing: 'cellSpacing',\n charset: 'charSet',\n class: 'className',\n classid: 'classID',\n classname: 'className',\n colspan: 'colSpan',\n contenteditable: 'contentEditable',\n contextmenu: 'contextMenu',\n controlslist: 'controlsList',\n crossorigin: 'crossOrigin',\n dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',\n datetime: 'dateTime',\n defaultchecked: 'defaultChecked',\n defaultvalue: 'defaultValue',\n enctype: 'encType',\n for: 'htmlFor',\n formmethod: 'formMethod',\n formaction: 'formAction',\n formenctype: 'formEncType',\n formnovalidate: 'formNoValidate',\n formtarget: 'formTarget',\n frameborder: 'frameBorder',\n hreflang: 'hrefLang',\n htmlfor: 'htmlFor',\n httpequiv: 'httpEquiv',\n 'http-equiv': 'httpEquiv',\n icon: 'icon',\n innerhtml: 'innerHTML',\n inputmode: 'inputMode',\n itemid: 'itemID',\n itemprop: 'itemProp',\n itemref: 'itemRef',\n itemscope: 'itemScope',\n itemtype: 'itemType',\n keyparams: 'keyParams',\n keytype: 'keyType',\n marginwidth: 'marginWidth',\n marginheight: 'marginHeight',\n maxlength: 'maxLength',\n mediagroup: 'mediaGroup',\n minlength: 'minLength',\n nomodule: 'noModule',\n novalidate: 'noValidate',\n playsinline: 'playsInline',\n radiogroup: 'radioGroup',\n readonly: 'readOnly',\n referrerpolicy: 'referrerPolicy',\n rowspan: 'rowSpan',\n spellcheck: 'spellCheck',\n srcdoc: 'srcDoc',\n srclang: 'srcLang',\n srcset: 'srcSet',\n tabindex: 'tabIndex',\n typemustmatch: 'typeMustMatch',\n usemap: 'useMap',\n\n // SVG\n accentheight: 'accentHeight',\n 'accent-height': 'accentHeight',\n alignmentbaseline: 'alignmentBaseline',\n 'alignment-baseline': 'alignmentBaseline',\n allowreorder: 'allowReorder',\n arabicform: 'arabicForm',\n 'arabic-form': 'arabicForm',\n attributename: 'attributeName',\n attributetype: 'attributeType',\n autoreverse: 'autoReverse',\n basefrequency: 'baseFrequency',\n baselineshift: 'baselineShift',\n 'baseline-shift': 'baselineShift',\n baseprofile: 'baseProfile',\n calcmode: 'calcMode',\n capheight: 'capHeight',\n 'cap-height': 'capHeight',\n clippath: 'clipPath',\n 'clip-path': 'clipPath',\n clippathunits: 'clipPathUnits',\n cliprule: 'clipRule',\n 'clip-rule': 'clipRule',\n colorinterpolation: 'colorInterpolation',\n 'color-interpolation': 'colorInterpolation',\n colorinterpolationfilters: 'colorInterpolationFilters',\n 'color-interpolation-filters': 'colorInterpolationFilters',\n colorprofile: 'colorProfile',\n 'color-profile': 'colorProfile',\n colorrendering: 'colorRendering',\n 'color-rendering': 'colorRendering',\n contentscripttype: 'contentScriptType',\n contentstyletype: 'contentStyleType',\n diffuseconstant: 'diffuseConstant',\n dominantbaseline: 'dominantBaseline',\n 'dominant-baseline': 'dominantBaseline',\n edgemode: 'edgeMode',\n enablebackground: 'enableBackground',\n 'enable-background': 'enableBackground',\n externalresourcesrequired: 'externalResourcesRequired',\n fillopacity: 'fillOpacity',\n 'fill-opacity': 'fillOpacity',\n fillrule: 'fillRule',\n 'fill-rule': 'fillRule',\n filterres: 'filterRes',\n filterunits: 'filterUnits',\n floodopacity: 'floodOpacity',\n 'flood-opacity': 'floodOpacity',\n floodcolor: 'floodColor',\n 'flood-color': 'floodColor',\n fontfamily: 'fontFamily',\n 'font-family': 'fontFamily',\n fontsize: 'fontSize',\n 'font-size': 'fontSize',\n fontsizeadjust: 'fontSizeAdjust',\n 'font-size-adjust': 'fontSizeAdjust',\n fontstretch: 'fontStretch',\n 'font-stretch': 'fontStretch',\n fontstyle: 'fontStyle',\n 'font-style': 'fontStyle',\n fontvariant: 'fontVariant',\n 'font-variant': 'fontVariant',\n fontweight: 'fontWeight',\n 'font-weight': 'fontWeight',\n glyphname: 'glyphName',\n 'glyph-name': 'glyphName',\n glyphorientationhorizontal: 'glyphOrientationHorizontal',\n 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',\n glyphorientationvertical: 'glyphOrientationVertical',\n 'glyph-orientation-vertical': 'glyphOrientationVertical',\n glyphref: 'glyphRef',\n gradienttransform: 'gradientTransform',\n gradientunits: 'gradientUnits',\n horizadvx: 'horizAdvX',\n 'horiz-adv-x': 'horizAdvX',\n horizoriginx: 'horizOriginX',\n 'horiz-origin-x': 'horizOriginX',\n imagerendering: 'imageRendering',\n 'image-rendering': 'imageRendering',\n kernelmatrix: 'kernelMatrix',\n kernelunitlength: 'kernelUnitLength',\n keypoints: 'keyPoints',\n keysplines: 'keySplines',\n keytimes: 'keyTimes',\n lengthadjust: 'lengthAdjust',\n letterspacing: 'letterSpacing',\n 'letter-spacing': 'letterSpacing',\n lightingcolor: 'lightingColor',\n 'lighting-color': 'lightingColor',\n limitingconeangle: 'limitingConeAngle',\n markerend: 'markerEnd',\n 'marker-end': 'markerEnd',\n markerheight: 'markerHeight',\n markermid: 'markerMid',\n 'marker-mid': 'markerMid',\n markerstart: 'markerStart',\n 'marker-start': 'markerStart',\n markerunits: 'markerUnits',\n markerwidth: 'markerWidth',\n maskcontentunits: 'maskContentUnits',\n maskunits: 'maskUnits',\n numoctaves: 'numOctaves',\n overlineposition: 'overlinePosition',\n 'overline-position': 'overlinePosition',\n overlinethickness: 'overlineThickness',\n 'overline-thickness': 'overlineThickness',\n paintorder: 'paintOrder',\n 'paint-order': 'paintOrder',\n 'panose-1': 'panose1',\n pathlength: 'pathLength',\n patterncontentunits: 'patternContentUnits',\n patterntransform: 'patternTransform',\n patternunits: 'patternUnits',\n pointerevents: 'pointerEvents',\n 'pointer-events': 'pointerEvents',\n pointsatx: 'pointsAtX',\n pointsaty: 'pointsAtY',\n pointsatz: 'pointsAtZ',\n preservealpha: 'preserveAlpha',\n preserveaspectratio: 'preserveAspectRatio',\n primitiveunits: 'primitiveUnits',\n refx: 'refX',\n refy: 'refY',\n renderingintent: 'renderingIntent',\n 'rendering-intent': 'renderingIntent',\n repeatcount: 'repeatCount',\n repeatdur: 'repeatDur',\n requiredextensions: 'requiredExtensions',\n requiredfeatures: 'requiredFeatures',\n shaperendering: 'shapeRendering',\n 'shape-rendering': 'shapeRendering',\n specularconstant: 'specularConstant',\n specularexponent: 'specularExponent',\n spreadmethod: 'spreadMethod',\n startoffset: 'startOffset',\n stddeviation: 'stdDeviation',\n stitchtiles: 'stitchTiles',\n stopcolor: 'stopColor',\n 'stop-color': 'stopColor',\n stopopacity: 'stopOpacity',\n 'stop-opacity': 'stopOpacity',\n strikethroughposition: 'strikethroughPosition',\n 'strikethrough-position': 'strikethroughPosition',\n strikethroughthickness: 'strikethroughThickness',\n 'strikethrough-thickness': 'strikethroughThickness',\n strokedasharray: 'strokeDasharray',\n 'stroke-dasharray': 'strokeDasharray',\n strokedashoffset: 'strokeDashoffset',\n 'stroke-dashoffset': 'strokeDashoffset',\n strokelinecap: 'strokeLinecap',\n 'stroke-linecap': 'strokeLinecap',\n strokelinejoin: 'strokeLinejoin',\n 'stroke-linejoin': 'strokeLinejoin',\n strokemiterlimit: 'strokeMiterlimit',\n 'stroke-miterlimit': 'strokeMiterlimit',\n strokewidth: 'strokeWidth',\n 'stroke-width': 'strokeWidth',\n strokeopacity: 'strokeOpacity',\n 'stroke-opacity': 'strokeOpacity',\n suppresscontenteditablewarning: 'suppressContentEditableWarning',\n suppresshydrationwarning: 'suppressHydrationWarning',\n surfacescale: 'surfaceScale',\n systemlanguage: 'systemLanguage',\n tablevalues: 'tableValues',\n targetx: 'targetX',\n targety: 'targetY',\n textanchor: 'textAnchor',\n 'text-anchor': 'textAnchor',\n textdecoration: 'textDecoration',\n 'text-decoration': 'textDecoration',\n textlength: 'textLength',\n textrendering: 'textRendering',\n 'text-rendering': 'textRendering',\n underlineposition: 'underlinePosition',\n 'underline-position': 'underlinePosition',\n underlinethickness: 'underlineThickness',\n 'underline-thickness': 'underlineThickness',\n unicodebidi: 'unicodeBidi',\n 'unicode-bidi': 'unicodeBidi',\n unicoderange: 'unicodeRange',\n 'unicode-range': 'unicodeRange',\n unitsperem: 'unitsPerEm',\n 'units-per-em': 'unitsPerEm',\n unselectable: 'unselectable',\n valphabetic: 'vAlphabetic',\n 'v-alphabetic': 'vAlphabetic',\n vectoreffect: 'vectorEffect',\n 'vector-effect': 'vectorEffect',\n vertadvy: 'vertAdvY',\n 'vert-adv-y': 'vertAdvY',\n vertoriginx: 'vertOriginX',\n 'vert-origin-x': 'vertOriginX',\n vertoriginy: 'vertOriginY',\n 'vert-origin-y': 'vertOriginY',\n vhanging: 'vHanging',\n 'v-hanging': 'vHanging',\n videographic: 'vIdeographic',\n 'v-ideographic': 'vIdeographic',\n viewbox: 'viewBox',\n viewtarget: 'viewTarget',\n vmathematical: 'vMathematical',\n 'v-mathematical': 'vMathematical',\n wordspacing: 'wordSpacing',\n 'word-spacing': 'wordSpacing',\n writingmode: 'writingMode',\n 'writing-mode': 'writingMode',\n xchannelselector: 'xChannelSelector',\n xheight: 'xHeight',\n 'x-height': 'xHeight',\n xlinkactuate: 'xlinkActuate',\n 'xlink:actuate': 'xlinkActuate',\n xlinkarcrole: 'xlinkArcrole',\n 'xlink:arcrole': 'xlinkArcrole',\n xlinkhref: 'xlinkHref',\n 'xlink:href': 'xlinkHref',\n xlinkrole: 'xlinkRole',\n 'xlink:role': 'xlinkRole',\n xlinkshow: 'xlinkShow',\n 'xlink:show': 'xlinkShow',\n xlinktitle: 'xlinkTitle',\n 'xlink:title': 'xlinkTitle',\n xlinktype: 'xlinkType',\n 'xlink:type': 'xlinkType',\n xmlbase: 'xmlBase',\n 'xml:base': 'xmlBase',\n xmllang: 'xmlLang',\n 'xml:lang': 'xmlLang',\n 'xml:space': 'xmlSpace',\n xmlnsxlink: 'xmlnsXlink',\n 'xmlns:xlink': 'xmlnsXlink',\n xmlspace: 'xmlSpace',\n ychannelselector: 'yChannelSelector',\n zoomandpan: 'zoomAndPan',\n\n // event handlers\n onblur: 'onBlur',\n onchange: 'onChange',\n onclick: 'onClick',\n oncontextmenu: 'onContextMenu',\n ondoubleclick: 'onDoubleClick',\n ondrag: 'onDrag',\n ondragend: 'onDragEnd',\n ondragenter: 'onDragEnter',\n ondragexit: 'onDragExit',\n ondragleave: 'onDragLeave',\n ondragover: 'onDragOver',\n ondragstart: 'onDragStart',\n ondrop: 'onDrop',\n onerror: 'onError',\n onfocus: 'onFocus',\n oninput: 'onInput',\n oninvalid: 'onInvalid',\n onkeydown: 'onKeyDown',\n onkeypress: 'onKeyPress',\n onkeyup: 'onKeyUp',\n onload: 'onLoad',\n onmousedown: 'onMouseDown',\n onmouseenter: 'onMouseEnter',\n onmouseleave: 'onMouseLeave',\n onmousemove: 'onMouseMove',\n onmouseout: 'onMouseOut',\n onmouseover: 'onMouseOver',\n onmouseup: 'onMouseUp',\n onscroll: 'onScroll',\n onsubmit: 'onSubmit',\n ontouchcancel: 'onTouchCancel',\n ontouchend: 'onTouchEnd',\n ontouchmove: 'onTouchMove',\n ontouchstart: 'onTouchStart',\n onwheel: 'onWheel',\n};\n"],"mappings":";AAAA,YAAY,WAAW;;;ACAhB,IAAM,gBAAgB,CAAC,UAAuC;AAEnE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MAAM,MAAM,OAAO,EAAE,OAAwC,CAAC,KAAK,SAAiB;AACzF,UAAM,CAAC,KAAK,KAAK,IAAI,KAClB,MAAM,OAAO,EACb,IAAI,CAAC,GAAG,UAAW,UAAU,IAAI,EAAE,QAAQ,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAE;AAErE,QAAI,OAAO,OAAO;AAChB,YAAM,UAAU,IAAI,QAAQ,cAAc,CAAC,KAAK,IAAI,OAAO,GAAG,EAAE,GAAG,GAAG,YAAY,CAAC,EAAE;AACrF,UAAI,YAA6B,MAAM,KAAK;AAE5C,UAAI,CAAC,OAAO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