code:
globalThis.policies = (function() {
	return {
		countEugenicsSMRs: countEugenicsSMRs,
		cost: cost,
	};

	function countEugenicsSMRs() {
		let value = 0;
		if (V.policies.SMR.eugenics.faceSMR === 1) {
			value++;
		}
		if (V.policies.SMR.eugenics.heightSMR === 1) {
			value++;
		}
		if (V.policies.SMR.eugenics.intelligenceSMR === 1) {
			value++;
		}
		return value;
	}

	function cost() { return 5000; }
})();
/**
 * @param {string} category
 * @returns {JQuery}
 */
globalThis.policy = function(category) {
	const frag = new DocumentFragment;
	for (let policyVariable in App.Data.Policies.Selection[category]) {
		frag.append(policyElement(policyVariable));
	}
	return jQuery(`#${category}`).empty().append(frag);
	/**
	 * @param {string} policyVariable
	 * @returns {Node} el
	 */
	function policyElement(policyVariable) {
		let el = document.createElement("p");
		let div;
		let span;
		let link;
		const policyValue = _.get(V, policyVariable);
		/** @type {PolicySelector[]} */
		const policyObject = App.Data.Policies.Selection[category][policyVariable];
		if (policyValue === 0) {
			// apply
			for (let i = 0; i < policyObject.length; i++) {
				const p = policyObject[i];
				const enable = p.enable || 1;
				if (p.hasOwnProperty("requirements") && p.requirements === false) {
					continue;
				}
				div = document.createElement("div");
				span = document.createElement("span");

				// title
				span.style.fontWeight = "bold";
				if (p.hasOwnProperty("titleClass")) {
					span.classList.add(p.titleClass);
				}
				span.append(p.title);
				div.append(span);
				div.append(`: `);

				// Description text
				div.append(p.text);
				div.append(` `);

				// link
				if (!(p.hasOwnProperty("hide") && p.hide.button === 1)) {
					if (p.hasOwnProperty("requirements")) {
						if (p.requirements === true) {
							div.append(implement(p, enable));
						} else {
							link = App.UI.DOM.disabledLink("Implement", [`You do not meet the requirements, or passed a conflicting policy already`]);
							link.style.color = "white";
							div.append(link);
						}
					} else {
						div.append(implement(p, enable));
					}
				}
				el.append(div);
			}
		} else if (typeof policyValue === "string" || typeof policyValue === "number") {
			// repeal
			let i = 0;
			for (const pol in policyObject) {
				if (policyObject[pol].hasOwnProperty("enable") && policyObject[pol].enable === policyValue) {
					i = pol;
					break;
				}
			}
			const p = policyObject[i];
			if (p.hasOwnProperty("hide")) {
				if (p.hide.ifActivated === 1) {
					return el;
				}
			}

			let title;
			if (p.hasOwnProperty("activatedTitle")) {
				title = p.activatedTitle;
			} else {
				title = p.title;
			}
			let text;
			if (p.hasOwnProperty("activatedText")) {
				text = p.activatedText;
			} else {
				text = p.text;
			}
			div = document.createElement("div");
			span = document.createElement("span");

			// title
			span.style.fontWeight = "bold";
			span.append(title);
			div.append(span);
			div.append(`: `);

			// Description text
			div.append(text);
			div.append(` `);

			// link
			div.append(repeal(p));
			el.append(div);
		} else {
			throw `V.${policyVariable} not initialized properly, "${policyValue}"`;
		}

		return el;

		/**
		 * @param {PolicySelector} p  The data object that describes the policy being considered.
		 * @returns {Node} Link to repeal.
		 */
		function repeal(p) {
			const frag = new DocumentFragment;
			let check = canAfford();
			if (!(p.hasOwnProperty("hide") && p.hide.button === 1)) {
				if (check === true) {
					link = App.UI.DOM.link(
						"Repeal",
						() => {
							if (V.rep >= 1000) {
								_.set(V, policyVariable, 0);
								applyCost();
								if (p.hasOwnProperty("onRepeal")) {
									p.onRepeal();
								}
							}
							policy(category);
						}
					);
					link.style.color = "yellow";
				} else {
					link = App.UI.DOM.disabledLink("Repeal", [`You do not have enough ${check}`]);
					link.style.color = "red";
				}
				frag.append(link);
			}

			if (p.hasOwnProperty("activatedNote")) {
				frag.append(App.UI.DOM.makeElement("div", p.activatedNote, ["note", "indent"]));
			}
			return frag;
		}
		/**
		 * @param {PolicySelector} p The data object that describes the policy being considered.
		 * @param {number|string} enable value to set the policy to in order to switch it on.
		 * @returns {Node} Link to implement.
		 */
		function implement(p, enable) {
			let check = canAfford();
			const frag = new DocumentFragment;
			if (check === true) {
				link = App.UI.DOM.link(
					"Implement",
					() => {
						if (V.rep >= 1000) {
							_.set(V, policyVariable, enable);
							applyCost();
							if (p.hasOwnProperty("onImplementation")) {
								p.onImplementation();
							}
						}
						policy(category);
					}
				);
				link.style.color = "green";
			} else {
				link = App.UI.DOM.disabledLink("Implement", [`You do not have enough ${check}`]);
				link.style.color = "red";
			}
			frag.append(link);
			if (p.hasOwnProperty("note")) {
				frag.append(App.UI.DOM.makeElement("div", p.note, ["note", "indent"]));
			}
			return frag;
		}

		function canAfford() {
			if (V.cash < 5000) {
				return "cash";
			} else if (V.rep < 1000 && !["EducationPolicies"].includes(category)) {
				return "reputation";
			}
			return true;
		}

		function applyCost() {
			cashX(-5000, "policies");
			if (!["EducationPolicies"].includes(category)) {
				repX(-1000, "policies");
			}
		}
	}
};

repo_name: Welptard/fc

license: mit


code:
:: Policies [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back">>
<<set $passageSwitchHandler = App.EventHandlers.societyChanged>>
<<if $arcologies[0].FSSupremacistLawME && $PC.race != $arcologies[0].FSSupremacistRace>>
	<<set $nextLink = "Gameover", $gameover = "Idiot Ball 2 The Dumbassening">>
<<elseif $arcologies[0].FSSubjugationistLawME && $PC.race == $arcologies[0].FSSubjugationistRace>>
	<<set $nextLink = "Gameover", $gameover = "Idiot Ball 3 Totally Not Idiot Ball 2 Again">>
<<else>>
	<<set $nextLink = "Main">>
<</if>>
<<set $encyclopedia = "Future Societies">>

<<run App.UI.tabBar.handlePreSelectedTab($tabChoice.policies)>>

	Passing any law will cost <<print cashFormat(5000)>> and
	<<if $rep >= 1000>>
		a small amount of reputation.
	<<else>>
		a better reputation.
	<</if>>
	More policies will become available as the arcology develops.

	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'SMRs')" id="tab SMRs">Slave Market Regulations</button>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'ST')" id="tab ST">Sexual Trendsetting</button>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Population')" id="tab Population">Population & Domestic</button>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Education')" id="tab Education">Education</button>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'FS')" id="tab FS">Future Societies</button>
	<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'SRP')" id="tab SRP">Slave Retirement Planning</button>

		Slave Market Regulations (SMRs) will affect slaves that come through the official slave markets in your arcology. The markets themselves will bear the cost of these regulations, but the minimum practicable slave prices may rise as a result.

Population

Domestic

		<<if $schoolSuggestion == 0>>

				You have yet to contact a school about adding a local branch.

		<</if>>

		<<if $policies.retirement.customAgePolicy == 0 && $policies.retirement.physicalAgePolicy == 0>>

''Default Retirement Age:'' in the absence of a defined slave retirement age, slaves will not remain sex slaves after reaching age $retirementAge.

    //This is a current content and mechanical limitation in FC $ver, not a universal Free Cities rule.//
		<</if>>

Menials

	<<if $arcologies[0].FSGenderFundamentalist >= 20>>

Gender Fundamentalist

	<<elseif $arcologies[0].FSGenderRadicalist >= 20>>

Gender Radicalist

	<</if>>

	<<if $arcologies[0].FSPaternalist >= 40>>

Paternalist

	<</if>>

	<<if $arcologies[0].FSDegradationist >= 40>>

Degradationist

	<</if>>

	<<if $arcologies[0].FSIntellectualDependency >= 40>>

Intellectual Dependency

	<</if>>

	<<if $arcologies[0].FSSlaveProfessionalism >= 40>>

Slave Professionalism

	<</if>>

	<<if $arcologies[0].FSBodyPurist >= 40>>

Body Purist

	<</if>>

	<<if $arcologies[0].FSTransformationFetishist >= 40>>

Transformation Fetishist

	<</if>>

	<<if $arcologies[0].FSYouthPreferentialist >= 40>>

Youth Preferentialist

	<</if>>

	<<if $arcologies[0].FSMaturityPreferentialist >= 40>>

Maturity Preferentialist

	<</if>>

	<<if $arcologies[0].FSPetiteAdmiration >= 40>>

Petite Admiration

	<</if>>

	<<if $arcologies[0].FSStatuesqueGlorification >= 40>>

Statuesque Glorification

	<</if>>

	<<if $arcologies[0].FSSlimnessEnthusiast >= 40>>

Slimness Enthusiast

	<</if>>

	<<if $arcologies[0].FSAssetExpansionist >= 40>>

Asset Expansionist

	<</if>>

	<<if $arcologies[0].FSPastoralist >= 40>>

Pastoralist

	<</if>>

	<<if $arcologies[0].FSPhysicalIdealist >= 40>>

Physical Idealist

	<</if>>

	<<if $arcologies[0].FSHedonisticDecadence >= 40>>

Hedonistic Decadence

	<</if>>

	<<if $arcologies[0].FSChattelReligionist >= 40>>

Chattel Religionist

	<</if>>

	<<if $nicaea.held>>

Nicaea

	<</if>>

	<<if $arcologies[0].FSRepopulationFocus >= 40>>

Repopulation Focus

	<</if>>

	<<if $arcologies[0].FSRestart >= 40 || $arcologies[0].FSSupremacist >= 40 || V.arcologies[0].FSSubjugationist >= 40>>

Race

			<<if $propOutcome>>
				''Elite Breeder Eligibility:'' Societal Elite may use eligible slaves as breeders.
			<<elseif $propOutcome == -1>>
				''Elite Breeder Eligibility:'' The Societal Elite have rejected your breeding proposal.
			<</if>>

	<</if>>

	<<if $arcologies[0].FSRomanRevivalist >= 40>>

Roman Revivalist

	<</if>>

	<<if $arcologies[0].FSNeoImperialist >= 40>>

Neo-Imperialism

	<</if>>

	<<if $arcologies[0].FSAztecRevivalist >= 40>>

Aztec Revivalist

	<</if>>

	<<if $arcologies[0].FSEgyptianRevivalist >= 40>>

Egyptian Revivalist

	<</if>>

	<<if $arcologies[0].FSEdoRevivalist >= 40>>

Edo Revivalist

	<</if>>

	<<if $arcologies[0].FSArabianRevivalist >= 40>>

Arabian Revivalist

	<</if>>

	<<if $arcologies[0].FSChineseRevivalist >= 40>>

Chinese Revivalist

	<</if>>


code:
:: Prosthetics Configuration [nobr]

<<switch $prostheticsConfig>>

