<commit_before>(function($) {

TiddlyWeb.Space = function(name, members, host) {
	TiddlyWeb.Resource.apply(this, ["space", host]);
	this.name = name;
	this.members = members;
	this.constituents = this.getConstituents();
};
TiddlyWeb.Space.prototype = new TiddlyWeb.Resource();
$.extend(TiddlyWeb.Space.prototype, {
	get: function(callback, errback) {
		var self = this;
		var _callback = function(entities, status, xhr) {
			self.constituents = entities;
			self.members = self.constituents[0].policy.manage; // XXX: authoritative?
			callback(self, status, xhr);
		};
		this.request("get", _callback, errback);
	},
	put: function(callback, errback) {
		var self = this;
		var _callback = function(responseData, status, xhr) {
			callback(self, status, xhr);
		};
		this.request("put", _callback, errback);
	},
	getConstituents: function() {
		var policies = {
			private: {
				read: this.members,
				write: this.members,
				create: this.members,
				"delete": this.members,
				manage: this.members,
				accept: this.members,
				owner: this.members[0] // XXX: ignored by TiddlyWeb
			}
		};
		policies.public = $.extend({}, policies.private, {
			read: []
		});
		var containers = [];
		var self = this;
		$.each(["bag", "recipe"], function(i, type) {
			$.each(["private", "public"], function(j, visibility) {
				var className = TiddlyWeb._capitalize(type);
				var name = self.name + "_" + visibility;
				var container = new TiddlyWeb[className](name, self.host);
				container.desc = self.name + " space, " + visibility + " " +
					(type == "bag" ? "content" : "document");
				container.policy = policies[visibility];
				if(type == "recipe") {
					container.recipe = [
						["system", ""],
						["tiddlyspace", ""],
						[self.name + "_public", ""]
					];
					if(visibility == "private") {
						container.recipe.push([self.name + "_private", ""]);
					}
				}
				containers.push(container);
			});
		});
		return containers;
	},
	request: function(type, callback, errback) {
		var responseData = [];
		var entityCount = this.constituents.length;
		var xhrCount = 0;<commit_msg>s/container/entity/g<commit_after>(function($) {

TiddlyWeb.Space = function(name, members, host) {
	TiddlyWeb.Resource.apply(this, ["space", host]);
	this.name = name;
	this.members = members;
	this.constituents = this.getConstituents();
};
TiddlyWeb.Space.prototype = new TiddlyWeb.Resource();
$.extend(TiddlyWeb.Space.prototype, {
	get: function(callback, errback) {
		var self = this;
		var _callback = function(entities, status, xhr) {
			self.constituents = entities;
			self.members = self.constituents[0].policy.manage; // XXX: authoritative?
			callback(self, status, xhr);
		};
		this.request("get", _callback, errback);
	},
	put: function(callback, errback) {
		var self = this;
		var _callback = function(responseData, status, xhr) {
			callback(self, status, xhr);
		};
		this.request("put", _callback, errback);
	},
	getConstituents: function() {
		var policies = {
			private: {
				read: this.members,
				write: this.members,
				create: this.members,
				"delete": this.members,
				manage: this.members,
				accept: this.members,
				owner: this.members[0] // XXX: ignored by TiddlyWeb
			}
		};
		policies.public = $.extend({}, policies.private, {
			read: []
		});
		var entities = [];
		var self = this;
		$.each(["bag", "recipe"], function(i, type) {
			$.each(["private", "public"], function(j, visibility) {
				var className = TiddlyWeb._capitalize(type);
				var name = self.name + "_" + visibility;
				var entity = new TiddlyWeb[className](name, self.host);
				entity.desc = self.name + " space, " + visibility + " " +
					(type == "bag" ? "content" : "document");
				entity.policy = policies[visibility];
				if(type == "recipe") {
					entity.recipe = [
						["system", ""],
						["tiddlyspace", ""],
						[self.name + "_public", ""]
					];
					if(visibility == "private") {
						entity.recipe.push([self.name + "_private", ""]);
					}
				}
				entities.push(entity);
			});
		});
		return entities;
	},
	request: function(type, callback, errback) {
		var responseData = [];
		var entityCount = this.constituents.length;
		var xhrCount = 0;
{'fraction_non_alphanumeric': 0.17244678306625208, 'fraction_numerical': 0.0014350633819660368, 'mean_word_length': 3.4775160599571735, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1259784', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1397, 'n_words': 291}