code:
/**
 * @param {App.Entity.SlaveState} mother
 * @param {boolean} cheat
 * @returns {DocumentFragment}
 */
globalThis.analyzePregnancies = function(mother, cheat) {
	const el = new DocumentFragment();
	for (let i = 0; i < mother.womb.length; i++) {
		el.append(scanFetus(i));
		App.UI.DOM.appendNewElement("hr", el);
	}
	return el;

	function scanFetus(i) {
		const el = new DocumentFragment();
		const fetus = mother.womb[i];
		const genes = fetus.genetics;
		let option;
		const options = new App.UI.OptionsGroup();
		if (fetus.age >= 2 || cheat) {
			option = options.addOption(`Ova: ${genes.name}`, "name", genes);
			if (cheat) {
				option.showTextBox();
			}
			option = options.addOption(`Age: ${Math.trunc(fetus.age * 1000) / 1000}`, "age", fetus);
			if (cheat) {
				option.showTextBox();
			}
			if (V.geneticMappingUpgrade >= 1 || cheat) {
				option = options.addOption(`Gender: ${genes.gender}`, "gender", genes);
				if (cheat) {
					option.addValue("Female", "XX");
					option.addValue("Male", "XY");
				}
				option = options.addOption(`Father name: ${(genes.fatherName) ? genes.fatherName : `name not registered`}; ID: ${genes.father}`, "father", genes);
				if (cheat) {
					option.showTextBox();
				}
				option = options.addOption(`Mother name: ${(genes.motherName) ? genes.motherName : `name not registered`}; ID: ${genes.mother}`, "mother", genes);
				if (cheat) {
					option.showTextBox();
				}
				option = options.addOption(`Nationality: ${genes.nationality}`, "nationality", genes);
				if (cheat) {
					option.showTextBox();
				}
				if (V.seeRace === 1) {
					option = options.addOption(`Race: ${capFirstChar(genes.race)}`, "race", genes);
					if (cheat) {
						option.showTextBox().pulldown().addValueList(Array.from(App.Data.misc.filterRaces, (k => [k[1], k[0]])));
					}
				}
				option = options.addOption(`Skin tone: ${capFirstChar(genes.skin)}`, "skin", genes);
				if (cheat) {
					option.showTextBox().pulldown().addValueList(App.Medicine.Modification.naturalSkins);
				}
				option = options.addOption(`Intelligence index: ${genes.intelligence} out of 100`, "intelligence", genes);
				if (cheat) {
					option.showTextBox();
				}
				option = options.addOption(`Face index: ${genes.face} out of 100`, "face", genes);
				if (cheat) {
					option.showTextBox();
				}
				option = options.addOption(`Eye Color: ${capFirstChar(genes.eyeColor)}`, "eyeColor", genes);
				if (cheat) {
					option.showTextBox().pulldown();
					for (const color of App.Medicine.Modification.eyeColor.map(color => color.value)) {
						option.addValue(capFirstChar(color), color);
					}
				}
				option = options.addOption(`Hair Color: ${capFirstChar(genes.hColor)}`, "hColor", genes);
				if (cheat) {
					option.showTextBox().pulldown();
					for (const color of App.Medicine.Modification.Color.Primary.map(color => color.value)) {
						option.addValue(capFirstChar(color), color);
					}
				}
				option = options.addOption(`Pubic hair: ${capFirstChar(genes.pubicHStyle)}`, "pubicHStyle", genes);
				if (cheat) {
					option.showTextBox().pulldown()
						.addValue("hairless")
						.addValue("bushy");
				}
				option = options.addOption(`Armpit hair: ${capFirstChar(genes.underArmHStyle)}`, "underArmHStyle", genes);
				if (cheat) {
					option.showTextBox().pulldown()
						.addValue("hairless")
						.addValue("bushy");
				}
				if (genes.markings === "freckles" || genes.markings === "heavily freckled") {
					option = options.addOption(`Markings: ${capFirstChar(genes.markings)}`, "markings", genes);
					if (cheat) {
						option.addValueList([
							["None", "none"],
							["Freckles", "freckles"],
							["Heavily freckled", "heavily freckled"],
							["Beauty mark", "beauty mark"],
							["Birthmark", "birthmark"],
						]);
					}
				}
				if (cheat) {
					const geneQuirks = App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
						"Show Genetic Quirks",
						() => jQuery(geneQuirks).empty().append(App.UI.SlaveInteract.geneticQuirks(genes, true))
					));
				} else {
					el.append(fetusAbnormalities());
				}
			} else {
				if (fetus.age > 13) {
					App.UI.DOM.appendNewElement("div", el, `Gender: ${genes.gender}`);
				}
				if (fetus.age > 5) {
					App.UI.DOM.appendNewElement("div", el, `Father ID: ${genes.father}`);
					App.UI.DOM.appendNewElement("div", el, `Father Name: ${genes.fatherName}`);
					App.UI.DOM.appendNewElement("div", el, `Mother ID: ${genes.mother}`);
					App.UI.DOM.appendNewElement("div", el, `Mother Name: ${genes.motherName}`);
				}
			}
			if (V.incubator.capacity > 0 || V.nursery > 0) {
				App.UI.DOM.appendNewElement("div", el, `Reserved: ${fetus.reserve}`);
			}

			if (fetus.age < 4 && (V.arcologies[0].FSRestart === "unset" || V.eugenicsFullControl === 1 || mother.breedingMark === 0 || V.propOutcome === 0 || (fetus.fatherID !== -1 && fetus.fatherID !== -6)) || cheat) {
				option = terminateOvum();
				if (V.surgeryUpgrade === 1) {
					option.addButton(
						"Transplant ovum",
						() => {
							V.donatrix = mother;
							V.wombIndex = i;
							V.nextLink = passage();
						},
						"Ova Transplant Workaround"
					);
				}
			}
			if (V.incubator.capacity > 0) {
				if (fetus.reserve === "incubator") {
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
						`Don't keep this child in ${V.incubator.name}`,
						() => {
							fetus.reserve = "";
						},
						[],
						passage()
					));
				} else if ((V.incubator.capacity - V.incubator.tanks.length) - FetusGlobalReserveCount("incubator") > 0) {
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
						`Keep this child in ${V.incubator.name}`,
						() => {
							fetus.reserve = "incubator";
						},
						[],
						passage()
					));
				} else {
					App.UI.DOM.appendNewElement("div", el, `There is not enough free space to keep this child in ${V.incubator.name}.`);
				}
			}
			if (V.nursery > 0) {
				if (fetus.reserve === "nursery") {
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
						`Don't keep this child in ${V.nurseryName}`,
						() => {
							fetus.reserve = "";
						},
						[],
						passage()
					));
				} else if ((V.nursery - V.cribs.length) - FetusGlobalReserveCount("nursery") > 0) {
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.link(
						`Keep this child in ${V.nurseryName}`,
						() => {
							fetus.reserve = "nursery";
						},
						[],
						passage()
					));
				} else {
					App.UI.DOM.appendNewElement("div", el, `There is not enough free space to keep this child in ${V.nurseryName}.`);
				}
			}
		} else {
			App.UI.DOM.appendNewElement("div", el, `Unidentified ova found, no detailed data available.`);
			App.UI.DOM.appendNewElement("div", el, `Age: too early for scan.`);
			option = terminateOvum();

			if (V.surgeryUpgrade === 1) {
				option.addButton(
					`Transplant ovum`,
					() => {
						V.donatrix = mother;
						V.wombIndex = i;
						V.nextLink = "Analyze Pregnancy";
					},
					`Ova Transplant Workaround`
				);
			}
		}
		el.append(options.render());
		return el;

		function fetusAbnormalities() {
			const div = App.UI.DOM.makeElement("div", null);

			const abnormalitySpans = [];
			for (const gene in genes.geneticQuirks) {
				const geneObj = App.Data.geneticQuirks.get(gene);
				const quirkName = (geneObj && geneObj.abbreviation) ? geneObj.abbreviation : gene;
				const quirkColor = (geneObj && geneObj.goodTrait) ? "green" : "red";
				if (genes.geneticQuirks[gene] >= 2 || typeof genes.geneticQuirks[gene] === "string") { // String check is for heterochromia
					abnormalitySpans.push(App.UI.DOM.makeElement("span", quirkName, quirkColor));
				} else if (genes.geneticQuirks[gene] === 1 && V.geneticMappingUpgrade >= 2) {
					abnormalitySpans.push(App.UI.DOM.makeElement("span", quirkName, "yellow"));
				}
			}
			if (abnormalitySpans.length > 0) {
				div.append("Detected abnormalities: ");
				App.Events.addNode(div, abnormalitySpans);
			}
			return div;
		}

		function terminateOvum() {
			return options.addCustomOption(`Surgical options`)
				.addButton(
					`Terminate ovum`,
					() => {
						WombRemoveFetus(mother, i);
						if (mother.preg === 0) {
							mother.pregWeek = -1;
						}
					},
					passage()
				);
		}
	}
};

