7601/**7602* Выполняет все сайд-эффекты при выборе/смене вариации товара.7603* Используется для интеграции виджета вариантов (editions widget): повторяет действия,7604* которые в легаси-флоу делает обработчик change у `.js-product-edition-option`.7605*7606* @param {string} recid7607* @param {HTMLElement} el_product - DOM-элемент товара7608* @param {ProductEdition | null} edition - выбранная вариация товара7609* @param {object} product - данные товара7610* @param {object} options - настройки каталога7611* @param {boolean} isChanged - true, если вариация сменилась по действию пользователя
* @param {boolean} sendStats - отправлять ли ecommerce-событие 'detail' **/function t_catalog_product_runEditionSideEffects(recid, el_product, edition, product, options, isChanged, sendStats) { const rec = document.getElementById(`rec${recid}`); const catalogWrapper = rec ? rec.querySelector('.t-catalog') : null; if (!edition) { t_catalog_product_triggerSoldOutMsg(recid, el_product, true, options); t_catalog_removeProductQuantity(el_product); if (catalogWrapper) { // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 t_catalog_triggerEvent(catalogWrapper, 'displayChanged'); } return; } t_catalog_product_updateEdition(recid, el_product, edition, product, options, isChanged); // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592) // @ts-expect-error ST-2949_4 t_prod__updatePrice(el_product, options); // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 const isSoldOut = parseInt(edition.quantity, 10) <= 0; t_catalog_product_triggerSoldOutMsg(recid, el_product, isSoldOut, options); if (!isSoldOut) { t_catalog_addProductQuantity(el_product, edition, options); } else { t_catalog_removeProductQuantity(el_product); } // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592) // @ts-expect-error ST-2949_4 if (sendStats && window.Tilda && Tilda.sendEcommerceEvent) { if (!window.tStoreDetailEvent) { window.tStoreDetailEvent = {}; } // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 const editionKey = edition.id ? edition.id : edition.uid; // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 if (!window.tStoreDetailEvent[editionKey]) { // TODO ST-2949_4: cannot find name / missing jQuery types (TS2304, TS2592) // @ts-expect-error ST-2949_4 Tilda.sendEcommerceEvent('detail', [ { id: String(editionKey), // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) uid: String(edition.uid), // @ts-expect-error ST-2949_1 price: String(edition.price_min || edition.price), sku: edition.sku ? edition.sku : '', // @ts-expect-error ST-2949_1 name: product.title, }, ]); // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 window.tStoreDetailEvent[editionKey] = true; } } if (catalogWrapper) { // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 t_catalog_triggerEvent(catalogWrapper, 'displayChanged'); }}/** * Монтирует виджет вариантов и выполняет стартовые сайд-эффекты. Синхронная функция: * вызывается, когда функция монтирования уже доступна в window. * * @param {HTMLElement} container - контейнер для виджета вариантов * @param {string} recid * @param {object} product * @param {HTMLElement} el_product * @param {object} options **/function t_catalog_product__mountEditionsWidget(container, recid, product, el_product, options) { if (!container) return; // Удаляем легаси-контролы вариантов, если они были отрисованы ранее Array.prototype.forEach.call(el_product.querySelectorAll('.js-product-edition-option'), editionOption => {