@orangecheck/app-design 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +21 -5
  2. package/dist/chrome.d.mts +31 -42
  3. package/dist/chrome.d.ts +31 -42
  4. package/dist/chrome.js +500 -23
  5. package/dist/chrome.js.map +1 -1
  6. package/dist/chrome.mjs +495 -25
  7. package/dist/chrome.mjs.map +1 -1
  8. package/dist/code.d.mts +52 -0
  9. package/dist/code.d.ts +52 -0
  10. package/dist/code.js +534 -0
  11. package/dist/code.js.map +1 -0
  12. package/dist/code.mjs +522 -0
  13. package/dist/code.mjs.map +1 -0
  14. package/dist/components.d.mts +61 -117
  15. package/dist/components.d.ts +61 -117
  16. package/dist/components.js +2170 -105
  17. package/dist/components.js.map +1 -1
  18. package/dist/components.mjs +2142 -109
  19. package/dist/components.mjs.map +1 -1
  20. package/dist/docs-DhnstueM.d.ts +219 -0
  21. package/dist/docs-DiR6s43s.d.mts +219 -0
  22. package/dist/format.d.mts +12 -0
  23. package/dist/format.d.ts +12 -0
  24. package/dist/format.js +65 -0
  25. package/dist/format.js.map +1 -0
  26. package/dist/format.mjs +58 -0
  27. package/dist/format.mjs.map +1 -0
  28. package/dist/hero-Dn37il-9.d.mts +31 -0
  29. package/dist/hero-Dn37il-9.d.ts +31 -0
  30. package/dist/index.d.mts +10 -3
  31. package/dist/index.d.ts +10 -3
  32. package/dist/index.js +2668 -131
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +2614 -134
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/mdx.d.mts +58 -0
  37. package/dist/mdx.d.ts +58 -0
  38. package/dist/mdx.js +1712 -0
  39. package/dist/mdx.js.map +1 -0
  40. package/dist/mdx.mjs +1685 -0
  41. package/dist/mdx.mjs.map +1 -0
  42. package/dist/primitives.d.mts +22 -5
  43. package/dist/primitives.d.ts +22 -5
  44. package/dist/primitives.js +51 -5
  45. package/dist/primitives.js.map +1 -1
  46. package/dist/primitives.mjs +51 -7
  47. package/dist/primitives.mjs.map +1 -1
  48. package/dist/session.d.mts +18 -0
  49. package/dist/session.d.ts +18 -0
  50. package/dist/session.js +432 -0
  51. package/dist/session.js.map +1 -0
  52. package/dist/session.mjs +401 -0
  53. package/dist/session.mjs.map +1 -0
  54. package/dist/styles/code.css +97 -0
  55. package/dist/styles/theme.css +2 -0
  56. package/dist/styles/tokens.css +40 -0
  57. package/dist/styles.css +1 -0
  58. package/dist/tool-shell-B1C7ahKE.d.ts +81 -0
  59. package/dist/tool-shell-BDx_N5ai.d.mts +81 -0
  60. package/dist/tools-BggNN5DV.d.ts +131 -0
  61. package/dist/tools-DFIxIj5p.d.mts +131 -0
  62. package/package.json +31 -2
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Slot } from '@radix-ui/react-slot';
2
2
  import { cva } from 'class-variance-authority';
3
- import { forwardRef, createContext, useContext, useRef, useState, useCallback, useEffect, useId, isValidElement, cloneElement, useSyncExternalStore, useMemo, createElement, Children, Component, Fragment as Fragment$1 } from 'react';
3
+ import { forwardRef, useContext, createContext, useRef, useState, useCallback, useEffect, useMemo, useId, useSyncExternalStore, Children, isValidElement, createElement, cloneElement, Component, Fragment as Fragment$1 } from 'react';
4
4
  import { clsx } from 'clsx';
5
5
  import { extendTailwindMerge } from 'tailwind-merge';
6
6
  import * as SeparatorPrimitive from '@radix-ui/react-separator';
@@ -12,14 +12,14 @@ import * as LabelPrimitive from '@radix-ui/react-label';
12
12
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
13
13
  import * as SelectPrimitive from '@radix-ui/react-select';
14
14
  import * as SwitchPrimitive from '@radix-ui/react-switch';
15
- import { ChevronDown, Check, X, ChevronLeft, ChevronRight, Copy, ArrowUpRight, Menu, Sun, Moon, SunMoon, CircleDashed, CircleMinus, Clock, CircleX, CircleCheck } from 'lucide-react';
15
+ import { ChevronDown, Check, X, Search, ArrowUpRight, ArrowRight, Copy, ChevronLeft, ChevronRight, CornerDownLeft, Download, FileText, Upload, Menu, PanelLeft, Sun, Moon, SunMoon, CircleUser, LogOut, ArrowLeft, Lock, CircleDashed, CircleMinus, Clock, CircleX, CircleCheck } from 'lucide-react';
16
16
  import * as DialogPrimitive from '@radix-ui/react-dialog';
17
17
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
18
18
  import * as PopoverPrimitive from '@radix-ui/react-popover';
19
19
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
20
20
  import * as TabsPrimitive from '@radix-ui/react-tabs';
21
21
  import QRCode from 'qrcode';
22
- import Link5 from 'next/link';
22
+ import Link8 from 'next/link';
23
23
  import { useTheme } from 'next-themes';
24
24
 
25
25
  // src/tokens/index.ts
