//= require ./core
//= require ./static_config
//= require_self

(function () {

	if (!Drop.config.JSON_CONFIG_URL) {
		throw Error("json_config_url is required!");
	}

	Drop.fetchConfig = function () {
		new Marbles.HTTP({
			method: 'GET',
			url: Drop.config.JSON_CONFIG_URL,
			middleware: [
				Marbles.HTTP.Middleware.WithCredentials,
				Marbles.HTTP.Middleware.SerializeJSON
			],
			callback: function (res, xhr) {
				if (xhr.status !== 200) {
					throw Error("failed to fetch json config: " + xhr.status + " - " + JSON.stringify(res));
				}

				if (!Drop.config) {
					Drop.config = {};
				}

				for (var key in res) {
					Drop.config[key] = res[key];
				}

				Drop.config_ready = true;
				Drop.trigger('config:ready');
			}
		});
	};

	Drop.fetchConfig();

})();

@@ -666,24 +666,139 @@
 ey%5D;%0A%09%09%09%09%7D%0A%0A
+%09%09%09%09if (!Drop.config.meta) %7B%0A%09%09%09%09%09throw Error(%22invalid config! missing meta post: %22 + JSON.stringify(res));%0A%09%09%09%09%7D%0A%0A
 %09%09%09%09Drop.con

Throw error if app isn't authenticated