<!DOCTYPE html>
<html>
	<head>
		<script src="/js/main" type="module"></script>
		<style id="styles">
			@keyframes fade-blink {
				0% { opacity: 100%; }
				100% { opacity: 0%; }
			}

			#message-modal.error {
				border: 2px solid red;
				background: #fff0f0;
			}

			#message-modal-content {
				text-align: center;
			}

			#message-modal-content p {
				font-size: 150%;
			}

			#message-modal.animate #message-modal-content {
				animation: fade-blink 1s ease-in-out infinite alternate;
			}

			input[type=email]:invalid {
				background: #ff8080;
			}

			.container.dialog {
				display: flex;
				width: 30em;
				max-width: 100vw;
				justify-content: center;
				align-content: center;
				text-align: center;
				flex-direction: column;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
			}

			.container > ol {
				margin-left: 1em;
			}

			hr {
				width: 100%;
			}

			form {
				display: flex;
				justify-content: center;
				align-content: center;
				flex-direction: column;
			}

			table {
				display: block;
				padding: 1em;
				border-collapse: collapse;
			}

			td {
				padding: 0.5ex 1ch;
			}
			td:not(:last-child) {
				border-right: 1px dashed black;
			}
			tr:not(:last-child) {
				border-bottom: 1px dashed black;
			}
			thead > tr  {
				border-bottom: 1px solid black;
			}

			.cwts-container {
				display: flex;
				text-align: left;
				flex-flow: row wrap;
			}

			.cwts-container div {
				min-width: 33%;
			}

			.settings-container {
				margin: 2em;
			}

			.settings-container form {
				display: block;
			}

			.disabled {
				color: grey;
				font-style: italic;
			}
		</style>

        <template id="tpl-fenix-style">
            <style>
                body { font-size: 300%; }
                input { font-size: 100%; }
            </style>
        </template>

		<template id="tpl-desktop-signedin">
			<div class="container dialog">
				successfully signed in!
			</div>
		</template>

		<template id="tpl-desktop-deleted">
			<div class="container dialog">
				account has been deleted.
			</div>
		</template>

		<template id="btpl-credentials">
			<form>
				<label for="email">email</label>
				<input id="email" type="email" name="email" maxlength="256">
				<label for="password">password</label>
				<input id="password" type="password" name="password" minlength="8" maxlength="256">
				<input type="submit" name="submit">
			</form>
		</template>

		<template id="tpl-desktop-signup">
			<div class="container dialog">
				<credentials-form submit-text="sign up"></credentials-form>
			</div>
		</template>

		<template id="tpl-desktop-signup-unverified">
			<div class="container dialog">
				<p>signup completed! please verify your account by clicking the
					link in the email you've just received.</p>
				<p>if you haven't received anything, go to Settings/Sync and resend
					the verification code.</p>
			</div>
		</template>

		<template id="tpl-desktop-signin">
			<div class="container dialog">
				<credentials-form submit-text="sign in"></credentials-form>
				<div>
					<a href="#/signup" class="_signup">sign up</a> |
					<a href="#/reset-password" class="_reset">reset password</a>
				</div>
			</div>
		</template>

		<template id="tpl-desktop-signin-confirm">
			<div class="container dialog">
				<p>signin completed! please verify your session by copying the code
					you've just received as an email into this box.</p>
				<form>
					<label for="code">code</label>
					<input id="code" type="text" name="code" minlength="6" maxlength="6">
					<input type="submit" name="submit" value="confirm signin">
					<hr>
					<a href="#" class="_resend">no email appeared? resend code</a>
				</form>
			</div>
		</template>

		<template id="tpl-desktop-resetpw">
			<div class="container dialog">
				<form>
					<label for="email">email</label>
					<input id="email" type="email" name="email" maxlength="256">
					<input type="submit" name="submit" value="send reset code">
				</form>
			</div>
		</template>

		<template id="tpl-desktop-resetpw-newpw">
			<div class="container dialog">
				<form>
					<table>
						<tr>
							<td><label for="new">new password</label></td>
							<td><input id="new" type="password" name="new" minlength="8" maxlength="256"></td>
						</tr>
						<tr>
							<td><label for="confirm">new password (confirm)</label></td>
							<td><input id="confirm" type="password" name="new-confirm"
									   minlength="8" maxlength="256"></td>
						</tr>
					</table>
					<div>
						<input type="submit" name="submit">
					</div>
				</form>
			</div>
		</template>

		<template id="tpl-desktop-cwts">
			<div class="container dialog">
				<form id="frm">
					<p>choose what to sync:</p>
					<div class="cwts-container">
						<div>
							<input type="checkbox" id="addons" name="addons">
							<label for="addons">add-ons</label>
						</div>
						<div>
							<input type="checkbox" id="addresses" name="addresses">
							<label for="addresses">addresses</label>
						</div>
						<div>
							<input type="checkbox" id="bookmarks" name="bookmarks">
							<label for="bookmarks">bookmarks</label>
						</div>
						<div>
							<input type="checkbox" id="creditcards" name="creditcards">
							<label for="creditcards">credit cards</label>
						</div>
						<div>
							<input type="checkbox" id="history" name="history">
							<label for="history">history</label>
						</div>
						<div>
							<input type="checkbox" id="passwords" name="passwords">
							<label for="passwords">passwords</label>
						</div>
						<!-- NOTE the spec says this key is named `preferences` -->
						<div>
							<input type="checkbox" id="prefs" name="prefs">
							<label for="prefs">preferences</label>
						</div>
						<div>
							<input type="checkbox" id="tabs" name="tabs">
							<label for="tabs">open tabs</label>
						</div>
					</div>
					<input type="submit" name="submit" value="start syncing">
				</form>
			</div>
		</template>

		<template id="tpl-desktop-settings">
			<div class="container">
				<nav>
					<a href="#/settings">settings</a> |
					<a href="#/settings/change-password">change password</a> |
					<a href="#/settings/destroy">delete account</a>
				</nav>
				<div class="settings-container tab"></div>
			</div>
		</template>

		<template id="tpl-desktop-settings-main">
			<style>
				#avatar-img {
					max-width: 200px;
					max-height: 200px;
				}
			</style>
			<form id="frm-avatar">
				<img id="avatar-img">
				<input type="file" accept="image/*" name="avatar">
				<input type="submit" value="save">
			</form>
			<form id="frm-name">
				<label for="name">user name:</label>
				<input type="text" id="name" name="name" maxlength="256">
				<input type="submit" value="save">
			</form>
			<table id="clients">
				<thead>
					<tr>
						<td>name</td>
						<td>deviceType</td>
						<td>createdTime</td>
						<td>lastAccessTime</td>
						<td>oauth?</td>
					</tr>
				</thead>
				<tbody>
				</tbody>
			</table>
		</template>

		<template id="tpl-desktop-settings-destroy">
			<p>deleting your account requires confirmation.</p>
			<credentials-form submit-text="really delete accout"></credentials-form>
		</template>

		<template id="tpl-desktop-settings-chpw">
			<form>
				<table>
					<tr>
						<td><label for="old">old password</label></td>
						<td><input id="old" type="password" name="old" minlength="8" maxlength="256"></td>
					</tr>
					<tr>
						<td><label for="new">new password</label></td>
						<td><input id="new" type="password" name="new" minlength="8" maxlength="256"></td>
					</tr>
					<tr>
						<td><label for="confirm">new password (confirm)</label></td>
						<td><input id="confirm" type="password" name="new-confirm"
								   minlength="8" maxlength="256"></td>
					</tr>
				</table>
				<div>
					<input type="submit" name="submit">
				</div>
			</form>
		</template>

		<template id="tpl-desktop-generate-invite">
			<div class="container dialog">
				<form>
					<label for="ttl">invite valid for</label>
					<select id="ttl" name="ttl" maxlength="256">
						<option value="1">one hour</option>
						<option value="24">one day</option>
						<option value="168">one week</option>
					</select>
					<input type="submit" name="submit" value="generate invite">
				</form>
				<div id="result" hidden>
					invite link is <a id="link"></a>
				</div>
			</div>
		</template>

		<template id="tpl-fenix-signin-warning">
			<div class="container">
				<p>it looks like you're trying to sign in to sync from an android firefox instance.
				we're very sorry, but this is going to hurt a bit.</p>
				<p>to sign in you'll need to follow these steps:</p>
				<ol>
					<li>
						enable USB debugging in the android:
						<ol>
							<li>go to setting → about phone</li>
							<li>scroll to the build number</li>
							<li>tap it until a "your are new a developer" message appears</li>
							<li>go to settings → system → developer options</li>
							<li>scroll down to "USB debugging", enable it</li>
						</ol>
					</li>
					<li>enable USB debugging in the android firefox settings</li>
					<li>connect your android device to a PC for USB debugging</li>
					<li>on this PC, open firefox and go to <pre>about:debugging</pre></li>
					<li>enable USB devices</li>
					<li>connect to your android device</li>
					<li>open this page in a normal tab, not through the sign-in interface.
						this is very important, if there's no normal tab with this URL open
						<em>signin will not work</em></li>
					<li>open the login page through the sign-in interface as well</li>
					<li>in the PC debugger, inspect the new tab that has just appeared</li>
					<li><a href="#" id="signin">actually sign in</a>.
						clicking this link will lead away from this page, finishing sign-in
						will bring you back.</li>
					<li>go to the javascript debug console of the tab we inspected previously,
						copy the long block of code</li>
					<li>locate the <pre>Firefox Accounts WebChannel</pre> extension in the
						debugger and inspect it. this may fail, if it does go to the setup
						tab of the debugger and disable USB devices, enable then, reconnect
						to your devices, and repeat this step
						<p><b>WARNING:</b> this is known to not work on firefox 102. if you get
							a blank tab instead of a tab with debug tools as seen earlier you
							may have to downgrade your android firefox to 101 to log in.
							unfortunately this seems to require uninstalling and reinstalling
							firefox, which wipes your data!</p>
					</li>
					<li>go to the javascript debug console, paste the block of code, and run it</li>
					<li>enjoy sync!</li>
				</ol>
			</div>
		</template>

		<template id="tpl-fenix-signin">
			<div class="container dialog">
				<credentials-form submit-text="do the fenix dance"></credentials-form>
			</div>
		</template>
	</head>
	<body>
		<noscript>this thing requires javascript!</noscript>

		<dialog id="message-modal">
			<div id="message-modal-content">
				<p id="message"></p>
				<a href="#" id="message-modal-close" hidden>close</a>
			</div>
		</dialog>

		<div id="content">
		</div>
	</body>
</html>