App.UI.analyzePregnancy = function() {
	const node = new DocumentFragment();
	if (lastVisited("Incubator") === 1) {
		V.storedLink = "Incubator";
	} else if (lastVisited("Slave Interact") === 1) {
		V.storedLink = "Slave Interact";
	}
	V.nextLink = V.storedLink;
	const slave = getSlave(V.AS);

	const WL = slave.womb.length;
	const incubatorReservations = WombReserveCount(slave, "incubator");
	const nurseryReservations = WombReserveCount(slave, "nursery");
	const freeTanks = V.incubator.capacity - V.incubator.tanks.length;
	const freeCribs = V.nursery - V.cribs.length;
	const reservedChildren = FetusGlobalReserveCount("incubator");
	let linkArray = [];

	const {
		His, He,
		his
	} = getPronouns(slave);

	App.UI.DOM.appendNewElement("p", node, `${slave.slaveName} is ${(slave.devotion < 20) ? `restrained` : `comfortably reclined`} with ${his} stomach prepped for examination. ${He} shudders slightly at the cold touch of the sensor against ${his} skin.`, "scene-intro");

	App.Events.addParagraph(node, [App.Desc.pregnancy(slave)]);

	App.UI.DOM.appendNewElement("h2", node, "Overall statistics");
	let p = App.UI.DOM.appendNewElement("p", node);
	const cc = Math.round(slave.bellyPreg);
	const safeCC = Math.round(slave.pregAdaptation * 2000);
	if (V.geneticMappingUpgrade > 0) {
		App.UI.DOM.appendNewElement("div", p, `Estimated physical degree of pregnancy adaptation: ${num(Math.round(slave.pregAdaptation))}`);
		App.UI.DOM.appendNewElement("div", p, `Estimated safe ${(slave.ovaries === 1 || slave.mpreg === 1) ? `womb` : `abdominal`} volume: ${num(safeCC)}cc`);
	}
	App.UI.DOM.appendNewElement("div", p, `Current fetal count: ${slave.womb.length}`);
	App.Events.addNode(p, [
		`Estimated ${(slave.ovaries === 1 || slave.mpreg === 1) ? `womb` : `abdominal`} volume: ${(safeCC < cc && V.geneticMappingUpgrade > 0) ? `${num(cc)}` : num(cc)}cc`
	], "div");

	if (slave.womb.length > 0) {
		App.UI.DOM.appendNewElement("h2", node, "Furthest developed pregnancy");
		App.UI.DOM.appendNewElement("p", node, `Fetal development week: ${Math.trunc(slave.preg * 1000) / 1000}`);

		p = App.UI.DOM.appendNewElement("p", node);
		if (V.incubator.capacity > 0 || V.nursery > 0) {
			let div = App.UI.DOM.appendNewElement("div", p);
			if (V.incubator.capacity > 0) {
				if (incubatorReservations > 0) {
					linkArray.push(App.UI.DOM.link(
						`Remove all of ${his} children from ${V.incubator.name}`,
						() => WombChangeReserveType(slave, "incubator", ""),
						[],
						"Analyze Pregnancy"
					));
				}
				if (incubatorReservations < WL && (reservedChildren + WL - incubatorReservations <= freeTanks)) {
					linkArray.push(App.UI.DOM.link(
						`Keep all of ${his} children in ${V.incubator.name}`,
						() => {
							WombChangeReserveType(slave, "nursery", "incubator");
							WombChangeReserveType(slave, "", "incubator");
						},
						[],
						"Analyze Pregnancy"
					));
				} else if (incubatorReservations < WL) {
					App.UI.DOM.appendNewElement("span", div, `There is not enough free space in ${V.incubator.name} for the rest of ${his} children.`);
				}
				div.append(App.UI.DOM.generateLinksStrip(linkArray));
			}

			linkArray = [];
			div = App.UI.DOM.appendNewElement("div", p);
			if (V.nursery > 0) {
				if (nurseryReservations > 0) {
					linkArray.push(App.UI.DOM.link(
						`Remove all of ${his} children from ${V.nurseryName}`,
						() => WombChangeReserveType(slave, "nursery", ""),
						[],
						"Analyze Pregnancy"
					));
				}
				if (nurseryReservations < WL && (FetusGlobalReserveCount("nursery") + WL - nurseryReservations <= freeCribs)) {
					linkArray.push(App.UI.DOM.link(
						`Keep all of ${his} children in ${V.incubator.name}`,
						() => {
							WombChangeReserveType(slave, "incubator", "nursery");
							WombChangeReserveType(slave, "", "nursery");
						},
						[],
						"Analyze Pregnancy"
					));
				} else if (nurseryReservations < WL) {
					App.UI.DOM.appendNewElement("span", div, `There is not enough free space in ${V.nurseryName} for the rest of ${his} children.`);
				}
				div.append(App.UI.DOM.generateLinksStrip(linkArray));
			}
		}
		App.UI.DOM.appendNewElement("h2", node, "Deep scan");
		App.UI.DOM.appendNewElement("p", node, analyzePregnancies(slave, false));
	} else if (slave.preg === -3) { // special states
		App.UI.DOM.appendNewElement("div", node, `Failure to locate any ova. Subject is infertile.`);
	} else if (slave.pregWeek < 0) { // special states
		App.UI.DOM.appendNewElement("div", node, `Subject is in the postpartum period.`);
	} else if (slave.ovaryAge >= 47) {
		App.UI.DOM.appendNewElement("div", node, `${His} infertility is due to menopausal ovaries.`);
	} else if (slave.ovaries === 0 && slave.mpreg === 0 && slave.vagina > -1) {
		App.UI.DOM.appendNewElement("div", node, `${His} infertility is due to missing ovaries.`);
	} else if (slave.preg === -2) { // special states
		App.UI.DOM.appendNewElement("div", node, `${His} infertility is due to sterilization; ${his} ovaries could still work.`);
	} else if (slave.preg === -1) { // special states
		App.UI.DOM.appendNewElement("div", node, `Contraceptive agents detected in subject.`);
	}

	return node;
};


code:
/**
 * @param {App.Entity.SlaveState|FC.FetusGenetics} slave
 * @param {boolean} fetus
 * @returns {DocumentFragment}
 */
App.UI.SlaveInteract.geneticQuirks = function(slave, fetus) {
	const el = new DocumentFragment();
	const options = new App.UI.OptionsGroup();
	for (const [key, obj] of App.Data.geneticQuirks) {
		if (obj.hasOwnProperty("requirements") && !obj.requirements) {
			continue;
		}
		const option = options.addOption(capFirstChar(obj.title), key, slave.geneticQuirks)
			.addComment(capFirstChar(obj.description))
			.addValue("off", 0).off()
			.addValue("carrier", 1);
		if (key === "heterochromia") {
			option.pulldown();
			for (const color of App.Medicine.Modification.eyeColor.map(color => color.value)) {
				option.addValue(capFirstChar(color), color);
			}
		} else {
			if (fetus) {
				option.addValue("active", obj.pubertyActivated ? 3 : 2).on();
			} else {
				option.addValue("active", 2).on();
				if (obj.pubertyActivated) {
					option.addValue("inactive", 3);
					option.comment += `. "inactive" is for dominant genes that are not yet taking effect (age, hormones, etc)`;
				}
			}
			if (key === "albinism" && "albinismOverride" in slave) {
				option.addCallbackToEach((val) => induceAlbinism(slave, val));
			}
		}
	}
	el.append(options.render());
	return el;
};

repo_name: Pecanus/fc

license: mit


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @returns {DocumentFragment}
 */
App.UI.SlaveInteract.geneticMods = function(slave) {
	const el = new DocumentFragment();
	const options = new App.UI.OptionsGroup();
	for (const [key, obj] of App.Data.geneticMods) {
		if (obj.hasOwnProperty("requirements") && !obj.requirements) {
			continue;
		}
		options.addOption(capFirstChar(obj.title), key, slave.geneMods)
			.addComment(capFirstChar(obj.description))
			.addValue("off", 0).off()
			.addValue("on", 1).on();
	}
	el.append(options.render());
	return el;
};


