/* Minification failed. Returning unminified contents.
(1,1): run-time error CSS1019: Unexpected token, found '$'
(1,2): run-time error CSS1019: Unexpected token, found '('
(1,11): run-time error CSS1031: Expected selector, found ')'
(1,11): run-time error CSS1025: Expected comma or open brace, found ')'
(8,2): run-time error CSS1019: Unexpected token, found ')'
(9,1): run-time error CSS1019: Unexpected token, found '$'
(9,2): run-time error CSS1019: Unexpected token, found '('
(9,11): run-time error CSS1031: Expected selector, found ')'
(9,11): run-time error CSS1025: Expected comma or open brace, found ')'
(11,2): run-time error CSS1019: Unexpected token, found ')'
(13,10): run-time error CSS1031: Expected selector, found 'DocumentReadySite('
(13,10): run-time error CSS1025: Expected comma or open brace, found 'DocumentReadySite('
(25,10): run-time error CSS1031: Expected selector, found 'AtualizarTooltip('
(25,10): run-time error CSS1025: Expected comma or open brace, found 'AtualizarTooltip('
(31,10): run-time error CSS1031: Expected selector, found 'AtualizarAutoSizeTextArea('
(31,10): run-time error CSS1025: Expected comma or open brace, found 'AtualizarAutoSizeTextArea('
(37,10): run-time error CSS1031: Expected selector, found 'ReportarBug('
(37,10): run-time error CSS1025: Expected comma or open brace, found 'ReportarBug('
(41,14): run-time error CSS1031: Expected selector, found '='
(41,14): run-time error CSS1025: Expected comma or open brace, found '='
(42,10): run-time error CSS1031: Expected selector, found 'confirmar('
(42,10): run-time error CSS1025: Expected comma or open brace, found 'confirmar('
(61,10): run-time error CSS1031: Expected selector, found 'alertar('
(61,10): run-time error CSS1025: Expected comma or open brace, found 'alertar('
(73,10): run-time error CSS1031: Expected selector, found 'isFloat('
(73,10): run-time error CSS1025: Expected comma or open brace, found 'isFloat('
(84,10): run-time error CSS1031: Expected selector, found 'isNullOrWhitespace('
(84,10): run-time error CSS1025: Expected comma or open brace, found 'isNullOrWhitespace('
(91,10): run-time error CSS1031: Expected selector, found 'getTagHtmlByIdFromHtmlString('
(91,10): run-time error CSS1025: Expected comma or open brace, found 'getTagHtmlByIdFromHtmlString('
(95,10): run-time error CSS1031: Expected selector, found 'getParameterByName('
(95,10): run-time error CSS1025: Expected comma or open brace, found 'getParameterByName('
(105,10): run-time error CSS1031: Expected selector, found 'removeParam('
(105,10): run-time error CSS1025: Expected comma or open brace, found 'removeParam('
(123,10): run-time error CSS1031: Expected selector, found 'getAverageRGB('
(123,10): run-time error CSS1025: Expected comma or open brace, found 'getAverageRGB('
(169,10): run-time error CSS1031: Expected selector, found 'colocarEmNegrito('
(169,10): run-time error CSS1025: Expected comma or open brace, found 'colocarEmNegrito('
(176,10): run-time error CSS1031: Expected selector, found 'colocarCorEmNumeros('
(176,10): run-time error CSS1025: Expected comma or open brace, found 'colocarCorEmNumeros('
(191,10): run-time error CSS1031: Expected selector, found 'removerAcentuacao('
(191,10): run-time error CSS1025: Expected comma or open brace, found 'removerAcentuacao('
(207,10): run-time error CSS1031: Expected selector, found 'formatarDescricaoSkill('
(207,10): run-time error CSS1025: Expected comma or open brace, found 'formatarDescricaoSkill('
(210,112): Scanner error CSS1002: Unterminated string: ');
 */
