{"version":3,"file":"BL-it-U-.js","sources":["../../src/utils/helpers.js"],"sourcesContent":["import { parseISO, isValid } from 'date-fns';\n\nconst dateTimeRegex = new RegExp(/^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d+)?)?$/);\n\nexport const makeCurrency = (val, curr = '₽') => `${val}\\u00A0${curr}`; // nbsp\n\nexport const toNumericFormat = (value) => {\n if (value == null) return '\\u2014';\n\n return Number(value).toLocaleString('ru-RU', {\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n });\n};\n\nexport function lastSeveralYears(lastYears) {\n var currentYear = new Date().getFullYear();\n var yearsArr = [];\n\n for (let i = lastYears; i > 0; --i) {\n yearsArr.push(currentYear - i);\n }\n\n return yearsArr;\n}\n\nexport function dateDiff(date1, date2) {\n var years = date2.getFullYear() - date1.getFullYear();\n var months = years * 12 + date2.getMonth() - date1.getMonth();\n var days = date2.getDate() - date1.getDate();\n\n years -= date2.getMonth() < date1.getMonth();\n months -= date2.getDate() < date1.getDate();\n days += days < 0 ? new Date(date2.getFullYear(), date2.getMonth() - 1, 0).getDate() + 1 : 0;\n\n return [years, months, days];\n}\n\nexport function datePassed(date) {\n let dateToCheck = new Date(date);\n let currentDate = new Date();\n var passed = false;\n // Обнуляем время, чтобы сравнение было только по дате (день, месяц, год)\n dateToCheck.setHours(0, 0, 0, 0);\n currentDate.setHours(0, 0, 0, 0);\n if (dateToCheck.getTime() <= currentDate.getTime()) {\n passed = true;\n }\n return passed;\n}\n\nexport function daysBetween(startDate, endDate) {\n if (!(startDate instanceof Date) || !(endDate instanceof Date)) {\n throw new Error('Применяйте корректные объекты Date.');\n }\n const diffTime = Math.abs(Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()) - Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()));\n const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));\n return diffDays;\n}\n\n// FIXME: надо бы как-то пометить какие из них относятся к 1, 2, 5 и пр.\nexport function makePlural(iNumber, ...endings) {\n const [v1, v2, v3] = endings;\n let sEnding;\n\n const lastDigits = iNumber % 100;\n if (lastDigits >= 11 && lastDigits <= 19) {\n sEnding = v3;\n } else {\n switch (iNumber % 10) {\n case 1:\n sEnding = v1;\n break;\n case 2:\n case 3:\n case 4:\n sEnding = v2;\n break;\n default:\n sEnding = v3;\n }\n }\n\n return iNumber + ' ' + sEnding;\n}\n\nexport function termActivity(date, turn) {\n let date1 = new Date(date);\n let date2 = new Date();\n let difference = turn ? dateDiff(date2, date1) : dateDiff(date1, date2);\n let differenceYear = difference[0];\n let differenceMonth = difference[1] - differenceYear * 12;\n let differenceDays = difference[2];\n let output = '';\n if (differenceYear) {\n output += makePlural(differenceYear, 'год', 'года', 'лет');\n }\n if (differenceMonth) {\n output += ' ' + makePlural(differenceMonth, 'месяц', 'месяца', 'месяцев');\n }\n if (differenceDays && !differenceMonth) {\n output += ' ' + makePlural(differenceDays, 'день', 'дня', 'дней');\n }\n return output;\n}\n\nconst patternEmail = /^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/i;\nexport const patternOnlyLetter = /^[a-zа-яё]+$/i;\n\nconst patternPhone = /^[+][7]{1}[(]?[0-9]{3}[)]?[-\\s ]?[0-9]{3}[-\\s ]?[0-9]{2}[-\\s ]?[0-9]{2}$/;\n\nexport const formatPhone = (phone) => {\n const phoneDigits = phone.replace(/\\D/g, '');\n if (phoneDigits.length !== 11) return phone;\n return phoneDigits.replace(/(\\d{1})(\\d{3})(\\d{3})(\\d{2})(\\d{2})/, '+$1 ($2) $3-$4-$5');\n};\n\nexport function notEmptyObject(obj) {\n if (obj == null) return false;\n\n for (const k in obj) {\n return true;\n }\n\n return false;\n}\n\nfunction clearPhone(phone) {\n return phone.replace(/\\D/g, '');\n}\n\nconst ISODateRegex = new RegExp(/^(\\d{4})-(\\d{2})-(\\d{2})/);\nfunction formatDate(str) {\n if (!str) return null;\n\n const matches = ISODateRegex.exec(str);\n if (!matches) return null;\n\n const [, year, month, day] = matches;\n return `${day}.${month}.${year}`;\n}\n\nfunction unformatDate(str) {\n if (!str) return null;\n\n const [day, month, year] = str.split('.');\n return `${year}-${month}-${day}`;\n}\n\nfunction validateBik(bik, rs, ks) {\n var result = false;\n var error = {};\n if (typeof bik === 'number') {\n bik = bik.toString();\n } else if (typeof bik !== 'string') {\n bik = '';\n }\n if (!bik.length) {\n error.code = 1;\n error.message = 'БИК пуст';\n } else if (/[^0-9]/.test(bik)) {\n error.code = 2;\n error.message = 'БИК может состоять только из цифр';\n } else if (bik.length !== 9) {\n error.code = 3;\n error.message = 'БИК может состоять только из 9 цифр';\n } else {\n result = true;\n if (rs) {\n validateRs(rs, bik);\n }\n if (ks) {\n validateKs(ks, bik);\n }\n }\n return result;\n}\n\nfunction validateInn(inn) {\n let valid = false;\n if (inn.length === 10) {\n const sum = [2, 4, 10, 3, 5, 9, 4, 6, 8].reduce((res, n, i) => res + n * inn[i], 0);\n valid = parseInt((sum % 11) % 10) === parseInt(inn[9]);\n }\n if (inn.length === 12) {\n const sum11 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8].reduce((res, n, i) => res + n * inn[i], 0);\n const sum12 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8].reduce((res, n, i) => res + n * inn[i], 0);\n\n valid = parseInt((sum11 % 11) % 10) === parseInt(inn[10]) && parseInt((sum12 % 11) % 10) === parseInt(inn[11]);\n }\n return valid;\n}\n\nfunction validateVIN(vin) {\n let valid = false;\n let pattern = new RegExp('^[A, E, U, B, C, D, F, G, H, J, K, L, M, N, P, R, S, T, V, W, X, Y, Z0-9]{17}$');\n\n if (vin) {\n if (pattern.test(vin)) {\n valid = true;\n }\n }\n return valid;\n}\n\nfunction validateOgrn(ogrn) {\n var result = false;\n var error = {};\n if (typeof ogrn === 'number') {\n ogrn = ogrn.toString();\n } else if (typeof ogrn !== 'string') {\n ogrn = '';\n }\n if (!ogrn.length) {\n error.code = 1;\n error.message = 'ОГРН пуст';\n } else if (/[^0-9]/.test(ogrn)) {\n error.code = 2;\n error.message = 'ОГРН может состоять только из цифр';\n } else if (ogrn.length !== 13) {\n error.code = 3;\n error.message = 'ОГРН может состоять только из 13 цифр';\n } else {\n var n13 = parseInt((parseInt(ogrn.slice(0, -1)) % 11).toString().slice(-1));\n if (n13 === parseInt(ogrn[12])) {\n result = true;\n } else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n return result;\n}\n\nfunction validateKpp(kpp) {\n var result = false;\n var error = {};\n if (typeof kpp === 'number') {\n kpp = kpp.toString();\n } else if (typeof kpp !== 'string') {\n kpp = '';\n }\n if (!kpp.length) {\n error.code = 1;\n error.message = 'КПП пуст';\n } else if (kpp.length !== 9) {\n error.code = 2;\n error.message = 'КПП может состоять только из 9 знаков (цифр или заглавных букв латинского алфавита от A до Z)';\n } else if (!/^[0-9]{4}[0-9A-Z]{2}[0-9]{3}$/.test(kpp)) {\n error.code = 3;\n error.message = 'Неправильный формат КПП';\n } else {\n result = true;\n }\n return result;\n}\n\nfunction validateRs(rs, bik) {\n var result = false;\n var error = {};\n if (validateBik(bik)) {\n if (typeof rs === 'number') {\n rs = rs.toString();\n } else if (typeof rs !== 'string') {\n rs = '';\n }\n if (!rs.length) {\n error.code = 1;\n error.message = 'Р/С пуст';\n } else if (/[^0-9]/.test(rs)) {\n error.code = 2;\n error.message = 'Р/С может состоять только из цифр';\n } else if (rs.length !== 20) {\n error.code = 3;\n error.message = 'Р/С может состоять только из 20 цифр';\n } else {\n var bikRs = bik.toString().slice(-3) + rs;\n var checksum = 0;\n var coefficients = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1];\n for (var i in coefficients) {\n checksum += coefficients[i] * (bikRs[i] % 10);\n }\n if (checksum % 10 === 0) {\n result = true;\n } else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n }\n return result;\n}\n\nfunction validateKs(ks, bik) {\n var result = false;\n var error = {};\n if (validateBik(bik, error)) {\n if (typeof ks === 'number') {\n ks = ks.toString();\n } else if (typeof ks !== 'string') {\n ks = '';\n }\n if (!ks.length) {\n error.code = 1;\n error.message = 'К/С пуст';\n } else if (/[^0-9]/.test(ks)) {\n error.code = 2;\n error.message = 'К/С может состоять только из цифр';\n } else if (ks.length !== 20) {\n error.code = 3;\n error.message = 'К/С может состоять только из 20 цифр';\n } else {\n var bikKs = '0' + bik.toString().slice(4, 6) + ks;\n var checksum = 0;\n var coefficients = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1];\n for (var i in coefficients) {\n checksum += coefficients[i] * (bikKs[i] % 10);\n }\n if (checksum % 10 === 0) {\n result = true;\n } else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n }\n return result;\n}\n\nfunction validateSnils(snils, error) {\n var result = false;\n if (typeof snils === 'number') {\n snils = snils.toString();\n } else if (typeof snils !== 'string') {\n snils = '';\n }\n if (!snils.length) {\n error.code = 1;\n error.message = 'СНИЛС пуст';\n } else if (/[^0-9]/.test(snils)) {\n error.code = 2;\n error.message = 'СНИЛС может состоять только из цифр';\n } else if (snils.length !== 11) {\n error.code = 3;\n error.message = 'СНИЛС может состоять только из 11 цифр';\n } else {\n var sum = 0;\n for (var i = 0; i < 9; i++) {\n sum += parseInt(snils[i]) * (9 - i);\n }\n var checkDigit = 0;\n if (sum < 100) {\n checkDigit = sum;\n } else if (sum > 101) {\n checkDigit = parseInt(sum % 101);\n if (checkDigit === 100) {\n checkDigit = 0;\n }\n }\n if (checkDigit === parseInt(snils.slice(-2))) {\n result = true;\n } else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n return result;\n}\n\nfunction validDate(v) {\n const unDate = unformatDate(v);\n const date = parseISO(unDate);\n\n let res = false;\n if (isValid(date)) {\n res = true;\n }\n return res;\n}\n\nconst shortGroups = [\n {\n name: 'млн.',\n minValue: 1e6,\n },\n {\n name: 'млрд.',\n minValue: 1e9,\n },\n];\n\nexport function makeCurrencyWithShortGroup(value) {\n if (value == null) return null;\n\n if (typeof value === 'string') {\n value = Number(value);\n }\n\n if (!Number.isFinite(value)) return null;\n\n let output;\n\n const shortGroup = findLast(shortGroups, (item) => value >= item.minValue);\n if (shortGroup) {\n value /= shortGroup.minValue;\n output = makeCurrency(value.toFixed(2).toString() + ' ' + shortGroup.name);\n } else {\n output = makeCurrency(\n value.toLocaleString('ru-RU', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })\n );\n }\n\n return output;\n}\n\nconst shortToLongCompanyNameRegexes = [\n // FIXME: случайно вытащил из интернета, в окопф справочнике не нашёл\n ['^ИП', 'Индивидуальный предприниматель'],\n ['^ООО', 'Общество с ограниченной ответственностью'],\n ['^АО', 'Акционерное общество'],\n ['^ЗАО', 'Закрытое акционерное общество'],\n ['^ОАО', 'Открытое акционерное общество'],\n ['^ПАО', 'Публичное акционерное общество'],\n ['^НКО', 'Некоммерческая организация'],\n ['^ОДО', 'Общество с дополнительной ответственностью'],\n ['^ПТ', 'Полное товарищество'],\n ['^КТ', 'Коммандитное товарищество'],\n ['^ПК', 'Производственный кооператив'],\n];\nexport function transformShortCompanyNameToLong(companyName) {\n if (typeof companyName !== 'string') return null;\n\n const idx = shortToLongCompanyNameRegexes.findIndex(([regexPattern]) => new RegExp(regexPattern).test(companyName));\n if (idx === -1) return companyName;\n\n const [regexPattern, textToReplace] = shortToLongCompanyNameRegexes[idx];\n return companyName.replace(new RegExp(regexPattern), textToReplace);\n}\n\nexport function removeCompanyOkopfFromText(text) {\n if (typeof text !== 'string' || !text?.length) return null;\n\n for (const [pattern] of shortToLongCompanyNameRegexes) {\n const regex = new RegExp(pattern);\n if (regex.test(text)) {\n return text.replace(regex, '');\n }\n }\n\n return text;\n}\n\nconst monthsLabels = {\n forDay: ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'],\n default: ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'],\n};\nexport function getZeroBasedMonthLabel(monthNumberZeroBased, forDay) {\n if (typeof monthNumberZeroBased === 'string') {\n monthNumberZeroBased = Number(monthNumberZeroBased);\n }\n\n if (typeof monthNumberZeroBased !== 'number' || !Number.isFinite(monthNumberZeroBased)) return null;\n\n const labelType = forDay ? 'forDay' : 'default';\n return monthsLabels[labelType][monthNumberZeroBased];\n}\n\n/**\n * @param {String} access_key base64 string\n * @returns String\n */\nexport function prepareDownloadKeyAsLink(access_key) {\n return __API_URL__ + `file/get/?access_key=${encodeURIComponent(access_key)}`;\n}\n\nexport function getDownloadPageUrl({ type, value, companyid, scope }) {\n // FIXME: динамически подставлять ссылку на entry - использовать define от vite?\n const downloadPageUrl = new URL('/download_page.html', document.location);\n downloadPageUrl.searchParams.append('type', type);\n downloadPageUrl.searchParams.append('value', value);\n companyid && downloadPageUrl.searchParams.append('cid', companyid);\n scope && downloadPageUrl.searchParams.append('scope', scope);\n\n return downloadPageUrl.toString();\n}\n\nexport function tryToBlankWindow(url) {\n if (window.open(url, '_blank') == null) {\n return Promise.reject('Не удалось открыть новое окно ссылки, возможно браузер ограничивает это действие');\n }\n\n return Promise.resolve();\n}\n\nexport function transformSizeInBytesToHuman(sizeInBytes) {\n let postfix, size;\n\n if (sizeInBytes > 1_048_576) {\n // 1MB or more\n postfix = 'мегабайт';\n size = sizeInBytes / 1_048_576;\n } else if (sizeInBytes > 1024) {\n // 1KB or more\n postfix = 'килобайт';\n size = sizeInBytes / 1024;\n } else {\n postfix = 'байт';\n size = sizeInBytes;\n }\n\n return Math.floor(size).toString() + ' ' + postfix;\n}\n\n/**\n * @param {number} valueHundred\n */\nexport function transformNumberToPercentString(valueHundred) {\n if (valueHundred == null) return '\\u2014';\n\n if (typeof valueHundred !== 'number') {\n valueHundred = Number(valueHundred);\n }\n\n return valueHundred.toLocaleString('ru', { maximumFractionDigits: 2 }) + '%';\n}\n\nexport function parseDatetimeString(dateTimeString) {\n if (!dateTimeString || !dateTimeString.length) return null;\n\n const matches = dateTimeRegex.exec(dateTimeString);\n if (!matches) return null;\n\n const [, year, month, day, hour, minute, second] = matches;\n return { year, month, day, hour, minute, second };\n}\n\nexport function tryConvertYMDToDMYRussian(dateTimeString, includeTime = true) {\n const dateTime = parseDatetimeString(dateTimeString);\n if (!dateTime) return dateTimeString;\n\n const DMYDate = [dateTime.day, dateTime.month, dateTime.year].filter((part) => part != null).join('.');\n if (!includeTime) return DMYDate;\n\n const timeString = [dateTime.hour, dateTime.minute, dateTime.second].filter((part) => part != null).join(':');\n\n if (!DMYDate && !timeString) return '';\n else if (DMYDate && timeString) return DMYDate + ' ' + timeString;\n else if (!DMYDate) return timeString;\n\n return DMYDate;\n}\n\n/**\n * Полифилл для findLast\n * @param {Array} array\n * @param {Function} predicate\n * @returns any\n */\nexport function findLast(array, predicate) {\n if (!Array.isArray(array) || !array.length) return undefined;\n\n if (typeof array.findLast === 'function') {\n return array.findLast(predicate);\n }\n\n for (let i = array.length - 1; i >= 0; --i) {\n const item = array[i];\n if (predicate(item, i, array)) {\n return item;\n }\n }\n\n return undefined;\n}\n\nexport function securityViewText(item) {\n let output = '';\n if (item.$extra.has_guarantor || item.project.issurety != 'N' || item.project.ispledge != 'N') {\n if (item.$extra.has_guarantor) {\n output = output.length != 0 ? output + ', Гарантия выкупа' : 'Гарантия выкупа';\n }\n if (item.project.ispledge != 'N') {\n output = output.length != 0 ? output + ', Залог' : 'Залог';\n }\n if (item.project.issurety != 'N') {\n output = output.length != 0 ? output + ', Поручительство' : 'Поручительство';\n }\n } else {\n output = '\\u2014';\n }\n return output;\n}\n\n/**\n * Get a random integer between `min` and `max`.\n *\n * @param {number} min - min number\n * @param {number} max - max number\n * @return {number} a random integer\n */\nexport function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\n\n// FIXME: перетащить trap-focus в composable\n/**\n * @overload\n * @param {Node[]} list\n * @returns {HTMLElement[]}\n *\n * @param {...Node} list\n * @returns {HTMLElement[]}\n */\nexport function setTrapFocus(...list) {\n const trapFocusElements = [];\n\n const iterateNodes = Array.isArray(list[0]) ? list[0] : list;\n for (const trapNode of iterateNodes) {\n if (!trapNode) continue;\n\n let currentElement = trapNode.parentElement;\n while (currentElement != null) {\n for (const children of currentElement.children) {\n if (children === trapNode || iterateNodes.some((node) => children.contains(node))) continue;\n if (children.inert || children.getAttribute('tabindex') === '-1') continue;\n if (children === document.head) continue;\n if ('disallowInert' in children.dataset) continue;\n\n children.setAttribute('inert', '');\n children.setAttribute('tabindex', '-1');\n\n trapFocusElements.push(children);\n }\n\n currentElement = currentElement.parentElement;\n }\n }\n\n return trapFocusElements;\n}\n\n/**\n * @param {Array} trapFocusElements\n */\nexport function removeTrapFocus(trapFocusElements) {\n for (const focusElement of trapFocusElements) {\n if (!focusElement) continue;\n\n focusElement.removeAttribute('inert');\n focusElement.removeAttribute('tabindex'); // TODO: проверять что до этого не было установлено значение (>=0, ...)\n }\n}\n\nexport { patternEmail, patternPhone, clearPhone, formatDate, unformatDate, validateBik, validateInn, validateVIN, validateOgrn, validateKpp, validateRs, validateKs, validateSnils, validDate };\n"],"names":["dateTimeRegex","makeCurrency","val","curr","toNumericFormat","value","lastSeveralYears","lastYears","currentYear","yearsArr","i","dateDiff","date1","date2","years","months","days","datePassed","date","dateToCheck","currentDate","passed","makePlural","iNumber","endings","v1","v2","v3","sEnding","lastDigits","termActivity","turn","difference","differenceYear","differenceMonth","differenceDays","output","patternEmail","formatPhone","phone","phoneDigits","notEmptyObject","obj","k","clearPhone","ISODateRegex","formatDate","str","matches","year","month","day","unformatDate","validateBik","bik","rs","ks","result","validateRs","validateKs","validateInn","inn","valid","sum","res","n","sum11","sum12","validateKpp","kpp","bikRs","checksum","coefficients","error","bikKs","shortGroups","makeCurrencyWithShortGroup","shortGroup","findLast","item","shortToLongCompanyNameRegexes","transformShortCompanyNameToLong","companyName","idx","regexPattern","textToReplace","removeCompanyOkopfFromText","text","pattern","regex","monthsLabels","getZeroBasedMonthLabel","monthNumberZeroBased","forDay","prepareDownloadKeyAsLink","access_key","getDownloadPageUrl","type","companyid","scope","downloadPageUrl","tryToBlankWindow","url","transformSizeInBytesToHuman","sizeInBytes","postfix","size","transformNumberToPercentString","valueHundred","parseDatetimeString","dateTimeString","hour","minute","second","tryConvertYMDToDMYRussian","includeTime","dateTime","DMYDate","part","timeString","array","predicate","securityViewText","setTrapFocus","list","trapFocusElements","iterateNodes","trapNode","currentElement","children","node","removeTrapFocus","focusElement"],"mappings":"AAEA,MAAMA,EAAgB,IAAI,OAAO,kEAAkE,EAEtFC,EAAe,CAACC,EAAKC,EAAO,MAAQ,GAAGD,CAAG,IAASC,CAAI,GAEvDC,EAAmBC,GAC1BA,GAAS,KAAa,IAEnB,OAAOA,CAAK,EAAE,eAAe,QAAS,CAC3C,sBAAuB,EACvB,sBAAuB,CAAA,CACxB,EAGI,SAASC,EAAiBC,EAAW,CAC1C,IAAIC,EAAc,IAAI,KAAK,EAAE,YAAY,EACrCC,EAAW,CAAC,EAEhB,QAASC,EAAIH,EAAWG,EAAI,EAAG,EAAEA,EACtBD,EAAA,KAAKD,EAAcE,CAAC,EAGxB,OAAAD,CACT,CAEgB,SAAAE,EAASC,EAAOC,EAAO,CACrC,IAAIC,EAAQD,EAAM,YAAY,EAAID,EAAM,YAAY,EAChDG,EAASD,EAAQ,GAAKD,EAAM,SAAS,EAAID,EAAM,SAAS,EACxDI,EAAOH,EAAM,QAAQ,EAAID,EAAM,QAAQ,EAE3C,OAAAE,GAASD,EAAM,WAAaD,EAAM,SAAS,EAC3CG,GAAUF,EAAM,UAAYD,EAAM,QAAQ,EAC1CI,GAAQA,EAAO,EAAI,IAAI,KAAKH,EAAM,YAAY,EAAGA,EAAM,SAAA,EAAa,EAAG,CAAC,EAAE,QAAA,EAAY,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