import { getBrain, olderBrain } from "../app/brain.ts";
import {
deleteBrain,
exportSave,
importSave,
renameOwner,
resetSave,
setChatter,
} from "../app/commands.ts";
import { CFG } from "../app/config.ts";
import { installApp, installEvent, isIOS, setAlerts, standalone } from "../app/pwa.ts";
import { brain, store, ui, upgrade } from "../app/store.ts";
import { fmtMB } from "../app/utils.ts";
import { brainStatus } from "./Brain.tsx";
import { HostingSettings } from "./Hosting.tsx";
import { isRemote } from "../app/hosting.ts";
export function Settings() {
const s = store.state,
st = brain.state,
up = upgrade.state;
const canUpgrade =
!isRemote() && st === "ready" && olderBrain() && (up === "idle" || up === "error");
const installing = !standalone() && (!!installEvent || isIOS());
const alertNote = s.settings.alerts
? standalone()
? "Alerts arrive while the app is open or in the background; when it is closed, your device decides how often it may check."
: "Alerts arrive while this tab is open in the background. Installed as an app, they can also come when it is closed, on some devices."
: ui.alertsNote;
return (
<>
{brainStatus()}
{ui.storage}
Install tokenling to open it from your home screen, use it offline and keep your pet's storage safer from browser clean-ups.
{isIOS() && !standalone() ? "On iPhone and iPad: tap Share, then Add to Home Screen." : ""}
{alertNote}
{isRemote() ? "Your server holds your pet, chat and diary; this browser keeps the last synchronized copy. Exports are local recovery saves and omit the server access key." : "Your pet, chat and diary live in this browser's local storage."}