<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
<?import org.cryptomator.ui.controls.ThroughputLabel?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<VBox xmlns:fx="http://javafx.com/fxml"
	  xmlns="http://javafx.com/javafx"
	  fx:controller="org.cryptomator.ui.mainwindow.VaultDetailUnlockedController"
	  alignment="TOP_CENTER"
	  spacing="9">
	<Label text="%main.vaultDetail.accessLocation"/>
	<Button styleClass="button-large" contentDisplay="GRAPHIC_ONLY" minWidth="120" onAction="#revealAccessLocation" defaultButton="${controller.accessibleViaPath}" visible="${controller.accessibleViaPath}" managed="${controller.accessibleViaPath}" accessibleText="%main.vaultDetail.revealBtn">
		<graphic>
			<HBox spacing="12" alignment="CENTER">
				<FontAwesome5IconView glyph="HDD" glyphSize="24"/>
				<VBox spacing="4" alignment="CENTER_LEFT">
					<Label text="%main.vaultDetail.revealBtn"/>
					<Label styleClass="label-extra-small" text="${controller.mountPoint}" textOverrun="CENTER_ELLIPSIS"/>
				</VBox>
			</HBox>
		</graphic>
		<tooltip>
			<Tooltip text="%main.vaultDetail.revealBtn"/>
		</tooltip>
	</Button>
	<Button styleClass="button-large" contentDisplay="GRAPHIC_ONLY" minWidth="120" onAction="#copyMountUri" defaultButton="${controller.accessibleViaUri}" visible="${controller.accessibleViaUri}" managed="${controller.accessibleViaUri}" accessibleText="%main.vaultDetail.copyUri">
		<graphic>
			<HBox spacing="12" alignment="CENTER">
				<FontAwesome5IconView glyph="LINK" glyphSize="24"/>
				<VBox spacing="4" alignment="CENTER_LEFT">
					<Label text="%main.vaultDetail.copyUri"/>
					<Label styleClass="label-extra-small" text="${controller.mountPoint}" textOverrun="CENTER_ELLIPSIS"/>
				</VBox>
			</HBox>
		</graphic>
		<tooltip>
			<Tooltip text="%main.vaultDetail.copyUri"/>
		</tooltip>
	</Button>
	<Button text="%main.vaultDetail.lockBtn" minWidth="120" onAction="#lock">
		<graphic>
			<FontAwesome5IconView glyph="KEY"/>
		</graphic>
	</Button>

	<Region VBox.vgrow="ALWAYS"/>

	<HBox alignment="BOTTOM_CENTER">
		<StackPane visible="${controller.accessibleViaPath}" managed="${controller.accessibleViaPath}">
			<padding>
				<Insets topRightBottomLeft="0"/>
			</padding>
			<Button fx:id="revealEncryptedDropZone" styleClass="drag-n-drop" text="%main.vaultDetail.locateEncryptedFileBtn" minWidth="120" maxWidth="180" prefHeight="72" wrapText="true" textAlignment="CENTER" onAction="#chooseDecryptedFileAndReveal" contentDisplay="TOP" visible="${!controller.ciphertextPathsCopied}" managed="${!controller.ciphertextPathsCopied}">
				<graphic>
					<Text styleClass="cryptic-text" text="abc → 101010"/>
				</graphic>
				<tooltip>
					<Tooltip text="%main.vaultDetail.locateEncryptedFileBtn.tooltip"/>
				</tooltip>
			</Button>
			<!-- TODO: instead of showing a button, show on error a small dialog and if copied, show a tooltip -->
			<Button styleClass="drag-n-drop" text="%main.vaultDetail.encryptedPathsCopied" minWidth="120" maxWidth="180" prefHeight="72" wrapText="true" textAlignment="CENTER" onAction="#chooseDecryptedFileAndReveal" contentDisplay="TOP" visible="${controller.ciphertextPathsCopied}" managed="${controller.ciphertextPathsCopied}">
				<graphic>
					<FontAwesome5IconView glyph="CHECK" glyphSize="15"/>
				</graphic>
			</Button>
		</StackPane>
		<!-- decrypt file name -->
		<Button fx:id="decryptNameDropZone" styleClass="drag-n-drop" text="%main.vaultDetail.decryptName.buttonLabel" minWidth="120" maxWidth="180" prefHeight="72" wrapText="true" textAlignment="CENTER" onAction="#showDecryptNameWindow" contentDisplay="TOP">
			<graphic>
				<Text styleClass="cryptic-text" text="101010 → abc"/>
			</graphic>
			<tooltip>
				<Tooltip text="%main.vaultDetail.decryptName.tooltip"/>
			</tooltip>
		</Button>
		<Region HBox.hgrow="ALWAYS"/>

		<Button text="%main.vaultDetail.stats" minWidth="120" onAction="#showVaultStatistics" contentDisplay="BOTTOM" prefHeight="72">
			<graphic>
				<VBox spacing="6">
					<HBox alignment="CENTER_RIGHT" spacing="6">
						<Label styleClass="label-small,label-muted" text="%main.vaultDetail.bytesPerSecondRead"/>
						<ThroughputLabel styleClass="label-small,label-muted" alignment="CENTER_RIGHT" minWidth="60" idleFormat="%main.vaultDetail.throughput.idle" kibsFormat="%main.vaultDetail.throughput.kbps" mibsFormat="%main.vaultDetail.throughput.mbps" bytesPerSecond="${controller.vault.stats.bytesPerSecondRead}"/>
					</HBox>
					<HBox alignment="CENTER_RIGHT" spacing="6">
						<Label styleClass="label-small,label-muted" text="%main.vaultDetail.bytesPerSecondWritten"/>
						<ThroughputLabel styleClass="label-small,label-muted" alignment="CENTER_RIGHT" minWidth="60" idleFormat="%main.vaultDetail.throughput.idle" kibsFormat="%main.vaultDetail.throughput.kbps" mibsFormat="%main.vaultDetail.throughput.mbps" bytesPerSecond="${controller.vault.stats.bytesPerSecondWritten}"/>
					</HBox>
				</VBox>
			</graphic>
		</Button>
	</HBox>
</VBox>