import * as m from "motion/react-m"
import { useEffect, useState, type ReactNode } from "react"
import type { Platform } from "./platform"
import { RELEASE } from "./release"
export function AppleMark() {
return (
)
}
export function WindowsMark() {
return (
)
}
export function LinuxMark() {
return (
)
}
function ShareMark() {
return (
)
}
const SEP = "\u2002\u00b7\u2002"
export const PLATFORM_NAMES: Record = {
mac: "Mac",
"mac-intel": "Mac",
"windows-x64": "Windows",
"windows-arm64": "Windows",
linux: "Linux",
mobile: "Mac, Windows, and Linux",
}
export const SHORTCUTS: Record = {
mac: "Option",
"mac-intel": "Option",
"windows-x64": "Ctrl+Space",
"windows-arm64": "Ctrl+Space",
linux: "Alt+Space",
mobile: "a shortcut",
}
function useCopy(): [boolean, (text: string) => void] {
const [copied, setCopied] = useState(false)
useEffect(() => {
if (!copied) return
const timer = setTimeout(() => setCopied(false), 1600)
return () => clearTimeout(timer)
}, [copied])
return [
copied,
(text) => {
void navigator.clipboard?.writeText(text).then(() => setCopied(true))
},
]
}
function Command({ text, label }: { text: string; label: string }) {
const [copied, copy] = useCopy()
return (
{text}
)
}
function Button({ href, mark, children }: { href: string; mark: ReactNode; children: ReactNode }) {
return (
{mark}
{children}
{"\u2193"}
)
}
function SendLink() {
const [copied, copy] = useCopy()
const send = () => {
const url = location.origin + import.meta.env.BASE_URL
if (navigator.share) {
void navigator.share({ title: "Hex", text: "Voice dictation for Mac, Windows, and Linux", url }).catch(() => {})
} else {
copy(url)
}
}
return (
{copied ? "Link copied" : "Send yourself the link"}
)
}
const WINDOWS_NOTE =
"The installer isn\u2019t code-signed yet, so Windows may say it protected your PC. Choose More info, then Run anyway."
function Primary({ platform }: { platform: Platform }) {
switch (platform) {
case "mac":
return (
<>
}>
Download for Mac
Version {RELEASE.mac.version}
{SEP}Apple silicon{SEP}macOS 15 or later
>
)
case "mac-intel":
return (
<>
Download for Mac
Hex needs a Mac with Apple silicon and macOS 15 or later.
>
)
case "windows-x64":
case "windows-arm64": {
const arm = platform === "windows-arm64"
const build = arm ? RELEASE.windowsArm64 : RELEASE.windowsX64
return (
<>
}>
Download for Windows
Version {build.version}
{SEP}Windows 10 or 11{SEP}
{arm ? "ARM64" : "x64"}
{SEP}beta
{WINDOWS_NOTE}
>
)
}
case "linux":
return (
<>
Version {RELEASE.linux.version}
{SEP}x86_64 Arch Linux{SEP}glibc 2.44 or later{SEP}beta
Paste it into a terminal. The installer checks the signed release, needs no root, and adds Hex to your app
launcher.