@orangecheck/design 0.6.1 → 0.7.1

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.
@@ -0,0 +1,1616 @@
1
+ import { Boxes, ChevronDown, Check, CornerDownLeft, Plus, Loader2, Copy } from 'lucide-react';
2
+ import Link5 from 'next/link';
3
+ import { useState, useRef, useEffect, useId } from 'react';
4
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
+ import { useRouter } from 'next/router';
6
+ import { useOcSession, fetchOcLinkedIdentities } from '@orangecheck/auth-client';
7
+ import { clsx } from 'clsx';
8
+ import { twMerge } from 'tailwind-merge';
9
+
10
+ // src/chrome/ecosystem-switcher.tsx
11
+ var ENTRIES = [
12
+ {
13
+ slug: "home",
14
+ href: "https://ochk.io",
15
+ label: "orangecheck",
16
+ sub: "umbrella",
17
+ docsHref: "https://docs.ochk.io"
18
+ },
19
+ {
20
+ slug: "docs",
21
+ href: "https://docs.ochk.io",
22
+ label: "oc\xB7docs",
23
+ sub: "unified docs",
24
+ docsHref: "https://docs.ochk.io"
25
+ },
26
+ {
27
+ slug: "fleet",
28
+ href: "https://fleet.ochk.io",
29
+ label: "oc\xB7fleet",
30
+ sub: "managed \u2014 agent fleet",
31
+ docsHref: "https://docs.ochk.io/fleet"
32
+ },
33
+ {
34
+ slug: "me",
35
+ href: "https://me.ochk.io",
36
+ label: "oc\xB7me",
37
+ sub: "earn \u2014 consumer identity",
38
+ docsHref: "https://docs.ochk.io/me"
39
+ },
40
+ {
41
+ slug: "vault",
42
+ href: "https://vault.ochk.io",
43
+ label: "oc\xB7vault",
44
+ sub: "keep \u2014 encrypted secrets",
45
+ docsHref: "https://docs.ochk.io/vault"
46
+ },
47
+ {
48
+ slug: "attest",
49
+ href: "https://attest.ochk.io",
50
+ label: "oc\xB7attest",
51
+ sub: "am \u2014 sybil resistance",
52
+ docsHref: "https://docs.ochk.io/attest"
53
+ },
54
+ {
55
+ slug: "lock",
56
+ href: "https://lock.ochk.io",
57
+ label: "oc\xB7lock",
58
+ sub: "whisper \u2014 encryption",
59
+ docsHref: "https://docs.ochk.io/lock"
60
+ },
61
+ {
62
+ slug: "vote",
63
+ href: "https://vote.ochk.io",
64
+ label: "oc\xB7vote",
65
+ sub: "decide \u2014 polls",
66
+ docsHref: "https://docs.ochk.io/vote"
67
+ },
68
+ {
69
+ slug: "stamp",
70
+ href: "https://stamp.ochk.io",
71
+ label: "oc\xB7stamp",
72
+ sub: "declare \u2014 block-anchored",
73
+ docsHref: "https://docs.ochk.io/stamp"
74
+ },
75
+ {
76
+ slug: "agent",
77
+ href: "https://agent.ochk.io",
78
+ label: "oc\xB7agent",
79
+ sub: "delegate \u2014 scoped auth",
80
+ docsHref: "https://docs.ochk.io/agent"
81
+ },
82
+ {
83
+ slug: "pledge",
84
+ href: "https://pledge.ochk.io",
85
+ label: "oc\xB7pledge",
86
+ sub: "swear \u2014 bonded commitment",
87
+ docsHref: "https://docs.ochk.io/pledge"
88
+ }
89
+ ];
90
+ var OWNER_ENTRIES = [
91
+ {
92
+ slug: "analytics",
93
+ href: "https://analytics.ochk.io",
94
+ label: "oc\xB7analytics",
95
+ sub: "owner cockpit",
96
+ docsHref: "https://analytics.ochk.io"
97
+ }
98
+ ];
99
+ function EcosystemSwitcher({
100
+ current,
101
+ className,
102
+ showOwnerEntries = false
103
+ }) {
104
+ const [open, setOpen] = useState(false);
105
+ const containerRef = useRef(null);
106
+ useEffect(() => {
107
+ if (!open) return;
108
+ function onDoc(e) {
109
+ if (!containerRef.current) return;
110
+ if (!containerRef.current.contains(e.target)) setOpen(false);
111
+ }
112
+ function onKey(e) {
113
+ if (e.key === "Escape") setOpen(false);
114
+ }
115
+ document.addEventListener("mousedown", onDoc);
116
+ document.addEventListener("keydown", onKey);
117
+ return () => {
118
+ document.removeEventListener("mousedown", onDoc);
119
+ document.removeEventListener("keydown", onKey);
120
+ };
121
+ }, [open]);
122
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "relative " + (className ?? ""), children: [
123
+ /* @__PURE__ */ jsxs(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ "aria-haspopup": "menu",
128
+ "aria-expanded": open,
129
+ "aria-label": "Switch OrangeCheck product",
130
+ title: "Switch product",
131
+ onClick: () => setOpen((v) => !v),
132
+ className: "inline-flex items-center gap-1 px-2 py-1 transition-colors " + (open ? "text-foreground" : "text-muted-foreground hover:text-foreground"),
133
+ children: [
134
+ /* @__PURE__ */ jsx(Boxes, { className: "h-4 w-4" }),
135
+ /* @__PURE__ */ jsx(
136
+ ChevronDown,
137
+ {
138
+ className: "h-3.5 w-3.5 transition-transform " + (open ? "rotate-180" : "")
139
+ }
140
+ )
141
+ ]
142
+ }
143
+ ),
144
+ open && /* @__PURE__ */ jsxs(
145
+ "div",
146
+ {
147
+ role: "menu",
148
+ "aria-label": "Switch OrangeCheck product",
149
+ className: "bg-background absolute right-0 top-full z-[60] mt-2 w-72 border shadow-lg",
150
+ children: [
151
+ /* @__PURE__ */ jsx("div", { className: "label-mono text-primary border-b px-4 py-2", children: "\xA7 the family" }),
152
+ /* @__PURE__ */ jsx("ul", { className: "py-1", children: [...ENTRIES, ...showOwnerEntries ? OWNER_ENTRIES : []].map((e) => {
153
+ const isActive2 = e.slug === current;
154
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
155
+ Link5,
156
+ {
157
+ href: e.href,
158
+ onClick: () => setOpen(false),
159
+ "aria-current": isActive2 ? "page" : void 0,
160
+ className: "group flex items-baseline gap-3 px-4 py-2 transition-colors " + (isActive2 ? "bg-primary/5" : "hover:bg-muted"),
161
+ children: [
162
+ /* @__PURE__ */ jsx(
163
+ "span",
164
+ {
165
+ className: "font-display flex-1 text-[12px] font-semibold tracking-tight " + (isActive2 ? "text-primary" : "text-foreground group-hover:text-primary transition-colors"),
166
+ children: e.label
167
+ }
168
+ ),
169
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground font-mono text-[10px] tracking-wider uppercase", children: e.sub }),
170
+ isActive2 && /* @__PURE__ */ jsx(Check, { className: "text-primary h-3 w-3" })
171
+ ]
172
+ }
173
+ ) }, e.slug);
174
+ }) }),
175
+ /* @__PURE__ */ jsx("div", { className: "border-t px-4 py-2 font-mono text-[10px] tracking-widest uppercase", children: /* @__PURE__ */ jsx(
176
+ Link5,
177
+ {
178
+ href: "https://docs.ochk.io",
179
+ onClick: () => setOpen(false),
180
+ className: "text-muted-foreground hover:text-foreground inline-block transition-colors",
181
+ children: "docs.ochk.io \u2192"
182
+ }
183
+ ) })
184
+ ]
185
+ }
186
+ )
187
+ ] });
188
+ }
189
+
190
+ // src/chrome/family-properties.ts
191
+ var FAMILY_PROPERTIES = [
192
+ {
193
+ slug: "home",
194
+ origin: "https://ochk.io",
195
+ hostname: "ochk.io",
196
+ label: "orangecheck",
197
+ sub: "umbrella \xB7 sign-in",
198
+ docsHref: "https://docs.ochk.io",
199
+ category: "hub"
200
+ },
201
+ {
202
+ slug: "docs",
203
+ origin: "https://docs.ochk.io",
204
+ hostname: "docs.ochk.io",
205
+ label: "oc\xB7docs",
206
+ sub: "unified reference",
207
+ docsHref: "https://docs.ochk.io",
208
+ category: "hub"
209
+ },
210
+ {
211
+ slug: "me",
212
+ origin: "https://me.ochk.io",
213
+ hostname: "me.ochk.io",
214
+ label: "oc\xB7me",
215
+ sub: "earn \u2014 consumer identity",
216
+ docsHref: "https://docs.ochk.io/me",
217
+ category: "product"
218
+ },
219
+ {
220
+ slug: "vault",
221
+ origin: "https://vault.ochk.io",
222
+ hostname: "vault.ochk.io",
223
+ label: "oc\xB7vault",
224
+ sub: "keep \u2014 encrypted secrets",
225
+ docsHref: "https://docs.ochk.io/vault",
226
+ category: "product"
227
+ },
228
+ {
229
+ slug: "fleet",
230
+ origin: "https://fleet.ochk.io",
231
+ hostname: "fleet.ochk.io",
232
+ label: "oc\xB7fleet",
233
+ sub: "managed \u2014 agent fleet",
234
+ docsHref: "https://docs.ochk.io/fleet",
235
+ category: "product"
236
+ },
237
+ {
238
+ slug: "attest",
239
+ origin: "https://attest.ochk.io",
240
+ hostname: "attest.ochk.io",
241
+ label: "oc\xB7attest",
242
+ sub: "am \u2014 sybil resistance",
243
+ docsHref: "https://docs.ochk.io/attest",
244
+ category: "protocol"
245
+ },
246
+ {
247
+ slug: "lock",
248
+ origin: "https://lock.ochk.io",
249
+ hostname: "lock.ochk.io",
250
+ label: "oc\xB7lock",
251
+ sub: "whisper \u2014 encryption",
252
+ docsHref: "https://docs.ochk.io/lock",
253
+ category: "protocol"
254
+ },
255
+ {
256
+ slug: "vote",
257
+ origin: "https://vote.ochk.io",
258
+ hostname: "vote.ochk.io",
259
+ label: "oc\xB7vote",
260
+ sub: "decide \u2014 polls",
261
+ docsHref: "https://docs.ochk.io/vote",
262
+ category: "protocol"
263
+ },
264
+ {
265
+ slug: "stamp",
266
+ origin: "https://stamp.ochk.io",
267
+ hostname: "stamp.ochk.io",
268
+ label: "oc\xB7stamp",
269
+ sub: "declare \u2014 block-anchored",
270
+ docsHref: "https://docs.ochk.io/stamp",
271
+ category: "protocol"
272
+ },
273
+ {
274
+ slug: "agent",
275
+ origin: "https://agent.ochk.io",
276
+ hostname: "agent.ochk.io",
277
+ label: "oc\xB7agent",
278
+ sub: "delegate \u2014 scoped auth",
279
+ docsHref: "https://docs.ochk.io/agent",
280
+ category: "protocol"
281
+ },
282
+ {
283
+ slug: "pledge",
284
+ origin: "https://pledge.ochk.io",
285
+ hostname: "pledge.ochk.io",
286
+ label: "oc\xB7pledge",
287
+ sub: "swear \u2014 bonded commitment",
288
+ docsHref: "https://docs.ochk.io/pledge",
289
+ category: "protocol"
290
+ },
291
+ {
292
+ slug: "analytics",
293
+ origin: "https://analytics.ochk.io",
294
+ hostname: "analytics.ochk.io",
295
+ label: "oc\xB7analytics",
296
+ sub: "owner cockpit",
297
+ docsHref: "https://analytics.ochk.io",
298
+ category: "owner"
299
+ }
300
+ ];
301
+ var SITE_STATE_LABEL = {
302
+ alpha: "alpha",
303
+ beta: "beta"
304
+ };
305
+ function findFamilyProperty(slug) {
306
+ return FAMILY_PROPERTIES.find((p) => p.slug === slug);
307
+ }
308
+ var SECTIONS = [
309
+ { category: "hub", label: "hub" },
310
+ { category: "product", label: "products" },
311
+ { category: "protocol", label: "protocols" },
312
+ { category: "owner", label: "owner" }
313
+ ];
314
+ function CategoryChip({ category }) {
315
+ if (category === "hub") return null;
316
+ const label = category === "product" ? "product" : category === "protocol" ? "protocol" : "owner";
317
+ const tone = category === "product" ? "border-primary/25 bg-primary/10 text-primary" : category === "protocol" ? "border-muted-foreground/20 bg-muted/40 text-muted-foreground/85" : "border-warning/30 bg-warning/10 text-warning";
318
+ return /* @__PURE__ */ jsx(
319
+ "span",
320
+ {
321
+ "aria-label": category === "product" ? "commercial product" : category === "protocol" ? "protocol reference" : "owner-only surface",
322
+ className: "ml-1 hidden rounded-sm border px-1.5 py-[1px] font-mono text-[9px] font-medium tracking-widest uppercase sm:inline-block " + tone,
323
+ "data-oc-category": category,
324
+ children: label
325
+ }
326
+ );
327
+ }
328
+ function SiteStateBadge({ state }) {
329
+ if (state === "live") return null;
330
+ return /* @__PURE__ */ jsx(
331
+ "span",
332
+ {
333
+ "aria-label": `site lifecycle: ${state}`,
334
+ className: "text-muted-foreground/70 ml-1 hidden font-mono text-[9px] font-medium tracking-widest uppercase sm:inline-block",
335
+ "data-oc-site-state": state,
336
+ children: SITE_STATE_LABEL[state]
337
+ }
338
+ );
339
+ }
340
+ function MenuCategoryChip({ category }) {
341
+ if (category === "hub") return null;
342
+ const label = category === "product" ? "pro" : category === "protocol" ? "spec" : "own";
343
+ const tone = category === "product" ? "bg-primary/10 text-primary" : category === "protocol" ? "bg-muted/60 text-muted-foreground/80" : "bg-warning/15 text-warning";
344
+ return /* @__PURE__ */ jsx(
345
+ "span",
346
+ {
347
+ "aria-hidden": true,
348
+ className: "inline-block shrink-0 rounded-sm px-1 py-[1px] font-mono text-[9px] font-medium tracking-widest uppercase " + tone,
349
+ children: label
350
+ }
351
+ );
352
+ }
353
+ function OcLogoDropdown({
354
+ current,
355
+ homeHref = "/",
356
+ siteState = "live",
357
+ children,
358
+ className,
359
+ triggerClassName,
360
+ popoverClassName,
361
+ showOwnerEntries = false
362
+ }) {
363
+ const [open, setOpen] = useState(false);
364
+ const containerRef = useRef(null);
365
+ const menuId = useId();
366
+ const router = useRouter();
367
+ const currentCategory = findFamilyProperty(current)?.category ?? "hub";
368
+ function handleTriggerClick(e) {
369
+ if (e.detail >= 2) {
370
+ e.preventDefault();
371
+ setOpen(false);
372
+ void router.push(homeHref);
373
+ return;
374
+ }
375
+ setOpen((v) => !v);
376
+ }
377
+ useEffect(() => {
378
+ if (!open) return;
379
+ function onDoc(e) {
380
+ if (!containerRef.current) return;
381
+ if (!containerRef.current.contains(e.target)) setOpen(false);
382
+ }
383
+ function onKey(e) {
384
+ if (e.key === "Escape") setOpen(false);
385
+ }
386
+ document.addEventListener("mousedown", onDoc);
387
+ document.addEventListener("keydown", onKey);
388
+ return () => {
389
+ document.removeEventListener("mousedown", onDoc);
390
+ document.removeEventListener("keydown", onKey);
391
+ };
392
+ }, [open]);
393
+ return /* @__PURE__ */ jsxs(
394
+ "div",
395
+ {
396
+ ref: containerRef,
397
+ className: "relative inline-flex items-center " + (className ?? ""),
398
+ "data-oc-logo-dropdown": "",
399
+ "data-oc-current-category": currentCategory,
400
+ "data-oc-site-state": siteState,
401
+ children: [
402
+ /* @__PURE__ */ jsxs(
403
+ "button",
404
+ {
405
+ type: "button",
406
+ "aria-haspopup": "menu",
407
+ "aria-expanded": open,
408
+ "aria-controls": menuId,
409
+ "aria-label": "OrangeCheck family \xB7 click to open property menu, double-click to go home",
410
+ title: "single-click \xB7 family menu \xB7 double-click \xB7 go home",
411
+ onClick: handleTriggerClick,
412
+ className: triggerClassName ?? "group hover:bg-accent/30 -mx-1.5 -my-1 flex min-h-[40px] items-center gap-2 rounded-sm px-1.5 py-1 transition-colors " + (open ? "bg-accent/20" : ""),
413
+ "data-oc-logo-dropdown-trigger": "",
414
+ "data-oc-logo-dropdown-open": open ? "true" : "false",
415
+ children: [
416
+ children,
417
+ /* @__PURE__ */ jsx(CategoryChip, { category: currentCategory }),
418
+ /* @__PURE__ */ jsx(SiteStateBadge, { state: siteState }),
419
+ /* @__PURE__ */ jsx(
420
+ ChevronDown,
421
+ {
422
+ "aria-hidden": true,
423
+ className: "text-muted-foreground/70 group-hover:text-foreground/80 h-3.5 w-3.5 shrink-0 transition-transform duration-200 " + (open ? "rotate-180" : "")
424
+ }
425
+ )
426
+ ]
427
+ }
428
+ ),
429
+ /* @__PURE__ */ jsxs(
430
+ Link5,
431
+ {
432
+ href: homeHref,
433
+ "aria-label": "go to " + homeHref + " (this site's home)",
434
+ onClick: () => setOpen(false),
435
+ tabIndex: open ? 0 : -1,
436
+ className: "hover:text-primary group/home -ml-1 hidden items-center gap-1 rounded-sm px-1.5 py-1 font-mono text-[9px] tracking-widest uppercase transition-all duration-200 sm:inline-flex " + (open ? "pointer-events-auto translate-x-0 text-muted-foreground/70 opacity-100 hover:bg-accent/30" : "pointer-events-none -translate-x-1 opacity-0"),
437
+ "data-oc-logo-dropdown-home-hint": "",
438
+ children: [
439
+ /* @__PURE__ */ jsx(
440
+ CornerDownLeft,
441
+ {
442
+ "aria-hidden": true,
443
+ className: "h-3 w-3 group-hover/home:text-primary " + (open ? "motion-safe:animate-pulse" : "")
444
+ }
445
+ ),
446
+ /* @__PURE__ */ jsx("span", { className: "text-primary/70 group-hover/home:text-primary", children: "home" })
447
+ ]
448
+ }
449
+ ),
450
+ open && /* @__PURE__ */ jsxs(
451
+ "div",
452
+ {
453
+ id: menuId,
454
+ role: "menu",
455
+ "aria-label": "OrangeCheck family",
456
+ className: popoverClassName ?? "bg-background absolute top-full left-0 z-[60] mt-2 w-[min(20rem,calc(100vw-1rem))] border shadow-lg",
457
+ "data-oc-logo-dropdown-popover": "",
458
+ children: [
459
+ /* @__PURE__ */ jsx("div", { className: "label-mono text-primary border-b px-4 py-2", children: "\xA7 the orangecheck family" }),
460
+ /* @__PURE__ */ jsx("div", { className: "max-h-[min(28rem,70vh)] overflow-y-auto py-1", role: "none", children: SECTIONS.map(({ category, label }) => {
461
+ if (category === "owner" && !showOwnerEntries) return null;
462
+ const sectionEntries = FAMILY_PROPERTIES.filter(
463
+ (e) => e.category === category
464
+ );
465
+ if (sectionEntries.length === 0) return null;
466
+ return /* @__PURE__ */ jsxs("div", { role: "none", "data-oc-section": category, children: [
467
+ /* @__PURE__ */ jsx(
468
+ "div",
469
+ {
470
+ role: "separator",
471
+ "aria-hidden": true,
472
+ className: "text-muted-foreground/60 px-4 pt-2.5 pb-1 font-mono text-[9px] font-medium tracking-widest uppercase " + (category === "hub" ? "" : "border-t mt-1"),
473
+ children: label
474
+ }
475
+ ),
476
+ /* @__PURE__ */ jsx("ul", { role: "none", className: "pb-1", children: sectionEntries.map((e) => {
477
+ const isActive2 = e.slug === current;
478
+ const href = isActive2 ? homeHref : e.origin;
479
+ return /* @__PURE__ */ jsx("li", { role: "none", children: /* @__PURE__ */ jsxs(
480
+ Link5,
481
+ {
482
+ href,
483
+ role: "menuitem",
484
+ onClick: () => setOpen(false),
485
+ "aria-current": isActive2 ? "page" : void 0,
486
+ className: "group flex items-center gap-2 px-4 py-2 transition-colors " + (isActive2 ? "bg-primary/8 border-primary -ml-px border-l-2" : "hover:bg-muted -ml-px border-l-2 border-transparent"),
487
+ "data-oc-logo-dropdown-item": isActive2 ? "current" : "sibling",
488
+ "data-oc-entry-category": e.category,
489
+ children: [
490
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [
491
+ /* @__PURE__ */ jsx(
492
+ "span",
493
+ {
494
+ className: "font-display text-[12px] font-semibold tracking-tight " + (isActive2 ? "text-primary" : "text-foreground group-hover:text-primary transition-colors"),
495
+ children: e.label
496
+ }
497
+ ),
498
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground mt-0.5 font-mono text-[10px] tracking-wide", children: e.sub })
499
+ ] }),
500
+ /* @__PURE__ */ jsx(MenuCategoryChip, { category: e.category }),
501
+ isActive2 ? /* @__PURE__ */ jsxs("span", { className: "text-primary inline-flex shrink-0 items-center gap-1 font-mono text-[10px] tracking-widest uppercase", children: [
502
+ "home",
503
+ /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" })
504
+ ] }) : null
505
+ ]
506
+ }
507
+ ) }, e.slug);
508
+ }) })
509
+ ] }, category);
510
+ }) }),
511
+ /* @__PURE__ */ jsx("div", { className: "border-t px-4 py-2 font-mono text-[10px] tracking-widest uppercase", children: /* @__PURE__ */ jsx(
512
+ Link5,
513
+ {
514
+ href: "https://docs.ochk.io",
515
+ onClick: () => setOpen(false),
516
+ className: "text-muted-foreground hover:text-foreground inline-block transition-colors",
517
+ children: "docs.ochk.io \u2192"
518
+ }
519
+ ) })
520
+ ]
521
+ }
522
+ )
523
+ ]
524
+ }
525
+ );
526
+ }
527
+ function obscureIdentity(value) {
528
+ if (value.length <= 12) {
529
+ return `${value.slice(0, 4)}\u2026${value.slice(-3)}`;
530
+ }
531
+ return `${value.slice(0, 6)}\u2026${value.slice(-4)}`;
532
+ }
533
+ var IDENTITY_KIND_LABEL = {
534
+ did: "did:oc",
535
+ btc: "bitcoin",
536
+ email: "email",
537
+ nostr: "nostr"
538
+ };
539
+ async function writeClipboard(text) {
540
+ try {
541
+ if (navigator.clipboard?.writeText) {
542
+ await navigator.clipboard.writeText(text);
543
+ return true;
544
+ }
545
+ } catch {
546
+ }
547
+ try {
548
+ const ta = document.createElement("textarea");
549
+ ta.value = text;
550
+ ta.setAttribute("readonly", "");
551
+ ta.style.position = "fixed";
552
+ ta.style.top = "-1000px";
553
+ ta.style.opacity = "0";
554
+ document.body.appendChild(ta);
555
+ ta.select();
556
+ const ok = document.execCommand("copy");
557
+ document.body.removeChild(ta);
558
+ return ok;
559
+ } catch {
560
+ return false;
561
+ }
562
+ }
563
+ function CopyableDid({ did }) {
564
+ const [copied, setCopied] = useState(false);
565
+ const timerRef = useRef(null);
566
+ useEffect(
567
+ () => () => {
568
+ if (timerRef.current) clearTimeout(timerRef.current);
569
+ },
570
+ []
571
+ );
572
+ const onCopy = async () => {
573
+ const ok = await writeClipboard(did);
574
+ if (!ok) return;
575
+ setCopied(true);
576
+ if (timerRef.current) clearTimeout(timerRef.current);
577
+ timerRef.current = setTimeout(() => setCopied(false), 1600);
578
+ };
579
+ return /* @__PURE__ */ jsxs(
580
+ "button",
581
+ {
582
+ type: "button",
583
+ onClick: onCopy,
584
+ "aria-label": copied ? "OrangeCheck identity copied to clipboard" : `Copy OrangeCheck identity ${did} to clipboard`,
585
+ title: "Copy identity",
586
+ "data-oc-account-menu-copy-did": "",
587
+ "data-copied": copied ? "" : void 0,
588
+ className: "group/did hover:bg-accent focus-visible:ring-ring/60 -mx-1.5 mt-px flex w-[calc(100%+0.75rem)] items-start gap-1.5 rounded px-1.5 py-1 text-left transition-colors focus-visible:ring-2 focus-visible:outline-none",
589
+ children: [
590
+ /* @__PURE__ */ jsx("span", { className: "text-foreground/90 min-w-0 flex-1 font-mono text-[11px] leading-tight break-all", children: did }),
591
+ /* @__PURE__ */ jsx(
592
+ "span",
593
+ {
594
+ className: "mt-px shrink-0 transition-colors " + (copied ? "text-primary" : "text-muted-foreground/50 group-hover/did:text-foreground/80"),
595
+ "aria-hidden": true,
596
+ children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3.5" })
597
+ }
598
+ ),
599
+ /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: copied ? "Copied to clipboard" : "" })
600
+ ]
601
+ }
602
+ );
603
+ }
604
+ function PromoteRow({
605
+ kind,
606
+ value,
607
+ active,
608
+ busy,
609
+ disabled,
610
+ onPromote
611
+ }) {
612
+ const [copied, setCopied] = useState(false);
613
+ const timerRef = useRef(null);
614
+ useEffect(
615
+ () => () => {
616
+ if (timerRef.current) clearTimeout(timerRef.current);
617
+ },
618
+ []
619
+ );
620
+ const onCopy = async () => {
621
+ const ok = await writeClipboard(value);
622
+ if (!ok) return;
623
+ setCopied(true);
624
+ if (timerRef.current) clearTimeout(timerRef.current);
625
+ timerRef.current = setTimeout(() => setCopied(false), 1600);
626
+ };
627
+ const kindLabel = IDENTITY_KIND_LABEL[kind];
628
+ return /* @__PURE__ */ jsxs(
629
+ "div",
630
+ {
631
+ className: "hover:bg-accent flex items-center gap-1 pr-2 transition-colors",
632
+ "data-oc-account-menu-promote-row": kind,
633
+ "data-active": active ? "" : void 0,
634
+ children: [
635
+ /* @__PURE__ */ jsxs(
636
+ "button",
637
+ {
638
+ type: "button",
639
+ role: "menuitemradio",
640
+ "aria-checked": active,
641
+ "aria-label": active ? `Showing as ${kindLabel}` : `Show as ${kindLabel}`,
642
+ disabled: disabled || active,
643
+ onClick: onPromote,
644
+ "data-oc-account-menu-promote": kind,
645
+ className: "flex min-w-0 flex-1 items-center gap-2 py-2 pl-3 text-left font-mono text-[11px] tracking-wide disabled:cursor-default",
646
+ children: [
647
+ /* @__PURE__ */ jsx(
648
+ "span",
649
+ {
650
+ className: "flex size-3.5 shrink-0 items-center justify-center rounded-full border " + (active ? "border-primary" : "border-muted-foreground/40"),
651
+ "aria-hidden": true,
652
+ children: active ? /* @__PURE__ */ jsx("span", { className: "bg-primary size-1.5 rounded-full" }) : null
653
+ }
654
+ ),
655
+ /* @__PURE__ */ jsx("span", { className: "text-foreground/90 min-w-0 flex-1 truncate", children: obscureIdentity(value) })
656
+ ]
657
+ }
658
+ ),
659
+ /* @__PURE__ */ jsx(
660
+ "button",
661
+ {
662
+ type: "button",
663
+ onClick: () => void onCopy(),
664
+ "aria-label": copied ? `${kindLabel} copied to clipboard` : `Copy ${kindLabel} to clipboard`,
665
+ title: "Copy",
666
+ "data-oc-account-menu-promote-copy": kind,
667
+ "data-copied": copied ? "" : void 0,
668
+ className: "hover:bg-background/70 focus-visible:ring-ring/60 flex size-6 shrink-0 items-center justify-center rounded transition-colors focus-visible:ring-2 focus-visible:outline-none",
669
+ children: copied ? /* @__PURE__ */ jsx(Check, { className: "text-primary size-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "text-muted-foreground/50 size-3.5" })
670
+ }
671
+ ),
672
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50 w-14 shrink-0 text-right text-[9px] tracking-widest uppercase", children: busy ? /* @__PURE__ */ jsx(Loader2, { className: "ml-auto size-3 animate-spin" }) : kindLabel }),
673
+ /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: copied ? "Copied to clipboard" : "" })
674
+ ]
675
+ }
676
+ );
677
+ }
678
+ function IdentityPromoteSection({
679
+ didOc,
680
+ nostrNpub,
681
+ current,
682
+ open,
683
+ setDisplayIdentity
684
+ }) {
685
+ const [identities, setIdentities] = useState(null);
686
+ const [loadFailed, setLoadFailed] = useState(false);
687
+ const [promoting, setPromoting] = useState(null);
688
+ const [promoteErr, setPromoteErr] = useState(null);
689
+ const lastFetchKeyRef = useRef(null);
690
+ useEffect(() => {
691
+ if (!open) return;
692
+ if (lastFetchKeyRef.current === didOc) return;
693
+ lastFetchKeyRef.current = didOc;
694
+ let cancelled = false;
695
+ setIdentities(null);
696
+ setLoadFailed(false);
697
+ void fetchOcLinkedIdentities().then((rows) => {
698
+ if (!cancelled) setIdentities(rows);
699
+ }).catch(() => {
700
+ if (!cancelled) setLoadFailed(true);
701
+ });
702
+ return () => {
703
+ cancelled = true;
704
+ };
705
+ }, [open, didOc]);
706
+ if (identities === null && !loadFailed) return null;
707
+ const btc = identities?.find((i) => i.kind === "btc" && i.is_primary && i.value) ?? identities?.find((i) => i.kind === "btc" && i.value);
708
+ const email = identities?.find((i) => i.kind === "email" && i.is_primary && i.value) ?? identities?.find((i) => i.kind === "email" && i.value);
709
+ const options = [
710
+ { kind: "did", value: didOc }
711
+ ];
712
+ if (btc?.value) options.push({ kind: "btc", value: btc.value });
713
+ if (email?.value) options.push({ kind: "email", value: email.value });
714
+ if (nostrNpub) options.push({ kind: "nostr", value: nostrNpub });
715
+ if (options.length < 2) return null;
716
+ const promote = async (kind) => {
717
+ if (promoting || kind === current.kind) return;
718
+ setPromoting(kind);
719
+ setPromoteErr(null);
720
+ try {
721
+ await setDisplayIdentity(kind);
722
+ } catch (e) {
723
+ setPromoteErr(e instanceof Error ? e.message : "promotion failed");
724
+ } finally {
725
+ setPromoting(null);
726
+ }
727
+ };
728
+ return /* @__PURE__ */ jsxs("div", { className: "border-border border-b p-1", "data-oc-account-menu-section": "show-as", children: [
729
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 px-3 pt-2 pb-1 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 show as" }),
730
+ options.map((opt) => /* @__PURE__ */ jsx(
731
+ PromoteRow,
732
+ {
733
+ kind: opt.kind,
734
+ value: opt.value,
735
+ active: opt.kind === current.kind,
736
+ busy: promoting === opt.kind,
737
+ disabled: promoting !== null,
738
+ onPromote: () => void promote(opt.kind)
739
+ },
740
+ opt.kind
741
+ )),
742
+ promoteErr ? /* @__PURE__ */ jsx("div", { className: "text-destructive/80 px-3 pt-1 pb-2 font-mono text-[10px]", children: promoteErr }) : null
743
+ ] });
744
+ }
745
+ function OcAccountMenu(props) {
746
+ const session = useOcSession();
747
+ return /* @__PURE__ */ jsx(
748
+ OcAccountMenuView,
749
+ {
750
+ ...props,
751
+ session: {
752
+ status: session.status,
753
+ account: session.account ? {
754
+ didOc: session.account.didOc,
755
+ displayName: session.account.displayName ?? null,
756
+ displayIdentity: session.account.displayIdentity,
757
+ nostrNpub: session.account.nostrNpub ?? null
758
+ } : null,
759
+ signOut: session.signOut,
760
+ refresh: session.refresh,
761
+ setDisplayIdentity: session.setDisplayIdentity,
762
+ // Multi-account · the connected variant always forwards
763
+ // these from useOcSession(). The View variant accepts
764
+ // them as optional so sites running their own auth
765
+ // context (oc-www) can opt in incrementally.
766
+ roster: session.roster,
767
+ switchAccount: session.switchAccount,
768
+ addAccountUrl: session.addAccountUrl
769
+ }
770
+ }
771
+ );
772
+ }
773
+ function OcAccountMenuView({
774
+ current,
775
+ signInUrl = "/signin",
776
+ signInLabel = "sign in",
777
+ signOutRedirect = "/",
778
+ menuItems,
779
+ primaryNavLinks,
780
+ secondaryNavLinks,
781
+ showFamilyDashboard,
782
+ build,
783
+ siteState,
784
+ className,
785
+ triggerClassName,
786
+ popoverClassName,
787
+ session
788
+ }) {
789
+ const {
790
+ status,
791
+ account,
792
+ signOut,
793
+ refresh,
794
+ setDisplayIdentity,
795
+ roster,
796
+ switchAccount,
797
+ addAccountUrl
798
+ } = session;
799
+ const [hydrated, setHydrated] = useState(false);
800
+ const [open, setOpen] = useState(false);
801
+ const wrapRef = useRef(null);
802
+ const property = findFamilyProperty(current);
803
+ const hostname = property?.hostname ?? `${current}.ochk.io`;
804
+ const isHome = current === "home";
805
+ const familyDashboardEnabled = showFamilyDashboard ?? !isHome;
806
+ useEffect(() => setHydrated(true), []);
807
+ useEffect(() => {
808
+ const onWake = () => {
809
+ if (document.visibilityState === "visible") void refresh();
810
+ };
811
+ const onFocus = () => void refresh();
812
+ document.addEventListener("visibilitychange", onWake);
813
+ window.addEventListener("focus", onFocus);
814
+ return () => {
815
+ document.removeEventListener("visibilitychange", onWake);
816
+ window.removeEventListener("focus", onFocus);
817
+ };
818
+ }, [refresh]);
819
+ useEffect(() => {
820
+ if (!open) return;
821
+ const onClick = (e) => {
822
+ if (wrapRef.current && !wrapRef.current.contains(e.target)) setOpen(false);
823
+ };
824
+ const onKey = (e) => {
825
+ if (e.key === "Escape") setOpen(false);
826
+ };
827
+ document.addEventListener("mousedown", onClick);
828
+ document.addEventListener("keydown", onKey);
829
+ return () => {
830
+ document.removeEventListener("mousedown", onClick);
831
+ document.removeEventListener("keydown", onKey);
832
+ };
833
+ }, [open]);
834
+ const signInTrigger = /* @__PURE__ */ jsx(
835
+ "a",
836
+ {
837
+ href: signInUrl,
838
+ "aria-label": signInLabel,
839
+ "data-oc-account-menu-signin": "",
840
+ className: triggerClassName ?? "border-input bg-background hover:bg-accent inline-flex h-8 items-center justify-center rounded-md border px-3 font-mono text-[11px] font-semibold tracking-widest uppercase transition-colors",
841
+ children: signInLabel
842
+ }
843
+ );
844
+ if (!hydrated || status === "loading") {
845
+ return signInTrigger;
846
+ }
847
+ if (status !== "authenticated" || !account) {
848
+ return signInTrigger;
849
+ }
850
+ const displayName = account.displayName ?? null;
851
+ const label = displayName ?? obscureIdentity(account.displayIdentity.value);
852
+ return /* @__PURE__ */ jsxs(
853
+ "div",
854
+ {
855
+ ref: wrapRef,
856
+ className: "relative inline-block " + (className ?? ""),
857
+ "data-oc-account-menu": "",
858
+ children: [
859
+ /* @__PURE__ */ jsxs(
860
+ "button",
861
+ {
862
+ type: "button",
863
+ onClick: () => setOpen((v) => !v),
864
+ "aria-haspopup": "menu",
865
+ "aria-expanded": open,
866
+ "aria-label": `Signed in as ${account.didOc}. Open account menu.`,
867
+ className: triggerClassName ?? "border-primary/40 bg-card hover:bg-accent inline-flex h-8 items-center gap-1.5 rounded-md border px-3 font-mono text-[11px] tracking-wide transition-colors",
868
+ "data-oc-account-menu-trigger": "",
869
+ children: [
870
+ /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block size-1.5 rounded-full", "aria-hidden": true }),
871
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: label }),
872
+ /* @__PURE__ */ jsx(
873
+ "svg",
874
+ {
875
+ width: "9",
876
+ height: "9",
877
+ viewBox: "0 0 10 10",
878
+ "aria-hidden": true,
879
+ className: "opacity-60 transition-transform " + (open ? "rotate-180" : "rotate-0"),
880
+ children: /* @__PURE__ */ jsx(
881
+ "path",
882
+ {
883
+ d: "M2 4 L5 7 L8 4",
884
+ stroke: "currentColor",
885
+ strokeWidth: "1.5",
886
+ fill: "none",
887
+ strokeLinecap: "round"
888
+ }
889
+ )
890
+ }
891
+ )
892
+ ]
893
+ }
894
+ ),
895
+ open && /* @__PURE__ */ jsxs(
896
+ "div",
897
+ {
898
+ role: "menu",
899
+ "aria-label": "Account menu",
900
+ className: popoverClassName ?? "border-border bg-popover text-popover-foreground absolute top-[calc(100%+6px)] right-0 z-50 w-[min(20rem,calc(100vw-1rem))] border shadow-xl",
901
+ "data-oc-account-menu-popover": "",
902
+ children: [
903
+ /* @__PURE__ */ jsxs("div", { className: "border-border border-b p-3", children: [
904
+ /* @__PURE__ */ jsxs("div", { className: "text-primary mb-1 font-mono text-[10px] tracking-widest uppercase", children: [
905
+ "\xA7 signed in \xB7 ",
906
+ hostname
907
+ ] }),
908
+ /* @__PURE__ */ jsx(CopyableDid, { did: account.didOc }),
909
+ displayName ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/80 mt-1 font-mono text-[10px] tracking-wide", children: displayName }) : null
910
+ ] }),
911
+ /* @__PURE__ */ jsx(
912
+ IdentityPromoteSection,
913
+ {
914
+ didOc: account.didOc,
915
+ nostrNpub: account.nostrNpub ?? null,
916
+ current: account.displayIdentity,
917
+ open,
918
+ setDisplayIdentity
919
+ }
920
+ ),
921
+ /* @__PURE__ */ jsx(
922
+ AccountsSection,
923
+ {
924
+ roster: roster ?? [],
925
+ switchAccount,
926
+ addAccountUrl,
927
+ signOut,
928
+ onActionStart: () => setOpen(false)
929
+ }
930
+ ),
931
+ primaryNavLinks && primaryNavLinks.length > 0 ? /* @__PURE__ */ jsx(
932
+ PopoverSection,
933
+ {
934
+ label: "navigate",
935
+ items: primaryNavLinks,
936
+ onItemClick: () => setOpen(false)
937
+ }
938
+ ) : null,
939
+ /* @__PURE__ */ jsxs("div", { className: "p-1", "data-oc-account-menu-section": "account", children: [
940
+ primaryNavLinks && primaryNavLinks.length > 0 ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 px-3 pb-1 pt-2 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 account" }) : null,
941
+ menuItems?.map((item) => {
942
+ const onClick = () => setOpen(false);
943
+ const cls = "hover:bg-accent flex items-center gap-2 px-3 py-2 font-mono text-[11px] tracking-wide transition-colors";
944
+ const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
945
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
946
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: item.label }),
947
+ item.external ? /* @__PURE__ */ jsx(
948
+ "span",
949
+ {
950
+ className: "text-muted-foreground/70 text-[10px]",
951
+ "aria-hidden": true,
952
+ children: "\u2197"
953
+ }
954
+ ) : null
955
+ ] });
956
+ return item.external ? /* @__PURE__ */ jsx(
957
+ "a",
958
+ {
959
+ href: item.href,
960
+ target: "_blank",
961
+ rel: "noreferrer",
962
+ onClick,
963
+ role: "menuitem",
964
+ className: cls,
965
+ "data-oc-account-menu-item": "",
966
+ children: inner
967
+ },
968
+ item.href
969
+ ) : /* @__PURE__ */ jsx(
970
+ Link5,
971
+ {
972
+ href: item.href,
973
+ onClick,
974
+ role: "menuitem",
975
+ className: cls,
976
+ "data-oc-account-menu-item": "",
977
+ children: inner
978
+ },
979
+ item.href
980
+ );
981
+ }),
982
+ familyDashboardEnabled ? /* @__PURE__ */ jsxs(
983
+ "a",
984
+ {
985
+ href: "https://ochk.io/dashboard",
986
+ target: "_blank",
987
+ rel: "noreferrer",
988
+ onClick: () => setOpen(false),
989
+ role: "menuitem",
990
+ className: "hover:bg-accent flex items-center gap-2 px-3 py-2 font-mono text-[11px] tracking-wide transition-colors",
991
+ "data-oc-account-menu-item": "",
992
+ "data-oc-account-menu-family-dashboard": "",
993
+ children: [
994
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
995
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: "family dashboard" }),
996
+ /* @__PURE__ */ jsx(
997
+ "span",
998
+ {
999
+ className: "text-muted-foreground/70 text-[10px]",
1000
+ "aria-hidden": true,
1001
+ children: "\u2197"
1002
+ }
1003
+ )
1004
+ ]
1005
+ }
1006
+ ) : null,
1007
+ /* @__PURE__ */ jsxs(
1008
+ "button",
1009
+ {
1010
+ type: "button",
1011
+ role: "menuitem",
1012
+ onClick: () => {
1013
+ setOpen(false);
1014
+ void (async () => {
1015
+ await signOut();
1016
+ if (typeof window !== "undefined") {
1017
+ window.location.assign(signOutRedirect);
1018
+ }
1019
+ })();
1020
+ },
1021
+ className: "hover:bg-accent flex w-full items-center gap-2 px-3 py-2 text-left font-mono text-[11px] tracking-wide transition-colors",
1022
+ "data-oc-account-menu-item": "",
1023
+ "data-oc-account-menu-signout": "",
1024
+ children: [
1025
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
1026
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: "sign out" })
1027
+ ]
1028
+ }
1029
+ )
1030
+ ] }),
1031
+ secondaryNavLinks && secondaryNavLinks.length > 0 ? /* @__PURE__ */ jsx(
1032
+ PopoverSection,
1033
+ {
1034
+ label: "more",
1035
+ items: secondaryNavLinks,
1036
+ onItemClick: () => setOpen(false),
1037
+ bordered: true
1038
+ }
1039
+ ) : null,
1040
+ build ? /* @__PURE__ */ jsx(BuildFooter, { hostname, build, state: siteState }) : null
1041
+ ]
1042
+ }
1043
+ )
1044
+ ]
1045
+ }
1046
+ );
1047
+ }
1048
+ function AccountsSection({
1049
+ roster,
1050
+ switchAccount,
1051
+ addAccountUrl,
1052
+ signOut,
1053
+ onActionStart
1054
+ }) {
1055
+ const [switching, setSwitching] = useState(null);
1056
+ const [err, setErr] = useState(null);
1057
+ if (!addAccountUrl) return null;
1058
+ const onSwitch = async (didOc) => {
1059
+ if (!switchAccount || switching) return;
1060
+ setSwitching(didOc);
1061
+ setErr(null);
1062
+ try {
1063
+ await switchAccount(didOc);
1064
+ } catch (e) {
1065
+ setErr(e instanceof Error ? e.message : "switch failed");
1066
+ } finally {
1067
+ setSwitching(null);
1068
+ }
1069
+ };
1070
+ return /* @__PURE__ */ jsxs("div", { className: "border-border border-b p-1", "data-oc-account-menu-section": "accounts", children: [
1071
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 px-3 pt-2 pb-1 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 accounts" }),
1072
+ roster.map((peer) => /* @__PURE__ */ jsx(
1073
+ SwitchRow,
1074
+ {
1075
+ peer,
1076
+ busy: switching === peer.didOc,
1077
+ disabled: switching !== null,
1078
+ onSwitch: () => void onSwitch(peer.didOc)
1079
+ },
1080
+ peer.didOc
1081
+ )),
1082
+ /* @__PURE__ */ jsxs(
1083
+ "a",
1084
+ {
1085
+ href: addAccountUrl(),
1086
+ onClick: () => onActionStart(),
1087
+ role: "menuitem",
1088
+ "data-oc-account-menu-add-account": "",
1089
+ className: "hover:bg-accent flex items-center gap-2 px-3 py-2 font-mono text-[11px] tracking-wide transition-colors",
1090
+ children: [
1091
+ /* @__PURE__ */ jsx(Plus, { className: "text-muted-foreground size-3.5 shrink-0", "aria-hidden": true }),
1092
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: roster.length === 0 ? "add another account" : "add another" })
1093
+ ]
1094
+ }
1095
+ ),
1096
+ roster.length > 0 ? /* @__PURE__ */ jsxs(
1097
+ "button",
1098
+ {
1099
+ type: "button",
1100
+ role: "menuitem",
1101
+ onClick: () => {
1102
+ onActionStart();
1103
+ void (async () => {
1104
+ try {
1105
+ await signOut({ scope: "current" });
1106
+ } catch {
1107
+ }
1108
+ })();
1109
+ },
1110
+ "data-oc-account-menu-leave-current": "",
1111
+ className: "hover:bg-accent flex w-full items-center gap-2 px-3 py-2 text-left font-mono text-[11px] tracking-wide transition-colors",
1112
+ children: [
1113
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
1114
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: "leave this account" })
1115
+ ]
1116
+ }
1117
+ ) : null,
1118
+ err ? /* @__PURE__ */ jsx("div", { className: "text-destructive/80 px-3 pt-1 pb-2 font-mono text-[10px]", children: err }) : null
1119
+ ] });
1120
+ }
1121
+ function SwitchRow({
1122
+ peer,
1123
+ busy,
1124
+ disabled,
1125
+ onSwitch
1126
+ }) {
1127
+ const label = peer.displayName ?? obscureIdentity(peer.displayIdentity.value);
1128
+ const kindLabel = IDENTITY_KIND_LABEL[peer.displayIdentity.kind];
1129
+ return /* @__PURE__ */ jsxs(
1130
+ "button",
1131
+ {
1132
+ type: "button",
1133
+ role: "menuitemradio",
1134
+ "aria-checked": false,
1135
+ "aria-label": `Switch to ${peer.didOc}`,
1136
+ disabled,
1137
+ onClick: onSwitch,
1138
+ "data-oc-account-menu-switch-row": "",
1139
+ className: "hover:bg-accent flex w-full items-center gap-2 px-3 py-2 text-left font-mono text-[11px] tracking-wide transition-colors disabled:cursor-default",
1140
+ children: [
1141
+ /* @__PURE__ */ jsx(
1142
+ "span",
1143
+ {
1144
+ className: "border-muted-foreground/40 flex size-3.5 shrink-0 items-center justify-center rounded-full border",
1145
+ "aria-hidden": true
1146
+ }
1147
+ ),
1148
+ /* @__PURE__ */ jsx("span", { className: "text-foreground/90 min-w-0 flex-1 truncate", children: label }),
1149
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50 w-14 shrink-0 text-right text-[9px] tracking-widest uppercase", children: busy ? /* @__PURE__ */ jsx(Loader2, { className: "ml-auto size-3 animate-spin" }) : kindLabel })
1150
+ ]
1151
+ }
1152
+ );
1153
+ }
1154
+ function PopoverSection({
1155
+ label,
1156
+ items,
1157
+ onItemClick,
1158
+ bordered
1159
+ }) {
1160
+ const cls = "hover:bg-accent flex items-center gap-2 px-3 py-2 font-mono text-[11px] tracking-wide transition-colors";
1161
+ return /* @__PURE__ */ jsxs(
1162
+ "div",
1163
+ {
1164
+ className: "p-1 " + (bordered ? "border-border border-t" : ""),
1165
+ "data-oc-account-menu-section": label,
1166
+ children: [
1167
+ /* @__PURE__ */ jsxs("div", { className: "text-muted-foreground/60 px-3 pt-2 pb-1 font-mono text-[10px] tracking-widest uppercase", children: [
1168
+ "\xA7 ",
1169
+ label
1170
+ ] }),
1171
+ items.map((item) => {
1172
+ const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
1173
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "aria-hidden": true, children: "\u2192" }),
1174
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children: item.label }),
1175
+ item.external ? /* @__PURE__ */ jsx(
1176
+ "span",
1177
+ {
1178
+ className: "text-muted-foreground/70 text-[10px]",
1179
+ "aria-hidden": true,
1180
+ children: "\u2197"
1181
+ }
1182
+ ) : null
1183
+ ] });
1184
+ return item.external ? /* @__PURE__ */ jsx(
1185
+ "a",
1186
+ {
1187
+ href: item.href,
1188
+ target: "_blank",
1189
+ rel: "noreferrer",
1190
+ onClick: onItemClick,
1191
+ role: "menuitem",
1192
+ className: cls,
1193
+ "data-oc-account-menu-item": "",
1194
+ children: inner
1195
+ },
1196
+ item.href
1197
+ ) : /* @__PURE__ */ jsx(
1198
+ Link5,
1199
+ {
1200
+ href: item.href,
1201
+ onClick: onItemClick,
1202
+ role: "menuitem",
1203
+ className: cls,
1204
+ "data-oc-account-menu-item": "",
1205
+ children: inner
1206
+ },
1207
+ item.href
1208
+ );
1209
+ })
1210
+ ]
1211
+ }
1212
+ );
1213
+ }
1214
+ function BuildFooter({
1215
+ hostname,
1216
+ build,
1217
+ state
1218
+ }) {
1219
+ const sha = build.sha;
1220
+ const showSha = !!sha && sha !== "dev";
1221
+ const commitUrl = showSha && build.repo ? `https://github.com/${build.repo}/commit/${sha}` : null;
1222
+ return /* @__PURE__ */ jsxs(
1223
+ "div",
1224
+ {
1225
+ className: "text-muted-foreground/60 border-border border-t px-3 py-2 font-mono text-[9.5px] tracking-widest uppercase",
1226
+ "data-oc-account-menu-build": "",
1227
+ children: [
1228
+ hostname,
1229
+ state && state !== "live" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1230
+ " \xB7 ",
1231
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/80", children: state })
1232
+ ] }) : null,
1233
+ " ",
1234
+ /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground/80", children: [
1235
+ "v",
1236
+ build.version,
1237
+ showSha ? /* @__PURE__ */ jsxs(Fragment, { children: [
1238
+ " \xB7 ",
1239
+ commitUrl ? /* @__PURE__ */ jsx(
1240
+ "a",
1241
+ {
1242
+ href: commitUrl,
1243
+ target: "_blank",
1244
+ rel: "noreferrer",
1245
+ className: "hover:text-foreground/90 underline decoration-dotted underline-offset-2",
1246
+ children: sha
1247
+ }
1248
+ ) : sha
1249
+ ] }) : null
1250
+ ] })
1251
+ ]
1252
+ }
1253
+ );
1254
+ }
1255
+ function isActive(pathname, link) {
1256
+ if (link.external) return false;
1257
+ if (link.matchExact) return pathname === link.href;
1258
+ if (link.href === "/") return pathname === "/";
1259
+ return pathname === link.href || pathname.startsWith(link.href + "/");
1260
+ }
1261
+ function OcPrimaryNav({ activePath, links, className }) {
1262
+ return /* @__PURE__ */ jsx(
1263
+ "nav",
1264
+ {
1265
+ "aria-label": "primary",
1266
+ className: "flex min-w-0 items-center justify-start overflow-x-auto gap-0.5 sm:gap-1 whitespace-nowrap [scrollbar-width:none] [&::-webkit-scrollbar]:hidden " + (className ?? ""),
1267
+ "data-oc-primary-nav": "",
1268
+ children: links.map((link) => {
1269
+ const active = isActive(activePath, link);
1270
+ const className2 = "font-display relative shrink-0 px-2 py-1 sm:px-3 text-[11px] sm:text-[12px] font-semibold tracking-wider uppercase transition-colors " + (active ? 'text-primary after:bg-primary after:absolute after:inset-x-2 after:-bottom-[13px] after:h-px after:content-[""]' : "text-muted-foreground hover:text-foreground");
1271
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
1272
+ link.label,
1273
+ link.external ? /* @__PURE__ */ jsx(
1274
+ "span",
1275
+ {
1276
+ "aria-hidden": true,
1277
+ className: "text-muted-foreground/60 ml-1 text-[9px]",
1278
+ children: "\u2197"
1279
+ }
1280
+ ) : null
1281
+ ] });
1282
+ return link.external ? /* @__PURE__ */ jsx(
1283
+ "a",
1284
+ {
1285
+ href: link.href,
1286
+ target: "_blank",
1287
+ rel: "noreferrer",
1288
+ className: className2,
1289
+ "data-oc-primary-nav-item": "",
1290
+ children: content
1291
+ },
1292
+ link.href
1293
+ ) : /* @__PURE__ */ jsx(
1294
+ Link5,
1295
+ {
1296
+ href: link.href,
1297
+ "aria-current": active ? "page" : void 0,
1298
+ className: className2,
1299
+ "data-oc-primary-nav-item": active ? "active" : "sibling",
1300
+ children: content
1301
+ },
1302
+ link.href
1303
+ );
1304
+ })
1305
+ }
1306
+ );
1307
+ }
1308
+ function OcDashboardShell({
1309
+ rootHref = "/dashboard",
1310
+ siteLabel,
1311
+ tools,
1312
+ active,
1313
+ eyebrow,
1314
+ title,
1315
+ description,
1316
+ children,
1317
+ className
1318
+ }) {
1319
+ const [drawerOpen, setDrawerOpen] = useState(false);
1320
+ useEffect(() => {
1321
+ if (!drawerOpen) return;
1322
+ function onKey(e) {
1323
+ if (e.key === "Escape") setDrawerOpen(false);
1324
+ }
1325
+ document.addEventListener("keydown", onKey);
1326
+ const prevOverflow = document.body.style.overflow;
1327
+ document.body.style.overflow = "hidden";
1328
+ return () => {
1329
+ document.removeEventListener("keydown", onKey);
1330
+ document.body.style.overflow = prevOverflow;
1331
+ };
1332
+ }, [drawerOpen]);
1333
+ const hasHeader = Boolean(title) || Boolean(eyebrow);
1334
+ return /* @__PURE__ */ jsxs(
1335
+ "div",
1336
+ {
1337
+ className: "container " + (className ?? ""),
1338
+ "data-oc-dashboard-shell": "",
1339
+ children: [
1340
+ /* @__PURE__ */ jsxs("div", { className: "flex min-h-[calc(100vh-3rem)] flex-col md:flex-row md:gap-8", children: [
1341
+ /* @__PURE__ */ jsx(
1342
+ Sidebar,
1343
+ {
1344
+ rootHref,
1345
+ siteLabel,
1346
+ tools,
1347
+ active,
1348
+ variant: "desktop"
1349
+ }
1350
+ ),
1351
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
1352
+ /* @__PURE__ */ jsxs("div", { className: "border-border flex items-center justify-between border-b py-3 md:hidden", children: [
1353
+ /* @__PURE__ */ jsxs(
1354
+ "button",
1355
+ {
1356
+ type: "button",
1357
+ onClick: () => setDrawerOpen(true),
1358
+ className: "text-muted-foreground hover:text-foreground inline-flex h-9 items-center gap-2 px-1 font-mono text-[11px] tracking-widest uppercase transition-colors",
1359
+ "aria-label": "open dashboard tools",
1360
+ "aria-expanded": drawerOpen,
1361
+ "data-oc-dashboard-mobile-trigger": "",
1362
+ children: [
1363
+ /* @__PURE__ */ jsx("span", { className: "text-[14px] leading-none", children: "\u2261" }),
1364
+ /* @__PURE__ */ jsx("span", { children: "tools" })
1365
+ ]
1366
+ }
1367
+ ),
1368
+ /* @__PURE__ */ jsx(
1369
+ Link5,
1370
+ {
1371
+ href: rootHref,
1372
+ className: "text-primary font-mono text-[11px] tracking-widest uppercase",
1373
+ children: "\xA7 dashboard"
1374
+ }
1375
+ )
1376
+ ] }),
1377
+ /* @__PURE__ */ jsxs("div", { className: "pt-6 md:pt-3", children: [
1378
+ hasHeader && /* @__PURE__ */ jsxs("div", { className: "max-w-3xl", children: [
1379
+ eyebrow ? /* @__PURE__ */ jsx("div", { className: "label-mono text-primary mb-3 font-mono text-[10px] tracking-widest uppercase", children: eyebrow }) : null,
1380
+ title ? /* @__PURE__ */ jsx("h1", { className: "font-display text-2xl font-bold tracking-tight sm:text-3xl", children: title }) : null,
1381
+ description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-3 max-w-[64ch] text-sm leading-relaxed", children: description }) : null
1382
+ ] }),
1383
+ /* @__PURE__ */ jsx("div", { className: hasHeader ? "mt-8 pb-12" : "pb-12", children })
1384
+ ] })
1385
+ ] })
1386
+ ] }),
1387
+ drawerOpen ? /* @__PURE__ */ jsxs(
1388
+ "div",
1389
+ {
1390
+ className: "fixed inset-0 z-50 md:hidden",
1391
+ role: "dialog",
1392
+ "aria-modal": "true",
1393
+ "aria-label": "dashboard tools",
1394
+ "data-oc-dashboard-drawer": "",
1395
+ children: [
1396
+ /* @__PURE__ */ jsx(
1397
+ "div",
1398
+ {
1399
+ className: "absolute inset-0 bg-background/80 backdrop-blur-sm",
1400
+ onClick: () => setDrawerOpen(false),
1401
+ "aria-hidden": true
1402
+ }
1403
+ ),
1404
+ /* @__PURE__ */ jsx("div", { className: "bg-background absolute top-0 left-0 h-full w-[85vw] max-w-sm border-r shadow-xl", children: /* @__PURE__ */ jsx(
1405
+ Sidebar,
1406
+ {
1407
+ rootHref,
1408
+ siteLabel,
1409
+ tools,
1410
+ active,
1411
+ variant: "drawer",
1412
+ onClose: () => setDrawerOpen(false)
1413
+ }
1414
+ ) })
1415
+ ]
1416
+ }
1417
+ ) : null
1418
+ ]
1419
+ }
1420
+ );
1421
+ }
1422
+ function Sidebar({
1423
+ rootHref,
1424
+ siteLabel,
1425
+ tools,
1426
+ active,
1427
+ variant,
1428
+ onClose
1429
+ }) {
1430
+ const isDrawer = variant === "drawer";
1431
+ return /* @__PURE__ */ jsxs(
1432
+ "aside",
1433
+ {
1434
+ className: isDrawer ? "flex h-full w-full flex-col bg-card" : "hidden md:sticky md:top-4 md:flex md:h-[calc(100vh-2rem)] md:w-56 md:shrink-0 md:flex-col md:self-start md:overflow-y-auto md:rounded md:border md:bg-card/40 lg:w-60",
1435
+ "aria-label": "dashboard tools",
1436
+ "data-oc-dashboard-sidebar": variant,
1437
+ children: [
1438
+ /* @__PURE__ */ jsxs("div", { className: "border-b px-4 py-3", children: [
1439
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1440
+ /* @__PURE__ */ jsx(
1441
+ Link5,
1442
+ {
1443
+ href: rootHref,
1444
+ onClick: onClose,
1445
+ className: "hover:text-foreground font-display text-sm font-bold tracking-tight",
1446
+ children: "\xA7 dashboard"
1447
+ }
1448
+ ),
1449
+ isDrawer ? /* @__PURE__ */ jsx(
1450
+ "button",
1451
+ {
1452
+ type: "button",
1453
+ onClick: onClose,
1454
+ className: "text-muted-foreground hover:text-foreground -mr-2 inline-flex h-8 w-8 items-center justify-center rounded font-mono text-lg",
1455
+ "aria-label": "close navigation",
1456
+ children: "\xD7"
1457
+ }
1458
+ ) : null
1459
+ ] }),
1460
+ siteLabel ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/70 mt-1 font-mono text-[10px] tracking-widest uppercase", children: siteLabel }) : null
1461
+ ] }),
1462
+ /* @__PURE__ */ jsxs("nav", { className: "flex-1 overflow-y-auto px-2 py-3", children: [
1463
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground/60 mb-1 px-3 font-mono text-[10px] tracking-widest uppercase", children: "\xA7 tools" }),
1464
+ /* @__PURE__ */ jsx("ul", { className: "space-y-0.5", children: tools.map((tool) => {
1465
+ const isActive2 = tool.id === active;
1466
+ const innerCls = "flex items-baseline gap-2 rounded px-3 py-1.5 text-[12.5px] transition-colors " + (isActive2 ? "bg-primary/10 text-primary font-semibold" : "text-muted-foreground hover:text-foreground hover:bg-muted/30");
1467
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
1468
+ tool.icon ? /* @__PURE__ */ jsx(
1469
+ "span",
1470
+ {
1471
+ className: "shrink-0 font-mono text-[11px] " + (isActive2 ? "text-primary" : "text-muted-foreground/70"),
1472
+ "aria-hidden": true,
1473
+ children: tool.icon
1474
+ }
1475
+ ) : null,
1476
+ /* @__PURE__ */ jsxs("span", { className: "flex-1 leading-tight", children: [
1477
+ /* @__PURE__ */ jsx("span", { children: tool.label }),
1478
+ tool.tagline ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/60 mt-0.5 block font-mono text-[10px] tracking-wide normal-case", children: tool.tagline }) : null
1479
+ ] }),
1480
+ tool.external ? /* @__PURE__ */ jsx(
1481
+ "span",
1482
+ {
1483
+ className: "text-muted-foreground/60 text-[10px]",
1484
+ "aria-hidden": true,
1485
+ children: "\u2197"
1486
+ }
1487
+ ) : null
1488
+ ] });
1489
+ return /* @__PURE__ */ jsx("li", { children: tool.external ? /* @__PURE__ */ jsx(
1490
+ "a",
1491
+ {
1492
+ href: tool.href,
1493
+ target: "_blank",
1494
+ rel: "noreferrer",
1495
+ onClick: onClose,
1496
+ className: innerCls,
1497
+ "data-oc-dashboard-tool": isActive2 ? "active" : "sibling",
1498
+ children: content
1499
+ }
1500
+ ) : /* @__PURE__ */ jsx(
1501
+ Link5,
1502
+ {
1503
+ href: tool.href,
1504
+ onClick: onClose,
1505
+ "aria-current": isActive2 ? "page" : void 0,
1506
+ className: innerCls,
1507
+ "data-oc-dashboard-tool": isActive2 ? "active" : "sibling",
1508
+ children: content
1509
+ }
1510
+ ) }, tool.id);
1511
+ }) })
1512
+ ] })
1513
+ ]
1514
+ }
1515
+ );
1516
+ }
1517
+ function OcDashboardHub({ tools, className }) {
1518
+ return /* @__PURE__ */ jsx(
1519
+ "ul",
1520
+ {
1521
+ className: "grid gap-px border-t border-l sm:grid-cols-2 " + (className ?? ""),
1522
+ "data-oc-dashboard-hub": "",
1523
+ children: tools.map((tool) => {
1524
+ const content = /* @__PURE__ */ jsxs("span", { className: "flex h-full flex-col gap-3 p-5 transition-colors", children: [
1525
+ /* @__PURE__ */ jsxs("span", { className: "flex items-baseline gap-3", children: [
1526
+ tool.icon ? /* @__PURE__ */ jsx(
1527
+ "span",
1528
+ {
1529
+ className: "text-primary font-mono text-[13px]",
1530
+ "aria-hidden": true,
1531
+ children: tool.icon
1532
+ }
1533
+ ) : null,
1534
+ /* @__PURE__ */ jsx("span", { className: "font-display text-foreground text-base font-bold tracking-tight", children: tool.label }),
1535
+ tool.external ? /* @__PURE__ */ jsx(
1536
+ "span",
1537
+ {
1538
+ className: "text-muted-foreground/60 ml-auto text-xs",
1539
+ "aria-hidden": true,
1540
+ children: "\u2197"
1541
+ }
1542
+ ) : /* @__PURE__ */ jsx(
1543
+ "span",
1544
+ {
1545
+ className: "text-muted-foreground/60 ml-auto text-xs",
1546
+ "aria-hidden": true,
1547
+ children: "\u2192"
1548
+ }
1549
+ )
1550
+ ] }),
1551
+ tool.tagline ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-sm leading-relaxed", children: tool.tagline }) : null
1552
+ ] });
1553
+ const cls = "hover:bg-muted/30 group block border-r border-b transition-colors";
1554
+ return /* @__PURE__ */ jsx("li", { children: tool.external ? /* @__PURE__ */ jsx(
1555
+ "a",
1556
+ {
1557
+ href: tool.href,
1558
+ target: "_blank",
1559
+ rel: "noreferrer",
1560
+ className: cls,
1561
+ children: content
1562
+ }
1563
+ ) : /* @__PURE__ */ jsx(Link5, { href: tool.href, className: cls, children: content }) }, tool.id);
1564
+ })
1565
+ }
1566
+ );
1567
+ }
1568
+ function AppShell({
1569
+ eyebrow,
1570
+ title,
1571
+ description,
1572
+ headerActions,
1573
+ children,
1574
+ className
1575
+ }) {
1576
+ const hasHeader = Boolean(title);
1577
+ return /* @__PURE__ */ jsx("div", { className: "container " + (className ?? ""), children: /* @__PURE__ */ jsx("div", { className: "flex min-h-[calc(100vh-3rem)] flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "pt-6 md:pt-8", children: [
1578
+ hasHeader && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between", children: [
1579
+ /* @__PURE__ */ jsxs("div", { className: "max-w-3xl", children: [
1580
+ eyebrow && /* @__PURE__ */ jsx("div", { className: "label-mono text-primary mb-3", children: eyebrow }),
1581
+ /* @__PURE__ */ jsx("h1", { className: "font-display text-2xl font-bold tracking-tight sm:text-3xl", children: title }),
1582
+ description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-3 max-w-[64ch] text-sm leading-relaxed", children: description })
1583
+ ] }),
1584
+ headerActions && /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: headerActions })
1585
+ ] }),
1586
+ /* @__PURE__ */ jsx("div", { className: hasHeader ? "mt-8 pb-12" : "pb-12", children })
1587
+ ] }) }) }) });
1588
+ }
1589
+ function cn(...inputs) {
1590
+ return twMerge(clsx(inputs));
1591
+ }
1592
+ var HIDE = {
1593
+ sm: "hidden sm:inline",
1594
+ md: "hidden md:inline",
1595
+ lg: "hidden lg:inline"
1596
+ };
1597
+ function LayoutSubHeader({
1598
+ product,
1599
+ status = "live \xB7 mainnet",
1600
+ tags = [],
1601
+ noHeartbeat = false,
1602
+ className
1603
+ }) {
1604
+ return /* @__PURE__ */ jsx("div", { className: cn("border-b", className), children: /* @__PURE__ */ jsxs("div", { className: "container flex flex-wrap items-center justify-between gap-x-6 gap-y-1 py-2 font-mono text-[11px]", children: [
1605
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1606
+ !noHeartbeat && /* @__PURE__ */ jsx("span", { className: "bg-primary inline-block h-1.5 w-1.5 animate-pulse rounded-full" }),
1607
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tracking-widest uppercase", children: status }),
1608
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: product })
1609
+ ] }),
1610
+ tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 tracking-widest uppercase", children: tags.map((tag, i) => /* @__PURE__ */ jsx("span", { className: tag.hideBelow ? HIDE[tag.hideBelow] : void 0, children: tag.label }, i)) })
1611
+ ] }) });
1612
+ }
1613
+
1614
+ export { AppShell, EcosystemSwitcher, FAMILY_PROPERTIES, LayoutSubHeader, OcAccountMenu, OcAccountMenuView, OcDashboardHub, OcDashboardShell, OcLogoDropdown, OcPrimaryNav, SITE_STATE_LABEL, findFamilyProperty };
1615
+ //# sourceMappingURL=chrome.mjs.map
1616
+ //# sourceMappingURL=chrome.mjs.map