text:
import unittest
import os
import sys
PACKAGE_ROOT = '../..'
SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(),
                                                           os.path.expanduser(__file__))))
PACKAGE_PATH = os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_ROOT))
sys.path.append(PACKAGE_PATH)
from projects.selenium_tests.base_tests import BaseProjectsTests
from zachsite.selenium_tests.pages import LoginPage, LogoutPage
from geopost.selenium_tests.pages import GeopostEntryPage, GeopostHomePage
from selenium import webdriver

class EntryTests(BaseProjectsTests, unittest.TestCase):
    """
    Methods to test the entry page of the app (create/edit/delete).
    """

    def setUp(self):
        """
        Make driver, page, sign in.
        """
        with open('/etc/zachsite_test_creds.txt') as f:
            testCreds = f.readlines()
        self.driver = webdriver.Firefox()
        self.driver.get(LoginPage.URL)
        self.page = LoginPage(self.driver)
        self.page.enter_username(testCreds[0].strip())
        self.page.enter_password(testCreds[1].strip())
        self.page.login()
        self.driver.get(GeopostEntryPage.URL)
        self.page = GeopostEntryPage(self.driver)

    def tearDown(self):
        """
        Close driver.
        """
        self.driver.get(LogoutPage.URL)
        self.page = LogoutPage(self.driver)
        self.assertTrue(self.page.verify_logged_out())
        self.driver.close()

    def test_attribution_displayed(self):
        """
        Test that the attribution is displayed initially, and that it
        collapses after click.
        """
        self.assertTrue(self.page.verify_attribution_displayed())

    def test_toolbar_open_and_close(self):
        """
        Make sure the toolbar opens and closes when toggled.
        """
        self.assertTrue(self.page.verify_toolbar_displayed())
        self.page.toggle_toolbar()
        self.assertTrue(self.page.verify_toolbar_not_displayed())
        self.page.toggle_toolbar()
        self.assertTrue(self.page.verify_toolbar_displayed())

    def test_toggle_draw(self):
        """
        Turn draw interaction on and off.
        """
        self.assertTrue(self.page.verify_draw_not_active())
        self.page.toggle_draw()
        self.assertTrue(self.page.verify_draw_active())
        self.page.toggle_draw()
        self.assertTrue(self.page.verify_draw_not_active())

    def test_toggle_modify(self):
        """
        Turn modify on and off.
        """
        # first draw a point so that modify button is present
        self.page.toggle_draw()
        self.page.draw_point()
        self.assertTrue(self.page.verify_modify_not_active())
        self.page.toggle_modify()
        self.assertTrue(self.page.verify_modify_active())
        self.page.toggle_modify()
        self.assertTrue(self.page.verify_modify_not_active())

    def test_create_new_entry_and_delete(self):
        """
        Draw point, fill in form, submit.
        """
        # read parameter file
        with open(SCRIPT_DIR + '/data_new_entry_valid.csv') as f:
            testData = f.readlines()
        # run subtests
        for paramList in testData:
            params = paramList.split(',')
            with self.subTest(params=params):
                # reload page for each subtest
                self.driver.get(GeopostEntryPage.URL)
                self.page = GeopostEntryPage(self.driver)
                # enter details and submit
                self.page.toggle_draw()
                self.page.draw_point()
                self.page.enter_title(params[0])
                self.page.enter_body(params[1])
                self.page.choose_photo(SCRIPT_DIR + params[2].strip())
                self.page.submit_form()
                # verify that entry was created successfully
                self.page = GeopostHomePage(self.driver)
                self.assertTrue(self.page.verify_path(time=8))
                self.assertTrue(
                        self.page.verify_entry_exists_by_title(params[0])
                )
                # Delete the newly created post
                self.page.delete_by_title(params[0])
                # Verify that the delete worked
                self.driver.get(GeopostHomePage.URL)
                self.assertTrue(self.page.verify_path(time=8))
                self.assertFalse(
                        self.page.verify_entry_exists_by_title(params[0])
                )

    def test_create_edit_delete(self):
        """
        Create a point, edit it, delete it.
        """
        # read parameter file
        with open(SCRIPT_DIR + '/data_edit_entry_valid.csv') as f:
            testData = f.readlines()
        # run subtests
        for paramList in testData:
            params = paramList.split(',')
            with self.subTest(params=params):
                # reload page for each subtest
                self.driver.get(GeopostEntryPage.URL)
                self.page = GeopostEntryPage(self.driver)
                # make new entry
                self.page.toggle_draw()
                self.page.draw_point()
                self.page.enter_title(params[0])
                self.page.enter_body(params[1])
                self.page.choose_photo(SCRIPT_DIR + params[2].strip())
                self.page.submit_form()
                # verify that entry was created successfully
                self.page = GeopostHomePage(self.driver)
                self.assertTrue(self.page.verify_path(time=12))
                self.assertTrue(
                        self.page.verify_entry_exists_by_title(params[0])
                )
                # edit the entry
                self.page.edit_by_title(params[0])
                self.page = GeopostEntryPage(self.driver)
                self.assertTrue(self.page.verify_path(time=8))
                self.assertEqual(self.page.get_title(), params[0])
                self.assertEqual(self.page.get_body(), params[1])
                self.page.draw_point()
                self.page.enter_title(params[3])
                self.page.enter_body(params[4])
                self.page.choose_photo(SCRIPT_DIR + params[5].strip())
                self.page.submit_form()
                # verify that entry was edited successfully
                self.page = GeopostHomePage(self.driver)
                self.assertTrue(self.page.verify_path(time=8))
                self.assertTrue(
                        self.page.verify_entry_exists_by_title(params[3])
                )
                # Delete the newly created post
                self.page.delete_by_title(params[3])
                # Verify that the delete worked
                self.assertFalse(
                        self.page.verify_entry_exists_by_title(params[3])
                )

if __name__ == '__main__':
    unittest.main()


text:
package org.openqa.selenium.firefox.internal;

import com.google.common.io.Closeables;
import com.google.common.io.Resources;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.io.FileHandler;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;

public class ClasspathExtension implements Extension {
  private final Class<?> loadResourcesUsing;
  private final String loadFrom;

  public ClasspathExtension(Class<?> loadResourcesUsing, String loadFrom) {
    this.loadResourcesUsing = loadResourcesUsing;
    this.loadFrom = loadFrom;
  }

  public void writeTo(File extensionsDir) throws IOException {
    if (!FileHandler.isZipped(loadFrom)) {
      throw new WebDriverException("Will only install zipped extensions for now");
    }

    File holdingPen = new File(extensionsDir, "webdriver-staging");
    FileHandler.createDir(holdingPen);

    File extractedXpi = new File(holdingPen, loadFrom);
    File parentDir = extractedXpi.getParentFile();
    if (!parentDir.exists()) {
      parentDir.mkdirs();
    }

    URL resourceUrl = Resources.getResource(loadResourcesUsing, loadFrom);
    OutputStream stream = null;

    try {
      stream = new FileOutputStream(extractedXpi);
      Resources.copy(resourceUrl, stream);
    } finally {
      Closeables.close(stream, false);
    }
    new FileExtension(extractedXpi).writeTo(extensionsDir);
  }
}

redpajama_set_name: RedPajamaGithub


text:
cwd=`pwd`
echo Adding $cwd to path...
export PATH=$cwd:$PATH


text:
package com.easemob;

import com.easemob.server.example.api.impl.EasemobAuthToken;
import io.swagger.client.ApiException;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by easemob on 2017/3/21.
 */
public class TokenGenerateTest {
    private EasemobAuthToken easemobAuthToken = new EasemobAuthToken();

    @Test
    public void testTokenGet() throws ApiException {
        System.out.println(easemobAuthToken.getAuthToken());
        Assert.assertNotNull(easemobAuthToken.getAuthToken());
    }
}


