1const t396__parsedCssVarRegex = /var\((--uc-([^-]+)-([^-]+)-([^,]+)),\s?(.*)\)/;23/**4* Проверяет, является ли значение CSS-переменной глобального стиля.5* @param {string} value CSS-переменная с глобальным стилем6*/7export function t396__isGlobalStyleCSSVar(value) {8if (typeof value !== 'string') return false;910const parsedVar = t396__parsedCssVarRegex.exec(value);1112if (!parsedVar) return false;
const [, , type, field, id, fallback] = parsedVar; return Boolean(type && field && id && fallback);}/** * Если переданная переменная соответствует переменной глобального стиля, возвращает всю возможную информацию про нее. * @param value CSS-переменная с глобальным стилем */export function t396__parseGlobalStyleCSSVar(value) { try { const parsedVar = t396__parsedCssVarRegex.exec(value); if (!parsedVar) return undefined; const [fullMatch, varName, type, field, id, fallback] = parsedVar; if (!fullMatch || !type || !field || !id || !fallback) return undefined; let actualFallback = fallback; // Ищем актуальное значение из CSS стилей, кроме случаев, когда находимся в редакторе zero if (window.tildamode !== 'zero') { const bodyStyle = window.getComputedStyle(document.body); actualFallback = bodyStyle.getPropertyValue(varName) || fallback; } return { parent: { id, type }, fallback: actualFallback, field }; } catch (e) { console.error('Error trying to parse CSS Variable'); }}/** * Конвертирует значение цвета из формата hex в формат RGBA * * @param {string} hexStr - цвет в формате hex * @param {string} opacity - коэффициент прозрачности * * @returns {Array} - массив RGBA */export function t396__hex2rgba(hexStr, opacity) { if (!hexStr) return false; const cssVarData = t396__parseGlobalStyleCSSVar(hexStr); if (cssVarData) { hexStr = cssVarData.fallback; } const cleanHex = hexStr.replace(/#/, ''); if (cleanHex.length === 3) { const [r, g, b] = cleanHex; hexStr = '#' + r + r + g + g + b + b; } const hex = parseInt(hexStr.substring(1), 16); const r = (hex & 0xff0000) >> 16; const g = (hex & 0x00ff00) >> 8; const b = hex & 0x0000ff; return [r, g, b, parseFloat(opacity)];}/** * @param {HTMLElement} element * @returns {boolean} */export function t396__isElementUsingCalcZoom(element) { const availableElementTypes = ['gallery', 'map']; const elementType = element.getAttribute('data-elem-type'); return availableElementTypes.includes(elementType);}export function t396__isFlex(element) { const isArtboardFlex = element.classList.contains('t396__artboard-flex'); const isGroupFlex = element.classList.contains('t396__group-flex'); return isArtboardFlex || isGroupFlex;}/** * Если артборду задано значение overflow: visible, то необходимо общему блоку * задать overflow: hidden, чтобы не появлялся горизонтальный скролл всей страницы. * Если на странице присутствует элементы со sticky-позицией, задаём overflow: clip, * чтобы фиксация этих элементов работала корректно. */export function t396__setOverflowToAllRecords() { const allRecords = document.getElementById('allrecords'); if (!allRecords) return; const stickyElementsSelectors = [ '.t951__sidebar_sticky', '.t1206__content_sticky',