import "./limits-graph.css" import { For, Show, createMemo, createSignal, createUniqueId, onCleanup, onMount } from "solid-js" import { useI18n } from "~/context/i18n" import { useLanguage } from "~/context/language" import { goModels } from "./go-models" // Compress the request range, with the same domain in both views. const max = Math.max(...goModels.map((model) => model.requests)) const position = (requests: number) => 4 + Math.pow(Math.log10(Math.max(requests / 100, 1)) / Math.log10(max / 100), 2.2) * 96 const ticks = [100, 1000, 10000, 40000] export function LimitsGraph(props: { href: string }) { const i18n = useI18n() const language = useLanguage() const id = createUniqueId() const [expanded, setExpanded] = createSignal(false) const [visible, setVisible] = createSignal(false) const models = createMemo(() => goModels.filter((model) => expanded() || model.featured || model.fresh)) const format = createMemo(() => new Intl.NumberFormat(language.tag(language.locale()))) const compact = createMemo( () => new Intl.NumberFormat(language.tag(language.locale()), { notation: "compact", maximumFractionDigits: 1 }), ) const currency = createMemo( () => new Intl.NumberFormat(language.tag(language.locale()), { style: "currency", currency: "USD", currencyDisplay: "narrowSymbol", maximumFractionDigits: 0, }), ) let root!: HTMLElement onMount(() => { if (!window.IntersectionObserver) return setVisible(true) const observer = new IntersectionObserver( (entries) => { if (!entries.some((entry) => entry.isIntersecting)) return setVisible(true) observer.disconnect() }, { threshold: 0.1 }, ) observer.observe(root) onCleanup(() => observer.disconnect()) }) return (

{i18n.t("go.graph.period")}

{i18n.t("go.graph.model")}
{i18n.t("go.graph.requests")}
{i18n.t("go.graph.allowance")}
{(model, index) => (
{model.name} {i18n.t("go.graph.new")} {i18n.t("go.graph.bonus", { count: model.bonus! })}
= 60 ? "" : undefined}> {currency().format(model.baseAllowance!)}{" "} {(part) => ( {part.value} )}
)}
{i18n.t("go.graph.usageLimits")}
) }