text:
'use strict';

/**
 * @ngdoc service
 * @name wwwApp.AuthService
 * @description
 * # AuthService
 * Service in the wwwApp.
 */
angular.module('wwwApp')
    .service('AuthService', function ($http, Session, storage, config) {
        var self = {
            login: function (credentials) {
                return $http
                    .post(config.api.baseURL + '/sessions', credentials)
                    .then(function (res) {

                        var session = {token: res.data.token, user_id: res.data.user_id, role: 'user'};
                        Session.create(session.token, session.user_id, session.role);
                        storage.set('session', session)
                    });
            },
            logout: function() {
                Session.destroy();
                storage.remove('session');
            },
            isAuthenticated: function () {
                return !!Session.userId;
            },
            isAuthorized: function (authorizedRoles) {
                if (!angular.isArray(authorizedRoles)) {
                    authorizedRoles = [authorizedRoles];
                }
                return (self.isAuthenticated() &&
                authorizedRoles.indexOf(Session.userRole) !== -1);
            },
            getToken: function() {
                return Session.userId && Session.id ? Session.id : null;
            }
        };
        return self;
    })


text:
package oj.macros;

import ij.IJ;
import ij.macro.Interpreter;
import ij.macro.MacroConstants;
import ij.macro.MacroRunner;
import ij.macro.Program;
import ij.macro.Symbol;
import ij.macro.Tokenizer;
import java.util.StringTokenizer;
import oj.gui.MenuManagerOJ;

public class MacroProgramOJ implements MacroConstants {

    private Program pgm;
    private String[] macroNames;
    private int[] macroStarts;

    public Program getProgram() {
        return pgm;
    }

    public int getMacroStarts(String name) {
        int index = indexOfMacro(name);
        if (index >= 0) {
            return macroStarts[index];
        }
        return 0;
    }

    private int indexOfMacro(String name) {
        for (int i = 0; i < macroNames.length; i++) {
            if (macroNames[i].equals(name)) {
                return i;
            }
        }
        return -1;
    }

    public void install(String macroText) {
        if (macroText != null) {
            Tokenizer tok = new Tokenizer();
            pgm = tok.tokenize(macroText);
        }
    }

    public void install(String macroText, int macroCount) {
        MenuManagerOJ.getInstance().clearSubMenus();

        Interpreter instance = Interpreter.getInstance();//8.4.2015
        if (instance != null) { // abort any currently running macro
            instance.abortMacro();
            long t0 = System.currentTimeMillis();
            while (Interpreter.getInstance() != null && (System.currentTimeMillis() - t0) < 3000L) {
                IJ.wait(10);
            }
        }
		//new MacroRunner(text, debug?this:null);

        macroNames = new String[macroCount];
        macroStarts = new int[macroCount];

        if (macroText != null) {
            Tokenizer tok = new Tokenizer();
            pgm = tok.tokenize(macroText);
        }
        int[] code = pgm.getCode();

        Symbol[] symbolTable = pgm.getSymbolTable();

        int address;
        int token;
        int nextToken;
        int count = 0;
        Symbol symbol;
        String name;

        if (pgm.hasVars() && pgm.macroCount() > 0 && pgm.getGlobals() == null) {
            new Interpreter().saveGlobals(pgm);
        }
        for (int i = 0; i < code.length; i++) {
            token = code[i] & TOK_MASK;
            if (token == MACRO) {
                nextToken = code[i + 1] & TOK_MASK;
                if (nextToken == STRING_CONSTANT) {
                    address = code[i + 1] >> TOK_SHIFT;
                    symbol = symbolTable[address];
                    name = extractMacroName(symbol.str);
                    if (!name.startsWith("Unused")) {
                        macroStarts[count] = i + 2;
                        macroNames[count] = name;
                        count++;
                    }
                }
            } else if (token == EOF) {
                break;
            }
        }
    }

    private String extractMacroName(String macroExtName) {

        int toolIndex = macroExtName.indexOf("Tool");//25.9.2013
        int minusIndex = macroExtName.lastIndexOf("-");

        if (toolIndex > 0 && minusIndex > toolIndex) {
            return macroExtName.substring(0, toolIndex + 4);
        } else {
            StringTokenizer st = new StringTokenizer(macroExtName, "[", true);
            if (st.hasMoreTokens()) {
                return st.nextToken().trim();
            }
        }
        return null;
    }
}


text:
/*************************************************************************/
/*  animation_blend_tree.cpp                                             */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                      https://godotengine.org                          */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).   */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/

#include "animation_blend_tree.h"

#include "scene/scene_string_names.h"

void AnimationNodeAnimation::set_animation(const StringName &p_name) {
	animation = p_name;
}

StringName AnimationNodeAnimation::get_animation() const {
	return animation;
}

Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = nullptr;

void AnimationNodeAnimation::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0));
}

void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
	if (property.name == "animation" && get_editable_animation_list) {
		Vector<String> names = get_editable_animation_list();
		String anims;
		for (int i = 0; i < names.size(); i++) {
			if (i > 0) {
				anims += ",";
			}
			anims += String(names[i]);
		}
		if (anims != String()) {
			property.hint = PROPERTY_HINT_ENUM;
			property.hint_string = anims;
		}
	}
}

float AnimationNodeAnimation::process(float p_time, bool p_seek) {
	AnimationPlayer *ap = state->player;
	ERR_FAIL_COND_V(!ap, 0);

	float time = get_parameter(this->time);

	if (!ap->has_animation(animation)) {
		AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent);
		if (tree) {
			String name = tree->get_node_name(Ref<AnimationNodeAnimation>(this));
			make_invalid(vformat(RTR("On BlendTree node '%s', animation not found: '%s'"), name, animation));

		} else {
			make_invalid(vformat(RTR("Animation not found: '%s'"), animation));
		}

		return 0;
	}

	Ref<Animation> anim = ap->get_animation(animation);

	float step;

	if (p_seek) {
		time = p_time;
		step = 0;
	} else {
		time = MAX(0, time + p_time);
		step = p_time;
	}

	float anim_size = anim->get_length();

	if (anim->has_loop()) {
		if (anim_size) {
			time = Math::fposmod(time, anim_size);
		}

	} else if (time > anim_size) {
		time = anim_size;
	}

	blend_animation(animation, time, step, p_seek, 1.0);

	set_parameter(this->time, time);

	return anim_size - time;
}

String AnimationNodeAnimation::get_caption() const {
	return "Animation";
}

void AnimationNodeAnimation::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_animation", "name"), &AnimationNodeAnimation::set_animation);
	ClassDB::bind_method(D_METHOD("get_animation"), &AnimationNodeAnimation::get_animation);

	ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "animation"), "set_animation", "get_animation");
}

AnimationNodeAnimation::AnimationNodeAnimation() {
}

////////////////////////////////////////////////////////

void AnimationNodeOneShot::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::BOOL, active));
	r_list->push_back(PropertyInfo(Variant::BOOL, prev_active, PROPERTY_HINT_NONE, "", 0));
	r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0));
	r_list->push_back(PropertyInfo(Variant::FLOAT, remaining, PROPERTY_HINT_NONE, "", 0));
	r_list->push_back(PropertyInfo(Variant::FLOAT, time_to_restart, PROPERTY_HINT_NONE, "", 0));
}

Variant AnimationNodeOneShot::get_parameter_default_value(const StringName &p_parameter) const {
	if (p_parameter == active || p_parameter == prev_active) {
		return false;
	} else if (p_parameter == time_to_restart) {
		return -1;
	} else {
		return 0.0;
	}
}

void AnimationNodeOneShot::set_fadein_time(float p_time) {
	fade_in = p_time;
}

void AnimationNodeOneShot::set_fadeout_time(float p_time) {
	fade_out = p_time;
}

float AnimationNodeOneShot::get_fadein_time() const {
	return fade_in;
}