code:
App.UI.multipleOrganImplant = function() {
	const node = new DocumentFragment();

	node.append(intro());

	App.UI.DOM.appendNewElement("h1", node, "Implant Prosthetics");

	/* prosthetics */
	for (const slave of V.slaves) {
		/* count for estimating health impact */
		const prostheticCount = V.adjustProsthetics.filter(p => p.slaveID === slave.ID && p.workLeft <= 0).length;

		/* since we already have count, skip slaves that don't need work */
		if (prostheticCount < 1) {
			continue;
		}
		/*
		Ensures that a slave can never die during the execution of this passage.
		Calculation based on worst case, so when changing worst case change it here too.
		*/
		if (slave.health.health - (prostheticCount * 20) < -75) {
			App.UI.DOM.appendNewElement("hr", node);
			App.UI.DOM.appendNewElement("div", node, `Estimated health impact too great; ${slave.slaveName} skipped.`, ["health", "dec"]);
			continue;
		}

		const {
			he,
		} = getPronouns(slave);

		for (let k = 0; k < V.adjustProsthetics.length; k++) {
			const p = V.adjustProsthetics[k];
			if (p.slaveID === slave.ID && p.workLeft <= 0) {
				V.adjustProsthetics.splice(k, 1);
				k--;
				V.adjustProstheticsCompleted--;
				addProsthetic(slave, p.id);
				const div = App.UI.DOM.appendNewElement("div", node, document.createElement("hr"));
				switch (p.id) {
					case "ocular":
						if (getBestVision(slave) === 0) {
							eyeSurgery(slave, "both", "cybernetic");
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 20);
							V.surgeryType = "ocular implant";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						} else {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} has working eyes the ${App.Data.prosthetics.ocular.name} will be put into storage.`, "note");
						}
						break;
					case "cochlear":
						if (slave.hears !== 0) {
							slave.earImplant = 1;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 20);
							V.surgeryType = "cochlear implant";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						} else {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} has working ears the ${App.Data.prosthetics.cochlear.name} will be put into storage.`, "note");
						}
						break;
					case "electrolarynx":
						if (slave.voice <= 0) {
							slave.electrolarynx = 1;
							slave.voice = 2;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 20);
							V.surgeryType = "electrolarynx";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						} else {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} has a voice the ${App.Data.prosthetics.electrolarynx.name} will be put into storage.`, "note");
						}
						break;
					case "interfaceP1":
						if (hasAnyNaturalLimbs(slave)) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} has at least one healthy limb the ${App.Data.prosthetics.interfaceP1.name} will be put into storage.`, "note");
						} else if (slave.PLimb === 2) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} already has ${addA(App.Data.prosthetics.interfaceP2.name)} installed the ${App.Data.prosthetics.interfaceP1.name} will be put into storage.`, "note");
						} else {
							slave.PLimb = 1;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 20);
							V.surgeryType = "PLimb interface1";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						}
						break;
					case "interfaceP2":
						if (hasAllNaturalLimbs(slave)) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} has no amputated limbs the ${App.Data.prosthetics.interfaceP2.name} will be put into storage.`, "note");
						} else if (slave.PLimb === 1) {
							slave.PLimb = 2;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 5);
							V.surgeryType = "PLimb interface3";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						} else {
							slave.PLimb = 2;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 20);
							V.surgeryType = "PLimb interface2";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						}
						break;
					case "interfaceP3":
						if (hasAnyLimbs(slave)) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} still has limbs attached, the ${App.Data.prosthetics.interfaceP3.name} will be put into storage.`, "note");
						} else if (slave.PLimb === 1 || slave.PLimb === 2) {
							slave.PLimb = 3;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 5);
							V.surgeryType = "PLimb interface4";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						} else {
							slave.PLimb = 3;
							cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
							surgeryDamage(slave, 20);
							V.surgeryType = "PLimb interface5";
							node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						}
						break;
					case "basicL":
					case "sexL":
					case "beautyL":
					case "combatL":
					case "felidaeL":
					case "canidaeL":
					case "felidaeCL":
					case "canidaeCL":
					case "cyberneticL":
						if (slave.fuckdoll !== 0) {
							App.UI.DOM.appendNewElement("span", div, `Since a Fuckdoll can't use prosthetic limbs the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else if (hasAllNaturalLimbs(slave)) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} needs an amputated limb to attach prosthetics the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else if (slave.PLimb === 0) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} must have a prosthetic interface installed to attach prosthetic limbs the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else {
							if (p.id === "basicL" && slave.PLimb < 3) {
								const state = App.Medicine.Limbs.currentLimbs(slave);
								const change = upgradeLimbs(slave, 2);
								if (change) {
									node.append(App.Medicine.Limbs.reaction(slave, state));
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} already has more advanced prosthetic limbs attached the ${App.Data.prosthetics.basicL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "sexL" && slave.PLimb < 3) {
								const state = App.Medicine.Limbs.currentLimbs(slave);
								const change = upgradeLimbs(slave, 3);
								if (change) {
									node.append(App.Medicine.Limbs.reaction(slave, state));
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} already has advanced prosthetic limbs attached the ${App.Data.prosthetics.sexL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "beautyL" && slave.PLimb < 3) {
								const state = App.Medicine.Limbs.currentLimbs(slave);
								const change = upgradeLimbs(slave, 4);
								if (change) {
									node.append(App.Medicine.Limbs.reaction(slave, state));
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} already has advanced prosthetic limbs attached the ${App.Data.prosthetics.beautyL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "combatL" && slave.PLimb < 3) {
								const state = App.Medicine.Limbs.currentLimbs(slave);
								const change = upgradeLimbs(slave, 5);
								if (change) {
									node.append(App.Medicine.Limbs.reaction(slave, state));
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} already has advanced prosthetic limbs attached the ${App.Data.prosthetics.combatL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "cybernetic") {
								if (slave.PLimb === 2) {
									const state = App.Medicine.Limbs.currentLimbs(slave);
									const change = upgradeLimbs(slave, 6);
									if (change) {
										node.append(App.Medicine.Limbs.reaction(slave, state));
									}
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceP2.name)} installed to attach cybernetic limbs the ${App.Data.prosthetics.cyberneticL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "felidaeL") {
								if (slave.PLimb === 3) {
									const state = App.Medicine.Limbs.currentLimbs(slave);
									const change = upgradeLimbs(slave, 7);
									if (change) {
										node.append(App.Medicine.Limbs.reaction(slave, state));
									}
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceP3.name)} installed to attach quadrupedal limbs, the ${App.Data.prosthetics.felidaeL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "canidaeL") {
								if (slave.PLimb === 3) {
									const state = App.Medicine.Limbs.currentLimbs(slave);
									const change = upgradeLimbs(slave, 8);
									if (change) {
										node.append(App.Medicine.Limbs.reaction(slave, state));
									}
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceP3.name)} installed to attach quadrupedal limbs, the ${App.Data.prosthetics.canidaeL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "felidaeCL") {
								if (slave.PLimb === 3) {
									const state = App.Medicine.Limbs.currentLimbs(slave);
									const change = upgradeLimbs(slave, 9);
									if (change) {
										node.append(App.Medicine.Limbs.reaction(slave, state));
									}
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceP3.name)} installed to attach quadrupedal limbs, the ${App.Data.prosthetics.felidaeCL.name} will be put into storage.`, "note");
								}
							} else if (p.id === "canidaeCL") {
								if (slave.PLimb === 3) {
									const state = App.Medicine.Limbs.currentLimbs(slave);
									const change = upgradeLimbs(slave, 10);
									if (change) {
										node.append(App.Medicine.Limbs.reaction(slave, state));
									}
								} else {
									App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceP3.name)} installed to attach quadrupedal limbs, the ${App.Data.prosthetics.canidaeCL.name} will be put into storage.`, "note");
								}
							}
						}
						break;
					case "interfaceTail":
						slave.PTail = 1;
						slave.tail = "none";
						slave.tailColor = "none";
						cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
						surgeryDamage(slave, 10);
						V.surgeryType = "tailInterface";
						node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						break;
					case "modT":
					case "sexT":
					case "combatT":
					case "combatT2":
						if (slave.PTail === 0) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceTail.name)} installed to attach tails the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else if (slave.tail !== "none") {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} currently has a tail attached the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else if (p.id === "modT") {
							App.UI.DOM.appendNewElement("span", div, `Since installing ${addA(App.Data.prosthetics.modT.name)} is complicated it can't be automated.`, "note");
							/* Reason: there are different designs player can choose from.*/
						} else if (p.id === "combatT") {
							V.prostheticsConfig = "attachTail";
							slave.tail = "combat";
							slave.tailColor = "jet black";
							node.append(App.UI.prostheticsConfigPassage(slave));
						} else if (p.id === "combatT2") {
							V.prostheticsConfig = "attachTail";
							slave.tail = "stinger";
							slave.tailColor = "purple";
							node.append(App.UI.prostheticsConfigPassage(slave));
						} else if (p.id === "sexT") {
							V.prostheticsConfig = "attachTail";
							slave.tail = "sex";
							slave.tailColor = "pink";
							node.append(App.UI.prostheticsConfigPassage(slave));
						}
						break;
					case "interfaceBack":
						slave.PBack = 1;
						slave.appendages = "none";
						slave.appendagesColor = "none";
						cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
						surgeryDamage(slave, 10);
						V.surgeryType = "backInterface";
						node.append(App.UI.SlaveInteract.surgeryDegradation(slave));
						break;
					case "modW":
					case "flightW":
					case "sexA":
					case "combatW":
					case "combatA1":
					case "combatA2":
						if (slave.PBack === 0) {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} must have ${addA(App.Data.prosthetics.interfaceBack.name)} installed to attach dorsal appendages the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else if (slave.appendages !== "none") {
							App.UI.DOM.appendNewElement("span", div, `Since ${he} currently has dorsal appendages attached the ${App.Data.prosthetics[p.id].name} will be put into storage.`, "note");
						} else if (p.id === "modW") {
							App.UI.DOM.appendNewElement("span", div, `Since installing ${addA(App.Data.prosthetics.modT.name)} is complicated it can't be automated.`, "note");
							/* Reason: there are different designs player can choose from.*/
						} else if (p.id === "combatW") {
							V.prostheticsConfig = "attachWings";
							slave.appendages = "falcon";
							node.append(App.UI.prostheticsConfigPassage(slave));
						} else if (p.id === "combatA1") {
							V.prostheticsConfig = "attachAppendages";
							slave.appendages = "arachnid";
							slave.appendagesColor = "jet black";
							node.append(App.UI.prostheticsConfigPassage(slave));
						} else if (p.id === "combatA2") {
							V.prostheticsConfig = "attachAppendages";
							slave.appendages = "kraken";
							slave.appendagesColor = "jet black";
							node.append(App.UI.prostheticsConfigPassage(slave));
						} else if (p.id === "flightW") {
							V.prostheticsConfig = "attachAppendages";
							slave.appendages = "flight";
							slave.appendagesColor = "silver";
							node.append(App.UI.prostheticsConfigPassage(slave));
						} else if (p.id === "sexA") {
							V.prostheticsConfig = "attachAppendages";
							slave.appendages = "sex";
							slave.appendagesColor = "pink";
							node.append(App.UI.prostheticsConfigPassage(slave));
						}
						break;
					default:
						App.UI.DOM.appendNewElement("span", div, `Since there is no automated procedure to implant/attach ${App.Data.prosthetics[p.id].name} it will be put into storage.`, "note");
				}
			}
		}
	}

	/* This needs to be down here to over-ride any Surgery Degradation calls */
	V.nextButton = "Continue";
	V.nextLink = "Main";

	return node;

	function intro() {
		const frag = document.createDocumentFragment();

		// Get the slaves with ready organs/prosthetics to have a count
		const ids = new Set();
		for (const organ of V.completedOrgans) {
			ids.add(organ.ID);
		}
		for (const p of V.adjustProsthetics) {
			if (p.workLeft <= 0) {
				ids.add(p.ID);
			}
		}

		let r = [];
		r.push("You head down to your");
		if (V.surgeryUpgrade === 1) {
			r.push("heavily upgraded and customized");
		}
		r.push(`remote surgery and start having the ${ids.size > 1 ? "slaves" : "slave"} with`);
		if (V.completedOrgans.length > 0 && V.adjustProstheticsCompleted > 0) {
			r.push("organs or prosthetics");
		} else if (V.completedOrgans.length > 1) {
			r.push("organs");
		} else if (V.adjustProstheticsCompleted > 1) {
			r.push("prosthetics");
		}
		r.push("which are ready be sent down.");

		App.UI.DOM.appendNewElement("p", frag, r.join(" "));

		let any = false;
		const applyFrag = new DocumentFragment();

		let F = App.Medicine.OrganFarm;
		for (const slave of V.slaves) {
			let sortedOrgans = F.getSortedOrgans(slave);
			if (sortedOrgans.length === 0) {
				continue;
			}
			any = true;

			App.UI.DOM.appendNewElement("h2", applyFrag, slave.slaveName);

			for (let j = 0; j < sortedOrgans.length; j++) {
				App.UI.DOM.appendNewElement("h3", applyFrag, F.Organs.get(sortedOrgans[j]).name);

				let actions = F.Organs.get(sortedOrgans[j]).implantActions;
				let manual = false;
				let success = false;
				let cancel = false;
				for (let k = 0; k < actions.length; k++) {
					if (!actions[k].autoImplant) {
						if (actions[k].canImplant(slave)) {
							manual = true;
						}
						continue;
					}
					if (!actions[k].canImplant(slave)) {
						let error = actions[k].implantError(slave);
						if (error !== "") {
							App.UI.DOM.appendNewElement("div", applyFrag, error, "warning");
						}
					} else {
						const procedure = App.Medicine.OrganFarm.instantiateProcedure(slave, actions[k]);
						if (slave.health.health - procedure.healthCost < -75) {
							App.UI.DOM.appendNewElement("div", applyFrag, "Estimated health impact too great, skipping further surgeries.", "warning");
							cancel = true;
							break;
						} else {
							applyFrag.append(App.Medicine.OrganFarm.implant(sortedOrgans[j], procedure));
							success = true;
						}
					}
				}
				if (cancel) {
					break;
				}
				if (!success && manual) {
					App.UI.DOM.appendNewElement("div", applyFrag, `Cannot implant ${F.Organs.get(sortedOrgans[j]).name.toLowerCase()} automatically, try implanting manually in the remote surgery.`, "note");
				}
			}
		}
		frag.append(applyFrag);

		// TODO: what is this for?
		// if (any) {
		// 	App.UI.DOM.appendNewElement("h1", frag, "Implant Organs");
		// }
		return frag;
	}
};