<<case "main">>
	<<set $nextButton = "Confirm changes", $nextLink = "Slave Interact">>
	/* get all prosthetics that are ready for this slave */
	<<if $adjustProstheticsCompleted > 0>>
		<<set $adjustProsthetics = $adjustProsthetics.filter(function(p) {
			if (p.workLeft <= 0 && p.slaveID == getSlave($AS).ID) {
				addProsthetic(getSlave($AS), p.id);
				$adjustProstheticsCompleted--;
				return false;
			}
			return true;
		})>>
	<</if>>

/* base screen START */

Prosthetic Configuration

This room is lined with shelves and cabinets; it could be easily mistaken for a storage room if it were not for the examination table in its center.

<<if hasBothLegs(getSlave($AS))>>
	<<= getSlave($AS).slaveName>> is obediently waiting for your instructions.
<<else>>
	<<= getSlave($AS).slaveName>> is lying on the table, waiting for your instructions.
<</if>>

<<if hasAnyCyberneticEyes(getSlave($AS))>>

Eyes

 /* tab works better with links */
	$He has <<if hasBothCyberneticEyes(getSlave($AS))>> ocular implants <<else>> an ocular implant <</if>> installed. You can change <<if hasBothCyberneticEyes(getSlave($AS))>>their<<else>>its<</if>> settings:

	<<set _on = 0, _blur = 0, _off = 0>>
	<<if getLeftEyeType(getSlave($AS)) === 3>>