float AnimationNodeOneShot::get_fadeout_time() const {
	return fade_out;
}

void AnimationNodeOneShot::set_autorestart(bool p_active) {
	autorestart = p_active;
}

void AnimationNodeOneShot::set_autorestart_delay(float p_time) {
	autorestart_delay = p_time;
}

void AnimationNodeOneShot::set_autorestart_random_delay(float p_time) {
	autorestart_random_delay = p_time;
}

bool AnimationNodeOneShot::has_autorestart() const {
	return autorestart;
}

float AnimationNodeOneShot::get_autorestart_delay() const {
	return autorestart_delay;
}

float AnimationNodeOneShot::get_autorestart_random_delay() const {
	return autorestart_random_delay;
}

void AnimationNodeOneShot::set_mix_mode(MixMode p_mix) {
	mix = p_mix;
}

AnimationNodeOneShot::MixMode AnimationNodeOneShot::get_mix_mode() const {
	return mix;
}

String AnimationNodeOneShot::get_caption() const {
	return "OneShot";
}

bool AnimationNodeOneShot::has_filter() const {
	return true;
}

float AnimationNodeOneShot::process(float p_time, bool p_seek) {
	bool active = get_parameter(this->active);
	bool prev_active = get_parameter(this->prev_active);
	float time = get_parameter(this->time);
	float remaining = get_parameter(this->remaining);
	float time_to_restart = get_parameter(this->time_to_restart);

	if (!active) {
		//make it as if this node doesn't exist, pass input 0 by.
		if (prev_active) {
			set_parameter(this->prev_active, false);
		}
		if (time_to_restart >= 0.0 && !p_seek) {
			time_to_restart -= p_time;
			if (time_to_restart < 0) {
				//restart
				set_parameter(this->active, true);
				active = true;
			}
			set_parameter(this->time_to_restart, time_to_restart);
		}

		if (!active) {
			return blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
		}
	}

	bool os_seek = p_seek;

	if (p_seek) {
		time = p_time;
	}
	bool do_start = !prev_active;

	if (do_start) {
		time = 0;
		os_seek = true;
		set_parameter(this->prev_active, true);
	}

	float blend;

	if (time < fade_in) {
		if (fade_in > 0) {
			blend = time / fade_in;
		} else {
			blend = 0; //wtf
		}

	} else if (!do_start && remaining < fade_out) {
		if (fade_out) {
			blend = (remaining / fade_out);
		} else {
			blend = 1.0;
		}
	} else {
		blend = 1.0;
	}

	float main_rem;
	if (mix == MIX_MODE_ADD) {
		main_rem = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
	} else {
		main_rem = blend_input(0, p_time, p_seek, 1.0 - blend, FILTER_BLEND, !sync);
	}

	float os_rem = blend_input(1, os_seek ? time : p_time, os_seek, blend, FILTER_PASS, false);

	if (do_start) {
		remaining = os_rem;
	}

	if (!p_seek) {
		time += p_time;
		remaining = os_rem;
		if (remaining <= 0) {
			set_parameter(this->active, false);
			set_parameter(this->prev_active, false);
			if (autorestart) {
				float restart_sec = autorestart_delay + Math::randf() * autorestart_random_delay;
				set_parameter(this->time_to_restart, restart_sec);
			}
		}
	}

	set_parameter(this->time, time);
	set_parameter(this->remaining, remaining);

	return MAX(main_rem, remaining);
}

void AnimationNodeOneShot::set_use_sync(bool p_sync) {
	sync = p_sync;
}

bool AnimationNodeOneShot::is_using_sync() const {
	return sync;
}

void AnimationNodeOneShot::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_fadein_time", "time"), &AnimationNodeOneShot::set_fadein_time);
	ClassDB::bind_method(D_METHOD("get_fadein_time"), &AnimationNodeOneShot::get_fadein_time);

	ClassDB::bind_method(D_METHOD("set_fadeout_time", "time"), &AnimationNodeOneShot::set_fadeout_time);
	ClassDB::bind_method(D_METHOD("get_fadeout_time"), &AnimationNodeOneShot::get_fadeout_time);

	ClassDB::bind_method(D_METHOD("set_autorestart", "enable"), &AnimationNodeOneShot::set_autorestart);
	ClassDB::bind_method(D_METHOD("has_autorestart"), &AnimationNodeOneShot::has_autorestart);

	ClassDB::bind_method(D_METHOD("set_autorestart_delay", "enable"), &AnimationNodeOneShot::set_autorestart_delay);
	ClassDB::bind_method(D_METHOD("get_autorestart_delay"), &AnimationNodeOneShot::get_autorestart_delay);

	ClassDB::bind_method(D_METHOD("set_autorestart_random_delay", "enable"), &AnimationNodeOneShot::set_autorestart_random_delay);
	ClassDB::bind_method(D_METHOD("get_autorestart_random_delay"), &AnimationNodeOneShot::get_autorestart_random_delay);

	ClassDB::bind_method(D_METHOD("set_mix_mode", "mode"), &AnimationNodeOneShot::set_mix_mode);
	ClassDB::bind_method(D_METHOD("get_mix_mode"), &AnimationNodeOneShot::get_mix_mode);

	ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeOneShot::set_use_sync);
	ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeOneShot::is_using_sync);

	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fadein_time", PROPERTY_HINT_RANGE, "0,60,0.01,or_greater"), "set_fadein_time", "get_fadein_time");
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fadeout_time", PROPERTY_HINT_RANGE, "0,60,0.01,or_greater"), "set_fadeout_time", "get_fadeout_time");

	ADD_GROUP("autorestart_", "Auto Restart");
	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autorestart"), "set_autorestart", "has_autorestart");

	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "autorestart_delay", PROPERTY_HINT_RANGE, "0,60,0.01,or_greater"), "set_autorestart_delay", "get_autorestart_delay");
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "autorestart_random_delay", PROPERTY_HINT_RANGE, "0,60,0.01,or_greater"), "set_autorestart_random_delay", "get_autorestart_random_delay");

	ADD_GROUP("", "");
	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");

	BIND_ENUM_CONSTANT(MIX_MODE_BLEND);
	BIND_ENUM_CONSTANT(MIX_MODE_ADD);
}

AnimationNodeOneShot::AnimationNodeOneShot() {
	add_input("in");
	add_input("shot");
}

////////////////////////////////////////////////

void AnimationNodeAdd2::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "0,1,0.01"));
}

Variant AnimationNodeAdd2::get_parameter_default_value(const StringName &p_parameter) const {
	return 0;
}

String AnimationNodeAdd2::get_caption() const {
	return "Add2";
}

void AnimationNodeAdd2::set_use_sync(bool p_sync) {
	sync = p_sync;
}

bool AnimationNodeAdd2::is_using_sync() const {
	return sync;
}

bool AnimationNodeAdd2::has_filter() const {
	return true;
}

float AnimationNodeAdd2::process(float p_time, bool p_seek) {
	float amount = get_parameter(add_amount);
	float rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
	blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);

	return rem0;
}

void AnimationNodeAdd2::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeAdd2::set_use_sync);
	ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeAdd2::is_using_sync);

	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");
}

AnimationNodeAdd2::AnimationNodeAdd2() {
	add_input("in");
	add_input("add");
}

////////////////////////////////////////////////

void AnimationNodeAdd3::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "-1,1,0.01"));
}

Variant AnimationNodeAdd3::get_parameter_default_value(const StringName &p_parameter) const {
	return 0;
}

String AnimationNodeAdd3::get_caption() const {
	return "Add3";
}

void AnimationNodeAdd3::set_use_sync(bool p_sync) {
	sync = p_sync;
}

bool AnimationNodeAdd3::is_using_sync() const {
	return sync;
}

bool AnimationNodeAdd3::has_filter() const {
	return true;
}