@@ -362,6 +362,20 @@ function CardContent({ className, ...props }) {
362
362
  function CardFooter({ className, ...props }) {
363
363
  return /* @__PURE__ */ jsx("div", { className: cn("mt-6 flex flex-wrap items-center gap-3", className), ...props });
364
364
  }
365
+ function sharedContext(name, initial) {
366
+ const key = /* @__PURE__ */ Symbol.for(`@orangecheck/app-design/${name}`);
367
+ const store = globalThis;
368
+ return store[key] ?? (store[key] = createContext(initial));
369
+ }
370
+
371
+ // src/lib/density.ts
372
+ var DensityContext = sharedContext("density", "comfortable");
373
+ function DensityProvider({ density, children }) {
374
+ return createElement(DensityContext.Provider, { value: density }, children);
375
+ }
376
+ function useDensity() {
377
+ return useContext(DensityContext);
378
+ }
365
379
  var fieldBase = [
366
380
  "w-full rounded-xl border border-input bg-card text-foreground placeholder:text-oca-subtle",
367
381
  "text-base md:text-[0.9375rem] outline-none transition-[border-color,box-shadow]",
@@ -369,8 +383,24 @@ var fieldBase = [
369
383
  "disabled:cursor-not-allowed disabled:opacity-55",
370
384
  "aria-[invalid=true]:border-destructive aria-[invalid=true]:focus:ring-[color-mix(in_oklab,var(--destructive)_14%,transparent)]"
371
385
  ];
372
- var Input = forwardRef(function Input2({ className, type = "text", ...props }, ref) {
373
- return /* @__PURE__ */ jsx("input", { ref, type, "data-ui": "input", className: cn(fieldBase, "h-11 px-3.5", className), ...props });
386
+ var FIELD_SIZE = {
387
+ md: "h-11 px-3.5",
388
+ sm: "h-9 rounded-[0.625rem] px-3 md:text-[0.875rem]"
389
+ };
390
+ var Input = forwardRef(function Input2({ className, type = "text", size, ...props }, ref) {
391
+ const density = useDensity();
392
+ const s = size ?? (density === "compact" ? "sm" : "md");
393
+ return /* @__PURE__ */ jsx(
394
+ "input",
395
+ {
396
+ ref,
397
+ type,
398
+ "data-ui": "input",
399
+ "data-size": s,
400
+ className: cn(fieldBase, FIELD_SIZE[s], className),
401
+ ...props
402
+ }
403
+ );
374
404
  });
375
405
  var Textarea = forwardRef(
376
406
  function Textarea2({ className, ...props }, ref) {
@@ -427,15 +457,29 @@ function Field({ label, hint, optional, error, children, className, hideLabel, a
427
457
  error ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-[0.8125rem] leading-snug text-destructive", children: error }) : null
428
458
  ] });
429
459
  }
430
- var Select = SelectPrimitive.Root;
460
+ var SelectFieldContext = sharedContext("select-field", null);
461
+ function Select({
462
+ id,
463
+ "aria-describedby": describedBy,
464
+ "aria-invalid": invalid,
465
+ ...props
466
+ }) {
467
+ return /* @__PURE__ */ jsx(SelectFieldContext.Provider, { value: { id, "aria-describedby": describedBy, "aria-invalid": invalid }, children: /* @__PURE__ */ jsx(SelectPrimitive.Root, { ...props }) });
468
+ }
431
469
  var SelectGroup = SelectPrimitive.Group;
432
470
  var SelectValue = SelectPrimitive.Value;
433
- var SelectTrigger = forwardRef(function SelectTrigger2({ className, children, ...props }, ref) {
471
+ var SelectTrigger = forwardRef(function SelectTrigger2({ className, children, size, ...props }, ref) {
472
+ const density = useDensity();
473
+ const field = useContext(SelectFieldContext);
474
+ const s = size ?? (density === "compact" ? "sm" : "md");
434
475
  return /* @__PURE__ */ jsxs(
435
476
  SelectPrimitive.Trigger,
436
477
  {
437
478
  ref,
438
- className: cn(fieldBase, "flex h-11 items-center justify-between gap-2 px-3.5 text-left", className),
479
+ id: field?.id,
480
+ "aria-describedby": field?.["aria-describedby"],
481
+ "aria-invalid": field?.["aria-invalid"],
482
+ className: cn(fieldBase, FIELD_SIZE[s], "flex items-center justify-between gap-2 text-left", className),
439
483
  ...props,
440
484
  children: [
441
485
  /* @__PURE__ */ jsx("span", { className: "truncate", children }),
@@ -1751,6 +1795,7 @@ function useActiveHeading(ids) {
1751
1795
  const [active, setActive] = useState(ids[0]);
1752
1796
  const key = ids.join("|");
1753
1797
  useEffect(() => {
1798
+ setActive(key.split("|")[0] || void 0);
1754
1799
  const els = key.split("|").map((id) => document.getElementById(id)).filter((el) => el !== null);
1755
1800
  if (els.length === 0 || typeof IntersectionObserver === "undefined") return;
1756
1801
  const io = new IntersectionObserver(
@@ -1843,7 +1888,563 @@ function StepGrid({ items, look = "cards", className }) {
1843
1888
  ] }) }, i)
1844
1889
  ) });
1845
1890
  }
1846
- var ShellContext = createContext({});
1891
+ var KIND = {
1892
+ package: "text-oca-code-package",
1893
+ tag: "text-oca-code-tag",
1894
+ link: "text-oca-code-link"
1895
+ };
1896
+ function PackageCard({ items, className }) {
1897
+ return /* @__PURE__ */ jsx(
1898
+ "div",
1899
+ {
1900
+ className: cn(
1901
+ "grid gap-x-10 gap-y-7 rounded-[1.25rem] border border-oca-ink-line bg-oca-ink-card p-6 text-oca-ink-foreground md:grid-cols-2 md:p-9",
1902
+ className
1903
+ ),
1904
+ children: items.map((it, i) => {
1905
+ const code = /* @__PURE__ */ jsx("span", { className: cn("text-[0.9375rem]", KIND[it.kind ?? "package"]), children: it.code });
1906
+ return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1.5", children: [
1907
+ /* @__PURE__ */ jsx("h3", { className: "text-[1.125rem] font-semibold tracking-[-0.01em] text-oca-ink-title", children: it.title }),
1908
+ it.href ? /* @__PURE__ */ jsx("a", { href: it.href, className: "w-fit underline decoration-transparent underline-offset-4 hover:decoration-current", children: code }) : code,
1909
+ it.note ? /* @__PURE__ */ jsxs("p", { className: "text-[0.9375rem] leading-relaxed text-oca-ink-subtle", children: [
1910
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "// " }),
1911
+ it.note
1912
+ ] }) : null
1913
+ ] }, i);
1914
+ })
1915
+ }
1916
+ );
1917
+ }
1918
+
1919
+ // src/code/highlight.ts
1920
+ var TOKEN_CLASS = {
1921
+ keyword: "oca-k",
1922
+ string: "oca-s",
1923
+ number: "oca-n",
1924
+ function: "oca-f",
1925
+ type: "oca-y",
1926
+ property: "oca-p",
1927
+ comment: "oca-c",
1928
+ tag: "oca-g",
1929
+ url: "oca-u"
1930
+ };
1931
+ var ALIASES = {
1932
+ ts: "js",
1933
+ typescript: "js",
1934
+ tsx: "js",
1935
+ js: "js",
1936
+ javascript: "js",
1937
+ jsx: "js",
1938
+ mjs: "js",
1939
+ cjs: "js",
1940
+ json: "json",
1941
+ jsonc: "json",
1942
+ json5: "json",
1943
+ bash: "shell",
1944
+ sh: "shell",
1945
+ shell: "shell",
1946
+ zsh: "shell",
1947
+ console: "shell",
1948
+ terminal: "shell",
1949
+ py: "python",
1950
+ python: "python",
1951
+ yaml: "yaml",
1952
+ yml: "yaml",
1953
+ diff: "diff"
1954
+ };
1955
+ var CODE_LANGS = Object.keys(ALIASES);
1956
+ function grammarOf(lang) {
1957
+ return lang && ALIASES[lang.toLowerCase()] || "plain";
1958
+ }
1959
+ function collector() {
1960
+ const tokens = [];
1961
+ const emit2 = (text, kind) => {
1962
+ if (!text) return;
1963
+ const last = tokens[tokens.length - 1];
1964
+ if (last && last.kind === kind) last.text += text;
1965
+ else tokens.push(kind ? { text, kind } : { text });
1966
+ };
1967
+ return { emit: emit2, tokens };
1968
+ }
1969
+ function at(re, src, i) {
1970
+ re.lastIndex = i;
1971
+ const m = re.exec(src);
1972
+ return m ? m[0] : null;
1973
+ }
1974
+ var WS = /[ \t]+/y;
1975
+ var NEWLINE = /\r?\n/y;
1976
+ var JS_KEYWORDS = new Set(
1977
+ "abstract as async await break case catch class const continue debugger declare default delete do else enum export extends finally for from function get if implements import in infer instanceof interface is keyof let module namespace new of override private protected public readonly return satisfies set static super switch this throw try type typeof unique var void while with yield".split(" ")
1978
+ );
1979
+ var JS_CONSTANTS = /* @__PURE__ */ new Set(["true", "false", "null", "undefined", "NaN", "Infinity"]);
1980
+ var TS_PRIMITIVES = /* @__PURE__ */ new Set(["string", "number", "boolean", "bigint", "symbol", "object", "unknown", "any", "never"]);
1981
+ var isConstant = (m) => /^[A-Z][A-Z\d_]+$/.test(m) && (m.includes("_") || m.length > 4);
1982
+ var JS_LINE_COMMENT = /\/\/[^\n]*/y;
1983
+ var JS_BLOCK_COMMENT = /\/\*[\s\S]*?(?:\*\/|$)/y;
1984
+ var JS_TEMPLATE = /`(?:\\[\s\S]|[^\\`])*`?/y;
1985
+ var JS_STRING = /'(?:\\.|[^\\'\n])*'?|"(?:\\.|[^\\"\n])*"?/y;
1986
+ var JS_NUMBER = /(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?\d+)?|\.\d[\d_]*(?:[eE][+-]?\d+)?)n?/y;
1987
+ var JS_IDENT = /[A-Za-z_$][\w$]*/y;
1988
+ var JS_DECORATOR = /@[A-Za-z_$][\w$.]*/y;
1989
+ var JS_CALL_AFTER = /\s*(?:<[\w$\s,.[\]|&'"]*>)?\s*\(/y;
1990
+ var JS_TAG = /<\/?(?=[A-Za-z])/y;
1991
+ var JS_TAG_NAME = /[A-Za-z][\w$.:-]*/y;
1992
+ var JS_PUNCT = /=>|\.\.\.|[{}()[\];,.<>=+\-*/%!?:&|^~#]/y;
1993
+ var JSX_BEFORE = /* @__PURE__ */ new Set(["(", ",", "=", "?", ":", "{", "[", ";", ">", "&&", "||", "=>", "return"]);
1994
+ function scanJs(src, emit2, jsx50) {
1995
+ let i = 0;
1996
+ let prev = "";
1997
+ let tagDepth = 0;
1998
+ let braceInTag = 0;
1999
+ const sig = (t) => {
2000
+ prev = t;
2001
+ };
2002
+ while (i < src.length) {
2003
+ let m;
2004
+ if ((m = at(WS, src, i)) || (m = at(NEWLINE, src, i))) {
2005
+ emit2(m);
2006
+ i += m.length;
2007
+ continue;
2008
+ }
2009
+ if ((m = at(JS_LINE_COMMENT, src, i)) || (m = at(JS_BLOCK_COMMENT, src, i))) {
2010
+ emit2(m, "comment");
2011
+ i += m.length;
2012
+ continue;
2013
+ }
2014
+ if ((m = at(JS_TEMPLATE, src, i)) || (m = at(JS_STRING, src, i))) {
2015
+ emit2(m, "string");
2016
+ i += m.length;
2017
+ sig('"');
2018
+ continue;
2019
+ }
2020
+ if (jsx50 && tagDepth === 0 && (m = at(JS_TAG, src, i)) && (prev === "" || JSX_BEFORE.has(prev))) {
2021
+ const name = at(JS_TAG_NAME, src, i + m.length);
2022
+ if (name) {
2023
+ emit2(m);
2024
+ emit2(name, "tag");
2025
+ i += m.length + name.length;
2026
+ tagDepth = 1;
2027
+ braceInTag = 0;
2028
+ sig("tag");
2029
+ continue;
2030
+ }
2031
+ }
2032
+ if (jsx50 && tagDepth > 0 && braceInTag === 0) {
2033
+ if (src.startsWith("/>", i) || src[i] === ">") {
2034
+ const close = src[i] === ">" ? ">" : "/>";
2035
+ emit2(close);
2036
+ i += close.length;
2037
+ tagDepth = 0;
2038
+ sig(">");
2039
+ continue;
2040
+ }
2041
+ if ((m = at(JS_IDENT, src, i)) && /^\s*=/.test(src.slice(i + m.length, i + m.length + 4))) {
2042
+ emit2(m, "property");
2043
+ i += m.length;
2044
+ continue;
2045
+ }
2046
+ if (m = at(JS_IDENT, src, i)) {
2047
+ emit2(m, "property");
2048
+ i += m.length;
2049
+ continue;
2050
+ }
2051
+ if (src[i] === "{") braceInTag = 1;
2052
+ } else if (jsx50 && tagDepth > 0 && braceInTag > 0) {
2053
+ if (src[i] === "{") braceInTag++;
2054
+ else if (src[i] === "}") braceInTag--;
2055
+ }
2056
+ if (m = at(JS_DECORATOR, src, i)) {
2057
+ emit2(m, "function");
2058
+ i += m.length;
2059
+ sig("@");
2060
+ continue;
2061
+ }
2062
+ if (m = at(JS_IDENT, src, i)) {
2063
+ const end = i + m.length;
2064
+ let kind;
2065
+ if (prev !== "." && JS_CONSTANTS.has(m)) kind = "number";
2066
+ else if (prev !== "." && JS_KEYWORDS.has(m)) kind = "keyword";
2067
+ else if (at(JS_CALL_AFTER, src, end) !== null) kind = "function";
2068
+ else if (prev !== "." && TS_PRIMITIVES.has(m)) kind = "type";
2069
+ else if (isConstant(m)) kind = "number";
2070
+ else if (/^[A-Z]/.test(m)) kind = "type";
2071
+ emit2(m, kind);
2072
+ i = end;
2073
+ sig(kind === "keyword" ? m : "id");
2074
+ continue;
2075
+ }
2076
+ if (m = at(JS_NUMBER, src, i)) {
2077
+ emit2(m, "number");
2078
+ i += m.length;
2079
+ sig("0");
2080
+ continue;
2081
+ }
2082
+ if (m = at(JS_PUNCT, src, i)) {
2083
+ emit2(m);
2084
+ i += m.length;
2085
+ sig(m === "." ? "." : m);
2086
+ continue;
2087
+ }
2088
+ emit2(src[i]);
2089
+ i++;
2090
+ }
2091
+ }
2092
+ var JSON_STRING = /"(?:\\.|[^\\"\n])*"?/y;
2093
+ var JSON_KEY_AFTER = /\s*:/y;
2094
+ var JSON_NUMBER = /-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/y;
2095
+ var JSON_WORD = /true|false|null/y;
2096
+ function scanJson(src, emit2) {
2097
+ let i = 0;
2098
+ while (i < src.length) {
2099
+ let m;
2100
+ if ((m = at(JS_LINE_COMMENT, src, i)) || (m = at(JS_BLOCK_COMMENT, src, i))) {
2101
+ emit2(m, "comment");
2102
+ } else if (m = at(JSON_STRING, src, i)) {
2103
+ emit2(m, at(JSON_KEY_AFTER, src, i + m.length) !== null ? "property" : "string");
2104
+ } else if ((m = at(JSON_NUMBER, src, i)) || (m = at(JSON_WORD, src, i))) {
2105
+ emit2(m, "number");
2106
+ } else {
2107
+ m = src[i];
2108
+ emit2(m);
2109
+ }
2110
+ i += m.length;
2111
+ }
2112
+ }
2113
+ var SH_KEYWORDS = new Set(
2114
+ "if then else elif fi for in do done case esac while until function return export local select time".split(" ")
2115
+ );
2116
+ var SH_PROMPT = /\$ (?=\S)/y;
2117
+ var SH_COMMENT = /#[^\n]*/y;
2118
+ var SH_SINGLE = /'[^']*'?/y;
2119
+ var SH_DOUBLE = /"(?:\\.|[^\\"])*"?/y;
2120
+ var SH_VAR = /\$(?:\{[^}\n]*\}?|[A-Za-z_][\w]*|[@*#?$!\d])/y;
2121
+ var SH_URL = /https?:\/\/[^\s'"`)]+/y;
2122
+ var SH_FLAG = /--?[A-Za-z][\w-]*/y;
2123
+ var SH_ASSIGN = /[A-Za-z_][\w]*(?==)/y;
2124
+ var SH_VALUE = /=[^\s|&;()<>'"`$]*/y;
2125
+ var SH_WORD = /[^\s|&;()<>'"`$#]+/y;
2126
+ var SH_OPERATOR = /\|\||&&|[|;&]|\$\(|[()<>]/y;
2127
+ function scanShell(src, emit2) {
2128
+ let i = 0;
2129
+ let command = true;
2130
+ let lineStart = true;
2131
+ while (i < src.length) {
2132
+ let m;
2133
+ if (m = at(NEWLINE, src, i)) {
2134
+ emit2(m);
2135
+ i += m.length;
2136
+ command = !/\\\s*$/.test(src.slice(0, i - m.length));
2137
+ lineStart = true;
2138
+ continue;
2139
+ }
2140
+ if (m = at(WS, src, i)) {
2141
+ emit2(m);
2142
+ i += m.length;
2143
+ continue;
2144
+ }
2145
+ if (lineStart && (m = at(SH_PROMPT, src, i))) {
2146
+ emit2(m, "comment");
2147
+ i += m.length;
2148
+ lineStart = false;
2149
+ continue;
2150
+ }
2151
+ lineStart = false;
2152
+ if ((m = at(SH_COMMENT, src, i)) && (i === 0 || /\s/.test(src[i - 1]))) {
2153
+ emit2(m, "comment");
2154
+ i += m.length;
2155
+ continue;
2156
+ }
2157
+ if ((m = at(SH_SINGLE, src, i)) || (m = at(SH_DOUBLE, src, i))) {
2158
+ emit2(m, "string");
2159
+ i += m.length;
2160
+ command = false;
2161
+ continue;
2162
+ }
2163
+ if (m = at(SH_OPERATOR, src, i)) {
2164
+ emit2(m);
2165
+ i += m.length;
2166
+ command = m !== ")" && m !== ">" && m !== "<";
2167
+ continue;
2168
+ }
2169
+ if (m = at(SH_VAR, src, i)) {
2170
+ emit2(m, "type");
2171
+ i += m.length;
2172
+ command = false;
2173
+ continue;
2174
+ }
2175
+ if (m = at(SH_URL, src, i)) {
2176
+ emit2(m, "url");
2177
+ i += m.length;
2178
+ command = false;
2179
+ continue;
2180
+ }
2181
+ if (command && (m = at(SH_ASSIGN, src, i))) {
2182
+ emit2(m, "property");
2183
+ i += m.length;
2184
+ const v = at(SH_VALUE, src, i);
2185
+ emit2(v);
2186
+ i += v.length;
2187
+ continue;
2188
+ }
2189
+ if ((m = at(SH_FLAG, src, i)) && !command) {
2190
+ emit2(m, "keyword");
2191
+ i += m.length;
2192
+ continue;
2193
+ }
2194
+ if (m = at(SH_WORD, src, i)) {
2195
+ if (command && SH_KEYWORDS.has(m)) emit2(m, "keyword");
2196
+ else if (command) {
2197
+ emit2(m, "function");
2198
+ command = m === "sudo" || m === "npx" || m === "env" || m === "time";
2199
+ i += m.length;
2200
+ continue;
2201
+ } else emit2(m);
2202
+ i += m.length;
2203
+ continue;
2204
+ }
2205
+ emit2(src[i]);
2206
+ i++;
2207
+ }
2208
+ }
2209
+ var PY_KEYWORDS = new Set(
2210
+ "and as assert async await break class continue def del elif else except finally for from global if import in is lambda match case nonlocal not or pass raise return try while with yield self cls".split(" ")
2211
+ );
2212
+ var PY_CONSTANTS = /* @__PURE__ */ new Set(["True", "False", "None"]);
2213
+ var PY_TYPES = /* @__PURE__ */ new Set(["int", "str", "bool", "float", "bytes", "list", "dict", "tuple", "set", "object"]);
2214
+ var PY_COMMENT = /#[^\n]*/y;
2215
+ var PY_TRIPLE = /[rRbBuUfF]{0,2}(?:"""[\s\S]*?(?:"""|$)|'''[\s\S]*?(?:'''|$))/y;
2216
+ var PY_STRING = /[rRbBuUfF]{0,2}(?:'(?:\\.|[^\\'\n])*'?|"(?:\\.|[^\\"\n])*"?)/y;
2217
+ var PY_NUMBER = /(?:0[xX][\da-fA-F_]+|\d[\d_]*(?:\.[\d_]*)?(?:[eE][+-]?\d+)?j?)/y;
2218
+ var PY_IDENT = /[A-Za-z_]\w*/y;
2219
+ var PY_DECORATOR = /@[A-Za-z_][\w.]*/y;
2220
+ var PY_CALL_AFTER = /\s*\(/y;
2221
+ function scanPython(src, emit2) {
2222
+ let i = 0;
2223
+ let prev = "";
2224
+ while (i < src.length) {
2225
+ let m;
2226
+ if ((m = at(WS, src, i)) || (m = at(NEWLINE, src, i))) {
2227
+ emit2(m);
2228
+ i += m.length;
2229
+ continue;
2230
+ }
2231
+ if (m = at(PY_COMMENT, src, i)) {
2232
+ emit2(m, "comment");
2233
+ } else if ((m = at(PY_TRIPLE, src, i)) || (m = at(PY_STRING, src, i))) {
2234
+ if (/^[A-Za-z]+$/.test(m)) {
2235
+ emit2(m);
2236
+ } else emit2(m, "string");
2237
+ prev = '"';
2238
+ } else if (m = at(PY_DECORATOR, src, i)) {
2239
+ emit2(m, "function");
2240
+ prev = "@";
2241
+ } else if (m = at(PY_IDENT, src, i)) {
2242
+ let kind;
2243
+ if (PY_CONSTANTS.has(m)) kind = "number";
2244
+ else if (prev !== "." && PY_KEYWORDS.has(m)) kind = "keyword";
2245
+ else if (prev === "def" || at(PY_CALL_AFTER, src, i + m.length) !== null) kind = "function";
2246
+ else if (prev === "class" || /^[A-Z][a-z]/.test(m) || PY_TYPES.has(m)) kind = "type";
2247
+ else if (isConstant(m)) kind = "number";
2248
+ emit2(m, kind);
2249
+ prev = kind === "keyword" ? m : "id";
2250
+ } else if (m = at(PY_NUMBER, src, i)) {
2251
+ emit2(m, "number");
2252
+ prev = "0";
2253
+ } else {
2254
+ m = src[i];
2255
+ emit2(m);
2256
+ prev = m;
2257
+ }
2258
+ i += m.length;
2259
+ }
2260
+ }
2261
+ var YAML_KEY = /[ \t]*(?:- )?[\w.$/-]+(?=[ \t]*:(?:\s|$))/y;
2262
+ var YAML_VALUE_WORD = /(?:true|false|null|yes|no|~|-?\d+(?:\.\d+)?)(?=\s*(?:#|$))/y;
2263
+ function scanYaml(src, emit2) {
2264
+ let i = 0;
2265
+ let lineStart = true;
2266
+ while (i < src.length) {
2267
+ let m;
2268
+ if (m = at(NEWLINE, src, i)) {
2269
+ emit2(m);
2270
+ i += m.length;
2271
+ lineStart = true;
2272
+ continue;
2273
+ }
2274
+ if (lineStart && (m = at(YAML_KEY, src, i))) {
2275
+ const dash = m.match(/^([ \t]*(?:- )?)/)[1];
2276
+ emit2(dash);
2277
+ emit2(m.slice(dash.length), "property");
2278
+ i += m.length;
2279
+ lineStart = false;
2280
+ continue;
2281
+ }
2282
+ lineStart = false;
2283
+ if ((m = at(SH_COMMENT, src, i)) && (i === 0 || /\s/.test(src[i - 1]))) emit2(m, "comment");
2284
+ else if ((m = at(SH_SINGLE, src, i)) || (m = at(JSON_STRING, src, i))) emit2(m, "string");
2285
+ else if (m = at(YAML_VALUE_WORD, src, i)) emit2(m, "number");
2286
+ else if (m = at(SH_URL, src, i)) emit2(m, "url");
2287
+ else {
2288
+ m = src[i];
2289
+ emit2(m);
2290
+ }
2291
+ i += m.length;
2292
+ }
2293
+ }
2294
+ function toLines(tokens) {
2295
+ const lines = [[]];
2296
+ for (const t of tokens) {
2297
+ const parts = t.text.split(/\r?\n/);
2298
+ parts.forEach((part, j) => {
2299
+ if (j > 0) lines.push([]);
2300
+ if (part) lines[lines.length - 1].push(t.kind ? { text: part, kind: t.kind } : { text: part });
2301
+ });
2302
+ }
2303
+ return lines;
2304
+ }
2305
+ function highlight(code, lang) {
2306
+ const src = code.replace(/\r?\n$/, "");
2307
+ const grammar = grammarOf(lang);
2308
+ const { emit: emit2, tokens } = collector();
2309
+ const name = (lang ?? "").toLowerCase();
2310
+ switch (grammar) {
2311
+ case "js":
2312
+ scanJs(src, emit2, name === "tsx" || name === "jsx");
2313
+ break;
2314
+ case "json":
2315
+ scanJson(src, emit2);
2316
+ break;
2317
+ case "shell":
2318
+ scanShell(src, emit2);
2319
+ break;
2320
+ case "python":
2321
+ scanPython(src, emit2);
2322
+ break;
2323
+ case "yaml":
2324
+ scanYaml(src, emit2);
2325
+ break;
2326
+ default:
2327
+ emit2(src);
2328
+ }
2329
+ return toLines(tokens);
2330
+ }
2331
+ function readDiff(code) {
2332
+ const diff = /* @__PURE__ */ new Map();
2333
+ const lines = code.replace(/\r?\n$/, "").split(/\r?\n/);
2334
+ const out = lines.map((line, i) => {
2335
+ const c = line[0];
2336
+ if (c === "+" || c === "-") {
2337
+ diff.set(i + 1, c === "+" ? "add" : "remove");
2338
+ return line.slice(1);
2339
+ }
2340
+ return c === " " ? line.slice(1) : line;
2341
+ });
2342
+ return { code: out.join("\n"), diff };
2343
+ }
2344
+ function parseLineRanges(spec) {
2345
+ if (!spec) return /* @__PURE__ */ new Set();
2346
+ if (typeof spec !== "string") return new Set(spec);
2347
+ const out = /* @__PURE__ */ new Set();
2348
+ for (const part of spec.split(",")) {
2349
+ const m = part.trim().match(/^(\d+)(?:\s*-\s*(\d+))?$/);
2350
+ if (!m) continue;
2351
+ const a = Number(m[1]);
2352
+ const b = m[2] ? Number(m[2]) : a;
2353
+ for (let n = Math.min(a, b); n <= Math.max(a, b) && n - a < 1e4; n++) out.add(n);
2354
+ }
2355
+ return out;
2356
+ }
2357
+ function parseCodeMeta(meta) {
2358
+ if (!meta) return {};
2359
+ const out = {};
2360
+ const title = meta.match(/(?:title|filename)=(?:"([^"]*)"|'([^']*)'|(\S+))/);
2361
+ if (title) out.title = title[1] ?? title[2] ?? title[3];
2362
+ const lines = meta.match(/\{([\d,\s-]+)\}/);
2363
+ if (lines) out.highlight = lines[1].replace(/\s+/g, "");
2364
+ const rest = meta.replace(/(?:title|filename)=(?:"[^"]*"|'[^']*'|\S+)/, "");
2365
+ if (/\bdiff\b/.test(rest)) out.diff = true;
2366
+ if (/\b(?:showLineNumbers|lineNumbers|numbers)\b/.test(rest)) out.lineNumbers = true;
2367
+ return out;
2368
+ }
2369
+ var ESCAPE = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" };
2370
+ function escapeHtml(s) {
2371
+ return s.replace(/[&<>"]/g, (c) => ESCAPE[c]);
2372
+ }
2373
+ function linesToHtml(lines, marks = {}) {
2374
+ return lines.map((line, i) => {
2375
+ const n = i + 1;
2376
+ const attrs = [
2377
+ 'data-line=""',
2378
+ marks.highlight?.has(n) ? 'data-mark=""' : "",
2379
+ marks.diff?.has(n) ? `data-diff="${marks.diff.get(n)}"` : ""
2380
+ ].filter(Boolean).join(" ");
2381
+ const body = line.map((t) => t.kind ? `<span class="${TOKEN_CLASS[t.kind]}">${escapeHtml(t.text)}</span>` : escapeHtml(t.text)).join("");
2382
+ return `<span ${attrs}>${body}</span>`;
2383
+ }).join("\n");
2384
+ }
2385
+ function highlightToHtml(code, lang, opts = {}) {
2386
+ const d = opts.diff ? readDiff(code) : null;
2387
+ return linesToHtml(highlight(d ? d.code : code, lang), {
2388
+ highlight: parseLineRanges(opts.highlight),
2389
+ diff: d?.diff
2390
+ });
2391
+ }
2392
+
2393
+ // src/format/index.ts
2394
+ var EXPLORER = "https://mempool.space";
2395
+ function explorerUrl(kind, value, network = "mainnet") {
2396
+ const net = network === "mainnet" ? "" : `/${network}`;
2397
+ return `${EXPLORER}${net}/${kind}/${encodeURIComponent(String(value))}`;
2398
+ }
2399
+ function shortenMiddle(value, head = 8, tail = 6) {
2400
+ return value.length <= head + tail + 1 ? value : `${value.slice(0, head)}\u2026${value.slice(-tail)}`;
2401
+ }
2402
+ function formatBlockHeight(height) {
2403
+ return Math.trunc(height).toLocaleString("en-US");
2404
+ }
2405
+ function blocksToDuration(blocks, minutesPerBlock = 10) {
2406
+ const minutes = Math.max(0, Math.round(blocks * minutesPerBlock));
2407
+ if (minutes < 60) return `about ${minutes} minute${minutes === 1 ? "" : "s"}`;
2408
+ const units = [
2409
+ [60 * 24 * 7, "week"],
2410
+ [60 * 24, "day"],
2411
+ [60, "hour"],
2412
+ [1, "minute"]
2413
+ ];
2414
+ const parts = [];
2415
+ let rest = minutes;
2416
+ for (const [size, word] of units) {
2417
+ const n = Math.floor(rest / size);
2418
+ if (n > 0 && parts.length < 2) {
2419
+ parts.push(`${n} ${word}${n === 1 ? "" : "s"}`);
2420
+ rest -= n * size;
2421
+ } else if (parts.length > 0) break;
2422
+ }
2423
+ return `about ${parts.join(" ")}`;
2424
+ }
2425
+ var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2426
+ function formatUtc(at2, opts = {}) {
2427
+ const d = typeof at2 === "number" ? new Date(at2 * 1e3) : new Date(at2);
2428
+ if (Number.isNaN(d.getTime())) return "\u2014";
2429
+ const day = `${d.getUTCDate()} ${MONTHS[d.getUTCMonth()]} ${d.getUTCFullYear()}`;
2430
+ if (opts.date) return day;
2431
+ const hh = String(d.getUTCHours()).padStart(2, "0");
2432
+ const mm = String(d.getUTCMinutes()).padStart(2, "0");
2433
+ return `${day}, ${hh}:${mm} UTC`;
2434
+ }
2435
+ function formatBytes(bytes) {
2436
+ if (!Number.isFinite(bytes) || bytes < 0) return "\u2014";
2437
+ if (bytes < 1024) return `${bytes} B`;
2438
+ const units = ["KB", "MB", "GB", "TB"];
2439
+ let v = bytes / 1024;
2440
+ let u = 0;
2441
+ while (v >= 1024 && u < units.length - 1) {
2442
+ v /= 1024;
2443
+ u++;
2444
+ }
2445
+ return `${v < 10 ? v.toFixed(1).replace(/\.0$/, "") : Math.round(v)} ${units[u]}`;
2446
+ }
2447
+ var ShellContext = sharedContext("shell-place", {});
1847
2448
  function useShellPlace() {
1848
2449
  return useContext(ShellContext);
1849
2450
  }
@@ -1866,26 +2467,30 @@ function PageHeader({
1866
2467
  ] });
1867
2468
  }
1868
2469
  var InStatGrid = createContext(false);
1869
- function StatCard({ label, value, hint, className }) {
2470
+ function StatCard({ label, value, hint, size, className }) {
1870
2471
  const inGrid = useContext(InStatGrid);
2472
+ const density = useDensity();
2473
+ const sm = (size ?? (density === "compact" ? "sm" : "md")) === "sm";
1871
2474
  return /* @__PURE__ */ jsxs(
1872
2475
  "div",
1873
2476
  {
1874
2477
  "data-ui": "stat",
1875
2478
  className: cn(
1876
- "rounded-[1.25rem] border border-border bg-card p-5 md:p-6",
2479
+ "border border-border bg-card",
2480
+ sm ? "rounded-2xl p-4" : "rounded-[1.25rem] p-5 md:p-6",
1877
2481
  // In a grid, label, value and hint each share a row with their
1878
2482
  // neighbours, so values line up whatever wraps above them.
1879
2483
  inGrid ? "row-span-3 grid grid-rows-subgrid gap-1.5" : "flex flex-col gap-2",
1880
2484
  className
1881
2485
  ),
1882
2486
  children: [
1883
- /* @__PURE__ */ jsx("span", { className: "text-[0.875rem] leading-snug text-muted-foreground", children: label }),
2487
+ /* @__PURE__ */ jsx("span", { className: cn("leading-snug text-muted-foreground", sm ? "text-[0.8125rem]" : "text-[0.875rem]"), children: label }),
1884
2488
  /* @__PURE__ */ jsx(
1885
2489
  "span",
1886
2490
  {
1887
2491
  className: cn(
1888
- "break-words oca-tabular text-[1.5rem] leading-tight tracking-[-0.02em] md:text-[1.75rem]",
2492
+ "break-words oca-tabular leading-tight tracking-[-0.02em]",
2493
+ sm ? "text-[1.25rem]" : "text-[1.5rem] md:text-[1.75rem]",
1889
2494
  inGrid && "self-end"
1890
2495
  ),
1891
2496
  children: value
@@ -1947,6 +2552,7 @@ function StatGrid({ columns, empty, isEmpty, className, children, ...props }) {
1947
2552
  const items = Children.toArray(children).filter(isValidElement);
1948
2553
  const n = items.length;
1949
2554
  const allZero = n > 0 && items.every((el) => "raw" in el.props && (el.props.raw === 0 || el.props.raw === null));
2555
+ const compact = useDensity() === "compact";
1950
2556
  if (isEmpty ?? allZero) return /* @__PURE__ */ jsx(EmptyLine, { className, children: empty ?? "Nothing here yet." });
1951
2557
  const lg = columns ?? statColumns(n);
1952
2558
  const md = lg > 4 ? 3 : lg;
@@ -1956,7 +2562,8 @@ function StatGrid({ columns, empty, isEmpty, className, children, ...props }) {
1956
2562
  "div",
1957
2563
  {
1958
2564
  className: cn(
1959
- "grid gap-3 md:gap-4",
2565
+ "grid",
2566
+ compact ? "gap-2.5 md:gap-3" : "gap-3 md:gap-4",
1960
2567
  n === 1 ? "grid-cols-1" : "grid-cols-2",
1961
2568
  MD_COLS[md],
1962
2569
  LG_COLS[lg],
@@ -1975,11 +2582,40 @@ function StatGrid({ columns, empty, isEmpty, className, children, ...props }) {
1975
2582
  }
1976
2583
  ) });
1977
2584
  }
1978
- function KeyValueList({ items, className }) {
1979
- return /* @__PURE__ */ jsx("dl", { className: cn("divide-y divide-border rounded-[1.25rem] border border-border bg-card", className), children: items.map((it, i) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 px-5 py-3.5 sm:flex-row sm:items-baseline sm:gap-6", children: [
1980
- /* @__PURE__ */ jsx("dt", { className: "shrink-0 text-[0.875rem] text-muted-foreground sm:w-48", children: it.label }),
1981
- /* @__PURE__ */ jsx("dd", { className: cn("min-w-0 break-words text-[0.9375rem]", it.mono && "font-mono text-[0.875rem]"), children: it.value })
1982
- ] }, i)) });
2585
+ function KeyValueList({
2586
+ items,
2587
+ dense,
2588
+ className
2589
+ }) {
2590
+ const density = useDensity();
2591
+ const tight = dense ?? density === "compact";
2592
+ return (
2593
+ // The rows go side by side when the list itself is wide enough, wherever it sits: a narrow card stacks them.
2594
+ /* @__PURE__ */ jsx("dl", { className: cn("@container divide-y divide-border border border-border bg-card", tight ? "rounded-2xl" : "rounded-[1.25rem]", className), children: items.map((it, i) => /* @__PURE__ */ jsxs(
2595
+ "div",
2596
+ {
2597
+ className: cn(
2598
+ "flex flex-col gap-1 @md:flex-row @md:items-baseline",
2599
+ tight ? "px-4 py-2.5 @md:gap-5" : "px-5 py-3.5 @md:gap-6"
2600
+ ),
2601
+ children: [
2602
+ /* @__PURE__ */ jsx("dt", { className: cn("shrink-0 text-muted-foreground", tight ? "text-[0.8125rem] @md:w-36" : "text-[0.875rem] @md:w-48"), children: it.label }),
2603
+ /* @__PURE__ */ jsx(
2604
+ "dd",
2605
+ {
2606
+ className: cn(
2607
+ "min-w-0 break-words",
2608
+ tight ? "text-[0.875rem]" : "text-[0.9375rem]",
2609
+ it.mono && (tight ? "font-mono text-[0.8125rem]" : "font-mono text-[0.875rem]")
2610
+ ),
2611
+ children: it.value
2612
+ }
2613
+ )
2614
+ ]
2615
+ },
2616
+ i
2617
+ )) })
2618
+ );
1983
2619
  }
1984
2620
  function DataTable({
1985
2621
  columns,
@@ -1988,8 +2624,11 @@ function DataTable({
1988
2624
  empty,
1989
2625
  caption,
1990
2626
  phone = "cards",
2627
+ dense,
1991
2628
  className
1992
2629
  }) {
2630
+ const density = useDensity();
2631
+ const tight = dense ?? density === "compact";
1993
2632
  if (rows.length === 0 && empty) return /* @__PURE__ */ jsx(Fragment, { children: empty });
1994
2633
  const primary = columns.find((c) => c.primary) ?? columns[0];
1995
2634
  const right = (c) => c.numeric || c.align === "end";
@@ -1997,11 +2636,12 @@ function DataTable({
1997
2636
  "div",
1998
2637
  {
1999
2638
  className: cn(
2000
- "overflow-hidden rounded-[1.25rem] border border-border bg-card",
2639
+ "overflow-hidden border border-border bg-card",
2640
+ tight ? "rounded-2xl" : "rounded-[1.25rem]",
2001
2641
  phone === "cards" && "max-sm:hidden",
2002
2642
  className
2003
2643
  ),
2004
- children: /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--card)", children: /* @__PURE__ */ jsxs("table", { className: "w-full border-collapse text-left text-[0.9375rem]", children: [
2644
+ children: /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--card)", children: /* @__PURE__ */ jsxs("table", { className: cn("w-full border-collapse text-left", tight ? "text-[0.875rem]" : "text-[0.9375rem]"), children: [
2005
2645
  caption ? /* @__PURE__ */ jsx("caption", { className: "sr-only", children: caption }) : null,
2006
2646
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "border-b border-border", children: columns.map((c) => /* @__PURE__ */ jsx(
2007
2647
  "th",
@@ -2009,7 +2649,8 @@ function DataTable({
2009
2649
  scope: "col",
2010
2650
  style: { width: c.width, minWidth: c.minWidth },
2011
2651
  className: cn(
2012
- "whitespace-nowrap px-5 py-3 text-[0.8125rem] font-medium text-muted-foreground",
2652
+ "whitespace-nowrap text-[0.8125rem] font-medium text-muted-foreground",
2653
+ tight ? "px-4 py-2.5" : "px-5 py-3",
2013
2654
  right(c) && "text-right",
2014
2655
  c.wide && "hidden md:table-cell"
2015
2656
  ),
@@ -2022,7 +2663,8 @@ function DataTable({
2022
2663
  {
2023
2664
  style: { minWidth: c.minWidth },
2024
2665
  className: cn(
2025
- "px-5 py-3.5 align-middle",
2666
+ "align-middle",
2667
+ tight ? "px-4 py-2" : "px-5 py-3.5",
2026
2668
  right(c) && "text-right",
2027
2669
  c.numeric && "whitespace-nowrap oca-tabular",
2028
2670
  c.wide && "hidden md:table-cell"
@@ -2042,8 +2684,12 @@ function DataTable({
2042
2684
  "ul",
2043
2685
  {
2044
2686
  "aria-label": caption,
2045
- className: cn("divide-y divide-border rounded-[1.25rem] border border-border bg-card sm:hidden", className),
2046
- children: rows.map((r, i) => /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-2.5 px-4 py-4", children: [
2687
+ className: cn(
2688
+ "divide-y divide-border border border-border bg-card sm:hidden",
2689
+ tight ? "rounded-2xl" : "rounded-[1.25rem]",
2690
+ className
2691
+ ),
2692
+ children: rows.map((r, i) => /* @__PURE__ */ jsxs("li", { className: cn("flex flex-col gap-2.5 px-4", tight ? "py-3" : "py-4"), children: [
2047
2693
  /* @__PURE__ */ jsx("div", { className: "min-w-0 break-words text-[0.9375rem] font-medium", children: primary?.cell(r) }),
2048
2694
  rest.length > 0 ? /* @__PURE__ */ jsx("dl", { className: "grid grid-cols-[minmax(5.5rem,auto)_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-[0.875rem]", children: rest.map((c) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
2049
2695
  /* @__PURE__ */ jsx("dt", { className: "text-muted-foreground", children: c.header }),
@@ -2090,13 +2736,14 @@ function Notice({
2090
2736
  title,
2091
2737
  children,
2092
2738
  action,
2739
+ role,
2093
2740
  className
2094
2741
  }) {
2095
2742
  const kind = NOTICE_KIND[tone];
2096
2743
  return /* @__PURE__ */ jsxs(
2097
2744
  "div",
2098
2745
  {
2099
- role: tone === "danger" || tone === "warning" ? "alert" : "note",
2746
+ role: role ?? (tone === "danger" || tone === "warning" ? "alert" : "note"),
2100
2747
  "data-tone": kind,
2101
2748
  className: cn(
2102
2749
  "flex flex-col gap-3 rounded-2xl border border-border bg-card px-5 py-4 sm:flex-row sm:items-start sm:justify-between",
@@ -2146,45 +2793,66 @@ function LoadingBlock({
2146
2793
  }
2147
2794
  return /* @__PURE__ */ jsx("div", { role: "status", "aria-label": label, className: cn("flex flex-col gap-3", className), children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-16 rounded-2xl" }, i)) });
2148
2795
  }
2149
- function middle(v, head, tail) {
2150
- return v.length <= head + tail + 1 ? v : `${v.slice(0, head)}\u2026${v.slice(-tail)}`;
2796
+ async function wipeIfUnchanged(expected) {
2797
+ try {
2798
+ if (await navigator.clipboard.readText() !== expected) return;
2799
+ } catch {
2800
+ }
2801
+ try {
2802
+ await navigator.clipboard.writeText("");
2803
+ } catch {
2804
+ }
2151
2805
  }
2152
2806
  function useCopy(timeoutMs = 1600) {
2153
2807
  const [copied, setCopied] = useState(false);
2154
2808
  const t = useRef(null);
2155
- useEffect(() => () => {
2156
- if (t.current) clearTimeout(t.current);
2157
- }, []);
2809
+ const wipe = useRef(null);
2810
+ useEffect(
2811
+ () => () => {
2812
+ if (t.current) clearTimeout(t.current);
2813
+ },
2814
+ []
2815
+ );
2158
2816
  const copy = useCallback(
2159
- async (text) => {
2817
+ async (text, opts = {}) => {
2160
2818
  try {
2161
2819
  await navigator.clipboard.writeText(text);
2162
2820
  setCopied(true);
2163
2821
  if (t.current) clearTimeout(t.current);
2164
2822
  t.current = setTimeout(() => setCopied(false), timeoutMs);
2823
+ if (opts.clearAfter && opts.clearAfter > 0) {
2824
+ if (wipe.current) clearTimeout(wipe.current);
2825
+ wipe.current = setTimeout(() => void wipeIfUnchanged(text), opts.clearAfter);
2826
+ }
2827
+ return true;
2165
2828
  } catch {
2166
2829
  setCopied(false);
2830
+ return false;
2167
2831
  }
2168
2832
  },
2169
2833
  [timeoutMs]
2170
2834
  );
2171
2835
  return { copied, copy };
2172
2836
  }
2173
- function CopyButton({ value, label = "Copy", className }) {
2837
+ function CopyButton({ value, label = "Copy", clearAfter, onCopied, className }) {
2174
2838
  const { copied, copy } = useCopy();
2839
+ const done2 = copied ? clearAfter ? `Copied. Cleared in ${Math.round(clearAfter / 1e3)} seconds` : "Copied" : "";
2175
2840
  return /* @__PURE__ */ jsxs(
2176
2841
  "button",
2177
2842
  {
2178
2843
  type: "button",
2179
- onClick: () => void copy(value),
2844
+ onClick: async () => {
2845
+ if (await copy(typeof value === "function" ? value() : value, { clearAfter })) onCopied?.();
2846
+ },
2180
2847
  "aria-label": copied ? "Copied" : label,
2848
+ title: label,
2181
2849
  className: cn(
2182
2850
  "inline-flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
2183
2851
  className
2184
2852
  ),
2185
2853
  children: [
2186
2854
  copied ? /* @__PURE__ */ jsx(Check, { className: "size-4 text-success" }) : /* @__PURE__ */ jsx(Copy, { className: "size-4" }),
2187
- /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", children: copied ? "Copied" : "" })
2855
+ /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", children: done2 })
2188
2856
  ]
2189
2857
  }
2190
2858
  );
@@ -2195,12 +2863,27 @@ function HashChip({
2195
2863
  tail = 6,
2196
2864
  copy = true,
2197
2865
  href,
2866
+ explorer,
2867
+ network = "mainnet",
2198
2868
  className
2199
2869
  }) {
2200
- const shown = middle(value, head, tail);
2870
+ const shown = shortenMiddle(value, head, tail);
2871
+ const link = href ?? (explorer ? explorerUrl(explorer, value, network) : void 0);
2872
+ const offsite = !!link && /^https?:\/\//.test(link);
2201
2873
  const text = /* @__PURE__ */ jsx("span", { title: value, className: "font-mono text-[0.875rem]", children: shown });
2202
2874
  return /* @__PURE__ */ jsxs("span", { className: cn("inline-flex max-w-full items-center gap-1", className), children: [
2203
- href ? /* @__PURE__ */ jsx("a", { href, className: "underline decoration-foreground/35 underline-offset-4 hover:decoration-foreground", children: text }) : text,
2875
+ link ? /* @__PURE__ */ jsxs(
2876
+ "a",
2877
+ {
2878
+ href: link,
2879
+ ...offsite ? { target: "_blank", rel: "noreferrer" } : {},
2880
+ className: "underline decoration-foreground/35 underline-offset-4 hover:decoration-foreground",
2881
+ children: [
2882
+ text,
2883
+ offsite ? /* @__PURE__ */ jsx("span", { className: "sr-only", children: " (opens in a new tab)" }) : null
2884
+ ]
2885
+ }
2886
+ ) : text,
2204
2887
  copy ? /* @__PURE__ */ jsx(CopyButton, { value, label: "Copy full value" }) : null
2205
2888
  ] });
2206
2889
  }
@@ -2254,96 +2937,269 @@ function ActivityList({ items, empty, className }) {
2254
2937
  return /* @__PURE__ */ jsx("li", { children: it.href ? /* @__PURE__ */ jsx("a", { href: it.href, className: "block transition-colors hover:bg-accent/60", children: body }) : body }, it.id);
2255
2938
  }) });
2256
2939
  }
2257
- var KIND = {
2258
- package: "text-oca-code-package",
2259
- tag: "text-oca-code-tag",
2260
- link: "text-oca-code-link"
2940
+ var LANG_NAME = {
2941
+ ts: "TypeScript",
2942
+ typescript: "TypeScript",
2943
+ tsx: "TSX",
2944
+ js: "JavaScript",
2945
+ javascript: "JavaScript",
2946
+ jsx: "JSX",
2947
+ mjs: "JavaScript",
2948
+ json: "JSON",
2949
+ jsonc: "JSON",
2950
+ bash: "Shell",
2951
+ sh: "Shell",
2952
+ shell: "Shell",
2953
+ zsh: "Shell",
2954
+ console: "Terminal",
2955
+ terminal: "Terminal",
2956
+ python: "Python",
2957
+ py: "Python",
2958
+ yaml: "YAML",
2959
+ yml: "YAML",
2960
+ diff: "Diff",
2961
+ text: "Text"
2261
2962
  };
2262
- function PackageCard({ items, className }) {
2263
- return /* @__PURE__ */ jsx(
2264
- "div",
2265
- {
2266
- className: cn(
2267
- "grid gap-x-10 gap-y-7 rounded-[1.25rem] border border-oca-ink-line bg-oca-ink-card p-6 text-oca-ink-foreground md:grid-cols-2 md:p-9",
2268
- className
2269
- ),
2270
- children: items.map((it, i) => {
2271
- const code = /* @__PURE__ */ jsx("span", { className: cn("text-[0.9375rem]", KIND[it.kind ?? "package"]), children: it.code });
2272
- return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1.5", children: [
2273
- /* @__PURE__ */ jsx("h3", { className: "text-[1.125rem] font-semibold tracking-[-0.01em] text-oca-ink-title", children: it.title }),
2274
- it.href ? /* @__PURE__ */ jsx("a", { href: it.href, className: "w-fit underline decoration-transparent underline-offset-4 hover:decoration-current", children: code }) : code,
2275
- it.note ? /* @__PURE__ */ jsxs("p", { className: "text-[0.9375rem] leading-relaxed text-oca-ink-subtle", children: [
2276
- /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "// " }),
2277
- it.note
2278
- ] }) : null
2279
- ] }, i);
2280
- })
2281
- }
2282
- );
2963
+ function languageName(lang) {
2964
+ return lang ? LANG_NAME[lang.toLowerCase()] ?? lang : void 0;
2965
+ }
2966
+ function forClipboard(text, lang) {
2967
+ if (grammarOf(lang) !== "shell") return text;
2968
+ const lines = text.split("\n");
2969
+ if (!lines.some((l) => l.startsWith("$ "))) return text;
2970
+ return lines.filter((l) => l.startsWith("$ ")).map((l) => l.slice(2)).join("\n");
2971
+ }
2972
+ function linesFromDom(pre) {
2973
+ if (!pre) return null;
2974
+ const lines = pre.querySelectorAll("[data-line]");
2975
+ if (lines.length === 0) return pre.textContent ?? "";
2976
+ return Array.from(lines).filter((l) => l.getAttribute("data-diff") !== "remove").map((l) => l.textContent ?? "").join("\n");
2977
+ }
2978
+ function prepare(code, lang, marks, diff) {
2979
+ const d = diff ? readDiff(code) : null;
2980
+ const src = d ? d.code : code.replace(/\r?\n$/, "");
2981
+ const lines = highlight(src, lang === "diff" ? void 0 : lang);
2982
+ const kept = d ? src.split("\n").filter((_, i) => d.diff.get(i + 1) !== "remove") : null;
2983
+ return {
2984
+ html: linesToHtml(lines, { highlight: parseLineRanges(marks), diff: d?.diff }),
2985
+ copy: kept ? kept.join("\n") : src,
2986
+ lines: lines.length,
2987
+ diff: !!d
2988
+ };
2989
+ }
2990
+ function Well({
2991
+ preRef,
2992
+ html,
2993
+ children,
2994
+ lang,
2995
+ lines,
2996
+ maxLines,
2997
+ diff,
2998
+ lineNumbers
2999
+ }) {
3000
+ const foldable = maxLines !== void 0 && lines > maxLines + 2;
3001
+ const [open, setOpen] = useState(false);
3002
+ const folded = foldable && !open;
3003
+ const lined = html !== void 0;
3004
+ return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3005
+ /* @__PURE__ */ jsx(
3006
+ "div",
3007
+ {
3008
+ className: cn(folded && "overflow-hidden"),
3009
+ style: folded ? { maxHeight: `calc(${maxLines} * 1.625em + 2rem)` } : void 0,
3010
+ children: /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--oca-code-surface)", children: /* @__PURE__ */ jsx(
3011
+ "pre",
3012
+ {
3013
+ ref: preRef,
3014
+ "data-diff": diff ? "" : void 0,
3015
+ "data-line-numbers": lineNumbers ? "" : void 0,
3016
+ className: cn(
3017
+ "oca-code w-max min-w-full py-4 font-mono text-[0.875rem] leading-[1.625] text-oca-ink-muted [font-variant-ligatures:none]",
3018
+ !lined && "px-5"
3019
+ ),
3020
+ children: lined ? /* @__PURE__ */ jsx("code", { className: "block", "data-lang": lang, dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx("code", { className: "block", "data-lang": lang, children })
3021
+ }
3022
+ ) })
3023
+ }
3024
+ ),
3025
+ foldable ? /* @__PURE__ */ jsx(
3026
+ "div",
3027
+ {
3028
+ className: cn("flex justify-center px-5 pb-4", folded && "absolute inset-x-0 bottom-0 pt-16"),
3029
+ style: folded ? { background: "linear-gradient(to top, var(--oca-code-surface) 40%, transparent)" } : void 0,
3030
+ children: /* @__PURE__ */ jsx(
3031
+ "button",
3032
+ {
3033
+ type: "button",
3034
+ onClick: () => setOpen((v) => !v),
3035
+ "aria-expanded": open,
3036
+ className: "rounded-full border border-white/20 px-4 py-1.5 text-[0.8125rem] text-white transition-colors hover:bg-white/10",
3037
+ children: open ? "Show less" : `Show all ${lines} lines`
3038
+ }
3039
+ )
3040
+ }
3041
+ ) : null
3042
+ ] });
2283
3043
  }
3044
+ var FRAME = "overflow-hidden rounded-[1.25rem] border border-[var(--oca-code-line)] bg-[var(--oca-code-surface)]";
3045
+ var COPY_ON_INK = "text-oca-ink-subtle hover:bg-white/10 hover:text-white";
2284
3046
  function CodeBlock({
2285
3047
  code,
3048
+ html,
3049
+ children,
3050
+ lang,
2286
3051
  caption,
2287
3052
  copy = true,
3053
+ clearAfter,
2288
3054
  maxLines,
3055
+ highlight: marks,
3056
+ diff,
3057
+ lineNumbers,
3058
+ actions,
2289
3059
  className
2290
3060
  }) {
2291
- const lines = code.split("\n").length;
2292
- const foldable = maxLines !== void 0 && lines > maxLines + 2;
2293
- const [open, setOpen] = useState(false);
2294
- const folded = foldable && !open;
3061
+ const preRef = useRef(null);
3062
+ const isDiff = diff || lang === "diff";
3063
+ const markKey = typeof marks === "string" ? marks : marks?.join(",");
3064
+ const prepared = useMemo(
3065
+ () => html === void 0 && children === void 0 && code !== void 0 ? prepare(code, lang, markKey, !!isDiff) : null,
3066
+ [code, html, children, lang, markKey, isDiff]
3067
+ );
3068
+ const markup = prepared?.html ?? html;
3069
+ const lines = prepared?.lines ?? (html !== void 0 ? html.split("\n").length : code?.split("\n").length ?? 0);
3070
+ const read = () => forClipboard(prepared?.copy ?? linesFromDom(preRef.current) ?? code ?? "", lang);
3071
+ return /* @__PURE__ */ jsxs("figure", { className: cn(FRAME, className), children: [
3072
+ /* @__PURE__ */ jsxs("figcaption", { className: "flex h-11 items-center justify-between gap-3 border-b border-[var(--oca-code-line)] pl-5 pr-2", children: [
3073
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[0.8125rem] text-oca-ink-subtle", children: caption ?? languageName(lang) ?? "Code" }),
3074
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [
3075
+ actions,
3076
+ copy ? /* @__PURE__ */ jsx(CopyButton, { value: read, label: "Copy code", clearAfter, className: COPY_ON_INK }) : null
3077
+ ] })
3078
+ ] }),
3079
+ /* @__PURE__ */ jsx(
3080
+ Well,
3081
+ {
3082
+ preRef,
3083
+ html: markup,
3084
+ lang,
3085
+ lines,
3086
+ maxLines,
3087
+ diff: prepared ? prepared.diff : isDiff,
3088
+ lineNumbers,
3089
+ children
3090
+ }
3091
+ )
3092
+ ] });
3093
+ }
3094
+ var tabListeners = /* @__PURE__ */ new Map();
3095
+ var tabMemory = /* @__PURE__ */ new Map();
3096
+ var storeKey = (k) => `oca-code-tab:${k}`;
3097
+ function readTab(key) {
3098
+ if (tabMemory.has(key)) return tabMemory.get(key);
3099
+ try {
3100
+ return window.localStorage.getItem(storeKey(key));
3101
+ } catch {
3102
+ return null;
3103
+ }
3104
+ }
3105
+ function writeTab(key, value) {
3106
+ tabMemory.set(key, value);
3107
+ try {
3108
+ window.localStorage.setItem(storeKey(key), value);
3109
+ } catch {
3110
+ }
3111
+ tabListeners.get(key)?.forEach((l) => l());
3112
+ }
3113
+ function useSyncedTab(key) {
3114
+ const subscribe2 = useCallback(
3115
+ (cb) => {
3116
+ if (!key) return () => {
3117
+ };
3118
+ const set = tabListeners.get(key) ?? /* @__PURE__ */ new Set();
3119
+ set.add(cb);
3120
+ tabListeners.set(key, set);
3121
+ return () => {
3122
+ set.delete(cb);
3123
+ };
3124
+ },
3125
+ [key]
3126
+ );
3127
+ const value = useSyncExternalStore(
3128
+ subscribe2,
3129
+ () => key ? readTab(key) : null,
3130
+ () => null
3131
+ );
3132
+ return [value, (v) => key && writeTab(key, v)];
3133
+ }
3134
+ function CodeTabs({
3135
+ items,
3136
+ syncKey,
3137
+ defaultValue,
3138
+ maxLines,
3139
+ className
3140
+ }) {
3141
+ const [synced, setSynced] = useSyncedTab(syncKey);
3142
+ const [local, setLocal] = useState(null);
3143
+ const labels = items.map((it) => it.label);
3144
+ const pick = [local, synced, defaultValue].find((v) => !!v && labels.includes(v)) ?? labels[0] ?? "";
3145
+ const active = items.find((it) => it.label === pick);
3146
+ const prepared = useMemo(() => items.map((it) => prepare(it.code, it.lang, void 0, it.lang === "diff")), [items]);
2295
3147
  return /* @__PURE__ */ jsxs(
2296
- "figure",
3148
+ TabsPrimitive.Root,
2297
3149
  {
2298
- className: cn(
2299
- "overflow-hidden rounded-[1.25rem] border border-[var(--oca-code-line)] bg-[var(--oca-code-surface)]",
2300
- className
2301
- ),
3150
+ value: pick,
3151
+ onValueChange: (v) => {
3152
+ setLocal(v);
3153
+ setSynced(v);
3154
+ },
3155
+ className: cn(FRAME, className),
2302
3156
  children: [
2303
- /* @__PURE__ */ jsxs("figcaption", { className: "flex h-11 items-center justify-between gap-3 border-b border-[var(--oca-code-line)] pl-5 pr-2", children: [
2304
- /* @__PURE__ */ jsx("span", { className: "truncate text-[0.8125rem] text-oca-ink-subtle", children: caption ?? "Code" }),
2305
- copy ? /* @__PURE__ */ jsx(
2306
- CopyButton,
2307
- {
2308
- value: code,
2309
- label: "Copy code",
2310
- className: "text-oca-ink-subtle hover:bg-white/10 hover:text-white"
2311
- }
2312
- ) : null
2313
- ] }),
2314
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
2315
- /* @__PURE__ */ jsx(
2316
- "div",
2317
- {
2318
- className: cn(folded && "overflow-hidden"),
2319
- style: folded ? { maxHeight: `calc(${maxLines} * 1.625em + 2.5rem)` } : void 0,
2320
- children: /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--oca-code-surface)", children: /* @__PURE__ */ jsx("pre", { className: "w-max min-w-full p-5 font-mono text-[0.875rem] leading-[1.625] text-oca-ink-muted [font-variant-ligatures:none]", children: /* @__PURE__ */ jsx("code", { children: code }) }) })
2321
- }
2322
- ),
2323
- foldable ? /* @__PURE__ */ jsx(
2324
- "div",
3157
+ /* @__PURE__ */ jsxs("div", { className: "flex h-11 items-center justify-between gap-3 border-b border-[var(--oca-code-line)] pl-2 pr-2", children: [
3158
+ /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--oca-code-surface)", className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(TabsPrimitive.List, { "aria-label": "Versions", className: "flex w-max items-center gap-0.5", children: items.map((it) => /* @__PURE__ */ jsx(
3159
+ TabsPrimitive.Trigger,
2325
3160
  {
3161
+ value: it.label,
2326
3162
  className: cn(
2327
- "flex justify-center px-5 pb-4",
2328
- folded && "absolute inset-x-0 bottom-0 pt-16"
3163
+ "relative inline-flex h-11 items-center whitespace-nowrap px-3 text-[0.8125rem] text-oca-ink-subtle outline-none transition-colors",
3164
+ "hover:text-white focus-visible:text-white focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
3165
+ "data-[state=active]:text-white",
3166
+ "after:absolute after:inset-x-3 after:bottom-0 after:h-0.5 after:rounded-full after:bg-transparent data-[state=active]:after:bg-oca-orange"
2329
3167
  ),
2330
- style: folded ? { background: "linear-gradient(to top, var(--oca-code-surface) 40%, transparent)" } : void 0,
2331
- children: /* @__PURE__ */ jsx(
2332
- "button",
2333
- {
2334
- type: "button",
2335
- onClick: () => setOpen((v) => !v),
2336
- className: "rounded-full border border-white/20 px-4 py-1.5 text-[0.8125rem] text-white transition-colors hover:bg-white/10",
2337
- children: open ? "Show less" : `Show all ${lines} lines`
2338
- }
2339
- )
3168
+ children: it.label
3169
+ },
3170
+ it.label
3171
+ )) }) }),
3172
+ active ? /* @__PURE__ */ jsx(
3173
+ CopyButton,
3174
+ {
3175
+ value: () => forClipboard(prepared[items.indexOf(active)]?.copy ?? active.code, active.lang),
3176
+ label: `Copy ${active.label}`,
3177
+ className: COPY_ON_INK
2340
3178
  }
2341
3179
  ) : null
2342
- ] })
3180
+ ] }),
3181
+ items.map((it, i) => /* @__PURE__ */ jsx(TabsPrimitive.Content, { value: it.label, className: "outline-none", tabIndex: -1, children: /* @__PURE__ */ jsx(
3182
+ Well,
3183
+ {
3184
+ html: prepared[i].html,
3185
+ lang: it.lang,
3186
+ lines: prepared[i].lines,
3187
+ maxLines,
3188
+ diff: prepared[i].diff
3189
+ }
3190
+ ) }, it.label))
2343
3191
  ]
2344
3192
  }
2345
3193
  );
2346
3194
  }
3195
+ function InstallTabs({ pkg, dev = false, className }) {
3196
+ const items = [
3197
+ { label: "npm", code: `npm install ${dev ? "--save-dev " : ""}${pkg}`, lang: "bash" },
3198
+ { label: "yarn", code: `yarn add ${dev ? "--dev " : ""}${pkg}`, lang: "bash" },
3199
+ { label: "pnpm", code: `pnpm add ${dev ? "--save-dev " : ""}${pkg}`, lang: "bash" }
3200
+ ];
3201
+ return /* @__PURE__ */ jsx(CodeTabs, { items, syncKey: "package-manager", className });
3202
+ }
2347
3203
  function SplitBar({
2348
3204
  segments,
2349
3205
  caption,
@@ -2728,7 +3584,7 @@ function ErrorPage({
2728
3584
  /* @__PURE__ */ jsx("p", { className: "oca-lead oca-enter [--enter-delay:150ms]", children: detail ?? words.detail }),
2729
3585
  /* @__PURE__ */ jsx("div", { className: "oca-enter flex flex-wrap gap-3 [--enter-delay:230ms]", children: actions ?? /* @__PURE__ */ jsxs(Fragment, { children: [
2730
3586
  server ? /* @__PURE__ */ jsx(Button, { onClick: () => window.location.reload(), children: "Try again" }) : null,
2731
- /* @__PURE__ */ jsx(Button, { asChild: true, variant: server ? "secondary" : "primary", children: /* @__PURE__ */ jsx(Link5, { href: home, children: "Go home" }) })
3587
+ /* @__PURE__ */ jsx(Button, { asChild: true, variant: server ? "secondary" : "primary", children: /* @__PURE__ */ jsx(Link8, { href: home, children: "Go home" }) })
2732
3588
  ] }) })
2733
3589
  ] }),
2734
3590
  art !== null ? /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: "oca-enter hidden justify-center md:col-span-5 md:flex [--enter-delay:120ms]", children: art ?? /* @__PURE__ */ jsx(MarkOutline, { className: "w-full max-w-[20rem] text-oca-hairline-strong" }) }) : null
@@ -2856,7 +3712,7 @@ function TextLink({
2856
3712
  const internal = href.startsWith("/") && !href.startsWith("/api/") && !href.startsWith("/.well-known/");
2857
3713
  const offsite = external ?? /^https?:\/\//.test(href);
2858
3714
  if (internal && !offsite) {
2859
- return /* @__PURE__ */ jsx(Link5, { href, className: cn(LINK, className), children });
3715
+ return /* @__PURE__ */ jsx(Link8, { href, className: cn(LINK, className), children });
2860
3716
  }
2861
3717
  return /* @__PURE__ */ jsxs("a", { href, className: cn(LINK, className), ...offsite ? { target: "_blank", rel: "noreferrer" } : {}, children: [
2862
3718
  children,
@@ -3136,7 +3992,14 @@ function ProtocolGrid({
3136
3992
  ] }),
3137
3993
  p.status !== "live" ? /* @__PURE__ */ jsx(StatusBadge, { status: p.status }) : null
3138
3994
  ] }),
3139
- /* @__PURE__ */ jsx("h3", { className: "oca-display-3", children: /* @__PURE__ */ jsx("a", { href: link === "tool" ? p.toolHref : p.pageHref, className: STRETCH, children: p.label }) }),
3995
+ /* @__PURE__ */ jsx("h3", { className: "oca-display-3", children: /* @__PURE__ */ jsx(
3996
+ "a",
3997
+ {
3998
+ href: link === "tool" ? p.toolHref : link === "docs" ? `${DOCS_HREF}/${p.slug}` : p.pageHref,
3999
+ className: STRETCH,
4000
+ children: p.label
4001
+ }
4002
+ ) }),
3140
4003
  /* @__PURE__ */ jsx("p", { className: "oca-body", children: p.line }),
3141
4004
  /* @__PURE__ */ jsxs("div", { className: "mt-auto flex items-center justify-between gap-3 pt-2 text-[0.875rem] text-muted-foreground", children: [
3142
4005
  /* @__PURE__ */ jsxs("span", { className: "oca-tabular", children: [
@@ -3434,6 +4297,7 @@ function VerifyReport({
3434
4297
  facts,
3435
4298
  notChecked,
3436
4299
  actions,
4300
+ as: Heading = "h2",
3437
4301
  className
3438
4302
  }) {
3439
4303
  return /* @__PURE__ */ jsxs(
@@ -3444,7 +4308,7 @@ function VerifyReport({
3444
4308
  children: [
3445
4309
  /* @__PURE__ */ jsxs("header", { className: "flex flex-col items-start gap-3 p-6 md:p-8", children: [
3446
4310
  /* @__PURE__ */ jsx(StatusBadge, { status: verdict }),
3447
- /* @__PURE__ */ jsx("h3", { className: "oca-display-3", children: title }),
4311
+ /* @__PURE__ */ jsx(Heading, { className: "oca-display-3", children: title }),
3448
4312
  summary ? /* @__PURE__ */ jsx("p", { className: "oca-body max-w-[40rem]", children: summary }) : null
3449
4313
  ] }),
3450
4314
  /* @__PURE__ */ jsx("ul", { "aria-label": "Checks", className: "divide-y divide-border border-t border-border", children: checks.map((c, i) => {
@@ -3544,12 +4408,1210 @@ function SignMessage({
3544
4408
  )
3545
4409
  ] });
3546
4410
  }
3547
- function SiteRow({ site, here, onNavigate }) {
3548
- return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
3549
- "a",
4411
+ var isInternal = (href) => href.startsWith("/") || href.startsWith("#");
4412
+ function DocLink({ href, className, children, ...rest }) {
4413
+ return isInternal(href) ? /* @__PURE__ */ jsx(Link8, { href, className, ...rest, children }) : /* @__PURE__ */ jsx("a", { href, className, ...rest, children });
4414
+ }
4415
+ function Breadcrumbs({ items, action, className }) {
4416
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex min-h-11 items-center justify-between gap-4 sm:min-h-0", className), children: [
4417
+ /* @__PURE__ */ jsx("nav", { "aria-label": "Breadcrumb", className: "min-w-0", children: /* @__PURE__ */ jsx("ol", { className: "flex min-w-0 items-center gap-1.5 text-[0.875rem] text-muted-foreground", children: items.map((c, i) => {
4418
+ const last = i === items.length - 1;
4419
+ return /* @__PURE__ */ jsxs("li", { className: cn("flex items-center gap-1.5", last ? "min-w-0" : "shrink-0"), children: [
4420
+ c.href && !last ? /* @__PURE__ */ jsx(DocLink, { href: c.href, className: "inline-flex min-h-11 items-center transition-colors hover:text-foreground sm:min-h-0", children: c.label }) : /* @__PURE__ */ jsx("span", { "aria-current": last ? "page" : void 0, className: cn("truncate", last && "text-foreground"), children: c.label }),
4421
+ !last ? /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-3.5 shrink-0 text-oca-subtle" }) : null
4422
+ ] }, i);
4423
+ }) }) }),
4424
+ action ? /* @__PURE__ */ jsx("div", { className: "shrink-0 text-[0.875rem]", children: action }) : null
4425
+ ] });
4426
+ }
4427
+ function DocsPager({ prev, next, className }) {
4428
+ if (!prev && !next) return null;
4429
+ const card = (l, dir) => /* @__PURE__ */ jsxs(
4430
+ DocLink,
3550
4431
  {
3551
- href: site.href,
3552
- onClick: onNavigate,
4432
+ href: l.href,
4433
+ className: cn(
4434
+ "group flex min-h-20 flex-col justify-center gap-1 rounded-2xl border border-border bg-card px-5 py-4 transition-colors hover:border-oca-hairline-strong",
4435
+ dir === "next" && "items-end text-right sm:col-start-2"
4436
+ ),
4437
+ children: [
4438
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-[0.8125rem] text-muted-foreground", children: [
4439
+ dir === "prev" ? /* @__PURE__ */ jsx(ArrowLeft, { "aria-hidden": true, className: "size-3.5" }) : null,
4440
+ dir === "prev" ? "Previous" : "Next",
4441
+ l.section ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "\xB7" }) : null,
4442
+ l.section ? /* @__PURE__ */ jsx("span", { className: "truncate", children: l.section }) : null,
4443
+ dir === "next" ? /* @__PURE__ */ jsx(ArrowRight, { "aria-hidden": true, className: "size-3.5" }) : null
4444
+ ] }),
4445
+ /* @__PURE__ */ jsx("span", { className: "text-[1rem] font-medium leading-snug text-foreground", children: l.label })
4446
+ ]
4447
+ }
4448
+ );
4449
+ return /* @__PURE__ */ jsxs("nav", { "aria-label": "Previous and next page", className: cn("grid grid-cols-1 gap-3 border-t border-border pt-8 sm:grid-cols-2", className), children: [
4450
+ prev ? card(prev, "prev") : null,
4451
+ next ? card(next, "next") : null
4452
+ ] });
4453
+ }
4454
+ function useHeadings(selector = "#docs-content", key) {
4455
+ const [items, setItems] = useState([]);
4456
+ useEffect(() => {
4457
+ const read = () => {
4458
+ const root = document.querySelector(selector);
4459
+ if (!root) return setItems([]);
4460
+ setItems(
4461
+ Array.from(root.querySelectorAll("h2[id], h3[id]")).map((h) => ({
4462
+ id: h.id,
4463
+ // The anchor link's "#" is not part of the name.
4464
+ label: (h.querySelector("[data-heading-text]") ?? h).textContent?.trim() ?? "",
4465
+ level: h.tagName === "H3" ? 3 : 2
4466
+ }))
4467
+ );
4468
+ };
4469
+ const raf = requestAnimationFrame(read);
4470
+ const t = setTimeout(read, 80);
4471
+ return () => {
4472
+ cancelAnimationFrame(raf);
4473
+ clearTimeout(t);
4474
+ };
4475
+ }, [selector, key]);
4476
+ const activeId = useActiveHeading(items.map((i) => i.id));
4477
+ return { items, activeId };
4478
+ }
4479
+ function OnThisPage({
4480
+ items,
4481
+ activeId,
4482
+ title = "On this page",
4483
+ onNavigate,
4484
+ className
4485
+ }) {
4486
+ const id = useId();
4487
+ if (items.length === 0) return null;
4488
+ return (
4489
+ // With no visible title (a folded list under its own summary) the name is still "On this page".
4490
+ /* @__PURE__ */ jsxs("nav", { "aria-labelledby": title ? id : void 0, "aria-label": title ? void 0 : "On this page", className, children: [
4491
+ title ? /* @__PURE__ */ jsx("p", { id, className: "mb-3 text-[0.875rem] font-medium", children: title }) : null,
4492
+ /* @__PURE__ */ jsx("ul", { children: items.map((t) => {
4493
+ const on = t.id === activeId;
4494
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
4495
+ "a",
4496
+ {
4497
+ href: `#${t.id}`,
4498
+ onClick: onNavigate,
4499
+ "aria-current": on ? "location" : void 0,
4500
+ className: cn(
4501
+ "block border-l py-1.5 text-[0.875rem] leading-snug transition-colors",
4502
+ t.level === 3 ? "pl-7" : "pl-4",
4503
+ on ? "border-foreground text-foreground" : "border-border text-muted-foreground hover:text-foreground"
4504
+ ),
4505
+ children: t.label
4506
+ }
4507
+ ) }, t.id);
4508
+ }) })
4509
+ ] })
4510
+ );
4511
+ }
4512
+ var CALLOUT_TONE = { note: "neutral", warning: "brand", danger: "danger" };
4513
+ function Callout({
4514
+ tone = "note",
4515
+ title,
4516
+ children,
4517
+ className
4518
+ }) {
4519
+ return /* @__PURE__ */ jsx(
4520
+ Notice,
4521
+ {
4522
+ tone: CALLOUT_TONE[tone],
4523
+ title,
4524
+ role: "note",
4525
+ className: cn("my-6 [&_p]:my-0 [&_p]:text-[0.9375rem] [&_p]:leading-relaxed [&_p+p]:mt-3", className),
4526
+ children
4527
+ }
4528
+ );
4529
+ }
4530
+ function Step({ title, id, children }) {
4531
+ return /* @__PURE__ */ jsxs("li", { className: "relative pb-8 pl-11 last:pb-0 [counter-increment:oca-step]", children: [
4532
+ /* @__PURE__ */ jsx(
4533
+ "span",
4534
+ {
4535
+ "aria-hidden": true,
4536
+ className: "absolute left-0 top-0 flex size-7 items-center justify-center rounded-full border border-oca-hairline-strong bg-card text-[0.8125rem] oca-tabular text-foreground before:content-[counter(oca-step)]"
4537
+ }
4538
+ ),
4539
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute bottom-1 left-[0.8125rem] top-9 w-px bg-border" }),
4540
+ /* @__PURE__ */ jsx("h3", { id, className: "scroll-mt-28 pt-0.5 text-[1.0625rem] font-medium leading-snug tracking-[-0.008em] text-foreground", children: title }),
4541
+ /* @__PURE__ */ jsx("div", { className: "mt-2 text-muted-foreground [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", children })
4542
+ ] });
4543
+ }
4544
+ function Steps({ children, className }) {
4545
+ return /* @__PURE__ */ jsx("ol", { className: cn("not-prose my-8 flex flex-col [counter-reset:oca-step] [&>li:last-child>span:nth-child(2)]:hidden", className), children });
4546
+ }
4547
+ function LinkCard({
4548
+ href,
4549
+ title,
4550
+ description,
4551
+ icon,
4552
+ meta,
4553
+ className
4554
+ }) {
4555
+ const Arrow = isInternal(href) ? ArrowRight : ArrowUpRight;
4556
+ return /* @__PURE__ */ jsxs(
4557
+ DocLink,
4558
+ {
4559
+ href,
4560
+ className: cn(
4561
+ "group flex h-full flex-col gap-3 rounded-[1.25rem] border border-border bg-card p-5 transition-colors hover:border-oca-hairline-strong",
4562
+ className
4563
+ ),
4564
+ children: [
4565
+ /* @__PURE__ */ jsxs("span", { className: "flex items-start justify-between gap-3", children: [
4566
+ icon ? /* @__PURE__ */ jsx("span", { className: "flex size-9 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground [&_svg]:size-[1.125rem]", children: icon }) : /* @__PURE__ */ jsx("span", { className: "text-[1rem] font-medium leading-snug text-foreground", children: title }),
4567
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-2", children: [
4568
+ meta,
4569
+ /* @__PURE__ */ jsx(Arrow, { "aria-hidden": true, className: "size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-foreground" })
4570
+ ] })
4571
+ ] }),
4572
+ icon ? /* @__PURE__ */ jsx("span", { className: "text-[1rem] font-medium leading-snug text-foreground", children: title }) : null,
4573
+ description ? /* @__PURE__ */ jsx("span", { className: "text-[0.9375rem] leading-relaxed text-muted-foreground", children: description }) : null
4574
+ ]
4575
+ }
4576
+ );
4577
+ }
4578
+ function CardGrid({ columns = 2, children, className }) {
4579
+ return /* @__PURE__ */ jsx("div", { className: cn("not-prose my-6 grid grid-cols-1 gap-3 sm:grid-cols-2", columns === 3 && "lg:grid-cols-3", className), children });
4580
+ }
4581
+ function MdxTable({ className, ...props }) {
4582
+ return /* @__PURE__ */ jsx("div", { className: "not-prose my-6 overflow-hidden rounded-2xl border border-border bg-card", children: /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--card)", children: /* @__PURE__ */ jsx(
4583
+ "table",
4584
+ {
4585
+ className: cn(
4586
+ "w-full border-collapse text-left text-[0.875rem] leading-relaxed",
4587
+ "[&_th]:whitespace-nowrap [&_th]:border-b [&_th]:border-oca-hairline-strong [&_th]:bg-oca-table-head [&_th]:px-4 [&_th]:py-2.5 [&_th]:text-[0.8125rem] [&_th]:font-medium [&_th]:text-foreground",
4588
+ "[&_td]:border-t [&_td]:border-border [&_td]:px-4 [&_td]:py-2.5 [&_td]:align-top [&_td]:text-muted-foreground [&_tbody_tr:first-child_td]:border-t-0",
4589
+ "[&_td_code]:bg-transparent [&_td_code]:p-0 [&_td_code]:text-foreground [&_td:first-child]:text-foreground",
4590
+ "[&_[align=center]]:text-center [&_[align=right]]:text-right",
4591
+ // On a phone a cell keeps a readable width; the table scrolls instead of crushing it.
4592
+ "max-sm:[&_td]:min-w-[9rem]",
4593
+ className
4594
+ ),
4595
+ ...props
4596
+ }
4597
+ ) }) });
4598
+ }
4599
+ function ApiTable({
4600
+ rows,
4601
+ caption,
4602
+ nameHeader = "Name",
4603
+ className
4604
+ }) {
4605
+ const hasDefault = rows.some((r) => r.default !== void 0);
4606
+ const marks = (r) => /* @__PURE__ */ jsxs(Fragment, { children: [
4607
+ r.required ? /* @__PURE__ */ jsx("span", { className: "text-[0.75rem] text-oca-accent-ink", children: "Required" }) : null,
4608
+ r.deprecated ? /* @__PURE__ */ jsx(Badge, { tone: "muted", children: "Deprecated" }) : null,
4609
+ r.status ? /* @__PURE__ */ jsx(StatusBadge, { status: r.status }) : null
4610
+ ] });
4611
+ return /* @__PURE__ */ jsxs("div", { className: cn("not-prose my-6", className), children: [
4612
+ /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-2xl border border-border bg-card max-sm:hidden", children: /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--card)", children: /* @__PURE__ */ jsxs("table", { className: "w-full border-collapse text-left text-[0.875rem]", children: [
4613
+ caption ? /* @__PURE__ */ jsx("caption", { className: "sr-only", children: caption }) : null,
4614
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b border-oca-hairline-strong bg-oca-table-head text-[0.8125rem]", children: [
4615
+ /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-2.5 font-medium", children: nameHeader }),
4616
+ /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-2.5 font-medium", children: "Type" }),
4617
+ hasDefault ? /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-2.5 font-medium", children: "Default" }) : null,
4618
+ /* @__PURE__ */ jsx("th", { scope: "col", className: "px-4 py-2.5 font-medium", children: "Description" })
4619
+ ] }) }),
4620
+ /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-border", children: rows.map((r) => /* @__PURE__ */ jsxs("tr", { className: "align-top", children: [
4621
+ /* @__PURE__ */ jsx("th", { scope: "row", className: "px-4 py-3 text-left font-normal", children: /* @__PURE__ */ jsxs("span", { className: "flex flex-col items-start gap-1", children: [
4622
+ /* @__PURE__ */ jsx("code", { className: cn("font-mono text-[0.8125rem] text-foreground", r.deprecated && "line-through decoration-oca-subtle"), children: r.name }),
4623
+ marks(r)
4624
+ ] }) }),
4625
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-3 font-mono text-[0.8125rem] text-muted-foreground", children: r.type ?? "\u2014" }),
4626
+ hasDefault ? /* @__PURE__ */ jsx("td", { className: "px-4 py-3 font-mono text-[0.8125rem] text-muted-foreground", children: r.default ?? "\u2014" }) : null,
4627
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-3 leading-relaxed text-muted-foreground", children: r.description })
4628
+ ] }, r.name)) })
4629
+ ] }) }) }),
4630
+ /* @__PURE__ */ jsx("ul", { "aria-label": caption, className: "divide-y divide-border rounded-2xl border border-border bg-card sm:hidden", children: rows.map((r) => /* @__PURE__ */ jsxs("li", { className: "flex flex-col gap-1.5 px-4 py-3.5", children: [
4631
+ /* @__PURE__ */ jsxs("span", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1", children: [
4632
+ /* @__PURE__ */ jsx("code", { className: cn("font-mono text-[0.875rem] text-foreground", r.deprecated && "line-through decoration-oca-subtle"), children: r.name }),
4633
+ r.type ? /* @__PURE__ */ jsx("code", { className: "break-all font-mono text-[0.8125rem] text-muted-foreground", children: r.type }) : null
4634
+ ] }),
4635
+ /* @__PURE__ */ jsx("span", { className: "flex flex-wrap items-center gap-2 empty:hidden", children: marks(r) }),
4636
+ r.description ? /* @__PURE__ */ jsx("span", { className: "text-[0.875rem] leading-relaxed text-muted-foreground", children: r.description }) : null,
4637
+ r.default !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "text-[0.8125rem] text-muted-foreground", children: [
4638
+ "Default ",
4639
+ /* @__PURE__ */ jsx("code", { className: "font-mono text-foreground", children: r.default })
4640
+ ] }) : null
4641
+ ] }, r.name)) })
4642
+ ] });
4643
+ }
4644
+ function useDarkMode() {
4645
+ const [dark, setDark] = useState(false);
4646
+ useEffect(() => {
4647
+ const root = document.documentElement;
4648
+ const read = () => setDark(root.classList.contains("dark"));
4649
+ read();
4650
+ const mo = new MutationObserver(read);
4651
+ mo.observe(root, { attributes: true, attributeFilter: ["class"] });
4652
+ return () => mo.disconnect();
4653
+ }, []);
4654
+ return dark;
4655
+ }
4656
+ function mermaidTheme(el) {
4657
+ const css = getComputedStyle(el);
4658
+ const v = (name) => css.getPropertyValue(name).trim();
4659
+ const card = v("--card");
4660
+ const muted = v("--muted");
4661
+ const text = v("--foreground");
4662
+ const subtle = v("--muted-foreground");
4663
+ const line = v("--input");
4664
+ const hair = v("--oca-hairline-strong");
4665
+ return {
4666
+ background: "transparent",
4667
+ fontFamily: css.fontFamily,
4668
+ fontSize: "14px",
4669
+ textColor: text,
4670
+ mainBkg: card,
4671
+ primaryColor: card,
4672
+ primaryTextColor: text,
4673
+ primaryBorderColor: hair,
4674
+ secondaryColor: muted,
4675
+ secondaryTextColor: text,
4676
+ secondaryBorderColor: hair,
4677
+ tertiaryColor: muted,
4678
+ tertiaryTextColor: text,
4679
+ tertiaryBorderColor: hair,
4680
+ nodeBorder: hair,
4681
+ lineColor: line,
4682
+ edgeLabelBackground: card,
4683
+ clusterBkg: muted,
4684
+ clusterBorder: hair,
4685
+ titleColor: text,
4686
+ noteBkgColor: muted,
4687
+ noteTextColor: text,
4688
+ noteBorderColor: hair,
4689
+ actorBkg: card,
4690
+ actorBorder: hair,
4691
+ actorTextColor: text,
4692
+ actorLineColor: line,
4693
+ signalColor: text,
4694
+ signalTextColor: text,
4695
+ labelBoxBkgColor: card,
4696
+ labelBoxBorderColor: hair,
4697
+ labelTextColor: text,
4698
+ loopTextColor: subtle,
4699
+ activationBkgColor: muted,
4700
+ activationBorderColor: hair,
4701
+ sequenceNumberColor: card
4702
+ };
4703
+ }
4704
+ function naturalSize(svg) {
4705
+ const w = svg.match(/viewBox="[\d.-]+ [\d.-]+ ([\d.]+) [\d.]+"/)?.[1];
4706
+ if (!w) return svg;
4707
+ return svg.replace(/<svg([^>]*?)\swidth="100%"/, `<svg$1 width="${Math.ceil(Number(w))}"`).replace(/max-width:\s*[\d.]+px;?/, "");
4708
+ }
4709
+ function Diagram({ chart, caption, load, className }) {
4710
+ const ref = useRef(null);
4711
+ const dark = useDarkMode();
4712
+ const raw = useId();
4713
+ const [svg, setSvg] = useState(null);
4714
+ const [failed, setFailed] = useState(false);
4715
+ useEffect(() => {
4716
+ let live = true;
4717
+ const el = ref.current;
4718
+ if (!el) return;
4719
+ (async () => {
4720
+ try {
4721
+ const mod = await load();
4722
+ const mermaid = "default" in mod ? mod.default : mod;
4723
+ mermaid.initialize({ startOnLoad: false, securityLevel: "strict", theme: "base", themeVariables: mermaidTheme(el) });
4724
+ const { svg: drawn } = await mermaid.render(`oca-diagram-${raw.replace(/[^a-zA-Z0-9]/g, "")}-${dark ? "d" : "l"}`, chart);
4725
+ if (live) {
4726
+ setSvg(naturalSize(drawn));
4727
+ setFailed(false);
4728
+ }
4729
+ } catch {
4730
+ if (live) setFailed(true);
4731
+ }
4732
+ })();
4733
+ return () => {
4734
+ live = false;
4735
+ };
4736
+ }, [chart, dark, load, raw]);
4737
+ if (failed) return /* @__PURE__ */ jsx(CodeBlock, { code: chart, caption: "Diagram (shown as its source)", className: cn("my-6", className) });
4738
+ return /* @__PURE__ */ jsxs("figure", { ref, className: cn("not-prose my-6 overflow-hidden rounded-[1.25rem] border border-border bg-card", className), children: [
4739
+ svg ? /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--card)", children: /* @__PURE__ */ jsx(
4740
+ "div",
4741
+ {
4742
+ className: "flex w-max min-w-full justify-center p-6 [&_svg]:h-auto [&_svg]:max-w-none",
4743
+ role: "img",
4744
+ "aria-label": typeof caption === "string" ? caption : "Diagram",
4745
+ dangerouslySetInnerHTML: { __html: svg }
4746
+ }
4747
+ ) }) : /* @__PURE__ */ jsx("div", { role: "status", "aria-label": "Drawing the diagram", className: "p-6", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full rounded-xl" }) }),
4748
+ caption ? /* @__PURE__ */ jsx("figcaption", { className: "border-t border-border px-5 py-3 text-[0.8125rem] text-muted-foreground", children: caption }) : null
4749
+ ] });
4750
+ }
4751
+ var HEADING = {
4752
+ h1: "oca-display-3 mb-4 text-foreground",
4753
+ h2: "mb-3 mt-12 text-[1.375rem] font-medium leading-tight tracking-[-0.015em] text-foreground md:text-[1.5rem]",
4754
+ h3: "mb-2 mt-9 text-[1.125rem] font-medium leading-snug tracking-[-0.01em] text-foreground",
4755
+ h4: "mb-2 mt-7 text-[1rem] font-medium leading-snug text-foreground"
4756
+ };
4757
+ function DocsHeading({
4758
+ as: Tag,
4759
+ id,
4760
+ children,
4761
+ className,
4762
+ ...props
4763
+ }) {
4764
+ return /* @__PURE__ */ jsxs(Tag, { id, className: cn("group scroll-mt-28", HEADING[Tag], className), ...props, children: [
4765
+ /* @__PURE__ */ jsx("span", { "data-heading-text": "", children }),
4766
+ id && Tag !== "h1" ? /* @__PURE__ */ jsxs(
4767
+ "a",
4768
+ {
4769
+ href: `#${id}`,
4770
+ className: "ml-2 inline-block rounded-md px-1 align-baseline text-[0.85em] font-normal text-oca-subtle no-underline opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100",
4771
+ children: [
4772
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "#" }),
4773
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Link to this section" })
4774
+ ]
4775
+ }
4776
+ ) : null
4777
+ ] });
4778
+ }
4779
+ function codeText(node) {
4780
+ if (typeof node === "string") return node;
4781
+ if (typeof node === "number") return String(node);
4782
+ if (Array.isArray(node)) return node.map(codeText).join("");
4783
+ if (isValidElement(node)) return codeText(node.props.children);
4784
+ return "";
4785
+ }
4786
+ function codeLang(node) {
4787
+ const child = Children.toArray(node)[0];
4788
+ if (!isValidElement(child)) return void 0;
4789
+ const cls = child.props.className ?? "";
4790
+ return cls.match(/language-([\w+-]+)/)?.[1];
4791
+ }
4792
+ function useMacKeys() {
4793
+ const [mac, setMac] = useState(true);
4794
+ useEffect(() => {
4795
+ setMac(/Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent));
4796
+ }, []);
4797
+ return mac;
4798
+ }
4799
+ var typing = (el) => el instanceof HTMLElement && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName));
4800
+ var SearchButton = forwardRef(function SearchButton2({ label = "Search", onClick, className }, ref) {
4801
+ const mac = useMacKeys();
4802
+ return /* @__PURE__ */ jsxs(
4803
+ "button",
4804
+ {
4805
+ ref,
4806
+ type: "button",
4807
+ onClick,
4808
+ "aria-keyshortcuts": mac ? "Meta+K" : "Control+K",
4809
+ className: cn(
4810
+ "inline-flex size-10 items-center justify-center gap-2 rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
4811
+ "md:h-10 md:w-56 md:justify-start md:border md:border-border md:bg-card md:pl-3.5 md:pr-2 md:hover:border-oca-hairline-strong md:hover:bg-card",
4812
+ className
4813
+ ),
4814
+ children: [
4815
+ /* @__PURE__ */ jsx(Search, { "aria-hidden": true, className: "size-[1.125rem] shrink-0 md:size-4" }),
4816
+ /* @__PURE__ */ jsx("span", { className: "sr-only flex-1 text-left text-[0.9375rem] md:not-sr-only", children: label }),
4817
+ /* @__PURE__ */ jsx(Kbd, { "aria-hidden": true, className: "hidden md:inline-flex", children: mac ? "\u2318K" : "Ctrl K" })
4818
+ ]
4819
+ }
4820
+ );
4821
+ });
4822
+ function SearchDialog({
4823
+ onQuery,
4824
+ open: openProp,
4825
+ onOpenChange,
4826
+ onSelect,
4827
+ button = true,
4828
+ hotkey = true,
4829
+ label = "Search",
4830
+ placeholder = "Search the docs",
4831
+ idle,
4832
+ defaultQuery = "",
4833
+ debounceMs = 120,
4834
+ className
4835
+ }) {
4836
+ const [own, setOwn] = useState(false);
4837
+ const open = openProp ?? own;
4838
+ const setOpen = (v) => {
4839
+ if (openProp === void 0) setOwn(v);
4840
+ onOpenChange?.(v);
4841
+ };
4842
+ const [query, setQuery] = useState(defaultQuery);
4843
+ const [groups, setGroups] = useState([]);
4844
+ const [state, setState] = useState("idle");
4845
+ const [active, setActive] = useState(0);
4846
+ const listId = useId();
4847
+ const listRef = useRef(null);
4848
+ const buttonRef = useRef(null);
4849
+ const returnTo = useRef(null);
4850
+ const flat = useMemo(() => groups.flatMap((g) => g.results), [groups]);
4851
+ const latest = useRef({ open, setOpen, onQuery });
4852
+ latest.current = { open, setOpen, onQuery };
4853
+ useEffect(() => {
4854
+ if (!hotkey) return;
4855
+ const onKey = (e) => {
4856
+ const { open: isOpen, setOpen: set } = latest.current;
4857
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
4858
+ e.preventDefault();
4859
+ set(!isOpen);
4860
+ } else if (e.key === "/" && !isOpen && !typing(e.target)) {
4861
+ e.preventDefault();
4862
+ set(true);
4863
+ }
4864
+ };
4865
+ window.addEventListener("keydown", onKey);
4866
+ return () => window.removeEventListener("keydown", onKey);
4867
+ }, [hotkey]);
4868
+ useEffect(() => {
4869
+ const q = query.trim();
4870
+ if (!q) {
4871
+ setGroups([]);
4872
+ setState("idle");
4873
+ return;
4874
+ }
4875
+ const ctl = new AbortController();
4876
+ setState("loading");
4877
+ const t = setTimeout(async () => {
4878
+ try {
4879
+ const out = await latest.current.onQuery(q, ctl.signal);
4880
+ if (ctl.signal.aborted) return;
4881
+ setGroups(out.filter((g) => g.results.length > 0));
4882
+ setActive(0);
4883
+ setState("done");
4884
+ } catch {
4885
+ if (!ctl.signal.aborted) setState("error");
4886
+ }
4887
+ }, debounceMs);
4888
+ return () => {
4889
+ clearTimeout(t);
4890
+ ctl.abort();
4891
+ };
4892
+ }, [query, debounceMs]);
4893
+ useEffect(() => {
4894
+ listRef.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: "nearest" });
4895
+ }, [active]);
4896
+ const choose = (r) => {
4897
+ setOpen(false);
4898
+ if (onSelect) onSelect(r);
4899
+ else window.location.assign(r.href);
4900
+ };
4901
+ const optionId = (i) => `${listId}-o${i}`;
4902
+ const showList = state === "done" && flat.length > 0;
4903
+ let index = -1;
4904
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4905
+ button ? /* @__PURE__ */ jsx(SearchButton, { ref: buttonRef, label, onClick: () => setOpen(true), className }) : null,
4906
+ /* @__PURE__ */ jsx(DialogPrimitive.Root, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogPrimitive.Portal, { children: [
4907
+ /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: "oca-animate-fade fixed inset-0 z-50 bg-[rgb(10_10_10/0.38)] backdrop-blur-[2px]" }),
4908
+ /* @__PURE__ */ jsxs(
4909
+ DialogPrimitive.Content,
4910
+ {
4911
+ "aria-describedby": void 0,
4912
+ onOpenAutoFocus: () => {
4913
+ const el = document.activeElement;
4914
+ returnTo.current = el instanceof HTMLElement && el !== document.body ? el : null;
4915
+ },
4916
+ onCloseAutoFocus: (e) => {
4917
+ const back = returnTo.current?.isConnected ? returnTo.current : buttonRef.current;
4918
+ if (back) {
4919
+ e.preventDefault();
4920
+ back.focus();
4921
+ }
4922
+ },
4923
+ className: "oca-animate-rise fixed left-1/2 top-3 z-50 flex max-h-[calc(100dvh-1.5rem)] w-[calc(100vw-1.5rem)] -translate-x-1/2 flex-col overflow-hidden rounded-[1.5rem] border border-border bg-popover text-popover-foreground shadow-xl outline-none sm:top-[12vh] sm:max-h-[min(36rem,76vh)] sm:w-[min(92vw,40rem)]",
4924
+ children: [
4925
+ /* @__PURE__ */ jsx(DialogPrimitive.Title, { className: "sr-only", children: label }),
4926
+ /* @__PURE__ */ jsxs("div", { className: "flex h-14 shrink-0 items-center gap-3 border-b border-border pl-5 pr-3", children: [
4927
+ state === "loading" ? /* @__PURE__ */ jsx(Spinner, { className: "size-[1.125rem] text-muted-foreground" }) : /* @__PURE__ */ jsx(Search, { "aria-hidden": true, className: "size-[1.125rem] shrink-0 text-muted-foreground" }),
4928
+ /* @__PURE__ */ jsx(
4929
+ "input",
4930
+ {
4931
+ autoFocus: true,
4932
+ value: query,
4933
+ onChange: (e) => setQuery(e.target.value),
4934
+ onKeyDown: (e) => {
4935
+ if (!showList) return;
4936
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
4937
+ e.preventDefault();
4938
+ const d = e.key === "ArrowDown" ? 1 : -1;
4939
+ setActive((a) => (a + d + flat.length) % flat.length);
4940
+ } else if (e.key === "Enter" && flat[active]) {
4941
+ e.preventDefault();
4942
+ choose(flat[active]);
4943
+ }
4944
+ },
4945
+ placeholder,
4946
+ role: "combobox",
4947
+ "aria-label": label,
4948
+ "aria-expanded": showList,
4949
+ "aria-controls": listId,
4950
+ "aria-autocomplete": "list",
4951
+ "aria-activedescendant": showList ? optionId(active) : void 0,
4952
+ spellCheck: false,
4953
+ autoComplete: "off",
4954
+ className: "h-full min-w-0 flex-1 bg-transparent text-base text-foreground outline-none placeholder:text-oca-subtle"
4955
+ }
4956
+ ),
4957
+ /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "inline-flex h-8 shrink-0 items-center rounded-md border border-border px-2 text-[0.75rem] text-muted-foreground transition-colors hover:text-foreground", children: [
4958
+ /* @__PURE__ */ jsx("span", { className: "sm:hidden", children: "Close" }),
4959
+ /* @__PURE__ */ jsx("span", { className: "max-sm:hidden", "aria-hidden": true, children: "Esc" }),
4960
+ /* @__PURE__ */ jsx("span", { className: "sr-only max-sm:hidden", children: "Close search" })
4961
+ ] })
4962
+ ] }),
4963
+ /* @__PURE__ */ jsxs("div", { ref: listRef, className: "min-h-0 flex-1 overflow-y-auto overscroll-contain p-2", children: [
4964
+ /* @__PURE__ */ jsx("div", { id: listId, role: "listbox", "aria-label": "Results", className: cn(!showList && "hidden"), children: groups.map((g, gi) => /* @__PURE__ */ jsxs("div", { role: "group", "aria-label": typeof g.label === "string" ? g.label : void 0, className: "pb-1", children: [
4965
+ /* @__PURE__ */ jsx("p", { "aria-hidden": true, className: "px-3 pb-1.5 pt-3 text-[0.8125rem] text-muted-foreground", children: g.label }),
4966
+ g.results.map((r) => {
4967
+ index++;
4968
+ const i = index;
4969
+ const on = i === active;
4970
+ return /* @__PURE__ */ jsxs(
4971
+ "a",
4972
+ {
4973
+ id: optionId(i),
4974
+ href: r.href,
4975
+ role: "option",
4976
+ "aria-selected": on,
4977
+ tabIndex: -1,
4978
+ onMouseMove: () => setActive(i),
4979
+ onClick: (e) => {
4980
+ if (e.metaKey || e.ctrlKey || e.shiftKey) return;
4981
+ e.preventDefault();
4982
+ choose(r);
4983
+ },
4984
+ className: cn(
4985
+ "flex items-start gap-3 rounded-xl px-3 py-2.5 transition-colors",
4986
+ on ? "bg-accent" : "hover:bg-accent"
4987
+ ),
4988
+ children: [
4989
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
4990
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[0.9375rem] font-medium text-foreground", children: r.title }),
4991
+ r.section ? /* @__PURE__ */ jsx("span", { className: "truncate text-[0.8125rem] text-muted-foreground", children: r.section }) : null,
4992
+ r.excerptHtml ? /* @__PURE__ */ jsx(
4993
+ "span",
4994
+ {
4995
+ className: "line-clamp-2 text-[0.875rem] leading-snug text-muted-foreground [&_mark]:rounded-sm [&_mark]:bg-[color-mix(in_oklab,var(--oca-orange)_22%,transparent)] [&_mark]:px-0.5 [&_mark]:text-foreground",
4996
+ dangerouslySetInnerHTML: { __html: r.excerptHtml }
4997
+ }
4998
+ ) : r.excerpt ? /* @__PURE__ */ jsx("span", { className: "line-clamp-2 text-[0.875rem] leading-snug text-muted-foreground", children: r.excerpt }) : null
4999
+ ] }),
5000
+ /* @__PURE__ */ jsx(CornerDownLeft, { "aria-hidden": true, className: cn("mt-1 size-4 shrink-0 text-muted-foreground", !on && "invisible") })
5001
+ ]
5002
+ },
5003
+ r.id
5004
+ );
5005
+ })
5006
+ ] }, gi)) }),
5007
+ state === "idle" ? /* @__PURE__ */ jsx("div", { className: "px-3 py-6 text-[0.9375rem] text-muted-foreground", children: idle ?? "Type a word: a protocol, a function, an error." }) : null,
5008
+ state === "done" && flat.length === 0 ? /* @__PURE__ */ jsxs("p", { role: "status", className: "px-3 py-6 text-[0.9375rem] text-muted-foreground", children: [
5009
+ "No results for \u201C",
5010
+ query.trim(),
5011
+ "\u201D."
5012
+ ] }) : null,
5013
+ state === "error" ? /* @__PURE__ */ jsx("p", { role: "status", className: "px-3 py-6 text-[0.9375rem] text-muted-foreground", children: "Search is not available right now. Try again in a moment." }) : null
5014
+ ] }),
5015
+ /* @__PURE__ */ jsxs("div", { "aria-hidden": true, className: "hidden shrink-0 items-center gap-4 border-t border-border px-5 py-2.5 text-[0.75rem] text-muted-foreground sm:flex", children: [
5016
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
5017
+ /* @__PURE__ */ jsx(Kbd, { children: "\u2191" }),
5018
+ /* @__PURE__ */ jsx(Kbd, { children: "\u2193" }),
5019
+ " to move"
5020
+ ] }),
5021
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
5022
+ /* @__PURE__ */ jsx(Kbd, { children: "\u21B5" }),
5023
+ " to open"
5024
+ ] }),
5025
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
5026
+ /* @__PURE__ */ jsx(Kbd, { children: "esc" }),
5027
+ " to close"
5028
+ ] })
5029
+ ] }),
5030
+ /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", children: state === "done" ? `${flat.length} result${flat.length === 1 ? "" : "s"}` : "" })
5031
+ ]
5032
+ }
5033
+ )
5034
+ ] }) })
5035
+ ] });
5036
+ }
5037
+ function pretty(content) {
5038
+ try {
5039
+ return JSON.stringify(JSON.parse(content), null, 2);
5040
+ } catch {
5041
+ return null;
5042
+ }
5043
+ }
5044
+ function download(content, filename, mime) {
5045
+ const url = URL.createObjectURL(new Blob([content], { type: mime }));
5046
+ const a = document.createElement("a");
5047
+ a.href = url;
5048
+ a.download = filename;
5049
+ document.body.appendChild(a);
5050
+ a.click();
5051
+ a.remove();
5052
+ setTimeout(() => URL.revokeObjectURL(url), 0);
5053
+ }
5054
+ var BAR_BUTTON = "inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-[0.75rem] text-oca-ink-subtle transition-colors hover:bg-white/10 hover:text-white";
5055
+ function ArtifactView({
5056
+ content,
5057
+ title,
5058
+ filename,
5059
+ mime,
5060
+ defaultView = "formatted",
5061
+ maxLines = 28,
5062
+ className
5063
+ }) {
5064
+ const formatted = useMemo(() => pretty(content), [content]);
5065
+ const [view, setView] = useState(formatted ? defaultView : "raw");
5066
+ const shown = view === "formatted" && formatted ? formatted : content;
5067
+ const json = formatted !== null;
5068
+ return /* @__PURE__ */ jsx(
5069
+ CodeBlock,
5070
+ {
5071
+ code: shown,
5072
+ lang: json ? "json" : void 0,
5073
+ caption: title,
5074
+ maxLines,
5075
+ className,
5076
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
5077
+ json ? /* @__PURE__ */ jsx("span", { role: "group", "aria-label": "View", className: "mr-1 flex items-center rounded-full bg-white/[0.06] p-0.5", children: ["formatted", "raw"].map((v) => /* @__PURE__ */ jsx(
5078
+ "button",
5079
+ {
5080
+ type: "button",
5081
+ "aria-pressed": view === v,
5082
+ onClick: () => setView(v),
5083
+ className: cn(
5084
+ "h-7 rounded-full px-2.5 text-[0.75rem] transition-colors",
5085
+ view === v ? "bg-white/[0.12] text-white" : "text-oca-ink-subtle hover:text-white"
5086
+ ),
5087
+ children: v === "formatted" ? "Formatted" : "Raw"
5088
+ },
5089
+ v
5090
+ )) }) : null,
5091
+ filename ? /* @__PURE__ */ jsxs(
5092
+ "button",
5093
+ {
5094
+ type: "button",
5095
+ onClick: () => download(content, filename, mime ?? (json ? "application/json" : "text/plain")),
5096
+ className: BAR_BUTTON,
5097
+ "aria-label": `Download ${filename}`,
5098
+ children: [
5099
+ /* @__PURE__ */ jsx(Download, { "aria-hidden": true, className: "size-3.5" }),
5100
+ /* @__PURE__ */ jsx("span", { className: "max-sm:hidden", children: "Download" })
5101
+ ]
5102
+ }
5103
+ ) : null
5104
+ ] })
5105
+ }
5106
+ );
5107
+ }
5108
+ function DropZone({
5109
+ onFile,
5110
+ onText,
5111
+ accept,
5112
+ title = "Drop a file here, or choose one",
5113
+ hint,
5114
+ privacy = "It stays in your browser. Only its hash leaves this page.",
5115
+ file,
5116
+ progress,
5117
+ progressLabel = "Hashing",
5118
+ onClear,
5119
+ error,
5120
+ disabled = false,
5121
+ className
5122
+ }) {
5123
+ const input = useRef(null);
5124
+ const [over, setOver] = useState(false);
5125
+ const depth = useRef(0);
5126
+ const [mode, setMode] = useState("file");
5127
+ const [text, setText] = useState("");
5128
+ const errorId = useId();
5129
+ const titleId = useId();
5130
+ const busy = progress !== null && progress !== void 0;
5131
+ const pct = busy ? Math.round(Math.max(0, Math.min(1, progress)) * 100) : 0;
5132
+ const take = (f) => {
5133
+ if (f && !disabled) onFile(f);
5134
+ };
5135
+ const privacyLine = privacy === null ? null : /* @__PURE__ */ jsxs("p", { className: "flex items-start gap-2 text-[0.8125rem] leading-snug text-muted-foreground", children: [
5136
+ /* @__PURE__ */ jsx(Lock, { "aria-hidden": true, className: "mt-0.5 size-3.5 shrink-0" }),
5137
+ /* @__PURE__ */ jsx("span", { children: privacy })
5138
+ ] });
5139
+ if (mode === "text" && onText) {
5140
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", className), children: [
5141
+ /* @__PURE__ */ jsx(
5142
+ Textarea,
5143
+ {
5144
+ value: text,
5145
+ onChange: (e) => setText(e.target.value),
5146
+ rows: 6,
5147
+ "aria-label": "Text",
5148
+ "aria-describedby": error ? errorId : void 0,
5149
+ "aria-invalid": error ? true : void 0,
5150
+ placeholder: "Paste the text here",
5151
+ className: "font-mono text-base md:text-[0.875rem]"
5152
+ }
5153
+ ),
5154
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
5155
+ /* @__PURE__ */ jsx(Button, { size: "sm", disabled: !text.trim() || disabled, onClick: () => onText(text), children: "Use this text" }),
5156
+ /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setMode("file"), children: "Choose a file instead" })
5157
+ ] }),
5158
+ error ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-[0.8125rem] text-destructive", children: error }) : null,
5159
+ privacyLine
5160
+ ] });
5161
+ }
5162
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", className), children: [
5163
+ /* @__PURE__ */ jsxs(
5164
+ "div",
5165
+ {
5166
+ role: "group",
5167
+ "aria-labelledby": titleId,
5168
+ "aria-describedby": error ? errorId : void 0,
5169
+ "aria-busy": busy || void 0,
5170
+ onDragEnter: (e) => {
5171
+ e.preventDefault();
5172
+ depth.current++;
5173
+ if (!disabled) setOver(true);
5174
+ },
5175
+ onDragOver: (e) => e.preventDefault(),
5176
+ onDragLeave: () => {
5177
+ depth.current = Math.max(0, depth.current - 1);
5178
+ if (depth.current === 0) setOver(false);
5179
+ },
5180
+ onDrop: (e) => {
5181
+ e.preventDefault();
5182
+ depth.current = 0;
5183
+ setOver(false);
5184
+ take(e.dataTransfer.files?.[0]);
5185
+ },
5186
+ className: cn(
5187
+ "relative flex flex-col gap-3 rounded-[1.25rem] border border-dashed transition-colors",
5188
+ file ? "px-4 py-4 sm:px-5" : "items-center px-5 py-8 text-center md:py-10",
5189
+ over ? "border-foreground bg-accent" : "border-oca-hairline-strong bg-card",
5190
+ error && "border-destructive",
5191
+ disabled && "opacity-55"
5192
+ ),
5193
+ children: [
5194
+ /* @__PURE__ */ jsx(
5195
+ "input",
5196
+ {
5197
+ ref: input,
5198
+ type: "file",
5199
+ accept,
5200
+ disabled,
5201
+ tabIndex: -1,
5202
+ "aria-hidden": true,
5203
+ className: "sr-only",
5204
+ onChange: (e) => {
5205
+ take(e.target.files?.[0]);
5206
+ e.target.value = "";
5207
+ }
5208
+ }
5209
+ ),
5210
+ file ? /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-3", children: [
5211
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
5212
+ /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground", children: busy ? /* @__PURE__ */ jsx(FileText, { "aria-hidden": true, className: "size-5" }) : /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "size-5" }) }),
5213
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
5214
+ /* @__PURE__ */ jsx("span", { id: titleId, className: "truncate text-[0.9375rem] font-medium", title: file.name, children: file.name }),
5215
+ /* @__PURE__ */ jsx("span", { className: "text-[0.8125rem] text-muted-foreground", children: [formatBytes(file.size), file.type].filter(Boolean).join(" \xB7 ") })
5216
+ ] }),
5217
+ !busy && onClear ? /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", onClick: onClear, disabled, className: "shrink-0", children: "Choose another" }) : null
5218
+ ] }),
5219
+ busy ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
5220
+ /* @__PURE__ */ jsx(
5221
+ "div",
5222
+ {
5223
+ role: "progressbar",
5224
+ "aria-valuemin": 0,
5225
+ "aria-valuemax": 100,
5226
+ "aria-valuenow": pct,
5227
+ "aria-label": typeof progressLabel === "string" ? progressLabel : "Progress",
5228
+ className: "h-1.5 overflow-hidden rounded-full bg-muted",
5229
+ children: /* @__PURE__ */ jsx("div", { className: "h-full rounded-full bg-foreground transition-[width] duration-200", style: { width: `${pct}%` } })
5230
+ }
5231
+ ),
5232
+ /* @__PURE__ */ jsxs("span", { className: "text-[0.8125rem] text-muted-foreground oca-tabular", children: [
5233
+ progressLabel,
5234
+ " ",
5235
+ pct,
5236
+ "%"
5237
+ ] })
5238
+ ] }) : null
5239
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5240
+ /* @__PURE__ */ jsx("span", { className: "flex size-11 items-center justify-center rounded-full bg-muted text-foreground", children: /* @__PURE__ */ jsx(Upload, { "aria-hidden": true, className: "size-5" }) }),
5241
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
5242
+ /* @__PURE__ */ jsx("p", { id: titleId, className: "text-[1rem] font-medium", children: over ? "Drop it to add it" : title }),
5243
+ hint ? /* @__PURE__ */ jsx("p", { className: "text-[0.875rem] text-muted-foreground", children: hint }) : null
5244
+ ] }),
5245
+ /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center justify-center gap-2", children: [
5246
+ /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", disabled, onClick: () => input.current?.click(), children: "Choose a file" }),
5247
+ onText ? /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled, onClick: () => setMode("text"), children: "Paste text instead" }) : null
5248
+ ] })
5249
+ ] })
5250
+ ]
5251
+ }
5252
+ ),
5253
+ error ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "text-[0.8125rem] text-destructive", children: error }) : null,
5254
+ privacyLine
5255
+ ] });
5256
+ }
5257
+ function FormSection({
5258
+ n,
5259
+ title,
5260
+ hint,
5261
+ status,
5262
+ action,
5263
+ as: Heading = "h2",
5264
+ id,
5265
+ children,
5266
+ className
5267
+ }) {
5268
+ const titleId = useId();
5269
+ const tight = useDensity() === "compact";
5270
+ return /* @__PURE__ */ jsxs(
5271
+ "section",
5272
+ {
5273
+ id,
5274
+ "aria-labelledby": titleId,
5275
+ "aria-current": status === "current" ? "step" : void 0,
5276
+ className: cn("scroll-mt-24 rounded-[1.25rem] border border-border bg-card", className),
5277
+ children: [
5278
+ /* @__PURE__ */ jsxs("header", { className: cn("flex items-start gap-3.5", tight ? "px-5 pt-5" : "px-6 pt-6"), children: [
5279
+ n !== void 0 ? /* @__PURE__ */ jsx(
5280
+ "span",
5281
+ {
5282
+ "aria-hidden": true,
5283
+ className: cn(
5284
+ "mt-px flex size-7 shrink-0 items-center justify-center rounded-full border text-[0.8125rem] oca-tabular",
5285
+ status === "done" && "border-primary bg-primary text-primary-foreground",
5286
+ status === "current" && "border-brand text-oca-accent-ink",
5287
+ status === "blocked" && "border-destructive text-destructive",
5288
+ (status === "upcoming" || status === void 0) && "border-oca-hairline-strong text-muted-foreground"
5289
+ ),
5290
+ children: status === "done" ? /* @__PURE__ */ jsx(Check, { className: "size-3.5", strokeWidth: 3 }) : n
5291
+ }
5292
+ ) : null,
5293
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
5294
+ /* @__PURE__ */ jsxs(Heading, { id: titleId, className: "text-[1.0625rem] font-medium leading-snug tracking-[-0.008em]", children: [
5295
+ n !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
5296
+ "Step ",
5297
+ n,
5298
+ ": "
5299
+ ] }) : null,
5300
+ title,
5301
+ status === "done" ? /* @__PURE__ */ jsx("span", { className: "sr-only", children: " (done)" }) : null
5302
+ ] }),
5303
+ hint ? /* @__PURE__ */ jsx("p", { className: "text-[0.875rem] leading-snug text-muted-foreground", children: hint }) : null
5304
+ ] }),
5305
+ action ? /* @__PURE__ */ jsx("div", { className: "shrink-0", children: action }) : null
5306
+ ] }),
5307
+ /* @__PURE__ */ jsx("div", { className: cn("flex flex-col", tight ? "gap-4 p-5" : "gap-5 p-6", n !== void 0 && (tight ? "sm:pl-[3.875rem]" : "sm:pl-[4.125rem]")), children })
5308
+ ]
5309
+ }
5310
+ );
5311
+ }
5312
+ var STATE_TONE = { good: "success", attention: "brand", bad: "danger", neutral: "neutral", quiet: "muted" };
5313
+ function StateBadge({
5314
+ tone = "neutral",
5315
+ children,
5316
+ title,
5317
+ className
5318
+ }) {
5319
+ return /* @__PURE__ */ jsx(Badge, { tone: STATE_TONE[tone], title, className, children });
5320
+ }
5321
+ function createStateBadge(states) {
5322
+ function ProtocolStateBadge({ state, className }) {
5323
+ const def = states[state];
5324
+ if (!def) {
5325
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
5326
+ console.warn(`StateBadge: no state "${state}"; known: ${Object.keys(states).join(", ")}`);
5327
+ }
5328
+ return /* @__PURE__ */ jsx(StateBadge, { className, children: String(state) });
5329
+ }
5330
+ return /* @__PURE__ */ jsx(StateBadge, { tone: def.tone, title: def.hint, className, children: def.label });
5331
+ }
5332
+ return ProtocolStateBadge;
5333
+ }
5334
+ function BlockHeight({
5335
+ height,
5336
+ label = false,
5337
+ link = true,
5338
+ network = "mainnet",
5339
+ className
5340
+ }) {
5341
+ const text = `${label ? "block " : ""}${formatBlockHeight(height)}`;
5342
+ if (!link) return /* @__PURE__ */ jsx("span", { className: cn("oca-tabular", className), children: text });
5343
+ return /* @__PURE__ */ jsxs(
5344
+ "a",
5345
+ {
5346
+ href: explorerUrl("block", Math.trunc(height), network),
5347
+ target: "_blank",
5348
+ rel: "noreferrer",
5349
+ title: `Block ${formatBlockHeight(height)} on mempool.space`,
5350
+ className: cn("oca-tabular underline decoration-foreground/35 underline-offset-4 hover:decoration-foreground", className),
5351
+ children: [
5352
+ text,
5353
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: " (opens mempool.space in a new tab)" })
5354
+ ]
5355
+ }
5356
+ );
5357
+ }
5358
+ var ANCHOR = {
5359
+ anchored: { label: "Anchored", tone: "good" },
5360
+ pending: { label: "Anchor pending", tone: "attention" },
5361
+ unverified: { label: "Not checked", tone: "quiet" },
5362
+ none: { label: "Not anchored", tone: "quiet" },
5363
+ fail: { label: "Does not check out", tone: "bad" }
5364
+ };
5365
+ function hostOf(url) {
5366
+ try {
5367
+ return new URL(url).host;
5368
+ } catch {
5369
+ return url;
5370
+ }
5371
+ }
5372
+ function AnchorStatus({
5373
+ state,
5374
+ blockHeight,
5375
+ blockTime,
5376
+ submittedAt,
5377
+ calendar,
5378
+ message,
5379
+ network = "mainnet",
5380
+ variant = "detail",
5381
+ className
5382
+ }) {
5383
+ const def = ANCHOR[state];
5384
+ const block = blockHeight !== void 0 ? /* @__PURE__ */ jsx(BlockHeight, { height: blockHeight, label: true, network }) : null;
5385
+ const line = message ?? (state === "anchored" ? block ? /* @__PURE__ */ jsxs(Fragment, { children: [
5386
+ "In ",
5387
+ block,
5388
+ blockTime !== void 0 ? ` \xB7 ${formatUtc(blockTime)}` : null
5389
+ ] }) : "Its hash is in a Bitcoin block." : state === "pending" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5390
+ "Submitted",
5391
+ submittedAt !== void 0 ? ` ${formatUtc(submittedAt)}` : "",
5392
+ " to",
5393
+ " ",
5394
+ calendar ? hostOf(calendar) : "an OpenTimestamps calendar",
5395
+ ". Waiting for a Bitcoin block."
5396
+ ] }) : state === "unverified" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5397
+ "The proof names ",
5398
+ block ?? "a block",
5399
+ ", but its header could not be fetched to check it."
5400
+ ] }) : state === "fail" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5401
+ "The proof does not lead to ",
5402
+ block ?? "the block it names",
5403
+ "."
5404
+ ] }) : "No timestamp yet. The signature still checks offline.");
5405
+ if (variant === "badge") {
5406
+ const plain = typeof line === "string" ? line : void 0;
5407
+ return /* @__PURE__ */ jsx(StateBadge, { tone: def.tone, title: plain, className, children: def.label });
5408
+ }
5409
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-start gap-1.5", className), children: [
5410
+ /* @__PURE__ */ jsx(StateBadge, { tone: def.tone, children: def.label }),
5411
+ /* @__PURE__ */ jsx("p", { className: "text-[0.875rem] leading-snug text-muted-foreground", children: line })
5412
+ ] });
5413
+ }
5414
+ function BlockCountdown({
5415
+ target,
5416
+ tip,
5417
+ from,
5418
+ reached = "Reached",
5419
+ minutesPerBlock = 10,
5420
+ network = "mainnet",
5421
+ className
5422
+ }) {
5423
+ const known = typeof tip === "number";
5424
+ const left = known ? target - tip : null;
5425
+ const done2 = left !== null && left <= 0;
5426
+ const share = known && from !== void 0 && target > from ? Math.min(1, Math.max(0, (tip - from) / (target - from))) : null;
5427
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", className), children: [
5428
+ /* @__PURE__ */ jsx("p", { className: "text-[0.9375rem] leading-snug", children: !known ? /* @__PURE__ */ jsxs(Fragment, { children: [
5429
+ "At ",
5430
+ /* @__PURE__ */ jsx(BlockHeight, { height: target, label: true, network })
5431
+ ] }) : done2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
5432
+ reached,
5433
+ " at ",
5434
+ /* @__PURE__ */ jsx(BlockHeight, { height: target, label: true, network })
5435
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5436
+ "In ",
5437
+ /* @__PURE__ */ jsx("span", { className: "oca-tabular font-medium", children: formatBlockHeight(left) }),
5438
+ " block",
5439
+ left === 1 ? "" : "s",
5440
+ /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
5441
+ ", ",
5442
+ blocksToDuration(left, minutesPerBlock)
5443
+ ] })
5444
+ ] }) }),
5445
+ share !== null ? /* @__PURE__ */ jsx(
5446
+ "div",
5447
+ {
5448
+ role: "progressbar",
5449
+ "aria-valuemin": 0,
5450
+ "aria-valuemax": 100,
5451
+ "aria-valuenow": Math.round(share * 100),
5452
+ "aria-label": "Blocks passed",
5453
+ className: "h-1.5 overflow-hidden rounded-full bg-muted",
5454
+ children: /* @__PURE__ */ jsx("div", { className: "h-full rounded-full bg-foreground", style: { width: `${share * 100}%` } })
5455
+ }
5456
+ ) : null,
5457
+ known && !done2 ? /* @__PURE__ */ jsxs("p", { className: "text-[0.8125rem] text-muted-foreground", children: [
5458
+ "Target ",
5459
+ /* @__PURE__ */ jsx(BlockHeight, { height: target, network }),
5460
+ " \xB7 tip ",
5461
+ /* @__PURE__ */ jsx("span", { className: "oca-tabular", children: formatBlockHeight(tip) })
5462
+ ] }) : null
5463
+ ] });
5464
+ }
5465
+ function Meter({
5466
+ value,
5467
+ max,
5468
+ ghost,
5469
+ label,
5470
+ figure,
5471
+ tone = "ink",
5472
+ size = "md",
5473
+ className
5474
+ }) {
5475
+ const id = useId();
5476
+ const total = max > 0 ? max : 1;
5477
+ const v = Math.max(0, Math.min(1, value / total));
5478
+ const g = ghost ? Math.max(0, Math.min(1 - v, ghost / total)) : 0;
5479
+ const pct = `${Math.round(v * 100)}%`;
5480
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", className), children: [
5481
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-4 text-[0.875rem]", children: [
5482
+ /* @__PURE__ */ jsx("span", { id, className: "min-w-0 truncate", children: label }),
5483
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 oca-tabular text-muted-foreground", children: figure ?? pct })
5484
+ ] }),
5485
+ /* @__PURE__ */ jsxs(
5486
+ "div",
5487
+ {
5488
+ role: "meter",
5489
+ "aria-labelledby": id,
5490
+ "aria-valuemin": 0,
5491
+ "aria-valuemax": max,
5492
+ "aria-valuenow": value,
5493
+ "aria-valuetext": typeof figure === "string" ? figure : pct,
5494
+ className: cn("flex overflow-hidden rounded-full bg-muted", size === "sm" ? "h-1.5" : "h-2.5"),
5495
+ children: [
5496
+ /* @__PURE__ */ jsx(
5497
+ "div",
5498
+ {
5499
+ className: cn("h-full shrink-0 rounded-full", tone === "brand" ? "bg-oca-orange-deep" : "bg-foreground"),
5500
+ style: { width: `${v * 100}%` }
5501
+ }
5502
+ ),
5503
+ g > 0 ? /* @__PURE__ */ jsx(
5504
+ "div",
5505
+ {
5506
+ "aria-hidden": true,
5507
+ className: "-ml-1.5 h-full shrink-0 rounded-r-full pl-1.5 text-foreground/45",
5508
+ style: {
5509
+ width: `calc(${g * 100}% + 0.375rem)`,
5510
+ backgroundImage: "repeating-linear-gradient(-45deg, currentColor 0 2px, transparent 2px 6px)"
5511
+ }
5512
+ }
5513
+ ) : null
5514
+ ]
5515
+ }
5516
+ )
5517
+ ] });
5518
+ }
5519
+ function FilterChips({
5520
+ options,
5521
+ value,
5522
+ onChange,
5523
+ label,
5524
+ className
5525
+ }) {
5526
+ const tight = useDensity() === "compact";
5527
+ const multi = Array.isArray(value);
5528
+ const isOn = (v) => multi ? value.includes(v) : value === v;
5529
+ const press = (v) => {
5530
+ if (multi) {
5531
+ const cur = value;
5532
+ onChange(cur.includes(v) ? cur.filter((x) => x !== v) : [...cur, v]);
5533
+ } else onChange(v);
5534
+ };
5535
+ return /* @__PURE__ */ jsx(ScrollFade, { fade: "var(--background)", className: cn("w-full", className), children: /* @__PURE__ */ jsx("div", { role: "group", "aria-label": label, className: "flex w-max items-center gap-2 py-0.5", children: options.map((o) => {
5536
+ const on = isOn(o.value);
5537
+ return /* @__PURE__ */ jsxs(
5538
+ "button",
5539
+ {
5540
+ type: "button",
5541
+ "aria-pressed": on,
5542
+ onClick: () => press(o.value),
5543
+ className: cn(
5544
+ "inline-flex shrink-0 items-center gap-1.5 rounded-full border px-3.5 text-[0.875rem] transition-colors",
5545
+ tight ? "h-8" : "h-9",
5546
+ on ? "border-foreground bg-foreground text-background" : "border-border bg-card text-muted-foreground hover:border-oca-hairline-strong hover:text-foreground"
5547
+ ),
5548
+ children: [
5549
+ o.label,
5550
+ o.count !== void 0 ? /* @__PURE__ */ jsx("span", { className: "oca-tabular", children: o.count.toLocaleString("en-US") }) : null
5551
+ ]
5552
+ },
5553
+ o.value
5554
+ );
5555
+ }) }) });
5556
+ }
5557
+ function ToolGrid({
5558
+ tools,
5559
+ as: Heading = "h2",
5560
+ className
5561
+ }) {
5562
+ const tight = useDensity() === "compact";
5563
+ const n = tools.length;
5564
+ return /* @__PURE__ */ jsx(
5565
+ "ul",
5566
+ {
5567
+ className: cn(
5568
+ "grid grid-cols-1 gap-3 sm:grid-cols-2 md:gap-4",
5569
+ // Three or four sit in one row on a wide screen.
5570
+ n === 3 || n === 6 ? "lg:grid-cols-3" : n === 4 ? "xl:grid-cols-4" : null,
5571
+ className
5572
+ ),
5573
+ children: tools.map((t) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
5574
+ "div",
5575
+ {
5576
+ className: cn(
5577
+ "group relative flex h-full flex-col rounded-[1.25rem] border border-border bg-card transition-colors",
5578
+ tight ? "gap-3 p-5" : "gap-4 p-6",
5579
+ "hover:border-oca-hairline-strong has-[a:focus-visible]:ring-2 has-[a:focus-visible]:ring-ring has-[a:focus-visible]:ring-offset-2 has-[a:focus-visible]:ring-offset-background"
5580
+ ),
5581
+ children: [
5582
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
5583
+ t.icon ? /* @__PURE__ */ jsx("span", { className: "flex size-10 items-center justify-center rounded-xl bg-muted text-foreground [&_svg]:size-5", children: t.icon }) : /* @__PURE__ */ jsx("span", {}),
5584
+ /* @__PURE__ */ jsx(
5585
+ ArrowRight,
5586
+ {
5587
+ "aria-hidden": true,
5588
+ className: "size-4 text-muted-foreground transition-transform duration-200 group-hover:translate-x-0.5 group-hover:text-foreground"
5589
+ }
5590
+ )
5591
+ ] }),
5592
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
5593
+ /* @__PURE__ */ jsx(Heading, { className: "oca-title-sm", children: /* @__PURE__ */ jsx(
5594
+ Link8,
5595
+ {
5596
+ href: t.href,
5597
+ className: "outline-none after:absolute after:inset-0 after:rounded-[1.25rem] after:content-['']",
5598
+ children: t.label
5599
+ }
5600
+ ) }),
5601
+ t.description ? /* @__PURE__ */ jsx("p", { className: "text-[0.9375rem] leading-relaxed text-muted-foreground", children: t.description }) : null
5602
+ ] })
5603
+ ]
5604
+ }
5605
+ ) }, t.href))
5606
+ }
5607
+ );
5608
+ }
5609
+ function SiteRow({ site, here, onNavigate }) {
5610
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
5611
+ "a",
5612
+ {
5613
+ href: site.href,
5614
+ onClick: onNavigate,
3553
5615
  "aria-current": here ? "page" : void 0,
3554
5616
  className: cn(
3555
5617
  "flex flex-col gap-0.5 rounded-xl px-3 py-2 transition-colors hover:bg-accent",
@@ -3622,16 +5684,23 @@ function FamilyMenu({ current: current2, className }) {
3622
5684
  )
3623
5685
  ] });
