49014902// prettier-ignore4903const fieldsUsedInCalculator = calculators4904.flatMap(calculatorData => t_zeroForms__getListOfFieldsInFormula(calculatorData.li_expr))4905.filter(Boolean);49064907return elements.map(element => {4908if (fieldsUsedInCalculator.includes(element.li_nm)) {4909element._usedInCalculator = true;4910}4911return element;4912
});}/** * @param {Record<string, any>} elementObj * @param {string} value */function t396_zeroForms__prepareCalcValue(elementObj, value) { if (!elementObj._usedInCalculator || !value) { const rawLabel = value || ''; return { label: rawLabel, labelText: t396__decodeHtmlText(rawLabel), calcValue: null }; } const [label, calcValue] = value.split('='); return { label, // label идёт в innerHTML, labelText — в input.value/option.value labelText: t396__decodeHtmlText(label), calcValue, };}function t396_zeroForms__setCalcValue(input, value) { if (!value || !input) return; input.setAttribute('data-calc-value', value);}function t396_zeroForms__getDefaultOption(elementObj) { if (!elementObj) return null; if (['sb', 'ri', 'rd'].includes(elementObj.li_type)) { return elementObj.li_defselitem || null; } if (['cb'].includes(elementObj.li_type)) { return elementObj.li_checked || null; } if (['qn', 'rg'].includes(elementObj.li_type)) { return elementObj.li_value || null; }}function t396_zeroForms__getProjectId() { if (t_zeroForms__getTildaMode() === 'zero') { return window.projectid; } const allRecords = document.getElementById('allrecords'); const projectId = allRecords.getAttribute('data-tilda-project-id'); return projectId;}function t396_zeroForms__getUserRole() { if (t_zeroForms__getTildaMode() !== 'published') { let userStatus = 'basic'; if (window.$oplan === '99') { userStatus = 'team'; } else if (window.userrole) { userStatus = 'tester'; } return userStatus; } const allRecords = document.getElementById('allrecords'); if (!allRecords) return 'basic'; const isOwnerTester = allRecords.getAttribute('data-tilda-ts') === 'y'; const isOwnerTeam = allRecords.getAttribute('data-tilda-te') === 'y'; let userStatus = 'basic'; if (isOwnerTeam) { userStatus = 'team'; } else if (isOwnerTester) { userStatus = 'tester'; } return userStatus;}/** * Промис резолвится после того, как все ресурсы для блока так или иначе завершили загрузку. * @param {string} recId ID блока, чьи ресусурсы нужно дождаться */async function t_zeroForms__waitForResources(recId) { await Promise.allSettled(window.t_zeroForms__resourcesQueue[recId] || []);}