code:
/** @param {App.Entity.SlaveState} slave */
App.UI.SlaveInteract.remoteSurgery = function(slave) {
	const el = new DocumentFragment();
	const {His} = getPronouns(slave);
	updateHealth(slave);

	V.surgeryType = 0;
	V.encyclopedia = "The Remote Surgery";
	/* get all prosthetics that are ready for this slave */
	if (V.adjustProstheticsCompleted > 0) {
		V.adjustProsthetics = V.adjustProsthetics.filter(function(p) {
			if (p.workLeft <= 0 && p.slaveID === slave.ID) {
				addProsthetic(slave, p.id);
				V.adjustProstheticsCompleted--;
				return false;
			}
			return true;
		});
	}

	App.UI.DOM.appendNewElement("h1", el, "The Remote Surgery");

	const introP = document.createElement("p");
	introP.classList.add("scene-intro");
	App.Events.addNode(introP, intro());
	el.append(introP);

	if (slave.indentureRestrictions >= 1) {
		App.UI.DOM.appendNewElement("p", el, `${His} indenture forbids elective surgery`, ["yellow", "note"]);
	}

	const tabBar = new App.UI.Tabs.TabBar("RemoteSurgery");
	const f = new DocumentFragment();
	App.Events.drawEventArt(f, slave);
	tabBar.customNode = f;

	tabBar.addTab("Hair and Face", "hairAndFace", App.UI.surgeryPassageHairAndFace(slave, refresh));
	tabBar.addTab("Upper", "upper", App.UI.surgeryPassageUpper(slave, refresh));
	tabBar.addTab("Lower", "lower", App.UI.surgeryPassageLower(slave, refresh));
	tabBar.addTab("Structural", "structural", App.UI.surgeryPassageStructural(slave, refresh));
	tabBar.addTab("Exotic", "exotic", App.UI.surgeryPassageExotic(slave, refresh));
	if (V.seeExtreme) {
		tabBar.addTab("Extreme", "extreme", App.UI.surgeryPassageExtreme(slave, refresh));
	}
	el.append(tabBar.render());

	return el;

	/**
	 * @returns {Array<string|HTMLElement>}
	 */
	function intro() {
		const r = [];
		r.push(`${slave.slaveName} is lying strapped down on the table in your`);
		if (V.surgeryUpgrade === 1) {
			r.push(`heavily upgraded and customized`);
		}
		r.push(`remote surgery. The surgical equipment reads`);
		if (slave.health.health < -20) {
			r.push(App.UI.DOM.makeElement("span", `SLAVE UNHEALTHY, SURGERY NOT RECOMMENDED.`, "red"));
		} else if (slave.health.health <= 20) {
			r.push(App.UI.DOM.makeElement("span", `SLAVE HEALTHY, SURGERY SAFE.`, "yellow"));
		} else {
			r.push(App.UI.DOM.makeElement("span", `SLAVE HEALTHY, SURGERY ENCOURAGED.`, "green"));
		}
		if (V.PC.skill.medicine >= 100) {
			r.push(`The remote surgery mechanisms that allow a surgeon to be brought in by telepresence are inactive, and the autosurgery is ready for your control inputs. Surgery on your slaves is a challenge and a pleasure you wouldn't dream of sharing.`);
		}
		return r;
	}

	function refresh() {
		$(introP).empty();
		App.Events.addNode(introP, intro());
	}
};


code:
/**
 * UI for performing surgery. Refreshes without refreshing the passage.
 * @param {App.Entity.SlaveState} slave
 * @param {()=>void} refreshParent
 * @param {boolean} [cheat=false]
 * @returns {HTMLElement}
 */