3624
5686
  }
3625
- function NavLink({ item, className, onNavigate }) {
5687
+ function NavLink({
5688
+ item,
5689
+ className,
5690
+ onNavigate,
5691
+ line = false
5692
+ }) {
3626
5693
  const cls = cn(
3627
5694
  "rounded-full px-3 py-2 text-[0.9375rem] transition-colors",
3628
5695
  item.active ? "text-foreground" : "text-muted-foreground hover:text-foreground",
5696
+ line && "relative after:absolute after:inset-x-3 after:-bottom-[0.625rem] after:h-0.5 after:rounded-full",
5697
+ line && item.active && "after:bg-foreground",
3629
5698
  className
3630
5699
  );
3631
5700
  if (item.external) {
3632
5701
  return /* @__PURE__ */ jsx("a", { href: item.href, className: cls, rel: "noreferrer", onClick: onNavigate, children: item.label });
3633
5702
  }
3634
- return /* @__PURE__ */ jsx(Link5, { href: item.href, className: cls, "aria-current": item.active ? "page" : void 0, onClick: onNavigate, children: item.label });
5703
+ return /* @__PURE__ */ jsx(Link8, { href: item.href, className: cls, "aria-current": item.active ? "page" : void 0, onClick: onNavigate, children: item.label });
3635
5704
  }
3636
5705
  function NavRow({ item, onNavigate }) {
3637
5706
  const body = /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -3642,7 +5711,7 @@ function NavRow({ item, onNavigate }) {
3642
5711
  "flex flex-col gap-0.5 rounded-xl px-3 py-2 transition-colors hover:bg-accent",
3643
5712
  item.active && "bg-muted hover:bg-muted dark:bg-white/[0.06]"
3644
5713
  );
3645
- return item.external ? /* @__PURE__ */ jsx("a", { href: item.href, className: cls, rel: "noreferrer", onClick: onNavigate, children: body }) : /* @__PURE__ */ jsx(Link5, { href: item.href, className: cls, "aria-current": item.active ? "page" : void 0, onClick: onNavigate, children: body });
5714
+ return item.external ? /* @__PURE__ */ jsx("a", { href: item.href, className: cls, rel: "noreferrer", onClick: onNavigate, children: body }) : /* @__PURE__ */ jsx(Link8, { href: item.href, className: cls, "aria-current": item.active ? "page" : void 0, onClick: onNavigate, children: body });
3646
5715
  }
3647
5716
  var seeAll = (item) => typeof item.label === "string" ? `All ${item.label.toLowerCase()}` : "See all";
3648
5717
  function NavDropdown({ item }) {
@@ -3684,13 +5753,16 @@ function SiteHeader({
3684
5753
  search,
3685
5754
  actions,
3686
5755
  variant = "site",
5756
+ navOnPhone = true,
5757
+ menu: menuExtra,
3687
5758
  className
3688
5759
  }) {
3689
5760
  const [open, setOpen] = useState(false);
3690
5761
  const tool = variant === "tool";
3691
5762
  const size = tool ? 24 : 28;
3692
5763
  const current2 = typeof family === "string" ? family : void 0;
3693
- const menu = nav.length > 0 || Boolean(family);
5764
+ const phoneNav = navOnPhone ? nav : [];
5765
+ const menu = phoneNav.length > 0 || Boolean(family) || Boolean(menuExtra);
3694
5766
  const brandNode = brand ?? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center", children: [
3695
5767
  /* @__PURE__ */ jsx(Lockup, { size }),
3696
5768
  product ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -3698,7 +5770,9 @@ function SiteHeader({
3698
5770
  /* @__PURE__ */ jsx("span", { className: "font-medium tracking-[-0.01em]", style: { fontSize: size * 0.56 }, children: product })
3699
5771
  ] }) : null
3700
5772
  ] });