float AnimationNodeAdd3::process(float p_time, bool p_seek) {
	float amount = get_parameter(add_amount);
	blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_PASS, !sync);
	float rem0 = blend_input(1, p_time, p_seek, 1.0, FILTER_IGNORE, !sync);
	blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_PASS, !sync);

	return rem0;
}

void AnimationNodeAdd3::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeAdd3::set_use_sync);
	ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeAdd3::is_using_sync);

	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");
}

AnimationNodeAdd3::AnimationNodeAdd3() {
	add_input("-add");
	add_input("in");
	add_input("+add");
}

/////////////////////////////////////////////

void AnimationNodeBlend2::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "0,1,0.01"));
}

Variant AnimationNodeBlend2::get_parameter_default_value(const StringName &p_parameter) const {
	return 0; //for blend amount
}

String AnimationNodeBlend2::get_caption() const {
	return "Blend2";
}

float AnimationNodeBlend2::process(float p_time, bool p_seek) {
	float amount = get_parameter(blend_amount);

	float rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync);
	float rem1 = blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);

	return amount > 0.5 ? rem1 : rem0; //hacky but good enough
}

void AnimationNodeBlend2::set_use_sync(bool p_sync) {
	sync = p_sync;
}

bool AnimationNodeBlend2::is_using_sync() const {
	return sync;
}

bool AnimationNodeBlend2::has_filter() const {
	return true;
}

void AnimationNodeBlend2::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeBlend2::set_use_sync);
	ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeBlend2::is_using_sync);

	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");
}

AnimationNodeBlend2::AnimationNodeBlend2() {
	add_input("in");
	add_input("blend");
}

//////////////////////////////////////

void AnimationNodeBlend3::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "-1,1,0.01"));
}

Variant AnimationNodeBlend3::get_parameter_default_value(const StringName &p_parameter) const {
	return 0; //for blend amount
}

String AnimationNodeBlend3::get_caption() const {
	return "Blend3";
}

void AnimationNodeBlend3::set_use_sync(bool p_sync) {
	sync = p_sync;
}

bool AnimationNodeBlend3::is_using_sync() const {
	return sync;
}

float AnimationNodeBlend3::process(float p_time, bool p_seek) {
	float amount = get_parameter(blend_amount);
	float rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync);
	float rem1 = blend_input(1, p_time, p_seek, 1.0 - ABS(amount), FILTER_IGNORE, !sync);
	float rem2 = blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_IGNORE, !sync);

	return amount > 0.5 ? rem2 : (amount < -0.5 ? rem0 : rem1); //hacky but good enough
}

void AnimationNodeBlend3::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_use_sync", "enable"), &AnimationNodeBlend3::set_use_sync);
	ClassDB::bind_method(D_METHOD("is_using_sync"), &AnimationNodeBlend3::is_using_sync);

	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sync"), "set_use_sync", "is_using_sync");
}

AnimationNodeBlend3::AnimationNodeBlend3() {
	blend_amount = "blend_amount";
	add_input("-blend");
	add_input("in");
	add_input("+blend");
	sync = false;
}

/////////////////////////////////

void AnimationNodeTimeScale::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, scale, PROPERTY_HINT_RANGE, "0,32,0.01,or_greater"));
}

Variant AnimationNodeTimeScale::get_parameter_default_value(const StringName &p_parameter) const {
	return 1.0; //initial timescale
}

String AnimationNodeTimeScale::get_caption() const {
	return "TimeScale";
}

float AnimationNodeTimeScale::process(float p_time, bool p_seek) {
	float scale = get_parameter(this->scale);
	if (p_seek) {
		return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
	} else {
		return blend_input(0, p_time * scale, false, 1.0, FILTER_IGNORE, false);
	}
}

void AnimationNodeTimeScale::_bind_methods() {
}

AnimationNodeTimeScale::AnimationNodeTimeScale() {
	add_input("in");
}

////////////////////////////////////

void AnimationNodeTimeSeek::get_parameter_list(List<PropertyInfo> *r_list) const {
	r_list->push_back(PropertyInfo(Variant::FLOAT, seek_pos, PROPERTY_HINT_RANGE, "-1,3600,0.01,or_greater"));
}

Variant AnimationNodeTimeSeek::get_parameter_default_value(const StringName &p_parameter) const {
	return 1.0; //initial timescale
}

String AnimationNodeTimeSeek::get_caption() const {
	return "Seek";
}

float AnimationNodeTimeSeek::process(float p_time, bool p_seek) {
	float seek_pos = get_parameter(this->seek_pos);
	if (p_seek) {
		return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
	} else if (seek_pos >= 0) {
		float ret = blend_input(0, seek_pos, true, 1.0, FILTER_IGNORE, false);
		set_parameter(this->seek_pos, -1.0); //reset
		return ret;
	} else {
		return blend_input(0, p_time, false, 1.0, FILTER_IGNORE, false);
	}
}

void AnimationNodeTimeSeek::_bind_methods() {
}

AnimationNodeTimeSeek::AnimationNodeTimeSeek() {
	add_input("in");
}

/////////////////////////////////////////////////

void AnimationNodeTransition::get_parameter_list(List<PropertyInfo> *r_list) const {
	String anims;
	for (int i = 0; i < enabled_inputs; i++) {
		if (i > 0) {
			anims += ",";
		}
		anims += inputs[i].name;
	}

	r_list->push_back(PropertyInfo(Variant::INT, current, PROPERTY_HINT_ENUM, anims));
	r_list->push_back(PropertyInfo(Variant::INT, prev_current, PROPERTY_HINT_NONE, "", 0));
	r_list->push_back(PropertyInfo(Variant::INT, prev, PROPERTY_HINT_NONE, "", 0));
	r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0));
	r_list->push_back(PropertyInfo(Variant::FLOAT, prev_xfading, PROPERTY_HINT_NONE, "", 0));
}

Variant AnimationNodeTransition::get_parameter_default_value(const StringName &p_parameter) const {
	if (p_parameter == time || p_parameter == prev_xfading) {
		return 0.0;
	} else if (p_parameter == prev || p_parameter == prev_current) {
		return -1;
	} else {
		return 0;
	}
}

String AnimationNodeTransition::get_caption() const {
	return "Transition";
}

void AnimationNodeTransition::_update_inputs() {
	while (get_input_count() < enabled_inputs) {
		add_input(inputs[get_input_count()].name);
	}

	while (get_input_count() > enabled_inputs) {
		remove_input(get_input_count() - 1);
	}
}

void AnimationNodeTransition::set_enabled_inputs(int p_inputs) {
	ERR_FAIL_INDEX(p_inputs, MAX_INPUTS);
	enabled_inputs = p_inputs;
	_update_inputs();
}

int AnimationNodeTransition::get_enabled_inputs() {
	return enabled_inputs;
}

void AnimationNodeTransition::set_input_as_auto_advance(int p_input, bool p_enable) {
	ERR_FAIL_INDEX(p_input, MAX_INPUTS);
	inputs[p_input].auto_advance = p_enable;
}

bool AnimationNodeTransition::is_input_set_as_auto_advance(int p_input) const {
	ERR_FAIL_INDEX_V(p_input, MAX_INPUTS, false);
	return inputs[p_input].auto_advance;
}

void AnimationNodeTransition::set_input_caption(int p_input, const String &p_name) {
	ERR_FAIL_INDEX(p_input, MAX_INPUTS);
	inputs[p_input].name = p_name;
	set_input_name(p_input, p_name);
}

String AnimationNodeTransition::get_input_caption(int p_input) const {
	ERR_FAIL_INDEX_V(p_input, MAX_INPUTS, String());
	return inputs[p_input].name;
}

void AnimationNodeTransition::set_cross_fade_time(float p_fade) {
	xfade = p_fade;
}