App.UI.surgeryPassageExotic = function(slave, refreshParent, cheat = false) {
	const container = document.createElement("span");
	container.append(content());
	return container;

	function content() {
		const frag = new DocumentFragment();
		const {
			His, He,
			his, him
		} = getPronouns(slave);

		frag.append(race());
		if (V.geneticMappingUpgrade >= 1) {
			App.UI.DOM.appendNewElement("h3", frag, `Retro-virus treatments:`);
			frag.append(geneTherapy());
		}
		frag.append(bodySwap());

		return frag;

		function race() {
			const el = new DocumentFragment();
			const linkArray = [];
			App.UI.DOM.appendNewElement("div", el, `${He} is ${slave.race}${(slave.race !== slave.origRace) ? `, but was originally ${slave.origRace}` : ``}. Surgically alter ${him} to look more:`);
			if (slave.indentureRestrictions > 1) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else {
				for (const race of App.Data.misc.filterRaces.keys()) {
					if (slave.race === race) {
						continue;
					}
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Race(slave, race),
						refresh, cheat));
				}
			}

			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function geneTherapy() {
			const el = new DocumentFragment();
			if (slave.indentureRestrictions >= 1) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else if (slave.health.health < 0) {
				App.UI.DOM.appendNewElement("div", el, `${He}'s too unhealthy to undergo gene therapy`, ["choices", "note"]);
			} else {
				const linkArray = [];
				if (V.arcologies[0].childhoodFertilityInducedNCSResearch === 1) {
					if (slave.geneMods.NCS === 0) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RetrogradeVirusInjectionNCS(slave),
							refresh, cheat));
					} else {
						App.UI.DOM.appendNewElement("div", el, `${He} already has Induced NCS`, ["choices", "note"]);
					}
				}

				if (V.RapidCellGrowthFormula === 1) {
					if (slave.geneMods.rapidCellGrowth === 0) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.ElasticityTreatment(slave),
							refresh, cheat));
					} else {
						App.UI.DOM.appendNewElement("div", el, `${He} already has received the plasticity increasing elasticity treatment`, ["choices", "note"]);
					}
				}

				if (V.immortalityFormula === 1) {
					if (slave.geneMods.immortality === 0) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.ImmortalityTreatment(slave),
							refresh, cheat));
					} else {
						App.UI.DOM.appendNewElement("div", el, `${He} already is already immortal`, ["choices", "note"]);
					}
				}
				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			}
			el.append(retroVirus());
			return el;

			function retroVirus() {
				const el = new DocumentFragment();
				const slaveGeneList = App.UI.DOM.appendNewElement("ul", el);
				const select = App.UI.DOM.makeElement("select", null, "choices");
				const canEditGenes = slave.indentureRestrictions === 0 && slave.health.health >= 0;
				select.classList.add("rajs-list");
				const description = App.UI.DOM.appendNewElement("div", el, null);
				for (const gene in slave.geneticQuirks) {
					const geneData = App.Data.geneticQuirks.get(gene);

					// Continue if player settings do not allow them to even see it described
					if (geneData.hasOwnProperty("requirements") && !geneData.requirements) {
						continue;
					}

					if (slave.geneticQuirks[gene] === 2 || (slave.geneticQuirks[gene] === 1 && V.geneticMappingUpgrade >= 2)) {
						const strength = (slave.geneticQuirks[gene] === 1) ? "Carrier for " : "Activated ";
						App.UI.DOM.appendNewElement("li", slaveGeneList, strength)
							.append(App.UI.DOM.makeElement("span", geneData.title, "orange"));
					}

					// Some of these can be described, but not tweaked in certain ways and circumstances
					if (
						(gene === "pFace" && slave.geneticQuirks.pFace !== 2) ||
						(gene === "uFace" && slave.geneticQuirks.uFace !== 2) ||
						(["heterochromia", "girlsOnly"].includes(gene))
					) {
						continue;
					}
					if (canEditGenes) {
						const choice = App.UI.DOM.appendNewElement("option", select, capFirstChar(geneData.title));
						choice.value = gene;
						select.append(choice);
					}
				}
				if (canEditGenes) {
					select.selectedIndex = -1;
					select.onchange = () => {
						// selectedGene = select.options[select.selectedIndex];
						jQuery(description).empty().append(describeGene(select.value));
					};
					el.append(select);
				}

				return el;

				function describeGene(selectedGene) {
					const el = new DocumentFragment();
					const linkArray = [];
					const geneData = App.Data.geneticQuirks.get(selectedGene);
					App.Events.addNode(el, [
						`Selected gene is`,
						App.UI.DOM.makeElement("span", `${geneData.title}:`, "orange"),
						`${geneData.description}.`
					], "div");
					if (["pFace", "uFace"].includes(selectedGene)) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveGene(slave, selectedGene, `Prevent passing of ${geneData.title}s`),
							refresh, cheat));
					} else if (slave.geneticQuirks[selectedGene] === 2) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveGene(slave, selectedGene, `Correct ${geneData.title}`),
							refresh, cheat));
					} else if (slave.geneticQuirks[selectedGene] === 1 && V.geneticMappingUpgrade >= 2) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.AddGene(slave, selectedGene, true),
							refresh, cheat));
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveGene(slave, selectedGene, `${geneData.title} carrier corrective treatment`),
							refresh, cheat));
					} else if (V.geneticFlawLibrary === 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.AddGene(slave, selectedGene),
							refresh, cheat));
					}
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
					return el;
				}
			}
		}

		function bodySwap() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			if (V.bodyswapAnnounced === 1 && slave.indenture < 0) {
				if (slave.bodySwap === 0) {
					r.push(`${He} is in ${his} native body.`);
				} else if (slave.origBodyOwner !== "") {
					r.push(`${He} currently occupies ${slave.origBodyOwner}'s body.`);
				} else {
					r.push(`${He} is no longer in ${his} native body.`);
				}
				if (slave.indenture === -1) {
					linkArray.push(App.UI.DOM.passageLink(
						`Swap ${his} body with another of your stock`,
						"Slave Slave Swap Workaround",
					));
				} else {
					App.UI.DOM.appendNewElement("div", el, `Indentured servants must remain in their own bodies.`, ["choices", "note"]);
				}
			} else if (V.cheatMode === 1) {
				linkArray.push(App.UI.DOM.link(
					`Force enable bodyswapping`,
					() => {
						V.bodyswapAnnounced = 1;
					},
					[],
					"Remote Surgery",
				));
			}
			App.Events.addNode(el, r, "div");
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function refresh() {
			jQuery(container).empty().append(content());
			App.Events.refreshEventArt(slave);
			refreshParent();
		}
	}
};


code:
/**
 * UI for performing surgery. Refreshes without refreshing the passage.
 * @param {App.Entity.SlaveState} slave
 * @param {()=>void} refreshParent
 * @param {boolean} [cheat=false]
 * @returns {HTMLElement}
 */
App.UI.surgeryPassageExtreme = function(slave, refreshParent, cheat = false) {
	const container = document.createElement("span");
	container.append(content());
	return container;

	function content() {
		const frag = new DocumentFragment();
		const {
			His, He,
			his, he
		} = getPronouns(slave);

		if (V.seeExtreme === 1) {
			frag.append(fuckdoll(), chemLobotomy());
		}

		return frag;

		function fuckdoll() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			if (slave.fuckdoll === 0) {
				r.push(`${He} is a normal sex slave, not a living sex toy.`);
				if (slave.indentureRestrictions < 1 && (slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Fuckdoll(slave),
						refresh, cheat));
				}
			} else {
				r.push(`${He} is encased in a Fuckdoll suit.`);
				linkArray.push(App.Medicine.Surgery.makeLink(
					new App.Medicine.Surgery.Procedures.FuckdollExtraction(slave),
					refresh, cheat));
			}
			App.Events.addNode(el, r, "div");
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function chemLobotomy() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			if (slave.fetish !== "mindbroken") {
				r.push(`${He} is mentally competent.`);
			} else if (slave.fetish === "mindbroken") {
				r.push(`${His} mind is gone; ${he} has either been chemically lobotomized, or has lost ${his} mind due to extreme abuse.`);
			}
			if (slave.indentureRestrictions < 1 && (slave.breedingMark !== 1 || V.propOutcome === 0 || V.eugenicsFullControl === 1 || V.arcologies[0].FSRestart === "unset")) {
				if (slave.fetish !== "mindbroken") {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Mindbreak(slave),
						refresh, cheat));
				}
			}
			App.Events.addNode(el, r, "div");
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}
	}

	function refresh() {
		jQuery(container).empty().append(content());
		App.Events.refreshEventArt(slave);
		refreshParent();
	}
};


code:
/**
 * UI for performing surgery. Refreshes without refreshing the passage.
 * @param {App.Entity.SlaveState} slave
 * @param {function():void} refreshParent
 * @param {boolean} [cheat=false]
 * @returns {HTMLElement}
 */