Left:

		<<if getLeftEyeVision(getSlave($AS)) !== 2>>
			<<set _on++>>
			[["[ON]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "left", "fix")]]
		<<else>>
			<<print "[ON]">>
		<</if>>

		<<if getLeftEyeVision(getSlave($AS)) !== 1>>
			<<set _blur++>>
			[["[BLUR]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "left", "blur")]]
		<<else>>
			<<print "[BLUR]">>
		<</if>>

		<<if getLeftEyeVision(getSlave($AS)) !== 0>>
			<<set _off++>>
			[["[OFF]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "left", "blind")]]
		<<else>>
			<<print "[OFF]">>
		<</if>>

	<</if>>
	<<if getRightEyeType(getSlave($AS)) === 3>>

Right:

		<<if getRightEyeVision(getSlave($AS)) !== 2>>
			<<set _on++>>
			[["[ON]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "right", "fix")]]
		<<else>>
			<<print "[ON]">>
		<</if>>

		<<if getRightEyeVision(getSlave($AS)) !== 1>>
			<<set _blur++>>
			[["[BLUR]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "right", "blur")]]
		<<else>>
			<<print "[BLUR]">>
		<</if>>

		<<if getRightEyeVision(getSlave($AS)) !== 0>>
			<<set _off++>>
			[["[OFF]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "right", "blind")]]
		<<else>>
			<<print "[OFF]">>
		<</if>>

	<</if>>
	<<if hasBothCyberneticEyes(getSlave($AS))>>

Both:

		<<if _on > 0>>
			[["[ON]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "both", "fix")]]
		<<else>>
			<<print "[ON]">>
		<</if>>

		<<if _blur > 0>>
			[["[BLUR]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "both", "blur")]]
		<<else>>
			<<print "[BLUR]">>
		<</if>>

		<<if _off > 0>>
			[["[OFF]"|Prosthetics Configuration][eyeSurgery(getSlave($AS), "both", "blind")]]
		<<else>>
			<<print "[OFF]">>
		<</if>>

	<</if>>

	$He has <<print App.Desc.eyesColor(getSlave($AS))>>. To change $his eye color visit the [[auto salon|Salon]].

<</if>>

<<if getSlave($AS).earImplant == 1>>

Ears

	$He has cochlear implants installed.
	<<if getSlave($AS).hears == 0>>
		They are operating normally.
	<<elseif getSlave($AS).hears == -1>>
		They are set to muffle $his hearing.
	<<else>>
		They are turned off.
	<</if>>

	<<if getSlave($AS).hears != 0>>
		[[Restore hearing|Prosthetics Configuration][getSlave($AS).hears = 0, $prostheticsConfig = "hearing"]] |
	<</if>>
	<<if getSlave($AS).hears != -1>>
		[[Muffle|Prosthetics Configuration][getSlave($AS).hears = -1, $prostheticsConfig = "hearing"]]
		<<if getSlave($AS).hears != -2>>
			|
		<</if>>
	<</if>>
	<<if getSlave($AS).hears != -2>>
		[[Disable|Prosthetics Configuration][getSlave($AS).hears = -2, $prostheticsConfig = "hearing"]]
	<</if>>

<</if>>

<<if getSlave($AS).electrolarynx == 1>>

Voice

	$He has an electrolarynx installed.
	<<if getSlave($AS).voice == 0>>
		It is turned off.
	<<elseif getSlave($AS).voice == 1>>
		It is set to its "deep voice" setting.
	<<elseif getSlave($AS).voice == 2>>
		It is set to its "normal voice" setting.
	<<elseif getSlave($AS).voice == 3>>
		It is set to its "high voice" setting.
	<</if>>

	<<if getSlave($AS).voice != 0>>
		[[Disable|Prosthetics Configuration][getSlave($AS).voice = 0, $prostheticsConfig = "voice"]] |
	<</if>>
	<<if getSlave($AS).voice != 1>>
		[[Deep voice setting|Prosthetics Configuration][getSlave($AS).voice = 1, $prostheticsConfig = "voice"]] |
	<</if>>
	<<if getSlave($AS).voice != 2>>
		[[Standard voice setting|Prosthetics Configuration][getSlave($AS).voice = 2, $prostheticsConfig = "voice"]]
		<<if getSlave($AS).voice != 3>>
			|
		<</if>>
	<</if>>
	<<if getSlave($AS).voice != 3>>
		[[High voice setting|Prosthetics Configuration][getSlave($AS).voice = 3, $prostheticsConfig = "voice"]]
	<</if>>

<</if>>

Limbs

	<<= App.Desc.limbChange().selector(getSlave($AS), App.Desc.limbChange().currentLimbs(getSlave($AS)))>>

Tail

<<if getSlave($AS).PTail == 1>>

	$He has a neural tail interface installed. You can assign and adjust $his tail here.

	<<if getSlave($AS).tail != "none">>
		$He currently has a tail attached, if you wish to change it you will first need to detach it.

		[[Detach|Prosthetics Configuration][$prostheticsConfig = "detachTail",$nextButton = "Continue", $nextLink = "Prosthetics Configuration"]]

	<<else>>
		<<if isProstheticAvailable(getSlave($AS), "modT")>>

			Attach a modular tail designed to look like a:

			[[Cat's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "neko", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Dog's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "inu", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Fox's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "kit", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Kitsune's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "kitsune", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Tanuki's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "tanuki", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Cow's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "ushi", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Rabbit's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "usagi", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Squirrel's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "risu", getSlave($AS).tailColor = getSlave($AS).hColor]]
			| [[Horse's Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "mod", getSlave($AS).tailShape = "uma", getSlave($AS).tailColor = getSlave($AS).hColor]]

		<</if>>

		<<if isProstheticAvailable(getSlave($AS), "combatT")>>
			[[Attach Combat Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "combat", getSlave($AS).tailColor = "jet black"]]
			<<if isProstheticAvailable(getSlave($AS), "sexT")>>
				|
			<</if>>
		<</if>>
		<<if isProstheticAvailable(getSlave($AS), "sexT")>>
			[[Attach Pleasure Tail|Prosthetics Configuration][$prostheticsConfig = "attachTail", getSlave($AS).tail = "sex", getSlave($AS).tailColor = "pink"]]
		<</if>>

	<</if>>

<<else>>
	//$He does not have a neural tail interface installed so you cannot attach a tail.//
<</if>>
<<if getSlave($AS).tail == "mod">>

	$He currently has a modular tail, styled to look like
	<<if getSlave($AS).tailShape == "neko">>
		a long, slender cat tail.
	<<elseif getSlave($AS).tailShape == "inu">>
		a bushy dog tail.
	<<elseif getSlave($AS).tailShape == "kit">>
		a soft, fluffy fox tail.
	<<elseif getSlave($AS).tailShape == "kitsune">>
		three incredibly soft, fluffy fox tails.
	<<elseif getSlave($AS).tailShape == "tanuki">>
		a long, fluffy tanuki tail.
	<<elseif getSlave($AS).tailShape == "ushi">>
		a long cow tail.
	<<elseif getSlave($AS).tailShape == "usagi">>
		a short rabbit tail.
	<<elseif getSlave($AS).tailShape == "risu">>
		a large squirrel tail.
	<<elseif getSlave($AS).tailShape == "uma">>
		a long horse tail.
	<</if>>

	Modify $his tail's appearance:

	[[Cat|Prosthetics Configuration][getSlave($AS).tailShape = "neko", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Dog|Prosthetics Configuration][getSlave($AS).tailShape = "inu", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Fox|Prosthetics Configuration][getSlave($AS).tailShape = "kit", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Kitsune|Prosthetics Configuration][getSlave($AS).tailShape = "kitsune", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Tanuki|Prosthetics Configuration][getSlave($AS).tailShape = "tanuki", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Bovine|Prosthetics Configuration][getSlave($AS).tailShape = "ushi", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Rabbit|Prosthetics Configuration][getSlave($AS).tailShape = "usagi", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Squirrel|Prosthetics Configuration][getSlave($AS).tailShape = "risu", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]
	| [[Horse|Prosthetics Configuration][getSlave($AS).tailShape = "uma", cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]]

<</if>>

Prosthetics

//Fit prosthetics to $him://

''Buy and fit''

		<<if $researchLab.level > 0>>
			<<= App.UI.disabledLink(`''Construct in lab''`, ["Depending on lab speed, it might be faster than fitting an existing prosthetic but should almost always be faster than first building and then fitting it to $him."])>>
		<<else>>
			<<= App.UI.disabledLink(`''Construct in lab''`, ["With a lab you could both increase speed and decrease cost."])>>
		<</if>>

		<<if $researchLab.speed >= 300>> /* max speed */
			<<= App.UI.disabledLink(`''Fast assembly''`, ["Your lab is so fast that fitting prosthetics to your slave can done instantly though you will sacrifice some efficiency."])>>
		<<elseif $researchLab.level > 0>>
			<<= App.UI.disabledLink(`''Fast assembly''`, ["Your lab is not fast enough to fit prosthetics instantly."])>>
		<</if>>

<<for _p range setup.prostheticIDs>>
	<<if _p != "erectile">> /* exclude erectile implant */

<<= capFirstChar(setup.prosthetics[_p].name)>>

		<<if $adjustProsthetics.findIndex(function(p) {return p.id == _p && p.slaveID == getSlave($AS).ID}) != -1 || $researchLab.tasks.findIndex(function(p) {return p.type == "craftFit" && p.id == _p && p.slaveID == getSlave($AS).ID}) != -1>>

//Currently being fitted to $him.//

		<<elseif setup.prosthetics[_p].level > $prostheticsUpgrade>>

//Better contracts are needed to buy this.//

		<<elseif isProstheticAvailable(getSlave($AS), _p)>>

//Completed.//

		<<else>>
			<<capture _p>>

			<<if $prosthetics[_p].amount > 0>>
				<<link "From storage" "Prosthetics Configuration">>
					<<set $adjustProsthetics.push({id: _p, workLeft: setup.prosthetics[_p].adjust, slaveID: getSlave($AS).ID}), $prosthetics[_p].amount -= 1>>
				<</link>>
			<<else>>
				<<link "<<= cashFormat(setup.prosthetics[_p].costs)>>" "Prosthetics Configuration">>
					<<set $adjustProsthetics.push({id: _p, workLeft: setup.prosthetics[_p].adjust, slaveID: getSlave($AS).ID}), cashX(forceNeg(setup.prosthetics[_p].costs), "slaveMod", getSlave($AS))>>
				<</link>>
			<</if>>

			<<if $prosthetics[_p].research > 0>>

			<<if $researchLab.level > 0 && $prosthetics[_p].research > 0>>
				<<link "Construct" "Prosthetics Configuration">>
					<<set $researchLab.tasks.push({
						type: "craftFit",
						id: _p,
						workLeft: (setup.prosthetics[_p].adjust + setup.prosthetics[_p].craft) / 1.5,
						slaveID: $AS})>>
					/* 1.5: longer than adjust, but faster than adjust+craft. */
				<</link>>
			<</if>>

			<<if $researchLab.speed >= 300 && $prosthetics[_p].research > 0>> /* max speed */
			<<if $prosthetics[_p].amount > 0>>
				<<link "From storage: <<= cashFormat(setup.prosthetics[_p].adjust * 50)>>" "Prosthetics Configuration">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs * 1.5), "slaveMod", getSlave($AS)), addProsthetic(getSlave($AS), _p)>>
				<</link>>
			<<else>>
				<<link "<<= cashFormat(setup.prosthetics[_p].costs + setup.prosthetics[_p].adjust * 100)>>" "Prosthetics Configuration">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs + setup.prosthetics[_p].adjust * 100), "slaveMod", getSlave($AS)), addProsthetic(getSlave($AS), _p)>>
				<</link>>
			<</if>>
			<</if>>

			<<elseif $researchLab.level > 0>>

				//Not researched.//

			<</if>>
			<</capture>>
		<</if>>
	<</if>>
<</for>>

/* base screen END */

/*
<<case "eyes">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<if getSlave($AS).eyes == 1>>
		$He blinks as $his vision returns.
	<<elseif getSlave($AS).eyes == -1>>
		$He squints at you as $his vision becomes a blur.
	<<else>>
		$He has a panicked expression when $his vision suddenly goes out.
	<</if>>
*/

<<case "limbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<= App.Desc.limbChange().reaction(getSlave($AS), $oldLimbs)>>
	<<unset $oldLimbs>>

/*
<<case "basicPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>>
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion > 20>>
			$He's overwhelmed with gratitude and thanks you profusely the first chance $he gets. $He follows the acclimation program diligently, doing $his best to learn how to be a good slave despite, or sometimes even because of, $his artificial arms and legs.
		<<elseif getSlave($AS).devotion >= -20>>
			$He's overwhelmed with gratitude in part because $he didn't think you'd do something like this for $him. $He thanks you profusely the first chance $he gets, and follows the acclimation program diligently, trying to deserve the expense you went to.
		<<else>>
			Despite $his hatred of you, $he can't help but notice that you clearly have a plan for $him that involves putting a good deal of value into $him. Your goals might not be $hers, but at least $he has an indication that you're not toying with $him.
		<</if>>
	<</if>>

<<case "sexPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>>
	While exiting the prosthetic lab $he is experimenting with $his new arms and legs.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			$He rapidly discovers that $his fingertips are now vibrators, and then makes a mess when $he figures out that $his hands can dispense lube without figuring out how to make them stop dispensing lube. $He's frustrated and frightened, realizing that even $his prosthetics are now customized to suit $his purpose as a human sex toy. $He knew $he was a toy before, but somehow, being a literal vibrator is a bit much for $him.
		<<elseif getSlave($AS).energy > 95>>
			Since $he's a nympho, $he discovers $his new sexual functions in a hurry. They trigger in part is based on arousal, and $he's never not aroused, so they activate one by one as $he leaves the surgery. The vibration, lube, and other dirty functions surprise $him, and it takes $him a moment to realize what's going on, but $he begins to breathe hard when $he understands.
		<<else>>
			$He discovers $his sexy new functions one by one. The vibration, lube, and other dirty functions surprise $him, and it takes $him a moment to realize what's going on, but $he begins to shake with amusement when $he understands. $He heads off to try them out.
		<</if>>
	<</if>>

<<case "beautyPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>> $He exits the prosthetic lab <<if canSee(getSlave($AS))>>marveling at the beautiful, natural appearance of $his new arms and legs<<else>>thanking you for $his new arms and legs, unaware of how natural they look<</if>>.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			If $he doubts that you have some sort of long term plan for $him, all $he has to do is <<if canSee(getSlave($AS))>>look down and examine<<else>>feel<</if>> $his elegant, natural prosthetics, which are often mistaken for the genuine article. Even $he makes the mistake at times as $he gets used to them.
		<<elseif getSlave($AS).skill.entertainment >= 100>>
			Since $he's a masterful entertainer, $he knows multiple styles of dance, though $his straightforward modern prosthetics never allowed $him to be anything more than a mechanically competent dancer. $He finds that $he has far better balance now, in addition to looking more natural. Before long, $he goes //en pointe// and holds the position, before collapsing in a heap. It soon becomes apparent that this wasn't due to clumsiness: $he's sobbing so hard $he can barely breathe. $He thanks you profusely the next time $he sees you, eyes still puffy with tears of joy.
		<<else>>
			When $he first <<if canSee(getSlave($AS))>>catches sight of $himself in a mirror<<else>>runs a new finger over $his natural feeling skin<</if>>, $he begins to cry. Terribly complex emotions war across $his face: gratitude, joy, regret, and something undefinable. Blinking, $he uses newly elegant fingertips to trace the scarcely visible seams where $his artificial and natural skin meet. $He thanks you profusely the next time $he sees you, eyes still puffy with tears.
		<</if>>
	<</if>>

<<case "combatPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>> While exiting the prosthetic lab $he is wondering over the bulky <<if canSee(getSlave($AS))>>appearance<<else>>weight<</if>> of $his reinforced arms and legs.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			$He's frightened, once $he discovers what $he can do, and what $he is. $His integral weapons are locked out by the arcology systems, for now, but $he quickly realizes what they are. $He is not, to say the least, thrilled by the revelation that $he is now a living weapon, and is kept awake by thoughts of what you might be planning for $him.
		<<elseif (getSlave($AS).skill.combat == 1) && (getSlave($AS).devotion > 75)>>
			$He leaves the prosthetic lab with a purpose, $his footsteps a bit heavier than before. $He heads down to the armory's range, still naked, and when $he gets there, $he places $his dominant hand over $his thigh on that side. It folds open, revealing a handgun, which $he draws and empties into a <<if canSee(getSlave($AS))>>target<<else>>beeping target<</if>>; as $he fires the last rounds, $he uses $his off hand to reach down to that thigh, which folds open and reveals spare magazines. $He knows that $his prosthetics are a wash, at best, in terms of actual combat effectiveness; they'll never match the reliability and dexterity of the genuine article. But $he thinks they are //cool.//
		<<else>>
			$He has mixed feelings about what $he soon discovers. $He's a living weapon now, and has to live with the constant knowledge that $he can incapacitate or kill with nothing more than what's contained within $his arms and legs. $He's touched, though, by the tremendous trust this shows. $He knows that the arcology would instantly lock out $his weapons if $he were to misbehave, but $he's still affected.
		<</if>>
	<</if>>

<<case "cyberPLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his limbs is a simple procedure, you simply push a connector on each limb into the socket in $his implants until the lock engages.<<if getSlave($AS).PLimb == 2>> $He jumps a bit as limbs connect to $his nerves.<</if>> $He exits the prosthetic lab marveling <<if canSee(getSlave($AS))>>at the shiny artificial skin of $his new arms and legs<<else>>at the feel of the artificial skin of $his new arms and legs under $his new fingers<</if>>.
	<<if getSlave($AS).fetish != "mindbroken" && getSlave($AS).fuckdoll == 0>>
		<<if getSlave($AS).devotion <= 20>>
			$He's frightened, once $he discovers what $he can do, and what $he is. $His cybernetic limbs are restricted by the arcology systems, for now, but $he quickly realizes what they are. $He is not, to say the least, thrilled by the revelation that $he is now a living weapon, and is kept awake by thoughts of what you might be planning for $him.
		<<elseif (getSlave($AS).skill.combat == 1) && (getSlave($AS).devotion > 75)>>
			$He leaves the surgery with a purpose, $his footsteps a bit heavier than before. $He heads down to the armory's range, still naked, and when $he gets there, $he places $his dominant hand over $his thigh on that side. It folds open, revealing a handgun, which $he draws and empties into a <<if canSee(getSlave($AS))>>target<<else>>beeping target<</if>>; as $he fires the last rounds, $he uses $his off hand to reach down to that thigh, which folds open and reveals spare magazines. $He knows that $his prosthetics will enhance $his combat effectiveness and $he thinks they are //cool.//
		<<else>>
			$He has mixed feelings about what $he soon discovers. $He's a living weapon now, and has to live with the constant knowledge that $he can incapacitate or kill with nothing more than $his arms and legs themselves. $He's touched, though, by the tremendous trust this shows. $He knows that the arcology would instantly lock out $his limbs if $he were to misbehave, but $he's still affected.
		<</if>>
	<</if>>

<<case "removeLimbs">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Due to built-in safeties it is necessary to remove each limb separately, first releasing the lock and then waiting for automated seal release.

	<<if (getSlave($AS).devotion > 20)>>
		You instruct $him to lie down on the table and proceed to remove $his limbs. $He <<if canSee(getSlave($AS))>>watches<<elseif canHear(getSlave($AS))>>listens<<else>>waits<</if>> with interest as you work.<<if (getSlave($AS).devotion > 50)>> As you remove the last limb $he playfully wiggles $his stumps at you.<</if>>
	<<else>>
		You order $him to lie down on the table and proceed to remove $his limbs. $He <<if canSee(getSlave($AS))>>watches<<elseif canHear(getSlave($AS))>>listens<<else>>waits<</if>> with a bitter expression as you work.
	<</if>>
*/

<<case "hearing">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<if getSlave($AS).hears == 0>>
		$He tilts $his head as $his hearing returns.
	<<elseif getSlave($AS).hears == -1>>
		$He shakes $his head as $his hearing becomes muffled.
	<<else>>
		$He has a panicked expression when $his hearing is suddenly silenced.
	<</if>>

<<case "voice">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<if getSlave($AS).voice == 0>>
		$He tries testing out $his new voice, only to discover $he's been made mute.
	<<elseif getSlave($AS).voice == 1>>
		$He tests out the <<if canHear(getSlave($AS))>>sound<<else>>feeling<</if>> of $his new, deep voice.
	<<elseif getSlave($AS).voice == 2>>
		$He tests out the <<if canHear(getSlave($AS))>>sound<<else>>feeling<</if>> of $his new, normal voice.
	<<elseif getSlave($AS).voice == 3>>
		$He tests out the <<if canHear(getSlave($AS))>>sound<<else>>feeling<</if>> of $his new, high voice.
	<</if>>

<<case "detachTail">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	<<set getSlave($AS).tail = "none", getSlave($AS).tailShape = "none", getSlave($AS).tailColor = "none">>
	You send the release signal and the mechanical lock disengages allowing the artificial tail to pop right off.

<<case "attachTail">>
	<<set $prostheticsConfig = "main", $nextButton = "Continue", $nextLink = "Prosthetics Configuration">>
	Attaching $his tail is a simple procedure, you simply push the connector into a socket, right where $his tailbone ends, until the lock engages.

	When you are done, $he looks back and
	<<if getSlave($AS).tailShape == "neko">>sways $his tail side to side enigmatically.
	<<elseif getSlave($AS).tailShape == "inu">>wags $his tail side to side energetically.
	<<elseif getSlave($AS).tailShape == "kit">>slowly sways $his tail feeling the soft fur brush against $his skin.
	<<elseif getSlave($AS).tailShape == "kitsune">>slowly sways $his tails luxuriating in the incredibly soft, fluffy fur brushing against $his skin.
	<<elseif getSlave($AS).tailShape == "tanuki">>admires $his long, thick fluffy tail.
	<<elseif getSlave($AS).tailShape == "ushi">>swats $himself playfully.
	<<elseif getSlave($AS).tailShape == "usagi">>wiggles $his little tail a bit.
	<<elseif getSlave($AS).tailShape == "risu">>admires $his the size of $his fluffy tail.
	<<elseif getSlave($AS).tailShape == "uma">>sways $his tail back and forth.
	<<elseif getSlave($AS).tail == "combat">>experimentally whips the long tail side to side then takes aim at a prepared fruit, lashes out with blinding speed and smiles as it explodes into chunks.
	<<elseif getSlave($AS).tail == "sex">>accidentally engages the vibrating and lube functions, startling $him and making quite a mess.
	<<else>>admires $his new tail.
	<</if>>

/*
<<case "interface">>

	<<set _first = 1>>
	/*TODO save .legsTat and .armsTat / link them to prosthetic*/
/*	<<if getLeftArmID(getSlave($AS)) !== 2 && isProstheticAvailable(getSlave($AS), "basicL")) != -1>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.basicL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 2), $prostheticsConfig = "basicPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 3 && isProstheticAvailable(getSlave($AS), "sexL"))>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.sexL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 3), $prostheticsConfig = "sexPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 4 && isProstheticAvailable(getSlave($AS), "beautyL")>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.beautyL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 4), $prostheticsConfig = "beautyPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 5 && isProstheticAvailable(getSlave($AS), "combatL")>>
		<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

			<<set _first = 0>>
		<</if>>
		<<link "Attach <<= addA(setup.prosthetics.combatL.name)>>">>
			<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 5), $prostheticsConfig = "combatPLimbs">>
			<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
		<</link>>

	<</if>>
	<<if getLeftArmID(getSlave($AS)) !== 6 && isProstheticAvailable(getSlave($AS), "cyberneticL")>>
		<<if getSlave($AS).PLimb == 2>>
			<<if _first>>

Since you already have prepared limbs for $him you might as well attach them while you are working on $him:

				<<set _first = 0>>
			<</if>>
			<<link "Attach <<= addA(setup.prosthetics.cyberneticL.name)>>" "Prosthetics Configuration">>
				<<set removeLimbs(getSlave($AS), "all"), attachLimbs(getSlave($AS), "all", 6), $prostheticsConfig = "cyberPLimbs">>
				<<replace #attach>>

<<include "Prosthetics Configuration">><<set $nextLink = "Remote Surgery">><</replace>>
			<</link>>
		<</if>>
	<</if>>

*/
<</switch>>


code:
:: Prosthetic Lab [nobr jump-to-safe jump-from-safe]

<<set $nextButton = "Back", $nextLink = "Manage Penthouse">>

<<set $researchLab.speed = (($researchLab.hired * 3) + $researchLab.menials) * $researchLab.aiModule>>

Prosthetic Lab

<<if $adjustProsthetics.length > $adjustProstheticsCompleted>>

External contract workers

	Currently adjusting these prosthetics:
	<<for _p range $adjustProsthetics>>
		<<if _p.workLeft > 0>>

				<<= capFirstChar(setup.prosthetics[_p.id].name)>> for <<= SlaveFullName($slaves[$slaveIndices[_p.slaveID]])>>

		<</if>>
	<</for>>
<</if>>

<<if $researchLab.level > 0>>

Research Department

	//You switch one of the screens in your office to the feed from your research facility.//

Personnel

	<<if $researchLab.aiModule == 1>>

			[[Buy and install research module|Prosthetic Lab][cashX(forceNeg(35000*$upgradeMultiplierArcology), "capEx"), $researchLab.aiModule = 2]] //This module enables your personal assistant to assist staff and direct menials assigned to your research facility, increasing efficiency. It costs <<= cashFormat(35000*$upgradeMultiplierArcology)>>//

	<</if>>
	<<if ($researchLab.hired + $researchLab.menials) == 0>>
		//Facility is currently unstaffed.//
	<<else>>
		//You have
		<<if $researchLab.hired == 1>>
			one scientist
		<<elseif $researchLab.hired > 1>>
			$researchLab.hired scientists
		<</if>>
		<<if $researchLab.hired > 0 && $researchLab.menials > 0 >> and<</if>>
		<<if $researchLab.menials == 1>>
			one menial slave
		<<elseif $researchLab.menials > 1>>
			$researchLab.menials menials
		<</if>>
		working in your lab.
			<<setAssistantPronouns>>
			<<if $researchLab.aiModule > 1>>Occasionally you hear the voice of your assistant as _heA helps direct and organize work.<</if>>//
	<</if>>

	Currently, this facility can employ $researchLab.maxSpace people.
	<<if $researchLab.maxSpace == 5>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(5000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 10]]
		//Costs <<= cashFormat(Math.trunc(5000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 10>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(10000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 20]]
		//Costs <<= cashFormat(Math.trunc(10000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 20>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(15000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 30]]
		//Costs <<= cashFormat(Math.trunc(15000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 30>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 40]]
		//Costs <<= cashFormat(Math.trunc(20000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 40>>
		[[Expand facility|Prosthetic Lab][cashX(forceNeg(Math.trunc(25000*$upgradeMultiplierArcology)), "capEx"), $researchLab.maxSpace = 50]]
		//Costs <<= cashFormat(Math.trunc(25000*$upgradeMultiplierArcology))>>//
	<<elseif $researchLab.maxSpace == 50>>
		//Facility is fully expanded.//
	<</if>>

	<<if ($researchLab.hired + $researchLab.menials) < $researchLab.maxSpace>>

		Hire [[x1|Prosthetic Lab][$researchLab.hired += 1,cashX(forceNeg(2000), "labScientistsTransfer")]]
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.hired += 5,cashX(forceNeg(10000), "labScientistsTransfer")]]
		<</if>>
		<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.hired += 10,cashX(forceNeg(10000), "labScientistsTransfer")]]
		<</if>>
		scientists.

		//Each scientist will require an initial fee of <<= cashFormat(2000)>> and incur <<= cashFormat(300)>> weekly.//

		<<if $menials > 0>>
			Assign [[x1|Prosthetic Lab][$researchLab.menials += 1,$menials -= 1]]
			<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 5 && $menials >= 5>>
				| [[x5|Prosthetic Lab][$researchLab.menials += 5,$menials -= 5]]
			<</if>>
			<<if ($researchLab.maxSpace - ($researchLab.hired + $researchLab.menials)) >= 10 && $menials >= 10>>
				| [[x10|Prosthetic Lab][$researchLab.menials += 10,$menials -= 10]]
			<</if>>
			menial slaves to lab.
		<<else>>
			You do not own any <<if $researchLab.menials != 0>>unassigned <</if>>menial slaves.
		<</if>>

		//Using menial slaves is much cheaper than hiring scientists, but they are less effective. <<= cashFormat(100)>> per slave each week.//

	<<else>>

//Facility is fully staffed.//

	<</if>>

	<<if $researchLab.hired > 0>>

		Fire [[x1|Prosthetic Lab][$researchLab.hired -= 1]]
		<<if $researchLab.hired >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.hired -= 5]]
		<</if>>
		<<if $researchLab.hired >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.hired -= 10]]
		<</if>>
		| [[All|Prosthetic Lab][$researchLab.hired = 0]]
		scientists.

	<</if>>
	<<if $researchLab.menials > 0>>

		Dismiss [[x1|Prosthetic Lab][$researchLab.menials -= 1,$menials += 1]]
		<<if $researchLab.menials >= 5>>
			| [[x5|Prosthetic Lab][$researchLab.menials -= 5,$menials += 5]]
		<</if>>
		<<if $researchLab.menials >= 10>>
			| [[x10|Prosthetic Lab][$researchLab.menials -= 10,$menials += 10]]
		<</if>>
		| [[All|Prosthetic Lab][$menials += $researchLab.menials, $researchLab.menials = 0]]
		menial slaves.

	<</if>>

Tasks

	<<if $researchLab.tasks.length > 0>>
		<<set _j = 0>>
		<<if $researchLab.speed > 0>>
			The following tasks are queued:
		<<else>>
			You have projects planned but without researchers you won't be able to work on them:
		<</if>>

		<<for _i = 0; _i < $researchLab.tasks.length; _i++>>

			<<switch $researchLab.tasks[_i].type>>
			<<case "research">>
				You <<if _i == 0>>are researching<<else>> plan to research<</if>>
			<<case "craft">>
				You <<if _i == 0>>are constructing<<else>> plan to construct<</if>>
			<<case "craftFit">>
				For @@.noteworthy;<<= SlaveFullName($slaves[$slaveIndices[$researchLab.tasks[_i].slaveID]])>>@@ you <<if _i == 0>>are constructing<<else>> plan to construct<</if>>
			<<default>>
				@@.error;Error: Unknown $researchLab.tasks[].type: $researchLab.tasks[_i].type@@
			<</switch>>
			<<set _j += $researchLab.tasks[_i].workLeft>>
			@@.noteworthy;<<= capFirstChar(setup.prosthetics[$researchLab.tasks[_i].id].name)>>@@.
			<<if $researchLab.speed > 0>>
				Finished in approximately <<= (Math.floor(_j / $researchLab.speed) + 1)>> week(s).
			<</if>>

			<<if $researchLab.tasks[_i].type == "research">>
				<<set _link = "Cancel: Will not return investments.">>
			<<else>>
				<<set _link = "Cancel">>
			<</if>>
			<<capture _i>>
				<<link _link "Prosthetic Lab">>
					<<if $researchLab.tasks[_i].type == "research">>
						<<set $prosthetics[$researchLab.tasks[_i].id].research = 0>>
					<</if>>
					<<set $researchLab.tasks.deleteAt(_i)>>
				<</link>>
			<</capture>>

		<</for>>
	<<else>>
		//Currently the research lab has no tasks planned.//
	<</if>>

Research

	Available research projects:
	<<for _p range setup.prostheticIDs>>
		<<if $prosthetics[_p].research == 0>>
			<<if _p != "erectile">> /*excludes erectile*/

			<<if setup.prosthetics[_p].level <= $prostheticsUpgrade>>
				<<capture _p>>
				<<link "Reverse engineer <<= addA(setup.prosthetics[_p].name)>>" "Prosthetic Lab">>
					<<set cashX(forceNeg(setup.prosthetics[_p].costs), "labResearch"), $prosthetics[_p].research = -1, $researchLab.tasks.push({type: "research", id: _p, workLeft: setup.prosthetics[_p].research})>>
				<</link>>
				<</capture>>
					//Costs <<= cashFormat(setup.prosthetics[_p].costs)>> of initial investment.//
			<<else>>
				//You need better contracts to get the required research material for reverse engineering <<= addA(setup.prosthetics[_p].name)>>.//
			<</if>>

			<</if>>
		<</if>>
	<</for>>

Manufacture

	Available building projects:
	<<for _p range setup.prostheticIDs>>
		<<if $prosthetics[_p].research == 1>>
			<<if _p != "erectile">> /*excludes erectile*/

			<<capture _p>>
			<<link "Build <<= addA(setup.prosthetics[_p].name)>>" "Prosthetic Lab">>
				<<set $researchLab.tasks.push({type: "craft", id: _p, workLeft: setup.prosthetics[_p].craft})>>
			<</link>>
			<</capture>>

			<</if>>
		<</if>>
	<</for>>

Prepared prosthetics

		<<= getProstheticsStockpile()>>

<</if>>


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @param {object} params
 * @param {string} [params.oldName] Their name before you renamed them by calling this function
 * @param {string} [params.oldSurname] Their surname before you renamed them by calling this function
 */
App.UI.SlaveInteract.rename = function(slave, {oldName = "", oldSurname = ""} = {}) {
	const r = [];
	const {
		He, he, His, his, him, girl, himself, wife
	} = getPronouns(slave);
	if (slave.slaveName === oldName && slave.slaveSurname === oldSurname) {
		return;
	} else {
		/* First time renaming reaction */
		if (slave.slaveName === "" || !(slave.hasOwnProperty("slaveName"))) {
			r.push(`${oldName} needs to be called something on the records, so ${oldName} ${he} stays.`);
			slave.slaveName = oldName;
		} else if (slave.fetish === "mindbroken") {
			r.push(`${slave.slaveName} doesn't even recognize that ${he}'s been renamed. It simply does not register.`);
		} else if ((oldName !== slave.birthName && slave.slaveName === slave.birthName) || (oldSurname !== slave.birthSurname && slave.slaveSurname === slave.birthSurname)) {
			r.push(`${slave.slaveName}`);
			if (slave.devotion > 50) {
				r.push(`cheerfully accepts ${his} old name back.`);
			} else if (slave.devotion >= -20) {
				r.push(`obediently accepts ${his} old name back.`);
			} else if (slave.devotion >= -50) {
				r.push(`happily accepts ${his} original name.`);
			} else if (slave.trust > 20) {
				r.push(`scoffs at the notion that ${he} was ever anything other than ${SlaveFullBirthName(slave)}, <span class="orangered">weakening your control over ${him}.</span>`);
				slave.trust += 5;
			} else {
				r.push(`cautiously accepts the return of ${his} name.`);
			}
		} else if ((oldName === slave.birthName && slave.slaveName !== slave.birthName) || (oldSurname === slave.birthSurname && slave.slaveSurname !== slave.birthSurname)) {
			r.push(`${slave.slaveName}`);
			if (slave.devotion > 50) {
				r.push(`accepts ${his} new name cheerfully. This attachment to you <span class="devotion inc">increases ${his} devotion.</span>`);
				slave.devotion += 4;
			} else if (slave.devotion >= -20) {
				r.push(`obediently accepts ${his} new name. This surrender to you <span class="devotion inc">increases ${his} obedience.</span>`);
				slave.devotion += 4;
			} else if (slave.devotion >= -50) {
				r.push(`reluctantly accepts ${his} new name.`);
			} else {
				r.push(`angrily tries to resist ${his} new name, insisting that ${his} name is ${SlaveFullBirthName(slave)}. This resistance <span class="devotion dec">increases ${his} rebelliousness.</span>`);
				slave.devotion -= 5;
			}
		} else {
			r.push(`Since ${slave.slaveName} has already had a new name`);
			if (slave.devotion > 20) {
				r.push(`given to`);
			} else {
				r.push(`forced on`);
			}
			r.push(`${him} before, the mere fact of having it changed again doesn't really affect ${him}.`);
		}

		let insultingName = false;
		let toSearch;
		if (oldName !== slave.slaveName && typeof slave.slaveName === "string") {
			toSearch = slave.slaveName.toLowerCase();
			insultingName = setup.badWords.some((s) => toSearch.includes(s));
		}
		if (!insultingName) {
			if (oldSurname !== slave.slaveSurname && typeof slave.slaveSurname === "string") {
				toSearch = slave.slaveSurname.toLowerCase();
				insultingName = setup.badWords.some((s) => toSearch.includes(s));
			}
		}
		if (insultingName) {
			if (slave.fetish === "mindbroken") {
				r.push(`${His} new name would be insulting to a normal ${girl}, but ${he} dully accepts that it is an accurate description and goes about ${his} duties.`);
			} else if (slave.devotion < -50) {
				r.push(`Being given such a degrading name <span class="devotion dec">further increases ${his} hatred</span> of you.`);
				slave.devotion -= 5;
			} else if (slave.devotion <= 50) {
				r.push(`Being given such a degrading name <span class="trust dec">terrifies ${him},</span> since ${he} thinks it's fair warning for what ${he}'ll suffer in the future.`);
				slave.trust -= 5;
			}
		}

		/* Wife's surname reaction */
		if (oldSurname !== slave.slaveSurname) {
			if (slave.relationship >= 5) {
				const slaveWife = getSlave(slave.relationshipTarget);
				if (!slaveWife) {
					r.push(`<span class="red">Error, relationshipTarget not found.</span>`);
				} else {
					if (slaveWife.slaveSurname) {
						const {wife2} = getPronouns(slaveWife).appendSuffix('2');
						if (slave.slaveSurname === slaveWife.slaveSurname) {
							r.push(`${He}'s touched that ${he} now shares a surname with ${his} ${wife2} ${slaveWife.slaveName} ${slaveWife.slaveSurname}, and is more confident than ever that you intend to keep them together in marital bliss.`);
							slave.trust += 5;
						} else if (oldSurname === slaveWife.slaveSurname) {
							r.push(`${He}'s concerned that ${he} no longer shares a surname with ${his} ${wife2} ${slaveWife.slaveName} ${slaveWife.slaveSurname}, and is very worried that you might be considering splitting them up.`);
							slave.trust -= 5;
						}
					}
				}
			}
		}

		/* PC's surname reaction */
		if (oldSurname !== slave.slaveSurname) {
			if (slave.relationship === -3) {
				if (V.PC.slaveSurname) {
					if (slave.fetish === "mindbroken") {
						r.push(`Names are meaningless to ${him} and it is unlikely ${he}'ll remember it.`);
					} else if (slave.devotion + slave.trust >= 175) {
						if (slave.slaveSurname === V.PC.slaveSurname) {
							r.push(`When you tell ${him} that ${he}'s to be known as ${slave.slaveName} ${slave.slaveSurname} now, ${he} starts to cry. ${He} tries to get ${himself} under control and thank you as best ${he} can,`);
							if (hasAnyArms(slave)) {
								r.push(`wiping at the tears running down ${his} ${slave.skin} cheeks,`);
							}
							r.push(`but ${he} can't seem to stop weeping as ${he} thanks you over and over. ${He}'s a sex slave, your property, and it's understandable that some doubts about the permanence of ${his} place as your slave ${wife}. This has helped reassure ${him}, and explains the strength of ${his} emotional reaction. The next time you make love to ${him}, ${he} presses ${himself} as close to you as ${he} can, eager to drink in as much of your presence as ${he} can get.`);
							slave.devotion += 5;
							slave.trust += 5;
						} else if (oldSurname === V.PC.slaveSurname) {
							r.push(`${He}'s devastated that you'd rename ${him} something other than your name. ${He}'s terrified that you intend to discard ${him} as your slave ${wife}, and saddened that you would take away something that was precious to ${him}.`);
							slave.devotion -= 5;
							slave.trust -= 5;
						}
					} else if (slave.devotion < -20 && slave.trust > 20) {
						if (slave.slaveSurname === V.PC.slaveSurname) {
							r.push(`When you tell ${him} that ${he}'s to be known as ${slave.slaveName} ${slave.slaveSurname} now, ${he} shows no reaction. You already took everything from ${him}, what's a name at this point?`);
						} else if (oldSurname === V.PC.slaveSurname) {
							r.push(`${He} doesn't care about losing your surname at first, but it quickly sets in that ${he} may have <span class="trust dec">pushed ${his} position too far.</span>`);
							slave.trust -= 20;
						}
					} else if (slave.devotion < -20) {
						if (slave.slaveSurname === V.PC.slaveSurname) {
							r.push(`When you tell ${him} that ${he}'s to be known as ${slave.slaveName} ${slave.slaveSurname} now, ${he} pleads with you not to steal ${his} name. It matters little to you, and ${he} is forced to accept your will.`);
							slave.devotion += 5;
						} else if (oldSurname === V.PC.slaveSurname) {
							r.push(`${He}'s happy to no longer have to share a name with ${his} tormentor, but the bliss doesn't last long as dread quickly sets in about what this may mean.`);
							slave.devotion += 5;
							slave.trust -= 10;
						}
					} else {
						if (slave.slaveSurname === V.PC.slaveSurname) {
							r.push(`When you tell ${him} that ${he}'s to be known as ${slave.slaveName} ${slave.slaveSurname} now, ${he} nods with approval feeling that ${he} may hold at least some value in your eyes.`);
							slave.trust += 5;
						} else if (oldSurname === V.PC.slaveSurname) {
							r.push(`${He} accepts that you'd rename ${him} something other than your name. ${He}'s a little scared that you intend to discard ${him} as your slave ${wife}, or worse, but realizes this was not only a possibility, but likely.`);
							slave.trust -= 5;
						}
					}
				}
			}
		}
	}
	return jQuery("#rename").empty().append(r.join(" "));
};


code:
App.UI.SlaveInteract.custom = function(slave) {
	const {
		He, His,
		he, his, him,
	} = getPronouns(slave);

	const el = document.createElement('div');

	el.appendChild(intro());

	App.UI.DOM.appendNewElement("h3", el, `Art`);
	el.appendChild(customSlaveImage());
	el.appendChild(customHairImage());

	App.UI.DOM.appendNewElement("h3", el, `Names`);
	el.appendChild(playerTitle());
	el.appendChild(slaveFullName());

	App.UI.DOM.appendNewElement("h3", el, `Description`);
	el.appendChild(hair());
	el.appendChild(eyeColor());
	el.appendChild(customTattoo());
	el.appendChild(customOriginStory());
	el.appendChild(customDescription());
	el.appendChild(customLabel());

	return el;

	function intro() {
		const frag = new DocumentFragment();
		let p;
		p = document.createElement('p');
		p.id = "rename";
		frag.append(p);

		p = document.createElement('p');
		p.className = "scene-p";
		p.append(`You may enter custom descriptors for your slave's hair color, hair style, tattoos, or anything else here. After typing, press `);
		p.appendChild(App.UI.DOM.makeElement("kbd", "enter"));
		p.append(` to commit your change. These custom descriptors will appear in descriptions of your slave, but will have no gameplay effect. Changing them is free.`);
		frag.append(p);
		return frag;
	}

	function playerTitle() {
		let playerTitle = document.createElement('p');
		const label = document.createElement('div');
		let result;
		if (slave.devotion >= -50) {
			if (slave.custom.title !== "") {
				label.textContent = `You have instructed ${him} to always refer to you as ${slave.custom.title}, which, should ${he} lisp, comes out as ${slave.custom.titleLisp}.`;
			} else {
				label.textContent = `You expect ${him} to refer to you as all your other slaves do.`;
			}
			result = document.createElement('div');
			result.id = "result";
			result.className = "choices";

			let hiddenTextBox = document.createElement('span');
			let shownTextBox = document.createElement('span');
			if (slave.custom.title === "") {
				hiddenTextBox.appendChild(
					App.UI.DOM.link(
						`Set a custom title for ${him} to address you as`,
						() => {
							jQuery('#result').empty().append(shownTextBox);
						}
					)
				);
				result.appendChild(hiddenTextBox);
				shownTextBox.textContent = `Custom title: `;
				shownTextBox.append(
					App.UI.DOM.makeTextBox(
						"",
						v => {
							slave.custom.title = v;
							jQuery('#result').empty().append(
								document.createTextNode(`${He}'ll try ${his} best to call you ${slave.custom.title}.`)
							);
							slave.custom.titleLisp = lispReplace(slave.custom.title);
						}
					)
				);
			} else {
				result.append(`${He}'s trying ${his} best to call you `);
				result.append(
					App.UI.DOM.makeTextBox(
						slave.custom.title,
						v => {
							slave.custom.title = v;
							jQuery('#result').empty().append(
								document.createTextNode(`${He}'ll try ${his} best to call you ${slave.custom.title}.`)
							);
							slave.custom.titleLisp = lispReplace(slave.custom.title);
						}
					)
				);
				result.appendChild(
					App.UI.DOM.link(
						` Stop using a custom title`,
						() => {
							jQuery('#result').empty().append(
								document.createTextNode(`${He} will no longer refer to you with a special title.`)
							);
							slave.custom.title = "";
							slave.custom.titleLisp = "";
						}
					)
				);
			}
			label.appendChild(result);
		} else {
			label.textContent = `You must break ${his} will further before ${he} will refer to you by a new title. `;
			if (SlaveStatsChecker.checkForLisp(slave)) {
				if (slave.custom.titleLisp && slave.custom.titleLisp !== "") {
					label.textContent += `For now, ${he} intends to keep calling you "${slave.custom.titleLisp}."`;
				}
			} else {
				if (slave.custom.title && slave.custom.title !== "") {
					label.textContent += `For now, ${he} intends to keep calling you "${slave.custom.title}."`;
				}
			}
		}
		playerTitle.appendChild(label);
		return playerTitle;
	}

	function slaveFullName() {
		let slaveFullNameNode = document.createElement('span');
		if (
			((slave.devotion >= -50 || slave.trust < -20) && (slave.birthName !== slave.slaveName)) ||
				(slave.devotion > 20 || slave.trust < -20)
		) {
			slaveFullNameNode.appendChild(slaveName());
			slaveFullNameNode.appendChild(slaveSurname());
		} else {
			slaveFullNameNode.textContent = `You must break ${his} will further before you can successfully force a new name on ${him}.`;
			slaveFullNameNode.className = "note";
		}

		return slaveFullNameNode;

		function slaveName() {
			const oldName = slave.slaveName;
			const oldSurname = slave.slaveSurname;
			// Slave Name
			let slaveNameNode = document.createElement('p');
			let label = document.createElement('div');
			let result = document.createElement('div');
			result.id = "result";
			result.className = "choices";
			const linkArray = [];

			label.append(`Change ${his} given name`);
			if (slave.birthName !== slave.slaveName) {
				label.append(` (${his} birth name was ${slave.birthName})`);
			}
			label.append(`: `);

			label.append(
				App.UI.DOM.makeTextBox(
					slave.slaveName,
					v => {
						slave.slaveName = v;
						updateName(slave, {oldName: oldName, oldSurname: oldSurname});
					},
					false,
				)
			);

			slaveNameNode.appendChild(label);

			if (slave.slaveName === slave.birthName) {
				linkArray.push(App.UI.DOM.disabledLink(`${He} has ${his} birth name`, [`Nothing to reset`]));
			} else {
				linkArray.push(App.UI.DOM.link(
					`Restore ${his} birth name`,
					() => {
						slave.slaveName = slave.birthName;
						updateName(slave, {oldName: oldName, oldSurname: oldSurname});
					},
					false,
				));
			}

			if (V.arcologies[0].FSPastoralist !== "unset") {
				if (slave.lactation > 0) {
					linkArray.push(chooseThreeNames(`Choose a random cow name for ${him}`, setup.cowSlaveNames, "cow-names"));
				}
			}
			if (V.arcologies[0].FSIntellectualDependency !== "unset") {
				if (slave.intelligence + slave.intelligenceImplant < -10) {
					linkArray.push(chooseThreeNames(`Give ${him} a random stripper given name`, setup.bimboSlaveNames, "bimbo-names"));
				}
			}
			if (V.arcologies[0].FSChattelReligionist !== "unset") {
				linkArray.push(chooseThreeNames(`Give ${him} a random devotional given name`, setup.chattelReligionistSlaveNames, "devotional-names"));
			}
			result.append(App.UI.DOM.generateLinksStrip(linkArray));
			slaveNameNode.appendChild(result);
			return slaveNameNode;

			function chooseThreeNames(title, array, id) {
				const el = document.createElement("span");
				el.id = id;
				el.append(
					App.UI.DOM.link(
						title,
						() => {
							linkGuts();
						}
					)
				);
				return el;
				function linkGuts() {
					// Randomize the array
					const shuffled = array.sort(() => 0.5 - Math.random());

					// Get the first three new names
					const names = [];
					for (let i = 0; names.length < 3; i++) {
						if (i > shuffled.length) {
							break;
						}
						if (shuffled[i] !== slave.slaveName) {
							names.push(shuffled[i]);
						}
					}

					// return the three names as links
					const nameLinks = [];
					for (const name of names) {
						nameLinks.push(
							App.UI.DOM.link(
								name,
								() => {
									slave.slaveName = name;
									updateName(slave, {oldName: oldName, oldSurname: oldSurname});
								}
							)
						);
					}
					nameLinks.push(
						App.UI.DOM.link(
							"...",
							() => {
								linkGuts();
							}
						)
					);
					jQuery(`#${id}`).empty().append(App.UI.DOM.generateLinksStrip(nameLinks));
				}
			}
		}

		function slaveSurname() {
			// Slave Surname
			const oldName = slave.slaveName;
			const oldSurname = slave.slaveSurname;
			const linkArray = [];
			let slaveSurnameNode = document.createElement('p');
			let label = document.createElement('div');
			let result = document.createElement('div');
			result.id = "result";
			result.className = "choices";

			label.append(`Change ${his} surname`);
			if (slave.birthSurname !== slave.slaveSurname) {
				label.append(` (${his} birth surname was ${slave.birthSurname})`);
			}
			label.append(`: `);

			label.append(
				App.UI.DOM.makeTextBox(
					slave.slaveSurname,
					v => {
						slave.slaveSurname = v;
						updateName(slave, {oldName: oldName, oldSurname: oldSurname});
					},
					false,
				)
			);

			slaveSurnameNode.appendChild(label);

			if (slave.slaveSurname === slave.birthSurname) {
				linkArray.push(
					App.UI.DOM.disabledLink(
						`Restore ${his} birth surname`,
						[`${He} has ${his} birth surname`]
					)
				);
			} else {
				linkArray.push(App.UI.DOM.link(
					` Restore ${his} birth surname`,
					() => {
						slave.slaveSurname = slave.birthSurname;
						updateName(slave, {oldName: oldName, oldSurname: oldSurname});
					},
					false,
				));
			}

			if (slave.slaveSurname) {
				linkArray.push(App.UI.DOM.link(
					`Take ${his} surname away`,
					() => {
						slave.slaveSurname = 0;
						updateName(slave, {oldName: oldName, oldSurname: oldSurname});
					},
					false,
				));
			}
			if (slave.relationship >= 5) {
				const spouse = getSlave(slave.relationshipTarget);
				if (spouse.slaveSurname && slave.slaveSurname !== spouse.slaveSurname) {
					const wifePronouns = getPronouns(spouse);
					linkArray.push(
						App.UI.DOM.link(
							`Give ${him} ${his} ${wifePronouns.wife}'s surname`,
							() => {
								slave.slaveSurname = spouse.slaveSurname;
								updateName(slave, {oldName: oldName, oldSurname: oldSurname});
							},
							false,
						)
					);
				}
			}
			if (slave.relationship === -3) {
				if (V.PC.slaveSurname && slave.slaveSurname !== V.PC.slaveSurname) {
					linkArray.push(
						App.UI.DOM.link(
							`Give ${him} your surname`,
							() => {
								slave.slaveSurname = V.PC.slaveSurname;
								updateName(slave, {oldName: oldName, oldSurname: oldSurname});
							},
							false,
						)
					);
				}
			}
			if (V.arcologies[0].FSRomanRevivalist !== "unset") {
				linkArray.push(
					App.UI.DOM.link(
						`Give ${him} a random full Roman name`,
						() => {
							slave.slaveName = setup.romanSlaveNames.random();
							slave.slaveSurname = setup.romanSlaveSurnames.random();
							updateName(slave, {oldName: oldName, oldSurname: oldSurname});
						},
						false,
					)
				);
			} else if (V.arcologies[0].FSAztecRevivalist !== "unset") {
				linkArray.push(
					App.UI.DOM.link(
						`Give ${him} a random full Aztec name`,
						() => {
							slave.slaveName = setup.aztecSlaveNames.random();
							slave.slaveSurname = 0;
							updateName(slave, {oldName: oldName, oldSurname: oldSurname});
						},
						false,
					)
				);
			} else if (V.arcologies[0].FSEgyptianRevivalist !== "unset") {
				linkArray.push(
					App.UI.DOM.link(
						`Give ${him} a random full ancient Egyptian name`,
						() => {
							slave.slaveName = setup.ancientEgyptianSlaveNames.random();
							slave.slaveSurname = 0;
							updateName(slave, {oldName: oldName, oldSurname: oldSurname});
						},
						false,
					)
				);
			} else if (V.arcologies[0].FSEdoRevivalist !== "unset") {
				linkArray.push(
					App.UI.DOM.link(
						`Give ${him} a random full feudal Japanese name`,
						() => {
							slave.slaveName = setup.edoSlaveNames.random();
							slave.slaveSurname = setup.edoSlaveSurnames.random();
							updateName(slave, {oldName: oldName, oldSurname: oldSurname});
						},
						false,
					)
				);
			}
			if (V.arcologies[0].FSDegradationist > -1) {
				linkArray.push(
					App.UI.DOM.link(
						`Give ${him} a degrading full name`,
						() => {
							DegradingName(slave);
							updateName(slave, {oldName: oldName, oldSurname: oldSurname});
						},
						false,
					)
				);
			}
			result.append(App.UI.DOM.generateLinksStrip(linkArray));
			slaveSurnameNode.appendChild(result);
			return slaveSurnameNode;
		}
		function updateName(slave, {oldName: oldName, oldSurname: oldSurname}) {
			App.UI.SlaveInteract.rename(slave, {oldName: oldName, oldSurname: oldSurname});
			refresh();
		}
	}

	function hair() {
		let hairNode = new DocumentFragment();
		hairNode.appendChild(hairStyle());
		hairNode.appendChild(hairColor());
		return hairNode;

		function hairStyle() {
			let hairStyleNode = document.createElement('p');
			let label = document.createElement('div');
			label.append(`Custom hair description: `);

			label.append(
				App.UI.DOM.makeTextBox(
					slave.hStyle,
					v => {
						slave.hStyle = v;
						refresh();
					}
				)
			);

			switch (slave.hStyle) {
				case "tails":
				case "dreadlocks":
				case "cornrows":
					label.append(` "${His} hair is in ${slave.hStyle}."`);
					break;
				case "ponytail":
					label.append(` "${His} hair is in a ${slave.hStyle}."`);
					break;
				default:
					label.append(` "${His} hair is ${slave.hStyle}."`);
					break;
			}
			hairStyleNode.appendChild(label);

			let choices = document.createElement('div');
			choices.className = "choices";
			choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short, uncapitalized and unpunctuated description; for example: 'back in a ponytail'`, 'note'));
			hairStyleNode.appendChild(choices);
			return hairStyleNode;
		}

		function hairColor() {
			let hairStyleNode = document.createElement('p');
			let label = document.createElement('div');
			label.append(`Custom hair color: `);
			label.append(
				App.UI.DOM.makeTextBox(
					slave.hColor,
					v => {
						slave.hColor = v;
						refresh();
					}
				)
			);
			label.append(` "${His} hair is ${slave.hColor}."`);
			hairStyleNode.appendChild(label);

			let choices = document.createElement('div');
			choices.className = "choices";
			choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short, uncapitalized and unpunctuated description; for example: 'black with purple highlights'`, 'note'));
			hairStyleNode.appendChild(choices);
			return hairStyleNode;
		}
	}

	function eyeColor() {
		let eyeColorNode = document.createElement('p');
		let label = document.createElement('div');
		if (getLenseCount(slave) > 0) {
			label.textContent = `${He} is wearing ${App.Desc.eyesColor(slave, "", "lense", "lenses")}.`;
		} else {
			label.textContent = `${He} has ${App.Desc.eyesColor(slave)}.`;
		}
		eyeColorNode.appendChild(label);

		let choices = document.createElement('div');
		choices.className = "choices";

		let eye;

		if (hasLeftEye(slave)) {
			eye = document.createElement('div');
			eye.append(`Custom left eye color: `);
			eye.append(
				App.UI.DOM.makeTextBox(
					slave.eye.left.iris,
					v => {
						slave.eye.left.iris = v;
						refresh();
					}
				)
			);
			choices.appendChild(eye);
		}
		if (hasRightEye(slave)) {
			eye = document.createElement('div');
			eye.append(`Custom right eye color: `);
			eye.append(
				App.UI.DOM.makeTextBox(
					slave.eye.right.iris,
					v => {
						slave.eye.right.iris = v;
						refresh();
					}
				)
			);
			choices.appendChild(eye);
		}
		choices.appendChild(App.UI.DOM.makeElement('span', `For best results, use a short, uncapitalized and unpunctuated description; for example: 'blue'`, 'note'));
		eyeColorNode.appendChild(choices);
		return eyeColorNode;
	}

	function customTattoo() {
		let el = document.createElement('p');
		el.append(`Change ${his} custom tattoo: `);
		el.appendChild(App.UI.DOM.makeTextBox(
			slave.custom.tattoo,
			v => {
				slave.custom.tattoo = v;
				refresh();
			}));

		let choices = document.createElement('div');
		choices.className = "choices";
		choices.appendChild(App.UI.DOM.makeElement('span', `For best results, use complete sentences; for example: '${He} has blue stars tattooed along ${his} cheekbones.'`, 'note'));
		el.appendChild(choices);

		return el;
	}

	function customOriginStory() {
		let el = document.createElement('p');
		el.append(`Change ${his} origin story: `);
		el.appendChild(App.UI.DOM.makeTextBox(
			slave.origin,
			v => {
				slave.origin = v;
				refresh();
			}));

		let choices = document.createElement('div');
		choices.className = "choices";
		choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use complete, capitalized and punctuated sentences; for example: '${He} followed you home from the pet store.'`, 'note'));
		el.appendChild(choices);

		return el;
	}

	function customDescription() {
		let el = document.createElement('p');
		el.append(`Change ${his} custom description: `);
		el.appendChild(
			App.UI.DOM.makeTextBox(
				pronounsForSlaveProp(slave, slave.custom.desc),
				v => {
					slave.custom.desc = v;
					refresh();
				}
			)
		);

		let choices = document.createElement('div');
		choices.className = "choices";
		choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use complete, capitalized and punctuated sentences; for example: '${He} has a beauty mark above ${his} left nipple.'`, 'note'));
		el.appendChild(choices);

		return el;
	}

	function customLabel() {
		let el = document.createElement('p');
		el.append(`Change ${his} custom label: `);
		el.appendChild(App.UI.DOM.makeTextBox(
			slave.custom.label,
			v => {
				slave.custom.label = v;
				refresh();
			}));

		let choices = document.createElement('div');
		choices.className = "choices";
		choices.appendChild(App.UI.DOM.makeElement('span', ` For best results, use a short phrase; for example: 'Breeder.'`, 'note'));
		el.appendChild(choices);

		return el;
	}

	function customSlaveImage() {
		let el = document.createElement('p');
		el.append(`Assign ${him} a custom image: `);

		const textbox = document.createElement("INPUT");
		textbox.id = "customImageValue";
		el.appendChild(textbox);

		let kbd = document.createElement('kbd');
		let select = document.createElement('SELECT');
		select.id = "customImageFormatSelector";
		select.style.border = "none";

		let filetypes = [
			"png",
			"jpg",
			"gif",
			"webm",
			"webp",
			"mp4"
		];

		filetypes.forEach((fileType) => {
			let el = document.createElement('OPTION');
			el.value = fileType;
			el.text = fileType.toUpperCase();
			select.add(el);
		});
		kbd.append(`.`);
		kbd.appendChild(select);
		el.appendChild(kbd);

		el.appendChild(
			App.UI.DOM.link(
				` Reset`,
				() => {
					slave.custom.image = null;
					refresh();
					App.Art.refreshSlaveArt(slave, 3, "art-frame");
				},
			)
		);

		let choices = document.createElement('div');
		choices.className = "choices";
		let note = document.createElement('span');
		note.className = "note";
		note.append(`Place file in the `);

		kbd = document.createElement('kbd');
		kbd.append(`resources`);
		note.appendChild(kbd);

		note.append(` folder. Choose the extension from the menu first, then enter the filename in the space and press enter. For example, for a file with the path `);

		kbd = document.createElement('kbd');
		kbd.textContent = `\\bin\\resources\\headgirl.`;
		let filetypeDesc = document.createElement('span');
		filetypeDesc.id = "customImageFormatValue";
		filetypeDesc.textContent = "png";
		kbd.appendChild(filetypeDesc);
		note.appendChild(kbd);

		note.append(`, choose `);

		kbd = document.createElement('kbd');
		kbd.textContent = `PNG`;
		note.appendChild(kbd);

		note.append(` then enter `);

		kbd = document.createElement('kbd');
		kbd.textContent = `headgirl`;
		note.appendChild(kbd);

		note.append(`.`);
		choices.appendChild(note);
		el.appendChild(choices);

		jQuery(function() {
			function activeSlave() {
				return slave;
			}

			jQuery("#customImageFormatValue").text(activeSlave().custom.image === null ? "png" : activeSlave().custom.image.format);
			jQuery("#customImageValue")
				.val(activeSlave().custom.image === null ?
					"" : activeSlave().custom.image.filename)
				.on("change", function(e) {
					const c = activeSlave().custom;
					if (this.value.length === 0) {
						c.image = null;
					} else {
						if (c.image === null) {
							c.image = {
								filename: this.value,
								format: jQuery("#customImageFormatSelector").val()
							};
							App.Art.refreshSlaveArt(slave, 3, "art-frame");
						} else {
							c.image.filename = this.value;
							App.Art.refreshSlaveArt(slave, 3, "art-frame");
						}
					}
				});
			jQuery("#customImageFormatSelector")
				.val(activeSlave().custom.image ? activeSlave().custom.image.format : "png")
				.on("change", function(e) {
					if (activeSlave().custom.image !== null) {
						activeSlave().custom.image.format = this.value;
					}
					jQuery("#customImageFormatValue").text(this.value);
				});
		});
		return el;
	}

	function customHairImage() {
		let el = document.createElement('p');
		if (V.seeImages === 1 && V.imageChoice === 1) {
			if (!slave.custom.hairVector) {
				slave.custom.hairVector = 0;
			}
			el.append(`Assign ${him} a custom hair SVG image: `);

			el.appendChild(App.UI.DOM.makeTextBox(
				slave.custom.hairVector,
				v => {
					slave.custom.hairVector = v;
					refresh();
				}));

			el.appendChild(
				App.UI.DOM.link(
					` Reset`,
					() => {
						slave.custom.hairVector = 0;
						refresh();
						App.Art.refreshSlaveArt(slave, 3, "art-frame");
					},
				)
			);
		}

		return el;
	}

	function refresh() {
		jQuery("#content-custom").empty().append(App.UI.SlaveInteract.custom(slave));
	}
};


code:
App.UI.SlaveInteract.description = function(slave) {
	const el = new DocumentFragment();
	const descriptionLink = document.createElement("div");
	descriptionLink.style.fontStyle = "italic";
	descriptionLink.id = "description-link";
	if (V.seeDetails === 1) {
		descriptionLink.append(showOptions());
		el.append(descriptionLink);

		const descriptionOptions = document.createElement("div");
		descriptionOptions.id = "description-options";
		el.append(descriptionOptions);

		el.append(App.Desc.longSlave(slave, {noArt: true}));
	} else {
		descriptionLink.append(
			App.UI.DOM.link(
				"Show descriptions",
				() => {
					V.seeDetails = 1;
				},
				[],
				"Slave Interact"
			)
		);
		el.append(descriptionLink);
	}

	return el;

	function showOptions() {
		return App.UI.DOM.link(
			"Description Options",
			() => {
				jQuery("#description-link").empty().append(hideOptions());
				jQuery("#description-options").empty().append(App.UI.DOM.renderPassage("Description Options"));
			}
		);
	}

	function hideOptions() {
		return App.UI.DOM.link(
			"Description Options",
			() => {
				jQuery("#description-link").empty().append(showOptions());
				jQuery("#description-options").empty().append();
			}
		);
	}
};


code:
/**
 * @returns {HTMLParagraphElement}
 */
App.UI.SlaveInteract.family = function() {
	let element;
	const p = document.createElement("p");
	p.id = "family";

	element = document.createElement("div");
	element.id = "family-tree";
	p.append(element);

	element = document.createElement("span");
	element.id = "family-tree-link";
	p.append(element);

	return p;
};


code:
App.UI.SlaveInteract.financial = function(slave) {
	const el = new DocumentFragment();
	let r;
	let linkArray;
	const {
		He, His,
		his, him
	} = getPronouns(slave);
	if (V.studio === 1) {
		App.UI.DOM.appendNewElement("h3", el, "Media");
		slave.porn.spending = Math.clamp(Math.ceil(slave.porn.spending / 1000) * 1000, 0, 5000);

		if (slave.porn.prestige === 3) {
			App.UI.DOM.appendNewElement("div", el, `${He} is so prestigious in the realm of ${slave.porn.fameType} porn that ${his} fame is self-sustaining.`, "note")
		} else if (slave.porn.feed === 0) {
			r = [];
			r.push(`The media hub is not releasing highlights of ${his} sex life.`);
			r.push(
				App.UI.DOM.link(
					"Release",
					() => {
						slave.porn.feed = 1;
						refresh();
					}
				)
			);
			App.Events.addNode(el, r, "div");
		} else {
			r = [];
			r.push(`The media hub is releasing highlights of ${his} sex life`);
			if (slave.porn.spending < 500) {
				r.push(`to those who can find it.`);
			} else if (slave.porn.spending < 2500) {
				r.push(`on several websites.`);
			} else if (slave.porn.spending > 5000) {
				r.push(`through your old distributor.`);
			} else {
				r.push(`on many websites.`);
			}
			if (slave.porn.spending === 0) {
				linkArray = [];
				linkArray.push(
					App.UI.DOM.link(
						"Halt",
						() => {
							slave.porn.feed = 0;
							slave.porn.focus = "none";
							refresh();
						}
					)
				);
				linkArray.push(
					App.UI.DOM.link(
						"Publicize",
						() => {
							slave.porn.spending += 1000;
							refresh();
						},
						[],
						"",
						`Will cost ${cashFormat(1000)} weekly.`
					)
				);
				r.push(App.UI.DOM.generateLinksStrip(linkArray));
				App.Events.addNode(el, r, "div");
			} else {
				r.push(
					App.UI.DOM.makeTextBox(
						slave.porn.spending,
						v => {
							slave.porn.spending = v;
						},
						true
					)
				);
				r.push(`weekly is spent to publicize them.`);

				linkArray = [];
				linkArray.push(
					App.UI.DOM.link(
						"Halt",
						() => {
							slave.porn.spending = 0;
							slave.porn.feed = 0;
							slave.porn.focus = "none";
							V.PCSlutContacts = 1;
							refresh();
						}
					)
				);
				if (slave.porn.spending <= 4000) {
					linkArray.push(
						App.UI.DOM.link(
							"Increase",
							() => {
								slave.porn.spending += 1000;
								refresh();
							},
							[],
							"",
							`Spending more than ${cashFormat(5000)} weekly will have no effect.`
						)
					);
				}
				linkArray.push(
					App.UI.DOM.link(
						"Decrease",
						() => {
							slave.porn.spending -= 1000;
							refresh();
						},
						[],
						"",
						`Will cost ${cashFormat(1000)} weekly.`
					)
				);
				r.push(App.UI.DOM.generateLinksStrip(linkArray));
				App.Events.addNode(el, r, "div");

				if (V.PC.career === "escort") {
					r = [];
					r.push(`You retain some contacts from your past life in the industry that may be willing to cut you some discounts should you return to it.`);
					if (V.PCSlutContacts !== 2) {
						r.push(`You are not baring your body for all to see.`);
						r.push(
							App.UI.DOM.link(
								`Star in porn for a discount`,
								() => {
									V.PCSlutContacts = 2;
									refresh();
								}
							)
						);
					} else {
						r.push(`You are starring in hardcore porn once more.`);
						r.push(
							App.UI.DOM.link(
								`Stop doing porn for a discount`,
								() => {
									V.PCSlutContacts = 1;
									refresh();
								}
							)
						);
					}
					App.Events.addNode(el, r, "div");
				}
			}
			if (V.studioFeed === 1) {
				r = [];
				if (slave.porn.viewerCount < 100) {
					r.push(`${He} lacks the fame in porn needed to discern what ${his} feed is getting tagged as.`);
				} else {
					if (slave.porn.prestige > 0) {
						r.push(`${He} is known for ${slave.porn.fameType}${(slave.porn.prestige > 1) ? ` and viewers have grown to expect it from ${him}` : ``}.`);
					}
					if (slave.porn.focus === "none") {
						r.push(`You are allowing ${his} viewers to guide the direction of ${his} content.`);
					} else {
						r.push(`You are focusing attention on the ${slave.porn.focus} aspect of ${his} content.`);
					}
					r.push(App.Porn.genreChoiceLinks("Slave Interact", slave));
				}
				App.Events.addNode(el, r, "div");
			}
		}
	}
	App.UI.DOM.appendNewElement("h3", el, "Financial");
	App.UI.DOM.appendNewElement("p", el, slaveExpenses(slave));

	r = [];
	linkArray = [];
	if (V.slaveCostFactor > 1) {
		r.push(App.UI.DOM.makeElement("span", `The slave market is bullish; the price of slaves is high.`, "yellow"));
	} else if ((V.slaveCostFactor < 1)) {
		r.push(App.UI.DOM.makeElement("span", `The slave market is bearish; the price of slaves is low.`, "yellow"));
	}

	if (V.slaves.length < 2) {
		r.push("You cannot sell your last save");
	} else if (slave.origin === "You bought ${him} from a body dump, completely broken." && (V.week - slave.weekAcquired <= 8)) {
		r.push(`A discarded slave must be kept for at least two months to ensure health before being sold.`);
	} else if (slave.accent > 3) {
		r.push(`${His} lack of language and basic life skills is a red sign to most slave appraisers. ${He} must not act like a child to be sold without raising suspicion.`);
	} else {
		linkArray.push(
			App.UI.DOM.link(
				`Sell ${him}`,
				() => {
					cashX(-500, "personalBusiness", slave);
				},
				[],
				"Sell Slave",
				`Listing ${him} for sale will cost ${cashFormat(500)}`
			)
		);
		if ((V.seeAge !== 0) && (slave.indenture < 1)) {
			linkArray.push(
				App.UI.DOM.link(
					`Retire ${him}`,
					() => {
						V.retiree = slave.ID;
						V.retired = 1;
					},
					[],
					"SE retirement",
				)
			);
		}
		linkArray.push(
			App.UI.DOM.passageLink(
				`Discard ${him}`,
				"Discard Confirm",
			)
		);
		if (V.seeExtreme === 1 && V.arcologies[0].FSPaternalist === "unset" && V.cheatMode === 1) {
			linkArray.push(
				App.UI.DOM.passageLink(
					`Threaten ${his} life`,
					"KillSlave",
				)
			);
		}
	}
	linkArray.push(
		App.UI.DOM.passageLink(
			`Export this slave`,
			"Export Slave",
		)
	);
	if (V.cheatMode) {
		linkArray.push(
			App.UI.DOM.passageLink(
				`Import a slave`,
				"Import Slave",
			)
		);
	}
	r.push(App.UI.DOM.generateLinksStrip(linkArray));
	App.Events.addNode(el, r, "p");
	return el;

	function refresh() {
		jQuery("#content-financial").empty().append(App.UI.SlaveInteract.financial(slave));
	}
};


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @returns {Node}
 */
App.UI.SlaveInteract.modify = function(slave) {
	const {he, his} = getPronouns(slave);
	let el = new DocumentFragment();

	const isAgent = [Job.AGENT, Job.AGENTPARTNER].includes(slave.assignment);

	App.UI.DOM.appendNewElement('p', el, isAgent ? "Recall your agent to modify them." : "Take slave to another room.", "scene-intro");

	if (isAgent) {
		return el;
	}

	/**
	 * Create a link with a note to send a  slave to a specific room
	 * @param {Node} c
	 * @param {string} caption
	 * @param {string} passage
	 * @param {string} note
	 * @param {function ():void} [handler]
	 */
	function makeRoomLink(c, caption, passage, note, handler = () => {}) {
		const res = document.createElement('div');
		c.appendChild(res);
		res.appendChild(App.UI.DOM.link(caption, handler, [], passage));
		App.UI.DOM.appendNewElement('span', res, note, "note");
		return res;
	}

	makeRoomLink(el, "Auto salon", "Salon", ' Modify hair (color, length, style), nails, and even skin color.');

	makeRoomLink(el, "Body mod studio", "Body Modification", ' Mark your slave with piercings, tattoos, brands or even scars.',
		() => {
			V.degradation = 0;
			V.tattooChoice = undefined;
		},
	);

	makeRoomLink(el, "Remote surgery", "Remote Surgery", ` Surgically modify your slave with state of the art plastic surgery and more. Alter ${his} senses, skeletal structure, organs, and even more.`);

	// Prosthetics
	if (V.prostheticsUpgrade > 0) {
		makeRoomLink(el, "Configure cybernetics", "Prosthetics Configuration", ` Configure prosthetics, if ${he} has been surgically implanted with interfaces that support it.`,
			() => {
				V.prostheticsConfig = "main";
			}
		);
	}

	// Analyze Pregnancy
	if (V.pregnancyMonitoringUpgrade > 0) {
		makeRoomLink(el, "Internal scan", "Analyze Pregnancy", ` Full scan of abdomen and reproductive organs.`);
	}

	return el;
};


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @returns {HTMLParagraphElement}
 */
App.UI.SlaveInteract.navigation = function(slave) {
	const p = document.createElement("p");
	const linkArray = [];
	p.classList.add("center");

	if (V.cheatMode) {
		linkArray.push(App.UI.DOM.passageLink("Cheat Edit Slave", "MOD_Edit Slave Cheat", () => { V.cheater = 1; }));
		linkArray.push(App.UI.DOM.passageLink("Cheat Edit Slave Alternative", "MOD_Edit Slave Cheat New", () => { V.cheater = 1; }));
		App.UI.DOM.appendNewElement("div", p, App.UI.DOM.generateLinksStrip(linkArray), "note");
	}

	App.UI.DOM.appendNewElement("span", p, App.UI.Hotkeys.hotkeys("prev-slave"), "hotkey");
	const prevSpan = App.UI.DOM.makeElement("span", App.UI.DOM.passageLink("Prev", "Slave Interact",
		() => { V.AS = App.UI.SlaveInteract.placeInLine(slave)[0]; }), "adjacent-slave");
	prevSpan.id = "prev-slave";
	p.append(" ", prevSpan);

	const centerSpan = document.createElement("span");
	centerSpan.classList.add("interact-name");

	App.UI.DOM.appendNewElement("span", centerSpan, slave.slaveName, "slave-name");

	const favSpan = document.createElement("span");
	favSpan.id = "fav-span";
	favSpan.append(favLink());

	centerSpan.append(" ", favSpan);
	p.append(centerSpan);

	const nextSpan = App.UI.DOM.makeElement("span", App.UI.DOM.passageLink("Next", "Slave Interact",
		() => { V.AS = App.UI.SlaveInteract.placeInLine(slave)[1]; }), "adjacent-slave");
	nextSpan.id = "next-slave";
	p.append(nextSpan, " ");
	App.UI.DOM.appendNewElement("span", p, App.UI.Hotkeys.hotkeys("next-slave"), "hotkey");

	return p;

	function favLink() {
		if (V.favorites.includes(slave.ID)) {
			const link = App.UI.DOM.link(String.fromCharCode(0xe800), () => {
				V.favorites.delete(slave.ID);
				App.UI.DOM.replace("#fav-span", favLink());
			});
			link.classList.add("icons", "favorite");
			return link;
		} else {
			const link = App.UI.DOM.link(String.fromCharCode(0xe801), () => {
				V.favorites.push(slave.ID);
				App.UI.DOM.replace("#fav-span", favLink());
			});
			link.classList.add("icons", "not-favorite");
			return link;
		}
	}
};