float AnimationNodeTransition::get_cross_fade_time() const {
	return xfade;
}

float AnimationNodeTransition::process(float p_time, bool p_seek) {
	int current = get_parameter(this->current);
	int prev = get_parameter(this->prev);
	int prev_current = get_parameter(this->prev_current);

	float time = get_parameter(this->time);
	float prev_xfading = get_parameter(this->prev_xfading);

	bool switched = current != prev_current;

	if (switched) {
		set_parameter(this->prev_current, current);
		set_parameter(this->prev, prev_current);

		prev = prev_current;
		prev_xfading = xfade;
		time = 0;
		switched = true;
	}

	if (current < 0 || current >= enabled_inputs || prev >= enabled_inputs) {
		return 0;
	}

	float rem = 0.0;

	if (prev < 0) { // process current animation, check for transition

		rem = blend_input(current, p_time, p_seek, 1.0, FILTER_IGNORE, false);

		if (p_seek) {
			time = p_time;
		} else {
			time += p_time;
		}

		if (inputs[current].auto_advance && rem <= xfade) {
			set_parameter(this->current, (current + 1) % enabled_inputs);
		}

	} else { // cross-fading from prev to current

		float blend = xfade ? (prev_xfading / xfade) : 1;

		if (!p_seek && switched) { //just switched, seek to start of current

			rem = blend_input(current, 0, true, 1.0 - blend, FILTER_IGNORE, false);
		} else {
			rem = blend_input(current, p_time, p_seek, 1.0 - blend, FILTER_IGNORE, false);
		}

		if (p_seek) { // don't seek prev animation
			blend_input(prev, 0, false, blend, FILTER_IGNORE, false);
			time = p_time;
		} else {
			blend_input(prev, p_time, false, blend, FILTER_IGNORE, false);
			time += p_time;
			prev_xfading -= p_time;
			if (prev_xfading < 0) {
				set_parameter(this->prev, -1);
			}
		}
	}

	set_parameter(this->time, time);
	set_parameter(this->prev_xfading, prev_xfading);

	return rem;
}

void AnimationNodeTransition::_validate_property(PropertyInfo &property) const {
	if (property.name.begins_with("input_")) {
		String n = property.name.get_slicec('/', 0).get_slicec('_', 1);
		if (n != "count") {
			int idx = n.to_int();
			if (idx >= enabled_inputs) {
				property.usage = 0;
			}
		}
	}

	AnimationNode::_validate_property(property);
}

void AnimationNodeTransition::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_enabled_inputs", "amount"), &AnimationNodeTransition::set_enabled_inputs);
	ClassDB::bind_method(D_METHOD("get_enabled_inputs"), &AnimationNodeTransition::get_enabled_inputs);

	ClassDB::bind_method(D_METHOD("set_input_as_auto_advance", "input", "enable"), &AnimationNodeTransition::set_input_as_auto_advance);
	ClassDB::bind_method(D_METHOD("is_input_set_as_auto_advance", "input"), &AnimationNodeTransition::is_input_set_as_auto_advance);

	ClassDB::bind_method(D_METHOD("set_input_caption", "input", "caption"), &AnimationNodeTransition::set_input_caption);
	ClassDB::bind_method(D_METHOD("get_input_caption", "input"), &AnimationNodeTransition::get_input_caption);

	ClassDB::bind_method(D_METHOD("set_cross_fade_time", "time"), &AnimationNodeTransition::set_cross_fade_time);
	ClassDB::bind_method(D_METHOD("get_cross_fade_time"), &AnimationNodeTransition::get_cross_fade_time);

	ADD_PROPERTY(PropertyInfo(Variant::INT, "input_count", PROPERTY_HINT_RANGE, "0,64,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_enabled_inputs", "get_enabled_inputs");
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "xfade_time", PROPERTY_HINT_RANGE, "0,120,0.01"), "set_cross_fade_time", "get_cross_fade_time");

	for (int i = 0; i < MAX_INPUTS; i++) {
		ADD_PROPERTYI(PropertyInfo(Variant::STRING, "input_" + itos(i) + "/name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_input_caption", "get_input_caption", i);
		ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "input_" + itos(i) + "/auto_advance", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_input_as_auto_advance", "is_input_set_as_auto_advance", i);
	}
}

AnimationNodeTransition::AnimationNodeTransition() {
	for (int i = 0; i < MAX_INPUTS; i++) {
		inputs[i].name = "state " + itos(i);
	}
}

/////////////////////

String AnimationNodeOutput::get_caption() const {
	return "Output";
}

float AnimationNodeOutput::process(float p_time, bool p_seek) {
	return blend_input(0, p_time, p_seek, 1.0);
}

AnimationNodeOutput::AnimationNodeOutput() {
	add_input("output");
}

///////////////////////////////////////////////////////
void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position) {
	ERR_FAIL_COND(nodes.has(p_name));
	ERR_FAIL_COND(p_node.is_null());
	ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output);
	ERR_FAIL_COND(String(p_name).find("/") != -1);

	Node n;
	n.node = p_node;
	n.position = p_position;
	n.connections.resize(n.node->get_input_count());
	nodes[p_name] = n;

	emit_changed();
	emit_signal("tree_changed");

	p_node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendTree::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
	p_node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed), varray(p_name), CONNECT_REFERENCE_COUNTED);
}

Ref<AnimationNode> AnimationNodeBlendTree::get_node(const StringName &p_name) const {
	ERR_FAIL_COND_V(!nodes.has(p_name), Ref<AnimationNode>());

	return nodes[p_name].node;
}

StringName AnimationNodeBlendTree::get_node_name(const Ref<AnimationNode> &p_node) const {
	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		if (E->get().node == p_node) {
			return E->key();
		}
	}

	ERR_FAIL_V(StringName());
}

void AnimationNodeBlendTree::set_node_position(const StringName &p_node, const Vector2 &p_position) {
	ERR_FAIL_COND(!nodes.has(p_node));
	nodes[p_node].position = p_position;
}

Vector2 AnimationNodeBlendTree::get_node_position(const StringName &p_node) const {
	ERR_FAIL_COND_V(!nodes.has(p_node), Vector2());
	return nodes[p_node].position;
}

void AnimationNodeBlendTree::get_child_nodes(List<ChildNode> *r_child_nodes) {
	Vector<StringName> ns;

	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		ns.push_back(E->key());
	}

	ns.sort_custom<StringName::AlphCompare>();

	for (int i = 0; i < ns.size(); i++) {
		ChildNode cn;
		cn.name = ns[i];
		cn.node = nodes[cn.name].node;
		r_child_nodes->push_back(cn);
	}
}

bool AnimationNodeBlendTree::has_node(const StringName &p_name) const {
	return nodes.has(p_name);
}

Vector<StringName> AnimationNodeBlendTree::get_node_connection_array(const StringName &p_name) const {
	ERR_FAIL_COND_V(!nodes.has(p_name), Vector<StringName>());
	return nodes[p_name].connections;
}

void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
	ERR_FAIL_COND(!nodes.has(p_name));
	ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output); //can't delete output

	{
		Ref<AnimationNode> node = nodes[p_name].node;
		node->disconnect("tree_changed", callable_mp(this, &AnimationNodeBlendTree::_tree_changed));
		node->disconnect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed));
	}

	nodes.erase(p_name);

	//erase connections to name
	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		for (int i = 0; i < E->get().connections.size(); i++) {
			if (E->get().connections[i] == p_name) {
				E->get().connections.write[i] = StringName();
			}
		}
	}

	emit_changed();
	emit_signal("tree_changed");
}

