// Class: openfl.net.URLVariables

var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this

$global.Object.defineProperty(exports, "__esModule", {value: true});

var __map_reserved = {};

// Imports

var $hxClasses = require("./../../hxClasses_stub").default;
var $import = require("./../../import_stub").default;
function Reflect() {return require("./../../Reflect");}
function StringTools() {return require("./../../StringTools");}
function HxOverrides() {return require("./../../HxOverrides");}

// Constructor

var URLVariables = function(source) {
	if(source != null) {
		this.decode(source);
	}
}

// Meta

URLVariables.__name__ = ["openfl","net","URLVariables"];
URLVariables.prototype = {
	decode: function(source) {
		var fields = (Reflect().default).fields(this);
		var _g = 0;
		while(_g < fields.length) {
			var f = fields[_g];
			++_g;
			(Reflect().default).deleteField(this,f);
		}
		var fields1 = source.split(";").join("&").split("&");
		var _g1 = 0;
		while(_g1 < fields1.length) {
			var f1 = fields1[_g1];
			++_g1;
			var eq = f1.indexOf("=");
			if(eq > 0) {
				(Reflect().default).setField(this,(StringTools().default).urlDecode((HxOverrides().default).substr(f1,0,eq)),(StringTools().default).urlDecode((HxOverrides().default).substr(f1,eq + 1,null)));
			} else if(eq != 0) {
				(Reflect().default).setField(this,(StringTools().default).urlDecode(f1),"");
			}
		}
	},
	toString: function() {
		var result = [];
		var fields = (Reflect().default).fields(this);
		var _g = 0;
		while(_g < fields.length) {
			var f = fields[_g];
			++_g;
			result.push((StringTools().default).urlEncode(f) + "=" + (StringTools().default).urlEncode((Reflect().default).field(this,f)));
		}
		return result.join("&");
	}
};
URLVariables.prototype.__class__ = URLVariables.prototype.constructor = $hxClasses["openfl.net.URLVariables"] = URLVariables;

// Init



// Statics




// Export

exports.default = URLVariables;