{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export type SplitMode = 'words' | 'chars' | 'both';\n\nexport interface TextSlicerOptions {\n  container?: HTMLElement | string;\n  splitMode?: SplitMode;\n  cssVariables?: boolean;\n  dataAttributes?: boolean;\n  keepWhitespaceNodes?: boolean;\n  containerHeightVar?: boolean;\n  locale?: string | string[];\n}\n\nexport interface TextSlicerMetrics {\n  wordTotal: number;\n  charTotal: number;\n  renderedAt: number;\n}\n\nexport interface TextSlicerCallbacks {\n  onAfterRender?: (metrics: TextSlicerMetrics) => void;\n}\n\ntype RuntimeOptions = Required<Omit<TextSlicerOptions, 'container' | 'locale'>> &\n  Pick<TextSlicerOptions, 'locale'>;\n\nconst DEFAULT_OPTIONS: RuntimeOptions = {\n  splitMode: 'both',\n  cssVariables: false,\n  dataAttributes: false,\n  keepWhitespaceNodes: true,\n  containerHeightVar: false,\n  locale: undefined,\n};\n\nexport const CLASSNAMES = Object.freeze({\n  word: 'ts-word',\n  char: 'ts-char',\n  whitespace: 'ts-whitespace',\n});\n\nconst CSS_VAR_WORD_TOTAL = '--word-total';\nconst CSS_VAR_CHAR_TOTAL = '--char-total';\nconst CSS_VAR_WORD_INDEX = '--word-index';\nconst CSS_VAR_CHAR_INDEX = '--char-index';\nconst CSS_VAR_CONTAINER_HEIGHT = '--container-height';\nconst MEASURING_CLASS = 'ts-measuring';\n\nconst canUseDOM = (): boolean => typeof window !== 'undefined' && typeof document !== 'undefined';\n\nconst resolveContainer = (container?: HTMLElement | string): HTMLElement | null => {\n  if (!canUseDOM()) return null;\n  if (!container) return null;\n\n  return typeof container === 'string' ? document.querySelector(container) : container;\n};\n\ntype IntlWithSegmenter = typeof Intl & {\n  Segmenter?: new (locales?: string | string[], options?: Intl.SegmenterOptions) => Intl.Segmenter;\n};\n\nconst localeKey = (locale: string | string[] | undefined): string =>\n  locale === undefined ? '' : Array.isArray(locale) ? locale.join('\\0') : locale;\n\nconst segmenterCache = new Map<string, Intl.Segmenter>();\n\nconst getSegmenter = (\n  locale: string | string[] | undefined,\n  granularity: 'grapheme' | 'word',\n): Intl.Segmenter | null => {\n  if (typeof Intl === 'undefined') return null;\n\n  const Seg = (Intl as IntlWithSegmenter).Segmenter;\n\n  if (typeof Seg !== 'function') return null;\n\n  const key = `${granularity}:${localeKey(locale)}`;\n  let segmenter = segmenterCache.get(key);\n\n  if (!segmenter) {\n    segmenter = new Seg(locale, { granularity });\n    segmenterCache.set(key, segmenter);\n  }\n\n  return segmenter;\n};\n\nconst splitIntoGraphemes = (text: string, locale?: string | string[]): string[] => {\n  const segmenter = getSegmenter(locale, 'grapheme');\n\n  if (segmenter) {\n    return Array.from(segmenter.segment(text), (s: Intl.SegmentData) => s.segment);\n  }\n\n  // Fallback: Array.from does not preserve all ZWJ/emoji grapheme clusters.\n  // Remove when the browser baseline requires Intl.Segmenter.\n  return Array.from(text);\n};\n\nconst isWhitespaceGrapheme = (ch: string): boolean => /^\\s+$/u.test(ch);\n\nconst countCharGraphemes = (text: string, locale?: string | string[]): number =>\n  splitIntoGraphemes(text, locale).filter((ch) => !isWhitespaceGrapheme(ch)).length;\n\ntype WordSegment = Intl.SegmentData;\n\nconst segmentWords = (text: string, locale?: string | string[]): WordSegment[] => {\n  const segmenter = getSegmenter(locale, 'word');\n\n  if (segmenter) {\n    return Array.from(segmenter.segment(text));\n  }\n\n  // Fallback: whitespace splitting is not locale-aware and keeps punctuation attached to tokens.\n  // Remove when the browser baseline requires Intl.Segmenter.\n  const words = text.split(/\\s+/u).filter(Boolean);\n  const segments: WordSegment[] = [];\n\n  let cursor = 0;\n\n  for (const word of words) {\n    const start = text.indexOf(word, cursor);\n\n    if (start > cursor) {\n      segments.push({\n        segment: text.slice(cursor, start),\n        index: cursor,\n        input: text,\n        isWordLike: false,\n      });\n    }\n\n    segments.push({ segment: word, index: start, input: text, isWordLike: true });\n    cursor = start + word.length;\n  }\n\n  if (cursor < text.length) {\n    segments.push({ segment: text.slice(cursor), index: cursor, input: text, isWordLike: false });\n  }\n\n  return segments;\n};\n\nconst countWords = (text: string, locale?: string | string[]): number =>\n  segmentWords(text, locale).filter((s) => s.isWordLike).length;\n\nconst emptyElement = (el: HTMLElement): void => {\n  el.replaceChildren();\n};\n\nconst isHTMLElement = (el: unknown): el is HTMLElement =>\n  !!el && typeof HTMLElement !== 'undefined' && el instanceof HTMLElement;\n\ntype NonUndefined<T> = T extends undefined ? never : T;\ntype OmitUndefined<T extends Record<string, unknown>> = {\n  [K in keyof T as T[K] extends undefined ? never : K]: NonUndefined<T[K]>;\n};\n\nconst omitUndefined = <T extends Record<string, unknown>>(obj: T): OmitUndefined<T> => {\n  const out = {} as OmitUndefined<T>;\n\n  (Object.keys(obj) as Array<keyof T>).forEach((key) => {\n    const val = obj[key];\n\n    if (val !== undefined) {\n      (out as Record<string, unknown>)[key as string] = val as unknown;\n    }\n  });\n\n  return out;\n};\n\ntype RuntimeOptionPatch = Partial<Omit<TextSlicerOptions, 'container'>>;\n\nconst mergeRuntimeOptions = (base: RuntimeOptions, patch: RuntimeOptionPatch): RuntimeOptions => {\n  const { container: _container, ...runtimeOptions } = patch as TextSlicerOptions;\n\n  return {\n    ...base,\n    ...omitUndefined(runtimeOptions as Record<string, unknown>),\n  };\n};\n\ntype ManagedStyle = { value: string; priority: string };\n\nexport class TextSlicer {\n  private readonly el: HTMLElement | null;\n  private original: string;\n  private opts: RuntimeOptions;\n  private callbacks: TextSlicerCallbacks | undefined;\n  private charIndex: number;\n  private mounted: boolean;\n  private resizeObserver?: ResizeObserver;\n  private managedStyles = new Map<string, ManagedStyle>();\n  private managedAttributes = new Map<string, string | null>();\n\n  constructor(options: TextSlicerOptions = {}, callbacks?: TextSlicerCallbacks) {\n    const { container, ...runtimeOptions } = options;\n    const el = resolveContainer(container);\n    this.el = el;\n    // Plain-text mode intentionally discards nested markup. Upgrade path:\n    // walk text nodes and preserve element boundaries in a DOM-preserving mode.\n    this.original = isHTMLElement(el) ? (el.textContent?.toString() ?? '') : '';\n    this.opts = mergeRuntimeOptions(DEFAULT_OPTIONS, runtimeOptions);\n\n    this.callbacks = callbacks;\n    this.charIndex = 0;\n    this.mounted = false;\n  }\n\n  get metrics(): TextSlicerMetrics {\n    const text = this.original;\n    const { locale } = this.opts;\n\n    return {\n      wordTotal: text.length ? countWords(text, locale) : 0,\n      charTotal: text.length ? countCharGraphemes(text, locale) : 0,\n      renderedAt: Date.now(),\n    };\n  }\n\n  init(): void {\n    if (!this.el) return;\n\n    this.mounted = true;\n    this.split();\n    this.syncHeightObserver();\n  }\n\n  reinit(newText?: string, next?: RuntimeOptionPatch): void {\n    if (!this.el) return;\n    if (typeof newText === 'string') this.original = newText;\n    if (next) this.opts = mergeRuntimeOptions(this.opts, next);\n\n    this.mounted = true;\n    this.split();\n    this.syncHeightObserver();\n  }\n\n  clear(): void {\n    if (!this.el) return;\n\n    emptyElement(this.el);\n    this.restoreManagedAttribute('aria-label');\n  }\n\n  split(): void {\n    if (!this.el) return;\n\n    emptyElement(this.el);\n    this.charIndex = 0;\n\n    const text = this.original;\n    const fragment = document.createDocumentFragment();\n\n    if (this.opts.splitMode === 'chars') {\n      this.appendChars(fragment, text);\n    } else {\n      this.appendWords(fragment, text);\n    }\n\n    this.el.appendChild(fragment);\n    this.syncAccessibleLabel(text);\n\n    const metrics = this.metrics;\n\n    if (this.opts.cssVariables) {\n      this.setManagedStyle(CSS_VAR_WORD_TOTAL, String(metrics.wordTotal));\n      this.setManagedStyle(CSS_VAR_CHAR_TOTAL, String(metrics.charTotal));\n    } else {\n      this.restoreManagedStyle(CSS_VAR_WORD_TOTAL);\n      this.restoreManagedStyle(CSS_VAR_CHAR_TOTAL);\n    }\n\n    this.callbacks?.onAfterRender?.(metrics);\n  }\n\n  destroy(): void {\n    if (!this.el) return;\n\n    this.syncHeightObserver(false);\n    this.restoreManagedStyles();\n    this.restoreManagedAttribute('aria-label');\n    this.el.textContent = this.original;\n    this.mounted = false;\n  }\n\n  updateOptions(next: RuntimeOptionPatch): void {\n    this.opts = mergeRuntimeOptions(this.opts, next);\n\n    if (this.mounted) {\n      this.split();\n      this.syncHeightObserver();\n    }\n  }\n\n  lockHeight(): void {\n    if (!this.el) return;\n\n    const h = this.measureHeight();\n\n    if (h > 0) {\n      this.setManagedStyle('height', `${h}px`);\n    }\n  }\n\n  unlockHeight(): void {\n    this.restoreManagedStyle('height');\n  }\n\n  private appendWords(fragment: DocumentFragment, text: string): void {\n    const segments = segmentWords(text, this.opts.locale);\n    let wordIndex = 0;\n\n    for (const { segment, isWordLike } of segments) {\n      if (isWordLike) {\n        const wordSpan = this.createWordSpan(wordIndex, segment);\n\n        if (this.opts.splitMode === 'both') {\n          this.appendGraphemes(wordSpan, segment);\n        } else {\n          wordSpan.append(document.createTextNode(segment));\n        }\n\n        fragment.append(wordSpan);\n        wordIndex += 1;\n      } else if (isWhitespaceGrapheme(segment)) {\n        if (this.opts.splitMode === 'both') {\n          this.appendGraphemes(fragment, segment);\n        } else {\n          fragment.append(this.createWhitespaceSpan(segment));\n        }\n      } else if (segment.length > 0) {\n        if (this.opts.splitMode === 'both') {\n          this.appendGraphemes(fragment, segment);\n        } else {\n          fragment.append(this.createHiddenTextSpan(segment));\n        }\n      }\n    }\n  }\n\n  private appendChars(fragment: DocumentFragment, text: string): void {\n    for (const ch of splitIntoGraphemes(text, this.opts.locale)) {\n      this.appendGrapheme(fragment, ch);\n    }\n  }\n\n  private appendGraphemes(parent: DocumentFragment | HTMLElement, text: string): void {\n    for (const ch of splitIntoGraphemes(text, this.opts.locale)) {\n      this.appendGrapheme(parent, ch);\n    }\n  }\n\n  private appendGrapheme(parent: DocumentFragment | HTMLElement, ch: string): void {\n    if (isWhitespaceGrapheme(ch)) {\n      if (this.opts.keepWhitespaceNodes) {\n        parent.append(this.createWhitespaceSpan(ch));\n      } else {\n        parent.append(document.createTextNode(ch));\n      }\n\n      return;\n    }\n\n    parent.append(this.createCharSpan(ch));\n  }\n\n  private createWordSpan(index: number, word: string): HTMLSpanElement {\n    const span = document.createElement('span');\n\n    span.classList.add(CLASSNAMES.word);\n    span.setAttribute('aria-hidden', 'true');\n\n    if (this.opts.dataAttributes) {\n      span.setAttribute('data-word', word);\n    }\n\n    if (this.opts.cssVariables) {\n      span.style.setProperty(CSS_VAR_WORD_INDEX, String(index));\n    }\n\n    return span;\n  }\n\n  private createCharSpan(ch: string): HTMLSpanElement {\n    const span = document.createElement('span');\n\n    span.textContent = ch;\n    span.setAttribute('aria-hidden', 'true');\n    span.classList.add(CLASSNAMES.char);\n\n    if (this.opts.dataAttributes) span.setAttribute('data-char', ch);\n\n    if (this.opts.cssVariables) {\n      span.style.setProperty(CSS_VAR_CHAR_INDEX, String(this.charIndex));\n    }\n\n    this.charIndex += 1;\n\n    return span;\n  }\n\n  private createWhitespaceSpan(text: string): HTMLSpanElement {\n    const span = document.createElement('span');\n\n    span.classList.add(CLASSNAMES.whitespace);\n    span.textContent = text;\n    span.setAttribute('aria-hidden', 'true');\n\n    return span;\n  }\n\n  private createHiddenTextSpan(text: string): HTMLSpanElement {\n    const span = document.createElement('span');\n\n    span.textContent = text;\n    span.setAttribute('aria-hidden', 'true');\n\n    return span;\n  }\n\n  private syncAccessibleLabel(text: string): void {\n    if (!this.el) return;\n\n    if (this.managedAttributes.has('aria-label')) {\n      this.setManagedAttribute('aria-label', text);\n      return;\n    }\n\n    if (this.el.hasAttribute('aria-label') || this.el.hasAttribute('aria-labelledby')) {\n      return;\n    }\n\n    this.setManagedAttribute('aria-label', text);\n  }\n\n  private measureHeight(): number {\n    if (!this.el) return 0;\n\n    this.el.classList.add(MEASURING_CLASS);\n\n    try {\n      void this.el.offsetHeight;\n\n      let h = this.el.offsetHeight || this.el.clientHeight || 0;\n\n      if (!h) {\n        h = Math.round(this.el.getBoundingClientRect().height);\n      }\n\n      return Math.max(0, Math.ceil(h));\n    } finally {\n      this.el.classList.remove(MEASURING_CLASS);\n    }\n  }\n\n  private syncHeightObserver(enable: boolean = this.opts.containerHeightVar): void {\n    if (!this.el) return;\n\n    if (enable) {\n      if (typeof ResizeObserver !== 'function') {\n        this.restoreManagedStyle(CSS_VAR_CONTAINER_HEIGHT);\n        return;\n      }\n\n      if (!this.resizeObserver) {\n        this.resizeObserver = new ResizeObserver((entries) => {\n          const entry = entries[0];\n\n          if (!entry || !this.el) return;\n\n          const boxSize = entry.borderBoxSize?.[0]?.blockSize;\n          const h = Math.max(0, Math.ceil(boxSize ?? entry.contentRect.height));\n\n          if (h > 0) {\n            this.setManagedStyle(CSS_VAR_CONTAINER_HEIGHT, `${h}px`);\n          }\n        });\n\n        this.resizeObserver.observe(this.el);\n      }\n    } else if (this.resizeObserver) {\n      this.resizeObserver.disconnect();\n      this.resizeObserver = undefined;\n      this.restoreManagedStyle(CSS_VAR_CONTAINER_HEIGHT);\n    }\n  }\n\n  private setManagedStyle(property: string, value: string): void {\n    if (!this.el) return;\n\n    if (!this.managedStyles.has(property)) {\n      this.managedStyles.set(property, {\n        value: this.el.style.getPropertyValue(property),\n        priority: this.el.style.getPropertyPriority(property),\n      });\n    }\n\n    this.el.style.setProperty(property, value);\n  }\n\n  private restoreManagedStyle(property: string): void {\n    if (!this.el) return;\n\n    const previous = this.managedStyles.get(property);\n\n    if (previous === undefined) return;\n\n    if (previous.value) {\n      this.el.style.setProperty(property, previous.value, previous.priority);\n    } else {\n      this.el.style.removeProperty(property);\n    }\n\n    this.managedStyles.delete(property);\n  }\n\n  private restoreManagedStyles(): void {\n    for (const property of [...this.managedStyles.keys()]) {\n      this.restoreManagedStyle(property);\n    }\n  }\n\n  private setManagedAttribute(name: string, value: string): void {\n    if (!this.el) return;\n\n    if (!this.managedAttributes.has(name)) {\n      this.managedAttributes.set(name, this.el.getAttribute(name));\n    }\n\n    this.el.setAttribute(name, value);\n  }\n\n  private restoreManagedAttribute(name: string): void {\n    if (!this.el || !this.managedAttributes.has(name)) return;\n\n    const previous = this.managedAttributes.get(name);\n\n    if (previous === null) {\n      this.el.removeAttribute(name);\n    } else if (previous !== undefined) {\n      this.el.setAttrib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