7801for (var j = 0; j < optsValsBeforeChangedArr.length; j++) {7802var name = optsValsBeforeChangedArr[j].name;7803var id = optsValsBeforeChangedArr[j].id;7804var val = t_store_product_getCurEditionOptValById(el_product, id);78057806curEdition[name] = (curEdition[name] || '')7807.replace(/\/g, '\\')7808.replace(/>/g, '>')7809.replace(/</g, '<');78107811if (curVal && j === optsValsBeforeChangedArr.length - 1) {7812
val = curVal; } if (curEdition[name] !== val) { doesContainSelectedOpts = false; break; } } if (doesContainSelectedOpts) { if (parseInt(curEdition.quantity, 10) !== 0) { return curEdition; } else if (!firstAvailable) { firstAvailable = curEdition; } } } if (firstAvailable) { // Блок "подписаться" - Выходим если не надо выключать опции var outOfStockBlock = document.querySelector('.t1122'); if (outOfStockBlock) return firstAvailable; if (parseInt(firstAvailable.quantity, 10) === 0) { firstAvailable = ''; } } return firstAvailable;}function t_store_product_getCurEditionOptValById(el_product, id) { var el_optionsWrap = el_product.querySelector('.js-product-edition-option[data-edition-option-id="' + id + '"]'); if (el_optionsWrap) { return el_optionsWrap.querySelector('.js-product-edition-option-variants').value; } else { return ''; }}function t_store_product_getEditionOptionsArr_getValues(prop, editions) { var values = []; // iterate all editions and collect unique property values editions.forEach(function (curEdition) { var val = curEdition[prop]; if (val !== undefined && values.indexOf(val) === -1) { values.push(val); } }); values = t_store_product_sortValues(values); return values;}/** * Sorts an array of values based on a specific order. * * @param {Array} result - An array of values to sort. * @param {string} type - The type of the values in the array. Can be either 'filter' or 'product'. * @param {Array} order - An array of strings representing the order to sort the values by. * @return {Array} The sorted array of values. */function t_store_product_sortValuesByOrder(result, type, order) { return result.sort(function (a, b) { var valueA = type === 'filter' ? a.value : a; var valueB = type === 'filter' ? b.value : b; valueA = valueA.toString().toUpperCase(); valueB = valueB.toString().toUpperCase(); return order.indexOf(valueA) - order.indexOf(valueB); });}/** * Tests if the values in an array are in a specific order. * * @param {Array} values - An array of values to test. Each value can be a string or an object with a `value` property. * @param {Array} order - An array of strings representing the expected order of the values. * @return {boolean} `true` if the values are in the specified order, `false` otherwise. */function t_store_product_isSimpleOrderValid(values, order) { return values.every(function (current) { var value = current; // value может быть объектом с полем value if (typeof value === 'object' && typeof value.value === 'string') { value = value.value;