$(document).ready(function () {    
    DocumentReadySite();
    Date.prototype.addHours = function (h) {
        this.setHours(this.getHours() + h);
        return this;
    }
    //new Date().addHours(144)
});
$(document).on('load', function () {
    SomeeAdsRemover();
});

function DocumentReadySite() {
    $('.datemask').inputmask('99/99/9999');
    $('.datetimemask').inputmask('99/99/9999 99:99:99');
    $('.valormask').inputmask('currency');
    $('.tresnumeros').inputmask('999');
    $('.quatronumeros').inputmask('9999');
    $('.cinconumeros').inputmask('99999');
    $('.deznumeros').inputmask('9999999999');
    autosize($('textarea'));
    AtualizarTooltip();
}

function AtualizarTooltip() {
    $(".tooltip").tooltip("hide");
    $('[data-toggle="tooltip"]').tooltip('dispose');
    $('[data-toggle="tooltip"]').tooltip({ boundary: 'window' });
}

function AtualizarAutoSizeTextArea() {
    setTimeout(function() {
        autosize.update(document.querySelector('textarea'));
    }, 200);
}

function ReportarBug(assunto, corpo) {
    var resultReportarBug = $.post("/Notificacao/ReportarBug", { assunto: assunto, corpo: corpo });
}

var _confirm = false;
function confirmar(button) {
    if (_confirm == false) {
        swal({
            title: "Você tem certeza?",
            text: "Essa ação não pode ser desfeita!",
            type: "warning",
            showCancelButton: true,
            cancelButtonText: 'Não',
            confirmButtonColor: "#FF7043",
            confirmButtonText: "Sim, eu quero excluir!",
            closeOnConfirm: true
        }, function () {
            _confirm = true;
            button.click();
        });
    }
    return _confirm;
}

function alertar(title, text, type) {
    type = typeof type === 'undefined' ? 'warning' : type;
    swal({
        title: title,
        text: text,
        type: type,
        closeOnConfirm: true
    }, function () {
        window.location.href = removeParam("modal", window.location.href);
    });
}

function isFloat(val) {
    var floatRegex = /^-?\d+(?:[.,]\d*?)?$/;
    if (!floatRegex.test(val))
        return false;

    val = parseFloat(val);
    if (isNaN(val))
        return false;
    return true;
}

function isNullOrWhitespace(input) {

    if (typeof input === 'undefined' || input == null) return true;

    return input.replace(/\s/g, '').length < 1;
}

function getTagHtmlByIdFromHtmlString(html, id) {
    return (new DOMParser()).parseFromString(html, 'text/html').getElementById(id).innerHTML;
}