3701
- const navigation = nav.length > 0 ? /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "hidden items-center gap-1 md:flex", children: nav.map((n) => n.children?.length ? /* @__PURE__ */ jsx(NavDropdown, { item: n }, n.href) : /* @__PURE__ */ jsx(NavLink, { item: n }, n.href)) }) : null;
5773
+ const navigation = nav.length > 0 ? /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "hidden items-center gap-1 md:flex", children: nav.map(
5774
+ (n) => n.children?.length ? /* @__PURE__ */ jsx(NavDropdown, { item: n }, n.href) : /* @__PURE__ */ jsx(NavLink, { item: n, line: tool }, n.href)
5775
+ ) }) : null;
3702
5776
  return /* @__PURE__ */ jsx(
3703
5777
  "header",
3704
5778
  {
@@ -3720,7 +5794,7 @@ function SiteHeader({
3720
5794
  ),
3721
5795
  children: [
3722
5796
  /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 items-center gap-1", tool ? "md:gap-1" : "justify-self-start"), children: [
3723
- /* @__PURE__ */ jsxs(Link5, { href: home, className: "-ml-1 min-w-0 rounded-lg p-1", children: [
5797
+ /* @__PURE__ */ jsxs(Link8, { href: home, className: "-ml-1 min-w-0 rounded-lg p-1", children: [
3724
5798
  brandNode,
3725
5799
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: " home" })
3726
5800
  ] }),
@@ -3742,7 +5816,8 @@ function SiteHeader({
3742
5816
  ),
3743
5817
  /* @__PURE__ */ jsxs(SheetContent, { side: "right", className: "pt-16", children: [
3744
5818
  /* @__PURE__ */ jsx(SheetTitle, { className: "sr-only", children: "Menu" }),
3745
- nav.length > 0 ? /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "flex flex-col", children: nav.map(
5819
+ menuExtra ? /* @__PURE__ */ jsx("div", { className: cn("flex flex-col", (phoneNav.length > 0 || family) && "border-b border-border pb-3"), children: menuExtra }) : null,
5820
+ phoneNav.length > 0 ? /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "flex flex-col", children: phoneNav.map(
3746
5821
  (n) => n.children?.length ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col py-2", children: [
3747
5822
  /* @__PURE__ */ jsx("p", { className: "px-3 pb-1 text-[0.8125rem] text-muted-foreground", children: n.label }),
3748
5823
  n.children.map((c) => /* @__PURE__ */ jsx(
@@ -3764,7 +5839,7 @@ function SiteHeader({
3764
5839
  n.href
3765
5840
  )
3766
5841
  ) }) : null,
3767
- family ? /* @__PURE__ */ jsxs("details", { className: cn("group", nav.length > 0 && "mt-2 border-t border-border pt-4"), children: [
5842
+ family ? /* @__PURE__ */ jsxs("details", { className: cn("group", phoneNav.length > 0 && "mt-2 border-t border-border pt-4"), children: [
3768
5843
  /* @__PURE__ */ jsxs("summary", { className: "flex cursor-pointer list-none items-center justify-between rounded-xl px-3 py-2.5 text-[1.0625rem] [&::-webkit-details-marker]:hidden", children: [
3769
5844
  "All orangecheck sites",
3770
5845
  /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: "size-4 text-muted-foreground transition-transform group-open:rotate-180" })
@@ -3931,12 +6006,12 @@ function SignInFrame({
3931
6006
  children: [
3932
6007
  /* @__PURE__ */ jsxs("section", { className: "flex flex-col px-4 pb-8 pt-5 sm:px-8 lg:px-14 lg:pt-8", children: [
3933
6008
  /* @__PURE__ */ jsxs("header", { className: "flex items-center justify-between gap-4", children: [
3934
- /* @__PURE__ */ jsxs(Link5, { href: home, className: "w-fit rounded-lg", children: [
6009
+ /* @__PURE__ */ jsxs(Link8, { href: home, className: "w-fit rounded-lg", children: [
3935
6010
  brand ?? /* @__PURE__ */ jsx(Lockup, { size: 28 }),
3936
6011
  /* @__PURE__ */ jsx("span", { className: "sr-only", children: " home" })
3937
6012
  ] }),
3938
6013
  back === void 0 ? /* @__PURE__ */ jsx(
3939
- Link5,
6014
+ Link8,
3940
6015
  {
3941
6016
  href: home,
3942
6017
  className: "text-[0.9375rem] text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",
@@ -3969,11 +6044,156 @@ function SignInFrame({
3969
6044
  }
3970
6045
  );
3971
6046
  }
6047
+ var STATUS_WORDS = /* @__PURE__ */ new Set(["live", "testing", "not-yet", "paused", "good", "caution", "refused"]);
6048
+ var pathOf = (href) => href.split(/[?#]/)[0].replace(/(.)\/$/, "$1");
6049
+ function DocsNav({
6050
+ sections,
6051
+ current: current2,
6052
+ onNavigate,
6053
+ className
6054
+ }) {
6055
+ const here = pathOf(current2);
6056
+ const activeSection = useMemo(
6057
+ () => sections.findIndex((s) => s.items.some((i) => pathOf(i.href) === here)),
6058
+ [sections, here]
6059
+ );
6060
+ const [peeked, setPeeked] = useState(() => /* @__PURE__ */ new Set());
6061
+ useEffect(() => setPeeked(/* @__PURE__ */ new Set()), [activeSection]);
6062
+ const activeRef = useRef(null);
6063
+ useEffect(() => {
6064
+ const id = requestAnimationFrame(() => activeRef.current?.scrollIntoView({ block: "nearest" }));
6065
+ return () => cancelAnimationFrame(id);
6066
+ }, [here]);
6067
+ const base = useId();
6068
+ return /* @__PURE__ */ jsx("nav", { "aria-label": "Docs", className: cn("flex flex-col gap-0.5", className), children: sections.map((section, si) => {
6069
+ const isActive = si === activeSection;
6070
+ const open = isActive || peeked.has(si);
6071
+ const panel = `${base}-s${si}`;
6072
+ return /* @__PURE__ */ jsxs("div", { children: [
6073
+ /* @__PURE__ */ jsxs(
6074
+ "button",
6075
+ {
6076
+ type: "button",
6077
+ "aria-expanded": open,
6078
+ "aria-controls": panel,
6079
+ onClick: () => {
6080
+ if (isActive) return;
6081
+ setPeeked((p) => {
6082
+ const n = new Set(p);
6083
+ if (n.has(si)) n.delete(si);
6084
+ else n.add(si);
6085
+ return n;
6086
+ });
6087
+ },
6088
+ className: cn(
6089
+ "flex min-h-9 w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-[0.875rem] transition-colors",
6090
+ isActive ? "font-medium text-foreground" : "text-muted-foreground hover:bg-accent hover:text-foreground",
6091
+ isActive && "cursor-default"
6092
+ ),
6093
+ children: [
6094
+ section.label,
6095
+ /* @__PURE__ */ jsx(
6096
+ ChevronRight,
6097
+ {
6098
+ "aria-hidden": true,
6099
+ className: cn("size-3.5 shrink-0 text-oca-subtle transition-transform duration-200", open && "rotate-90")
6100
+ }
6101
+ )
6102
+ ]
6103
+ }
6104
+ ),
6105
+ /* @__PURE__ */ jsx("ul", { id: panel, hidden: !open, className: "mb-2 ml-2.5 mt-0.5 border-l border-border", children: section.items.map((item) => {
6106
+ const on = pathOf(item.href) === here;
6107
+ const badge = typeof item.badge === "string" && STATUS_WORDS.has(item.badge) ? /* @__PURE__ */ jsx(StatusBadge, { status: item.badge }) : item.badge ? /* @__PURE__ */ jsx(Badge, { tone: "muted", children: item.badge }) : null;
6108
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
6109
+ Link8,
6110
+ {
6111
+ href: item.href,
6112
+ ref: on ? activeRef : void 0,
6113
+ onClick: onNavigate,
6114
+ "aria-current": on ? "page" : void 0,
6115
+ className: cn(
6116
+ "-ml-px flex min-h-9 items-center gap-2 border-l-2 py-1.5 pl-3.5 pr-2 text-[0.875rem] leading-snug transition-colors",
6117
+ on ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:border-oca-hairline-strong hover:text-foreground"
6118
+ ),
6119
+ children: [
6120
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1", children: item.label }),
6121
+ badge
6122
+ ]
6123
+ }
6124
+ ) }, item.href);
6125
+ }) })
6126
+ ] }, section.label);
6127
+ }) });
6128
+ }
6129
+ var DOCS_HEADER_NAV = OCHK_IO_NAV.map((n) => n.href === DOCS_HREF ? { ...n, active: true } : n);
6130
+ function DocsShell({
6131
+ nav,
6132
+ current: current2,
6133
+ header,
6134
+ search,
6135
+ actions,
6136
+ breadcrumbs,
6137
+ toc,
6138
+ pager,
6139
+ footer,
6140
+ children
6141
+ }) {
6142
+ const [menu, setMenu] = useState(false);
6143
+ useEffect(() => setMenu(false), [current2]);
6144
+ const read = useHeadings("#docs-content", current2);
6145
+ const items = toc ?? read.items;
6146
+ const activeId = toc ? void 0 : read.activeId;
6147
+ const here = pathOf(current2);
6148
+ const place = useMemo(() => {
6149
+ for (const s of nav) {
6150
+ const it = s.items.find((i) => pathOf(i.href) === here);
6151
+ if (it) return { section: s.label, page: it.label };
6152
+ }
6153
+ return null;
6154
+ }, [nav, here]);
6155
+ return /* @__PURE__ */ jsxs("div", { className: "flex min-h-dvh flex-col bg-background", children: [
6156
+ /* @__PURE__ */ jsx(SkipLink, {}),
6157
+ header ?? /* @__PURE__ */ jsx(SiteHeader, { home: OCHK_IO, family: "docs", nav: DOCS_HEADER_NAV, search, actions }),
6158
+ /* @__PURE__ */ jsx("div", { className: "sticky top-16 z-30 border-b border-border bg-background/95 backdrop-blur-md supports-[backdrop-filter]:bg-background/90 md:top-[4.5rem] lg:hidden", children: /* @__PURE__ */ jsx("div", { className: "oca-container flex h-12 items-center gap-2", children: /* @__PURE__ */ jsxs(Sheet, { open: menu, onOpenChange: setMenu, children: [
6159
+ /* @__PURE__ */ jsxs(SheetTrigger, { className: "-ml-2 inline-flex h-10 min-w-0 items-center gap-2 rounded-full px-2.5 text-[0.875rem] hover:bg-accent", children: [
6160
+ /* @__PURE__ */ jsx(PanelLeft, { "aria-hidden": true, className: "size-[1.125rem] shrink-0" }),
6161
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Docs menu. " }),
6162
+ place ? /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [
6163
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: place.section }),
6164
+ /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-3.5 shrink-0 text-oca-subtle" }),
6165
+ /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: place.page })
6166
+ ] }) : /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Docs" })
6167
+ ] }),
6168
+ /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "w-[min(88vw,22rem)] gap-0 p-0", children: [
6169
+ /* @__PURE__ */ jsx("div", { className: "border-b border-border px-5 py-4 pr-14", children: /* @__PURE__ */ jsx(SheetTitle, { className: "text-[1.0625rem] font-medium", children: "Docs" }) }),
6170
+ /* @__PURE__ */ jsx("div", { className: "overflow-y-auto p-3", children: /* @__PURE__ */ jsx(DocsNav, { sections: nav, current: current2, onNavigate: () => setMenu(false) }) })
6171
+ ] })
6172
+ ] }) }) }),
6173
+ /* @__PURE__ */ jsx("div", { className: "oca-container flex-1", children: /* @__PURE__ */ jsxs("div", { className: "lg:grid lg:grid-cols-[13.5rem_minmax(0,1fr)] lg:gap-x-10 xl:grid-cols-[13.5rem_minmax(0,1fr)_11rem]", children: [
6174
+ /* @__PURE__ */ jsx("div", { className: "sticky top-[4.5rem] hidden max-h-[calc(100dvh-4.5rem)] self-start overflow-y-auto overscroll-contain py-8 pr-1 lg:block", children: /* @__PURE__ */ jsx(DocsNav, { sections: nav, current: current2 }) }),
6175
+ /* @__PURE__ */ jsxs("main", { id: "main-content", className: "min-w-0 pb-16 pt-6 md:pt-8", children: [
6176
+ breadcrumbs ? /* @__PURE__ */ jsx("div", { className: "mb-6 max-lg:hidden", children: breadcrumbs }) : null,
6177
+ items.length > 1 ? /* @__PURE__ */ jsxs("details", { className: "group mb-8 rounded-2xl border border-border bg-card xl:hidden", children: [
6178
+ /* @__PURE__ */ jsxs("summary", { className: "flex min-h-12 cursor-pointer list-none items-center justify-between px-4 text-[0.9375rem] font-medium [&::-webkit-details-marker]:hidden", children: [
6179
+ "On this page",
6180
+ /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: "size-4 text-muted-foreground transition-transform group-open:rotate-180" })
6181
+ ] }),
6182
+ /* @__PURE__ */ jsx(OnThisPage, { items, activeId, title: null, className: "px-4 pb-4" })
6183
+ ] }) : null,
6184
+ /* @__PURE__ */ jsx("article", { id: "docs-content", className: "max-w-[46rem]", children }),
6185
+ pager ? /* @__PURE__ */ jsx("div", { className: "mt-16 max-w-[46rem]", children: pager }) : null
6186
+ ] }),
6187
+ /* @__PURE__ */ jsx("div", { className: "sticky top-[4.5rem] hidden max-h-[calc(100dvh-4.5rem)] self-start overflow-y-auto py-10 xl:block", children: items.length > 1 ? /* @__PURE__ */ jsx(OnThisPage, { items, activeId }) : null })
6188
+ ] }) }),
6189
+ footer ?? /* @__PURE__ */ jsx(SiteFooter, { columns: OCHK_IO_FOOTER, family: true, legal: true, signature: false })
6190
+ ] });
6191
+ }
3972
6192
  function SideNav({ groups, onNavigate }) {
3973
6193
  return /* @__PURE__ */ jsx("nav", { "aria-label": "Pages", className: "flex flex-col gap-5", children: groups.map((g, gi) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
3974
6194
  g.label ? /* @__PURE__ */ jsx("p", { className: "px-3 pb-1 text-[0.8125rem] text-muted-foreground", children: g.label }) : null,
3975
6195
  g.items.map((it) => /* @__PURE__ */ jsxs(
3976
- Link5,
6196
+ Link8,
3977
6197
  {
3978
6198
  href: it.href,
3979
6199
  onClick: onNavigate,
@@ -4008,7 +6228,7 @@ function SectionSwitch({
4008
6228
  children: sections.map((sec) => {
4009
6229
  const on = sec.id === current2.id;
4010
6230
  return /* @__PURE__ */ jsx(
4011
- Link5,
6231
+ Link8,
4012
6232
  {
4013
6233
  href: sec.href,
4014
6234
  onClick: onNavigate,
@@ -4038,7 +6258,7 @@ function TabBar({ items }) {
4038
6258
  className: "mx-auto grid h-14 max-w-[32rem] px-1.5",
4039
6259
  style: { gridTemplateColumns: `repeat(${items.length}, minmax(0, 1fr))` },
4040
6260
  children: items.map((it) => /* @__PURE__ */ jsxs(
4041
- Link5,
6261
+ Link8,
4042
6262
  {
4043
6263
  href: it.href,
4044
6264
  "aria-current": it.active ? "page" : void 0,
@@ -4147,7 +6367,7 @@ function AppShell({
4147
6367
  footer ? /* @__PURE__ */ jsx("div", { className: "mt-auto flex flex-col gap-3", children: footer }) : null
4148
6368
  ] })
4149
6369
  ] }),
4150
- /* @__PURE__ */ jsx(Link5, { href: home, "aria-label": "Home", className: "rounded-lg p-1", children: /* @__PURE__ */ jsx(Lockup, { size: 22 }) }),
6370
+ /* @__PURE__ */ jsx(Link8, { href: home, "aria-label": "Home", className: "rounded-lg p-1", children: /* @__PURE__ */ jsx(Lockup, { size: 22 }) }),
4151
6371
  /* @__PURE__ */ jsx("div", { className: "ml-auto flex items-center", children: account })
4152
6372
  ] }),
4153
6373
  place.page ? /* @__PURE__ */ jsxs(
@@ -4170,7 +6390,7 @@ function AppShell({
4170
6390
  ] }),
4171
6391
  /* @__PURE__ */ jsxs("div", { className: "mx-auto flex w-full max-w-[90rem]", children: [
4172
6392
  /* @__PURE__ */ jsxs("aside", { className: "sticky top-0 hidden h-dvh w-[17rem] shrink-0 flex-col gap-6 overflow-y-auto px-4 py-6 lg:flex", children: [
4173
- /* @__PURE__ */ jsx(Link5, { href: home, className: "px-2", "aria-label": "Home", children: /* @__PURE__ */ jsx(Lockup, { size: 26 }) }),
6393
+ /* @__PURE__ */ jsx(Link8, { href: home, className: "px-2", "aria-label": "Home", children: /* @__PURE__ */ jsx(Lockup, { size: 26 }) }),
4174
6394
  switcher,
4175
6395
  /* @__PURE__ */ jsx(SideNav, { groups }),
4176
6396
  /* @__PURE__ */ jsx("div", { className: "mt-auto flex flex-col gap-3", children: footer })
@@ -4201,9 +6421,16 @@ function AccountMenu({
4201
6421
  "inline-flex h-10 items-center gap-2.5 rounded-full border border-border bg-card pl-1 pr-1 text-[0.9375rem] outline-none transition-colors hover:border-oca-hairline-strong focus-visible:ring-2 focus-visible:ring-ring",
4202
6422
  nameFrom === "lg" ? "lg:pr-3.5" : "sm:pr-3.5"
4203
6423
  ),
4204
- "aria-label": `Account: ${name}`,
6424
+ "aria-label": `${name}, account menu`,
4205
6425
  children: [
4206
- /* @__PURE__ */ jsx("span", { className: "flex size-8 items-center justify-center rounded-full bg-foreground text-[0.8125rem] font-medium text-background", children: initial }),
6426
+ /* @__PURE__ */ jsx(
6427
+ "span",
6428
+ {
6429
+ "aria-hidden": true,
6430
+ "data-initial": initial,
6431
+ className: "flex size-8 items-center justify-center rounded-full bg-foreground text-[0.8125rem] font-medium text-background before:content-[attr(data-initial)]"
6432
+ }
6433
+ ),
4207
6434
  /* @__PURE__ */ jsx("span", { className: cn("max-w-[10rem] truncate", nameFrom === "lg" ? "max-lg:hidden" : "max-sm:hidden"), children: name })
4208
6435
  ]
4209
6436
  }
@@ -4215,7 +6442,7 @@ function AccountMenu({
4215
6442
  ] }),
4216
6443
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
4217
6444
  items.map(
4218
- (it, i) => it === "separator" ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, `sep-${i}`) : it.href ? /* @__PURE__ */ jsx(DropdownMenuItem, { asChild: true, destructive: it.destructive, children: /* @__PURE__ */ jsxs(Link5, { href: it.href, children: [
6445
+ (it, i) => it === "separator" ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, `sep-${i}`) : it.href ? /* @__PURE__ */ jsx(DropdownMenuItem, { asChild: true, destructive: it.destructive, children: /* @__PURE__ */ jsxs(Link8, { href: it.href, children: [
4219
6446
  it.icon,
4220
6447
  it.label
4221
6448
  ] }) }, it.label) : /* @__PURE__ */ jsxs(DropdownMenuItem, { onSelect: it.onSelect, destructive: it.destructive, children: [
@@ -4248,7 +6475,260 @@ function ThemeToggle({ className }) {
4248
6475
  }
4249
6476
  );
4250
6477
  }
6478
+ var OCHK_APP_ACCOUNT = "https://ochk.app/me/account";
6479
+ function SessionAccountView({
6480
+ state,
6481
+ name,
6482
+ detail,
6483
+ items = [],
6484
+ signInHref,
6485
+ signInLabel = "Sign in",
6486
+ accountHref = OCHK_APP_ACCOUNT,
6487
+ onSignOut,
6488
+ nameFrom = "lg"
6489
+ }) {
6490
+ if (state === "in") {
6491
+ return /* @__PURE__ */ jsx(
6492
+ AccountMenu,
6493
+ {
6494
+ name: name || "Your account",
6495
+ detail,
6496
+ nameFrom,
6497
+ items: [
6498
+ ...items,
6499
+ ...items.length > 0 ? ["separator"] : [],
6500
+ { label: "Your account", href: accountHref, icon: /* @__PURE__ */ jsx(CircleUser, {}) },
6501
+ "separator",
6502
+ { label: "Sign out", onSelect: onSignOut, icon: /* @__PURE__ */ jsx(LogOut, {}) }
6503
+ ]
6504
+ }
6505
+ );
6506
+ }
6507
+ if (state === "unknown") {
6508
+ return /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "secondary", children: /* @__PURE__ */ jsx("a", { href: accountHref, children: "Your account" }) });
6509
+ }
6510
+ return (
6511
+ // No box of its own: it sits exactly where the signed-in chip will. While checking it is only unseen.
6512
+ /* @__PURE__ */ jsx("span", { className: state === "checking" ? "contents invisible" : "contents", "aria-hidden": state === "checking" || void 0, children: /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "secondary", tabIndex: state === "checking" ? -1 : void 0, children: /* @__PURE__ */ jsx("a", { href: signInHref, children: signInLabel }) }) })
6513
+ );
6514
+ }
6515
+ function ToolShell({
6516
+ protocol: protocol2,
6517
+ tools,
6518
+ home = "/",
6519
+ account,
6520
+ rail = false,
6521
+ railFooter,
6522
+ variant = "tool",
6523
+ banner,
6524
+ footer,
6525
+ children
6526
+ }) {
6527
+ const p = protocolSite(protocol2);
6528
+ const app = variant === "app";
6529
+ const tabs = app ? null : tabsFor([{ items: [...tools] }]);
6530
+ const about = /* @__PURE__ */ jsxs(
6531
+ "a",
6532
+ {
6533
+ href: p.pageHref,
6534
+ className: "inline-flex items-center gap-1 rounded-full px-3 py-2 text-[0.9375rem] text-muted-foreground transition-colors hover:text-foreground",
6535
+ children: [
6536
+ "About ",
6537
+ p.label,
6538
+ /* @__PURE__ */ jsx(ArrowUpRight, { "aria-hidden": true, className: "size-3.5" })
6539
+ ]
6540
+ }
6541
+ );
6542
+ return /* @__PURE__ */ jsx(DensityProvider, { density: "compact", children: /* @__PURE__ */ jsxs(
6543
+ "div",
6544
+ {
6545
+ className: cn(
6546
+ "flex flex-col bg-background",
6547
+ app ? "h-dvh overflow-hidden" : "min-h-dvh",
6548
+ tabs && "max-md:pb-[calc(3.5rem_+_env(safe-area-inset-bottom))]"
6549
+ ),
6550
+ children: [
6551
+ /* @__PURE__ */ jsx(SkipLink, {}),
6552
+ banner,
6553
+ /* @__PURE__ */ jsx(
6554
+ SiteHeader,
6555
+ {
6556
+ variant: "tool",
6557
+ home,
6558
+ product: p.label,
6559
+ family: protocol2,
6560
+ nav: tools.map((t) => ({ href: t.href, label: t.label, active: t.active })),
6561
+ navOnPhone: !tabs,
6562
+ menu: /* @__PURE__ */ jsx("div", { className: "[&>a]:px-3 [&>a]:py-3 [&>a]:text-[1.0625rem]", children: about }),
6563
+ className: cn(rail && "lg:[&_nav[aria-label=Main]]:hidden"),
6564
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
6565
+ /* @__PURE__ */ jsx("span", { className: "hidden lg:contents", children: about }),
6566
+ p.status !== "live" ? /* @__PURE__ */ jsx(StatusBadge, { status: p.status, className: "max-sm:hidden" }) : null,
6567
+ /* @__PURE__ */ jsx(ThemeToggle, { className: "max-sm:hidden" }),
6568
+ account
6569
+ ] })
6570
+ }
6571
+ ),
6572
+ /* @__PURE__ */ jsxs("div", { className: cn("mx-auto flex w-full", app ? "min-h-0 flex-1" : "max-w-[90rem] flex-1"), children: [
6573
+ rail ? /* @__PURE__ */ jsxs("aside", { className: "sticky top-14 hidden h-[calc(100dvh-3.5rem)] w-60 shrink-0 flex-col gap-6 overflow-y-auto px-4 py-6 lg:flex", children: [
6574
+ /* @__PURE__ */ jsx(SideNav, { groups: [{ label: "Tools", items: tools.map(({ href, label, icon, active }) => ({ href, label, icon, active })) }] }),
6575
+ railFooter ? /* @__PURE__ */ jsx("div", { className: "mt-auto flex flex-col gap-0.5 px-3 text-[0.875rem] text-muted-foreground [&_a:hover]:text-foreground [&_a]:py-1.5 [&_a]:transition-colors", children: railFooter }) : null
6576
+ ] }) : null,
6577
+ /* @__PURE__ */ jsx(
6578
+ "main",
6579
+ {
6580
+ id: "main-content",
6581
+ className: cn("min-w-0 flex-1", app ? "flex min-h-0 flex-col" : "px-4 pb-16 pt-8 md:px-8 md:pt-10"),
6582
+ children: app ? children : /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-[72rem]", children })
6583
+ }
6584
+ )
6585
+ ] }),
6586
+ app || footer === false ? null : footer ?? /* @__PURE__ */ jsx(SiteFooter, { compact: true, family: true, legal: true }),
6587
+ tabs ? /* @__PURE__ */ jsx(TabBar, { items: tabs }) : null
6588
+ ]
6589
+ }
6590
+ ) });
6591
+ }
6592
+
6593
+ // src/code/rehype.ts
6594
+ function textOf(node) {
6595
+ if (node.type === "text") return node.value ?? "";
6596
+ return (node.children ?? []).map(textOf).join("");
6597
+ }
6598
+ function langOf(code) {
6599
+ const cls = code.properties?.className;
6600
+ const list = Array.isArray(cls) ? cls : typeof cls === "string" ? cls.split(" ") : [];
6601
+ for (const c of list) {
6602
+ const m = String(c).match(/^language-(.+)$/);
6603
+ if (m) return m[1];
6604
+ }
6605
+ return void 0;
6606
+ }
6607
+ function rehypeCode(options = {}) {
6608
+ const skip = new Set(options.skip ?? ["mermaid"]);
6609
+ const visit = (node) => {
6610
+ for (const child of node.children ?? []) {
6611
+ const code = child.type === "element" && child.tagName === "pre" ? child.children?.[0] : void 0;
6612
+ if (code && code.type === "element" && code.tagName === "code" && child.children?.length === 1) {
6613
+ const lang = langOf(code);
6614
+ if (lang && skip.has(lang)) continue;
6615
+ const meta = parseCodeMeta(code.data?.meta);
6616
+ let source = textOf(code);
6617
+ const diff = meta.diff || lang === "diff" ? readDiff(source) : null;
6618
+ if (diff) source = diff.code;
6619
+ const lines = options.tokenize?.(source, lang) ?? highlight(source, lang === "diff" ? void 0 : lang);
6620
+ child.properties = {
6621
+ ...child.properties,
6622
+ dataOcaCode: "",
6623
+ dataHtml: linesToHtml(lines, { highlight: parseLineRanges(meta.highlight), diff: diff?.diff }),
6624
+ ...lang ? { dataLang: lang } : {},
6625
+ ...meta.title ? { dataTitle: meta.title } : {},
6626
+ ...diff ? { dataDiff: "" } : {},
6627
+ ...meta.lineNumbers ? { dataLineNumbers: "" } : {}
6628
+ };
6629
+ child.children = [];
6630
+ continue;
6631
+ }
6632
+ visit(child);
6633
+ }
6634
+ };
6635
+ return (tree) => visit(tree);
6636
+ }
6637
+ function createMdxComponents({ mermaid } = {}) {
6638
+ function Pre(props) {
6639
+ if (props["data-oca-code"] !== void 0) {
6640
+ return /* @__PURE__ */ jsx(
6641
+ CodeBlock,
6642
+ {
6643
+ html: props["data-html"] ?? "",
6644
+ lang: props["data-lang"],
6645
+ caption: props["data-title"],
6646
+ diff: props["data-diff"] !== void 0,
6647
+ lineNumbers: props["data-line-numbers"] !== void 0,
6648
+ className: "my-6"
6649
+ }
6650
+ );
6651
+ }
6652
+ const lang = codeLang(props.children);
6653
+ const code = codeText(props.children);
6654
+ if (lang === "mermaid" && mermaid) return /* @__PURE__ */ jsx(Diagram, { chart: code, load: mermaid });
6655
+ return /* @__PURE__ */ jsx(
6656
+ CodeBlock,
6657
+ {
6658
+ code,
6659
+ lang: lang === "mermaid" ? void 0 : lang,
6660
+ caption: lang === "mermaid" ? "Diagram source" : void 0,
6661
+ className: "my-6"
6662
+ }
6663
+ );
6664
+ }
6665
+ function A({ href, children, ...rest }) {
6666
+ if (!href || href.startsWith("#")) {
6667
+ return /* @__PURE__ */ jsx("a", { href, ...rest, className: "text-foreground underline decoration-foreground/35 underline-offset-4 hover:decoration-foreground", children });
6668
+ }
6669
+ return /* @__PURE__ */ jsx(TextLink, { href, children });
6670
+ }
6671
+ const heading = (as) => function Heading(props) {
6672
+ return /* @__PURE__ */ jsx(DocsHeading, { as, ...props });
6673
+ };
6674
+ return {
6675
+ h1: heading("h1"),
6676
+ h2: heading("h2"),
6677
+ h3: heading("h3"),
6678
+ h4: heading("h4"),
6679
+ p: ({ className, ...props }) => /* @__PURE__ */ jsx("p", { className: cn("my-4 text-[1rem] leading-[1.75] text-muted-foreground md:text-[1.0625rem]", className), ...props }),
6680
+ a: A,
6681
+ strong: (props) => /* @__PURE__ */ jsx("strong", { className: "font-medium text-foreground", ...props }),
6682
+ ul: ({ className, ...props }) => /* @__PURE__ */ jsx(
6683
+ "ul",
6684
+ {
6685
+ className: cn(
6686
+ "my-4 list-disc space-y-1.5 pl-5 text-[1rem] leading-[1.7] text-muted-foreground marker:text-oca-subtle md:text-[1.0625rem]",
6687
+ className
6688
+ ),
6689
+ ...props
6690
+ }
6691
+ ),
6692
+ ol: ({ className, ...props }) => /* @__PURE__ */ jsx(
6693
+ "ol",
6694
+ {
6695
+ className: cn(
6696
+ "my-4 list-decimal space-y-1.5 pl-5 text-[1rem] leading-[1.7] text-muted-foreground marker:text-oca-subtle md:text-[1.0625rem]",
6697
+ className
6698
+ ),
6699
+ ...props
6700
+ }
6701
+ ),
6702
+ li: ({ className, ...props }) => /* @__PURE__ */ jsx("li", { className: cn("pl-1 [&>p]:my-1 [&>ul]:my-1.5 [&>ol]:my-1.5", className), ...props }),
6703
+ blockquote: ({ children }) => /* @__PURE__ */ jsx(Callout, { children }),
6704
+ hr: () => /* @__PURE__ */ jsx("hr", { className: "my-10 border-border" }),
6705
+ table: MdxTable,
6706
+ code: ({ className, ...props }) => /* @__PURE__ */ jsx(
6707
+ "code",
6708
+ {
6709
+ className: cn("break-words rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.875em] text-foreground", className),
6710
+ ...props
6711
+ }
6712
+ ),
6713
+ pre: Pre,
6714
+ img: ({ className, alt = "", ...props }) => /* @__PURE__ */ jsx("img", { alt, loading: "lazy", className: cn("my-6 h-auto max-w-full rounded-2xl border border-border", className), ...props }),
6715
+ Callout,
6716
+ Steps,
6717
+ Step,
6718
+ LinkCard,
6719
+ CardGrid,
6720
+ ApiTable,
6721
+ CodeBlock,
6722
+ CodeTabs,
6723
+ InstallTabs,
6724
+ SpecCard,
6725
+ ProtocolGrid,
6726
+ StatusBadge,
6727
+ ...mermaid ? { Diagram: (p) => /* @__PURE__ */ jsx(Diagram, { ...p, load: mermaid }) } : {}
6728
+ };
6729
+ }
6730
+ var mdxComponents = createMdxComponents();
4251
6731
 
4252
- export { APP_ATTRIBUTE, APP_ID, Accent, Accordion, AccordionItem, AccountMenu, ActivityList, AppCard, AppGrid, AppIcon, AppShell, Badge, BrowserFrame, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardNumeral, CardTitle, Checkbox, Closing, CodeBlock, ComparisonTable, Container, CopyButton, Crowd, DOCS_HREF, DataTable, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHost, DialogTitle, DialogTrigger, Display, DocHeader, DocLayout, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, EmptyLine, EmptyState, EndpointList, ErrorBoundary, ErrorPage, Eyebrow, FAMILY, FAMILY_GROUPS, FactBlock, FactRows, FamilyMenu, Faq, Field, FloatChip, Footnote, HalftoneCanvas, HalftoneSphere, HashChip, Input, IsoCheck, Kbd, KeyValueList, LEGAL_LINKS, Label, Lead, LegalDocument, LoadingBlock, Lockup, MARK_FACES, Mark, Monogram, Notice, OCHK_IO, OCHK_IO_FOOTER, OCHK_IO_NAV, PROTOCOLS, PROTOCOL_ORDER, PackageCard, PageHeader, PageHero, Pagination, PhoneFrame, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ProgressSteps, ProofStrip, Prose, ProtocolGrid, ProtocolHero, ProtocolNav, QrCode, RadioGroup, RadioGroupItem, Reveal, SPHERE_GRADIENT, Sats, SatsFigure, ScrollFade, ScrollStory, Section, SectionHeading, SectionIntro, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetTitle, SheetTrigger, ShellContext, SignInFrame, SignMessage, SiteBanner, SiteFooter, SiteHeader, Skeleton, SkipLink, SpecCard, Spinner, SplitBar, StatCard, StatGrid, StatusBadge, StatusDot, StatusPill, StepGrid, Switch, Tabs, TabsContent, TabsList, TabsTrigger, TextLink, Textarea, ThemeToggle, Ticker, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruthTable, UsdApprox, VerifyBox, VerifyReport, appColors, appFonts, badgeVariants, buttonVariants, cardVariants, cn, confirm, familyByGroup, familySite, monogramGround, monogramLetter, portraitTone, prompt, protocolSite, satsText, sectionVariants, statusWord, useCopy, useInView, useShellPlace, useTimedOut };
6732
+ export { APP_ATTRIBUTE, APP_ID, Accent, Accordion, AccordionItem, AccountMenu, ActivityList, AnchorStatus, ApiTable, AppCard, AppGrid, AppIcon, AppShell, ArtifactView, Badge, BlockCountdown, BlockHeight, Breadcrumbs, BrowserFrame, Button, CODE_LANGS, Callout, Card, CardContent, CardDescription, CardFooter, CardGrid, CardHeader, CardNumeral, CardTitle, Checkbox, Closing, CodeBlock, CodeTabs, ComparisonTable, Container, CopyButton, Crowd, DOCS_HEADER_NAV, DOCS_HREF, DataTable, DensityProvider, Diagram, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogHost, DialogTitle, DialogTrigger, Display, DocHeader, DocLayout, DocsHeading, DocsNav, DocsPager, DocsShell, DropZone, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, EmptyLine, EmptyState, EndpointList, ErrorBoundary, ErrorPage, Eyebrow, FAMILY, FAMILY_GROUPS, FactBlock, FactRows, FamilyMenu, Faq, Field, FilterChips, FloatChip, Footnote, FormSection, HalftoneCanvas, HalftoneSphere, HashChip, Input, InstallTabs, IsoCheck, Kbd, KeyValueList, LEGAL_LINKS, Label, Lead, LegalDocument, LinkCard, LoadingBlock, Lockup, MARK_FACES, Mark, MdxTable, Meter, Monogram, Notice, OCHK_APP_ACCOUNT, OCHK_IO, OCHK_IO_FOOTER, OCHK_IO_NAV, OnThisPage, PROTOCOLS, PROTOCOL_ORDER, PackageCard, PageHeader, PageHero, Pagination, PhoneFrame, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ProgressSteps, ProofStrip, Prose, ProtocolGrid, ProtocolHero, ProtocolNav, QrCode, RadioGroup, RadioGroupItem, Reveal, SPHERE_GRADIENT, Sats, SatsFigure, ScrollFade, ScrollStory, SearchButton, SearchDialog, Section, SectionHeading, SectionIntro, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Separator, SessionAccountView, Sheet, SheetClose, SheetContent, SheetDescription, SheetTitle, SheetTrigger, ShellContext, SignInFrame, SignMessage, SiteBanner, SiteFooter, SiteHeader, Skeleton, SkipLink, SpecCard, Spinner, SplitBar, StatCard, StatGrid, StateBadge, StatusBadge, StatusDot, StatusPill, Step, StepGrid, Steps, Switch, TOKEN_CLASS, Tabs, TabsContent, TabsList, TabsTrigger, TextLink, Textarea, ThemeToggle, Ticker, Toaster, ToolGrid, ToolShell, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TruthTable, UsdApprox, VerifyBox, VerifyReport, appColors, appFonts, badgeVariants, blocksToDuration, buttonVariants, cardVariants, cn, confirm, createMdxComponents, createStateBadge, escapeHtml, explorerUrl, familyByGroup, familySite, formatBlockHeight, formatBytes, formatUtc, grammarOf, highlight, highlightToHtml, languageName, linesToHtml, mdxComponents, monogramGround, monogramLetter, parseCodeMeta, parseLineRanges, portraitTone, prompt, protocolSite, readDiff, rehypeCode, satsText, sectionVariants, shortenMiddle, statusWord, useActiveHeading, useCopy, useDensity, useHeadings, useInView, useShellPlace, useTimedOut };
4253
6733
  //# sourceMappingURL=index.mjs.map
4254
6734
  //# sourceMappingURL=index.mjs.map