void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringName &p_new_name) {
	ERR_FAIL_COND(!nodes.has(p_name));
	ERR_FAIL_COND(nodes.has(p_new_name));
	ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output);
	ERR_FAIL_COND(p_new_name == SceneStringNames::get_singleton()->output);

	nodes[p_name].node->disconnect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed));

	nodes[p_new_name] = nodes[p_name];
	nodes.erase(p_name);

	//rename connections
	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		for (int i = 0; i < E->get().connections.size(); i++) {
			if (E->get().connections[i] == p_name) {
				E->get().connections.write[i] = p_new_name;
			}
		}
	}
	//connection must be done with new name
	nodes[p_new_name].node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed), varray(p_new_name), CONNECT_REFERENCE_COUNTED);

	emit_signal("tree_changed");
}

void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) {
	ERR_FAIL_COND(!nodes.has(p_output_node));
	ERR_FAIL_COND(!nodes.has(p_input_node));
	ERR_FAIL_COND(p_output_node == SceneStringNames::get_singleton()->output);
	ERR_FAIL_COND(p_input_node == p_output_node);

	Ref<AnimationNode> input = nodes[p_input_node].node;
	ERR_FAIL_INDEX(p_input_index, nodes[p_input_node].connections.size());

	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		for (int i = 0; i < E->get().connections.size(); i++) {
			StringName output = E->get().connections[i];
			ERR_FAIL_COND(output == p_output_node);
		}
	}

	nodes[p_input_node].connections.write[p_input_index] = p_output_node;

	emit_changed();
}

void AnimationNodeBlendTree::disconnect_node(const StringName &p_node, int p_input_index) {
	ERR_FAIL_COND(!nodes.has(p_node));

	Ref<AnimationNode> input = nodes[p_node].node;
	ERR_FAIL_INDEX(p_input_index, nodes[p_node].connections.size());

	nodes[p_node].connections.write[p_input_index] = StringName();
}

AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) const {
	if (!nodes.has(p_output_node) || p_output_node == SceneStringNames::get_singleton()->output) {
		return CONNECTION_ERROR_NO_OUTPUT;
	}

	if (!nodes.has(p_input_node)) {
		return CONNECTION_ERROR_NO_INPUT;
	}

	if (p_input_node == p_output_node) {
		return CONNECTION_ERROR_SAME_NODE;
	}

	Ref<AnimationNode> input = nodes[p_input_node].node;

	if (p_input_index < 0 || p_input_index >= nodes[p_input_node].connections.size()) {
		return CONNECTION_ERROR_NO_INPUT_INDEX;
	}

	if (nodes[p_input_node].connections[p_input_index] != StringName()) {
		return CONNECTION_ERROR_CONNECTION_EXISTS;
	}

	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		for (int i = 0; i < E->get().connections.size(); i++) {
			StringName output = E->get().connections[i];
			if (output == p_output_node) {
				return CONNECTION_ERROR_CONNECTION_EXISTS;
			}
		}
	}
	return CONNECTION_OK;
}

void AnimationNodeBlendTree::get_node_connections(List<NodeConnection> *r_connections) const {
	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		for (int i = 0; i < E->get().connections.size(); i++) {
			StringName output = E->get().connections[i];
			if (output != StringName()) {
				NodeConnection nc;
				nc.input_node = E->key();
				nc.input_index = i;
				nc.output_node = output;
				r_connections->push_back(nc);
			}
		}
	}
}

String AnimationNodeBlendTree::get_caption() const {
	return "BlendTree";
}

float AnimationNodeBlendTree::process(float p_time, bool p_seek) {
	Ref<AnimationNodeOutput> output = nodes[SceneStringNames::get_singleton()->output].node;
	return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, 1.0);
}

void AnimationNodeBlendTree::get_node_list(List<StringName> *r_list) {
	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		r_list->push_back(E->key());
	}
}

void AnimationNodeBlendTree::set_graph_offset(const Vector2 &p_graph_offset) {
	graph_offset = p_graph_offset;
}

Vector2 AnimationNodeBlendTree::get_graph_offset() const {
	return graph_offset;
}

Ref<AnimationNode> AnimationNodeBlendTree::get_child_by_name(const StringName &p_name) {
	return get_node(p_name);
}

bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_value) {
	String name = p_name;
	if (name.begins_with("nodes/")) {
		String node_name = name.get_slicec('/', 1);
		String what = name.get_slicec('/', 2);

		if (what == "node") {
			Ref<AnimationNode> anode = p_value;
			if (anode.is_valid()) {
				add_node(node_name, p_value);
			}
			return true;
		}

		if (what == "position") {
			if (nodes.has(node_name)) {
				nodes[node_name].position = p_value;
			}
			return true;
		}
	} else if (name == "node_connections") {
		Array conns = p_value;
		ERR_FAIL_COND_V(conns.size() % 3 != 0, false);

		for (int i = 0; i < conns.size(); i += 3) {
			connect_node(conns[i], conns[i + 1], conns[i + 2]);
		}
		return true;
	}

	return false;
}

bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) const {
	String name = p_name;
	if (name.begins_with("nodes/")) {
		String node_name = name.get_slicec('/', 1);
		String what = name.get_slicec('/', 2);

		if (what == "node") {
			if (nodes.has(node_name)) {
				r_ret = nodes[node_name].node;
				return true;
			}
		}

		if (what == "position") {
			if (nodes.has(node_name)) {
				r_ret = nodes[node_name].position;
				return true;
			}
		}
	} else if (name == "node_connections") {
		List<NodeConnection> nc;
		get_node_connections(&nc);
		Array conns;
		conns.resize(nc.size() * 3);

		int idx = 0;
		for (List<NodeConnection>::Element *E = nc.front(); E; E = E->next()) {
			conns[idx * 3 + 0] = E->get().input_node;
			conns[idx * 3 + 1] = E->get().input_index;
			conns[idx * 3 + 2] = E->get().output_node;
			idx++;
		}

		r_ret = conns;
		return true;
	}

	return false;
}

