} catch (e) { console.error(e); } try { for (var unit in units) { var unitValues = units[unit]; var isUnit = t_store_product_hasMeasureUnit(unitValues, firstTestValue) && t_store_product_hasMeasureUnit(unitValues, secondTestValue); var re = new RegExp(/^\d*,?\.?\d+\s*/, 'gi'); if (isUnit) { result = result.sort(function (a, b) { var valueA = type === 'filter' ? a.value : a; var valueB = type === 'filter' ? b.value : b; valueA = valueA.toString().replace(re, '').trim(); valueB = valueB.toString().replace(re, '').trim(); return unitValues.indexOf(valueA) - unitValues.indexOf(valueB); }); return result; } } } catch (e) { console.error(e); } } return result;}/** * Tests if a value contains a measure unit. * * @param {Array} values - An array of measure units to test against. * @param {string} testValue - The value to test. * @return {boolean} `true` if the value contains a measure unit, `false` otherwise. */function t_store_product_hasMeasureUnit(values, testValue) { var clearedTestValue = testValue.replace(/\s/g, ''); return values.some(function (value) { var test = '^[\\d.,]+(' + value + '){1}$'; var re = new RegExp(test, 'i'); return re.test(clearedTestValue); });}function t_store_product_getEditionOptionsArr_getParams(p, product, optionsData) { var params = {}; if (optionsData) { // Store current option parametrs and all option values in current option. Use it to style custom UI later params = optionsData[p] ? optionsData[p].params : {}; } else { try { var json_options = JSON.parse(product.json_options); if (json_options) { json_options.forEach(function (optionObj) { if (optionObj.params && optionObj.title && optionObj.title === p) { params = optionObj.params; } }); } } catch (error) { console.error(error); } } return params;}function t_store_product_getEditionOptionsArr_getImgValues(prop, editions) { var values = {}; editions.forEach(function (curEdition) { var val = curEdition[prop]; if (!values[val]) { values[val] = curEdition.img; } }); return values;}function t_store_product_getEditionSelectEl(wrapper, curOption) {