{"version":3,"file":"index.mjs","names":["CONTENT_ASSET_EXTS"],"sources":["../../src/assets/copier.ts","../../src/assets/hasher.ts","../../src/assets/index.ts"],"sourcesContent":["import { copyFileSync, existsSync, mkdirSync, readdirSync } from \"fs\";\nimport { dirname, join, relative } from \"path\";\n\n/**\n * Copy public directory to output, preserving structure (no hashing).\n * Skips `fonts/` since those are copied to dist/assets/ and hashed.\n */\nexport function copyPublicFiles(publicDir: string, outDir: string): void {\n  if (!existsSync(publicDir)) return;\n  function walk(dir: string) {\n    for (const entry of readdirSync(dir, { withFileTypes: true })) {\n      const full = join(dir, entry.name);\n      // Skip fonts/ — they are copied to dist/assets/ and hashed\n      if (entry.isDirectory() && entry.name === \"fonts\" && dir === publicDir) continue;\n      if (entry.isDirectory()) {\n        walk(full);\n        continue;\n      }\n      const rel = relative(publicDir, full);\n      const dest = join(outDir, rel);\n      mkdirSync(dirname(dest), { recursive: true });\n      copyFileSync(full, dest);\n    }\n  }\n  walk(publicDir);\n}\n","/**\n * Demand-driven asset pipeline.\n *\n * Instead of blindly copying all content assets to dist, this:\n *   1. Hashes pre-existing dist/assets/ files (CSS, JS, fonts — already there from bundling)\n *   2. Scans generated HTML for /assets/* references\n *   3. For each referenced content asset not yet in dist, finds the source\n *      file in the content directory, copies it with a content hash\n *   4. Rewrites all HTML references to hashed paths\n *\n * Content assets are only copied if actually referenced in the output HTML.\n * Public assets (favicons, robots.txt) are handled separately by copyPublicFiles.\n */\n\nimport { createHash } from \"crypto\";\nimport {\n  existsSync,\n  mkdirSync,\n  readdirSync,\n  readFileSync,\n  renameSync,\n  rmSync,\n  writeFileSync,\n} from \"fs\";\nimport { basename, dirname, extname, join, relative } from \"path\";\n\nconst HASHABLE_EXTS = new Set([\n  \".css\",\n  \".js\",\n  \".svg\",\n  \".png\",\n  \".jpg\",\n  \".jpeg\",\n  \".gif\",\n  \".webp\",\n  \".avif\",\n  \".ico\",\n  \".woff\",\n  \".woff2\",\n  \".ttf\",\n  \".eot\",\n]);\n\nconst CONTENT_ASSET_EXTS = new Set([\n  \".svg\",\n  \".png\",\n  \".jpg\",\n  \".jpeg\",\n  \".gif\",\n  \".webp\",\n  \".avif\",\n  \".ico\",\n]);\n\nconst HASH_SUFFIX_PATTERN = /\\.[a-f0-9]{8}$/i;\n\nconst FONT_EXTS = new Set([\".woff\", \".woff2\", \".ttf\", \".eot\", \".otf\"]);\n\ntype ContentAssetLookup = {\n  byPath: Map<string, string>;\n  byBasename: Map<string, string[]>;\n};\n\nfunction normalizePath(value: string): string {\n  return value.replace(/\\\\/g, \"/\");\n}\n\n/** Build a content-relative lookup for content assets. */\nfunction buildContentAssetMap(contentDirs: string | string[]): ContentAssetLookup {\n  const dirs = Array.isArray(contentDirs) ? contentDirs : [contentDirs];\n  const byPath = new Map<string, string>();\n  const byBasename = new Map<string, string[]>();\n  for (const contentDir of dirs) {\n    function walk(dir: string) {\n      if (!existsSync(dir)) return;\n      for (const entry of readdirSync(dir, { withFileTypes: true })) {\n        const full = join(dir, entry.name);\n        if (entry.isDirectory()) {\n          walk(full);\n          continue;\n        }\n        const ext = extname(entry.name);\n        if (!CONTENT_ASSET_EXTS.has(ext)) continue;\n        if (entry.name.endsWith(\".inline.svg\")) continue;\n        const relPath = normalizePath(relative(contentDir, full));\n        byPath.set(relPath, full);\n\n        const existing = byBasename.get(entry.name);\n        if (existing) {\n          if (!existing.includes(relPath)) existing.push(relPath);\n        } else {\n          byBasename.set(entry.name, [relPath]);\n        }\n      }\n    }\n    walk(contentDir);\n  }\n  return { byPath, byBasename };\n}\n\nfunction computeHash(content: Buffer): string {\n  return createHash(\"sha256\").update(content).digest(\"hex\").slice(0, 8);\n}\n\n/**\n * Strip unnecessary metadata from SVG content for the processed output.\n * Removes XML processing instructions, comments, editor metadata elements,\n * and unnecessary namespace declarations while preserving the visual output.\n */\nfunction cleanSvgContent(content: Buffer): Buffer {\n  let svg = content.toString(\"utf-8\");\n\n  // Remove XML processing instructions (<?xml ...?>)\n  svg = svg.replace(/<\\?xml[^?]*\\?>\\s*/gi, \"\");\n\n  // Remove HTML comments (<!-- ... -->)\n  svg = svg.replace(/<!--[\\s\\S]*?-->\\s*/g, \"\");\n\n  // Remove common editor metadata elements\n  svg = svg.replace(/<metadata[\\s\\S]*?<\\/metadata>\\s*/gi, \"\");\n  svg = svg.replace(/<sodipodi:[^>]*(?:\\/>|>[\\s\\S]*?<\\/sodipodi:[^>]*>)\\s*/gi, \"\");\n  svg = svg.replace(/<inkscape:[^>]*(?:\\/>|>[\\s\\S]*?<\\/inkscape:[^>]*>)\\s*/gi, \"\");\n\n  // Remove unnecessary namespace declarations from the root <svg> tag\n  svg = svg.replace(\n    /(<svg\\b[^>]*?)\\s+xmlns:(sodipodi|inkscape|dc|cc|rdf|sketch|illustrator)=\"[^\"]*\"/gi,\n    \"$1\",\n  );\n\n  // Remove empty <defs></defs> blocks\n  svg = svg.replace(/<defs\\s*>\\s*<\\/defs>\\s*/gi, \"\");\n\n  // Collapse multiple newlines into one\n  svg = svg.replace(/\\n{3,}/g, \"\\n\\n\");\n\n  return Buffer.from(svg.trim(), \"utf-8\");\n}\n\nfunction stripHashSuffix(name: string): string {\n  return name.replace(HASH_SUFFIX_PATTERN, \"\");\n}\n\nfunction isHashedAssetFileName(fileName: string): boolean {\n  const ext = extname(fileName);\n  return HASH_SUFFIX_PATTERN.test(basename(fileName, ext));\n}\n\nfunction toLogicalAssetFileName(assetPath: string): string {\n  const ext = extname(assetPath);\n  const logicalName = `${stripHashSuffix(basename(assetPath, ext))}${ext}`;\n  const assetDir = dirname(assetPath);\n  return assetDir === \".\" ? logicalName : normalizePath(join(assetDir, logicalName));\n}\n\nfunction toHashedAssetFileName(assetPath: string, hash: string): string {\n  const ext = extname(assetPath);\n  return `${stripHashSuffix(basename(assetPath, ext))}.${hash}${ext}`;\n}\n\n/**\n * Same as `toHashedAssetFileName` but preserves the asset's directory\n * structure inside `assets/` (e.g. `fonts/foo.woff2` stays in `fonts/`).\n * Used for pre-existing bundle output (fonts, CSS-relative resources)\n * where the directory layout has meaning for url() resolution.\n */\nfunction toHashedAssetPathPreservingDir(assetPath: string, hash: string): string {\n  const hashedBase = toHashedAssetFileName(assetPath, hash);\n  const assetDir = dirname(assetPath);\n  return assetDir === \".\" ? hashedBase : normalizePath(join(assetDir, hashedBase));\n}\n\nfunction isExternalRef(ref: string): boolean {\n  return (\n    ref.startsWith(\"http:\") ||\n    ref.startsWith(\"https:\") ||\n    ref.startsWith(\"//\") ||\n    ref.startsWith(\"#\") ||\n    ref.startsWith(\"data:\") ||\n    ref.startsWith(\"mailto:\")\n  );\n}\n\nfunction resolveAssetReference(\n  ref: string,\n): { basePrefix: string; assetPath: string; suffix: string; isContentAsset: boolean } | undefined {\n  const pathname = ref.split(/[?#]/u, 1)[0] ?? ref;\n  const suffix = ref.slice(pathname.length);\n\n  if (pathname.startsWith(\"./\")) {\n    const assetPath = normalizePath(pathname.slice(2));\n    const ext = extname(pathname).toLowerCase();\n    if (!CONTENT_ASSET_EXTS.has(ext)) return undefined;\n    if (!assetPath) return undefined;\n    return { basePrefix: \"\", assetPath, suffix, isContentAsset: true };\n  }\n\n  if (!pathname.startsWith(\"/\")) return undefined;\n\n  const marker = \"/assets/\";\n  const markerIndex = pathname.indexOf(marker);\n  if (markerIndex < 0) return undefined;\n\n  const basePrefix = pathname.slice(0, markerIndex);\n  const assetPath = normalizePath(pathname.slice(markerIndex + marker.length));\n  if (!assetPath || assetPath.startsWith(\"/\")) return undefined;\n\n  return {\n    basePrefix,\n    assetPath,\n    suffix,\n    isContentAsset: CONTENT_ASSET_EXTS.has(extname(assetPath).toLowerCase()),\n  };\n}\n\nfunction toPublishedAssetUrl(basePrefix: string, assetPath: string): string {\n  return `${basePrefix}/assets/${assetPath}`.replace(/^\\/\\//, \"/\");\n}\n\nfunction listAssetFiles(dir: string, prefix = \"\"): string[] {\n  const files: string[] = [];\n  if (!existsSync(dir)) return files;\n\n  for (const entry of readdirSync(dir, { withFileTypes: true })) {\n    const relPath = prefix ? normalizePath(join(prefix, entry.name)) : entry.name;\n    const fullPath = join(dir, entry.name);\n    if (entry.isDirectory()) {\n      files.push(...listAssetFiles(fullPath, relPath));\n      continue;\n    }\n    files.push(relPath);\n  }\n\n  return files;\n}\n\n/** Remove empty directories left behind after flattening asset files. */\nfunction removeEmptyDirs(dir: string): void {\n  for (const entry of readdirSync(dir, { withFileTypes: true })) {\n    if (!entry.isDirectory()) continue;\n    const full = join(dir, entry.name);\n    removeEmptyDirs(full);\n    if (readdirSync(full).length === 0) {\n      rmSync(full, { recursive: true, force: true });\n    }\n  }\n}\n\nfunction rewriteSrcsetValue(srcset: string, rewriteRef: (ref: string) => string): string {\n  return srcset\n    .split(\",\")\n    .map((entry) => {\n      const trimmed = entry.trim();\n      if (!trimmed) return trimmed;\n      const [ref, ...descriptor] = trimmed.split(/\\s+/);\n      const rewrittenRef = rewriteRef(ref);\n      return [rewrittenRef, ...descriptor].join(\" \");\n    })\n    .join(\", \");\n}\n\n/**\n * Hash assets and rewrite HTML references.\n *\n * @param outDir - The dist output directory\n * @param contentDir - The content source directory (for finding referenced assets)\n */\nexport function hashAssets(outDir: string, contentDir: string | string[]): void {\n  const assetsDir = join(outDir, \"assets\");\n  mkdirSync(assetsDir, { recursive: true });\n\n  const renames = new Map<string, string>();\n  const contentAssets = buildContentAssetMap(contentDir);\n\n  // Phase 1: Collect and hash pre-existing files in dist/assets/ (CSS, JS, fonts)\n  const existing: Array<{ ext: string; full: string; isHashed: boolean; logicalFileName: string }> =\n    listAssetFiles(assetsDir)\n      .map((assetPath) => ({\n        ext: extname(assetPath),\n        full: join(assetsDir, assetPath),\n        isHashed: isHashedAssetFileName(assetPath),\n        logicalFileName: toLogicalAssetFileName(assetPath),\n      }))\n      .filter((asset) => HASHABLE_EXTS.has(asset.ext));\n\n  // Process already-hashed files first so fresh unhashed copies from content rebuilds win.\n  existing.sort((left, right) => Number(right.isHashed) - Number(left.isHashed));\n\n  for (const file of existing) {\n    let content: Buffer = readFileSync(file.full);\n\n    // Clean SVG files: strip unnecessary metadata from processed output\n    if (file.ext === \".svg\") {\n      content = cleanSvgContent(content);\n    }\n\n    const hash = computeHash(content);\n    // Fonts keep their `fonts/` (or other) parent directory so CSS-relative\n    // `url('fonts/x.woff2')` references in the bundled stylesheet still\n    // resolve after hashing. Other pre-existing assets stay flattened for\n    // historical compatibility (and to avoid basename collisions for\n    // content assets that happen to share the same dist staging area).\n    const hashedFileName = FONT_EXTS.has(file.ext)\n      ? toHashedAssetPathPreservingDir(file.logicalFileName, hash)\n      : toHashedAssetFileName(file.logicalFileName, hash);\n    const hashedPath = join(assetsDir, hashedFileName);\n\n    if (file.full !== hashedPath) {\n      if (existsSync(hashedPath)) {\n        rmSync(file.full, { force: true });\n      } else if (file.ext === \".svg\") {\n        // Write cleaned content then rename (original may differ)\n        writeFileSync(file.full, content);\n        renameSync(file.full, hashedPath);\n      } else {\n        renameSync(file.full, hashedPath);\n      }\n    } else if (file.ext === \".svg\") {\n      // Same path but content was cleaned\n      writeFileSync(file.full, content);\n    }\n\n    renames.set(file.logicalFileName, hashedFileName);\n  }\n\n  // Clean up empty subdirectories left after flattening\n  removeEmptyDirs(assetsDir);\n\n  // Phase 2: Scan HTML — resolve content assets on demand, rewrite all references\n  const missingAssets: string[] = [];\n\n  function rewriteAssetReference(ref: string): string {\n    if (isExternalRef(ref)) return ref;\n\n    const resolved = resolveAssetReference(ref);\n    if (!resolved) return ref;\n\n    const { assetPath, basePrefix, suffix, isContentAsset } = resolved;\n\n    // Already hashed in phase 1 (CSS, JS, fonts) or a prior HTML file\n    const already = renames.get(assetPath);\n    if (already) {\n      return `${toPublishedAssetUrl(basePrefix, already)}${suffix}`;\n    }\n\n    if (!isContentAsset) return ref;\n\n    // Check dist/assets/ first (content assets already copied there)\n    const distAsset = join(assetsDir, assetPath);\n    const sourcePath = existsSync(distAsset)\n      ? distAsset\n      : (contentAssets.byPath.get(assetPath) ??\n        (() => {\n          const fileName = basename(assetPath);\n          const candidates = contentAssets.byBasename.get(fileName);\n          if (!candidates || candidates.length !== 1) return undefined;\n          return contentAssets.byPath.get(candidates[0]);\n        })());\n    if (!sourcePath) {\n      if (!missingAssets.includes(assetPath)) missingAssets.push(assetPath);\n      return ref;\n    }\n\n    let content: Buffer = readFileSync(sourcePath);\n\n    // Clean SVG files when copying to output\n    if (extname(assetPath).toLowerCase() === \".svg\") {\n      content = cleanSvgContent(content);\n    }\n\n    const hash = computeHash(content);\n    const hashedName = toHashedAssetFileName(assetPath, hash);\n    const hashedDest = join(assetsDir, hashedName);\n\n    if (!existsSync(hashedDest)) {\n      writeFileSync(hashedDest, content);\n    }\n\n    renames.set(assetPath, hashedName);\n    return `${toPublishedAssetUrl(basePrefix, hashedName)}${suffix}`;\n  }\n\n  /**\n   * Rewrite a `url(...)` reference inside a CSS file at `cssDirRelToAssets`\n   * (relative to `<outDir>/assets/`). Resolves the relative reference into an\n   * `assets/...` logical path, looks it up in `renames`, and emits the\n   * absolute hashed URL so the CSS works regardless of where the bundler\n   * chose to emit the stylesheet.\n   */\n  function rewriteCssAssetReference(ref: string, cssDirRelToAssets: string): string {\n    if (isExternalRef(ref)) return ref;\n\n    const pathname = ref.split(/[?#]/u, 1)[0] ?? ref;\n    const suffix = ref.slice(pathname.length);\n    if (!pathname) return ref;\n\n    // Absolute /assets/... → reuse the HTML pipeline.\n    if (pathname.startsWith(\"/\")) return rewriteAssetReference(ref);\n\n    // Strip optional `./` prefix; treat any other prefix as opaque (e.g.\n    // `data:`, fragment-only refs) so we don't accidentally rewrite them.\n    const cleaned = pathname.replace(/^\\.\\//, \"\");\n    if (cleaned.startsWith(\"..\") || cleaned.includes(\":\")) return ref;\n\n    const assetPath = cssDirRelToAssets\n      ? normalizePath(`${cssDirRelToAssets}/${cleaned}`)\n      : cleaned;\n    const hashed = renames.get(assetPath);\n    if (!hashed) return ref;\n\n    // Use a relative URL pointing back to the hashed asset so the rewritten\n    // CSS keeps working regardless of `basePath`.\n    const cssDirSegments = cssDirRelToAssets ? cssDirRelToAssets.split(\"/\").length : 0;\n    const upPrefix = \"../\".repeat(cssDirSegments);\n    return `${upPrefix}${hashed}${suffix}`;\n  }\n\n  function processHtml(dir: string) {\n    for (const entry of readdirSync(dir, { withFileTypes: true })) {\n      const full = join(dir, entry.name);\n      if (entry.isDirectory()) {\n        processHtml(full);\n        continue;\n      }\n      if (!entry.name.endsWith(\".html\")) continue;\n\n      let html = readFileSync(full, \"utf-8\");\n\n      html = html.replace(\n        /\\b(src|href|data-zoom-src|data-zoom-src-light|data-zoom-src-dark)=(\"|')([^\"']*)\\2/g,\n        (match, attr: string, quote: string, ref: string) => {\n          const rewrittenRef = rewriteAssetReference(ref);\n          return rewrittenRef === ref ? match : `${attr}=${quote}${rewrittenRef}${quote}`;\n        },\n      );\n      html = html.replace(/\\bsrcset=(\"|')([^\"']*)\\1/g, (match, quote: string, srcset: string) => {\n        const rewrittenSrcset = rewriteSrcsetValue(srcset, rewriteAssetReference);\n        return rewrittenSrcset === srcset ? match : `srcset=${quote}${rewrittenSrcset}${quote}`;\n      });\n\n      writeFileSync(full, html);\n    }\n  }\n  processHtml(outDir);\n\n  // Phase 3: Rewrite `url(...)` references in CSS files so @font-face / `url()`\n  // refs land on the hashed asset names. CSS lives at `assets/<file>.<hash>.css`\n  // and originally contains relative URLs like `url('fonts/foo.woff2')` or\n  // `url('./bar.png')`. Resolve those relative to the CSS file's directory in\n  // `assets/`, look the asset up in the same `renames` map the HTML rewriter\n  // uses, and rewrite to the published hashed URL.\n  function processCss(dir: string) {\n    for (const entry of readdirSync(dir, { withFileTypes: true })) {\n      const full = join(dir, entry.name);\n      if (entry.isDirectory()) {\n        processCss(full);\n        continue;\n      }\n      if (!entry.name.endsWith(\".css\")) continue;\n\n      const css = readFileSync(full, \"utf-8\");\n      const cssDirRelToAssets = normalizePath(relative(assetsDir, dirname(full)));\n      const next = css.replace(\n        /url\\(\\s*(['\"]?)([^'\")]+)\\1\\s*\\)/g,\n        (match, quote: string, ref: string) => {\n          const rewritten = rewriteCssAssetReference(ref, cssDirRelToAssets);\n          return rewritten === ref ? match : `url(${quote}${rewritten}${quote})`;\n        },\n      );\n      if (next !== css) writeFileSync(full, next);\n    }\n  }\n  processCss(assetsDir);\n\n  if (missingAssets.length > 0) {\n    throw new Error(\n      `[pagesmith] ${missingAssets.length} referenced content asset(s) not found:\\n` +\n        missingAssets.map((a) => `  - /assets/${a}`).join(\"\\n\"),\n    );\n  }\n}\n","import { existsSync, readdirSync } from \"fs\";\nimport { extname, join, relative } from \"path\";\n\nexport { copyPublicFiles } from \"./copier\";\nexport { hashAssets } from \"./hasher\";\nexport {\n  CONVERTIBLE_IMAGE_EXTS,\n  DISPLAY_MAX_WIDTH,\n  GENERATED_IMAGE_FORMATS,\n  ZOOM_MAX_WIDTH,\n  ZOOM_VARIANT_SUFFIX,\n  emitGeneratedImageVariants,\n  getGeneratedImageVariantPath,\n  getLocalImageDimensions,\n  getZoomImageVariantPath,\n  isConvertibleImagePath,\n  renderGeneratedImageVariant,\n  renderZoomImageVariant,\n  resolveGeneratedImageSourceAssetPath,\n  resolveGeneratedImageSourcePath,\n  type GeneratedImageFormat,\n  type LocalImageDimensions,\n} from \"./images\";\n\n/** File extensions recognized as content companion assets. */\nexport const CONTENT_ASSET_EXTS = new Set([\n  \".svg\",\n  \".png\",\n  \".jpg\",\n  \".jpeg\",\n  \".gif\",\n  \".webp\",\n  \".avif\",\n  \".ico\",\n]);\n\n/**\n * Directory-preserving companion asset map.\n *\n * Assets are keyed by their relative path from the content root\n * (e.g., `\"articles/foo/diagram.svg\"`), which prevents basename\n * collisions when multiple content entries share generic filenames.\n */\nexport type ContentAssetMap = {\n  /** Relative path from content root → absolute source path */\n  byPath: Map<string, string>;\n  /** Original basename → relative paths (for rewrite lookup) */\n  byBasename: Map<string, string[]>;\n};\n\nfunction normalizeAssetPathKey(path: string): string {\n  return path.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Walk content directories and collect companion asset files (images, SVGs, etc.)\n * keyed by their relative path from each content root.\n */\nexport function collectContentAssets(contentDirs: string[]): ContentAssetMap {\n  const byPath = new Map<string, string>();\n  const byBasename = new Map<string, string[]>();\n\n  for (const contentDir of contentDirs) {\n    if (!existsSync(contentDir)) continue;\n\n    function walk(dir: string): void {\n      const entries = readdirSync(dir, { withFileTypes: true }).sort((left, right) =>\n        left.name.localeCompare(right.name),\n      );\n\n      for (const entry of entries) {\n        if (entry.name.startsWith(\".\")) continue;\n        const fullPath = join(dir, entry.name);\n        if (entry.isDirectory()) {\n          walk(fullPath);\n          continue;\n        }\n        const ext = extname(entry.name).toLowerCase();\n        if (!CONTENT_ASSET_EXTS.has(ext)) continue;\n\n        const relPath = normalizeAssetPathKey(relative(contentDir, fullPath));\n\n        if (byPath.has(relPath) && byPath.get(relPath) !== fullPath) {\n          throw new Error(\n            `pagesmith duplicate companion asset path \"${relPath}\" across content directories: ${byPath.get(relPath)} and ${fullPath}`,\n          );\n        }\n        byPath.set(relPath, fullPath);\n\n        const existing = byBasename.get(entry.name);\n        if (existing) {\n          if (!existing.includes(relPath)) existing.push(relPath);\n        } else {\n          byBasename.set(entry.name, [relPath]);\n        }\n      }\n    }\n\n    walk(contentDir);\n  }\n\n  for (const candidates of byBasename.values()) {\n    candidates.sort((left, right) => left.localeCompare(right));\n  }\n\n  return { byPath, byBasename };\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,gBAAgB,WAAmB,QAAsB;CACvE,IAAI,CAAC,WAAW,SAAS,GAAG;CAC5B,SAAS,KAAK,KAAa;EACzB,KAAK,MAAM,SAAS,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,GAAG;GAC7D,MAAM,OAAO,KAAK,KAAK,MAAM,IAAI;GAEjC,IAAI,MAAM,YAAY,KAAK,MAAM,SAAS,WAAW,QAAQ,WAAW;GACxE,IAAI,MAAM,YAAY,GAAG;IACvB,KAAK,IAAI;IACT;GACF;GAEA,MAAM,OAAO,KAAK,QADN,SAAS,WAAW,IACJ,CAAC;GAC7B,UAAU,QAAQ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