1/**2* Блок ST100, находится в категории "Магазин"3* Скрипт добавляет на страницу виджет корзины. Список товаров хранится в localStorage.4* Используется вместе с блоками товаров (ST***)5**/67/**8* @typedef CartOptions9* @param {string} [ymapApiKey] - Ключ для яндекс карт10* @param {string} [cssClassName] - Кастомный класс из настроек блока. Нужен для правильной инициализации11*/12import {
t_store__useTranslation, t_cart__loadLkpSettings, t_cart__loadProductsInfoById, t_cart__loadProductsPrices, t_cart__safeDecodeURIComponent,} from '../src/tilda-cart/index.ts';window.t_cart__isiOS = false;if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { window.t_cart__isiOS = true;}window.t_cart__iOSMajorVersion = '';if (window.t_cart__isiOS) { var version = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/); if (version !== null) { window.t_cart__iOSMajorVersion = parseInt(version[1], 10); }}window.t_cart__browserLang = (window.navigator.userLanguage || window.navigator.language).toUpperCase().slice(0, 2);window.tcart_endpoint = 'store.tildacdn.com';/** * Language override based on attribute **/t_onReady(function () { var allrecords = document.getElementById('allrecords'); if (allrecords) { var projectLang = allrecords.getAttribute('data-tilda-project-lang'); if (projectLang) { window.t_cart__browserLang = projectLang; } var rootzoneapi = allrecords.getAttribute('data-tilda-root-zone'); if (rootzoneapi) { window.tcart_endpoint = 'store.tildaapi.' + rootzoneapi; } }});/** * Инит корзины * * @param {string} recid * @param {CartOptions} options */async function tcart__init(recid, options = {}) { if (options && typeof options !== 'object') { console.error(`Cart param "options" is not an object. Please specify object instead of ${typeof options}`); } const cartBlock = document.querySelector('.t706'); if (!cartBlock) return; const { ymapApiKey = cartBlock.getAttribute('data-yandexmap-apikey') || '', cssClassName } = options; const cartBlocksLength = document.querySelectorAll('.t706').length; const rec = document.querySelector('#rec' + recid); window.tcart__ymapApiKey = ymapApiKey; if (rec && cssClassName) { rec.classList.add(cssClassName); } // Скрываем поля формы и рассчет цены, пока не загрузились данные об авторизации tcart__form__hideFormFields(); tcart__hideBottomTotalAmount(); await t_store__useTranslation().loadTranslations(window.t_cart__browserLang); // предотвращает несколько инициализаций if (window.tcart_initted === 'yes' && cartBlocksLength > 1) { var errorText = window.t_cart__browserLang === 'RU' ? 'Ошибка: На странице присутствуют ' + cartBlocksLength + ' виджета корзины (блок ST100). Пожалуйста, удалите дубликаты. Блоки могут находиться на странице Header или Footer.' : 'Error: ' + cartBlocksLength + ' cart widgets (block ST100) on the page. Remove a duplicate. Blocks can be on the Header or Footer page.'; if (!document.querySelector('.t706__previewmode-infobox .t706__previewmode-infobox-error')) { Array.prototype.forEach.call( document.querySelectorAll('.t706__previewmode-infobox center'), function (infobox) {