(function () { function escapeHtml(value) { return String(value ?? '') .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } function formatDashboardDate(value) { if (!value) { return ''; } var date = new Date(value); if (Number.isNaN(date.getTime())) { return ''; } return new Intl.DateTimeFormat('en-US', { month: 'short', day: '2-digit', year: 'numeric', hour: 'numeric', minute: '2-digit', second: '2-digit' }).format(date); } function getClientRowKey(client) { return String(client && client.id ? client.id : client && client.clientId ? client.clientId : '').trim(); } function getClientDisplayName(client) { if (client && client.client_name) { return String(client.client_name).trim(); } var clientId = String(client && client.clientId ? client.clientId : '').trim(); if (clientId) { return clientId; } return ''; } function setButtonVariant(button, classesToRemove, classToAdd) { if (!button) { return; } if (button.classList) { classesToRemove.forEach(function (className) { button.classList.remove(className); }); if (classToAdd) { button.classList.add(classToAdd); } return; } var className = String(button.className || ''); classesToRemove.forEach(function (removeClass) { className = className.replace(new RegExp('(^|\\s)' + removeClass + '(?=\\s|$)', 'g'), ' '); }); if (classToAdd) { className += ' ' + classToAdd; } button.className = className.replace(/\s+/g, ' ').trim(); } function normalizeDisplayIp(value) { var ip = String(value || '').trim(); if (!ip) { return ''; } if (ip.toLowerCase().indexOf('::ffff:') === 0) { return ip.slice(7).trim(); } return ip; } window.webUiHelpers = { escapeHtml: escapeHtml, formatDashboardDate: formatDashboardDate, getClientRowKey: getClientRowKey, getClientDisplayName: getClientDisplayName, setButtonVariant: setButtonVariant, normalizeDisplayIp: normalizeDisplayIp }; }());