code:
/**
 * Displays a list of the children in the Nursery
 * @returns {DocumentFragment}
 */
App.Facilities.Nursery.childList = function childList() {
	const cribs = V.cribs;

	let frag = document.createDocumentFragment();
	let r = [];

	if (V.nurseryChildren) {
		App.UI.DOM.appendNewElement("h3", frag, `Children in ${V.nurseryName}`, "indent");

		const list = App.UI.DOM.appendNewElement("p", frag, '', "indent");

		for (const child of cribs) {
			const weeksOwned = V.week - child.weekAcquired;
			const weeksLeft = (V.targetAgeNursery * 52) - weeksOwned;
			const {he, him, He} = getPronouns(child);
			const hr = document.createElement("hr");

			hr.style.margin = "0";
			list.appendChild(hr);

			if (child.actualAge < 3) {
				$(list).append(App.UI.DOM.link(SlaveFullName(child), (id) => V.activeChild = getChild(id), [child.ID], "Infant Interact"));
				$(list).append(App.Facilities.Nursery.InfantSummary(child));
			} else {
				$(list).append(App.UI.DOM.link(SlaveFullName(child), (id) => V.activeChild = getChild(id), [child.ID], "Child Interact"));
				$(list).append(App.Facilities.Nursery.ChildSummary(child));
			}

			if (child.actualAge >= 18) {
				if (child.targetLocation === "freedom") {
					V.freedSlaves.push(child);
				}

				V.readySlave = cribs.pluck();
				r.push(`<<goto "Nursery Retrieval Workaround">>`);
				return r;
			}

			if (child.growTime <= 0 || child.actualAge >= V.targetAgeNursery) {
				const targetText = child.targetLocation === "slavery" ? `"Introduce ${him} to life as a slave"` : `"Set ${him} free"`;

				list.appendChild(document.createElement("br"));

				r.push(`${He} is ready to leave ${V.nurseryName} and ${child.targetLocation === "slavery" ? `join your ménage` : `become a free citizen`}.`);
				$(list).append(App.UI.DOM.passageLink(targetText, "Nursery Retrieval Workaround", () => { V.readySlave = child; }));
			} else {
				list.appendChild(document.createElement("br"));

				r.push(`${He} is to continue staying in ${V.nurseryName} for another ${years(weeksLeft)}. ${He} is destined for ${child.targetLocation} once ${he} is of age.`);
			}

			$(list).append(r.join(' '));

			r = [];	// reset for next child
		}
	}

	return frag;
};

/**
 * Converts the infant object into a new child object
 * @param {object} child
 * @returns {object}
 */
App.Facilities.Nursery.infantToChild = function infantToChild(child) {
	child.abortionTat = -1;
	child.accent = 0;
	child.ageImplant = 0;
	child.arm = {
		left: new App.Entity.ArmState(),
		right: new App.Entity.LegState()
	};
	child.leg = {
		left: new App.Entity.LegState(),
		right: new App.Entity.LegState()
	};
	child.analArea = 0;
	child.anus = 0;
	child.piercing = new App.Entity.completePiercingState();
	child.anusTat = 0;
	child.aphrodisiacs = 0;
	child.areolae = 0;
	child.areolaeShape = "circle";
	child.armAccessory = "none";
	child.armsTat = 0;
	child.attrKnown = 0;
	child.attrXX = 0;
	child.attrXY = 0;
	child.backTat = 0;
	child.bald = 0;
	child.balls = 0;
	child.behavioralFlaw = "none";
	child.belly = 0;
	child.bellyAccessory = "none";
	child.bellyFluid = 0;
	child.bellyImplant = -1;
	child.bellyPreg = 0;
	child.bellySag = 0;
	child.bellySagPreg = 0;
	child.bellyTat = 0;
	child.bodySwap = 0;
	child.boobShape = jsEither(["normal", "normal", "normal", "perky", "perky", "perky", "torpedo-shaped", "downward-facing", "wide-set"]);
	child.boobs = jsRandom(200, 500);
	child.boobsImplant = 0;
	child.boobsImplantType = "none";
	child.boobsTat = 0;
	child.brand = {};
	child.breastMesh = 0;
	child.breedingMark = 0;
	child.butt = jsRandom(0, 3);
	child.buttImplant = 0;
	child.buttImplantType = "none";
	child.buttTat = 0;
	child.buttplug = "none";
	child.buttplugAttachment = "none";
	child.canRecruit = 0;
	child.chastityAnus = 0;
	child.chastityPenis = 0;
	child.chastityVagina = 0;
	child.chem = 0;
	child.choosesOwnClothes = 0;
	child.clit = jsRandom(0, 2);
	child.clothes = "no clothing";
	child.collar = "none";
	child.counter = {
		PCChildrenFathered: 0,
		PCKnockedUp: 0,
		anal: 0,
		births: 0,
		birthsTotal: 0,
		cum: 0,
		laborCount: 0,
		mammary: 0,
		milk: 0,
		oral: 0,
		penetrative: 0,
		pitKills: 0,
		publicUse: 0,
		slavesFathered: 0,
		slavesKnockedUp: 0,
		vaginal: 0
	};
	child.curatives = 0;
	child.custom = {
		desc: "",
		hairVector: "",
		image: null,
		label: "",
		tattoo: "",
		title: "",
		titleLisp: ""
	};
	child.daughters = 0;
	child.devotion = 40;
	child.dick = 0;
	child.dickAccessory = "none";
	child.dickTat = 0;
	child.diet = "healthy";
	child.dietCum = 0;
	child.dietMilk = 0;
	child.drugs = "no drugs";
	if (child.race !== "catgirl") {
		child.earImplant = 0;
		child.earShape = "normal";
		child.earT = "none";
		child.earTColor = "hairless";
	}
	if (child.race === "catgirl") {
		child.earImplant = 1;
		child.earShape = "none";
		child.earT = "cat";
		child.earTColor = child.hColor;
	}
	child.earwear = "none";
	child.electrolarynx = 0;
	child.energy = 0;
	child.eyebrowFullness = "natural";
	child.eyebrowHStyle = "natural";
	child.eyewear = "none";
	child.faceImplant = 0;
	child.fertKnown = 1;
	child.fertPeak = 0;
	child.fetishKnown = 0;
	child.fetishStrength = 0;
	child.foreskin = 0;
	child.geneMods = {
		NCS: 0,
		rapidCellGrowth: 0,
		immortality: 0
	};
	child.hLength = jsRandom(30, 70);
	child.hStyle = "long";
	child.haircuts = 0;
	child.health = {};
	setHealth(child, jsRandom(80, 100), 0, 0, 0, 0);
	child.hears = 0;
	child.heels = 0;
	child.height = jsRandom(85, 105);
	child.hips = 0;
	child.hormoneBalance = 0;
	child.hormones = 0;
	child.horn = "none";
	child.hornColor = "none";
	child.induce = 0;
	child.induceLactation = 0;
	child.intelligence = 100;
	child.intelligenceImplant = 0;
	child.labia = jsRandom(0, 2);
	child.labor = 0;
	child.lactation = 0;
	child.lactationAdaptation = 0;
	child.lactationDuration = 0;
	child.rules = new App.Entity.RuleState();
	child.rules.lactation = "none";
	child.legAccessory = "none";
	child.legsTat = 0;
	child.lips = jsRandom(10, 30);
	child.lipsImplant = 0;
	child.lipsTat = 0;
	child.rules.living = "normal";
	child.makeup = 0;
	child.markings = "none";
	child.minorInjury = 0;
	child.mpreg = 0;
	child.muscles = jsRandom(-10, 10);
	child.nails = 0;
	child.need = 0;
	if (child.boobs > 500 || child.weight > 95) {
		child.nipples = jsEither(["cute", "puffy", "partially inverted", "inverted", "tiny"]);
	} else {
		child.nipples = jsEither(["cute", "cute", "cute", "tiny"]);
	}
	child.nipplesAccessory = "none";
	child.oldDevotion = 0;
	child.oldTrust = 0;
	child.onDiet = 0;
	child.origRace = child.race;
	child.eye = new App.Entity.EyeState();
	child.eye.origColor = child.eyeColor;
	child.origHColor = child.hColor;
	child.origSkin = child.skin;
	child.ovaries = child.genes === "XX" ? 1 : 0;
	child.ovaryAge = child.actualAge;
	/* eslint-disable camelcase */
	child.override_Arm_H_Color = 0;
	child.override_Brow_H_Color = 0;
	child.override_Eye_Color = 0;
	child.override_H_Color = 0;
	child.override_Pubic_H_Color = 0;
	child.override_Race = 0;
	child.override_Skin = 0;
	/* eslint-enable camelcase */
	child.physicalAge = child.actualAge;
	child.porn = new App.Entity.SlavePornPerformanceState();
	child.pregAdaptation = 50;
	child.pregControl = "none";
	child.pregData = {
		drugsEffect: 1,
		fetusRate: [1, 1, 1, 0.64, 0.6513, 0.6459, 0.644, 0.6393, 0.58, 0.51],
		fetusSize: [1, 3, 16, 25.6, 51, 60, 67.5, 71.6, 129.5, 130],
		fetusWeek: [0, 9, 20, 20, 40, 52, 64, 80, 384, 99999],
		minLiveBirth: 32,
		normalBirth: 40,
		normalOvaMax: 1,
		normalOvaMin: 1,
		sizeType: 0,
		type: "human"
	};
	child.pregKnown = 0;
	child.pregSource = 0;
	child.pregType = 0;
	child.pregWeek = 0;
	child.prematureBirth = 0;
	child.prestige = 0;
	child.prostate = 0;
	child.pubertyAgeXX = 10;
	child.pubertyAgeXY = 12;
	child.pubertyXX = 1;
	child.pubicHColor = "black";
	child.pubicHStyle = "bushy";
	child.readyOva = 0;
	child.relationship = 0;
	child.rules.relationship = "restrictive";
	child.relationshipTarget = 0;
	child.rules.release = new App.Entity.ReleaseRulesState();
	child.rivalry = 0;
	child.rivalryTarget = 0;
	child.rudeTitle = 0;
	child.scar = {};
	child.scrotum = 0;
	child.shoes = "none";
	child.shoulders = 0;
	child.shouldersTat = 0;
	child.sisters = 0;
	child.skill = {
		DJ: 0,
		anal: 0,
		attendant: 0,
		bodyguard: 0,
		combat: 0,
		entertainer: 0,
		entertainment: 0,
		farmer: 0,
		headGirl: 0,
		madam: 0,
		matron: 0,
		milkmaid: 0,
		nurse: 0,
		oral: 0,
		recruiter: 0,
		servant: 0,
		stewardess: 0,
		teacher: 0,
		vaginal: 0,
		wardeness: 0,
		whore: 0,
		whoring: 8
	};
	child.smells = 0;
	child.rules.speech = "restrictive";
	child.stampTat = 0;
	child.rules.punishment = "situational";
	child.rules.reward = "situational";
	if (child.race !== "catgirl") {
		child.tailColor = "none";
		child.tailShape = "none";
	} else {
		child.tailColor = child.hColor;
		child.tailShape = "cat";
	}
	child.tastes = 0;
	child.teeth = "baby";
	child.training = 0;
	child.trust = 0;
	child.underArmHStyle = "natural";
	child.vagina = child.genes === "XX" ? 0 : -1;
	child.vaginaLube = 0;
	child.vaginaTat = 0;
	child.vaginalAccessory = "none";
	child.vaginalAttachment = "none";
	child.vasectomy = 0;
	child.visualAge = child.actualAge;
	child.voice = 1;
	child.voiceImplant = 0;
	child.waist = 0;
	child.weeksLeft = 0;
	child.weight = jsRandom(-10, 10);
	child.womb = [];
	child.wombImplant = "none";
	resetEyeColor(child, "both");
	generatePronouns(child);

	return child;
};

/**
 * Allows the player to name the infant
 * FIXME: Does not currently work
 * @param {object} child
 * @returns {string}
 */