App.UI.surgeryPassageHairAndFace = function(slave, refreshParent, cheat = false) {
	const container = document.createElement("span");
	container.append(content());
	return container;

	function content() {
		const frag = new DocumentFragment();
		const pubertyAge = Math.min(slave.pubertyAgeXX, slave.pubertyAgeXY);
		const {
			His, He,
			his, him
		} = getPronouns(slave);
		const artificiality = faceSurgeryArtificiality();

		App.UI.DOM.appendNewElement("h3", frag, `Hair:`);
		frag.append(
			mainHair(), eyebrows(), armpitHair()
		);

		App.UI.DOM.appendNewElement("h3", frag, `Face:`);
		frag.append(
			faceShape(), eyes(), ears(), topEars(), hearing(), horns(), lips(), teeth(), voice(), chemosensory()
		);

		return frag;

		function mainHair() {
			const el = new DocumentFragment();
			if (slave.bald === 0 && slave.hStyle !== "bald") {
				App.UI.DOM.appendNewElement("div", el, `${He} naturally grows ${slave.origHColor} hair from ${his} head.`);
				if (slave.indentureRestrictions > 1) {
					App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
				} else {
					App.UI.DOM.appendNewElement("div", el,
						App.Medicine.Surgery.makeLink(new App.Medicine.Surgery.Procedures.HairRemoval(slave), refresh, cheat),
						"choices");
				}
			} else {
				App.UI.DOM.appendNewElement("div", el, `${He} is no longer capable of growing hair on ${his} head.`);
			}
			return el;
		}

		function eyebrows() {
			const el = new DocumentFragment();
			if (slave.eyebrowHStyle !== "bald") {
				App.UI.DOM.appendNewElement("div", el, `${He} has ${slave.origHColor} eyebrows.`);
				if (slave.indentureRestrictions > 1) {
					App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
				} else {
					App.UI.DOM.appendNewElement("div", el,
						App.Medicine.Surgery.makeLink(new App.Medicine.Surgery.Procedures.EyebrowRemoval(slave), refresh, cheat),
						"choices");
				}
			} else {
				App.UI.DOM.appendNewElement("div", el, `${He} is no longer capable of growing eyebrow hair.`);
			}
			return el;
		}

		function armpitHair() {
			const el = new DocumentFragment();
			const r = [];
			if ((slave.underArmHStyle !== "bald" && slave.underArmHStyle !== "hairless") || (slave.pubicHStyle !== "bald" && slave.pubicHStyle !== "hairless")) {
				r.push(`${He}`);
				if (slave.physicalAge >= pubertyAge) {
					r.push(`naturally grows`);
				} else if (slave.physicalAge >= pubertyAge - 1) {
					r.push(`is beginning to grow`);
				} else {
					r.push(`will someday grow`);
				}
				r.push(`${slave.origHColor} body hair.`);
				App.Events.addNode(el, r, "div");
				if (slave.indentureRestrictions > 1) {
					App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
				} else {
					App.UI.DOM.appendNewElement("div", el,
						App.Medicine.Surgery.makeLink(new App.Medicine.Surgery.Procedures.BodyHairRemoval(slave), refresh, cheat),
						"indent");
				}
			} else {
				r.push(`${His} ${slave.skin} skin is silky smooth and hair free from ${his} neck to ${his}`);
				if (!hasAnyLegs(slave)) {
					r.push(`hips.`);
				} else {
					r.push(`toes.`);
				}
				App.Events.addNode(el, r, "div");
			}
			return el;
		}

		function faceShape() {
			const el = new DocumentFragment();
			let r = [];
			r.push(`${His} ${slave.faceShape} face is`);
			const faceDiv = App.UI.DOM.appendNewElement("div", el);
			if (slave.face < -95) {
				r.push(`very ugly.`);
			} else if (slave.face < -40) {
				r.push(`ugly.`);
			} else if (slave.face < -10) {
				r.push(`unattractive.`);
			} else if (slave.face <= 10) {
				r.push(`quite average.`);
			} else if (slave.face <= 40) {
				r.push(`attractive.`);
			} else if (slave.face <= 95) {
				r.push(`beautiful.`);
			} else if (slave.face > 95) {
				r.push(`very beautiful.`);
			}

			if (slave.faceImplant === 0) {
				r.push(`It is entirely natural.`);
			} else if (slave.faceImplant > 5) {
				r.push(`It has seen some work.`);
			} else if (slave.faceImplant > 30) {
				r.push(`It has been totally reworked.`);
			}
			App.Events.addNode(faceDiv, r, "div");

			if (slave.indentureRestrictions > 1) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else if (slave.faceImplant > 95) {
				App.UI.DOM.appendNewElement("div", el, `${His} face cannot sustain further cosmetic surgery`, ["choices", "note"]);
			} else {
				const linkArray = [];
				const faceMap = (slave.faceShape === "masculine") ? new Map([["normal", {}], ["androgynous", {}]]) : App.Medicine.Modification.faceShape;

				for (const [key, shape] of faceMap) {
					if (
						(shape.hasOwnProperty("requirements") && !shape.requirements) ||
						slave.faceShape === key || // Can't change to what you are
						slave.faceShape !== "androgynous" && key === "masculine" // Can't go directly to or from masculine, have to go through androgynous
					) {
						continue;
					}
					linkArray.push(App.Medicine.Surgery.makeLink(new App.Medicine.Surgery.Procedures.FaceShape(slave, key), refresh, cheat));
				}
				linkArray.push(App.Medicine.Surgery.makeLink(new App.Medicine.Surgery.Procedures.FaceAttractiveness(slave), refresh, cheat));
				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
				r = [];
				r.push(`Facial surgery can either rework it and improve its attractiveness, or simply make it more attractive. No facial surgery is perfect and each surgery will make it look less natural.`);
				if (V.PC.skill.medicine >= 100 && V.surgeryUpgrade) {
					r.push(`Your surgical skills and the advanced surgical suite will minimize this effect as much as possible.`);
				} else if (V.PC.skill.medicine >= 100) {
					r.push(`Your surgical skills will reduce this effect.`);
				} else if (V.surgeryUpgrade) {
					r.push(`The advanced surgical suite will reduce this effect.`);
				}
				if (slave.faceImplant + artificiality > 95) {
					r.push(App.UI.DOM.makeElement("span", `${(slave.faceImplant !== 0) ? `Further facial` : `Facial`} surgery will create a severe uncanny valley effect.`, "yellow"));
				} else if (slave.faceImplant + artificiality > 60 && slave.faceImplant <= 60) {
					r.push(App.UI.DOM.makeElement("span", `${(slave.faceImplant !== 0) ? `Further facial` : `Facial`}surgery will be extremely obvious.`, "yellow"));
				} else if (slave.faceImplant + artificiality > 30 && slave.faceImplant <= 30) {
					r.push(App.UI.DOM.makeElement("span", `${(slave.faceImplant !== 0) ? `Further facial` : `Facial`} surgery will eliminate a natural appearance.`, "yellow"));
				} else if (slave.faceImplant + artificiality > 5 && slave.faceImplant <= 5) {
					r.push(App.UI.DOM.makeElement("span", `${(slave.faceImplant !== 0) ? `Further facial` : `Facial`} surgery will disturb a perfectly natural appearance.`, "yellow"));
				} else {
					r.push(`A single facial surgery is not projected to significantly impact artificiality.`);
				}
				App.Events.addNode(faceDiv, r, "span", "note");
			}

			if (slave.indentureRestrictions < 2 && slave.faceImplant <= 95) {
				if (slave.ageImplant > 1) {
					App.UI.DOM.appendNewElement("div", el, `${He}'s had a multiple facelifts and other cosmetic procedures in an effort to preserve ${his} youth.`);
				} else if (slave.ageImplant > 0) {
					App.UI.DOM.appendNewElement("div", el, `${He}'s had a face lift and other minor cosmetic procedures to make ${him} look younger.`);
				} else if (slave.physicalAge >= 25 && slave.visualAge >= 25) {
					App.UI.DOM.appendNewElement("div", el, `${He}'s old enough that a face lift and other minor cosmetic procedures could make ${him} look younger.`);
					App.UI.DOM.appendNewElement("div", el,
						App.Medicine.Surgery.makeLink(new App.Medicine.Surgery.Procedures.AgeLift(slave), refresh, cheat),
						"choices");
				}
			}
			return el;
		}

		function eyes() {
			const el = new DocumentFragment();
			let linkArray;
			App.UI.DOM.appendNewElement("div", el, `${He} has ${App.Desc.eyesType(slave)}${(hasAnyEyes(slave)) ? `, they are ${App.Desc.eyesVision(slave)}` : ``}.`);
			/* eye blur and fix */
			if (hasAnyEyes(slave)) {
				/* Blur eyes*/
				if (slave.indentureRestrictions > 1) {
					App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
				} else {
					linkArray = [];
					if (getLeftEyeVision(slave) === 2 && getLeftEyeType(slave) === 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.EyeBlur(slave, "left"),
							refresh, cheat));
					}
					if (getRightEyeVision(slave) === 2 && getRightEyeType(slave) === 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.EyeBlur(slave, "right"),
							refresh, cheat));
					}
					if (linkArray.length === 2) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.EyeBlur(slave, "both"),
							refresh, cheat));
					}
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
				}

				/* Fix eyes */
				linkArray = [];
				if (getLeftEyeVision(slave) === 1 && getLeftEyeType(slave) === 1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.EyeFix(slave, "left"),
						refresh, cheat));
				}
				if (getRightEyeVision(slave) === 1 && getRightEyeType(slave) === 1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.EyeFix(slave, "right"),
						refresh, cheat));
				}
				if (linkArray.length === 2) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.EyeFix(slave, "both"),
						refresh, cheat));
				}
				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			}

			if (V.seeExtreme === 1) {
				if (slave.indentureRestrictions < 1) {
					/* blind */
					linkArray = [];
					if (getLeftEyeVision(slave) > 0 && getLeftEyeType(slave) === 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.Blind(slave, "left"),
							refresh, cheat));
					}
					if (getRightEyeVision(slave) > 0 && getRightEyeType(slave) === 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.Blind(slave, "right"),
							refresh, cheat));
					}
					if (linkArray.length === 2) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.Blind(slave, "both"),
							refresh, cheat));
					}
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");

					/* remove */
					linkArray = [];
					if (hasLeftEye(slave)) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveEyes(slave, "left"),
							refresh, cheat));
					}
					if (hasRightEye(slave)) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveEyes(slave, "right"),
							refresh, cheat));
					}
					if (linkArray.length === 2) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveEyes(slave, "both"),
							refresh, cheat));
					}
					App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
					/* implant */
					if (isProstheticAvailable(slave, "ocular")) {
						linkArray = [];
						if (!hasLeftEye(slave)) {
							linkArray.push(App.Medicine.Surgery.makeLink(
								new App.Medicine.Surgery.Procedures.OcularImplant(slave, "left"),
								refresh, cheat));
						}
						if (!hasRightEye(slave)) {
							linkArray.push(App.Medicine.Surgery.makeLink(
								new App.Medicine.Surgery.Procedures.OcularImplant(slave, "right"),
								refresh, cheat));
						}
						if (linkArray.length === 2) {
							linkArray.push(App.Medicine.Surgery.makeLink(
								new App.Medicine.Surgery.Procedures.OcularImplant(slave, "both"),
								refresh, cheat));
						}
						App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
					}
				}
			}
			return el;
		}

		function ears() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			r.push(`${He} has`);
			if (slave.earShape === "normal") {
				r.push(`normal ears.`);
			} else if (slave.earShape === "damaged") {
				r.push(`damaged ears.`);
				linkArray.push(App.Medicine.Surgery.makeLink(
					new App.Medicine.Surgery.Procedures.EarRestore(slave),
					refresh, cheat));
			} else if (slave.earShape === "pointy") {
				r.push(`small pointy ears.`);
			} else if (slave.earShape === "elven") {
				r.push(`long elf ears.`);
			} else if (slave.earShape === "orcish") {
				r.push(`distinct orcish ears.`);
			} else if (slave.earShape === "cow") {
				r.push(`floppy ${App.Utils.translate("cow")} ears.`);
			} else if (slave.earShape === "sheep") {
				r.push(`cupped sheep ears.`);
			} else if (slave.earShape === "gazelle") {
				r.push(`cupped gazelle ears.`);
			} else if (slave.earShape === "deer") {
				r.push(`cupped deer ears.`);
			} else if (slave.earShape === "bird") {
				r.push(`ordinary ears with small tufts of ${slave.hColor} colored feathers behind them.`);
			} else if (slave.earShape === "dragon") {
				r.push(`elongated draconic ears.`);
			} else if (slave.earShape === "none") {
				r.push(`no ears.`);
			} else {
				r.push(`bugged ears. You done goofed. <span class="note">Report This</span>`);
			}
			App.Events.addNode(el, r, "div");

			if (slave.indentureRestrictions >= 2) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else {
				if (slave.earShape !== "normal" && slave.earShape !== "none") {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.EarRestore(slave),
						refresh, cheat));
				}

				if (slave.earShape !== "none" && V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.RemoveEars(slave),
						refresh, cheat));
				}
				if (slave.earShape !== "none") {
					if (slave.earShape !== "pointy") {
						if (slave.earShape !== "elven") {
							linkArray.push(App.Medicine.Surgery.makeLink(
								new App.Medicine.Surgery.Procedures.EarMinorReshape(slave, "small elfin", "pointy"),
								refresh, cheat));
						}
					}
					if (V.surgeryUpgrade === 1) {
						for (const earShape in App.Data.Slave.FancyEars) {
							if (!["robot"].includes(earShape)) {
								if (slave.earShape !== earShape) {
									linkArray.push(App.Medicine.Surgery.makeLink(
										new App.Medicine.Surgery.Procedures.EarMajorReshape(slave, App.Data.Slave.FancyEars[earShape].title, earShape),
										refresh, cheat));
								}
							}
						}
					}
				}
			}
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function topEars() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			r.push(`${He} has`);
			if (slave.earT === "none") {
				if (slave.earShape !== "none") {
					r.push(`only one set of ears.`);
				} else {
					r.push(`no secondary ears.`);
				}
			} else if (slave.earT === "normal") {
				if (slave.earShape !== "none") {
					r.push(`a second pair of ears grafted to ${his} head.`);
				} else {
					r.push(`a pair of ears grafted to the top of ${his} head.`);
				}
			} else if (slave.earT === "cat") {
				r.push(`a pair of ${App.Utils.translate("cat")} ears adorning ${his} head.`);
			} else if (slave.earT === "leopard") {
				r.push(`a pair of leopard ears adorning ${his} head.`);
			} else if (slave.earT === "tiger") {
				r.push(`a pair of tiger ears adorning ${his} head.`);
			} else if (slave.earT === "jaguar") {
				r.push(`a pair of jaguar ears adorning ${his} head.`);
			} else if (slave.earT === "lion") {
				r.push(`a pair of lion ears adorning ${his} head.`);
			} else if (slave.earT === "dog") {
				r.push(`a pair of ${App.Utils.translate("dog")} ears adorning ${his} head.`);
			} else if (slave.earT === "wolf") {
				r.push(`a pair of wolf ears adorning ${his} head.`);
			} else if (slave.earT === "jackal") {
				r.push(`a pair of jackal ears adorning ${his} head.`);
			} else if (slave.earT === "fox") {
				r.push(`a pair of ${App.Utils.translate("fox")} ears adorning ${his} head.`);
			} else if (slave.earT === "raccoon") {
				r.push(`a pair of ${App.Utils.translate("raccoon")} ears adorning ${his} head.`);
			} else if (slave.earT === "rabbit") {
				r.push(`a pair of ${App.Utils.translate("rabbit")} ears adorning ${his} head.`);
			} else if (slave.earT === "squirrel") {
				r.push(`a pair of ${App.Utils.translate("squirrel")} ears adorning ${his} head.`);
			} else if (slave.earT === "horse") {
				r.push(`a pair of ${App.Utils.translate("horse")} ears adorning ${his} head.`);
			} else {
				r.push(`You done goofed.`);
				r.push(`<span class="note">Report This</span>`);
			}
			if (slave.indentureRestrictions >= 2) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else {
				if (slave.earT !== "none") {
					if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemoveTopEars(slave),
							refresh, cheat));
					}
					if (slave.earT !== "cat") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "cat"),
							refresh, cheat));
					}
					if (slave.earT !== "leopard") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "leopard"),
							refresh, cheat));
					}
					if (slave.earT !== "tiger") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "tiger"),
							refresh, cheat));
					}
					if (slave.earT !== "jaguar") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "jaguar"),
							refresh, cheat));
					}
					if (slave.earT !== "lion") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "lion"),
							refresh, cheat));
					}
					if (slave.earT !== "dog") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "dog"),
							refresh, cheat));
					}
					if (slave.earT !== "wolf") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "wolf"),
							refresh, cheat));
					}
					if (slave.earT !== "jackal") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "jackal"),
							refresh, cheat));
					}
					if (slave.earT !== "fox") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "fox"),
							refresh, cheat));
					}
					if (slave.earT !== "raccoon") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "raccoon"),
							refresh, cheat));
					}
					if (slave.earT !== "rabbit") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "rabbit"),
							refresh, cheat));
					}
					if (slave.earT !== "squirrel") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "squirrel"),
							refresh, cheat));
					}
					if (slave.earT !== "horse") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarReshape(slave, "horse"),
							refresh, cheat));
					}
					if (slave.earTColor === "hairless") {
						r.push(`They are completely bald.`);
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarsImplantHair(slave),
							refresh, cheat));
					} else {
						r.push(`They are covered by a multitude of implanted ${slave.earTColor} fibers mimicking hair.`);
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.TopEarsRemoveHair(slave),
							refresh, cheat));
					}
				}
			}
			App.Events.addNode(el, r, "div");
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function hearing() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];

			if (slave.earImplant === 1) {
				r.push(`${He} has cochlear implants.`);
			} else if (slave.hears <= -2) {
				r.push(`${He} is deaf.`);
			} else {
				r.push(`${He} has working`);
				if (slave.hears === -1) {
					r.push(`inner ears, but is hearing impaired${(slave.earShape === "none") ? `, likely due to missing the outer structure` : ``}.`);
				} else {
					r.push(`ears and good hearing.`);
				}
			}
			App.Events.addNode(el, r, "div");

			if (slave.earImplant !== 1) {
				if (slave.hears === -1) {
					if (slave.earImplant !== 1 && slave.earShape !== "none") {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.EarFix(slave),
							refresh, cheat));
					}
				} else if (slave.hears === 0) {
					if (V.seeExtreme === 1 && slave.earImplant !== 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.EarMuffle(slave),
							refresh, cheat));
					}
				}
			}

			if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
				if (slave.earImplant === 0) {
					if (slave.hears > -2) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.Deafen(slave),
							refresh, cheat));
					}
					if (isProstheticAvailable(slave, "cochlear")) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.CochlearImplant(slave),
							refresh, cheat));
					}
				}
			}
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function horns() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			r.push(`${He} has`);
			if (slave.horn === "none") {
				r.push(`no horns.`);
			} else {
				r.push(`${slave.horn}.`);
			}
			App.Events.addNode(el, r, "div");

			if (slave.indentureRestrictions >= 2) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else if (slave.horn === "none") {
				/**
				 * @type {Array<[string, FC.HornType, string]>}
				 */
				const hornArray = [
					["Succubus horns", "curved succubus horns", "jet black"],
					["Backswept horns", "backswept horns", "jet black"],
					["Bovine horns", "cow horns", "ivory"],
					["One oni horn", "one long oni horn", slave.skin],
					["Two oni horns", "two long oni horns", slave.skin],
					["Small horns", "small horns", "ivory"],
				];
				for (const horn of hornArray) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Horn(slave, horn[0], horn[1], horn[2]),
						refresh, cheat));
				}
			} else {
				linkArray.push(App.Medicine.Surgery.makeLink(
					new App.Medicine.Surgery.Procedures.HornGone(slave),
					refresh, cheat));
			}
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function lips() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			r.push(`${He} has`);
			if (slave.lips <= 10) {
				r.push(`thin, unattractive lips.`);
			} else if (slave.lips <= 20) {
				r.push(`normal lips.`);
			} else if (slave.lips <= 40) {
				r.push(`full, attractive lips.`);
			} else if (slave.lips <= 70) {
				r.push(`plump, beestung lips.`);
			} else if (slave.lips <= 95) {
				r.push(`huge, obviously augmented lips.`);
			} else {
				r.push(`a facepussy: ${his} lips are so huge that they're always a bit parted in the middle, forming a moist, inviting hole for cock.`);
			}
			if (slave.lipsImplant > 20) {
				r.push(`${He} has enormous lip implants.`);
			} else if (slave.lipsImplant > 10) {
				r.push(`${He} has large lip implants.`);
			} else if (slave.lipsImplant > 0) {
				r.push(`${He} has moderate lip implants.`);
			}
			r.push(App.UI.DOM.makeElement("span", `New implants will reduce ${his} oral skills`, "note"));
			App.Events.addNode(el, r, "div");

			if (slave.indentureRestrictions >= 2) {
				App.UI.DOM.appendNewElement("div", el, `${His} indenture forbids elective surgery`, ["choices", "note"]);
			} else if ((slave.lips <= 75) || ((slave.lips <= 95) && (V.seeExtreme === 1))) {
				if (slave.lipsImplant > 0) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.IncreaseLipImplant(slave),
						refresh, cheat));
				} else {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.AddLipImplant(slave),
						refresh, cheat));
				}
			}
			if (slave.lipsImplant !== 0) {
				if (slave.indentureRestrictions < 2) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.RemoveLipImplant(slave),
						refresh, cheat));
				}
			}
			if (slave.lips >= 10 && slave.lipsImplant === 0) {
				if (slave.indentureRestrictions < 2) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.ReduceLips(slave),
						refresh, cheat));
				}
			}
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function teeth() {
			const el = new DocumentFragment();
			const r = [];
			const linkArray = [];
			switch (slave.teeth) {
				case "crooked":
					r.push(`${He} has crooked teeth.`);
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.ApplyBraces(slave),
						refresh, cheat));
					break;
				case "gapped":
					r.push(`${He} has a noticeable gap in ${his} front teeth.`);
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.ApplyBraces(slave),
						refresh, cheat));
					break;
				case "straightening braces":
					r.push(`${His} crooked teeth are in braces.`);
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.RemoveBraces(slave),
						refresh, cheat));
					break;
				case "cosmetic braces":
					r.push(`${He} has braces on ${his} straight teeth.`);
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.RemoveCosmeticBraces(slave),
						refresh, cheat));
					break;
				case "removable":
					r.push(`${He} has prosthetic teeth that can be removed for extreme oral sex.`);
					break;
				case "pointy":
					r.push(`${His} teeth have been replaced with sturdy, realistic implants that mimic the dentition of a predator.`);
					if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.DentalImplant(slave),
							refresh, cheat));
					}
					break;
				case "fangs":
					r.push(`${His} upper canines have been replaced with sturdy, realistic implants that can only be described as vampiric.`);
					if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.FangImplant(slave),
							refresh, cheat));
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.DentalImplant(slave),
							refresh, cheat));
					}
					break;
				case "fang":
					r.push(`A single one of ${his} upper canines has been replaced with a sturdy, realistic implant shaped like a fang.`);
					if (slave.lips <= 50) {
						r.push(`It is occasionally visible over ${his} lower lip.`);
					}
					if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.RemovableTeeth(slave),
							refresh, cheat));
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.FangsImplant(slave),
							refresh, cheat));
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.DentalImplant(slave),
							refresh, cheat));
					}
					break;
				case "baby":
					r.push(`${He} has baby teeth.`);
					if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.DentalImplant(slave),
							refresh, cheat));
					}
					break;
				case "mixed":
					r.push(`${He} has a mix of baby and normal teeth.`);
					break;
				default:
					r.push(`${He} has normal, healthy teeth.`);
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.AddCosmeticBraces(slave),
						refresh, cheat));
					if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.FangImplant(slave),
							refresh, cheat));
					}
			}
			if (V.seeExtreme === 1 && slave.indentureRestrictions < 1) {
				if (slave.teeth !== "removable") {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.RemovableTeeth(slave),
						refresh, cheat));
				}

				if (slave.teeth !== "pointy") {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.SharpTeeth(slave),
						refresh, cheat));
				}

				if (slave.teeth !== "fangs" && slave.teeth !== "fang") {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.FangsImplant(slave),
						refresh, cheat));
				}
			}
			App.Events.addNode(el, r, "div");
			App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			return el;
		}

		function voice() {
			const el = new DocumentFragment();
			const r = [];
			if (slave.electrolarynx === 1) {
				r.push(`${He} has an artificial larynx.`);
			} else {
				if (slave.voice === 0) {
					r.push(`${He} is mute.`);
				} else if (slave.voice === 1) {
					r.push(`${He} has a deep voice.`);
				} else if (slave.voice === 2) {
					r.push(`${He} has a feminine voice.`);
				} else if (slave.voice === 3) {
					r.push(`${He} has a high, girly voice.`);
				}
				if (slave.voiceImplant >= 1) {
					r.push(`${He} has had surgery on ${his} voice box to raise ${his} voice.`);
				} else if (slave.voiceImplant <= -1) {
					r.push(`${He} has had surgery on ${his} voice box to lower ${his} voice.`);
				}
			}
			App.Events.addNode(el, r, "div");
			if (slave.indentureRestrictions < 1 && slave.electrolarynx !== 1) {
				const linkArray = [];
				if (slave.voice !== 0) {
					if (slave.voice < 3) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.VoiceRaise(slave),
							refresh, cheat));
					}
					if (slave.voice > 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.VoiceLower(slave),
							refresh, cheat));
					}
					if (V.seeExtreme === 1) {
						linkArray.push(App.Medicine.Surgery.makeLink(
							new App.Medicine.Surgery.Procedures.Mute(slave),
							refresh, cheat));
					}
				} else if (isProstheticAvailable(slave, "electrolarynx")) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Electrolarynx(slave),
						refresh, cheat));
				}
				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			}
			return el;
		}

		function chemosensory() {
			const el = new DocumentFragment();
			const r = [];
			if (slave.smells === 0 && slave.tastes === 0) {
				r.push(`${He} has a working chemosensory system.`);
			} else if (slave.smells === 0) {
				r.push(`${He} has a working olfactory system and an impaired gustatory system.`);
			} else if (slave.tastes === 0) {
				r.push(`${He} has a working gustatory system and an impaired olfactory system.`);
			} else {
				r.push(`${He} has an impaired chemosensory system.`);
			}
			App.Events.addNode(el, r, "div");
			if (slave.indentureRestrictions < 1) {
				const linkArray = [];
				if (slave.smells === 0 && V.seeExtreme === 1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Desmell(slave),
						refresh, cheat));
				} else if (slave.smells === -1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Resmell(slave),
						refresh, cheat));
				}
				if (slave.tastes === 0 && V.seeExtreme === 1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Detaste(slave),
						refresh, cheat));
				} else if (slave.tastes === -1) {
					linkArray.push(App.Medicine.Surgery.makeLink(
						new App.Medicine.Surgery.Procedures.Retaste(slave),
						refresh, cheat));
				}
				App.UI.DOM.appendNewElement("div", el, App.UI.DOM.generateLinksStrip(linkArray), "choices");
			}
			return el;
		}
	}

	function refresh() {
		jQuery(container).empty().append(content());
		App.Events.refreshEventArt(slave);
		refreshParent();
	}
};