2701* @param {CSSStyleDeclaration} computedStyle - computed style of the node2702* @param {string|null} parentVerticalAlign - inherited vertical align from parent2703* @returns {string|null} - vertical align value or null if none2704*/2705function t_animate__getTextVerticalAlign(computedStyle, parentVerticalAlign) {2706const verticalAlign = computedStyle.verticalAlign;27072708if (!verticalAlign || verticalAlign === 'baseline' || verticalAlign === 'middle') {2709return parentVerticalAlign;2710}2711
return verticalAlign;}/** * @typedef {Object} TextStyleOptions * @property {string|null} verticalAlign - vertical align value (e.g., 'baseline', 'middle', 'sub', 'super') or null if none * @property {TextDecoration|null} textDecoration - text decoration properties or null if none *//** * Get text style options of a node, including vertical align and text decoration, considering inherited styles from parent. * @param {Node} node - node to get text style options from * @param {TextStyleOptions|null} parentTextStyleOptions - inherited text style options from parent * @returns {TextStyleOptions} - object with verticalAlign and textDecoration properties */function t_animate__getTextStyleOptions(node, parentTextStyleOptions) { const { verticalAlign: parentVerticalAlign = null, textDecoration: parentTextDecoration = null } = parentTextStyleOptions ?? {}; const computedStyle = window.getComputedStyle(node); const verticalAlign = t_animate__getTextVerticalAlign(computedStyle, parentVerticalAlign); const textDecoration = t_animate__getTextDecoration(computedStyle, parentTextDecoration); return { verticalAlign, textDecoration };}/** * Create word mask wrapper for word animation * @returns {HTMLSpanElement} */function t_animate__createWordMaskWrapper() { const wrapper = document.createElement('span'); wrapper.className = 't-animate__word-mask-wrapper'; return wrapper;}/** * Create word span with animation * @param {string} text - text content for the span * @param {TextDecoration|null} textDecoration - inherited text decoration from parent * @param {boolean} isMasked - whether the word should be wrapped in a mask wrapper * @returns {HTMLSpanElement} */function t_animate__createWord(text, textDecoration, isMasked = false) { const span = document.createElement('span'); span.className = 't-animate__word'; span.style.textDecorationLine = textDecoration?.lines?.join(' ') || ''; span.style.textDecorationStyle = textDecoration?.style || ''; span.style.textDecorationColor = textDecoration?.color || ''; span.style.textDecorationThickness = textDecoration?.thickness || ''; span.textContent = text; if (!isMasked) { return span; } const wrapper = t_animate__createWordMaskWrapper(); wrapper.appendChild(span); return wrapper;}/** * Create strict inline word span for complex text nodes (like superscripts with underline). * Such node will be inline and have more simple animation without transforms. * @param {string} text - text content for the span * @returns {HTMLSpanElement} */function t_animate__createStrictWord(text) { const span = document.createElement('span'); span.className = 't-animate__word t-animate__word_strict'; span.textContent = text; return span;}/** * Create whitespace span for word animation * @param {string} text - text content for the span * @returns {HTMLSpanElement} */function t_animate__createWhitespaceWord(text) { const span = document.createElement('span'); span.className = 't-animate__word t-animate__word_whitespace'; span.textContent = text; return span;