Function.prototype.TO_STRING = function() {
	return ('function ' + this.toString() + this.name + "();\n\n").PROPS({ await: 'await' });
}
Function.prototype.TO_STRING_RAW = function() {
	return this.toString().replaceAll(this.name + '()', '').replaceAll('function', '').PROPS({ await: 'await' });
}
String.prototype.TO_FLOAT = function()
{
    return parseFloat(this.replace('px', ''));
}
String.prototype.PROPS = function(props) {
	a = this;
	Object.keys(props).forEach
		(
			function(n) {
				a = a.replaceAll("<!--" + n + "-->", props[n]);
				a = a.replaceAll("/*" + n + "*/", props[n]);
				a = a.replaceAll(`'--${n}--'+`, props[n]);
				a = a.replaceAll(`'--${n}--' +`, props[n]);
				a = a.replaceAll("__" + n + "__", props[n]);
				a = a.replaceAll(">>" + n + "<<", props[n]);
			}
		)
	return a
}
function follow_to(t, pp)
{
    var t_y = t.style.getPropertyValue('top').TO_FLOAT();
    var t_x = t.style.getPropertyValue('left').TO_FLOAT();
    
    var o_y = pp.style.getPropertyValue('top').TO_FLOAT();
    var o_x = pp.style.getPropertyValue('left').TO_FLOAT();

    var d_y = t_y - o_y;
    var d_x = t_x - o_x;

    if(d_y < 0)
    {
        t.style.setProperty('top', t_y + 1);
    }
    else
    {
        t.style.setProperty('top', t_y - 1);
    }
    if(d_x < 0)
    {
        t.style.setProperty('left', t_x + 1);
    }
    else
    {
        t.style.setProperty('left', t_x - 1);
    }
    return {x: d_x, y: d_y };
}
class mono 
{
    constructor()
    {
        this.value = '';
    }
    Value(value)
    {
        this.value = value;
        return this;
    }
    Count(count)
    {
        mono.count = count;
        return this;
    }
}
mono.prototype.toString = function ()
{
    var r = this.value.PROPS({count:mono.count});
    mono.count++;
    console.log(mono.count);
    return r;
}
mono.count = 0;

function Play ()
{
    eval(play.value);
}
function ToPlay ()
{
    play.value = load.value;
}
function Cargar()
{
    load.value = localStorage.getItem('save');
}
function Salvar()
{   
    localStorage.setItem('save', save.value);
}
function Copy() 
{
    save.select();
    save.setSelectionRange(0, 99999); // For mobile devices

    // Copy the text inside the text field
    navigator.clipboard.writeText(save.value);
    
    // Alert the copied text
    alert("Copied the text: " + save.value);
}
function is_update (value)
{
    document.body.setAttribute('is_update', value.toString())
}