App.Facilities.Nursery.nameChild = function nameChild(child) {
	const PC = V.PC;
	const arcology = V.arcologies[0];
	const girl = child.genes === "XX" ? "girl" : "boy";

	let r = ``;
	/** @type {App.Entity.SlaveState} */
	let father = 0;
	/** @type {App.Entity.SlaveState} */
	let mother = 0;

	const {him, his, he} = getPronouns(child);

	if (child.father === -1 && child.mother === -1) {
		father = PC;
		mother = PC;
	} else {
		if (child.father === -1) {
			father = PC;
			mother = getSlave(child.mother);
		} else if (child.mother === -1) {
			father = getSlave(child.father);
			mother = PC;
		} else {
			father = getSlave(child.father);
			mother = getSlave(child.mother);
		}
	}

	function newChildName(child) {
		child.birthName = generateName(child.nationality, child.race, child.genes === "XY");

		if (child.genes === "XY" && !V.allowMaleSlaveNames && isMaleName(child.birthName, child.nationality, child.race)) {
			child.slaveName = generateName(child.nationality, child.race, false);
		} else {
			child.slaveName = child.birthName;
		}
	}

	r += `You can name the new child, if you so desire. `;

	r += `<br><<textbox "${child.slaveName}" ${child.slaveName}>>`;
	r += App.UI.passageLink("Commit name", "Nursery Workaround", `${child.birthName = child.slaveName}, ${App.UI.replace("#naming", `You instruct ${V.assistant.name} to register the new ${girl} as "${child.slaveName}" in the slave registry.`)}`);
	r += `<br>`;
	r += App.UI.passageLink(`Have your PA assign ${him} a random name`, "Nursery Workaround", `${App.UI.replace("#naming", `${newChildName(child)}
${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.`)}`);

	if (arcology.FSPastoralist !== "unset") {
		if (child.lactation > 0) {
			r += `

			<<link "Have your PA assign ${him} a random cow name">>
			<<replace "#naming">>`;
			child.slaveName = App.Data.misc.cowSlaveNames.random();
			child.birthName = child.slaveName;
			r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
			<</link>>`;
		}
	}
	if (child.race === "catgirl") {
		r += `

		<<link "Have your PA assign ${him} a random cat name">>
		<<replace "#naming">>`;
		child.slaveName = App.Data.misc.catSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
		<</replace>>
		<</link>>`;
	}
	if (arcology.FSChattelReligionist !== "unset") {
		r += `

		<<link "Have your PA assign ${him} a random devotional name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.chattelReligionistSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	}
	if (arcology.FSRomanRevivalist !== "unset") {
		r += `

		<<link "Have your PA assign ${him} a random Roman name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.romanSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	} else if (arcology.FSAztecRevivalist !== "unset") {
		r += `

		<<link "Have your PA assign ${him} a random Aztec name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.aztecSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	} else if (arcology.FSEgyptianRevivalist !== "unset") {
		r += `

		<<link "Have your PA assign ${him} a random ancient Egyptian name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.ancientEgyptianSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	} else if (arcology.FSEdoRevivalist !== "unset") {
		r += `

		<<link "Have your PA assign ${him} a random feudal Japanese name">>
			<<replace "#naming">>`;
		child.slaveName = App.Data.misc.edoSlaveNames.random();
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	}
	if (arcology.FSDegradationist !== "unset") {
		r += `

		<<link "Have your PA assign ${him} a degrading name">>
			<<replace "#naming">>`;
		DegradingName(child);
		child.birthName = child.slaveName;
		r += `${V.assistant.name} registers the new ${girl} as "${child.slaveName}" in your registry.
			<</replace>>
		<</link>>`;
	}
	if (mother !== PC && mother !== 0) {
		const {He2, he2, his2} = getPronouns(mother).appendSuffix('2');
		if (mother.ID === V.ConcubineID) {
			r += `

			<<link "Permit your Concubine to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} picks a name ${he2} thinks you might find attractive; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (mother.relationship === -3 && mother.devotion >= -20) {
			r += `

			<<link "Permit your wife to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} picks a name suitable for your daughter; from now on ${he2} will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (mother.ID === V.BodyguardID) {
			r += `

			<<link "Permit your bodyguard to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} decides on "${child.slaveName}" for ${his2} daughter. ${He2} hopes you'll find it fitting ${his} station.
				<</replace>>
			<</link>>`;
		} else if (mother.ID === V.HeadGirlID) {
			r += `

			<<link "Permit your Head Girl to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} decides on "${child.slaveName}" for ${his2} daughter, and hopes it will be a name your other slaves will learn to respect.
				<</replace>>
			<</link>>`;
		} else if (mother.devotion > 50 && mother.trust > 50) {
			r += `

			<<link "Permit ${his} devoted mother to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(mother, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${mother.slaveName} picks a name ${he2} hopes you'll like; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		}
	}
	if (father !== PC && father !== 0 && father !== mother) {
		const {He2, he2, his2} = getPronouns(father).appendSuffix('2');
		if (father.ID === V.ConcubineID) {
			r += `

			<<link "Permit your Concubine to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} picks a name ${he2} thinks you might find attractive; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (father.relationship === -3 && father.devotion >= -20) {
			r += `

			<<link "Permit your wife to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} picks a name suitable for your daughter; from now on ${he} will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		} else if (father.ID === V.BodyguardID) {
			r += `

			<<link "Permit your bodyguard to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} decides on "${child.slaveName}" for ${his2} daughter. ${He2} hopes you'll find it fitting ${his} station.
				<</replace>>
			<</link>>`;
		} else if (father.ID === V.HeadGirlID) {
			r += `

			<<link "Permit your Head Girl to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} decides on "${child.slaveName}" for ${his2} daughter, and hopes it will be a name your other slaves will learn to respect.
				<</replace>>
			<</link>>`;
		} else if (father.devotion > 50 && father.trust > 50) {
			r += `

			<<link "Permit ${his} devoted father to name ${his2} daughter">>
				<<replace "#naming">>`;
			parentNames(father, child);
			child.birthName = child.slaveName;
			r += `After some careful consideration, ${father.slaveName} picks a name ${he2} hopes you'll like; from now on ${his2} daughter will be known as "${child.slaveName}".
				<</replace>>
			<</link>>`;
		}
	}

	return r;
};

/**
 * Adds an infant to a the cribs
 * @param {App.Facilities.Nursery.InfantState} child
 */
App.Facilities.Nursery.newChild = function newChild(child) {
	child.ID = generateSlaveID();

	child.actualAge = 0;
	child.birthWeek = 0;

	if (child.override_Race !== 1) {
		child.origRace = child.race;
	}

	if (child.override_H_Color !== 1) {
		child.hColor = getGeneticHairColor(child);
	}
	if (child.override_Arm_H_Color !== 1) {
		child.underArmHColor = getGeneticHairColor(child);
	}
	if (child.override_Pubic_H_Color !== 1) {
		child.pubicHColor = getGeneticHairColor(child);
	}
	if (child.override_Brow_H_Color !== 1) {
		child.eyebrowHColor = getGeneticHairColor(child);
	}
	if (child.override_Skin !== 1) {
		child.origSkin = getGeneticSkinColor(child);
	}
	/* eslint-disable camelcase*/
	child.override_Race = 0;
	child.override_H_Color = 0;
	child.override_Arm_H_Color = 0;
	child.override_Pubic_H_Color = 0;
	child.override_Brow_H_Color = 0;
	child.override_Skin = 0;
	child.override_Eye_Color = 0;
	/* eslint-enable */

	child.arm = {
		left: new App.Entity.ArmState(),
		right: new App.Entity.ArmState()
	};
	child.leg = {
		left: new App.Entity.LegState(),
		right: new App.Entity.LegState()
	};

	if (V.surnamesForbidden === 1) {
		child.slaveSurname = 0;
	}

	if (child.clone !== 0) {
		child.canRecruit = 0;
	}
	generatePronouns(child);
	child.origin = `$He was born and raised in your arcology. `;
	child.targetLocation = "slavery";
	child.growTime = V.targetAgeNursery * 52;
	V.cribs.push(child);
	V.cribsIndices = App.Facilities.Nursery.cribsToIndices();
	V.nurseryChildren++;
};

/**
 * @param {App.Entity.ChildState[]} [cribs]
 * @returns {object.<number, number>}
 */
App.Facilities.Nursery.cribsToIndices = function cribsToIndices(cribs = V.cribs) {
	return cribs.reduce((acc, child, i) => { acc[child.ID] = i; return acc; }, {});
};

/**
 * Returns index in the children array for the given ID
 * @param {number} id child's ID
 * @returns {number}
 */
App.Facilities.Nursery.childIndexForID = function childIndexForID(id) {
	return V.cribsIndices[id];
};

/**
 * Removes the child using the child's ID
 * @param {number} index
 * @returns {Array}
 */
App.Facilities.Nursery.removeChild = function removeChild(index) {
	return V.cribs.deleteAt(index);
};

/**
 * Displays a list of slaves with children eligible for the Nursery
 * FIXME: Does not currently work
 * @returns {string}
 */
App.Facilities.Nursery.nurserySort = function nurserySort() {
	const PC = V.PC;
	const SL = V.slaves.length;
	const arcology = V.arcologies[0];
	const freeCribs = (V.nursery - V.cribs.length);

	let r = ``;
	let eligibility = 0;
	let sortNurseryList = V.sortNurseryList || "Unsorted";
	let nurseryHasReservedChildren = false;
	let reservedChildrenNursery = FetusGlobalReserveCount("nursery");

	r += `<br><i>Sorting:</i> <b><span id="ql-nursery-sort">${sortNurseryList}.</span></b> `;
	r += `${App.UI.passageLink("Sort by Name", "Nursery", `${sortNurseryList = "Name"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byName()}`)} | `;
	r += `${App.UI.passageLink("Sort by Reserved Nursery Spots", "Nursery", `${sortNurseryList = "Reserved Nursery Spots"}, ${App.UI.replace(`#ql-nursery-sort`)} ${sortNurseryList}, ${byReservedSpots()}`)} | `;
	r += `${App.UI.passageLink("Sort by Pregnancy Week", "Nursery", `${sortNurseryList = "Pregnancy Week"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byPregnancyWeek()}`)} | `;
	r += `${App.UI.passageLink("Sort by Number of Children", "Nursery", `${sortNurseryList = "Number of Children"}, ${App.UI.replace(`#ql-nursery-sort`, sortNurseryList)}, ${byPregnancyCount()}`)}`;
	r += `<br>`;

	r += `<div id="ql-nursery">`;

	for (let i = 0; i < SL; i++) {
		const slave = V.slaves[i];
		const {His, his} = getPronouns(slave);

		if (slave.preg > 0 && !slave.broodmother && slave.pregKnown && slave.eggType === "human") {
			if (slave.assignment !== Job.DAIRY && V.dairyPregSetting <= 0) {
				const slaveID = "slave-" + slave.ID;
				const WL = slave.womb.length;
				const reservedNursery = WombReserveCount(slave, "nursery");
				const reservedIncubator = WombReserveCount(slave, "incubator");
				const pregWeek = slave.pregWeek;
				const slaveName = SlaveFullName(slave);

				r += `<div class="possible" @id="${slaveID}" @data-preg-count="${WL}" @data-reserved-spots="${reservedNursery}" @data-preg-week="${pregWeek}" @data-name="${slaveName}">`;

				r += `${App.UI.SlaveDescriptionDialog(slave)} is ${pregWeek} weeks pregnant with `;

				switch (slave.pregSource) {
					case 0:
						r += `someone's${slave.preg <= 5 ? `, though it is too early to tell whose,` : ``}`;
						break;
					case -1:
						r += `your`;
						break;
					case -2:
						r += `a citizen's`;
						break;
					case -3:
						r += `your Master's`;
						break;
					case -4:
						r += `another arcology owner's`;
						break;
					case -5:
						r += `your client's`;
						break;
					case -6:
						r += `the Societal Elite's`;
						break;
					case -7:
						r += `the lab's`;
						break;
					case -9:
						r += `the Futanari Sister's`;
						break;
					default:
						if (slave.preg <= 5) {
							r += `someone's, though it is too early to tell whose,`;
						} else {
							let source = getSlave(slave.pregSource);
							if (source !== undefined) {
								r += `${source.slaveName}'s`;
							}
						}
						break;
				}
				r += ` ${WL > 1 ? `babies` : `baby`}. `;

				if (reservedNursery > 0) {
					nurseryHasReservedChildren = true;
					if (WL === 1) {
						r += `${His} child will be placed in ${V.nurseryName}. `;
					} else if (reservedNursery < WL) {
						r += `${reservedNursery} of ${his} children will be placed in ${V.nurseryName}. `;
					} else if (WL === 2) {
						r += `Both of ${his} children will be placed in ${V.nurseryName}. `;
					} else {
						r += `All ${reservedNursery} of ${his} children will be placed in ${V.nurseryName}. `;
					}

					if ((reservedIncubator + reservedNursery < WL) && (reservedChildrenNursery < freeCribs)) {
						r += `<br>    `;
						r += App.UI.passageLink("Keep another child", "Nursery", `${WombAddToGenericReserve(slave, "nursery", 1)}`);
						if (reservedNursery > 0) {
							r += ` | ${App.UI.passageLink("Keep one less child", "Nursery", `${WombCleanGenericReserve(slave, "nursery", 1)}`)}`;
						}
						if (reservedNursery > 1) {
							r += ` | ${App.UI.passageLink(`Keep none of ${his} children`, "Nursery", `${WombCleanGenericReserve(slave, "nursery", 9999)}`)}`;
						}
						if (reservedChildrenNursery + WL - reservedNursery <= freeCribs) {
							r += ` | ${App.UI.passageLink(`Keep the rest of ${his} children`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 9999)}`)}`;
						}
					} else if (reservedNursery === WL || reservedChildrenNursery === freeCribs || reservedIncubator + reservedNursery === WL) {
						r += `<br>    `;
						r += App.UI.passageLink("Keep one less child", "Nursery", `${WombCleanGenericReserve(slave, "nursery", 1)}`);
						if (reservedNursery > 1) {
							r += ` | ${App.UI.passageLink(`Keep none of ${his} children`, "Nursery", `${WombCleanGenericReserve(slave, "nursery", 9999)}`)}`;
						}
					}
				} else if (reservedChildrenNursery < freeCribs && freeCribs > WL) {
					if (WL - reservedIncubator === 0) {
						r += `<i>${His} children are already reserved for ${V.incubator.name}</i>`;
						r += `<br>    `;
						r += App.UI.passageLink(`Keep ${his} child${WL > 1 ? `ren` : ``} here instead`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 1)}`);
					} else {
						r += `You have ${freeCribs === 1 ? `an ` : ``}available room${freeCribs > 1 ? `s` : ``}. `;
						r += `<br>    `;
						r += App.UI.passageLink(`Keep ${WL > 1 ? `a` : `the`} child`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 1)}`);
						if (WL > 1 && (reservedChildrenNursery + WL - reservedNursery <= freeCribs)) {
							r += ` | ${App.UI.passageLink(`Keep all of ${his} children`, "Nursery", `${WombAddToGenericReserve(slave, "nursery", 9999)}`)}`;
						}
					}
				} else if (reservedChildrenNursery === freeCribs) {
					r += `<br>    `;
					r += `You have <span class="red">no room for ${his} offspring.</span> `;
				}

				eligibility = 1;
				r += `</div>`;
			}
		}
	}

	r += `</div>`;

	$('div#ql-nursery').ready(byPreviousSort);

	if (!eligibility) {
		r += `<br>`;
		r += `<i>You have no pregnant slave bearing eligible children</i>`;
	}

	if (PC.pregKnown && (arcology.FSRestart === "unset" || V.eugenicsFullControl || (PC.pregSource !== -1 && PC.pregSource !== -6))) {
		const WL = PC.womb.length;

		let reservedIncubator = WombReserveCount(PC, "incubator");
		let reservedNursery = WombReserveCount(PC, "nursery");

		r += `<br><b><span class="pink">You're pregnant</span></b> and going to have ${WL === 1 ? `a baby. ` : pregNumberName(WL, 1)} `;

		if (reservedNursery > 0) {
			nurseryHasReservedChildren = true;
			if (WL === 1) {
				r += `Your child will be placed in ${V.nurseryName}.`;
			} else if (reservedNursery < WL) {
				r += `${reservedNursery} of your children will be placed in ${V.nurseryName}.`;
			} else if (WL === 2) {
				r += `Both of your children will be placed in ${V.nurseryName}.`;
			} else {
				r += `All ${reservedNursery} of your children will be placed in ${V.nurseryName}.`;
			}

			if (reservedNursery < WL && reservedChildrenNursery < freeCribs && reservedNursery - reservedIncubator > 0) {
				r += `<br>    `;
				r += App.UI.passageLink("Keep another child", "Nursery", `${reservedNursery += 1}, ${reservedChildrenNursery += 1}`);
				if (reservedNursery > 0) {
					r += ` | ${App.UI.passageLink("Keep one less child", "Nursery", `${reservedNursery -= 1}, ${reservedChildrenNursery -= 1}`)}`;
				}

				if (reservedNursery > 1) {
					r += ` | ${App.UI.passageLink("Keep none of your children", "Nursery", `${reservedChildrenNursery -= reservedNursery}, ${reservedChildrenNursery = 0}`)}`;
				}

				if (reservedChildrenNursery + WL - reservedNursery <= freeCribs) {
					r += ` | ${App.UI.passageLink("Keep the rest of your children", "Nursery", `${reservedChildrenNursery += (WL - reservedNursery)}, ${reservedNursery += (WL - reservedNursery)}`)}`;
				}
			} else if (reservedNursery === WL || reservedChildrenNursery === freeCribs || reservedNursery - reservedIncubator >= 0) {
				r += `<br>    `;
				r += App.UI.passageLink("Keep one less child", "Nursery", `${reservedNursery -= 1}, ${reservedChildrenNursery -= 1}`);
				if (reservedNursery > 1) {
					r += App.UI.passageLink("Keep none of your children", "Nursery", `${reservedChildrenNursery -= reservedNursery}, ${reservedNursery = 0}`);
				}
			}
		} else if (reservedChildrenNursery < freeCribs) {
			if (WL - reservedIncubator === 0) {
				r += `<i>Your child${WL > 1 ? `ren are` : ` is`} already reserved for ${V.incubator.name}</i>`;
				r += App.UI.passageLink(`Keep your child${WL > 1 ? `ren` : ``} here instead`, "Nursery", `${reservedNursery += WL}, ${reservedIncubator = 0}`);
			} else {
				r += `You have ${freeCribs === 1 ? `an ` : ``}available room${freeCribs > 1 ? `s` : ``}. `;
				r += `<br>    `;
				r += App.UI.passageLink(`Keep ${WL > 1 ? `a` : `your`} child`, "Nursery", `${reservedNursery += 1}, ${reservedChildrenNursery += 1}`);
				if (WL > 1 && (reservedChildrenNursery + WL - reservedNursery <= freeCribs)) {
					r += ` | ${App.UI.passageLink("Keep all of your children", "Nursery", `${reservedChildrenNursery += WL}, ${reservedNursery += WL}`)}`;
				}
			}
		} else if (reservedChildrenNursery === freeCribs) {
			r += `<br>    `;
			r += `You have <span class="red">no room for your offspring.</span> `;
		}
	}

	if (reservedChildrenNursery || nurseryHasReservedChildren) {
		r += `<br>`;
		r += App.UI.passageLink("Clear all reserved children", "Nursery", `${V.slaves.forEach((slave) => WombCleanGenericReserve(slave, "nursery", 9999))}, ${WombCleanGenericReserve(PC, "nursery", 9999)}`);
	}

	function byName() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-name');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byReservedSpots() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-reserved-spots');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byPregnancyWeek() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-preg-week');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byPregnancyCount() {
		let sortedNurseryPossibles = $('#ql-nursery div.possible').detach();
		sortedNurseryPossibles = sortDomObjects(sortedNurseryPossibles, 'data-preg-count');
		$(sortedNurseryPossibles).appendTo($('#ql-nursery'));
	}

	function byPreviousSort() {
		let sort = V.sortNurseryList;
		if (sort !== 'unsorted') {
			if (sort === 'Name') {
				sortNurseryPossiblesByName();
			} else if (sort === 'Reserved Nursery Spots') {
				sortNurseryPossiblesByReservedSpots();
			} else if (sort === 'Pregnancy Week') {
				sortNurseryPossiblesByPregnancyWeek();
			} else if (sort === 'Number of Children') {
				sortNurseryPossiblesByPregnancyCount();
			}
		}
	}

	return r;
};


code:
App.UI.organFarm = function() {
	const node = new DocumentFragment();
	const PCSkillCheck = Math.min(V.upgradeMultiplierMedicine, V.HackingSkillMultiplier);

	App.UI.DOM.appendNewElement("h1", node, "The Organ Farm");

	if (V.organFarmUpgrade > 2) {
		App.UI.DOM.appendNewElement("div", node, `The organ farm is running smoothly. It can rapidly grow tailored organs for implantation in slaves. It can easily produce altered variants should you obtain the data necessary to create them.`, "scene-intro");
	} else if (V.organFarmUpgrade > 1) {
		App.UI.DOM.appendNewElement("div", node, `The organ farm is running smoothly. It can quickly grow tailored organs for implantation in slaves, though there will be side-effects. It can easily produce altered variants should you obtain the data necessary to create them.`, "scene-intro");
	} else if (V.organFarmUpgrade > 0) {
		App.UI.DOM.appendNewElement("div", node, `The organ farm is running smoothly. It can grow tailored organs for implantation in slaves. It can easily produce altered variants should you obtain the data necessary to create them.`, "scene-intro");
	}

	if (V.organFarmUpgrade < 3 && V.rep <= 10000 * PCSkillCheck) {
		App.UI.DOM.appendNewElement("div", node, "You lack the reputation to access experimental organ farm parts.", "note");
	} else if (V.dispensary === 0 && V.organFarmUpgrade === 2) {
		App.UI.DOM.appendNewElement("div", node, "An upgraded pharmaceutical fabricator is required by the perfected organ farm.", "note");
	} else if (V.dispensary === 0 && V.organFarmUpgrade === 1) {
		App.UI.DOM.appendNewElement("div", node, "A pharmaceutical fabricator is required to produce the chemicals for the accelerated organ farm.", "note");
	} else if (V.dispensaryUpgrade === 0 && V.organFarmUpgrade === 2) {
		App.UI.DOM.appendNewElement("div", node, "The pharmaceutical fabricator must be upgraded in order to produce the drugs required by the perfected organ farm.", "note");
	} else if (V.organs.length > 0) {
		App.UI.DOM.appendNewElement("div", node, "The organ farm cannot be upgraded while it is use.", "note");
	} else if (V.rep > 10000 * PCSkillCheck) {
		if (V.organFarmUpgrade === 2) {
			App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
				"Upgrade the organ farm to the cutting edge model",
				() => {
					cashX(forceNeg(150000 * PCSkillCheck), "capEx");
					V.organFarmUpgrade = 3;
					App.UI.reload();
				}, [], "",
				`Costs ${cashFormat(150000 * PCSkillCheck)}. Will allow the organ farm to rapidly grow organs without risk to the implantee's health.`
			));
		} else if (V.organFarmUpgrade === 1) {
			App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
				"Upgrade the organ farm with an experimental growth accelerator",
				() => {
					cashX(forceNeg(75000 * PCSkillCheck), "capEx");
					V.organFarmUpgrade = 2;
					App.UI.reload();
				}, [], "",
				`Costs ${cashFormat(75000 * PCSkillCheck)}. Will allow the organ farm to quickly grow organs. Implanted organs may cause health issues.`
			));
		}
	}

	if (V.youngerOvaries > 0) {
		App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing fertile ovaries for postmenopausal slaves.");
	} else {
		if (V.rep <= 10000 * PCSkillCheck) {
			App.UI.DOM.appendNewElement("div", node, "You lack the reputation to access designs for cloning fertile ovaries for menopausal slaves.", "note");
		} else {
			App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
				"Purchase designs for cloning fertile ovaries for menopausal slaves",
				() => {
					cashX(forceNeg(30000 * PCSkillCheck), "capEx");
					V.youngerOvaries = 1;
					App.UI.reload();
				}, [], "",
				`Costs ${cashFormat(30000 * PCSkillCheck)}. Will allow the growth of younger, fertile ovaries for menopausal slaves. Restored fertility will only last for a couple years at most.`
			));
		}
	}

	if (V.asexualReproduction === 1) {
		App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing modified ovary pairs capable of self-fertilization.");
	}

	if (V.seePreg !== 0 && V.seeBestiality === 1 && V.experimental.animalOvaries === 1) {
		if (V.animalOvaries < 1) {
			App.UI.DOM.appendNewElement("div", node, "You lack the required designs for cloning animal ovaries for slaves.", "note");
		} else {
			App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing animal ovaries for slaves.");
		}

		if (V.animalTesticles < 1) {
			App.UI.DOM.appendNewElement("div", node, "You lack the required designs for cloning animal testicles for slaves.", "note");
		} else {
			App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing animal testicles for slaves.");
		}

		if (V.arcologies[0].FSGenderRadicalistResearch === 1) {
			if (V.animalMpreg < 1) {
				App.UI.DOM.appendNewElement("div", node, "You lack the required designs for cloning animal anal wombs and ovaries for slaves.", "note");
			} else {
				App.UI.DOM.appendNewElement("div", node, "The organ farm is capable of growing animal anal wombs and ovaries for slaves.");
			}
		}
	}

	App.UI.DOM.appendNewElement("h2", node, "Organ Production");
	App.UI.DOM.appendNewElement("p", node, App.Medicine.OrganFarm.currentlyGrowing());

	App.UI.DOM.appendNewElement("h2", node, "Future Societies Research");

	if (V.seePreg !== 0) {
		if (V.arcologies[0].FSGenderRadicalistDecoration === 100) {
			if (V.arcologies[0].FSGenderRadicalistResearch === 0) {
				if (V.rep >= 10000 * PCSkillCheck) {
					App.UI.DOM.appendNewElement("div", node, App.UI.DOM.link(
						"Fund research into developing male pregnancy methods",
						() => {
							cashX(forceNeg(50000 * PCSkillCheck), "capEx");
							V.arcologies[0].FSGenderRadicalistResearch = 1;
							App.UI.reload();
						}, [], "",
						`Costs ${cashFormat(50000 * PCSkillCheck)}. Will allow cloning and production of anal uteri and ovaries.`
					));
				} else {
					App.UI.DOM.appendNewElement("div", node, "You lack the reputation to access the research necessary to develop anal uteri and ovaries.", "note");
				}
			} else {
				App.UI.DOM.appendNewElement("div", node, "The organ farm has been upgraded with schematics for modified uteri and ovaries.");
			}
		} else if (V.arcologies[0].FSGenderRadicalistResearch === 1) {
			App.UI.DOM.appendNewElement("div", node, "The organ farm has been upgraded with schematics for modified uteri and ovaries.", "note");
		} else {
			App.UI.DOM.appendNewElement("div", node, "Gender Radicalist focused research unavailable.", "note");
		}
	}
	return node;
};

