#include <hxcpp.h>

#ifndef INCLUDED_EReg
#include <EReg.h>
#endif
#ifndef INCLUDED_IMap
#include <IMap.h>
#endif
#ifndef INCLUDED_Luxe
#include <Luxe.h>
#endif
#ifndef INCLUDED_Std
#include <Std.h>
#endif
#ifndef INCLUDED_Type
#include <Type.h>
#endif
#ifndef INCLUDED_haxe_CallStack
#include <haxe/CallStack.h>
#endif
#ifndef INCLUDED_haxe_Log
#include <haxe/Log.h>
#endif
#ifndef INCLUDED_haxe_StackItem
#include <haxe/StackItem.h>
#endif
#ifndef INCLUDED_haxe_crypto_Md5
#include <haxe/crypto/Md5.h>
#endif
#ifndef INCLUDED_haxe_ds_StringMap
#include <haxe/ds/StringMap.h>
#endif
#ifndef INCLUDED_haxe_io_Bytes
#include <haxe/io/Bytes.h>
#endif
#ifndef INCLUDED_hxMath
#include <hxMath.h>
#endif
#ifndef INCLUDED_luxe_Core
#include <luxe/Core.h>
#endif
#ifndef INCLUDED_luxe_utils_GeometryUtils
#include <luxe/utils/GeometryUtils.h>
#endif
#ifndef INCLUDED_luxe_utils_UUID
#include <luxe/utils/UUID.h>
#endif
#ifndef INCLUDED_luxe_utils_Utils
#include <luxe/utils/Utils.h>
#endif
#ifndef INCLUDED_snow_App
#include <snow/App.h>
#endif
#ifndef INCLUDED_snow_Snow
#include <snow/Snow.h>
#endif
#ifndef INCLUDED_snow_assets_Assets
#include <snow/assets/Assets.h>
#endif
namespace luxe{
namespace utils{

Void Utils_obj::__construct(::luxe::Core _luxe)
{
HX_STACK_FRAME("luxe.utils.Utils","new",0x3458be4e,"luxe.utils.Utils.new","luxe/utils/Utils.hx",15,0x2d9d0da4)

HX_STACK_ARG(_luxe,"_luxe")
{
	HX_STACK_LINE(18)
	this->luxe = _luxe;
	HX_STACK_LINE(20)
	this->geometry = ::luxe::utils::GeometryUtils_obj::__new(this->luxe);
	HX_STACK_LINE(22)
	this->_byte_levels = Array_obj< ::String >::__new().Add(HX_CSTRING("bytes")).Add(HX_CSTRING("Kb")).Add(HX_CSTRING("MB")).Add(HX_CSTRING("GB")).Add(HX_CSTRING("TB"));
}
;
	return null();
}

//Utils_obj::~Utils_obj() { }

Dynamic Utils_obj::__CreateEmpty() { return  new Utils_obj; }
hx::ObjectPtr< Utils_obj > Utils_obj::__new(::luxe::Core _luxe)
{  hx::ObjectPtr< Utils_obj > result = new Utils_obj();
	result->__construct(_luxe);
	return result;}

Dynamic Utils_obj::__Create(hx::DynamicArray inArgs)
{  hx::ObjectPtr< Utils_obj > result = new Utils_obj();
	result->__construct(inArgs[0]);
	return result;}

::String Utils_obj::uniqueid( ){
	HX_STACK_FRAME("luxe.utils.Utils","uniqueid",0xd69a687e,"luxe.utils.Utils.uniqueid","luxe/utils/Utils.hx",26,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_LINE(28)
	Float _g = ::Luxe_obj::get_time();		HX_STACK_VAR(_g,"_g");
	HX_STACK_LINE(28)
	return ::haxe::crypto::Md5_obj::encode(::Std_obj::string((_g * ::Math_obj::random())));
}


HX_DEFINE_DYNAMIC_FUNC0(Utils_obj,uniqueid,return )

::String Utils_obj::uuid( ){
	HX_STACK_FRAME("luxe.utils.Utils","uuid",0x9dfa5c8d,"luxe.utils.Utils.uuid","luxe/utils/Utils.hx",34,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_LINE(34)
	return ::luxe::utils::UUID_obj::get();
}


HX_DEFINE_DYNAMIC_FUNC0(Utils_obj,uuid,return )

::String Utils_obj::stacktrace( Dynamic __o__depth){
Dynamic _depth = __o__depth.Default(100);
	HX_STACK_FRAME("luxe.utils.Utils","stacktrace",0x8b198e0f,"luxe.utils.Utils.stacktrace","luxe/utils/Utils.hx",38,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_ARG(_depth,"_depth")
{
		HX_STACK_LINE(40)
		::String result = HX_CSTRING("\n");		HX_STACK_VAR(result,"result");
		HX_STACK_LINE(42)
		Array< ::Dynamic > stack = ::haxe::CallStack_obj::callStack();		HX_STACK_VAR(stack,"stack");
		HX_STACK_LINE(44)
		stack->shift().StaticCast< ::haxe::StackItem >();
		HX_STACK_LINE(45)
		stack->reverse();
		HX_STACK_LINE(47)
		int total = ::Std_obj::_int(::Math_obj::min(stack->length,_depth));		HX_STACK_VAR(total,"total");
		HX_STACK_LINE(49)
		{
			HX_STACK_LINE(49)
			int _g = (int)0;		HX_STACK_VAR(_g,"_g");
			HX_STACK_LINE(49)
			while(((_g < total))){
				HX_STACK_LINE(49)
				int i = (_g)++;		HX_STACK_VAR(i,"i");
				HX_STACK_LINE(50)
				::haxe::StackItem stackitem = stack->__get(i).StaticCast< ::haxe::StackItem >();		HX_STACK_VAR(stackitem,"stackitem");
				HX_STACK_LINE(51)
				Dynamic params = ::Type_obj::enumParameters(stackitem);		HX_STACK_VAR(params,"params");
				HX_STACK_LINE(53)
				hx::AddEq(result,(((HX_CSTRING(" >  ") + params->__GetItem((int)1)) + HX_CSTRING(":")) + params->__GetItem((int)2)));
				HX_STACK_LINE(55)
				if (((i != (total - (int)1)))){
					HX_STACK_LINE(56)
					hx::AddEq(result,HX_CSTRING("\n"));
				}
			}
		}
		HX_STACK_LINE(60)
		return result;
	}
}


HX_DEFINE_DYNAMIC_FUNC1(Utils_obj,stacktrace,return )

bool Utils_obj::path_is_relative( ::String _path){
	HX_STACK_FRAME("luxe.utils.Utils","path_is_relative",0x5216f779,"luxe.utils.Utils.path_is_relative","luxe/utils/Utils.hx",66,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_ARG(_path,"_path")
	HX_STACK_LINE(66)
	if (((  (((  (((  (((_path.charAt((int)0) != HX_CSTRING("#")))) ? bool((_path.charAt((int)0) != HX_CSTRING("/"))) : bool(false) ))) ? bool((_path.indexOf(HX_CSTRING(":\\"),null()) == (int)-1)) : bool(false) ))) ? bool((_path.indexOf(HX_CSTRING(":/"),null()) == (int)-1)) : bool(false) ))){
		struct _Function_2_1{
			inline static bool Block( ::String &_path){
				HX_STACK_FRAME("*","closure",0x5bdab937,"*.closure","luxe/utils/Utils.hx",72,0x2d9d0da4)
				{
					HX_STACK_LINE(72)
					int _g = _path.indexOf(HX_CSTRING("//"),null());		HX_STACK_VAR(_g,"_g");
					HX_STACK_LINE(72)
					return (_g > _path.indexOf(HX_CSTRING("#"),null()));
				}
				return null();
			}
		};
		HX_STACK_LINE(71)
		if ((!(((  ((!(((_path.indexOf(HX_CSTRING("//"),null()) == (int)-1))))) ? bool(_Function_2_1::Block(_path)) : bool(true) ))))){
			HX_STACK_LINE(73)
			int _g1 = _path.indexOf(HX_CSTRING("//"),null());		HX_STACK_VAR(_g1,"_g1");
			HX_STACK_LINE(73)
			return (_g1 > _path.indexOf(HX_CSTRING("?"),null()));
		}
		else{
			HX_STACK_LINE(71)
			return true;
		}
	}
	else{
		HX_STACK_LINE(66)
		return false;
	}
	HX_STACK_LINE(66)
	return false;
}


HX_DEFINE_DYNAMIC_FUNC1(Utils_obj,path_is_relative,return )

Array< ::String > Utils_obj::find_assets_image_sequence( ::String _name,::String __o__ext,::String __o__start){
::String _ext = __o__ext.Default(HX_CSTRING(".png"));
::String _start = __o__start.Default(HX_CSTRING("1"));
	HX_STACK_FRAME("luxe.utils.Utils","find_assets_image_sequence",0x66eeea6d,"luxe.utils.Utils.find_assets_image_sequence","luxe/utils/Utils.hx",77,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_ARG(_name,"_name")
	HX_STACK_ARG(_ext,"_ext")
	HX_STACK_ARG(_start,"_start")
{
		HX_STACK_LINE(79)
		Array< ::String > _final = Array_obj< ::String >::__new();		HX_STACK_VAR(_final,"_final");
		HX_STACK_LINE(81)
		::String _sequence_type = HX_CSTRING("");		HX_STACK_VAR(_sequence_type,"_sequence_type");
		HX_STACK_LINE(82)
		::EReg _pattern_regex = null();		HX_STACK_VAR(_pattern_regex,"_pattern_regex");
		HX_STACK_LINE(84)
		::String _type0 = ((_name + _start) + _ext);		HX_STACK_VAR(_type0,"_type0");
		HX_STACK_LINE(85)
		::EReg _type0_re = ::EReg_obj::__new(((HX_CSTRING("(") + _name) + HX_CSTRING(")(\\d\\b)")),HX_CSTRING("gi"));		HX_STACK_VAR(_type0_re,"_type0_re");
		HX_STACK_LINE(86)
		::String _type1 = (((_name + HX_CSTRING("_")) + _start) + _ext);		HX_STACK_VAR(_type1,"_type1");
		HX_STACK_LINE(87)
		::EReg _type1_re = ::EReg_obj::__new(((HX_CSTRING("(") + _name) + HX_CSTRING(")(_\\d\\b)")),HX_CSTRING("gi"));		HX_STACK_VAR(_type1_re,"_type1_re");
		HX_STACK_LINE(88)
		::String _type2 = (((_name + HX_CSTRING("-")) + _start) + _ext);		HX_STACK_VAR(_type2,"_type2");
		HX_STACK_LINE(89)
		::EReg _type2_re = ::EReg_obj::__new(((HX_CSTRING("(") + _name) + HX_CSTRING(")(-\\d\\b)")),HX_CSTRING("gi"));		HX_STACK_VAR(_type2_re,"_type2_re");
		HX_STACK_LINE(92)
		if ((this->luxe->app->assets->listed(_type0))){
			HX_STACK_LINE(93)
			_sequence_type = _type0;
			HX_STACK_LINE(94)
			_pattern_regex = _type0_re;
		}
		else{
			HX_STACK_LINE(95)
			if ((this->luxe->app->assets->listed(_type1))){
				HX_STACK_LINE(96)
				_sequence_type = _type1;
				HX_STACK_LINE(97)
				_pattern_regex = _type1_re;
			}
			else{
				HX_STACK_LINE(98)
				if ((this->luxe->app->assets->listed(_type2))){
					HX_STACK_LINE(99)
					_sequence_type = _type2;
					HX_STACK_LINE(100)
					_pattern_regex = _type2_re;
				}
				else{
					HX_STACK_LINE(102)
					::haxe::Log_obj::trace(((((((((HX_CSTRING("Sequence requested from ") + _name) + HX_CSTRING(" but no assets found like `")) + _type0) + HX_CSTRING("` or `")) + _type1) + HX_CSTRING("` or `")) + _type2) + HX_CSTRING("`")),hx::SourceInfo(HX_CSTRING("Utils.hx"),102,HX_CSTRING("luxe.utils.Utils"),HX_CSTRING("find_assets_image_sequence")));
				}
			}
		}
		HX_STACK_LINE(105)
		if (((_sequence_type != HX_CSTRING("")))){
			HX_STACK_LINE(106)
			for(::cpp::FastIterator_obj< Dynamic > *__it = ::cpp::CreateFastIterator< Dynamic >(this->luxe->app->assets->list->iterator());  __it->hasNext(); ){
				Dynamic _asset = __it->next();
				if ((_pattern_regex->match(_asset->__Field(HX_CSTRING("id"),true)))){
					HX_STACK_LINE(109)
					_final->push(_asset->__Field(HX_CSTRING("id"),true));
				}
;
			}

			HX_BEGIN_LOCAL_FUNC_S0(hx::LocalFunc,_Function_2_1)
			int run(::String a,::String b){
				HX_STACK_FRAME("*","_Function_2_1",0x5201af78,"*._Function_2_1","luxe/utils/Utils.hx",113,0x2d9d0da4)
				HX_STACK_ARG(a,"a")
				HX_STACK_ARG(b,"b")
				{
					HX_STACK_LINE(113)
					if (((a == b))){
						HX_STACK_LINE(113)
						return (int)0;
					}
					HX_STACK_LINE(113)
					if (((a < b))){
						HX_STACK_LINE(113)
						return (int)-1;
					}
					HX_STACK_LINE(113)
					return (int)1;
				}
				return null();
			}
			HX_END_LOCAL_FUNC2(return)

			HX_STACK_LINE(113)
			_final->sort( Dynamic(new _Function_2_1()));
		}
		HX_STACK_LINE(116)
		return _final;
	}
}


HX_DEFINE_DYNAMIC_FUNC3(Utils_obj,find_assets_image_sequence,return )

::String Utils_obj::bytes_to_string( int bytes){
	HX_STACK_FRAME("luxe.utils.Utils","bytes_to_string",0xf09ebd2f,"luxe.utils.Utils.bytes_to_string","luxe/utils/Utils.hx",120,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_ARG(bytes,"bytes")
	HX_STACK_LINE(122)
	Float _g = ::Math_obj::log(bytes);		HX_STACK_VAR(_g,"_g");
	HX_STACK_LINE(122)
	int index = ::Math_obj::floor((Float(_g) / Float(::Math_obj::log((int)1024))));		HX_STACK_VAR(index,"index");
	HX_STACK_LINE(123)
	Float _byte_value = (Float(bytes) / Float(::Math_obj::pow((int)1024,index)));		HX_STACK_VAR(_byte_value,"_byte_value");
	HX_STACK_LINE(125)
	return (_byte_value + this->_byte_levels->__get(index));
}


HX_DEFINE_DYNAMIC_FUNC1(Utils_obj,bytes_to_string,return )

::haxe::io::Bytes Utils_obj::array_to_bytes( Array< int > array){
	HX_STACK_FRAME("luxe.utils.Utils","array_to_bytes",0x20cc2edf,"luxe.utils.Utils.array_to_bytes","luxe/utils/Utils.hx",129,0x2d9d0da4)
	HX_STACK_THIS(this)
	HX_STACK_ARG(array,"array")
	HX_STACK_LINE(131)
	if (((array == null()))){
		HX_STACK_LINE(131)
		return null();
	}
	HX_STACK_LINE(132)
	::haxe::io::Bytes bytes = ::haxe::io::Bytes_obj::alloc(array->length);		HX_STACK_VAR(bytes,"bytes");
	HX_STACK_LINE(133)
	{
		HX_STACK_LINE(133)
		int _g1 = (int)0;		HX_STACK_VAR(_g1,"_g1");
		HX_STACK_LINE(133)
		int _g = bytes->length;		HX_STACK_VAR(_g,"_g");
		HX_STACK_LINE(133)
		while(((_g1 < _g))){
			HX_STACK_LINE(133)
			int n = (_g1)++;		HX_STACK_VAR(n,"n");
			HX_STACK_LINE(133)
			bytes->b[n] = array->__get(n);
		}
	}
	HX_STACK_LINE(135)
	return bytes;
}


HX_DEFINE_DYNAMIC_FUNC1(Utils_obj,array_to_bytes,return )


Utils_obj::Utils_obj()
{
}

void Utils_obj::__Mark(HX_MARK_PARAMS)
{
	HX_MARK_BEGIN_CLASS(Utils);
	HX_MARK_MEMBER_NAME(geometry,"geometry");
	HX_MARK_MEMBER_NAME(luxe,"luxe");
	HX_MARK_MEMBER_NAME(_byte_levels,"_byte_levels");
	HX_MARK_END_CLASS();
}

void Utils_obj::__Visit(HX_VISIT_PARAMS)
{
	HX_VISIT_MEMBER_NAME(geometry,"geometry");
	HX_VISIT_MEMBER_NAME(luxe,"luxe");
	HX_VISIT_MEMBER_NAME(_byte_levels,"_byte_levels");
}

Dynamic Utils_obj::__Field(const ::String &inName,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"luxe") ) { return luxe; }
		if (HX_FIELD_EQ(inName,"uuid") ) { return uuid_dyn(); }
		break;
	case 8:
		if (HX_FIELD_EQ(inName,"geometry") ) { return geometry; }
		if (HX_FIELD_EQ(inName,"uniqueid") ) { return uniqueid_dyn(); }
		break;
	case 10:
		if (HX_FIELD_EQ(inName,"stacktrace") ) { return stacktrace_dyn(); }
		break;
	case 12:
		if (HX_FIELD_EQ(inName,"_byte_levels") ) { return _byte_levels; }
		break;
	case 14:
		if (HX_FIELD_EQ(inName,"array_to_bytes") ) { return array_to_bytes_dyn(); }
		break;
	case 15:
		if (HX_FIELD_EQ(inName,"bytes_to_string") ) { return bytes_to_string_dyn(); }
		break;
	case 16:
		if (HX_FIELD_EQ(inName,"path_is_relative") ) { return path_is_relative_dyn(); }
		break;
	case 26:
		if (HX_FIELD_EQ(inName,"find_assets_image_sequence") ) { return find_assets_image_sequence_dyn(); }
	}
	return super::__Field(inName,inCallProp);
}

Dynamic Utils_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"luxe") ) { luxe=inValue.Cast< ::luxe::Core >(); return inValue; }
		break;
	case 8:
		if (HX_FIELD_EQ(inName,"geometry") ) { geometry=inValue.Cast< ::luxe::utils::GeometryUtils >(); return inValue; }
		break;
	case 12:
		if (HX_FIELD_EQ(inName,"_byte_levels") ) { _byte_levels=inValue.Cast< Array< ::String > >(); return inValue; }
	}
	return super::__SetField(inName,inValue,inCallProp);
}

void Utils_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("geometry"));
	outFields->push(HX_CSTRING("luxe"));
	outFields->push(HX_CSTRING("_byte_levels"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	String(null()) };

#if HXCPP_SCRIPTABLE
static hx::StorageInfo sMemberStorageInfo[] = {
	{hx::fsObject /*::luxe::utils::GeometryUtils*/ ,(int)offsetof(Utils_obj,geometry),HX_CSTRING("geometry")},
	{hx::fsObject /*::luxe::Core*/ ,(int)offsetof(Utils_obj,luxe),HX_CSTRING("luxe")},
	{hx::fsObject /*Array< ::String >*/ ,(int)offsetof(Utils_obj,_byte_levels),HX_CSTRING("_byte_levels")},
	{ hx::fsUnknown, 0, null()}
};
#endif

static ::String sMemberFields[] = {
	HX_CSTRING("geometry"),
	HX_CSTRING("luxe"),
	HX_CSTRING("_byte_levels"),
	HX_CSTRING("uniqueid"),
	HX_CSTRING("uuid"),
	HX_CSTRING("stacktrace"),
	HX_CSTRING("path_is_relative"),
	HX_CSTRING("find_assets_image_sequence"),
	HX_CSTRING("bytes_to_string"),
	HX_CSTRING("array_to_bytes"),
	String(null()) };

static void sMarkStatics(HX_MARK_PARAMS) {
	HX_MARK_MEMBER_NAME(Utils_obj::__mClass,"__mClass");
};

#ifdef HXCPP_VISIT_ALLOCS
static void sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(Utils_obj::__mClass,"__mClass");
};

#endif

Class Utils_obj::__mClass;

void Utils_obj::__register()
{
	hx::Static(__mClass) = hx::RegisterClass(HX_CSTRING("luxe.utils.Utils"), hx::TCanCast< Utils_obj> ,sStaticFields,sMemberFields,
	&__CreateEmpty, &__Create,
	&super::__SGetClass(), 0, sMarkStatics
#ifdef HXCPP_VISIT_ALLOCS
    , sVisitStatics
#endif
#ifdef HXCPP_SCRIPTABLE
    , sMemberStorageInfo
#endif
);
}

void Utils_obj::__boot()
{
}

} // end namespace luxe
} // end namespace utils
