{"version":3,"file":"index.cjs","names":["RE2JS","Decoration","DecorationSet","PluginKey","Plugin","TextSelection","Extension"],"sources":["../src/state/debounced-search-state.ts","../src/constants/constants.ts","../src/style/create-style-tag.ts","../src/style/style.ts","../src/search/regex.ts","../src/search/matches.ts","../src/search/text-segments.ts","../src/search/textblock-search.ts","../src/search/search.ts","../src/utils/createDecoration.ts","../src/utils/createDecorations.ts","../src/utils/createState.ts","../src/utils/hasCurrentIndex.ts","../src/utils/findDecorations.ts","../src/utils/sameResult.ts","../src/utils/isCurrentResult.ts","../src/utils/resultInTextblocks.ts","../src/utils/shouldRefreshResult.ts","../src/utils/getResultsToRefresh.ts","../src/utils/refreshDecorations.ts","../src/utils/normalizeCurrentIndex.ts","../src/utils/getMetaCurrentIndex.ts","../src/utils/getFallbackCurrentIndex.ts","../src/utils/getPreviousCurrentResult.ts","../src/utils/getMappedCurrentIndex.ts","../src/utils/isNewSearch.ts","../src/utils/getSearchCurrentIndex.ts","../src/utils/resolveCurrentIndex.ts","../src/utils/refreshCurrentIndexState.ts","../src/utils/getChangedTextblocks.ts","../src/utils/mapResult.ts","../src/utils/mapResults.ts","../src/utils/mergeResults.ts","../src/utils/refreshDocumentState.ts","../src/utils/refreshState.ts","../src/utils/touchesSearch.ts","../src/utils/updateState.ts","../src/plugin/plugin.ts","../src/utils/getTextNodeResult.ts","../src/utils/groupResults.ts","../src/utils/replaceGroup.ts","../src/utils/replaceAllResults.ts","../src/find-and-replace.ts","../src/index.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\n\nexport interface DebouncedSearchState {\n  timeout: ReturnType<typeof setTimeout> | null\n  pendingTerm: string | null\n}\n\nconst debouncedSearchState = new WeakMap<Editor, DebouncedSearchState>()\n\nexport function getDebouncedSearchState(editor: Editor): DebouncedSearchState {\n  const existingState = debouncedSearchState.get(editor)\n\n  if (existingState) {\n    return existingState\n  }\n\n  const nextState: DebouncedSearchState = {\n    timeout: null,\n    pendingTerm: null,\n  }\n\n  debouncedSearchState.set(editor, nextState)\n\n  return nextState\n}\n\nexport function clearDebouncedSearchState(editor: Editor): void {\n  const state = debouncedSearchState.get(editor)\n\n  if (!state) {\n    return\n  }\n\n  if (state.timeout !== null) {\n    clearTimeout(state.timeout)\n  }\n\n  debouncedSearchState.delete(editor)\n}\n","export const resultClass = 'find-and-replace-result'\nexport const currentResultClass = 'find-and-replace-result-current'\n","export const createStyleTag = (style: string, nonce?: string): HTMLStyleElement => {\n  const existing = document.querySelector<HTMLStyleElement>(\n    'style[data-tiptap-extension-find-and-replace-style]',\n  )\n\n  if (existing !== null) {\n    return existing\n  }\n\n  const styleNode = document.createElement('style')\n\n  if (nonce) {\n    styleNode.setAttribute('nonce', nonce)\n  }\n\n  styleNode.setAttribute('data-tiptap-extension-find-and-replace-style', '')\n  styleNode.textContent = style\n  document.getElementsByTagName('head')[0].appendChild(styleNode)\n\n  return styleNode\n}\n\nexport default createStyleTag\n","export const style = `.find-and-replace-result {\n  background-color: rgb(255 225 0 / 0.4);\n}\n\n.find-and-replace-result-current {\n  background-color: rgb(255 165 0 / 0.55);\n}\n`\n\nexport default style\n","import { RE2JS } from 're2js'\n\nimport type { SearchOptions } from './types.js'\n\nexport type SearchRegex = RegExp | RE2JS\n\nconst escapeRegExp = (value: string): string => {\n  return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/** Unicode word characters like letters, accents, numbers, and underscore-like punctuation. */\nconst unicodeWordCharacter = '[\\\\p{L}\\\\p{M}\\\\p{N}\\\\p{Pc}]'\n\nfunction compileNativeRegex(source: string, caseSensitive: boolean): RegExp | null {\n  try {\n    return new RegExp(source, caseSensitive ? 'gu' : 'giu')\n  } catch {\n    return null\n  }\n}\n\nfunction compileSafeRegex(source: string, caseSensitive: boolean): RE2JS | null {\n  try {\n    const flags = caseSensitive ? 0 : RE2JS.CASE_INSENSITIVE\n\n    return RE2JS.compile(source, flags)\n  } catch {\n    return null\n  }\n}\n\nfunction compileRegex(\n  source: string,\n  options: Pick<SearchOptions, 'caseSensitive' | 'useRegex'>,\n): SearchRegex | null {\n  return options.useRegex\n    ? compileSafeRegex(source, options.caseSensitive)\n    : compileNativeRegex(source, options.caseSensitive)\n}\n\n/**\n * Creates a search matcher for a term.\n * Regex mode uses RE2-compatible syntax to avoid catastrophic backtracking.\n * @param term The search term, treated as regex source when `useRegex` is enabled.\n * @param options Case sensitivity, regex mode, and whole word matching.\n * @returns A compiled matcher, or `null` when the term is invalid or unsupported.\n */\nexport function createSearchRegex(term: string, options: SearchOptions): SearchRegex | null {\n  if (!term) {\n    return null\n  }\n\n  let source: string\n\n  if (options.useRegex) {\n    source = term\n  } else {\n    const escaped = escapeRegExp(term)\n\n    // Whole-word searches reject terms next to another Unicode word character.\n    source = options.wholeWord\n      ? `(?<!${unicodeWordCharacter})${escaped}(?!${unicodeWordCharacter})`\n      : escaped\n  }\n\n  return compileRegex(source, options)\n}\n","import { RE2JS } from 're2js'\n\nimport type { SearchRegex } from './regex.js'\n\ninterface TextMatch {\n  index: number\n  value: string\n}\n\nfunction* findNativeMatches(regex: RegExp, text: string): Generator<TextMatch> {\n  for (const match of text.matchAll(regex)) {\n    yield { index: match.index, value: match[0] }\n  }\n}\n\nfunction* findSafeMatches(regex: RE2JS, text: string): Generator<TextMatch> {\n  const matcher = regex.matcher(text)\n\n  while (matcher.find()) {\n    yield { index: matcher.start(), value: matcher.group() ?? '' }\n  }\n}\n\nexport function findMatches(regex: SearchRegex, text: string): Generator<TextMatch> {\n  return regex instanceof RegExp ? findNativeMatches(regex, text) : findSafeMatches(regex, text)\n}\n","import type { Node } from '@tiptap/pm/model'\n\ninterface TextSegment {\n  isText: boolean\n  pos: number\n  length: number\n  text: string\n  textOffset: number\n}\n\n// Non-text inline nodes (hard break, mention, ...) contribute a placeholder\n// so matches never silently span across them.\nexport function getTextSegments(textblock: Node, pos: number): TextSegment[] {\n  const segments: TextSegment[] = []\n  let textOffset = 0\n\n  textblock.forEach((child, offset) => {\n    const text = child.isText ? (child.text ?? '') : '\\n'\n\n    segments.push({\n      isText: child.isText,\n      pos: pos + 1 + offset,\n      length: child.nodeSize,\n      text,\n      textOffset,\n    })\n    textOffset += text.length\n  })\n\n  return segments\n}\n\nfunction findOffsetSegment(segments: TextSegment[], offset: number): TextSegment | undefined {\n  let low = 0\n  let high = segments.length\n\n  while (low < high) {\n    const middle = Math.floor((low + high) / 2)\n    const segment = segments[middle]\n    const segmentEnd = segment.textOffset + segment.text.length\n\n    if (offset < segmentEnd) {\n      high = middle\n    } else {\n      low = middle + 1\n    }\n  }\n\n  return segments[low] ?? segments.at(-1)\n}\n\nexport function offsetToPos(segments: TextSegment[], offset: number): number {\n  const segment = findOffsetSegment(segments, offset)\n\n  return segment ? segment.pos + Math.min(offset - segment.textOffset, segment.length) : 0\n}\n\nexport function overlapsNonTextSegment(segments: TextSegment[], from: number, to: number): boolean {\n  return segments.some(\n    segment =>\n      !segment.isText && from < segment.textOffset + segment.text.length && to > segment.textOffset,\n  )\n}\n","import type { Node } from '@tiptap/pm/model'\n\nimport { findMatches } from './matches.js'\nimport type { SearchRegex } from './regex.js'\nimport { getTextSegments, offsetToPos, overlapsNonTextSegment } from './text-segments.js'\nimport type { SearchResult } from './types.js'\n\nexport function searchTextblock(regex: SearchRegex, textblock: Node, pos: number): SearchResult[] {\n  const segments = getTextSegments(textblock, pos)\n  const text = segments.map(segment => segment.text).join('')\n  const results: SearchResult[] = []\n\n  for (const match of findMatches(regex, text)) {\n    if (match.value.length === 0) {\n      continue\n    }\n\n    const matchEnd = match.index + match.value.length\n\n    if (overlapsNonTextSegment(segments, match.index, matchEnd)) {\n      continue\n    }\n\n    results.push({\n      from: offsetToPos(segments, match.index),\n      to: offsetToPos(segments, matchEnd),\n    })\n  }\n\n  return results\n}\n","import type { Node } from '@tiptap/pm/model'\n\nimport { createSearchRegex } from './regex.js'\nimport { searchTextblock } from './textblock-search.js'\nimport type { SearchOptions, SearchResult, TextblockSearchTarget } from './types.js'\n\nexport type { SearchOptions, SearchResult, TextblockSearchTarget } from './types.js'\nexport { createSearchRegex } from './regex.js'\n\n/**\n * Searches textblocks for a term and returns their matched ranges.\n * @param textblocks The textblocks and their document positions.\n * @param term The search term, treated as regex source when `useRegex` is enabled.\n * @param options Case sensitivity, regex mode, and whole word matching.\n * @returns The list of matched ranges in textblock order.\n */\nexport function searchTextblocks(\n  textblocks: readonly TextblockSearchTarget[],\n  term: string,\n  options: SearchOptions,\n): SearchResult[] {\n  const regex = createSearchRegex(term, options)\n\n  if (!regex) {\n    return []\n  }\n\n  return textblocks.flatMap(({ node, pos }) => searchTextblock(regex, node, pos))\n}\n\n/**\n * Searches all textblocks of a document for a term and returns the matched ranges.\n * Matches may span multiple text nodes (e.g. across marks), but never leave a textblock.\n * @param doc The document to search in.\n * @param term The search term, treated as regex source when `useRegex` is enabled.\n * @param options Case sensitivity, regex mode, and whole word matching.\n * @returns The list of matched ranges in document order.\n */\nexport function searchDocument(doc: Node, term: string, options: SearchOptions): SearchResult[] {\n  const textblocks: TextblockSearchTarget[] = []\n\n  doc.descendants((node, pos) => {\n    if (!node.isTextblock) {\n      return true\n    }\n\n    textblocks.push({ node, pos })\n\n    return false\n  })\n\n  return searchTextblocks(textblocks, term, options)\n}\n\n/**\n * Finds the index of the first result at or after a position, wrapping around\n * to the first result when the position is behind the last result.\n * @param results The current search results.\n * @param from The position to search from.\n * @returns The result index, or `null` when there are no results.\n */\nexport function findNextIndex(results: SearchResult[], from: number): number | null {\n  if (results.length === 0) {\n    return null\n  }\n\n  const index = results.findIndex(result => result.from >= from)\n\n  return index === -1 ? 0 : index\n}\n","import { Decoration } from '@tiptap/pm/view'\n\nimport { currentResultClass, resultClass } from '../constants/constants.js'\nimport type { SearchResult } from '../search/search.js'\n\nexport function createDecoration(\n  result: SearchResult,\n  currentIndex: number | null,\n  index: number,\n): Decoration {\n  const className = index === currentIndex ? `${resultClass} ${currentResultClass}` : resultClass\n\n  return Decoration.inline(result.from, result.to, { class: className })\n}\n","import type { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport type { SearchResult } from '../search/search.js'\n\nimport { createDecoration } from './createDecoration.js'\n\nexport function createDecorations(\n  doc: Node,\n  results: SearchResult[],\n  currentIndex: number | null,\n): DecorationSet {\n  const decorations = results.map((result, index) => createDecoration(result, currentIndex, index))\n\n  return DecorationSet.create(doc, decorations)\n}\n","import type { Node } from '@tiptap/pm/model'\n\nimport type { FindAndReplaceOptions } from '../types.js'\nimport type { FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport { searchDocument } from '../search/search.js'\n\nimport { createDecorations } from './createDecorations.js'\n\nexport function createState(doc: Node, options: FindAndReplaceOptions): FindAndReplacePluginState {\n  const results = searchDocument(doc, options.searchTerm, options)\n  const currentIndex = results.length > 0 ? 0 : null\n\n  return {\n    searchTerm: options.searchTerm,\n    replaceTerm: options.replaceTerm,\n    caseSensitive: options.caseSensitive,\n    useRegex: options.useRegex,\n    wholeWord: options.wholeWord,\n    results,\n    currentIndex,\n    decorations: createDecorations(doc, results, currentIndex),\n  }\n}\n","import type { FindAndReplaceMeta } from '../plugin/plugin-state.js'\n\nexport function hasCurrentIndex(meta: FindAndReplaceMeta | undefined): boolean {\n  return !!meta && 'currentIndex' in meta\n}\n","import { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nimport type { SearchResult } from '../search/search.js'\n\nimport type { TextblockRange } from './types.js'\n\nexport function findDecorations(\n  decorations: DecorationSet,\n  results: readonly SearchResult[],\n  textblocks: readonly TextblockRange[],\n): Decoration[] {\n  const found = new Set<Decoration>()\n\n  textblocks.forEach(textblock => {\n    decorations.find(textblock.from, textblock.to).forEach(decoration => found.add(decoration))\n  })\n\n  results.forEach(result => {\n    decorations\n      .find(result.from, result.to)\n      .filter(decoration => {\n        return decoration.from === result.from && decoration.to === result.to\n      })\n      .forEach(decoration => found.add(decoration))\n  })\n\n  return [...found]\n}\n","import type { SearchResult } from '../search/search.js'\n\nexport function sameResult(first: SearchResult, second: SearchResult): boolean {\n  return first.from === second.from && first.to === second.to\n}\n","import type { SearchResult } from '../search/search.js'\n\nimport { sameResult } from './sameResult.js'\n\nexport function isCurrentResult(result: SearchResult, current: SearchResult | null): boolean {\n  return current !== null && sameResult(result, current)\n}\n","import type { SearchResult } from '../search/search.js'\n\nimport type { TextblockRange } from './types.js'\n\nexport function resultInTextblocks(\n  result: SearchResult,\n  textblocks: readonly TextblockRange[],\n): boolean {\n  let start = 0\n  let end = textblocks.length - 1\n\n  while (start <= end) {\n    const index = Math.floor((start + end) / 2)\n    const textblock = textblocks[index]\n\n    if (result.from < textblock.from) {\n      end = index - 1\n      continue\n    }\n\n    if (result.to > textblock.to) {\n      start = index + 1\n      continue\n    }\n\n    return true\n  }\n\n  return false\n}\n","import type { SearchResult } from '../search/search.js'\n\nimport { isCurrentResult } from './isCurrentResult.js'\nimport { resultInTextblocks } from './resultInTextblocks.js'\nimport type { TextblockRange } from './types.js'\n\nexport function shouldRefreshResult(\n  result: SearchResult,\n  textblocks: readonly TextblockRange[],\n  previousCurrent: SearchResult | null,\n  current: SearchResult | null,\n): boolean {\n  return (\n    resultInTextblocks(result, textblocks) ||\n    isCurrentResult(result, previousCurrent) ||\n    isCurrentResult(result, current)\n  )\n}\n","import type { SearchResult } from '../search/search.js'\n\nimport { shouldRefreshResult } from './shouldRefreshResult.js'\nimport type { IndexedResult, TextblockRange } from './types.js'\n\nexport function getResultsToRefresh(\n  results: SearchResult[],\n  textblocks: readonly TextblockRange[],\n  previousCurrent: SearchResult | null,\n  currentIndex: number | null,\n): IndexedResult[] {\n  const current = currentIndex === null ? null : (results[currentIndex] ?? null)\n  const refreshedResults: IndexedResult[] = []\n\n  results.forEach((result, index) => {\n    if (shouldRefreshResult(result, textblocks, previousCurrent, current)) {\n      refreshedResults.push({ result, index })\n    }\n  })\n\n  return refreshedResults\n}\n","import type { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport type { SearchResult } from '../search/search.js'\n\nimport { createDecoration } from './createDecoration.js'\nimport { findDecorations } from './findDecorations.js'\nimport { getResultsToRefresh } from './getResultsToRefresh.js'\nimport type { TextblockRange } from './types.js'\n\nexport function refreshDecorations(\n  decorations: DecorationSet,\n  doc: Node,\n  results: SearchResult[],\n  currentIndex: number | null,\n  textblocks: readonly TextblockRange[],\n  previousCurrent: SearchResult | null,\n): DecorationSet {\n  const resultsToRefresh = getResultsToRefresh(results, textblocks, previousCurrent, currentIndex)\n  const refreshedResults = resultsToRefresh.map(({ result }) => result)\n  const staleResults = previousCurrent ? [...refreshedResults, previousCurrent] : refreshedResults\n  const decorationsToRemove = findDecorations(decorations, staleResults, textblocks)\n  const decorationsToAdd = resultsToRefresh.map(({ result, index }) => {\n    return createDecoration(result, currentIndex, index)\n  })\n\n  return decorations.remove(decorationsToRemove).add(doc, decorationsToAdd)\n}\n","export function normalizeCurrentIndex(\n  currentIndex: number | null | undefined,\n  length: number,\n): number | null {\n  if (currentIndex === undefined || currentIndex === null || length === 0) {\n    return null\n  }\n\n  return Math.max(0, Math.min(currentIndex, length - 1))\n}\n","import type { FindAndReplaceMeta } from '../plugin/plugin-state.js'\n\nimport { hasCurrentIndex } from './hasCurrentIndex.js'\nimport { normalizeCurrentIndex } from './normalizeCurrentIndex.js'\n\nexport function getMetaCurrentIndex(\n  meta: FindAndReplaceMeta | undefined,\n  length: number,\n): number | null | undefined {\n  if (!meta) {\n    return undefined\n  }\n\n  if (!hasCurrentIndex(meta)) {\n    return undefined\n  }\n\n  return normalizeCurrentIndex(meta.currentIndex, length)\n}\n","import type { FindAndReplacePluginState } from '../plugin/plugin-state.js'\n\nexport function getFallbackCurrentIndex(\n  previousState: FindAndReplacePluginState,\n  length: number,\n): number {\n  return previousState.currentIndex === null ? 0 : Math.min(previousState.currentIndex, length - 1)\n}\n","import type { FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport type { SearchResult } from '../search/search.js'\n\nexport function getPreviousCurrentResult(\n  previousState: FindAndReplacePluginState,\n): SearchResult | undefined {\n  return previousState.currentIndex === null\n    ? undefined\n    : previousState.results[previousState.currentIndex]\n}\n","import type { Mapping } from '@tiptap/pm/transform'\n\nimport type { FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport type { SearchResult } from '../search/search.js'\nimport { findNextIndex } from '../search/search.js'\n\nimport { getPreviousCurrentResult } from './getPreviousCurrentResult.js'\n\nexport function getMappedCurrentIndex(\n  previousState: FindAndReplacePluginState,\n  results: SearchResult[],\n  docChanged: boolean,\n  mapping: Mapping | undefined,\n): number | null | undefined {\n  if (!docChanged) {\n    return undefined\n  }\n\n  if (!mapping) {\n    return undefined\n  }\n\n  const previousResult = getPreviousCurrentResult(previousState)\n\n  if (!previousResult) {\n    return undefined\n  }\n\n  const mappedFrom = mapping.map(previousResult.from, 1)\n\n  return findNextIndex(results, mappedFrom)\n}\n","import type { FindAndReplaceMeta } from '../plugin/plugin-state.js'\n\nexport function isNewSearch(meta: FindAndReplaceMeta | undefined): boolean {\n  return !!meta && 'searchTerm' in meta\n}\n","import type { Mapping } from '@tiptap/pm/transform'\n\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport type { SearchResult } from '../search/search.js'\n\nimport { getFallbackCurrentIndex } from './getFallbackCurrentIndex.js'\nimport { getMappedCurrentIndex } from './getMappedCurrentIndex.js'\nimport { isNewSearch } from './isNewSearch.js'\n\nexport function getSearchCurrentIndex(\n  previousState: FindAndReplacePluginState,\n  results: SearchResult[],\n  meta: FindAndReplaceMeta | undefined,\n  docChanged: boolean,\n  mapping: Mapping | undefined,\n): number {\n  if (isNewSearch(meta)) {\n    return 0\n  }\n\n  const mappedIndex = getMappedCurrentIndex(previousState, results, docChanged, mapping)\n\n  return mappedIndex ?? getFallbackCurrentIndex(previousState, results.length)\n}\n","import type { Mapping } from '@tiptap/pm/transform'\n\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport type { SearchResult } from '../search/search.js'\n\nimport { getMetaCurrentIndex } from './getMetaCurrentIndex.js'\nimport { getSearchCurrentIndex } from './getSearchCurrentIndex.js'\n\nexport function resolveCurrentIndex(\n  previousState: FindAndReplacePluginState,\n  results: SearchResult[],\n  meta: FindAndReplaceMeta | undefined,\n  docChanged: boolean,\n  mapping: Mapping | undefined,\n): number | null {\n  if (results.length === 0) {\n    return null\n  }\n\n  const metaIndex = getMetaCurrentIndex(meta, results.length)\n\n  if (metaIndex !== undefined) {\n    return metaIndex\n  }\n\n  return getSearchCurrentIndex(previousState, results, meta, docChanged, mapping)\n}\n","import type { Node } from '@tiptap/pm/model'\n\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from '../plugin/plugin-state.js'\n\nimport { refreshDecorations } from './refreshDecorations.js'\nimport { resolveCurrentIndex } from './resolveCurrentIndex.js'\n\nexport function refreshCurrentIndexState(\n  previousState: FindAndReplacePluginState,\n  state: FindAndReplacePluginState,\n  doc: Node,\n  meta: FindAndReplaceMeta | undefined,\n): FindAndReplacePluginState {\n  const currentIndex = resolveCurrentIndex(previousState, state.results, meta, false, undefined)\n  const previousCurrent =\n    previousState.currentIndex === null ? null : previousState.results[previousState.currentIndex]\n\n  return {\n    ...state,\n    currentIndex,\n    decorations: refreshDecorations(\n      previousState.decorations,\n      doc,\n      state.results,\n      currentIndex,\n      [],\n      previousCurrent,\n    ),\n  }\n}\n","import type { Node } from '@tiptap/pm/model'\nimport type { Mapping } from '@tiptap/pm/transform'\n\nimport type { TextblockRange } from './types.js'\n\nexport function getChangedTextblocks(doc: Node, mapping: Mapping): TextblockRange[] {\n  const textblocks = new Map<number, TextblockRange>()\n\n  mapping.maps.forEach((stepMap, index) => {\n    const remaining = mapping.slice(index + 1)\n\n    stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {\n      const from = Math.max(0, remaining.map(newStart, -1) - 1)\n      const to = Math.min(doc.content.size, remaining.map(newEnd, 1) + 1)\n\n      doc.nodesBetween(from, to, (node, pos) => {\n        if (!node.isTextblock) {\n          return true\n        }\n\n        textblocks.set(pos, { node, pos, from: pos, to: pos + node.nodeSize })\n\n        return false\n      })\n    })\n  })\n\n  return [...textblocks.values()].sort((first, second) => first.pos - second.pos)\n}\n","import type { Mapping } from '@tiptap/pm/transform'\n\nimport type { SearchResult } from '../search/search.js'\n\nexport function mapResult(result: SearchResult, mapping: Mapping): SearchResult | null {\n  const from = mapping.map(result.from, 1)\n  const to = mapping.map(result.to, -1)\n\n  return from < to ? { from, to } : null\n}\n","import type { Mapping } from '@tiptap/pm/transform'\n\nimport type { SearchResult } from '../search/search.js'\n\nimport { mapResult } from './mapResult.js'\n\nexport function mapResults(results: SearchResult[], mapping: Mapping): SearchResult[] {\n  const mappedResults: SearchResult[] = []\n\n  results.forEach(result => {\n    const mapped = mapResult(result, mapping)\n\n    if (mapped) {\n      mappedResults.push(mapped)\n    }\n  })\n\n  return mappedResults\n}\n","import type { SearchResult } from '../search/search.js'\n\nexport function mergeResults(first: SearchResult[], second: SearchResult[]): SearchResult[] {\n  const results: SearchResult[] = []\n  let firstIndex = 0\n  let secondIndex = 0\n\n  while (firstIndex < first.length && secondIndex < second.length) {\n    if (first[firstIndex].from < second[secondIndex].from) {\n      results.push(first[firstIndex++])\n      continue\n    }\n\n    results.push(second[secondIndex++])\n  }\n\n  return results.concat(first.slice(firstIndex), second.slice(secondIndex))\n}\n","import type { Node } from '@tiptap/pm/model'\nimport type { Mapping } from '@tiptap/pm/transform'\n\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport { searchTextblocks } from '../search/search.js'\n\nimport { getChangedTextblocks } from './getChangedTextblocks.js'\nimport { mapResult } from './mapResult.js'\nimport { mapResults } from './mapResults.js'\nimport { mergeResults } from './mergeResults.js'\nimport { refreshDecorations } from './refreshDecorations.js'\nimport { resolveCurrentIndex } from './resolveCurrentIndex.js'\nimport { resultInTextblocks } from './resultInTextblocks.js'\n\nexport function refreshDocumentState(\n  previousState: FindAndReplacePluginState,\n  state: FindAndReplacePluginState,\n  doc: Node,\n  meta: FindAndReplaceMeta | undefined,\n  mapping: Mapping,\n): FindAndReplacePluginState {\n  const textblocks = getChangedTextblocks(doc, mapping)\n  const mappedResults = mapResults(previousState.results, mapping)\n  const unaffectedResults = mappedResults.filter(result => !resultInTextblocks(result, textblocks))\n  const changedResults = searchTextblocks(textblocks, state.searchTerm, state)\n  const results = mergeResults(unaffectedResults, changedResults)\n  const currentIndex = resolveCurrentIndex(previousState, results, meta, true, mapping)\n  const previousCurrent =\n    previousState.currentIndex === null\n      ? null\n      : mapResult(previousState.results[previousState.currentIndex], mapping)\n  const decorations = previousState.decorations.map(mapping, doc)\n\n  return {\n    ...state,\n    results,\n    currentIndex,\n    decorations: refreshDecorations(\n      decorations,\n      doc,\n      results,\n      currentIndex,\n      textblocks,\n      previousCurrent,\n    ),\n  }\n}\n","import type { Node } from '@tiptap/pm/model'\nimport type { Mapping } from '@tiptap/pm/transform'\n\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from '../plugin/plugin-state.js'\nimport { searchDocument } from '../search/search.js'\n\nimport { createDecorations } from './createDecorations.js'\nimport { resolveCurrentIndex } from './resolveCurrentIndex.js'\n\nexport function refreshState(\n  previousState: FindAndReplacePluginState,\n  state: FindAndReplacePluginState,\n  doc: Node,\n  meta: FindAndReplaceMeta | undefined,\n  docChanged: boolean,\n  mapping: Mapping | undefined,\n): FindAndReplacePluginState {\n  const results = searchDocument(doc, state.searchTerm, state)\n  const currentIndex = resolveCurrentIndex(previousState, results, meta, docChanged, mapping)\n\n  return {\n    ...state,\n    results,\n    currentIndex,\n    decorations: createDecorations(doc, results, currentIndex),\n  }\n}\n","import type { FindAndReplaceMeta } from '../plugin/plugin-state.js'\n\nconst searchKeys = ['searchTerm', 'caseSensitive', 'useRegex', 'wholeWord'] as const\n\nexport function touchesSearch(meta: FindAndReplaceMeta | undefined): boolean {\n  return !!meta && searchKeys.some(key => key in meta)\n}\n","import type { Node } from '@tiptap/pm/model'\nimport type { Mapping } from '@tiptap/pm/transform'\n\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from '../plugin/plugin-state.js'\n\nimport { hasCurrentIndex } from './hasCurrentIndex.js'\nimport { refreshCurrentIndexState } from './refreshCurrentIndexState.js'\nimport { refreshDocumentState } from './refreshDocumentState.js'\nimport { refreshState } from './refreshState.js'\nimport { touchesSearch } from './touchesSearch.js'\n\nexport function updateState(\n  previousState: FindAndReplacePluginState,\n  state: FindAndReplacePluginState,\n  doc: Node,\n  meta: FindAndReplaceMeta | undefined,\n  docChanged: boolean,\n  mapping: Mapping,\n): FindAndReplacePluginState {\n  if (touchesSearch(meta)) {\n    return refreshState(previousState, state, doc, meta, docChanged, mapping)\n  }\n\n  if (docChanged) {\n    return refreshDocumentState(previousState, state, doc, meta, mapping)\n  }\n\n  if (hasCurrentIndex(meta)) {\n    return refreshCurrentIndexState(previousState, state, doc, meta)\n  }\n\n  return state\n}\n","import { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { currentResultClass, resultClass } from '../constants/constants.js'\nimport { createStyleTag } from '../style/create-style-tag.js'\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from './plugin-state.js'\nimport { style } from '../style/style.js'\nimport type { FindAndReplaceOptions } from '../types.js'\nimport { createState, updateState } from '../utils/index.js'\n\nexport { currentResultClass, resultClass }\nexport type { FindAndReplaceMeta, FindAndReplacePluginState }\n\nexport const FindAndReplacePluginKey = new PluginKey<FindAndReplacePluginState>('findAndReplace')\n\nexport const FindAndReplacePlugin = (\n  options: FindAndReplaceOptions,\n  onCreate: (pluginState: FindAndReplacePluginState) => void,\n) => {\n  return new Plugin<FindAndReplacePluginState>({\n    key: FindAndReplacePluginKey,\n\n    state: {\n      init: (_config, state) => {\n        if (options.injectCSS && typeof document !== 'undefined') {\n          createStyleTag(style, options.injectNonce)\n        }\n\n        const pluginState = createState(state.doc, options)\n        onCreate(pluginState)\n\n        return pluginState\n      },\n\n      apply: (tr, state, _oldState, newState) => {\n        const meta = tr.getMeta(FindAndReplacePluginKey) as FindAndReplaceMeta | undefined\n\n        if (!meta && !tr.docChanged) {\n          return state\n        }\n\n        return updateState(\n          state,\n          { ...state, ...meta },\n          newState.doc,\n          meta,\n          tr.docChanged,\n          tr.mapping,\n        )\n      },\n    },\n\n    props: {\n      decorations(state) {\n        return FindAndReplacePluginKey.getState(state)?.decorations\n      },\n    },\n  })\n}\n\nexport default FindAndReplacePlugin\n","import type { EditorState } from '@tiptap/pm/state'\n\nimport type { SearchResult } from '../search/search.js'\n\nexport interface TextNodeResult {\n  from: number\n  text: string\n}\n\nexport function getTextNodeResult(state: EditorState, result: SearchResult): TextNodeResult | null {\n  const $from = state.doc.resolve(result.from)\n  const node = $from.parent.child($from.index())\n\n  if (!node.isText || !node.text) {\n    return null\n  }\n\n  const from = result.from - $from.textOffset\n\n  return result.to <= from + node.nodeSize ? { from, text: node.text } : null\n}\n","import type { EditorState } from '@tiptap/pm/state'\n\nimport type { SearchResult } from '../search/search.js'\nimport type { TextNodeResult } from './getTextNodeResult.js'\nimport { getTextNodeResult } from './getTextNodeResult.js'\n\nexport interface ResultGroup {\n  from: number\n  text: string | null\n  results: SearchResult[]\n}\n\nfunction shouldMergeResult(\n  group: ResultGroup | undefined,\n  textNode: TextNodeResult | null,\n): boolean {\n  if (!group || !textNode) {\n    return false\n  }\n\n  return group.from === textNode.from && group.text !== null\n}\n\nfunction createTextResultGroup(result: SearchResult, textNode: TextNodeResult): ResultGroup {\n  return {\n    from: textNode.from,\n    text: textNode.text,\n    results: [result],\n  }\n}\n\nfunction createResultGroup(result: SearchResult): ResultGroup {\n  return {\n    from: result.from,\n    text: null,\n    results: [result],\n  }\n}\n\nfunction appendResult(\n  groups: ResultGroup[],\n  result: SearchResult,\n  textNode: TextNodeResult | null,\n): void {\n  const group = groups.at(-1)\n\n  if (shouldMergeResult(group, textNode)) {\n    group!.results.push(result)\n    return\n  }\n\n  if (textNode) {\n    groups.push(createTextResultGroup(result, textNode))\n    return\n  }\n\n  groups.push(createResultGroup(result))\n}\n\nexport function groupResults(state: EditorState, results: SearchResult[]): ResultGroup[] {\n  const groups: ResultGroup[] = []\n\n  for (const result of results) {\n    appendResult(groups, result, getTextNodeResult(state, result))\n  }\n\n  return groups\n}\n","import type { Transaction } from '@tiptap/pm/state'\n\nimport type { SearchResult } from '../search/search.js'\nimport type { ResultGroup } from './groupResults.js'\n\nfunction replaceSeparateResults(\n  tr: Transaction,\n  results: SearchResult[],\n  replaceTerm: string,\n): void {\n  for (const result of [...results].reverse()) {\n    tr.insertText(replaceTerm, result.from, result.to)\n  }\n}\n\nfunction createReplacement(\n  group: ResultGroup,\n  text: string,\n  firstResult: SearchResult,\n  replaceTerm: string,\n): string {\n  let offset = firstResult.from - group.from\n  const replacement: string[] = []\n\n  for (const result of group.results) {\n    const from = result.from - group.from\n    const to = result.to - group.from\n\n    replacement.push(text.slice(offset, from), replaceTerm)\n    offset = to\n  }\n\n  return replacement.join('')\n}\n\nexport function replaceGroup(tr: Transaction, group: ResultGroup, replaceTerm: string): void {\n  const firstResult = group.results[0]\n  const lastResult = group.results.at(-1)\n\n  if (!lastResult) {\n    return\n  }\n\n  if (group.text === null) {\n    replaceSeparateResults(tr, group.results, replaceTerm)\n    return\n  }\n\n  tr.insertText(\n    createReplacement(group, group.text, firstResult, replaceTerm),\n    firstResult.from,\n    lastResult.to,\n  )\n}\n","import type { EditorState, Transaction } from '@tiptap/pm/state'\n\nimport type { SearchResult } from '../search/search.js'\nimport { groupResults } from './groupResults.js'\nimport { replaceGroup } from './replaceGroup.js'\n\nexport function replaceAllResults(\n  tr: Transaction,\n  state: EditorState,\n  results: SearchResult[],\n  replaceTerm: string,\n): void {\n  const groups = groupResults(state, results)\n\n  for (const group of groups.reverse()) {\n    replaceGroup(tr, group, replaceTerm)\n  }\n}\n","import type { Command, Editor } from '@tiptap/core'\nimport { Extension } from '@tiptap/core'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport { TextSelection } from '@tiptap/pm/state'\n\nimport {\n  clearDebouncedSearchState,\n  getDebouncedSearchState,\n} from './state/debounced-search-state.js'\nimport type { FindAndReplaceMeta, FindAndReplacePluginState } from './plugin/plugin.js'\nimport { FindAndReplacePlugin, FindAndReplacePluginKey } from './plugin/plugin.js'\nimport { findNextIndex, searchDocument } from './search/search.js'\nimport type { SearchResult } from './search/search.js'\nimport type { FindAndReplaceOptions, FindAndReplaceStorage } from './types.js'\nimport { replaceAllResults } from './utils/replaceAllResults.js'\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    findAndReplace: {\n      /**\n       * Set the search term and highlight all matches in the document.\n       * @param term The search term, treated as regex source when regex mode is enabled.\n       * @example editor.commands.setSearchTerm('Hello')\n       */\n      setSearchTerm: (term: string) => ReturnType\n\n      /**\n       * Set the replace term used by the replace commands.\n       * @param term The replacement text.\n       * @example editor.commands.setReplaceTerm('World')\n       */\n      setReplaceTerm: (term: string) => ReturnType\n\n      /**\n       * Set whether the search is case sensitive.\n       * @param caseSensitive The new case sensitivity.\n       * @example editor.commands.setCaseSensitive(true)\n       */\n      setCaseSensitive: (caseSensitive: boolean) => ReturnType\n\n      /**\n       * Set whether the search term is treated as an RE2-compatible regular expression.\n       * Lookarounds and backreferences are not supported.\n       * @param useRegex The new regex mode.\n       * @example editor.commands.setUseRegex(true)\n       */\n      setUseRegex: (useRegex: boolean) => ReturnType\n\n      /**\n       * Set whether to match whole words only. Ignored when regex mode is enabled.\n       * @param wholeWord The new whole word mode.\n       * @example editor.commands.setWholeWord(true)\n       */\n      setWholeWord: (wholeWord: boolean) => ReturnType\n\n      /**\n       * Replace the current search result and jump to the next one.\n       * @example editor.commands.replace()\n       */\n      replace: () => ReturnType\n\n      /**\n       * Replace all search results at once.\n       * @example editor.commands.replaceAll()\n       */\n      replaceAll: () => ReturnType\n\n      /**\n       * Jump to the next search result, wrapping around at the end.\n       * @example editor.commands.goToNextResult()\n       */\n      goToNextResult: () => ReturnType\n\n      /**\n       * Jump to the previous search result, wrapping around at the start.\n       * @example editor.commands.goToPreviousResult()\n       */\n      goToPreviousResult: () => ReturnType\n\n      /**\n       * Clear the search term and remove all search result highlights.\n       * @example editor.commands.clearSearch()\n       */\n      clearSearch: () => ReturnType\n    }\n  }\n}\n\nfunction mergePluginMeta(tr: Transaction, meta: FindAndReplaceMeta): void {\n  const currentMeta = tr.getMeta(FindAndReplacePluginKey) as FindAndReplaceMeta | undefined\n\n  tr.setMeta(FindAndReplacePluginKey, { ...currentMeta, ...meta })\n}\n\nfunction setPluginMeta(meta: FindAndReplaceMeta): Command {\n  return ({ tr, dispatch }) => {\n    if (dispatch) {\n      mergePluginMeta(tr, meta)\n    }\n\n    return true\n  }\n}\n\nfunction applySearchTerm(editor: Editor, term: string): void {\n  const tr = editor.state.tr\n\n  mergePluginMeta(tr, { searchTerm: term })\n  editor.view.dispatch(tr)\n}\n\nfunction consumePendingSearch(editor: Editor): string | null {\n  const state = getDebouncedSearchState(editor)\n\n  if (state.pendingTerm === null) {\n    return null\n  }\n\n  const pendingTerm = state.pendingTerm\n\n  state.pendingTerm = null\n\n  if (state.timeout !== null) {\n    clearTimeout(state.timeout)\n    state.timeout = null\n  }\n\n  return pendingTerm\n}\n\nfunction getPendingAwarePluginState(\n  state: EditorState,\n  pendingTerm: string | null,\n): FindAndReplacePluginState | null {\n  const pluginState = FindAndReplacePluginKey.getState(state)\n\n  if (!pluginState) {\n    return null\n  }\n\n  if (pendingTerm === null) {\n    return pluginState.results.length === 0 ? null : pluginState\n  }\n\n  const results = searchDocument(state.doc, pendingTerm, {\n    caseSensitive: pluginState.caseSensitive,\n    useRegex: pluginState.useRegex,\n    wholeWord: pluginState.wholeWord,\n  })\n\n  if (results.length === 0) {\n    return null\n  }\n\n  return {\n    ...pluginState,\n    searchTerm: pendingTerm,\n    results,\n    currentIndex: 0,\n  }\n}\n\nfunction currentResult(pluginState: FindAndReplacePluginState): SearchResult | undefined {\n  return pluginState.results[pluginState.currentIndex ?? 0]\n}\n\nfunction shiftIndex(currentIndex: number | null, length: number, direction: 1 | -1): number {\n  if (currentIndex === null) {\n    return direction === 1 ? 0 : length - 1\n  }\n\n  return (currentIndex + direction + length) % length\n}\n\nfunction selectResult(tr: Transaction, result: SearchResult, index: number): void {\n  tr.setSelection(TextSelection.create(tr.doc, result.from, result.to))\n  mergePluginMeta(tr, { currentIndex: index })\n  tr.scrollIntoView()\n}\n\nfunction replaceResult(\n  tr: Transaction,\n  pluginState: FindAndReplacePluginState,\n  result: SearchResult,\n): void {\n  const { searchTerm, replaceTerm, caseSensitive, useRegex, wholeWord } = pluginState\n\n  tr.insertText(replaceTerm, result.from, result.to)\n\n  // Jump to the first result behind the inserted text, so a replacement\n  // that still matches the search (e.g. \"foo\" -> \"foobar\") is skipped.\n  const results = searchDocument(tr.doc, searchTerm, { caseSensitive, useRegex, wholeWord })\n  const nextIndex = findNextIndex(results, result.from + replaceTerm.length)\n\n  if (nextIndex === null) {\n    mergePluginMeta(tr, { currentIndex: null })\n    return\n  }\n\n  selectResult(tr, results[nextIndex], nextIndex)\n}\n\nexport const FindAndReplace = Extension.create<FindAndReplaceOptions, FindAndReplaceStorage>({\n  name: 'findAndReplace',\n\n  addOptions() {\n    return {\n      searchTerm: '',\n      replaceTerm: '',\n      caseSensitive: false,\n      useRegex: false,\n      wholeWord: false,\n      searchDebounceMs: 250,\n      injectCSS: true,\n      injectNonce: undefined,\n    }\n  },\n\n  addStorage() {\n    return {\n      searchTerm: this.options.searchTerm,\n      replaceTerm: this.options.replaceTerm,\n      caseSensitive: this.options.caseSensitive,\n      useRegex: this.options.useRegex,\n      wholeWord: this.options.wholeWord,\n      results: [],\n      currentIndex: null,\n    }\n  },\n\n  addProseMirrorPlugins() {\n    return [\n      FindAndReplacePlugin(this.options, pluginState => {\n        this.storage.results = pluginState.results\n        this.storage.currentIndex = pluginState.currentIndex\n      }),\n    ]\n  },\n\n  onTransaction() {\n    const pluginState = FindAndReplacePluginKey.getState(this.editor.state)\n\n    if (!pluginState) {\n      return\n    }\n\n    this.storage.searchTerm = pluginState.searchTerm\n    this.storage.replaceTerm = pluginState.replaceTerm\n    this.storage.caseSensitive = pluginState.caseSensitive\n    this.storage.useRegex = pluginState.useRegex\n    this.storage.wholeWord = pluginState.wholeWord\n    this.storage.results = pluginState.results\n    this.storage.currentIndex = pluginState.currentIndex\n  },\n\n  addCommands() {\n    const scheduleSearchTerm = (term: string): boolean => {\n      const state = getDebouncedSearchState(this.editor)\n\n      if (this.options.searchDebounceMs <= 0) {\n        if (state.timeout !== null) {\n          clearTimeout(state.timeout)\n          state.timeout = null\n        }\n\n        state.pendingTerm = null\n\n        applySearchTerm(this.editor, term)\n\n        return true\n      }\n\n      if (state.timeout !== null) {\n        clearTimeout(state.timeout)\n      }\n\n      state.pendingTerm = term\n      state.timeout = setTimeout(() => {\n        const debouncedState = getDebouncedSearchState(this.editor)\n\n        debouncedState.timeout = null\n\n        if (debouncedState.pendingTerm === null) {\n          return\n        }\n\n        const pendingTerm = debouncedState.pendingTerm\n\n        debouncedState.pendingTerm = null\n        applySearchTerm(this.editor, pendingTerm)\n      }, this.options.searchDebounceMs)\n\n      return true\n    }\n\n    return {\n      setSearchTerm:\n        term =>\n        ({ dispatch }) => {\n          if (!dispatch) {\n            return true\n          }\n\n          return scheduleSearchTerm(term)\n        },\n      setReplaceTerm: term => setPluginMeta({ replaceTerm: term }),\n      setCaseSensitive: caseSensitive => setPluginMeta({ caseSensitive }),\n      setUseRegex: useRegex => setPluginMeta({ useRegex }),\n      setWholeWord: wholeWord => setPluginMeta({ wholeWord }),\n      clearSearch:\n        () =>\n        ({ tr, dispatch }) => {\n          const state = getDebouncedSearchState(this.editor)\n\n          if (state.timeout !== null) {\n            clearTimeout(state.timeout)\n            state.timeout = null\n          }\n\n          state.pendingTerm = null\n\n          if (dispatch) {\n            mergePluginMeta(tr, { searchTerm: '' })\n          }\n\n          return true\n        },\n\n      replace:\n        () =>\n        ({ tr, state, dispatch }) => {\n          const pendingTerm = dispatch ? consumePendingSearch(this.editor) : null\n\n          if (dispatch && pendingTerm !== null) {\n            mergePluginMeta(tr, { searchTerm: pendingTerm })\n          }\n\n          const pluginState = getPendingAwarePluginState(state, pendingTerm)\n\n          if (!pluginState) {\n            return false\n          }\n\n          const result = currentResult(pluginState)\n\n          if (!result) {\n            return false\n          }\n\n          if (dispatch) {\n            replaceResult(tr, pluginState, result)\n          }\n\n          return true\n        },\n\n      replaceAll:\n        () =>\n        ({ tr, state, dispatch }) => {\n          const pendingTerm = dispatch ? consumePendingSearch(this.editor) : null\n\n          if (dispatch && pendingTerm !== null) {\n            mergePluginMeta(tr, { searchTerm: pendingTerm })\n          }\n\n          const pluginState = getPendingAwarePluginState(state, pendingTerm)\n\n          if (!pluginState) {\n            return false\n          }\n\n          if (dispatch) {\n            replaceAllResults(tr, state, pluginState.results, pluginState.replaceTerm)\n          }\n\n          return true\n        },\n\n      goToNextResult:\n        () =>\n        ({ tr, state, dispatch }) => {\n          const pendingTerm = dispatch ? consumePendingSearch(this.editor) : null\n\n          if (dispatch && pendingTerm !== null) {\n            mergePluginMeta(tr, { searchTerm: pendingTerm })\n          }\n\n          const pluginState = getPendingAwarePluginState(state, pendingTerm)\n\n          if (!pluginState) {\n            return false\n          }\n\n          const nextIndex = shiftIndex(pluginState.currentIndex, pluginState.results.length, 1)\n\n          if (dispatch) {\n            selectResult(tr, pluginState.results[nextIndex], nextIndex)\n          }\n\n          return true\n        },\n\n      goToPreviousResult:\n        () =>\n        ({ tr, state, dispatch }) => {\n          const pendingTerm = dispatch ? consumePendingSearch(this.editor) : null\n\n          if (dispatch && pendingTerm !== null) {\n            mergePluginMeta(tr, { searchTerm: pendingTerm })\n          }\n\n          const pluginState = getPendingAwarePluginState(state, pendingTerm)\n\n          if (!pluginState) {\n            return false\n          }\n\n          const previousIndex = shiftIndex(pluginState.currentIndex, pluginState.results.length, -1)\n\n          if (dispatch) {\n            selectResult(tr, pluginState.results[previousIndex], previousIndex)\n          }\n\n          return true\n        },\n    }\n  },\n\n  onDestroy() {\n    clearDebouncedSearchState(this.editor)\n  },\n})\n\nexport default FindAndReplace\n","import { FindAndReplace } from './find-and-replace.js'\n\nexport * from './find-and-replace.js'\nexport * from './plugin/plugin.js'\nexport * from './search/search.js'\nexport * from './types.js'\n\nexport default FindAndReplace\n"],"mappings":";;;;;;;;;AAOA,MAAM,uCAAuB,IAAI,QAAsC;AAEvE,SAAgB,wBAAwB,QAAsC;CAC5E,MAAM,gBAAgB,qBAAqB,IAAI,MAAM;CAErD,IAAI,eACF,OAAO;CAGT,MAAM,YAAkC;EACtC,SAAS;EACT,aAAa;CACf;CAEA,qBAAqB,IAAI,QAAQ,SAAS;CAE1C,OAAO;AACT;AAEA,SAAgB,0BAA0B,QAAsB;CAC9D,MAAM,QAAQ,qBAAqB,IAAI,MAAM;CAE7C,IAAI,CAAC,OACH;CAGF,IAAI,MAAM,YAAY,MACpB,aAAa,MAAM,OAAO;CAG5B,qBAAqB,OAAO,MAAM;AACpC;;;ACtCA,MAAa,cAAc;AAC3B,MAAa,qBAAqB;;;ACDlC,MAAa,kBAAkB,OAAe,UAAqC;CACjF,MAAM,WAAW,SAAS,cACxB,qDACF;CAEA,IAAI,aAAa,MACf,OAAO;CAGT,MAAM,YAAY,SAAS,cAAc,OAAO;CAEhD,IAAI,OACF,UAAU,aAAa,SAAS,KAAK;CAGvC,UAAU,aAAa,gDAAgD,EAAE;CACzE,UAAU,cAAc;CACxB,SAAS,qBAAqB,MAAM,CAAC,CAAC,EAAE,CAAC,YAAY,SAAS;CAE9D,OAAO;AACT;;;ACpBA,MAAa,QAAQ;;;;;;;;;;ACMrB,MAAM,gBAAgB,UAA0B;CAC9C,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD;;AAGA,MAAM,uBAAuB;AAE7B,SAAS,mBAAmB,QAAgB,eAAuC;CACjF,IAAI;EACF,OAAO,IAAI,OAAO,QAAQ,gBAAgB,OAAO,KAAK;CACxD,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,iBAAiB,QAAgB,eAA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