repo_name: Fanatey/fc

license: mit


code:
App.Facilities.HGSelect = function() {
	let div = document.createElement("div");
	const f = document.createDocumentFragment();
	let r = [];
	let links = [];

	App.UI.DOM.appendNewElement("h1", f, "Head Girl Management");

	if (S.HeadGirl) {
		const HGName = SlaveFullName(S.HeadGirl);
		const {
			His, He, he,
			his, him, himself
		} = getPronouns(S.HeadGirl);

		f.append(`${SlaveFullName(S.HeadGirl)} is working as your HeadGirl`);
		if (V.arcologies[0].FSEgyptianRevivalistLaw === 1) {
			f.append(`/Consort; serving and providing comfort, in addition to performing normal Head Girl duties`);
		}
		f.append(`. `);
		if (V.HGSuite) {
			f.append(`Currently living in ${capFirstChar(V.HGSuiteName)}. `);
		}
		f.append(App.UI.DOM.link("Remove HeadGirl", () => {
			removeJob(S.HeadGirl, Job.HEADGIRL);
		},
		[], "Main"
		));

		App.UI.DOM.appendNewElement("h2", f, `Slave training`);
		App.UI.DOM.appendNewElement("div", f, `${HGName} will prioritize enabled items in the following order`, "note");

		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsHealth"), " Health");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		div = document.createElement("div");
		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsParaphilias"), " Paraphilias");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		if (V.headGirlTrainsFlaws) {
			r.push(`${HGName} will remove flaws.`,);
		} else if (V.headGirlSoftensFlaws) {
			r.push(`${HGName} will soften flaws into quirks.`);
		} else if (V.headGirlOverridesQuirks) {
			r.push(`${HGName} will override quirks.`);
		} else {
			r.push(`${HGName} will ignore flaws.`);
		}

		links.push(App.UI.DOM.link("Override quirks", () => {
			V.headGirlTrainsFlaws = 0;
			V.headGirlSoftensFlaws = 0;
			V.headGirlOverridesQuirks = 1;
			App.UI.reload();
		}));
		links.push(App.UI.DOM.link("Soften flaws", () => {
			V.headGirlTrainsFlaws = 0;
			V.headGirlSoftensFlaws = 1;
			V.headGirlOverridesQuirks = 0;
			App.UI.reload();
		}));
		links.push(App.UI.DOM.link("Remove flaws", () => {
			V.headGirlTrainsFlaws = 1;
			V.headGirlSoftensFlaws = 0;
			V.headGirlOverridesQuirks = 0;
			App.UI.reload();
		}));

		links.push(App.UI.DOM.link("Ignore flaws", () => {
			V.headGirlTrainsFlaws = 0;
			V.headGirlSoftensFlaws = 0;
			V.headGirlOverridesQuirks = 0;
			App.UI.reload();
		}));

		r.push(App.UI.DOM.generateLinksStrip(links));
		App.Events.addNode(f, r, "div", "indent");

		div = document.createElement("div");
		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsObedience"), " Obedience");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		div = document.createElement("div");
		div.append(App.UI.DOM.makeCheckbox("headGirlTrainsSkills"), " Skills");
		App.UI.DOM.appendNewElement("div", f, div, "indent");

		App.UI.DOM.appendNewElement("h2", f, "Training methods");

		r = [];
		if (V.HGSeverity === 1) {
			r.push(`${HGName} will be <span class="bold">aggressive</span> when punishing, with rape strongly encouraged.`);
			r.push(App.UI.DOM.link("Moderate", () => {
				V.HGSeverity = 0;
				App.UI.reload();
			}));
		} else if (V.HGSeverity === 0) {
			links = [];
			r.push(`${HGName} will be <span class="bold">moderate</span> when punishing, carefully selecting appropriate consequences.`);
			links.push(App.UI.DOM.link("Be aggressive", () => {
				V.HGSeverity = 1;
				App.UI.reload();
			}));
			links.push(App.UI.DOM.link(`Apply restrictions`, () => {
				V.HGSeverity = -1;
				App.UI.reload();
			}));
			r.push(App.UI.DOM.generateLinksStrip(links));
		} else if (V.HGSeverity === -1) {
			r.push(`${HGName} will be <span class="bold">respectful</span> when punishing, treating slaves decently.`);
			r.push(App.UI.DOM.link("Be stricter", () => {
				V.HGSeverity = 0;
				App.UI.reload();
			}));
		}
		App.Events.addNode(f, r, "div", "indent");

		r = [];
		if (V.HGPiercings === 1) {
			r.push(`${HGName} is <span class="bold">allowed</span> to use piercings as a tool to improve slaves' attitudes.`);
			r.push(App.UI.DOM.link("Disallow", () => {
				V.HGPiercings = 0;
				App.UI.reload();
			}));
		} else {
			r.push(`${HGName} is <span class="bold">not allowed</span> to use piercings as a tool to improve slaves' attitudes.`);
			r.push(App.UI.DOM.link("Allow", () => {
				V.HGPiercings = 1;
				App.UI.reload();
			}));
		}
		App.Events.addNode(f, r, "div", "indent");

		r = [];
		App.UI.DOM.appendNewElement("h2", f, "Behavior");
		if (V.HGFormality === 1) {
			r.push(`${HGName} will be <span class="bold">formal:</span> you will always be called ${getWrittenTitle(S.HeadGirl)}, just like any other slave.`);
			r.push(App.UI.DOM.link("Allow private informality", () => {
				V.HGFormality = 0;
				App.UI.reload();
			}));
		} else {
			r.push(`${HGName} is allowed to be <span class="bold">informal:</span> in private, you can be called ${properTitle()}.`);
			r.push(App.UI.DOM.link("Maintain complete formality", () => {
				V.HGFormality = 1;
				App.UI.reload();
			}));
		}
		App.Events.addNode(f, r, "div", "indent");

		if (V.seePreg !== 0) {
			if (V.universalRulesImpregnation === "HG") {
				App.UI.DOM.appendNewElement("div", f, `${HGName} is responsible for impregnating fertile slaves.`);
				V.HGCum = resetHGCum(S.HeadGirl);
				if (canPenetrate(S.HeadGirl) && S.HeadGirl.pubertyXY === 1) {
					App.UI.DOM.appendNewElement("div", f, `To maximize the chances of impregnation, ${he} will fuck fertile pussies frequently during the week. ${S.HeadGirl.slaveName} can service ${V.HGCum} slaves this way.`);
					if (S.HeadGirl.devotion > 95) {
						App.UI.DOM.appendNewElement("div", f, `${He} loves you so much ${he}'ll fuck them until ${he}'s sore.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `If ${he} were more devoted to you, ${he} might be able to drive ${himself} to get hard and service one more.`);
					}
					if (S.HeadGirl.balls >= 120) {
						App.UI.DOM.appendNewElement("div", f, `${His} unreal balls produce nearly an endless supply of semen; ${his} ability to impregnate is almost limitless.`);
					} else if (S.HeadGirl.balls >= 80) {
						App.UI.DOM.appendNewElement("div", f, `${His} inhuman balls produce so much semen ${he} can easily impregnate twenty girls in one sitting.`);
					} else if (S.HeadGirl.balls >= 50) {
						App.UI.DOM.appendNewElement("div", f, `${His} giant balls produce so much semen ${he} can easily impregnate twelve girls in one sitting.`);
					} else if (S.HeadGirl.balls >= 25) {
						App.UI.DOM.appendNewElement("div", f, `${His} oversized balls produce so much semen ${he} can cum repeatedly in a single session.`);
					} else if (S.HeadGirl.balls >= 5) {
						App.UI.DOM.appendNewElement("div", f, `${His} big balls produce so much semen ${he} can cum more before ${he}'s drained.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `Bigger balls would let ${him} cum more before ${he}'s drained.`);
					}
					if (S.HeadGirl.health.condition > 95) {
						App.UI.DOM.appendNewElement("div", f, `${His} wonderful health lets ${him} get hard and stay hard all the time.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `If ${his} health were perfect, ${he} might be able to get hard more often.`);
					}
					if (S.HeadGirl.energy > 95) {
						App.UI.DOM.appendNewElement("div", f, `${His} nymphomania drives ${him} to go above and beyond in this.`);
					} else {
						App.UI.DOM.appendNewElement("div", f, `A more powerful sex drive could reduce ${his} refractory period.`);
					}
				} else {
					App.UI.DOM.appendNewElement("div", f, `However, ${S.HeadGirl.slaveName} cannot perform this duty.`);
				}
				r.push(App.UI.DOM.link(` Rescind ${his} impregnation responsibility`, () => {
					V.universalRulesImpregnation = "none";
					App.UI.reload();
				}));
				r.push(App.UI.DOM.link(` See to it yourself`, () => {
					V.universalRulesImpregnation = "PC";
					App.UI.reload();
				}));
				f.append(App.UI.DOM.generateLinksStrip(r));
			} else {
				if (canPenetrate(S.HeadGirl) && S.HeadGirl.pubertyXY === 1) {
					App.UI.DOM.appendNewElement("div", f, `${HGName} is capable of impregnating slaves, but it's not part of ${his} responsibilities.`).append(
						App.UI.DOM.link(` Assign ${him} to impregnate`, () => {
							V.universalRulesImpregnation = "HG";
							App.UI.reload();
						}));
				}
			}
		}
	} else {
		f.append(`No HeadGirl assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.headGirlSuite, "Head Girl Select"));
	return f;
};


code:
App.Facilities.RecruiterSelect = function() {
	const f = document.createDocumentFragment();
	const recruiterCap = document.createDocumentFragment();
	let newLine = document.createElement("div");
	let r = [];

	App.UI.DOM.appendNewElement("h1", f, "Recruiter Management");
	if (S.Recruiter) {
		App.UI.DOM.appendNewElement("span", f, `${SlaveFullName(S.Recruiter)} is working as your Recruiter, currently ${V.recruiterTarget !== "other arcologies" ? 'recruiting girls. ' : 'acting as a sexual Ambassador'}`);
		if (V.recruiterTarget === "other arcologies") {
			const externalArcology = V.arcologies.find(s => s.direction === V.arcologies[0].influenceTarget);
			if (!externalArcology) {
				App.UI.DOM.appendNewElement("span", f, `. `);
				App.UI.DOM.appendNewElement("span", f, `Since you have not selected another arcology to influence, your recruiter's talents are going to waste. Select an influence target to apply them. `, "red");
			} else {
				App.UI.DOM.appendNewElement("span", f, ` to ${externalArcology.name}. `);
			}
		}
		f.append(App.UI.DOM.link("Remove Recruiter", () => {
			removeJob(S.Recruiter, Job.RECRUITER);
		},
		[], "Main"
		));

		App.UI.DOM.appendNewElement("p", f);
		f.append(`Your recruiter will target ${V.recruiterTarget}, `);
		if (V.recruiterTarget === "desperate whores") {
			f.append("they will be skilled but unhealthy. ");
		} else if (V.recruiterTarget === "young migrants") {
			f.append("they will be young and inexperienced but unhealthy. ");
		} else if (V.recruiterTarget === "recent divorcees") {
			f.append("they will be mature. ");
		} else if (V.recruiterTarget === "expectant mothers") {
			f.append("they will be pregnant and likely unhealthy. ");
		} else if (V.recruiterTarget === "dissolute sissies") {
			f.append("they will be born male and have some experience. ");
		} else if (V.recruiterTarget === "reassignment candidates") {
			f.append("they will be born male. ");
		} else if (V.recruiterTarget === "other arcologies") {
			f.append("they will appoint the Recruiter to be a sexual Ambassador. ");
		}

		r.push(App.UI.DOM.link(`Desperate whores`, () => {
			V.recruiterTarget = "desperate whores";
			App.UI.reload();
		}));
		r.push(App.UI.DOM.link("Young migrants", () => {
			V.recruiterTarget = "young migrants";
			App.UI.reload();
		}));
		r.push(App.UI.DOM.link("Recent divorcees", () => {
			V.recruiterTarget = "recent divorcees";
			App.UI.reload();
		}));

		if (V.seeDicks !== 100 && V.seePreg !== 0) {
			r.push(App.UI.DOM.link("Expectant mothers", () => {
				V.recruiterTarget = "expectant mothers";
				App.UI.reload();
			}));
		}
		if (V.seeDicks !== 0) {
			r.push(App.UI.DOM.link("Dissolute sissies", () => {
				V.recruiterTarget = "dissolute sissies";
				App.UI.reload();
			}));
			r.push(App.UI.DOM.link("Reassignment candidates", () => {
				V.recruiterTarget = "reassignment candidates";
				App.UI.reload();
			}));
		}
		if (V.arcologies.length > 1) {
			r.push(App.UI.DOM.link("Other arcologies' cultures", () => {
				V.oldRecruiterTarget = V.recruiterTarget;
				V.recruiterTarget = "other arcologies";
				App.UI.reload();
			}));
		}
		App.UI.DOM.appendNewElement("div", f, App.UI.DOM.generateLinksStrip(r));
		App.UI.DOM.appendNewElement("p", f);

		newLine.append(App.UI.DOM.makeCheckbox("recruiterEugenics"), App.UI.DOM.makeElement("span", " Target only individuals that can pass eugenics SMRs. This option will increase time it takes to recruit depending on how many eugenics SMR are active.", "note"));
		App.UI.DOM.appendNewElement("div", f, newLine);

		f.append("Suspend active recruiting and focus on publicity when: ");
		if (V.recruiterIdleRule === "number") {
			f.append(`${V.recruiterIdleNumber} sex slaves owned`);
		} else if (V.recruiterIdleRule === "facility") {
			const idleTarget = App.Utils.recruiterFacilitySpace();
			f.append(`match facility expansion, `);
			if (idleTarget > 20) {
				f.append(`${idleTarget} positions.`);
			} else {
				f.append("20 positions (rule minimum).");
			}
		} else {
			f.append("always recruit");
		}

		r = [];
		r.push(App.UI.DOM.link("Always recruit", () => {
			V.recruiterIdleRule = "always";
			App.UI.reload();
		}));
		r.push(App.UI.DOM.link("Facilities & leadership", () => {
			V.recruiterIdleRule = "facility";
			App.UI.reload();
		}));
		recruiterCap.append(App.UI.DOM.link("Set to this many slaves ", () => {
			V.recruiterIdleRule = "number";
			App.UI.reload();
		}));
		if (V.recruiterIdleRule === "number") {
			recruiterCap.append(App.UI.DOM.makeTextBox(V.recruiterIdleNumber, (v) => {
				V.recruiterIdleNumber = v;
				Engine.play(passage());
			}, true));
		}
		r.push(recruiterCap);
		App.UI.DOM.appendNewElement("div", f, App.UI.DOM.generateLinksStrip(r));
		App.UI.DOM.appendNewElement("div", f, "'Facilities' doesn't include training slots in cellblock, schoolroom, spa, clinic (but does include those leaders)");

		V.recruiterIdleNumber = Math.max(Math.trunc(Number(V.recruiterIdleNumber) || 20), 20);
	} else {
		f.append(`No Recruiter assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.penthouse, "Recruiter Select"));
	return f;
};


code:
/**
 * UI for managing Penthouse Refreshes without refreshing the passage.
 */
App.UI.managePenthouse = function() {
	const container = document.createElement("span");
	container.append(createPage());
	return container;

	function createPage() {
		const el = new DocumentFragment();
		el.append(intro());
		el.append(capacity());
		el.append(major());
		el.append(minor());
		el.append(upgrades());
		el.append(blackMarket());
		return el;
	}

	function intro() {
		const el = new DocumentFragment();
		if (V.cheatMode === 1) {
			App.UI.DOM.appendNewElement("div", el,
				App.UI.DOM.passageLink("Cheat Edit Arcology", "MOD_Edit Arcology Cheat"),
				["cheat-menu"]);
		}
		App.UI.DOM.appendNewElement("h1", el, "Penthouse");
		App.UI.DOM.appendNewElement("div", el, App.Desc.officeDescription(V.PC.career === "mercenary" ? "You look back at the rifle. It could never hold a zero, and would fail to feed if it wasn't given just the right amount of lubricant. But sometimes, you'd give anything for one more mission with that shitty old rifle." : ""), "scene-intro");
		if (V.SF.Toggle && V.SF.Active >= 1) {
			App.UI.DOM.appendNewElement("div", el,
				App.UI.DOM.passageLink(
					`Take your express elevator down to ${V.SF.Lower}`,
					"Firebase"
				)
			);
		} else if (V.SF.FS.Tension > 100) {
			App.UI.DOM.appendNewElement("div", el, App.Mods.SF.fsIntegration.badOutcomeFirebase());
		}
		return el;
	}

	function capacity() {
		const el = new DocumentFragment();
		let r = [];
		App.UI.DOM.appendNewElement("h2", el, "Penthouse Capacity");

		// Dorms
		const dormCost = Math.trunc(V.dormitory * 1000 * V.upgradeMultiplierArcology);
		r.push(`The main penthouse dormitory, which houses slaves who aren't living in a facility and aren't granted a luxurious standard of living, has a capacity of`);
		r.push(App.UI.DOM.makeElement("span", JSON.stringify(V.dormitory), ["bold"]));
		r.push(`slaves.`);
		r.push(
			makePurchase(`Expand the dormitory`, dormCost, "capEx", {
				handler: () => {
					V.dormitory += 10;
					V.PC.skill.engineering += .1;
				}
			})
		);
		r.push(App.UI.DOM.makeElement("div", `Exceeding this limit is bad for slaves' health, devotion and trust.`, ["detail", "indent"]));
		App.Events.addNode(el, r, "div");

		// Luxury rooms
		r = [];
		const luxuryCost = Math.trunc(V.rooms * 1000 * V.upgradeMultiplierArcology);
		r.push(`The penthouse also features little individual rooms, which house slaves who do enjoy a luxurious standard of living. They have a capacity of`);
		r.push(App.UI.DOM.makeElement("span", JSON.stringify(V.rooms), ["bold"]));
		r.push(`slaves.`);
		r.push(
			makePurchase(`Expand the rooms`, luxuryCost, "capEx", {
				handler: () => {
					V.rooms += 5;
					V.PC.skill.engineering += .1;
				}
			})
		);
		r.push(App.UI.DOM.makeElement("div", `The number of rooms determines the number of slaves that can be granted luxury.`, ["detail", "indent"]));
		App.Events.addNode(el, r, "div");
		return el;
	}

	function major() {
		const el = new DocumentFragment();
		App.UI.DOM.appendNewElement("h2", el, "Major Penthouse Facilities");

		if (V.masterSuite === 0) {
			App.UI.DOM.appendNewElement("div", el, makeLink("Improve your master bedroom to house a harem of personal toys", () => { V.masterSuite = 1; }));
		} else {
			App.UI.DOM.appendNewElement("div", el, `Your penthouse is capped by a master suite with room for an entire harem of personal toys.`);
		}

		if (V.servantsQuarters === 0) {
			App.UI.DOM.appendNewElement("div", el, makeLink("Build a dormitory to house large numbers of house servants", () => { V.servantsQuarters = 5; }));
		} else {
			App.UI.DOM.appendNewElement("div", el, `Your penthouse includes a dormitory to house large numbers of house servants.`);
		}

		if (V.schoolroom === 0) {
			App.UI.DOM.appendNewElement("div", el, makeLink("Build a schoolroom where slaves can be educated", () => { V.schoolroom = 5; }));
		} else {
			App.UI.DOM.appendNewElement("div", el, `Your penthouse includes a schoolroom where slaves can be educated.`);
		}

		if (V.spa === 0) {
			App.UI.DOM.appendNewElement("div", el, makeLink("Install open baths to provide relaxation space for resting slaves", () => { V.spa = 5; }));
		} else {
			App.UI.DOM.appendNewElement("div", el, `The penthouse includes a fully appointed spa where slaves can rest and recuperate.`);
		}

		if (V.seePreg !== 0) {
			if (V.experimental.nursery === 1) {
				if (V.nursery === 0) {
					App.UI.DOM.appendNewElement("div", el, makeLink("Build a nursery to raise children from birth", () => {
						V.nursery = 5;
						V.nurseryNannies = 1;
					}));
				} else {
					App.UI.DOM.appendNewElement("div", el, `The penthouse has a nursery built where infants can be brought up.`);
				}
			}
		}

		if (V.clinic === 0) {
			App.UI.DOM.appendNewElement("div", el, makeLink("Expand the surgical recovery area to accommodate patients and a nurse", () => { V.clinic = 5; }));
		} else {
			App.UI.DOM.appendNewElement("div", el, `The surgical recovery area has been expanded to take in more unhealthy slaves and be staffed by a nurse.`);
		}

		if (V.cellblock === 0) {
			App.UI.DOM.appendNewElement("div", el, makeLink("Construct cells to properly confine disobedient slaves", () => { V.cellblock = 5; }));
		} else {
			App.UI.DOM.appendNewElement("div", el, `The lower level of the penthouse includes a hallway of cells to confine slaves in.`);
		}

		if (V.seePreg !== 0) {
			if (V.arcologyUpgrade.grid === 1) {
				if (V.incubator.capacity === 0) {
					App.UI.DOM.appendNewElement("div", el, makeLink("Install an incubation chamber to rapidly age children", () => {
						App.Facilities.Incubator.init('full');
					}));
				} else {
					App.UI.DOM.appendNewElement("div", el, `The penthouse has a specialized facility dedicated to rapidly aging children.`);
				}
			} else if (V.arcologyUpgrade.hydro === 1 || V.arcologyUpgrade.apron === 1) {
				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.makeElement("span", "Installation of a child aging facility will require the arcology's electrical infrastructure to be overhauled.", "note"));
			}
		}

		return el;
	}

	function minor() {
		const el = new DocumentFragment();
		let r = [];
		App.UI.DOM.appendNewElement("h2", el, "Minor Penthouse Facilities");

		if (V.HGSuite !== 1) {
			r.push(makeLink("Build a small suite for a Head Girl to live in", () => { V.HGSuite = 1; }));
		} else {
			r.push(`There is a small but handsome suite next to yours reserved for the Head Girl.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.dojo === 0) {
			r.push(makeLink("Set up a personal armory to support a bodyguard", () => { V.dojo = 1; }));
		} else if (V.dojo === 1) {
			r.push(`There is a small armory next to your office that can support a bodyguard.`);
			r.push(makeLink("Upgrade the armory with a private room for the bodyguard", () => { V.dojo = 2; }));
		} else {
			r.push(`There is a small armory next to your office that can support a bodyguard, with a little room for them to rest in when off duty.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (!V.toyShop) {
			r.push(makeLink("Install a workshop for making custom toys", () => { V.toyShop = true; }));
		} else {
			r.push(`There is a`);
			r.push(App.UI.DOM.passageLink("workshop", "Toy Shop"));
			r.push(`for making custom toys.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.surgeryUpgrade === 0) {
			if (V.rep > 10000) {
				r.push(makeLink("Upgrade the remote surgery", () => { V.surgeryUpgrade = 1; }, 50000));
			} else {
				r.push(App.UI.DOM.makeElement("span", "You lack the reputation to secure rare surgery upgrades.", "note"));
			}
		} else {
			r.push(`Your remote surgery has been heavily upgraded and customized.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.dispensary === 0) {
			if (V.rep > 2000) {
				r.push(makeLink("Install a pharmaceutical fabricator", () => {
					V.dispensary = 1;
					V.drugsCost = V.drugsCost * .75;
				}, 20000));
			} else {
				r.push(App.UI.DOM.makeElement("span", "You lack the reputation to obtain cutting-edge pharmaceutical technology.", "note"));
			}
		} else {
			r.push(`There is a`);
			r.push(App.UI.DOM.passageLink("pharmaceutical fabricator", "Dispensary"));
			r.push(`attached to the surgery.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.ImplantProductionUpgrade === 0) {
			if (V.rep > 2000) {
				r.push(makeLink("Install an implant manufactory", () => { V.ImplantProductionUpgrade = 1; }, 20000));
			} else {
				r.push(App.UI.DOM.makeElement("span", "You lack the reputation to obtain cutting-edge implant fabrication technology.", "note"));
			}
		} else {
			r.push(`There is a`);
			r.push(App.UI.DOM.passageLink("implant manufactory", "Implant Manufactory"));
			r.push(`attached to the surgery.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.organFarmUpgrade === 0) {
			if (V.rep > 10000) {
				r.push(makeLink("Install an experimental organ farm", () => { V.organFarmUpgrade = 1; }, 70000));
			} else {
				r.push(App.UI.DOM.makeElement("span", "You lack the reputation to obtain an experimental organ fabricator.", "note"));
			}
		} else {
			r.push(`There is a`);
			r.push(App.UI.DOM.passageLink("organ farm", "Organ Farm"));
			r.push(`attached to the surgery.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.geneticMappingUpgrade === 0) {
			if (V.rep > 14000) {
				r.push(makeLink("Install a genetic sequencer", () => { V.geneticMappingUpgrade = 1; }, 120000));
			} else {
				r.push(App.UI.DOM.makeElement("span", "You lack the reputation to purchase a cutting-edge genetic sequencer.", "note"));
			}
		} else {
			r.push(`There is a`);
			r.push(App.UI.DOM.passageLink("genetic sequencer", "Gene Lab"));
			r.push(`attached to the surgery.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		switch (V.prostheticsUpgrade) {
			case 0:
				if (V.rep > 8000) {
					r.push(makeLink("Install basic equipment for attaching and maintenance of prosthetics", () => { V.prostheticsUpgrade = 1; }, 120000));
				} else {
					r.push(App.UI.DOM.makeElement("span", "You lack the reputation to buy basic equipment for attaching and maintenance of prosthetics.", "note"));
				}
				break;
			case 1:
				r.push(`You have basic equipment for attaching and maintenance of prosthetics.`);
				if (V.rep > 12000) {
					r.push(makeLink("Buy a contract for advanced prosthetics", () => { V.prostheticsUpgrade = 2; }, 100000));
				} else {
					r.push(App.UI.DOM.makeElement("span", "You lack the reputation to get a contract for advanced prosthetics.", "note"));
				}
				break;
			case 2:
				r.push(`You have basic equipment for attaching and maintenance of prosthetics and a contract to guarantee the availability of advanced prosthetics.`);
				if (V.rep > 16000) {
					r.push(makeLink("Buy a contract for high-tech prosthetics", () => { V.prostheticsUpgrade = 3; }, 100000));
				} else {
					r.push(App.UI.DOM.makeElement("span", "You lack the reputation to get a contract for high-tech prosthetics.", "note"));
				}
				break;
			case 3:
				r.push(`You have advanced equipment for attaching and maintenance of prosthetics and a contract to guarantee the availability of high-tech prosthetics.`);
				if (V.rep > 18000) {
					r.push(makeLink("Buy a contract for quadruped prosthetics", () => { V.prostheticsUpgrade = 4; }, 100000));
				} else {
					r.push(App.UI.DOM.makeElement("span", "You lack the reputation to get a contract for qaudruped prosthetics.", "note"));
				}
				break;
			case 4:
				r.push(`You have advanced equipment for attaching and maintenance of prosthetics and a contract to guarantee the availability of qaudruped prosthetics.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.prostheticsUpgrade > 0) {
			if (V.researchLab.level > 0) {
				r.push(`Your penthouse is equipped with an advanced prosthetic lab.`);
			} else {
				r.push(makeLink("Clear out one of the floors and install equipment to construct prosthetics yourself", () => {
					V.researchLab.level = 1;
					V.researchLab.maxSpace = 5;
				}, 150000));
				r.push(App.UI.DOM.makeElement("div", `Buying the equipment to construct prosthetics yourself is expensive but if you plan to construct many prosthetics it will pay out in the long run.`, "indent"));
			}
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.seePreg === 1) {
			if (V.pregnancyMonitoringUpgrade === 0) {
				if (V.rep > 10000) {
					r.push(makeLink("Upgrade the pregnancy monitoring systems", () => { V.pregnancyMonitoringUpgrade = 1; }, 30000));
				} else {
					r.push(App.UI.DOM.makeElement("span", "You lack the reputation to purchase improved pregnancy monitoring systems.", "note"));
				}
			} else {
				r.push(`Your pregnancy monitoring systems have been heavily upgraded.`);
			}
		}
		App.Events.addNode(el, r, "div");

		return el;
	}

	function upgrades() {
		const el = new DocumentFragment();
		let r = [];
		App.UI.DOM.appendNewElement("h2", el, "Penthouse Upgrades");

		if (V.servantMilkers !== 1) {
			r.push("Your penthouse is equipped with basic milkers for lactating slaves.");
			r.push(makeLink("Install more and tie them into the liquid systems", () => { V.servantMilkers = 1; }, 25000));
		} else {
			r.push(`Every room in the penthouse is equipped with milkers tied into the liquid systems, letting slaves with full udders drain them anywhere.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.boobAccessibility !== 1) {
			if (V.pregAccessibility === 1 || V.ballsAccessibility || V.buttAccessibility) {
				r.push(`Your penthouse has already been widened for overly wide slaves but there are no special accommodations for slaves with enormous breasts.`);
				r.push(makeLink("Remodel for accessibility", () => { V.boobAccessibility = 1; }, 20000));
			} else {
				r.push(`Your penthouse has no special accessibility provisions for slaves with enormous breasts.`);
				r.push(makeLink("Remodel for accessibility", () => { V.boobAccessibility = 1; }, 50000));
			}
		} else {
			r.push(`The entire penthouse has been remodeled to make life with enormous breasts easier. The doorways have been widened, and tables, sinks, and other items now have two levels: one at shoulder height for slaves to use, and another at waist height for them to rest their tits on while they do.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.seeHyperPreg === 1) {
			if (V.pregAccessibility !== 1) {
				if (V.boobAccessibility === 1 || V.ballsAccessibility || V.buttAccessibility) {
					r.push(`Your penthouse has already been widened to make life for overly wide slaves easier but there are no special accommodations for slaves with enormous pregnancies.`);
					r.push(makeLink("Remodel for accessibility", () => { V.pregAccessibility = 1; }, 20000));
				} else {
					r.push(`Your penthouse has no special accessibility provisions for slaves with enormous pregnancies.`);
					r.push(makeLink("Remodel for accessibility", () => { V.pregAccessibility = 1; }, 50000));
				}
			} else {
				r.push(`The entire penthouse has been remodeled to make life with enormous pregnancies easier. The doorways have been widened, and tables, sinks, and other items are now designed to work around a massively distended belly.`);
			}
		}
		App.Events.addNode(el, r, "div");

		if (V.arcologies[0].FSAssetExpansionistResearch === 1) {
			r = [];
			if (V.dickAccessibility !== 1) {
				r.push(`Your penthouse has no special accessibility provisions for slaves with enormous dicks.`);
				r.push(makeLink("Remodel for accessibility", () => { V.dickAccessibility = 1; }, 20000));
			} else {
				r.push(`The entire penthouse has been remodeled to make life with enormous dicks easier. Carts, slings and harnesses are available to keep things from dragging and there is now plenty of room for huge genitals to occupy when a slave must use appliances, tables and seats.`);
			}
			App.Events.addNode(el, r, "div");

			r = [];
			if (V.ballsAccessibility !== 1) {
				if (V.boobAccessibility === 1 || V.buttAccessibility || V.pregAccessibility) {
					r.push(`Your penthouse has already been widened to make life for overly wide slaves easier but there are no special accommodations for slaves with enormous testicles.`);
					r.push(makeLink("Remodel for accessibility", () => { V.ballsAccessibility = 1; }, 20000));
				} else {
					r.push(`Your penthouse has no special accessibility provisions for slaves with enormous testicles.`);
					r.push(makeLink("Remodel for accessibility", () => { V.ballsAccessibility = 1; }, 50000));
				}
			} else {
				r.push(`The entire penthouse has been remodeled to make life with enormous testicles easier. The doorways have been widened, tables, sinks, and other items are now designed to fit over giant balls, drains have been widened to allow excessive cum to flow easier, and seats have been specially altered to allow plenty of ball room for seated slaves.`);
			}
			App.Events.addNode(el, r, "div");

			r = [];
			if (V.buttAccessibility !== 1) {
				if (V.boobAccessibility === 1 || V.dickAccessibility || V.ballsAccessibility) {
					r.push(`Your penthouse has already been widened to make life for overly wide slaves easier but there are no special accommodations for slaves with gigantic posteriors.`);
					r.push(makeLink("Remodel for accessibility", () => { V.buttAccessibility = 1; }, 20000));
				} else {
					r.push(`Your penthouse has no special accessibility provisions for slaves with enormous posteriors.`);
					r.push(makeLink("Remodel for accessibility", () => { V.buttAccessibility = 1; }, 50000));
				}
			} else {
				r.push(`The entire penthouse has been remodeled to make life with enormous rears easier. The doorways have been widened, and anything that can be sat on is now extra, extra wide and reinforced to allow even the heaviest, biggest asses to comfortably rest upon it.`);
			}
			App.Events.addNode(el, r, "div");
		}

		r = [];
		if (V.boobAccessibility > 0 || V.pregAccessibility > 0 || V.dickAccessibility > 0 || V.ballsAccessibility > 0 || V.buttAccessibility > 0) {
			const removeCost = Math.trunc((5000 * (V.boobAccessibility + V.pregAccessibility + V.dickAccessibility + V.ballsAccessibility + V.buttAccessibility)) * V.upgradeMultiplierArcology);
			el.append(makePurchase(`Remove the accessibility renovations`, removeCost, "capEx", {
				handler: () => {
					V.boobAccessibility = 0;
					V.pregAccessibility = 0;
					V.dickAccessibility = 0;
					V.ballsAccessibility = 0;
					V.buttAccessibility = 0;
				}
			}));
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.feeder === 0) {
			r.push(makeLink("Upgrade the kitchen's nutritional sensing systems", () => { V.feeder = 1; }));
		} else {
			r.push(`The kitchen mounts sensors to refine diets in real time.`);
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.cockFeeder === 0) {
			r.push(makeLink("Enhance the feeding system with faux phalli", () => { V.cockFeeder = 1; }));
		} else {
			r.push(`The kitchen dispenses food from phalli slaves must suck off in order to eat.`);
			r.push(makeLink("Remove them", () => { V.cockFeeder = 0; }, 0));
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.suppository === 0) {
			r.push(makeLink("Replace the drug dispensers with reciprocating dildo suppositories", () => { V.suppository = 1; }));
		} else {
			r.push(`The kitchen applies drugs that can be absorbed rectally by assfucking slaves with dildos that cum the pharmaceuticals.`);
			r.push(makeLink("Remove them", () => { V.suppository = 0; }, 0));
		}
		App.Events.addNode(el, r, "div");

		r = [];
		if (V.dairy !== 0) {
			if (V.dairyPiping === 0) {
				r.push(makeLink("Install pipes connecting the Dairy to the rest of your penthouse for use in enema play", () => { V.dairyPiping = 1; }));
			} else {
				r.push(`Various taps around the penthouse supply product from ${V.dairyName} for use in enema play and force-feeding.`);
			}
		} else if (V.dairyPiping === 1) {
			r.push(`Various taps around the penthouse supply product from ${V.dairyName} for use in enema play and force-feeding. With no dairy to draw from, they are currently unused.`);
		}
		App.Events.addNode(el, r, "div");

		if (V.seePee === 1) {
			r = [];
			if (V.wcPiping === 0) {
				r.push(makeLink("Install pipes connecting the slave bathrooms to the rest of your penthouse for use in watersports", () => { V.wcPiping = 1; }, 10000));
			} else {
				r.push(`The plumbing underneath the slave bathrooms connects to various taps throughout the penthouse that can dispense its contents when needed.`);
			}
			App.Events.addNode(el, r, "div");
		}

		r = [];
		if (V.studio === 0) {
			r.push(makeLink("Install a media hub to convert slave video feeds into pornography", () => { V.studio = 1; }, 10000));
		} else {
			r.push(`The arcology's video systems are connected to a media hub that can convert slave video feeds into pornography.`);
			if (V.studioFeed === 0) {
				r.push(makeLink("Upgrade the media hub to allow better control of pornographic content", () => { V.studioFeed = 1; }, 15000));
			} else {
				r.push(`It has been upgraded to allow superior control of a slave's pornographic content.`);
			}
		}
		App.Events.addNode(el, r, "div");

		return el;
	}

	function blackMarket() {
		const el = new DocumentFragment();
		App.UI.DOM.appendNewElement("h2", el, "Black Market");
		const rep = 10000;

		App.UI.DOM.appendNewElement(
			"div",
			el,
			(V.rep >= rep)
				? App.UI.DOM.passageLink("Visit the market", "The Black Market")
				: `You lack the ${num(rep)} reputation to be invited to the underground Black Market.`
		);
		return el;
	}

	/**
	 * Creates a new link to purchase a facility.
	 *
	 * @param {string} title
	 * @param {function(void):void} handler
	 * @param {number} [cost]
	 * @returns {DocumentFragment}
	 */
	function makeLink(title, handler, cost = 5000) {
		const el = new DocumentFragment();
		cost = Math.trunc(cost * V.upgradeMultiplierArcology);
		el.append(makePurchase(title, cost, "capEx", {
			handler: () => {
				handler();

				V.PC.skill.engineering += .1;
				jQuery(container).empty().append(createPage());
			}
		}));

		return el;
	}
};


code:
/** @type {FC.FacilityFramework} */
App.Data.Facilities.penthouse = {
	baseName: "penthouse",
	genericName: "Penthouse",
	jobs: {
		rest: {
			position: "Rest",
			assignment: Job.REST,
			publicSexUse: false,
			fuckdollAccepted: true
		},
		chooseOwn: {
			position: "Choose own",
			assignment: Job.CHOICE,
			publicSexUse: false,
			fuckdollAccepted: false
		},
		fucktoy: {
			position: "Fucktoy",
			assignment: Job.FUCKTOY,
			publicSexUse: false,
			fuckdollAccepted: true
		},
		classes: {
			position: "Classes",
			assignment: Job.CLASSES,
			publicSexUse: false,
			fuckdollAccepted: false
		},
		houseServant: {
			position: "House Servant",
			assignment: Job.HOUSE,
			publicSexUse: false,
			fuckdollAccepted: false
		},
		whore: {
			position: "Whore",
			assignment: Job.WHORE,
			publicSexUse: true,
			fuckdollAccepted: false
		},
		publicServant: {
			position: "Public Servant",
			assignment: Job.PUBLIC,
			publicSexUse: true,
			fuckdollAccepted: false
		},
		subordinateSlave: {
			position: "Subordinate slave",
			assignment: Job.SUBORDINATE,
			publicSexUse: false,
			fuckdollAccepted: false
		},
		cow: {
			position: "Milked",
			assignment: Job.MILKED,
			publicSexUse: false,
			fuckdollAccepted: false
		},
		gloryhole: {
			position: "Gloryhole",
			assignment: Job.GLORYHOLE,
			publicSexUse: false,
			fuckdollAccepted: true
		},
		confinement: {
			position: "Confinement",
			assignment: Job.CONFINEMENT,
			publicSexUse: false,
			fuckdollAccepted: true
		}
	},
	defaultJob: "rest",
	manager: {
		position: "Recruiter",
		assignment: Job.RECRUITER,
		careers: App.Data.Careers.Leader.recruiter,
		skill: "recruiter",
		publicSexUse: false,
		fuckdollAccepted: false,
		broodmotherAccepted: false,
		shouldWalk: true,
		shouldHold: false,
		shouldSee: true,
		shouldHear: true,
		shouldTalk: true,
		shouldThink: true,
		requiredDevotion: 51
	},
	decorated: false
};

App.Entity.Facilities.PenthouseJobs = {
	Classes: class extends App.Entity.Facilities.Job {
		checkRequirements(slave) {
			let r = super.checkRequirements(slave);
			if (slave.intelligenceImplant >= 15) {
				r.push(`${slave.slaveName} already has a basic education.`);
			}
			if (!App.Entity.Facilities.Job._isBrokenEnough(slave, -20, -50, -20, -51)) {
				r.push(`${slave.slaveName} is too resistant to learn.`);
			}

			if (slave.fetish === "mindbroken") {
				r.push(`${slave.slaveName}'s mind is fundamentally broken and can't learn.`);
			}
			return r;
		}
	},
	HouseServant: class extends App.Entity.Facilities.Job {
		checkRequirements(slave) {
			let r = super.checkRequirements(slave);

			if (!App.Entity.Facilities.Job._isBrokenEnough(slave, -20, -50, -19, -51)) {
				r.push(App.Entity.Facilities.Job._stdBreakageMessage(slave));
			}

			if (!canWalk(slave)) {
				r.push(`${slave.slaveName} can't walk and would be unable to properly clean.`);
			} else if (!canHold(slave)) {
				r.push(`${slave.slaveName} has no hands and would be unable to properly clean.`);
			}
			if (!canSee(slave)) {
				r.push(`${slave.slaveName} is blind and would be unable to properly clean.`);
			}

			return r;
		}
	},

	SubordinateSlave: class extends App.Entity.Facilities.Job {
		checkRequirements(slave) {
			let r = super.checkRequirements(slave);
			if (!App.Entity.Facilities.Job._isBrokenEnough(slave, -20, -50, -19, -51)) {
				r.push(App.Entity.Facilities.Job._stdBreakageMessage(slave));
			}
			return r;
		}

		assignmentLinkElement(ID, passage, callback, linkText) {
			linkText = linkText || this.desc.position;
			return App.UI.DOM.assignmentLink(slaveStateById(ID), this.desc.assignment, "Subordinate Targeting",
				(slave, assignment) => {
					if (callback) {
						callback(slave, assignment);
					}
					V.AS = ID;
					V.returnTo = passage;
				}, linkText);
		}
	},
	Cow: class extends App.Entity.Facilities.Job {
		checkRequirements(slave) {
			let r = super.checkRequirements(slave);
			if ((slave.lactation <= 0) && (slave.balls <= 0)) {
				r.push(`${slave.slaveName} is not lactating` + ((V.seeDicks > 0) ? ' or producing semen.' : '.'));
			}
			return r;
		}
	},
};

App.Entity.Facilities.Penthouse = class extends App.Entity.Facilities.Facility {
	constructor() {
		super(App.Data.Facilities.penthouse, {
			classes: new App.Entity.Facilities.PenthouseJobs.Classes(),
			houseServant: new App.Entity.Facilities.PenthouseJobs.HouseServant(),
			subordinateSlave: new App.Entity.Facilities.PenthouseJobs.SubordinateSlave(),
			cow: new App.Entity.Facilities.PenthouseJobs.Cow(),
		});
	}

	/** Facility slave capacity
	 * Note that slaves in a relationship may share luxury rooms, so actual capacity is slightly larger (@see penthouseCensus)
	 * @override
	 * @returns {number} */
	get capacity() {
		return V.dormitory + V.rooms;
	}

	/** Penthouse can be overcrowded, so it always has free space
	 * @override
	 * @returns {boolean} */
	get hasFreeSpace() {
		return true;
	}

	/** Not meaningful */
	occupancyReport() {
		return "";
	}
};

App.Entity.facilities.penthouse = new App.Entity.Facilities.Penthouse();


code:
App.Facilities.Pit.pit = class Pit extends App.Facilities.Facility {
	constructor() {
		const pit = App.Entity.facilities.pit;
		const decommissionHandler = () => {
			V.pit = null;

			App.Arcology.cellUpgrade(V.building, App.Arcology.Cell.Market, "Pit", "Markets");
		};

		super(
			pit,
			decommissionHandler,
		);

		V.nextButton = "Back to Main";
		V.nextLink = "Main";
		V.encyclopedia = "Pit";

		if (V.pit.slavesFighting.length !== 2) {
			V.pit.slavesFighting = [];
			V.pit.fighters = V.pit.fighters !== 4 ? V.pit.fighters : 0;
		}
	}

	/** @returns {string} */
	get intro() {
		const text = [];

		text.push(`${this.facility.nameCaps} ${this.decorations}`);

		if (this.facility.hostedSlaves > 2) {
			text.push(`It has a pool of slaves assigned to fight in the next week's bout.`);
		} else if (this.facility.hostedSlaves > 1) {
			text.push(`It has two slaves assigned to the week's bout.`);
		} else if (this.facility.hostedSlaves > 0) {
			text.push(`It only has one slave assigned to the week's bout.`);
		} else {
			text.push(`It doesn't have any slaves assigned to fight.`);
		}

		return text.join(' ');
	}

	/** @returns {string} */
	get decorations() {
		const chattelReligionist = () => {
			const text = [`is a large, modern arena decorated with frescoes of two fictional slaves reaching the afterlife. On the upper walls near the seatings, the obedient slave blissfully follow ${V.seeDicks < 100 ? `her` : `his`} master through`];
			if (V.arcologies[0].FSRomanRevivalist !== "unset") {
				text.push(`Elysian Fields' gates, Pluto's chthonic arcology, while on the walls of the fighting area, the disobedient one is sentenced to suffer in a hellish-looking old world city named Tartarus.`);
			} else if (V.arcologies[0].FSNeoImperialist !== "unset") {
				text.push(`Heaven's gates, God's celestial arcology, while on the wall of the fighting area, the disobedient one is dragged by demonlike raiders down to Hell.`);
			} else if (V.arcologies[0].FSEgyptianRevivalist !== "unset") {
				text.push(`Aaru's gates, Osiris' celestial arcology, while on the wall of the fighting area, the disobedient one, whose heart is heavier than the feather of Maat, is eaten by Ammit, the devourer of souls.`);
			} else if (V.arcologies[0].FSEdoRevivalist !== "unset") {
				text.push(`Takamagahara's gates, Amaterasu's celestial arcology, while on the wall of the fighting area, the disobedient one is tortured in Jigoku by oni-like raiders.`);
			} else if (V.arcologies[0].FSArabianRevivalist !== "unset") {
				text.push(`Jannah's gates, Allah's celestial arcology, while on the wall of the fighting area, the disobedient one is thrown by two angels into Jahannam for the awaiting ifrit-like raiders.`);
			} else if (V.arcologies[0].FSChineseRevivalist !== "unset") {
				text.push(`Tian's gates, Jade Emperor's arcology, while on the wall of the fighting area, the disobedient one is tortured in Diyu by yaoguai-like raiders.`);
			} else if (V.arcologies[0].FSAztecRevivalist !== "unset") {
				text.push(`Tonatiuhtlán's gates, Tōnatiuh's celestial arcology, to accompany the sun during the morning, while on the wall of the fighting area, the disobedient one is sent to Mictlān to suffer through many challenges.`);
			} else {
				text.push(`Paradise's gates, Allslaver's celestial arcology, while on the wall of the fighting area, the disobedient one is sentenced to survive in the Wasteland of the Freedom Trickster.`);
			}
			return text.join(" ");
		};

		/** @type {FC.Facilities.Decoration} */
		const FS = {
			"Roman Revivalist": `is a circular Roman amphitheater-like structure with a coffered dome built of limestone. Walls are covered with mosaics depicting various idealized gladiatorial fights. At the bottom, the pit is covered with a fine layered of sand.`,
			"Neo-Imperialist": `is a futurist, gothic-styled indoor list field with a retractable ceiling and a modular arena where tournaments are held. While most of them are used for slaves fighting, ${V.arcologies[0].name}'s citizens may enjoy and participate in neo-jousting with highly-powered motorcycles and modern mock battles with heavily-armored knights.`,
			"Aztec Revivalist": `is a large rectangular masonry structure used for both Mesoamerican ballgames and slave fights decorated in the traditional Aztec way, with stacked stone walls painted with bright murals.`,
			"Egyptian Revivalist": `is a a simple sunken pit with a sand floor and sandstone walls. In the seating area, there are papyriform columns supporting the ceiling while the walls are decorated with hieroglyphic and pictorial frescoes.`,
			"Edo Revivalist": `is a lush Japanese garden surrounding a pond filled with large, colorful koi. A red wooden footbridge links the garden with the small island that lies in the middle of the pond, which is where the slaves fight.`,
			"Arabian Revivalist": `is a riad, a symmetrical indoor garden centered around the fighting area. Seating for guests are available under the shade of the flora and the surrounding balconies decorated with complex arabesque.`,
			"Chinese Revivalist": `is decorated like a traditional Chinese courtyard, with a large open area in the center surrounded by low buildings with brick walls and clay tile roofs. A couple of bronze-cast Chinese guardian lions protect the entrance of the structure.`,
			"Chattel Religionist": chattelReligionist(),
			"Degradationist": `is a large, modern arena with huge screens mounted strategically to allow its guests the best possible view of the combatants' rape or dismemberment.`,
			"Repopulationist": `is a large, modern stadium with a large open area in the center for the fighters. The bleachers are connected with adjacent birthing areas furnished with wall screens allowing the mothers to enjoy the fight while increasing ${V.arcologies[0].name}'s population.`,
			"Eugenics": `is a large, modern arena with a large open area in the center for the fighters. The seating area is divided in two to separate the Elite, who own the most comfortable seats with the best views, from the unwashed masses.`,
			"Asset Expansionist": `is a large, modern arena that has been designed to welcome all of your well-stacked citizens and slaves. The front row is designed to accommodate and reward the most hypertrophied ones.`,
			"Transformation Fetishist": `is both a architectural and engineering marvel made with some of the most recently crafted composite materials and filled with cutting-edge technologies designed to record the fighters from every angle.`,
			"Gender Radicalist": `is a large, modern arena that offers the best seats to slave owners, with a designated spot at their feet for their slaves with dicks.`,
			"Gender Fundamentalist": `is a large, modern arena with a clear separation between gender. Front seats are reserved for male citizens while the back seats are left for women and slaves.`,
			"Physical Idealist": `is a large, modern arena  made nearly entirely of marble decorated with imposing statues of muscular athletes that seem to support the structure with ease.`,
			"Supremacist": `is a massive arena decorated to glorified ${V.arcologies[0].FSSupremacistRace} architecture, martial arts and military superiority throughout history.`,
			"Subjugationist": `is a large, modern arena that looks like a zoo enclosure, where ${V.arcologies[0].name}'s citizens can comfortably watch ${V.arcologies[0].FSSubjugationistRace} subhuman rape${V.seeBestiality ? ` and bestiality` : ``}.`,
			"Paternalist": `is a large, modern arena with seating that allows not only your citizens, but also menial and sexual slaves to come and watch the combatants fighting.`,
			"Pastoralist": `is a large, modern arena${V.dairy > 0 ? ` connected with ${V.dairyName} pipelines` : ``}. The fighting area can receive low quality body fluids of various quantities that makes each fight more unique.`,
			"Maturity Preferentialist": `is a large arena with the same architectural style as the arenas built in the first arcologies ever made.`,
			"Youth Preferentialist": `is a large, modern arena that is regularly decorated by the most trending arcologies' fashion designers.`,
			"Body Purist": `is a large arena made entirely out of local wood and stone and constructed with little to no fasteners, bindings or adhesives.`,
			"Slimness Enthusiast": `is a large, modern  arena made of graphene and other lightweight materials, allowing natural light to illuminate every corner of the structure.`,
			"Hedonistic": `is both a large, modern arena and a congregation of restaurants. Its many chefs compete as fiercely as the fighters to offer vast quantities of caloric nourishment for the audience.`,
			"Intellectual Dependency": `is a large, modern arena decorated with simple and cartoonish representation of gladiatorial fights. Phallus-shaped foam bats are given to the easily-bored bimbo slaves while their masters watch the fights in peace.`,
			"Slave Professionalism": `is a large, modern arena decorated with displays of armed and unarmed fighting stances to incite slave owners to train their favorite slaves with combat skills.`,
			"Petite Admiration": `is a small, modern arena that is surprisingly roomy on the inside and decorated with artwork of small, cunning heroes defeating dumb giants.`,
			"Statuesque Glorification": `is a colossal arena that can be seen from any sector of the arcology and looks like a shepherd casting its protective shadow on the herd of smaller buildings.`,
			"standard": `is fairly unremarkable – little more than a fairly large, circular amphitheater set into one corner of ${V.arcologies[0].name}.`,
		};

		const res = FS[V.pit.decoration];

		if (!res) {
			throw new Error(`Unknown V.pit.decoration value of '${V.pit.decoration}' found in decorations().`);
		}

		return res;
	}

	/** @returns {FC.Facilities.Expand} */
	get expand() {
		return {
			desc: `Slaves assigned here will continue with their usual duties and fight during the weekend. There ${this.facility.hostedSlaves === 1 ? `is` : `are`} currently ${numberWithPluralOne(this.facility.hostedSlaves, "slave")} assigned to fight in ${this.facility.name}.`,
			unexpandable: true,
			removeAll: removeAll(),
		};

		function removeAll() {
			const div = document.createElement("div");

			App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(`Cancel all fights`, () => {
				App.Entity.facilities.pit.employees().forEach(slave => removeJob(slave, Job.PIT));

				App.UI.reload();
			}));

			return div;
		}
	}

	/** @returns {FC.Facilities.Rule[]} */
	get rules() {
		const animal = V.active.canine || V.active.hooved || V.active.feline;

		if (!V.pit.slaveFightingAnimal && !V.pit.slaveFightingBodyguard) {	// only display if a fight has not been scheduled
			return [
				{
					property: "audience",
					prereqs: [],
					options: [
						{
							get text() { return `Fights here are strictly private.`; },
							link: `Closed`,
							value: 'none',
						},
						{
							get text() { return `Fights here are free and open to the public.`; },
							link: `Free`,
							value: 'free',
						},
						{
							get text() { return `Admission is charged to the fights here.`; },
							link: `Paid`,
							value: 'paid',
						},
					],
					object: V.pit,
				},
				{
					property: "fighters",
					prereqs: [],
					options: [
						{
							get text() { return `Two fighters will be selected from the pool at random.`; },
							link: `Slaves`,
							value: 0,
						},
						{
							get text() { return `Your bodyguard ${S.Bodyguard.slaveName} will fight a slave selected from the pool at random.`; },
							link: `Bodyguard`,
							value: 1,
							prereqs: [
								!!S.Bodyguard,
							],
						},
						{
							get text() { return `A random slave will fight an animal.`; },
							link: `Animal`,
							value: 2,
							prereqs: [
								!!animal,
							],
							handler: () => {
								if (!V.pit.animal) {
									V.pit.animal = animal;
								}
							},
						},
						{
							get text() {
								return `A random slave will fight another slave${S.Bodyguard && !animal ? ` or your bodyguard` : S.Bodyguard ? `, your bodyguard` : ``}${animal ? ` or an animal` : ``}.`;
							},
							link: `Random`,
							value: 3,
							prereqs: [
								!!S.Bodyguard || !!animal,
							],
						},
						{
							get text() {
								return `${V.pit.slavesFighting.length > 1
									? `${SlaveFullName(getSlave(V.pit.slavesFighting[0]))} will fight ${SlaveFullName(getSlave(V.pit.slavesFighting[1]))} this week.`
									: `Two chosen slaves will fight.`}`;
							},
							link: `Choose slaves`,
							value: 4,
							handler: () => {
								Engine.play("Pit Workaround");

								V.pit.slavesFighting = [];
							},
						},
					],
					object: V.pit,
				},
				{
					property: "animal",
					prereqs: [
						V.pit.fighters === 2 || V.pit.fighters === 3,
						!!animal,
					],
					options: [
						{
							get text() { return `Your slave will fight ${getAnimal(V.active.canine).articleAn} ${V.active.canine}.`; },
							get link() { return capFirstChar(V.active.canine); },
							value: V.active.canine,
							prereqs: [
								!!V.active.canine,
								!["beagle", "French bulldog", "poodle", "Yorkshire terrier"].includes(V.active.canine),
							],
						},
						{
							get text() { return `Your slave will fight ${getAnimal(V.active.hooved).articleAn} ${V.active.hooved}.`; },
							get link() { return capFirstChar(V.active.hooved); },
							value: V.active.hooved,
							prereqs: [
								!!V.active.hooved,
							],
						},
						{
							get text() { return `Your slave will fight ${getAnimal(V.active.feline).articleAn} ${V.active.feline}.`; },
							get link() { return capFirstChar(V.active.feline); },
							value: V.active.feline,
							prereqs: [
								!!V.active.feline,
								getAnimal(V.active.feline)?.species !== "cat",
							],
						},
						{
							get text() { return `Your slave will fight one of your animals at random.`; },
							link: `Random`,
							value: 'random',
							prereqs: [
								(!!V.active.canine && !!V.active.hooved) ||
									(!!V.active.canine && !!V.active.feline) ||
									(!!V.active.hooved && !!V.active.feline),
							],
						},
					],
					object: V.pit,
				},
				{
					property: "lethal",
					prereqs: [],
					options: [
						{
							get text() {
								return V.pit.fighters === 2
									? `The fighter will be armed with a sword and will fight to the death.`
									: `Fighters will be armed with swords, and fights will be to the death.`;
							},
							link: `Lethal`,
							value: true,
						},
						{
							get text() {
								return V.pit.fighters === 2
									? `The slave will be restrained and will try to avoid becoming the animal's plaything.`
									: `Fighters will use their fists and feet, and fights will be to submission.`;
							},
							link: `Nonlethal`,
							value: false,
						},
					],
					object: V.pit,
				},
				{
					property: "virginities",
					prereqs: [
						V.pit.fighters !== 2,
						!V.pit.lethal,
					],
					options: [
						{
							get text() { return `No virginities of the loser will be respected.`; },
							link: `Neither`,
							value: 'neither',
						},
						{
							get text() { return `Vaginal virginity of the loser will be respected.`; },
							link: `Vaginal`,
							value: 'vaginal',
						},
						{
							get text() { return `Anal virginity of the loser will be respected.`; },
							link: `Anal`,
							value: 'anal',
						},
						{
							get text() { return `All virginities of the loser will be respected.`; },
							link: `All`,
							value: 'all',
						},
					],
					object: V.pit,
				},
			];
		}

		return [];
	}

	/** @returns {HTMLDivElement} */
	get slaves() {
		const div = document.createElement("div");

		div.append(App.UI.SlaveList.listSJFacilitySlaves(App.Entity.facilities.pit, passage(), false,
			{assign: "Schedule a slave to fight", remove: "Cancel a slave's fight", transfer: null}));

		return div;
	}

	/** @returns {HTMLDivElement} */
	get scheduled() {
		const div = document.createElement("div");

		if (V.pit.slaveFightingAnimal || V.pit.slaveFightingBodyguard) {
			const animal = V.pit.slaveFightingAnimal;
			const bodyguard = V.pit.slaveFightingBodyguard;

			div.append(`You have scheduled ${getSlave(animal || bodyguard).slaveName} to fight ${V.pit.slaveFightingAnimal ? `an animal` : `your bodyguard`} to the death this week.`);

			App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(`Cancel it`, () => {
				V.pit.slaveFightingAnimal = null;
				V.pit.slaveFightingBodyguard = null;

				App.UI.reload();
			}), ['indent']);
		}

		return div;
	}

	/** @returns {HTMLDivElement[]} */
	get customNodes() {
		return [
			this.scheduled,
		];
	}
};


code:
/** @type {FC.FacilityFramework} */
App.Data.Facilities.pit = {
	baseName: "pit",
	genericName: null,
	jobs: {
		fighter: {
			position: "fighter",
			assignment: Job.PIT, /* pseudo-assignment for assignmentTransition/assignJob/removeJob */
			publicSexUse: false,
			fuckdollAccepted: false,
			partTime: true
		}
	},
	defaultJob: "fighter",
	manager: null,
	decorated: true,
};

App.Entity.Facilities.PitFighterJob = class extends App.Entity.Facilities.FacilitySingleJob {
	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {string[]}
	 */
	checkRequirements(slave) {
		let r = super.checkRequirements(slave);
		if (slave.breedingMark === 1 && V.propOutcome === 1 && V.eugenicsFullControl !== 1 && V.arcologies[0].FSRestart !== "unset") {
			r.push(`${slave.slaveName} may not participate in combat.`);
		}
		if (slave.indentureRestrictions > 1) {
			r.push(`${slave.slaveName}'s indenture forbids fighting.`);
		}
		if ((slave.indentureRestrictions > 0) && (this.facility.option("lethal"))) {
			r.push(`${slave.slaveName}'s indenture forbids lethal fights.`);
		}
		return r;
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {string[]}
	 */
	canEmploy(slave) {
		if (this.isEmployed(slave)) {
			return [`${slave.slaveName} is already assigned to fight in ${this.facility.name}.`];
		}
		if (!this._facilityHasFreeSpace) {
			return [`Capacity of ${this.facility.name} exceeded.`];
		}

		return this.checkRequirements(slave);
	}
};

App.Entity.Facilities.Pit = class extends App.Entity.Facilities.SingleJobFacility {
	constructor() {
		super(App.Data.Facilities.pit,
			{
				fighter: new App.Entity.Facilities.PitFighterJob()
			});
	}

	get capacity() {
		return V.pit ? Number.MAX_VALUE : null;
	}

	/** @override */
	occupancyReport(long) {
		return `${this.hostedSlaves}${long ? ` ${this.job().desc.position}s` : ""}`;
	}
};

App.Entity.facilities.pit = new App.Entity.Facilities.Pit();


code:
App.Facilities.Pit.init = function() {
	/** @type {FC.Facilities.Pit} */
	V.pit = {
		name: "the Pit",

		animal: null,
		audience: "free",
		bodyguardFights: false,
		decoration: "standard",
		fighters: 0,
		fighterIDs: [],
		fought: false,
		lethal: false,
		slaveFightingAnimal: null,
		slaveFightingBodyguard: null,
		slavesFighting: [],
		virginities: "neither",
	};
};


code:
App.Facilities.Pit.workaround = function() {
	const frag = new DocumentFragment();

	const slaveOne = getSlave(V.pit.slavesFighting[0]);
	const slaveTwo = getSlave(V.pit.slavesFighting[1]);

	frag.append(
		App.UI.DOM.makeElement("h1", `Slaves Fighting`),
		App.UI.DOM.makeElement("div", V.pit.slavesFighting.length > 1
			? `${slaveOne.slaveName} is fighting ${slaveTwo.slaveName} this week.`
			: `Choose two slaves to fight.`),
		App.UI.DOM.makeElement("h2", `Choose slaves`, ['margin-top']),
	);

	for (const slave of V.pit.fighterIDs) {
		if (V.pit.slavesFighting.includes(slave)) {
			App.UI.DOM.appendNewElement("div", frag, SlaveFullName(getSlave(slave)), ['indent']);
		} else {
			App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.link(SlaveFullName(getSlave(slave)), () => {
				if (V.pit.slavesFighting.length > 1) {
					V.pit.slavesFighting.shift();
				}

				V.pit.slavesFighting.push(slave);

				App.UI.reload();
			}), ['indent']);
		}
	}

	return frag;
};