void AnimationNodeBlendTree::_get_property_list(List<PropertyInfo> *p_list) const {
	List<StringName> names;
	for (Map<StringName, Node>::Element *E = nodes.front(); E; E = E->next()) {
		names.push_back(E->key());
	}
	names.sort_custom<StringName::AlphCompare>();

	for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
		String name = E->get();
		if (name != "output") {
			p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR));
		}
		p_list->push_back(PropertyInfo(Variant::VECTOR2, "nodes/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
	}

	p_list->push_back(PropertyInfo(Variant::ARRAY, "node_connections", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
}

void AnimationNodeBlendTree::reset_state() {
	graph_offset = Vector2();
	nodes.clear();
	emit_changed();
	emit_signal("tree_changed");
}

void AnimationNodeBlendTree::_tree_changed() {
	emit_signal("tree_changed");
}

void AnimationNodeBlendTree::_node_changed(const StringName &p_node) {
	ERR_FAIL_COND(!nodes.has(p_node));
	nodes[p_node].connections.resize(nodes[p_node].node->get_input_count());
}

void AnimationNodeBlendTree::_bind_methods() {
	ClassDB::bind_method(D_METHOD("add_node", "name", "node", "position"), &AnimationNodeBlendTree::add_node, DEFVAL(Vector2()));
	ClassDB::bind_method(D_METHOD("get_node", "name"), &AnimationNodeBlendTree::get_node);
	ClassDB::bind_method(D_METHOD("remove_node", "name"), &AnimationNodeBlendTree::remove_node);
	ClassDB::bind_method(D_METHOD("rename_node", "name", "new_name"), &AnimationNodeBlendTree::rename_node);
	ClassDB::bind_method(D_METHOD("has_node", "name"), &AnimationNodeBlendTree::has_node);
	ClassDB::bind_method(D_METHOD("connect_node", "input_node", "input_index", "output_node"), &AnimationNodeBlendTree::connect_node);
	ClassDB::bind_method(D_METHOD("disconnect_node", "input_node", "input_index"), &AnimationNodeBlendTree::disconnect_node);

	ClassDB::bind_method(D_METHOD("set_node_position", "name", "position"), &AnimationNodeBlendTree::set_node_position);
	ClassDB::bind_method(D_METHOD("get_node_position", "name"), &AnimationNodeBlendTree::get_node_position);

	ClassDB::bind_method(D_METHOD("set_graph_offset", "offset"), &AnimationNodeBlendTree::set_graph_offset);
	ClassDB::bind_method(D_METHOD("get_graph_offset"), &AnimationNodeBlendTree::get_graph_offset);

	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "graph_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_graph_offset", "get_graph_offset");

	BIND_CONSTANT(CONNECTION_OK);
	BIND_CONSTANT(CONNECTION_ERROR_NO_INPUT);
	BIND_CONSTANT(CONNECTION_ERROR_NO_INPUT_INDEX);
	BIND_CONSTANT(CONNECTION_ERROR_NO_OUTPUT);
	BIND_CONSTANT(CONNECTION_ERROR_SAME_NODE);
	BIND_CONSTANT(CONNECTION_ERROR_CONNECTION_EXISTS);
}

AnimationNodeBlendTree::AnimationNodeBlendTree() {
	Ref<AnimationNodeOutput> output;
	output.instance();
	Node n;
	n.node = output;
	n.position = Vector2(300, 150);
	n.connections.resize(1);
	nodes["output"] = n;
}

AnimationNodeBlendTree::~AnimationNodeBlendTree() {
}


text:
// <copyright file="IMetricsOutputFormattingBuilder.cs" company="App Metrics Contributors">
// Copyright (c) App Metrics Contributors. All rights reserved.
// </copyright>

using App.Metrics.Formatters;

// ReSharper disable CheckNamespace
namespace App.Metrics
    // ReSharper restore CheckNamespace
{
    public interface IMetricsOutputFormattingBuilder
    {
        /// <summary>
        ///     Gets the <see cref="IMetricsBuilder" /> where App Metrics is configured.
        /// </summary>
        IMetricsBuilder Builder { get; }

        /// <summary>
        ///     <para>
        ///         Uses the specifed <see cref="IMetricsOutputFormatter" /> as one of the available formatters when reporting
        ///         metric values.
        ///     </para>
        ///     <para>
        ///         Multiple formatters can be used, in which case the <see cref="IMetricsRoot.DefaultOutputMetricsFormatter" />
        ///         will be set to the first configured formatter.
        ///     </para>
        /// </summary>
        /// <param name="formatter">An <see cref="IMetricsOutputFormatter" /> instance used to format metric values when reporting.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        IMetricsBuilder Using(IMetricsOutputFormatter formatter);

        /// <summary>
        ///     <para>
        ///         Uses the specifed <see cref="IMetricsOutputFormatter" /> as one of the available formatters when reporting
        ///         metric values.
        ///     </para>
        ///     <para>
        ///         Multiple formatters can be used, in which case the <see cref="IMetricsRoot.DefaultOutputMetricsFormatter" />
        ///         will be set to the first configured formatter.
        ///     </para>
        /// </summary>
        /// <param name="fields">The metric fields to write as well as thier names.</param>
        /// <typeparam name="TMetricsOutputFormatter">
        ///     An <see cref="IMetricsOutputFormatter" /> type used to format metric values
        ///     when reporting.
        /// </typeparam>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        IMetricsBuilder Using<TMetricsOutputFormatter>(MetricFields fields = null)
            where TMetricsOutputFormatter : IMetricsOutputFormatter, new();

        /// <summary>
        ///     <para>
        ///         Uses the specifed <see cref="IMetricsOutputFormatter" /> as one of the available formatters when reporting
        ///         metric values.
        ///     </para>
        ///     <para>
        ///         Multiple formatters can be used, in which case the <see cref="IMetricsRoot.DefaultOutputMetricsFormatter" />
        ///         will be set to the first configured formatter.
        ///     </para>
        /// </summary>
        /// <param name="formatter">An <see cref="IMetricsOutputFormatter" /> instance used to format metric values when reporting.</param>
        /// <param name="replaceExisting">
        ///     If [true] replaces matching formatter type with the formatter instance, otherwise the
        ///     existing formatter instance of matching type.
        /// </param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        IMetricsBuilder Using(IMetricsOutputFormatter formatter, bool replaceExisting);

        /// <summary>
        ///     <para>
        ///         Uses the specifed <see cref="IMetricsOutputFormatter" /> as one of the available formatters when reporting
        ///         metric values.
        ///     </para>
        ///     <para>
        ///         Multiple formatters can be used, in which case the <see cref="IMetricsRoot.DefaultOutputMetricsFormatter" />
        ///         will be set to the first configured formatter.
        ///     </para>
        /// </summary>
        /// <typeparam name="TMetricsOutputFormatter">
        ///     An <see cref="IMetricsOutputFormatter" /> type used to format metric values
        ///     when reporting.
        /// </typeparam>
        /// <param name="replaceExisting">
        ///     If [true] replaces matching formatter type with the formatter instance, otherwise the
        ///     existing formatter instance of matching type.
        /// </param>
        /// <param name="fields">The metric fields to write as well as thier names.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        IMetricsBuilder Using<TMetricsOutputFormatter>(bool replaceExisting, MetricFields fields = null)
            where TMetricsOutputFormatter : IMetricsOutputFormatter, new();
    }
}


text:
package examples;

import java.util.Optional;
import java.math.BigInteger;
import numbers.*;

public class Example2 {

  public static void main(String[] args) {
    // Reals can be made from rationals

    Real two = new Real(Rational.create(2, 1).get());
    Real half = new Real(Rational.create(2, 1).get().inverse().get());

    // These reals are infinite sequences of rational numbers, so they cannot
    // be viewed easily. Instead, they must be approximated

    two.approx(100);
    two.approx(new BigInteger("100"));
    // Both above approximations give 2 +/- (1/100)
    // Clearly, this is silly for 2, but it becomes useful for other reals

    // Reals can be operated on:

    two.add(two);
    two.multiply(half);

    // And there are a few special functions implemented for reals: sqrt, cos,
    // arctan, and cos

    Real.sqrt(two);

    Real.cos(Real.ONE);
  }
}


text:
namespace Nz
{
	class Light;
	struct LightUniforms;

	class NAZARA_GRAPHICS_API Light : public Renderable
	{
		public:
			Light(LightType type = LightType_Point);
			inline Light(const Light& light);
			Light(Light&& light) = default;
			~Light() = default;

			void AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const override;

			Light* Clone() const;
			Light* Create() const;

			bool Cull(const Frustumf& frustum, const Matrix4f& transformMatrix) const override;

			inline void EnableShadowCasting(bool castShadows);

			inline void EnsureShadowMapUpdate() const;

			inline float GetAmbientFactor() const;
			inline float GetAttenuation() const;
			inline Color GetColor() const;
			inline float GetDiffuseFactor() const;
			inline float GetInnerAngle() const;
			inline float GetInnerAngleCosine() const;
			inline float GetInvRadius() const;
			inline LightType GetLightType() const;
			inline float GetOuterAngle() const;
			inline float GetOuterAngleCosine() const;
			inline float GetOuterAngleTangent() const;
			inline float GetRadius() const;
			inline TextureRef GetShadowMap() const;
			inline PixelFormatType GetShadowMapFormat() const;
			inline const Vector2ui& GetShadowMapSize() const;

			inline bool IsShadowCastingEnabled() const;

			inline void SetAmbientFactor(float factor);
			inline void SetAttenuation(float attenuation);
			inline void SetColor(const Color& color);
			inline void SetDiffuseFactor(float factor);
			inline void SetInnerAngle(float innerAngle);
			inline void SetLightType(LightType type);
			inline void SetOuterAngle(float outerAngle);
			inline void SetRadius(float radius);
			inline void SetShadowMapFormat(PixelFormatType shadowFormat);
			inline void SetShadowMapSize(const Vector2ui& size);

			void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;

			Light& operator=(const Light& light);
			Light& operator=(Light&& light) = default;

		private:
			void MakeBoundingVolume() const override;
			inline void InvalidateShadowMap();
			void UpdateShadowMap() const;

			Color m_color;
			LightType m_type;
			PixelFormatType m_shadowMapFormat;
			Vector2ui m_shadowMapSize;
			mutable TextureRef m_shadowMap;
			bool m_shadowCastingEnabled;
			mutable bool m_shadowMapUpdated;
			float m_ambientFactor;
			float m_attenuation;
			float m_diffuseFactor;
			float m_innerAngle;
			float m_innerAngleCosine;
			float m_invRadius;
			float m_outerAngle;
			float m_outerAngleCosine;
			float m_outerAngleTangent;
			float m_radius;
	};

	struct LightUniforms
	{
		struct UniformLocations
		{
			int type;
			int color;
			int factors;
			int lightViewProjMatrix;
			int parameters1;
			int parameters2;
			int parameters3;
			int shadowMapping;
		};

		bool ubo;

		union
		{
			UniformLocations locations;
			int blockLocation;
		};
	};
}

#include <Nazara/Graphics/Light.inl>

#endif // NAZARA_LIGHT_HPP


text:
require "spec_helper"
require "support/mock_dependency_list"
require "support/mock_injectable_class"
require "carb/inject/store_dependencies"

describe Carb::Inject::StoreDependencies do
  include ::Carb::MockDependencyList
  include ::Carb::MockInjectable

  it "does nothing if class has no dependency_list set" do
    store    = Carb::Inject::StoreDependencies.new
    instance = Object.new

    store.(instance, foo: 1, bar: 2)

    expect(instance.instance_variable_get(:@foo)).to be_nil
    expect(instance.instance_variable_get(:@bar)).to be_nil
  end

  it "doesn't set any instance variable if dependency_list has none set" do
    store    = Carb::Inject::StoreDependencies.new
    klass    = mock_injectable_class
    instance = klass.new(foo: 1, bar: 2)
    mock_dependency_list(klass, {})

    store.(instance)

    expect(instance.instance_variable_get(:@foo)).to be_nil
    expect(instance.instance_variable_get(:@bar)).to be_nil
  end

  it "sets instance variables based on dependency_list" do
    store    = Carb::Inject::StoreDependencies.new
    klass    = mock_injectable_class
    instance = klass.new
    mock_dependency_list(klass, { foo: 1, bar: 2 })

    store.(instance)

    expect(instance.instance_variable_get(:@foo)).to eq 1
    expect(instance.instance_variable_get(:@bar)).to eq 2
  end

  it "overwrites instance variables from dependency_list with those passed" do
    store    = Carb::Inject::StoreDependencies.new
    klass    = mock_injectable_class
    instance = klass.new
    mock_dependency_list(klass, { foo: 1, bar: 2 })

    store.(instance, foo: 3)

    expect(instance.instance_variable_get(:@foo)).to eq 3
    expect(instance.instance_variable_get(:@bar)).to eq 2
  end

  it "sets instance variables for parent dependencies" do
    store    = Carb::Inject::StoreDependencies.new
    parent   = mock_injectable_class
    klass    = mock_injectable_class(parent)
    instance = klass.new
    mock_dependency_list(parent, { baz: 3 })
    mock_dependency_list(klass, { foo: 1, bar: 2 })

    store.(instance)

    expect(instance.instance_variable_get(:@foo)).to eq 1
    expect(instance.instance_variable_get(:@bar)).to eq 2
    expect(instance.instance_variable_get(:@baz)).to eq 3
  end
end


text:
<book its:version="2.0" xmlns:its="http://www.w3.org/2005/11/its">
  Sample file

And he said: you need a new <quote its:annotatorsRef="terminology|http://example.com/term-tool#T2" its:term="yes" its:termInfoRef="http://www.directron.com/motherboards1.html" its:termConfidence="0.5">motherboard</quote>

</book>


text:
<resources>
    <string name="app_name">VRMU</string>

    <!-- TODO: Remove or change this placeholder text -->
    <string name="hello_blank_fragment">Hello blank fragment</string>
    <string name="more">更多</string>
</resources>


text:
// This file is automatically generated.

package adila.db;

/*
 * Kyocera INFOBAR A03
 *
 * DEVICE: KYV33
 * MODEL: KYV33
 */
final class kyv33_kyv33 {
    public static final String DATA = "Kyocera|INFOBAR A03|";
}


text:
title: Componente React Box
githubLabel: 'component: Box'
---

# Box

O componente Box serve como um componente encapsulador (wrapper) para a auxiliar na maioria das necessidades de uso com CSS.

O component Box compõe [todas as funções de estilo](/system/basics/#all-inclusive) que são expostas no `@material-ui/system`.

[A paleta](/system/palette/) com funções de estilo.

## Exemplo

[A paleta](/system/palette/) com funções de estilo.

## A propriedade `sx`

All system properties are available via the [`sx` prop](/system/basics/#the-sx-prop). In addition, the `sx` prop allows you to specify any other CSS rules you may need. Aqui está um exemplo de como você pode usá-la:

{{"demo": "BoxSx.js", "defaultCodeOpen": true }}

## Sobrescrevendo componentes do Material-UI

O componente Box envolve seu componente. Ele cria um novo elemento DOM, uma `<div>` por padrão, algo que pode ser modificado com a propriedade `component`. Digamos que você queira usar um `<span>`:

{{"demo": "BoxComponent.js", "defaultCodeOpen": true }}

Isso funciona muito bem quando as alterações precisam ser isoladas em um novo elemento DOM. Note no exemplo, a forma que você alterou a margem.

No entanto, às vezes, você precisa modificar o elemento DOM subjacente. As an example, you may want to change the border of the Button. Por exemplo, você quer mudar a borda do botão. A herança por CSS não irá ajudar nesse caso. To workaround the problem, you can use the [`sx`](/system/basics/#the-sx-prop) prop directly on the child if it is a Material-UI component.

```diff
-<Box sx={{ border: '1px dashed grey' }}>
-  <Button>Save</Button>
-</Box>
+<Button sx={{ border: '1px dashed grey' }}>Save</Button>
```

For non-Material-UI components, use the `component` prop.

```diff
-<Box sx={{ border: '1px dashed grey' }}>
-  <button>Save</button>
-</Box>
+<Box component="button" sx={{ border: '1px dashed grey' }}>Save</Box>
```

## API

```jsx
import Box from '@material-ui/core/Box';
```

| Nome                                     | Tipo                                                                                | Padrão                                  | Descrição                                                                               |
|:---------------------------------------- |:----------------------------------------------------------------------------------------------------------------------------- |:--------------------------------------- |:--------------------------------------------------------------------------------------- |
| children  | node
                                                                                |                                         | Função de renderização do Box ou nó.                                                    |
| component | union: string |
 func |
 object
 | 'div' | O componente usado como nó raiz. Ou uma string para usar um elemento DOM ou componente. |
| sx        | object                                                                                | {}    | Aceita todas as propriedades do sistema, bem como quaisquer propriedades CSS válidas.   |

## System props

As a CSS utility component, the `Box` also supports all [`system`](/system/properties/) properties. You can use them as prop directly on the component. For instance, a margin-top:

```jsx
<Box mt={2}>
```

## Crie seu próprio componente `Box` componente.

Se você quiser ter um tema padrão diferente para o componente `Box` , você pode criar sua própria versão dele, usando o utilitário `createBox()`.

```js
import { createBox, createTheme } from '@mui/system';

const defaultTheme = createTheme({
  // your custom theme values
});

const Box = createBox({ defaultTheme });

export default Box;
```