/**
 * Creates a full report of the Nursery
 * @returns {string}
 */
// TODO: refactor this
App.Facilities.Nursery.nurseryReport = function nurseryReport() {
	"use strict";

	let r = ``;

	const
		Matron = getSlave(V.Matron.ID),
		arcology = V.arcologies[0];

	let
		NL = App.Utils.jobForAssignment(Job.NURSERY).employeesIDs().size,
		healthBonus = 0,
		trustBonus = 0,
		idleBonus = 0,
		devBonus = 0;

	if (V.nurseryDecoration !== "standard") {
		devBonus = 1;
	}

	if (Matron) {
		const
			{
				he, him, his, himself, He, His
			} = getPronouns(Matron);

		if (Matron.health.condition < 100) {
			improveCondition(Matron, 20);
		}
		if (Matron.devotion <= 60) {
			Matron.devotion++;
		}
		if (Matron.trust <= 60) {
			Matron.trust++;
		}
		if (Matron.rules.living !== "luxurious") {
			Matron.rules.living = "luxurious";
		}

		let FLsFetish = 0;
		/*
		if (Matron.fetishStrength <= 95) {
			if (Matron.fetish !== "caring") {
				if (fetishChangeChance(Matron) > jsRandom(0, 100)) {
					FLsFetish = 1, Matron.fetishKnown = 1, Matron.fetish = "caring";
				}
			} else if (!Matron.fetishKnown) {
				FLsFetish = 1, Matron.fetishKnown = 1;
			} else {
				FLsFetish = 2, Matron.fetishStrength += 4;
			}
		}
		*/
		if (Matron.fetish === "none" || Matron.fetish === "caring") {
			devBonus++;
		}

		Matron.devotion += devBonus;

		if (V.Matron !== Matron) {
			V.Matron = Matron;
		}

		r += `&nbsp;&nbsp;&nbsp;&nbsp;${SlaveFullName(Matron)} is serving as ${V.nurseryName} matron. `;

		if (Matron.relationship === -3 && Matron.devotion > 50) {
			r += `${He} tries ${his} best to ${V.nurseryChildren ? `properly take care of and raise the children` : `look after ${V.nurseryName} and keep it tidy and running smoothly`}. `;
		}

		if (FLsFetish === 1) {
			r += `${He} ${V.nurseryChildren ? `seems to have a real soft spot for children, and enjoys working with the child${V.nurseryChildren > 1 ? `ren` : ``} in ${V.nurseryName} and raising ${V.nurseryChildren > 1 ? `them` : V.cribs[0].genes === "XX" ? `her` : `him`} to be ${V.nurseryChildren > 1 ? `good slaves` : `a good slave`}` : ``/* TODO: */}. ${He} finds real satisfaction in helping your slaves find sexual gratification, and <span class="lightsalmon">becomes more caring.</span> `;
		} else if (FLsFetish === 2) {
			r += `Every new slave in the nursery is a new person ${he} gets to connect with and serve. Sexually. <span class='lightsalmon'>${He} becomes more caring.</span>`;	// TODO:
		}

		// TODO:
		if (setup.matronCareers.includes(Matron.career)) {
			r += `${He} has experience with childcare from ${his} life before ${he} was a slave, making ${him} better at properly raising children, and giving ${him} a better chance of softening flaws into beneficial quirks. `;
			idleBonus++;
		} else if (Matron.skill.matron >= V.masteredXP) {
			r += `${He} has experience with childcare from working for you, making ${him} better at properly raising children, and giving ${him} a better chance of softening flaws into beneficial quirks. `;
			idleBonus++;
		} else {
			Matron.skill.matron += jsRandom(1, (Matron.intelligence + 4) * 2);
		}

		// TODO:
		if (Matron.fetish === "none") {
			r += `${Matron.slaveName} respects the slaves working in the nursery, allowing them to care for the children more effectively. `;
			idleBonus++;
		} else if (Matron.fetish === "dom") {
			r += `${Matron.slaveName} enjoys being able to have control over the nannies. `;
			idleBonus++;
		} else if (Matron.fetishKnown) {
			r += `${Matron.slaveName} can't keep ${his} hands to ${himself}, preventing the slaves in the nursery from relaxing completely. `;
		}

		// TODO:
		if (Matron.visualAge > 35) {
			r += `${His} apparent maturity encourages the slaves in the nursery to relax and pour out their troubles to ${him}. `;
		}

		// TODO:
		if (Matron.intelligence > 0) {
			r += `${He}'s so intelligent ${he} can suss out the cause of slaves' emotional issues and counsel them effectively. `;
		}

		// TODO: write more

		if (NL < V.nursery) {
			let seed = jsRandom(1, 10) + ((V.nursery - NL) * (jsRandom(150, 170) + (idleBonus * 10)));
			cashX(seed, "nursery", Matron);
			r += `<br>&nbsp;&nbsp;&nbsp;&nbsp;Since ${he} doesn't have enough children to occupy all ${his} time, ${V.nurseryName} takes in citizens' children on a contract basis and ${he} cares for them too, earning <span class='yellowgreen'>${cashFormat(seed)}.</span> `;
		}

		if (arcology.FSRepopulationFocus > 0 && V.nurseryBabies > 0) {
			r += `Society <span class='green'>loves</span> the way you are raising more children for ${arcology.name}. `;
			FSChange("Repopulationist", 2);
		}

		if (NL > 0) {
			r += `<br><br>`;
		}
	}

	if (NL > 0) {
		r += `&nbsp;&nbsp;&nbsp;&nbsp;<strong>${NL > 1 ? `There are ${NL} slaves` : `There is one slave`} working in ${V.nurseryName}.</strong> `;
		if (arcology.FSRepopulationFocus > 0 && V.nurseryBabies > 0) {
			r += `Society <span class="green">approves</span> of your bringing more children into this world. `;
		} else if (arcology.FSGenderFundamentalist > 0) {
			r += `Society <span class="green">approves</span> of your assigning slaves to a traditionally feminine role. `;
		}
	}

	if (Matron) {
		V.i = V.slaveIndices[Matron.ID];
		if (V.showEWD) {
			// TODO: all this
			r += `<br><br>`;
			/* 000-250-006 */
			if (V.seeImages && V.seeReportImages) {
				r += `<div class="imageRef medImg">${SlaveArt(Matron, 2, 0)}</div>`;
			}
			/* 000-250-006 */
			r += `<strong><u><span class="pink">${SlaveFullName(Matron)}</span></u></strong> is serving as the Matron in ${V.nurseryName}.`;
			r += `${App.SlaveAssignment.choosesOwnClothes(Matron)}`;
			r += `<<include "SA rules">>`;
			r += `<<include "SA diet">>`;
			r += `<<include "SA long term effects">>`;
			r += `${App.SlaveAssignment.drugs(Matron)}`;
			r += `<<include "SA relationships">>`;
			r += `<<include "SA rivalries">>`;
			r += `<br><<include "SA devotion">>`;
		} else {
			r += `<<silently>>
			${App.SlaveAssignment.choosesOwnClothes(Matron)};
			<<include "SA rules">>
			<<include "SA diet">>
			<<include "SA long term effects">>
			${App.SlaveAssignment.drugs(Matron)};
			<<include "SA relationships">>
			<<include "SA rivalries">>
			<<include "SA devotion">>
			<</silently>>`;
		}
	}

	for (const slave of App.Utils.sortedEmployees(App.Utils.jobForAssignment(Job.NURSERY))) {
		V.i = V.slaveIndices[slave.ID];

		slave.devotion += devBonus, slave.trust += trustBonus;
		improveCondition(slave, healthBonus);

		// TODO: rework these
		if (slave.devotion < 60 && slave.trust < 60) {
			slave.devotion++, slave.trust++;
		} else if (slave.devotion < 40) {
			slave.devotion += 10;
		} else if (slave.trust < 40) {
			slave.trust += 10;
		}

		// TODO: rework this
		if (V.nurseryUpgrade === 1 && slave.health.condition < 20) {
			improveCondition(slave, 3);
		}

		// TODO:
		switch (V.nurseryDecoration) {
			case "Repopulationist":
				slave.rules.living = "luxurious";
				break;
			case "Degradationist":
				slave.rules.living = "spare";
				break;
			default:
				slave.rules.living = "normal";
				break;
		}

		// TODO:
		if (V.showEWD) {
			const
				He = slave.genes === "XX" ? `She` : `He`;

			r += `<br><br>`;
			/* 000-250-006 */
			if (V.seeImages && V.seeReportImages) {
				r += `<div class="imageRef smlImg">${SlaveArt(slave, 0, 0)}</div>`;
			}
			/* 000-250-006 */
			r += `<strong><u><span class="pink">${SlaveFullName(slave)}</span></u></strong>`;
			if (slave.choosesOwnAssignment === 2) {
				r += `${choosesOwnJob(slave)}`;
			} else {
				r += ` is working in ${V.nurseryName}. `;
			}
			// TODO: clean this mess up
			r += `<br>&nbsp;&nbsp;&nbsp;&nbsp;${He} ${App.SlaveAssignment.nanny(slave)}<br>&nbsp;&nbsp;&nbsp;`;
			r += `${App.SlaveAssignment.choosesOwnClothes(slave)} ${saRules(slave)}`;
			r += `<<include "SA diet">>`;					// TODO:
			r += `<<include "SA long term effects">>`;		// TODO:
			r += `${App.SlaveAssignment.drugs(slave)}`;						// TODO:
			r += `<<include "SA relationships">>`;			// TODO:
			r += `<<include "SA rivalries">>`;				// TODO:
			r += `<br><<include "SA devotion">>`;			// TODO:
		} else {
			r += `<<silently>>`;
			r += `${choosesOwnJob(slave)} ${App.SlaveAssignment.nanny(slave)} ${App.SlaveAssignment.choosesOwnClothes(slave)} ${saRules(slave)}`;
			r += `<<include "SA diet">>`;
			r += `<<include "SA long term effects">>`;
			r += `${App.SlaveAssignment.drugs(slave)}`;
			r += `<<include "SA relationships">>`;
			r += `<<include "SA rivalries">>`;
			r += `<<include "SA devotion">>`;
			r += `<</silently>>`;
		}
	}

	if (NL > 0 || Matron) {
		r += `<br><br>`;
	}

	function choosesOwnJob(slave) {
		let r = ``;

		if (V.universalRulesAssignsSelfFacility && slave.devotion > 50 && canWalk(slave) && canSee(slave) && slave.sexualQuirk === "caring" && V.nurseryNannies > NL) {
			slave.choosesOwnAssignmentText += ` enjoys taking care of children, so ${he} decides to work in ${V.nurseryName}. `;
			r = slave.choosesOwnAssignmentText;
			assignJob(slave, Job.NURSERY);
		}

		return r;
	}

	// function diet(slave) {
	// 	let r = ``;

	// 	return r;
	// }

	// function longTermEffects(slave) {
	// 	let r = ``;

	// 	return r;
	// }

	// function drugs(slave) {
	// 	let r = ``;

	// 	return r;
	// }

	// function relationships(slave) {
	// 	let r = ``;

	// 	return r;
	// }

	// function rivalries(slave) {
	// 	let r = ``;

	// 	return r;
	// }

	// function devotion(slave) {
	// 	let r = ``;

	// 	return r;
	// }

	return r;
};

src/facilities/nursery/widgets/reports/nurseryReport.js