function getParameterByName(name, url) {
    url = typeof url === 'undefined' ? window.location.href : url;
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function removeParam(key, sourceURL) {
    var rtn = sourceURL.split("?")[0],
        param,
        params_arr = [],
        queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
    if (queryString !== "") {
        params_arr = queryString.split("&");
        for (var i = params_arr.length - 1; i >= 0; i -= 1) {
            param = params_arr[i].split("=")[0];
            if (param === key) {
                params_arr.splice(i, 1);
            }
        }
        rtn = rtn + "?" + params_arr.join("&");
    }
    return rtn;
}

function getAverageRGB(imgEl) {

    var blockSize = 5, // only visit every 5 pixels
        defaultRGB = { r: 0, g: 0, b: 0 }, // for non-supporting envs
        canvas = document.createElement('canvas'),
        context = canvas.getContext && canvas.getContext('2d'),
        data, width, height,
        i = -4,
        length,
        rgb = { r: 0, g: 0, b: 0 },
        count = 0;

    if (!context) {
        return defaultRGB;
    }

    height = canvas.height = imgEl.naturalHeight || imgEl.offsetHeight || imgEl.height;
    width = canvas.width = imgEl.naturalWidth || imgEl.offsetWidth || imgEl.width;

    context.drawImage(imgEl, 0, 0);

    try {
        data = context.getImageData(0, 0, width, height);
    } catch (e) {
        /* security error, img on diff domain */alert('x');
        return defaultRGB;
    }

    length = data.data.length;

    while ((i += blockSize * 4) < length) {
        ++count;
        rgb.r += data.data[i];
        rgb.g += data.data[i + 1];
        rgb.b += data.data[i + 2];
    }

    // ~~ used to floor values
    rgb.r = ~~(rgb.r / count);
    rgb.g = ~~(rgb.g / count);
    rgb.b = ~~(rgb.b / count);

    return rgb;

}

function colocarEmNegrito(texto, cor) {
    if (isNullOrWhitespace(cor) == false)
        return "<b style=\"color: " + cor + ";\">" + texto + "</b>";
    else
        return "<b>" + texto + "</b>";
}

function colocarCorEmNumeros(texto, cor) {
    texto = texto.replaceAll("0", "<span style=\"color: " + cor + ";\">" + "0" + "</span>");
    texto = texto.replaceAll("1", "<span style=\"color: " + cor + ";\">" + "1" + "</span>");
    texto = texto.replaceAll("2", "<span style=\"color: " + cor + ";\">" + "2" + "</span>");
    texto = texto.replaceAll("3", "<span style=\"color: " + cor + ";\">" + "3" + "</span>");
    texto = texto.replaceAll("4", "<span style=\"color: " + cor + ";\">" + "4" + "</span>");
    texto = texto.replaceAll("5", "<span style=\"color: " + cor + ";\">" + "5" + "</span>");
    texto = texto.replaceAll("6", "<span style=\"color: " + cor + ";\">" + "6" + "</span>");
    texto = texto.replaceAll("7", "<span style=\"color: " + cor + ";\">" + "7" + "</span>");
    texto = texto.replaceAll("8", "<span style=\"color: " + cor + ";\">" + "8" + "</span>");
    texto = texto.replaceAll("9", "<span style=\"color: " + cor + ";\">" + "9" + "</span>");

    return texto;
}

function removerAcentuacao(text) {
    return text
        .replaceAll(/[áàãâä]/g, 'a')
        .replaceAll(/[éèêë]/g, 'e')
        .replaceAll(/[íìîï]/g, 'i')
        .replaceAll(/[óòõôö]/g, 'o')
        .replaceAll(/[úùûü]/g, 'u')
        .replaceAll(/[ç]/g, 'c')
        .replaceAll(/[ÁÀÃÂÄ]/g, 'A')
        .replaceAll(/[ÉÈÊË]/g, 'E')
        .replaceAll(/[ÍÌÎÏ]/g, 'I')
        .replaceAll(/[ÓÒÕÔÖ]/g, 'O')
        .replaceAll(/[ÚÙÛÜ]/g, 'U')
        .replaceAll(/[Ç]/g, 'C');
}

function formatarDescricaoSkill(str, aspas) {
    // substitui cada palavra entre aspas por uma tag HTML
    if (aspas == "'")
        str = str.replace(/(['"])(.*?)\1/g, '<span style="color:orange; text-decoration:underline;">$2</span>');
    else if (aspas == "’")
        str = str.replace(/([’])(.*?)\1/g, '<span style="color:orange; text-decoration:underline;">$2</span>');

    // expressão regular para buscar palavras "mana"
    str = str.replace(/\bmana(s)?\b/gi, `<span style="text-decoration:underline; color:deepskyblue;">$&</span>`);

    // expressão regular para buscar palavras "energia"
    str = str.replace(/\benergia(s)?\b/gi, `<span style="text-decoration:underline; color:deepskyblue;">$&</span>`);

    // expressão regular para buscar palavras "atordoar" e suas conjugações
    const regexAtordoar = /\b(atordo[aei]?|atordoad[ao]?s?|atordoem|atordoante[s]?|atordoado[s]?|atordoamento|atordoabilidade|atordoaríamos|atordoável[mns]?|atordoaria[mns]?|atordoará[smn]?|atordoáreis|atordoarei|atordoaria|atordoas|atordoa|atordoada|atordoado|atordoai|atordoavam|atordoava|atordoam|atordoar|atordoando)(-[a-z]+)?\b/gi;
    str = str.replace(regexAtordoar, '<span style="color:greenyellow; text-decoration:underline;">$&</span>');

    // expressão regular para buscar palavras "dano" e suas variações (ignorando o caso)
    str = str.replace(/\bdano(s)?\b/gi, '<span style="color:red; text-decoration:underline;">$&</span>');

    // expressão regular para buscar palavras "curar" e suas variações
    const regexCurar = /\b(cur[ao]|curado|curando-o|curando|curou|curav[ae]|curava[mns]?|curai|curam|cure|curará[smn]?|curar[eiá](s|mos|s|em)?|cura[rz](es)?|curáveis?)\b/gi;
    str = str.replace("curará", '<span style="color:lightseagreen; text-decoration:underline;">curará</span>');
    str = str.replace(regexCurar, '<span style="color:lightseagreen; text-decoration:underline;">$&</span>');

    // expressão regular para buscar palavras "imune" e suas variações
    const regexImune = /\b(imun[ei]dade|imun[io]l[óo]gic[oa]s?|imunizados?|imune?s?|imunizantes?|imunologista[sz]?|imunidade|imunobiológic[oa]s?|imunocit[óo]log[oa]s?|imunodepressores?|imunodeficient[ée]ncias?)\b/gi;
    str = str.replace(regexImune, '<span style="color:darkred; text-decoration:underline;">$&</span>');

    // expressão regular para buscar a palavra "invulnerável" e suas variações
    const regexInvulneravel = /\b(invulnerável|invulner[áa]veis?|invulner[áa]bil[íií]dade)\b/gi;
    str = str.replace(regexInvulneravel, '<span style="color:darkblue; text-decoration:underline;">$&</span>');

    // expressão regular para buscar palavras "inalvejável" e suas variações
    str = str.replace(/\b(inalvejáveis?|inalvejávei[so]?|inalvejand[oai]?|inalvejado|inalvejável)\b/gi, `<span style="text-decoration:underline; color:blue;">$&</span>`);
    
    return str;
}

function ctrlC(texto) {
    var selBox = document.createElement('textarea');
    selBox.style.position = 'fixed';
    selBox.style.left = '0';
    selBox.style.top = '0';
    selBox.style.opacity = '0';
    selBox.value = texto;
    document.body.appendChild(selBox);
    selBox.focus();
    selBox.select();
    document.execCommand('copy');
    document.body.removeChild(selBox);
}

function ctrlCbyId(id) {
    ctrlC($("#" + id).val());
}

function copiarValorInputFilho(id) {
    ctrlC($('#' + id + ' > input').val());
}

function TrocarTipoInputSenha(idInput) {
    var x = document.getElementById(idInput);
    if (x.type === "password") {
        x.type = "text";
    } else {
        x.type = "password";
    }
}

function dataFormatada(datejs) {
    var data = datejs,
        dia = data.getDate().toString(),
        diaF = (dia.length == 1) ? '0' + dia : dia,
        mes = (data.getMonth() + 1).toString(), //+1 pois no getMonth Janeiro começa com zero.
        mesF = (mes.length == 1) ? '0' + mes : mes,
        anoF = data.getFullYear();
    return diaF + "/" + mesF + "/" + anoF;
}
function FecharTodasEAbrirModal(elemento) {
    $('.modal').modal('hide');
    setTimeout(function () {
        $(elemento).modal('show');
    }, 50);
}

function AbrirLoading() {
    $("#ModalLoad").modal('show');
}

function FecharLoading() {
    setTimeout(
        function () {
            $("#ModalLoad").modal('hide');
        }, 50);    
}

async function EsperarUmTempo(tempoMilisegundos) {
    await $(window).delay(tempoMilisegundos).promise();
}

function playAudio(audioFile, volume) {
    if (volume > 0) {
        var audio = new Audio(audioFile);
        audio.volume = volume > 1 ? 1 : volume;
        audio.play();
    }
}

function htmlDiferentes(htmlAntes, htmlDepois) {
    let parser = new DOMParser();
    let doc = parser.parseFromString(htmlAntes, 'text/html');
    let elementsWithAria = doc.querySelectorAll('[aria-describedby]');
    elementsWithAria.forEach(element => {
        element.removeAttribute('aria-describedby');
    });

    let parser2 = new DOMParser();
    let doc2 = parser2.parseFromString(htmlDepois, 'text/html');
    let elementsWithAria2 = doc2.querySelectorAll('[aria-describedby]');
    elementsWithAria2.forEach(element => {
        element.removeAttribute('aria-describedby');
    });

    return doc.body.innerHTML != doc2.body.innerHTML;
}

function ArrayHasDuplicates(array) {
    const uniqueValues = new Set(array);
    return uniqueValues.size !== array.length;
}

function isMobile() {
    let check = false;
    (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
    return check;
}

function eventPreventDefault(event) {
    event.preventDefault();
}

function removerReferencia(obj) {
    return JSON.parse(JSON.stringify(obj));
}

function montarTempoRestante(inicio, fim) {
    const diferenca = fim - inicio;
    const horas = Math.floor(diferenca / (1000 * 60 * 60));
    const minutos = Math.floor((diferenca % (1000 * 60 * 60)) / (1000 * 60));
    const segundos = Math.floor((diferenca % (1000 * 60)) / 1000);
    if (horas > 0) {
        return `${horas}h ${minutos}m ${segundos}s`;
    }
    if (minutos > 0) {
        return `${minutos}m ${segundos}s`;
    }
    return `${segundos}s`;
}

function ganheiRNG(chanceDeDarCerto, valorMaximoMaisUm = 101, seed = null) {
    let numeroSorteado;

    if (seed !== null) {
        // Usa a seed fornecida para gerar número determinístico
        const random = () => {
            seed = (seed * 9301 + 49297) % 233280;
            return seed / 233280;
        };
        numeroSorteado = Math.floor(random() * (valorMaximoMaisUm - 1)) + 1;
    } else {
        // Gera número verdadeiramente aleatório
        numeroSorteado = Math.floor(Math.random() * (valorMaximoMaisUm - 1)) + 1;
    }

    return chanceDeDarCerto >= numeroSorteado;
}

function generateGuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        const r = Math.random() * 16 | 0; // Gera um número aleatório entre 0 e 15
        const v = c === 'x' ? r : (r & 0x3 | 0x8); // Garante que o 'y' seja 8, 9, A ou B
        return v.toString(16); // Converte para hexadecimal
    });
}

function parseFloatDuasCasasDecimais(valor) {
    return parseFloat(parseFloat(valor).toFixed(2));
}

function addTimeToDate(newDate, time, porcentagem = 100) {
    if (time == null) {
        return newDate;
    }

    // Calcula o fator de aceleração
    const fator = porcentagem / 100;

    let ehObjeto = time.Days > 0 || time.Hours > 0 || time.Minutes > 0 || time.Seconds > 0;
    if (ehObjeto) {
        if (time.Days > 0) {
            newDate.setHours(newDate.getHours() + Math.round((time.Days * 24) / fator));
        }
        if (time.Hours > 0) {
            newDate.setHours(newDate.getHours() + Math.round(time.Hours / fator));
        }
        if (time.Minutes > 0) {
            newDate.setMinutes(newDate.getMinutes() + Math.round(time.Minutes / fator));
        }
        if (time.Seconds > 0) {
            newDate.setSeconds(newDate.getSeconds() + Math.round(time.Seconds / fator));
        }
        return newDate;
    }

    const regex = /(?:(\d+)\.)?(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?/;
    const match = time.match(regex);
    if (match) {
        const days = parseInt(match[1] || 0, 10);
        const hours = parseInt(match[2] || 0, 10);
        const minutes = parseInt(match[3] || 0, 10);
        const seconds = parseInt(match[4] || 0, 10);
        const milliseconds = Math.round(parseFloat("0." + (match[5] || "0")) * 1000);
        newDate.setUTCDate(newDate.getUTCDate() + Math.round(Number(days) / fator));
        newDate.setUTCHours(newDate.getUTCHours() + Math.round(hours / fator));
        newDate.setUTCMinutes(newDate.getUTCMinutes() + Math.round(minutes / fator));
        newDate.setUTCSeconds(newDate.getUTCSeconds() + Math.round(seconds / fator));
        newDate.setUTCMilliseconds(newDate.getUTCMilliseconds() + Math.round(milliseconds / fator));
        return newDate;
    } else if (time.length >= 10) {
        debugger;
        const [days, tempo] = time.split('.');
        const [hours, minutes, seconds] = tempo.split(':').map(Number);
        newDate.setUTCDate(newDate.getUTCDate() + Math.round(Number(days) / fator));
        newDate.setUTCHours(newDate.getUTCHours() + Math.round(hours / fator));
        newDate.setUTCMinutes(newDate.getUTCMinutes() + Math.round(minutes / fator));
        newDate.setUTCSeconds(newDate.getUTCSeconds() + Math.round(seconds / fator));
        return newDate;
    } else {
        debugger;
        const [hours, minutes, seconds] = time.split(':').map(Number);
        newDate.setHours(newDate.getHours() + Math.round(hours / fator));
        newDate.setMinutes(newDate.getMinutes() + Math.round(minutes / fator));
        newDate.setSeconds(newDate.getSeconds() + Math.round(seconds / fator));
        return newDate;
    }
}

function dateToString(date) {
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0'); // Meses começam em 0
    const day = String(date.getDate()).padStart(2, '0');
    const hours = String(date.getHours()).padStart(2, '0');
    const minutes = String(date.getMinutes()).padStart(2, '0');
    const seconds = String(date.getSeconds()).padStart(2, '0');
    const milliseconds = String(date.getMilliseconds()).padStart(3, '0');
    return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;
}

function stringToDate(obj) {
    if (typeof obj.getMonth === 'function')
        return obj;

    const timestampMatch = obj.match(/\/Date\((\d+)\)\//);
    if (timestampMatch && timestampMatch[1]) {
        const timestamp = parseInt(timestampMatch[1], 10); // Converte para número
        return new Date(timestamp); // Cria o objeto Date
    }

    return new Date(obj);
}

function getTimeString(now = null) {
    if (now == null) {
        now = new Date();
    }
    const hours = String(now.getHours()).padStart(2, '0');
    const minutes = String(now.getMinutes()).padStart(2, '0');
    const seconds = String(now.getSeconds()).padStart(2, '0');
    const milliseconds = String(now.getMilliseconds()).padStart(3, '0');

    return `${hours}:${minutes}:${seconds}.${milliseconds}`;
}

function arredondar(num) {
    return +(Math.round(num + "e+1") + "e-1");
}

function numberToString(txt) {
    try {
        if (isNaN(txt))
            return "0";
        return txt.toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 2, useGrouping: false });
    } catch (e) {
        return txt;
    }
}

function swal2(swalobj) {
    Swal.fire(swalobj);
}

function SomeeAdsRemover() {
    $("center").each(function () {
        if ($(this).html() == '<a href="http://somee.com">Web hosting by Somee.com</a>') {
            $(this).next().remove();
            $(this).next().next().remove();
            $(this).next().next().next().remove();
            $(this).remove();

            return false;
        }
        $("div[style='opacity: 0.9; z-index: 2147483647; position: fixed; left: 0px; bottom: 0px; height: 65px; right: 0px; display: block; width: 100%; background-color: #202020; margin: 0px; padding: 0px;']").addClass('hidden');
        $("div[style='position: fixed; z-index: 2147483647; left: 0px; bottom: 0px; height: 65px; right: 0px; display: block; width: 100%; background-color: transparent; margin: 0px; padding: 0px;']").addClass('hidden');
        $("div[style='height: 65px;']").addClass('hidden');
    });
}
