{"version":3,"file":"index.mjs","names":[],"sources":["../../src/shared/utils/pretty.ts","../../src/shared/utils/to-plain-text.ts","../../src/shared/utils/unstable-to-plain-text.ts","../../src/shared/error-boundary.tsx","../../src/shared/utils/strip-image-preload-links.ts","../../src/node/read-stream.ts","../../src/node/render.tsx"],"sourcesContent":["import type { Options, Plugin } from 'prettier';\nimport type { builders } from 'prettier/doc';\n\ninterface HtmlNode {\n  type?: 'element' | 'text' | 'ieConditionalComment';\n  kind?: 'element' | 'text' | 'ieConditionalComment' | 'root';\n  name?: string;\n  sourceSpan: {\n    start: { file: unknown[]; offset: number; line: number; col: number };\n    end: { file: unknown[]; offset: number; line: number; col: number };\n    details: null;\n  };\n  parent?: HtmlNode;\n}\n\nfunction getHtmlNode(path: {\n  node?: HtmlNode;\n  stack?: Array<Record<string, unknown>>;\n}) {\n  const topNode = path.node;\n  if (topNode) {\n    return topNode;\n  }\n\n  return path.stack?.[path.stack.length - 1] as unknown as HtmlNode;\n}\n\nfunction recursivelyMapDoc(\n  doc: builders.Doc,\n  callback: (innerDoc: string | builders.DocCommand) => builders.Doc,\n): builders.Doc {\n  if (Array.isArray(doc)) {\n    return doc.map((innerDoc) => recursivelyMapDoc(innerDoc, callback));\n  }\n\n  if (typeof doc === 'object') {\n    if (doc.type === 'line') {\n      return callback(doc.soft ? '' : ' ');\n    }\n\n    if (doc.type === 'group') {\n      return {\n        ...doc,\n        contents: recursivelyMapDoc(doc.contents, callback),\n        expandedStates: recursivelyMapDoc(\n          doc.expandedStates,\n          callback,\n        ) as builders.Doc[],\n      };\n    }\n\n    if ('contents' in doc) {\n      return {\n        ...doc,\n        contents: recursivelyMapDoc(doc.contents, callback),\n      };\n    }\n\n    if ('parts' in doc) {\n      return {\n        ...doc,\n        parts: recursivelyMapDoc(doc.parts, callback) as builders.Doc[],\n      };\n    }\n\n    if (doc.type === 'if-break') {\n      return {\n        ...doc,\n        breakContents: recursivelyMapDoc(doc.breakContents, callback),\n        flatContents: recursivelyMapDoc(doc.flatContents, callback),\n      };\n    }\n\n    const nextDoc = { ...doc } as Record<string, unknown>;\n    for (const [key, value] of Object.entries(nextDoc)) {\n      if (value && typeof value === 'object') {\n        nextDoc[key] = recursivelyMapDoc(value as builders.Doc, callback);\n      }\n    }\n\n    return nextDoc as unknown as builders.Doc;\n  }\n\n  return callback(doc);\n}\n\nfunction createModifiedHtmlPlugin(html: Plugin): Plugin {\n  const modifiedHtml = { ...html };\n  if (modifiedHtml.printers) {\n    const previousPrint = modifiedHtml.printers.html.print;\n    modifiedHtml.printers.html.print = (path, options, print, args) => {\n      const node = getHtmlNode(\n        path as Parameters<NonNullable<Plugin['printers']>['html']['print']>[0],\n      );\n\n      const rawPrintingResult = previousPrint(path, options, print, args);\n\n      if (\n        node?.type === 'ieConditionalComment' ||\n        node?.kind === 'ieConditionalComment'\n      ) {\n        const printingResult = recursivelyMapDoc(rawPrintingResult, (doc) => {\n          if (typeof doc === 'object' && doc.type === 'line') {\n            return doc.soft ? '' : ' ';\n          }\n\n          return doc;\n        });\n\n        return printingResult;\n      }\n\n      return rawPrintingResult;\n    };\n  }\n\n  return modifiedHtml;\n}\n\nconst importPrettier = async () => {\n  const [{ format }, html] = await Promise.all([\n    import('prettier/standalone'),\n    import('prettier/plugins/html'),\n  ]);\n\n  return { format, html: createModifiedHtmlPlugin(html as Plugin) };\n};\n\n/**\n * Prettier is only loaded the first time `pretty` is called, so importing\n * `render` doesn't load it when `pretty` is never used. This also keeps\n * bundlers that externalize `prettier` (e.g. Next.js with Turbopack) from\n * trying to resolve it at runtime unless it's actually needed.\n */\nlet prettierPromise: ReturnType<typeof importPrettier> | undefined;\n\nconst defaults: Options = {\n  endOfLine: 'lf',\n  tabWidth: 2,\n  bracketSameLine: true,\n  parser: 'html',\n};\n\nexport const pretty = async (str: string, options: Options = {}) => {\n  prettierPromise ??= importPrettier();\n  const { format, html } = await prettierPromise;\n\n  return format(str.replaceAll('\\0', ''), {\n    ...defaults,\n    plugins: [html],\n    ...options,\n  });\n};\n","import {\n  convert,\n  type HtmlToTextOptions,\n  type SelectorDefinition,\n} from 'html-to-text';\n\nexport const plainTextSelectors: SelectorDefinition[] = [\n  { selector: 'img', format: 'skip' },\n  { selector: '[data-skip-in-text=true]', format: 'skip' },\n  {\n    selector: 'a',\n    options: { linkBrackets: false, hideLinkHrefIfSameAsText: true },\n  },\n  { selector: '[data-text-format=\"dataTable\"]', format: 'dataTable' },\n];\n\nexport function toPlainText(html: string, options?: HtmlToTextOptions) {\n  return convert(html, {\n    wordwrap: false,\n    ...options,\n    selectors: [...plainTextSelectors, ...(options?.selectors ?? [])],\n  });\n}\n","import { decodeHTML, decodeHTMLAttribute } from 'entities/lib/decode.js';\nimport { type INode, type ITag, parse, SyntaxKind } from 'html5parser';\n\nconst SKIPPED_TAGS = new Set([\n  'img',\n  'noscript',\n  'script',\n  'style',\n  'template',\n]);\n\nconst WHITESPACE_RUN = /([ \\t\\n\\r\\f\\u200b]+)/;\n\n// A block prefix puts `first` before the block's content and `rest` at the\n// start of every following line: blockquote marks every line (\"> \"), a list\n// item marks the first (\" * \") and indents the rest to align nested content.\ntype BlockPrefix = { first: string; rest: string };\n\n// Everything tag-specific about how a block separates from its surroundings.\ntype Block = { open: number; close: number; prefix?: BlockPrefix };\n\n// html-to-text's default separation for the block tags implemented so far.\n// Tags absent here (and not handled in `enterNode`) are treated as inline\n// and contribute no separation — notably td/tr, which is why table cells run\n// together, matching `toPlainText` today. Only extend this alongside a spec\n// case verifying the behavior against `toPlainText`.\nconst TAG_BLOCKS: Record<string, Block> = {\n  article: { open: 2, close: 2 },\n  aside: { open: 2, close: 2 },\n  blockquote: { open: 2, close: 2, prefix: { first: '> ', rest: '> ' } },\n  div: { open: 2, close: 2 },\n  footer: { open: 2, close: 2 },\n  form: { open: 2, close: 2 },\n  h1: { open: 3, close: 2 },\n  h2: { open: 3, close: 2 },\n  h3: { open: 3, close: 2 },\n  h4: { open: 3, close: 2 },\n  h5: { open: 3, close: 2 },\n  h6: { open: 3, close: 2 },\n  header: { open: 2, close: 2 },\n  hr: { open: 2, close: 2 },\n  main: { open: 2, close: 2 },\n  nav: { open: 2, close: 2 },\n  p: { open: 2, close: 2 },\n  pre: { open: 2, close: 2 },\n  section: { open: 2, close: 2 },\n  table: { open: 2, close: 2 },\n};\n\ninterface OpenBlock {\n  block: Block;\n  text: string[];\n  leading: number;\n  stash: number;\n  space: boolean;\n}\n\ninterface OrderedList {\n  next: number;\n  prefixLength: number;\n  nested: boolean;\n}\n\ninterface WalkFrame {\n  // the element whose children this frame is iterating, or undefined at root\n  parent: ITag | undefined;\n  children: INode[];\n  index: number;\n  pre: boolean;\n  // whether this element opened a block, to be closed back on exit\n  opened: boolean;\n  // content length of the enclosing block when this element was entered;\n  // exit of an <a> reads back the text written since\n  textFrom: number;\n  orderedList: OrderedList | undefined;\n}\n\nexport function unstableToPlainText(html: string): string {\n  const tree = parse(html, { setAttributeMap: true });\n  const body = findBody(tree);\n\n  const blocks: OpenBlock[] = [\n    {\n      block: { open: 0, close: 0 },\n      text: [],\n      leading: 0,\n      stash: 0,\n      space: false,\n    },\n  ];\n  const stack: WalkFrame[] = [\n    {\n      parent: body,\n      children: body?.body ?? tree,\n      index: 0,\n      pre: false,\n      opened: false,\n      textFrom: 0,\n      orderedList: undefined,\n    },\n  ];\n\n  while (stack.length > 0) {\n    const frame = stack[stack.length - 1];\n    const node = frame.children[frame.index];\n    if (node === undefined) {\n      // children exhausted: the element ends here, the only moment its\n      // exit effects can go out — they must follow the subtree's content\n      stack.pop();\n      exitElement(frame.parent, frame);\n      continue;\n    }\n    frame.index += 1;\n    enterNode(node, frame);\n  }\n\n  function top(): OpenBlock {\n    return blocks[blocks.length - 1];\n  }\n\n  function writeWord(value: string) {\n    const block = top();\n    if (block.stash > 0) block.text.push('\\n'.repeat(block.stash));\n    else if (block.space && block.text.length > 0) block.text.push(' ');\n    block.stash = 0;\n    block.space = false;\n    block.text.push(value);\n  }\n\n  // enterNode descends into an element by pushing its frame; skipped\n  // subtrees are skipped by simply not pushing\n  function enterNode(node: INode, frame: WalkFrame) {\n    if (node.type === SyntaxKind.Text) {\n      const value = decodeHTML(node.value);\n      if (frame.pre) {\n        // whitespace is significant inside <pre>: one verbatim word,\n        // newlines and all, so it never goes through collapsing\n        if (value.length > 0) {\n          writeWord(value);\n        }\n      } else {\n        // splitting on a capturing group alternates strictly: even indices\n        // are the words, odd indices are the whitespace runs between them —\n        // so parity alone says which, no need to re-match each segment\n        const segments = value.split(WHITESPACE_RUN);\n        for (let i = 0; i < segments.length; i++) {\n          const segment = segments[i];\n          if (segment.length === 0) continue;\n          if (i % 2 === 1) {\n            top().space = true;\n          } else {\n            writeWord(segment);\n          }\n        }\n      }\n      return;\n    }\n    if (\n      SKIPPED_TAGS.has(node.name) ||\n      decodeHTMLAttribute(\n        node.attributeMap?.['data-skip-in-text']?.value?.value ?? '',\n      ) === 'true'\n    ) {\n      return;\n    }\n\n    const parentTag = frame.parent?.name;\n\n    let block: Block | undefined = TAG_BLOCKS[node.name];\n    let orderedList: OrderedList | undefined;\n    if (node.name === 'ul') {\n      // a list directly inside an <li> sits closer to its parent item:\n      // single line breaks both ways (html-to-text's isNestedList)\n      const breaks = parentTag === 'li' ? 1 : 2;\n      block = { open: breaks, close: breaks };\n    } else if (node.name === 'li' && parentTag === 'ul') {\n      // whether the enclosing list is itself nested decides the item's\n      // prefix; `frame` belongs to that list, so the list's own parent is\n      // one frame below the top of the stack\n      const grandparent = stack[stack.length - 2]?.parent;\n      const inNestedList = grandparent?.name === 'li';\n      block = {\n        open: 1,\n        close: 1,\n        prefix: inNestedList\n          ? { first: '* ', rest: '  ' }\n          : { first: ' * ', rest: '   ' },\n      };\n    } else if (node.name === 'ol') {\n      const nested = parentTag === 'li';\n      const parsedStart = Number.parseInt(\n        decodeHTMLAttribute(node.attributeMap?.start?.value?.value ?? '1'),\n        10,\n      );\n      const start = Number.isNaN(parsedStart) ? 1 : parsedStart;\n      const itemCount =\n        node.body?.filter(\n          (child) => child.type === SyntaxKind.Tag && child.name === 'li',\n        ).length ?? 0;\n      let prefixLength = 0;\n      for (let index = start; index < start + itemCount; index++) {\n        const prefix = `${nested ? '' : ' '}${index}. `;\n        prefixLength = Math.max(prefixLength, prefix.length);\n      }\n      const breaks = nested ? 1 : 2;\n      block = { open: breaks, close: breaks };\n      orderedList = { next: start, prefixLength, nested };\n    } else if (node.name === 'li' && parentTag === 'ol' && frame.orderedList) {\n      const list = frame.orderedList;\n      const prefix = `${list.nested ? '' : ' '}${list.next++}. `.padEnd(\n        list.prefixLength,\n      );\n      block = {\n        open: 1,\n        close: 1,\n        prefix: { first: prefix, rest: ' '.repeat(list.prefixLength) },\n      };\n    }\n\n    if (block) {\n      blocks.push({\n        block,\n        text: [],\n        leading: block.open,\n        stash: 0,\n        space: false,\n      });\n    }\n\n    if (node.name === 'hr') {\n      writeWord('-'.repeat(40));\n    } else if (node.name === 'br') {\n      top().space = false;\n      top().text.push('\\n');\n    }\n\n    stack.push({\n      parent: node,\n      children: node.body ?? [],\n      index: 0,\n      pre: frame.pre || node.name === 'pre',\n      opened: block !== undefined,\n      textFrom: top().text.length,\n      orderedList,\n    });\n  }\n\n  function exitElement(element: ITag | undefined, frame: WalkFrame) {\n    if (element === undefined) return;\n\n    if (element.name === 'a') {\n      const href = decodeHTMLAttribute(\n        element.attributeMap?.href?.value?.value ?? '',\n      ).replace(/^mailto:/, '');\n      // fragment-only hrefs are suppressed (html-to-text's noAnchorUrl)\n      if (href.length > 0 && !href.startsWith('#')) {\n        // the enclosing block's content doubles as the buffer of the\n        // anchor's text: what was written since the anchor opened is\n        // compared against the href to decide whether to append it\n        // (html-to-text's hideLinkHrefIfSameAsText, which `toPlainText`\n        // enables)\n        const anchorText = top().text.slice(frame.textFrom).join('');\n        if (anchorText !== href) {\n          if (anchorText.length > 0) top().space = true;\n          writeWord(href);\n        }\n      }\n    }\n\n    if (frame.opened) {\n      closeBlock();\n    }\n  }\n\n  function closeBlock() {\n    const child = blocks.pop();\n    if (child === undefined) return;\n    const parent = blocks[blocks.length - 1];\n\n    let content = child.text.join('');\n    const prefix = child.block.prefix;\n    if (prefix !== undefined) {\n      const trimmed = content.replace(/^\\n+|\\n+$/g, '');\n      content = prefix.first + trimmed.replaceAll('\\n', `\\n${prefix.rest}`);\n    }\n\n    const breaks = Math.max(parent.stash, child.leading);\n    if (parent.text.length > 0) {\n      parent.text.push('\\n'.repeat(breaks));\n      if (content.length > 0) parent.text.push(content);\n    } else {\n      // nothing to separate from yet: the separation propagates upward\n      // instead of materializing — this is edge suppression, and also how\n      // empty blocks nested in empty blocks still commit their breaks\n      if (content.length > 0) parent.text.push(content);\n      parent.leading = breaks;\n    }\n    parent.stash = Math.max(child.stash, child.block.close);\n  }\n\n  return blocks[0].text.join('');\n}\n\nfunction findBody(tree: INode[]): ITag | undefined {\n  for (const child of tree) {\n    if (child.type !== SyntaxKind.Tag || child.name !== 'html') continue;\n    for (const inner of child.body ?? []) {\n      if (inner.type === SyntaxKind.Tag && inner.name === 'body') return inner;\n    }\n  }\n  return undefined;\n}\n","import React from 'react';\n\nexport function createErrorBoundary(reject: (error: unknown) => void) {\n  // React Server Components don't support React.Component, so it's just not defined here\n  if (!React.Component) {\n    return (props: { children?: React.ReactNode }) => <>{props.children}</>;\n  }\n\n  return class ErrorBoundary extends React.Component<{\n    children: React.ReactNode;\n  }> {\n    componentDidCatch(error: unknown) {\n      reject(error);\n    }\n    render() {\n      return this.props.children;\n    }\n  };\n}\n","/**\n * React injects `<link rel=\"preload\" as=\"image\" />` resource hints into the\n * document `<head>` for every `<img>` it renders during server-side rendering.\n *\n * These hints are meant for browsers loading a web page, where they can speed\n * up the initial paint. In an email they are dead weight: email clients ignore\n * `<link rel=\"preload\">`, and the tags only add noise to the rendered HTML.\n *\n * @see https://github.com/resend/react-email/issues/3034\n *\n * This removes only those auto-injected image preload links, leaving every\n * other `<link>` (stylesheets, fonts, user-authored non-image preloads, ...)\n * untouched. It parses each `<link>` tag's attributes instead of relying on a\n * fixed string match, so it is not affected by attribute order or spacing.\n */\nexport const stripImagePreloadLinks = (html: string): string => {\n  return html.replace(/<link\\b[^>]*\\/?>/gi, (tag) =>\n    isImagePreloadLink(tag) ? '' : tag,\n  );\n};\n\nconst isImagePreloadLink = (tag: string): boolean => {\n  const attributes = parseAttributes(tag);\n  return attributes.rel === 'preload' && attributes.as === 'image';\n};\n\nconst ATTRIBUTE_PATTERN =\n  /([a-z][a-z0-9-]*)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'>]+)))?/gi;\n\n/**\n * Parses the attributes of a single, already-isolated HTML tag string (e.g.\n * `<link rel=\"preload\" as=\"image\" href=\"...\" />`) into a name → value map.\n * Attribute names are lower-cased; values are read from double, single, or\n * unquoted forms.\n */\nconst parseAttributes = (tag: string): Record<string, string> => {\n  // Skip the tag name (`<link`) so it is not read as an attribute.\n  const attributeSection = tag.replace(/^<[a-z][a-z0-9-]*/i, '');\n\n  const attributes: Record<string, string> = {};\n  for (const [\n    ,\n    name,\n    doubleQuoted,\n    singleQuoted,\n    unquoted,\n  ] of attributeSection.matchAll(ATTRIBUTE_PATTERN)) {\n    attributes[name.toLowerCase()] =\n      doubleQuoted ?? singleQuoted ?? unquoted ?? '';\n  }\n\n  return attributes;\n};\n","import { Writable } from 'node:stream';\nimport type {\n  PipeableStream,\n  ReactDOMServerReadableStream,\n} from 'react-dom/server.browser';\n\nexport const readStream = async (\n  stream: PipeableStream | ReactDOMServerReadableStream,\n) => {\n  let result = '';\n  // Create a single TextDecoder instance to handle streaming properly\n  // This fixes issues with multi-byte characters (e.g., CJK) being split across chunks\n  const decoder = new TextDecoder('utf-8');\n\n  if ('pipeTo' in stream) {\n    // means it's a readable stream\n    const writableStream = new WritableStream({\n      write(chunk: BufferSource) {\n        // Use stream: true to handle multi-byte characters split across chunks\n        result += decoder.decode(chunk, { stream: true });\n      },\n      close() {\n        // Flush any remaining bytes\n        result += decoder.decode();\n      },\n    });\n    await stream.pipeTo(writableStream);\n  } else {\n    const writable = new Writable({\n      write(chunk: BufferSource, _encoding, callback) {\n        // Use stream: true to handle multi-byte characters split across chunks\n        result += decoder.decode(chunk, { stream: true });\n\n        callback();\n      },\n      final(callback) {\n        // Flush any remaining bytes\n        result += decoder.decode();\n        callback();\n      },\n    });\n    await new Promise<void>((resolve, reject) => {\n      writable.on('pipe', (source) => {\n        source.on('error', (err: Error) => {\n          writable.destroy(err);\n        });\n      });\n      writable.on('error', reject);\n      writable.on('close', () => {\n        resolve();\n      });\n\n      stream.pipe(writable);\n    });\n  }\n\n  return result;\n};\n","import { Suspense } from 'react';\nimport { createErrorBoundary } from '../shared/error-boundary';\nimport type { Options } from '../shared/options';\nimport { pretty } from '../shared/utils/pretty';\nimport { stripImagePreloadLinks } from '../shared/utils/strip-image-preload-links';\nimport { toPlainText } from '../shared/utils/to-plain-text';\nimport { unstableToPlainText } from '../shared/utils/unstable-to-plain-text';\nimport { readStream } from './read-stream';\n\nexport const render = async (node: React.ReactNode, options?: Options) => {\n  const reactDOMServer = await import('react-dom/server').then((m) => {\n    if ('default' in m) {\n      return m.default;\n    }\n    return m;\n  });\n\n  let html!: string;\n  await new Promise<void>((resolve, reject) => {\n    if (\n      Object.hasOwn(reactDOMServer, 'renderToReadableStream') &&\n      typeof WritableStream !== 'undefined'\n    ) {\n      const ErrorBoundary = createErrorBoundary(reject);\n      reactDOMServer\n        .renderToReadableStream(\n          <ErrorBoundary>\n            <Suspense>{node}</Suspense>\n          </ErrorBoundary>,\n          {\n            progressiveChunkSize: Number.POSITIVE_INFINITY,\n            onError(error) {\n              // Throw immediately when an error occurs to prevent CSR fallback\n              reject(error);\n            },\n          },\n        )\n        .then(async (stream) => {\n          await stream.allReady;\n          return readStream(stream);\n        })\n        .then((result) => {\n          html = result;\n          resolve();\n        })\n        .catch(reject);\n    } else {\n      const ErrorBoundary = createErrorBoundary(reject);\n      const stream = reactDOMServer.renderToPipeableStream(\n        <ErrorBoundary>\n          <Suspense>{node}</Suspense>\n        </ErrorBoundary>,\n        {\n          async onAllReady() {\n            html = await readStream(stream).then((s: string) => {\n              // Workaround for https://github.com/facebook/react/pull/26228\n              // (fixed in React 19, not backported to 18)\n              return s.replaceAll('\\0', '');\n            });\n            resolve();\n          },\n          onError(error) {\n            reject(error);\n          },\n          progressiveChunkSize: Number.POSITIVE_INFINITY,\n        },\n      );\n    }\n  });\n\n  html = stripImagePreloadLinks(html);\n\n  if (options?.plainText) {\n    return options.unstableTextConversion\n      ? unstableToPlainText(html)\n      : toPlainText(html, options.htmlToTextOptions);\n  }\n\n  const doctype =\n    '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">';\n\n  const document = `${doctype}${html.replace(/<!DOCTYPE.*?>/, '')}`;\n\n  if (options?.pretty) {\n    return pretty(document);\n  }\n\n  return document;\n};\n"],"mappings":";;;;;;;AAeA,SAAS,YAAY,MAGlB;CACD,MAAM,UAAU,KAAK;AACrB,KAAI,QACF,QAAO;AAGT,QAAO,KAAK,QAAQ,KAAK,MAAM,SAAS;;AAG1C,SAAS,kBACP,KACA,UACc;AACd,KAAI,MAAM,QAAQ,IAAI,CACpB,QAAO,IAAI,KAAK,aAAa,kBAAkB,UAAU,SAAS,CAAC;AAGrE,KAAI,OAAO,QAAQ,UAAU;AAC3B,MAAI,IAAI,SAAS,OACf,QAAO,SAAS,IAAI,OAAO,KAAK,IAAI;AAGtC,MAAI,IAAI,SAAS,QACf,QAAO;GACL,GAAG;GACH,UAAU,kBAAkB,IAAI,UAAU,SAAS;GACnD,gBAAgB,kBACd,IAAI,gBACJ,SACD;GACF;AAGH,MAAI,cAAc,IAChB,QAAO;GACL,GAAG;GACH,UAAU,kBAAkB,IAAI,UAAU,SAAS;GACpD;AAGH,MAAI,WAAW,IACb,QAAO;GACL,GAAG;GACH,OAAO,kBAAkB,IAAI,OAAO,SAAS;GAC9C;AAGH,MAAI,IAAI,SAAS,WACf,QAAO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