@nimblebrain/synapse 0.8.0 → 0.10.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.
@@ -0,0 +1,1451 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+
6
+ // src/ui/components/Avatar.tsx
7
+
8
+ // src/ui/tokens.ts
9
+ var tokens = {
10
+ // ── Surfaces ──
11
+ bg: "var(--color-background-primary, #ffffff)",
12
+ bgRaised: "var(--color-background-secondary, #fafafa)",
13
+ bgSubtle: "var(--color-background-tertiary, #f3f4f6)",
14
+ // ── Text ──
15
+ fg: "var(--color-text-primary, #111827)",
16
+ fgMuted: "var(--color-text-secondary, #6b7280)",
17
+ fgFaint: "var(--color-text-tertiary, #9ca3af)",
18
+ accent: "var(--color-text-accent, #2563eb)",
19
+ accentFg: "var(--nb-color-accent-foreground, #ffffff)",
20
+ // ── Border / ring ──
21
+ border: "var(--color-border-primary, #e5e7eb)",
22
+ borderStrong: "var(--color-border-secondary, #d1d5db)",
23
+ ring: "var(--color-ring-primary, #2563eb)",
24
+ // ── Status / brand semantics ──
25
+ danger: "var(--nb-color-danger, #dc2626)",
26
+ success: "var(--nb-color-success, #059669)",
27
+ warning: "var(--nb-color-warning, #f59e0b)",
28
+ warm: "var(--nb-color-warm, #d4620a)",
29
+ warmLight: "var(--nb-color-warm-light, #fef5ee)",
30
+ processing: "var(--nb-color-processing, #7c3aed)",
31
+ processingLight: "var(--nb-color-processing-light, #f3eeff)",
32
+ infoLight: "var(--nb-color-info-light, #eef4ff)",
33
+ // ── Typography ──
34
+ fontSans: "var(--font-sans, system-ui, -apple-system, BlinkMacSystemFont, sans-serif)",
35
+ fontMono: "var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)",
36
+ fontHeading: "var(--nb-font-heading, Georgia, 'Times New Roman', serif)",
37
+ weightNormal: "var(--font-weight-normal, 400)",
38
+ weightMedium: "var(--font-weight-medium, 500)",
39
+ weightSemibold: "var(--font-weight-semibold, 600)",
40
+ weightBold: "var(--font-weight-bold, 700)",
41
+ // ── Type scale (size + line-height pairs) ──
42
+ textXsSize: "var(--font-text-xs-size, 0.75rem)",
43
+ textXsLine: "var(--font-text-xs-line-height, 1rem)",
44
+ textSmSize: "var(--font-text-sm-size, 0.875rem)",
45
+ textSmLine: "var(--font-text-sm-line-height, 1.25rem)",
46
+ textBaseSize: "var(--font-text-base-size, 1rem)",
47
+ textBaseLine: "var(--font-text-base-line-height, 1.5rem)",
48
+ textLgSize: "var(--font-text-lg-size, 1.125rem)",
49
+ textLgLine: "var(--font-text-lg-line-height, 1.75rem)",
50
+ headingSmSize: "var(--font-heading-sm-size, 1.25rem)",
51
+ headingSmLine: "var(--font-heading-sm-line-height, 1.75rem)",
52
+ headingMdSize: "var(--font-heading-md-size, 1.5rem)",
53
+ headingMdLine: "var(--font-heading-md-line-height, 2rem)",
54
+ headingLgSize: "var(--font-heading-lg-size, 2rem)",
55
+ headingLgLine: "var(--font-heading-lg-line-height, 2.5rem)",
56
+ // ── Radius / border width ──
57
+ radiusXs: "var(--border-radius-xs, 0.25rem)",
58
+ radiusSm: "var(--border-radius-sm, 0.5rem)",
59
+ radiusMd: "var(--border-radius-md, 0.75rem)",
60
+ radiusLg: "var(--border-radius-lg, 1rem)",
61
+ radiusXl: "var(--border-radius-xl, 1.5rem)",
62
+ borderWidth: "var(--border-width-regular, 1px)",
63
+ // ── Shadows ──
64
+ shadowHairline: "var(--shadow-hairline, 0 0 0 1px rgba(0,0,0,0.06))",
65
+ shadowSm: "var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05))",
66
+ shadowMd: "var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,0.1))",
67
+ shadowLg: "var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.1))"
68
+ };
69
+ var TEXT_SCALE = {
70
+ xs: { fontSize: tokens.textXsSize, lineHeight: tokens.textXsLine },
71
+ sm: { fontSize: tokens.textSmSize, lineHeight: tokens.textSmLine },
72
+ base: { fontSize: tokens.textBaseSize, lineHeight: tokens.textBaseLine },
73
+ lg: { fontSize: tokens.textLgSize, lineHeight: tokens.textLgLine }
74
+ };
75
+ var HEADING_SCALE = {
76
+ sm: { fontSize: tokens.headingSmSize, lineHeight: tokens.headingSmLine },
77
+ md: { fontSize: tokens.headingMdSize, lineHeight: tokens.headingMdLine },
78
+ lg: { fontSize: tokens.headingLgSize, lineHeight: tokens.headingLgLine }
79
+ };
80
+ function textStyle(size) {
81
+ return TEXT_SCALE[size];
82
+ }
83
+ function headingStyle(size) {
84
+ return HEADING_SCALE[size];
85
+ }
86
+ function initialsOf(name) {
87
+ const parts = name.trim().split(/\s+/).filter(Boolean);
88
+ if (parts.length === 0) return "?";
89
+ const first = parts[0] ?? "";
90
+ if (parts.length === 1) return first.charAt(0).toUpperCase();
91
+ const last = parts[parts.length - 1] ?? "";
92
+ return (first.charAt(0) + last.charAt(0)).toUpperCase();
93
+ }
94
+ function Avatar({ name, src, size = 28, style, ...rest }) {
95
+ const [failed, setFailed] = react.useState(false);
96
+ react.useEffect(() => setFailed(false), [src]);
97
+ const showImage = Boolean(src) && !failed;
98
+ return /* @__PURE__ */ jsxRuntime.jsx(
99
+ "span",
100
+ {
101
+ style: {
102
+ display: "inline-flex",
103
+ alignItems: "center",
104
+ justifyContent: "center",
105
+ flexShrink: 0,
106
+ width: size,
107
+ height: size,
108
+ borderRadius: "50%",
109
+ overflow: "hidden",
110
+ background: tokens.bgSubtle,
111
+ color: tokens.fgMuted,
112
+ fontFamily: tokens.fontSans,
113
+ fontSize: Math.round(size * 0.4),
114
+ fontWeight: tokens.weightSemibold,
115
+ userSelect: "none",
116
+ ...style
117
+ },
118
+ ...rest,
119
+ children: showImage ? /* @__PURE__ */ jsxRuntime.jsx(
120
+ "img",
121
+ {
122
+ src,
123
+ alt: name,
124
+ width: size,
125
+ height: size,
126
+ onError: () => setFailed(true),
127
+ style: { width: "100%", height: "100%", objectFit: "cover" }
128
+ }
129
+ ) : initialsOf(name)
130
+ }
131
+ );
132
+ }
133
+ var TONE = {
134
+ neutral: { bg: tokens.bgSubtle, fg: tokens.fgMuted },
135
+ accent: { bg: tokens.infoLight, fg: tokens.accent },
136
+ success: { bg: `color-mix(in oklab, ${tokens.success} 14%, transparent)`, fg: tokens.success },
137
+ warning: { bg: `color-mix(in oklab, ${tokens.warning} 14%, transparent)`, fg: tokens.warning },
138
+ danger: { bg: `color-mix(in oklab, ${tokens.danger} 14%, transparent)`, fg: tokens.danger },
139
+ processing: { bg: tokens.processingLight, fg: tokens.processing },
140
+ warm: { bg: tokens.warmLight, fg: tokens.warm }
141
+ };
142
+ function Badge({ tone = "neutral", style, children, ...rest }) {
143
+ const { bg, fg } = TONE[tone];
144
+ return /* @__PURE__ */ jsxRuntime.jsx(
145
+ "span",
146
+ {
147
+ style: {
148
+ display: "inline-flex",
149
+ alignItems: "center",
150
+ gap: "0.25rem",
151
+ padding: "0.1rem 0.45rem",
152
+ borderRadius: tokens.radiusXs,
153
+ background: bg,
154
+ color: fg,
155
+ fontFamily: tokens.fontSans,
156
+ fontSize: tokens.textXsSize,
157
+ lineHeight: tokens.textXsLine,
158
+ fontWeight: tokens.weightSemibold,
159
+ letterSpacing: "0.02em",
160
+ textTransform: "uppercase",
161
+ whiteSpace: "nowrap",
162
+ ...style
163
+ },
164
+ ...rest,
165
+ children
166
+ }
167
+ );
168
+ }
169
+
170
+ // src/ui/internal/inject-style.ts
171
+ function ensureStyle(id, css) {
172
+ if (typeof document === "undefined") return;
173
+ if (document.getElementById(id)) return;
174
+ const style = document.createElement("style");
175
+ style.id = id;
176
+ style.textContent = css;
177
+ document.head.appendChild(style);
178
+ }
179
+ var STYLE_ID = "nb-synapse-button";
180
+ var RULES = `
181
+ .nb-btn {
182
+ --nb-btn-bg: transparent;
183
+ --nb-btn-bg-hover: transparent;
184
+ display: inline-flex;
185
+ align-items: center;
186
+ justify-content: center;
187
+ gap: 0.4rem;
188
+ border: var(--nb-btn-border, none);
189
+ border-radius: var(--nb-btn-radius);
190
+ background: var(--nb-btn-bg);
191
+ color: var(--nb-btn-fg);
192
+ font-family: var(--nb-btn-font);
193
+ font-weight: var(--nb-btn-weight);
194
+ cursor: pointer;
195
+ transition: background 130ms ease, color 130ms ease, opacity 130ms ease;
196
+ white-space: nowrap;
197
+ }
198
+ .nb-btn:hover { background: var(--nb-btn-bg-hover); }
199
+ .nb-btn:active { transform: translateY(0.5px); }
200
+ .nb-btn:disabled { opacity: 0.5; cursor: default; }
201
+ .nb-btn:disabled:hover { background: var(--nb-btn-bg); }
202
+ .nb-textlink {
203
+ border: none;
204
+ background: none;
205
+ padding: 0;
206
+ cursor: pointer;
207
+ font-family: var(--nb-tl-font);
208
+ color: var(--nb-tl-fg);
209
+ transition: color 130ms ease, opacity 130ms ease;
210
+ }
211
+ .nb-textlink:hover { color: var(--nb-tl-fg-hover); }
212
+ .nb-textlink:disabled { opacity: 0.45; cursor: default; }
213
+ `;
214
+ var SIZE_PAD = {
215
+ sm: "0.3rem 0.6rem",
216
+ md: "0.45rem 0.85rem"
217
+ };
218
+ function Button({
219
+ variant = "primary",
220
+ size = "md",
221
+ style,
222
+ className,
223
+ children,
224
+ ...rest
225
+ }) {
226
+ ensureStyle(STYLE_ID, RULES);
227
+ const vars = {
228
+ "--nb-btn-radius": tokens.radiusSm,
229
+ "--nb-btn-font": tokens.fontSans,
230
+ "--nb-btn-weight": tokens.weightMedium
231
+ };
232
+ if (variant === "primary") {
233
+ vars["--nb-btn-bg"] = tokens.accent;
234
+ vars["--nb-btn-bg-hover"] = `color-mix(in oklab, ${tokens.accent} 88%, black)`;
235
+ vars["--nb-btn-fg"] = tokens.accentFg;
236
+ } else if (variant === "secondary") {
237
+ vars["--nb-btn-bg"] = tokens.bgSubtle;
238
+ vars["--nb-btn-bg-hover"] = tokens.bgRaised;
239
+ vars["--nb-btn-fg"] = tokens.fg;
240
+ vars["--nb-btn-border"] = `${tokens.borderWidth} solid ${tokens.border}`;
241
+ } else {
242
+ vars["--nb-btn-bg"] = "transparent";
243
+ vars["--nb-btn-bg-hover"] = tokens.bgSubtle;
244
+ vars["--nb-btn-fg"] = tokens.fg;
245
+ }
246
+ const btnStyle = {
247
+ ...vars,
248
+ padding: SIZE_PAD[size],
249
+ fontSize: size === "sm" ? tokens.textSmSize : tokens.textBaseSize,
250
+ lineHeight: size === "sm" ? tokens.textSmLine : tokens.textBaseLine,
251
+ ...style
252
+ };
253
+ return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: `nb-btn ${className ?? ""}`.trim(), style: btnStyle, ...rest, children });
254
+ }
255
+ function TextLink({ tone = "muted", style, className, children, ...rest }) {
256
+ ensureStyle(STYLE_ID, RULES);
257
+ const resting = tone === "danger" ? tokens.danger : tone === "default" ? tokens.fg : tokens.fgMuted;
258
+ const hover = tone === "danger" ? tokens.danger : tokens.accent;
259
+ const linkStyle = {
260
+ "--nb-tl-font": tokens.fontSans,
261
+ "--nb-tl-fg": resting,
262
+ "--nb-tl-fg-hover": hover,
263
+ fontSize: tokens.textXsSize,
264
+ lineHeight: tokens.textXsLine,
265
+ letterSpacing: "0.02em",
266
+ ...style
267
+ };
268
+ return /* @__PURE__ */ jsxRuntime.jsx(
269
+ "button",
270
+ {
271
+ type: "button",
272
+ className: `nb-textlink ${className ?? ""}`.trim(),
273
+ style: linkStyle,
274
+ ...rest,
275
+ children
276
+ }
277
+ );
278
+ }
279
+ var STYLE_ID2 = "nb-synapse-card";
280
+ var RULES2 = `
281
+ .nb-card--interactive {
282
+ cursor: pointer;
283
+ transition: box-shadow 140ms ease, border-color 140ms ease;
284
+ }
285
+ .nb-card--interactive:hover {
286
+ box-shadow: var(--nb-card-shadow-hover);
287
+ border-color: var(--nb-card-border-hover);
288
+ }
289
+ `;
290
+ function Card({
291
+ padding = "0.875rem",
292
+ interactive = false,
293
+ style,
294
+ className,
295
+ children,
296
+ ...rest
297
+ }) {
298
+ if (interactive) ensureStyle(STYLE_ID2, RULES2);
299
+ const cardStyle = {
300
+ background: tokens.bgRaised,
301
+ border: `${tokens.borderWidth} solid ${tokens.border}`,
302
+ borderRadius: tokens.radiusMd,
303
+ padding,
304
+ boxShadow: tokens.shadowSm,
305
+ "--nb-card-shadow-hover": tokens.shadowMd,
306
+ "--nb-card-border-hover": tokens.borderStrong,
307
+ ...style
308
+ };
309
+ return /* @__PURE__ */ jsxRuntime.jsx(
310
+ "div",
311
+ {
312
+ className: interactive ? `nb-card--interactive ${className ?? ""}`.trim() : className,
313
+ style: cardStyle,
314
+ ...rest,
315
+ children
316
+ }
317
+ );
318
+ }
319
+ var STYLE_ID3 = "nb-synapse-drawer";
320
+ var RULES3 = `
321
+ .nb-drawer {
322
+ margin: 0; padding: 0; border: none; max-width: 92%;
323
+ height: 100%; max-height: 100%; display: flex; flex-direction: column;
324
+ }
325
+ .nb-drawer--right { margin-left: auto; }
326
+ .nb-drawer--left { margin-right: auto; }
327
+ .nb-drawer--bottom {
328
+ margin-top: auto; width: 100%; max-width: 100%;
329
+ height: auto; max-height: 92%;
330
+ }
331
+ .nb-drawer--right[open] { animation: nb-drawer-in-right 240ms cubic-bezier(0.2, 0, 0, 1); }
332
+ .nb-drawer--left[open] { animation: nb-drawer-in-left 240ms cubic-bezier(0.2, 0, 0, 1); }
333
+ .nb-drawer--bottom[open] { animation: nb-drawer-in-bottom 240ms cubic-bezier(0.2, 0, 0, 1); }
334
+ .nb-drawer::backdrop { background: rgba(0, 0, 0, 0.32); }
335
+ .nb-drawer[open]::backdrop { animation: nb-drawer-fade 200ms ease; }
336
+ @keyframes nb-drawer-in-right { from { transform: translateX(100%); } }
337
+ @keyframes nb-drawer-in-left { from { transform: translateX(-100%); } }
338
+ @keyframes nb-drawer-in-bottom { from { transform: translateY(100%); } }
339
+ @keyframes nb-drawer-fade { from { opacity: 0; } }
340
+ .nb-drawer-iconbtn { width: 28px; height: 28px; }
341
+ @media (pointer: coarse) {
342
+ .nb-drawer-iconbtn { min-width: 44px; min-height: 44px; }
343
+ }
344
+ `;
345
+ var DrawerContext = react.createContext(null);
346
+ function DrawerRoot({
347
+ open,
348
+ onClose,
349
+ onEscape,
350
+ side = "right",
351
+ width = 480,
352
+ style,
353
+ children,
354
+ ...rest
355
+ }) {
356
+ ensureStyle(STYLE_ID3, RULES3);
357
+ const dialogRef = react.useRef(null);
358
+ const labelId = react.useId();
359
+ const [hasTitle, setHasTitle] = react.useState(false);
360
+ react.useEffect(() => {
361
+ const dialog = dialogRef.current;
362
+ if (!dialog || typeof dialog.showModal !== "function") return;
363
+ if (open && !dialog.open) dialog.showModal();
364
+ else if (!open && dialog.open) dialog.close();
365
+ }, [open]);
366
+ const isBottom = side === "bottom";
367
+ const panelStyle = {
368
+ ...isBottom ? { width: "100%", maxWidth: "100%" } : { width },
369
+ background: tokens.bg,
370
+ color: tokens.fg,
371
+ boxShadow: tokens.shadowLg,
372
+ ...side === "right" ? { borderLeft: `${tokens.borderWidth} solid ${tokens.border}` } : side === "left" ? { borderRight: `${tokens.borderWidth} solid ${tokens.border}` } : { borderTop: `${tokens.borderWidth} solid ${tokens.border}` },
373
+ ...style
374
+ };
375
+ const ctxValue = react.useMemo(() => ({ labelId, setHasTitle }), [labelId]);
376
+ return /* @__PURE__ */ jsxRuntime.jsx(DrawerContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxRuntime.jsx(
377
+ "dialog",
378
+ {
379
+ ref: dialogRef,
380
+ className: `nb-drawer nb-drawer--${side}`,
381
+ style: panelStyle,
382
+ "aria-labelledby": hasTitle ? labelId : void 0,
383
+ onCancel: (e) => {
384
+ e.preventDefault();
385
+ (onEscape ?? onClose)();
386
+ },
387
+ onClick: (e) => {
388
+ if (e.target === dialogRef.current) onClose();
389
+ },
390
+ ...rest,
391
+ children
392
+ }
393
+ ) });
394
+ }
395
+ function Header({ title, onBack, actions, onClose, style, children, ...rest }) {
396
+ const ctx = react.useContext(DrawerContext);
397
+ const hasTitle = title != null;
398
+ react.useEffect(() => {
399
+ if (!ctx || !hasTitle) return;
400
+ ctx.setHasTitle(true);
401
+ return () => ctx.setHasTitle(false);
402
+ }, [ctx, hasTitle]);
403
+ return /* @__PURE__ */ jsxRuntime.jsxs(
404
+ "header",
405
+ {
406
+ style: {
407
+ flexShrink: 0,
408
+ display: "flex",
409
+ alignItems: "center",
410
+ gap: "0.75rem",
411
+ padding: "0.875rem 1rem",
412
+ borderBottom: `${tokens.borderWidth} solid ${tokens.border}`,
413
+ fontFamily: tokens.fontSans,
414
+ fontWeight: tokens.weightSemibold,
415
+ color: tokens.fg,
416
+ ...style
417
+ },
418
+ ...rest,
419
+ children: [
420
+ onBack ? /* @__PURE__ */ jsxRuntime.jsx(IconButton, { label: "Back", onClick: onBack, children: /* @__PURE__ */ jsxRuntime.jsx(
421
+ "path",
422
+ {
423
+ d: "M10 3L5 8l5 5",
424
+ stroke: "currentColor",
425
+ strokeWidth: "1.5",
426
+ fill: "none",
427
+ strokeLinecap: "round",
428
+ strokeLinejoin: "round"
429
+ }
430
+ ) }) : null,
431
+ hasTitle ? /* @__PURE__ */ jsxRuntime.jsx(
432
+ "h2",
433
+ {
434
+ id: ctx?.labelId,
435
+ style: {
436
+ flex: 1,
437
+ minWidth: 0,
438
+ margin: 0,
439
+ fontFamily: tokens.fontSans,
440
+ fontSize: tokens.textBaseSize,
441
+ lineHeight: tokens.textBaseLine,
442
+ fontWeight: tokens.weightSemibold,
443
+ color: tokens.fg,
444
+ whiteSpace: "nowrap",
445
+ overflow: "hidden",
446
+ textOverflow: "ellipsis"
447
+ },
448
+ children: title
449
+ }
450
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minWidth: 0 }, children }),
451
+ actions ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", gap: "0.4rem", flexShrink: 0 }, children: actions }) : null,
452
+ onClose ? /* @__PURE__ */ jsxRuntime.jsx(IconButton, { label: "Close", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
453
+ "path",
454
+ {
455
+ d: "M4 4l8 8M12 4l-8 8",
456
+ stroke: "currentColor",
457
+ strokeWidth: "1.5",
458
+ strokeLinecap: "round"
459
+ }
460
+ ) }) : null
461
+ ]
462
+ }
463
+ );
464
+ }
465
+ function IconButton({
466
+ label,
467
+ onClick,
468
+ children
469
+ }) {
470
+ return /* @__PURE__ */ jsxRuntime.jsx(
471
+ "button",
472
+ {
473
+ type: "button",
474
+ "aria-label": label,
475
+ onClick,
476
+ className: "nb-drawer-iconbtn",
477
+ style: {
478
+ flexShrink: 0,
479
+ display: "inline-flex",
480
+ alignItems: "center",
481
+ justifyContent: "center",
482
+ border: "none",
483
+ background: "transparent",
484
+ color: tokens.fgMuted,
485
+ cursor: "pointer",
486
+ borderRadius: tokens.radiusSm
487
+ },
488
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": "true", children })
489
+ }
490
+ );
491
+ }
492
+ function Body({ style, children, ...rest }) {
493
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", padding: "1rem", ...style }, ...rest, children });
494
+ }
495
+ function Footer({ style, children, ...rest }) {
496
+ return /* @__PURE__ */ jsxRuntime.jsx(
497
+ "footer",
498
+ {
499
+ style: {
500
+ flexShrink: 0,
501
+ padding: "0.75rem 1rem",
502
+ borderTop: `${tokens.borderWidth} solid ${tokens.border}`,
503
+ ...style
504
+ },
505
+ ...rest,
506
+ children
507
+ }
508
+ );
509
+ }
510
+ var Drawer = Object.assign(DrawerRoot, { Header, Body, Footer });
511
+ var ALIGN = {
512
+ start: "flex-start",
513
+ center: "center",
514
+ end: "flex-end",
515
+ stretch: "stretch",
516
+ baseline: "baseline"
517
+ };
518
+ var JUSTIFY = {
519
+ start: "flex-start",
520
+ center: "center",
521
+ end: "flex-end",
522
+ between: "space-between",
523
+ around: "space-around"
524
+ };
525
+ function flexStyle(direction, { gap, align, justify, wrap }) {
526
+ return {
527
+ display: "flex",
528
+ flexDirection: direction,
529
+ gap,
530
+ alignItems: align ? ALIGN[align] : void 0,
531
+ justifyContent: justify ? JUSTIFY[justify] : void 0,
532
+ flexWrap: wrap ? "wrap" : void 0
533
+ };
534
+ }
535
+ function Stack({ gap, align, justify, wrap, style, children, ...rest }) {
536
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...flexStyle("column", { gap, align, justify, wrap }), ...style }, ...rest, children });
537
+ }
538
+ function Inline({
539
+ gap,
540
+ align = "center",
541
+ justify,
542
+ wrap,
543
+ style,
544
+ children,
545
+ ...rest
546
+ }) {
547
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...flexStyle("row", { gap, align, justify, wrap }), ...style }, ...rest, children });
548
+ }
549
+ function Spacer({ style, ...rest }) {
550
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, ...style }, ...rest });
551
+ }
552
+ function Divider({ orientation = "horizontal", style, ...rest }) {
553
+ const isVertical = orientation === "vertical";
554
+ return /* @__PURE__ */ jsxRuntime.jsx(
555
+ "div",
556
+ {
557
+ "aria-hidden": "true",
558
+ style: {
559
+ flexShrink: 0,
560
+ background: tokens.border,
561
+ ...isVertical ? { width: tokens.borderWidth, alignSelf: "stretch" } : { height: tokens.borderWidth, width: "100%" },
562
+ ...style
563
+ },
564
+ ...rest
565
+ }
566
+ );
567
+ }
568
+ var TONE2 = {
569
+ default: tokens.fg,
570
+ muted: tokens.fgMuted,
571
+ faint: tokens.fgFaint,
572
+ accent: tokens.accent,
573
+ danger: tokens.danger,
574
+ success: tokens.success
575
+ };
576
+ var WEIGHT = {
577
+ normal: tokens.weightNormal,
578
+ medium: tokens.weightMedium,
579
+ semibold: tokens.weightSemibold,
580
+ bold: tokens.weightBold
581
+ };
582
+ function Text({
583
+ size = "base",
584
+ weight = "normal",
585
+ tone = "default",
586
+ mono = false,
587
+ truncate = false,
588
+ as: As = "span",
589
+ style,
590
+ children,
591
+ ...rest
592
+ }) {
593
+ const truncation = truncate ? { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } : {};
594
+ return /* @__PURE__ */ jsxRuntime.jsx(
595
+ As,
596
+ {
597
+ style: {
598
+ margin: 0,
599
+ fontFamily: mono ? tokens.fontMono : tokens.fontSans,
600
+ fontWeight: WEIGHT[weight],
601
+ color: TONE2[tone],
602
+ ...textStyle(size),
603
+ ...truncation,
604
+ ...style
605
+ },
606
+ ...rest,
607
+ children
608
+ }
609
+ );
610
+ }
611
+ function Heading({
612
+ size = "md",
613
+ weight = "semibold",
614
+ tone = "default",
615
+ as: As = "h2",
616
+ style,
617
+ children,
618
+ ...rest
619
+ }) {
620
+ return /* @__PURE__ */ jsxRuntime.jsx(
621
+ As,
622
+ {
623
+ style: {
624
+ margin: 0,
625
+ fontFamily: tokens.fontHeading,
626
+ fontWeight: WEIGHT[weight],
627
+ color: TONE2[tone],
628
+ letterSpacing: "-0.015em",
629
+ ...headingStyle(size),
630
+ ...style
631
+ },
632
+ ...rest,
633
+ children
634
+ }
635
+ );
636
+ }
637
+ function EmptyState({ icon, title, description, action, style, ...rest }) {
638
+ return /* @__PURE__ */ jsxRuntime.jsxs(
639
+ Stack,
640
+ {
641
+ align: "center",
642
+ gap: "0.5rem",
643
+ style: {
644
+ textAlign: "center",
645
+ padding: "4rem 1.5rem",
646
+ color: tokens.fgMuted,
647
+ ...style
648
+ },
649
+ ...rest,
650
+ children: [
651
+ icon ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: tokens.fgFaint, marginBottom: "0.25rem" }, children: icon }) : null,
652
+ title ? /* @__PURE__ */ jsxRuntime.jsx(Heading, { size: "sm", children: title }) : null,
653
+ description ? /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "sm", tone: "muted", style: { maxWidth: 360 }, children: description }) : null,
654
+ action ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "0.75rem" }, children: action }) : null
655
+ ]
656
+ }
657
+ );
658
+ }
659
+ var STYLE_ID4 = "nb-synapse-listrow";
660
+ var RULES4 = `
661
+ .nb-listrow { transition: background 140ms ease; }
662
+ .nb-listrow--interactive { cursor: pointer; }
663
+ .nb-listrow--interactive:hover { background: var(--nb-listrow-hover); }
664
+ `;
665
+ function ListRow({
666
+ title,
667
+ meta,
668
+ leading,
669
+ trailing,
670
+ interactive = false,
671
+ style,
672
+ className,
673
+ ...rest
674
+ }) {
675
+ ensureStyle(STYLE_ID4, RULES4);
676
+ const rowStyle = {
677
+ "--nb-listrow-hover": tokens.bgSubtle,
678
+ display: "grid",
679
+ gridTemplateColumns: `${leading ? "auto " : ""}minmax(0, 1fr)${trailing ? " auto" : ""}`,
680
+ columnGap: "0.75rem",
681
+ alignItems: "baseline",
682
+ padding: "0.65rem 0.75rem",
683
+ borderRadius: tokens.radiusSm,
684
+ ...style
685
+ };
686
+ const interactiveProps = interactive ? {
687
+ role: "button",
688
+ tabIndex: 0,
689
+ onKeyDown: (e) => {
690
+ if (e.key === "Enter" || e.key === " ") {
691
+ e.preventDefault();
692
+ e.currentTarget.click();
693
+ }
694
+ }
695
+ } : {};
696
+ return /* @__PURE__ */ jsxRuntime.jsxs(
697
+ "div",
698
+ {
699
+ className: `nb-listrow ${interactive ? "nb-listrow--interactive" : ""} ${className ?? ""}`.trim(),
700
+ style: rowStyle,
701
+ ...interactiveProps,
702
+ ...rest,
703
+ children: [
704
+ leading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { alignSelf: "center", display: "flex" }, children: leading }) : null,
705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { minWidth: 0 }, children: [
706
+ /* @__PURE__ */ jsxRuntime.jsx(
707
+ "div",
708
+ {
709
+ style: {
710
+ fontFamily: tokens.fontSans,
711
+ fontSize: tokens.textBaseSize,
712
+ lineHeight: tokens.textBaseLine,
713
+ fontWeight: tokens.weightMedium,
714
+ color: tokens.fg,
715
+ overflow: "hidden",
716
+ textOverflow: "ellipsis",
717
+ whiteSpace: "nowrap"
718
+ },
719
+ children: title
720
+ }
721
+ ),
722
+ meta ? /* @__PURE__ */ jsxRuntime.jsx(
723
+ "div",
724
+ {
725
+ style: {
726
+ marginTop: "0.15rem",
727
+ fontFamily: tokens.fontSans,
728
+ fontSize: tokens.textXsSize,
729
+ lineHeight: tokens.textXsLine,
730
+ color: tokens.fgMuted,
731
+ overflow: "hidden",
732
+ textOverflow: "ellipsis",
733
+ whiteSpace: "nowrap"
734
+ },
735
+ children: meta
736
+ }
737
+ ) : null
738
+ ] }),
739
+ trailing ? /* @__PURE__ */ jsxRuntime.jsx(
740
+ "div",
741
+ {
742
+ style: {
743
+ alignSelf: "center",
744
+ display: "inline-flex",
745
+ alignItems: "center",
746
+ gap: "0.5rem",
747
+ fontSize: tokens.textXsSize,
748
+ color: tokens.fgMuted,
749
+ whiteSpace: "nowrap"
750
+ },
751
+ children: trailing
752
+ }
753
+ ) : null
754
+ ]
755
+ }
756
+ );
757
+ }
758
+ function Pagination({ page, pageCount, onChange, style, ...rest }) {
759
+ const total = Math.max(1, pageCount);
760
+ const atStart = page <= 1;
761
+ const atEnd = page >= total;
762
+ return /* @__PURE__ */ jsxRuntime.jsxs(
763
+ Inline,
764
+ {
765
+ justify: "between",
766
+ style: {
767
+ fontFamily: tokens.fontSans,
768
+ fontSize: tokens.textXsSize,
769
+ color: tokens.fgMuted,
770
+ letterSpacing: "0.02em",
771
+ ...style
772
+ },
773
+ ...rest,
774
+ children: [
775
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontVariantNumeric: "tabular-nums" }, children: [
776
+ "Page ",
777
+ page,
778
+ " of ",
779
+ total
780
+ ] }),
781
+ /* @__PURE__ */ jsxRuntime.jsxs(Inline, { gap: "1rem", children: [
782
+ /* @__PURE__ */ jsxRuntime.jsx(TextLink, { disabled: atStart, onClick: () => onChange(page - 1), children: "\u2190 Prev" }),
783
+ /* @__PURE__ */ jsxRuntime.jsx(TextLink, { disabled: atEnd, onClick: () => onChange(page + 1), children: "Next \u2192" })
784
+ ] })
785
+ ]
786
+ }
787
+ );
788
+ }
789
+ var STYLE_ID5 = "nb-synapse-prose";
790
+ var RULES5 = `
791
+ .nb-prose {
792
+ font-family: ${tokens.fontSans};
793
+ font-size: ${tokens.textBaseSize};
794
+ line-height: 1.7;
795
+ color: ${tokens.fg};
796
+ }
797
+ .nb-prose > :first-child { margin-top: 0; }
798
+ .nb-prose > :last-child { margin-bottom: 0; }
799
+ .nb-prose h1, .nb-prose h2 { font-family: ${tokens.fontHeading}; letter-spacing: -0.015em; color: ${tokens.fg}; }
800
+ .nb-prose h1 { font-size: ${tokens.headingMdSize}; line-height: ${tokens.headingMdLine}; margin: 2rem 0 0.75rem; }
801
+ .nb-prose h2 { font-size: ${tokens.headingSmSize}; line-height: ${tokens.headingSmLine}; margin: 1.75rem 0 0.5rem; }
802
+ .nb-prose h3 { font-size: ${tokens.textBaseSize}; font-weight: ${tokens.weightSemibold}; margin: 1.5rem 0 0.35rem; color: ${tokens.fg}; }
803
+ .nb-prose p { margin: 0 0 1rem; }
804
+ .nb-prose ul, .nb-prose ol { margin: 0 0 1rem; padding-left: 1.25rem; }
805
+ .nb-prose li { margin: 0.25rem 0; }
806
+ .nb-prose a { color: ${tokens.accent}; text-decoration: underline; text-underline-offset: 2px; }
807
+ .nb-prose blockquote { margin: 0 0 1rem; padding-left: 1rem; border-left: 2px solid ${tokens.accent}; color: ${tokens.fgMuted}; font-style: italic; }
808
+ .nb-prose code { font-family: ${tokens.fontMono}; font-size: 0.88em; padding: 0.08rem 0.32rem; border-radius: ${tokens.radiusXs}; background: ${tokens.bgSubtle}; }
809
+ .nb-prose pre { font-family: ${tokens.fontMono}; font-size: ${tokens.textSmSize}; line-height: 1.55; margin: 0 0 1.25rem; padding: 0.875rem 1rem; background: ${tokens.bgSubtle}; border-radius: ${tokens.radiusSm}; overflow-x: auto; }
810
+ .nb-prose pre code { padding: 0; background: none; }
811
+ .nb-prose hr { border: none; border-top: 1px solid ${tokens.border}; margin: 2rem 0; }
812
+ .nb-prose strong { font-weight: ${tokens.weightSemibold}; }
813
+ `;
814
+ function Prose({ html, children, className, ...rest }) {
815
+ ensureStyle(STYLE_ID5, RULES5);
816
+ const cls = `nb-prose ${className ?? ""}`.trim();
817
+ if (html !== void 0) {
818
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls, dangerouslySetInnerHTML: { __html: html }, ...rest });
819
+ }
820
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cls, ...rest, children });
821
+ }
822
+ var STYLE_ID6 = "nb-synapse-searchfield";
823
+ var RULES6 = `
824
+ .nb-search { font-family: var(--nb-search-font); color: var(--nb-search-fg); outline: none; }
825
+ .nb-search::placeholder { color: var(--nb-search-placeholder); }
826
+ .nb-search--underline {
827
+ border: none;
828
+ border-bottom: 1px solid transparent;
829
+ background: transparent;
830
+ padding: 0.3rem 0.1rem;
831
+ transition: border-color 160ms ease;
832
+ }
833
+ .nb-search--underline:focus { border-bottom-color: var(--nb-search-accent); }
834
+ .nb-search--boxed {
835
+ border: 1px solid var(--nb-search-border);
836
+ border-radius: var(--nb-search-radius);
837
+ background: var(--nb-search-bg);
838
+ padding: 0.4rem 0.6rem;
839
+ transition: border-color 160ms ease, box-shadow 160ms ease;
840
+ }
841
+ .nb-search--boxed:focus {
842
+ border-color: var(--nb-search-accent);
843
+ box-shadow: 0 0 0 3px color-mix(in oklab, var(--nb-search-accent) 18%, transparent);
844
+ }
845
+ `;
846
+ function SearchField({
847
+ variant = "underline",
848
+ style,
849
+ className,
850
+ type = "search",
851
+ ...rest
852
+ }) {
853
+ ensureStyle(STYLE_ID6, RULES6);
854
+ const fieldStyle = {
855
+ "--nb-search-font": tokens.fontSans,
856
+ "--nb-search-fg": tokens.fg,
857
+ "--nb-search-placeholder": tokens.fgFaint,
858
+ "--nb-search-accent": tokens.accent,
859
+ "--nb-search-border": tokens.border,
860
+ "--nb-search-bg": tokens.bgSubtle,
861
+ "--nb-search-radius": tokens.radiusSm,
862
+ fontSize: tokens.textSmSize,
863
+ lineHeight: tokens.textSmLine,
864
+ ...style
865
+ };
866
+ return /* @__PURE__ */ jsxRuntime.jsx(
867
+ "input",
868
+ {
869
+ type,
870
+ className: `nb-search nb-search--${variant} ${className ?? ""}`.trim(),
871
+ style: fieldStyle,
872
+ ...rest
873
+ }
874
+ );
875
+ }
876
+ var STYLE_ID7 = "nb-synapse-segmented";
877
+ var RULES7 = `
878
+ .nb-seg {
879
+ display: inline-flex;
880
+ gap: 2px;
881
+ padding: 2px;
882
+ border-radius: var(--nb-seg-radius);
883
+ background: var(--nb-seg-track);
884
+ }
885
+ .nb-seg__btn {
886
+ border: none;
887
+ background: transparent;
888
+ color: var(--nb-seg-fg);
889
+ font-family: var(--nb-seg-font);
890
+ font-weight: var(--nb-seg-weight);
891
+ padding: 0.25rem 0.7rem;
892
+ border-radius: calc(var(--nb-seg-radius) - 2px);
893
+ cursor: pointer;
894
+ transition: color 130ms ease, background 130ms ease;
895
+ white-space: nowrap;
896
+ }
897
+ .nb-seg__btn:hover:not([aria-pressed="true"]) { color: var(--nb-seg-fg-strong); }
898
+ .nb-seg__btn[aria-pressed="true"] {
899
+ background: var(--nb-seg-active-bg);
900
+ color: var(--nb-seg-fg-strong);
901
+ box-shadow: var(--nb-seg-active-shadow);
902
+ }
903
+ `;
904
+ function SegmentedControl({
905
+ options,
906
+ value,
907
+ onChange,
908
+ style,
909
+ className,
910
+ ...rest
911
+ }) {
912
+ ensureStyle(STYLE_ID7, RULES7);
913
+ const trackStyle = {
914
+ "--nb-seg-radius": tokens.radiusSm,
915
+ "--nb-seg-track": tokens.bgSubtle,
916
+ "--nb-seg-fg": tokens.fgMuted,
917
+ "--nb-seg-fg-strong": tokens.fg,
918
+ "--nb-seg-font": tokens.fontSans,
919
+ "--nb-seg-weight": tokens.weightMedium,
920
+ "--nb-seg-active-bg": tokens.bgRaised,
921
+ "--nb-seg-active-shadow": tokens.shadowSm,
922
+ fontSize: tokens.textSmSize,
923
+ lineHeight: tokens.textSmLine,
924
+ ...style
925
+ };
926
+ return (
927
+ // biome-ignore lint/a11y/useSemanticElements: role="group" with aria-label is the correct grouping for a set of toggle buttons; <fieldset> would impose form semantics this control doesn't have.
928
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nb-seg ${className ?? ""}`.trim(), role: "group", style: trackStyle, ...rest, children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
929
+ "button",
930
+ {
931
+ type: "button",
932
+ className: "nb-seg__btn",
933
+ "aria-pressed": opt.value === value,
934
+ onClick: () => onChange(opt.value),
935
+ children: opt.label
936
+ },
937
+ opt.value
938
+ )) })
939
+ );
940
+ }
941
+ var STYLE_ID8 = "nb-synapse-spinner";
942
+ var RULES8 = `
943
+ @keyframes nb-spin { to { transform: rotate(360deg); } }
944
+ .nb-spinner { animation: nb-spin 0.7s linear infinite; }
945
+ @media (prefers-reduced-motion: reduce) { .nb-spinner { animation-duration: 1.6s; } }
946
+ `;
947
+ function Spinner({ size = 16, color, style, className, ...rest }) {
948
+ ensureStyle(STYLE_ID8, RULES8);
949
+ const spinnerStyle = {
950
+ display: "inline-block",
951
+ flexShrink: 0,
952
+ width: size,
953
+ height: size,
954
+ borderRadius: "50%",
955
+ border: `2px solid ${tokens.border}`,
956
+ borderTopColor: color ?? tokens.accent,
957
+ boxSizing: "border-box",
958
+ ...style
959
+ };
960
+ return /* @__PURE__ */ jsxRuntime.jsx(
961
+ "span",
962
+ {
963
+ className: `nb-spinner ${className ?? ""}`.trim(),
964
+ role: "status",
965
+ "aria-label": "Loading",
966
+ style: spinnerStyle,
967
+ ...rest
968
+ }
969
+ );
970
+ }
971
+ var COLOR = {
972
+ working: tokens.accent,
973
+ completed: tokens.success,
974
+ failed: tokens.danger,
975
+ idle: tokens.fgFaint
976
+ };
977
+ var STYLE_ID9 = "nb-synapse-statusdot";
978
+ var KEYFRAMES = `
979
+ @keyframes nb-statusdot-pulse {
980
+ 0% { box-shadow: 0 0 0 0 var(--nb-statusdot-ring); transform: scale(1); }
981
+ 70% { box-shadow: 0 0 0 7px transparent; transform: scale(1.15); }
982
+ 100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); }
983
+ }
984
+ .nb-statusdot--working {
985
+ animation: nb-statusdot-pulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
986
+ }
987
+ @media (prefers-reduced-motion: reduce) {
988
+ .nb-statusdot--working { animation: none; box-shadow: 0 0 0 2px var(--nb-statusdot-ring); }
989
+ }
990
+ `;
991
+ function StatusDot({
992
+ status = "idle",
993
+ color,
994
+ size = 8,
995
+ style,
996
+ className,
997
+ ...rest
998
+ }) {
999
+ ensureStyle(STYLE_ID9, KEYFRAMES);
1000
+ const dotColor = color ?? COLOR[status];
1001
+ const working = status === "working";
1002
+ const dotStyle = {
1003
+ display: "inline-block",
1004
+ flexShrink: 0,
1005
+ width: size,
1006
+ height: size,
1007
+ borderRadius: "50%",
1008
+ background: dotColor,
1009
+ // Ring color for the pulse keyframe — a faded copy of the dot color.
1010
+ "--nb-statusdot-ring": `color-mix(in oklab, ${dotColor} 45%, transparent)`,
1011
+ ...style
1012
+ };
1013
+ return /* @__PURE__ */ jsxRuntime.jsx(
1014
+ "span",
1015
+ {
1016
+ className: working ? `nb-statusdot--working ${className ?? ""}`.trim() : className,
1017
+ style: dotStyle,
1018
+ ...rest
1019
+ }
1020
+ );
1021
+ }
1022
+ var STYLE_ID10 = "nb-synapse-table";
1023
+ var RULES9 = `
1024
+ .nb-table { width: 100%; border-collapse: collapse; font-family: var(--nb-table-font); }
1025
+ .nb-table th, .nb-table td {
1026
+ padding: 0.55rem 0.75rem;
1027
+ border-bottom: var(--nb-table-border);
1028
+ font-size: var(--nb-table-size); line-height: var(--nb-table-line);
1029
+ }
1030
+ .nb-table thead th {
1031
+ position: sticky; top: 0; z-index: 1;
1032
+ background: var(--nb-table-head-bg);
1033
+ color: var(--nb-table-muted);
1034
+ font-weight: var(--nb-table-semibold);
1035
+ font-size: var(--nb-table-xs); text-align: left;
1036
+ text-transform: uppercase; letter-spacing: 0.04em;
1037
+ }
1038
+ .nb-table tbody td { color: var(--nb-table-fg); }
1039
+ .nb-table tbody tr.nb-table__row--clickable { cursor: pointer; }
1040
+ .nb-table tbody tr.nb-table__row--clickable:hover { background: var(--nb-table-hover); }
1041
+ `;
1042
+ function Table({
1043
+ data,
1044
+ columns,
1045
+ rowKey,
1046
+ onRowClick,
1047
+ empty,
1048
+ style,
1049
+ className,
1050
+ ...rest
1051
+ }) {
1052
+ ensureStyle(STYLE_ID10, RULES9);
1053
+ const vars = {
1054
+ "--nb-table-font": tokens.fontSans,
1055
+ "--nb-table-fg": tokens.fg,
1056
+ "--nb-table-muted": tokens.fgMuted,
1057
+ "--nb-table-head-bg": tokens.bg,
1058
+ "--nb-table-hover": tokens.bgSubtle,
1059
+ "--nb-table-border": `${tokens.borderWidth} solid ${tokens.border}`,
1060
+ "--nb-table-size": tokens.textSmSize,
1061
+ "--nb-table-line": tokens.textSmLine,
1062
+ "--nb-table-xs": tokens.textXsSize,
1063
+ "--nb-table-semibold": tokens.weightSemibold
1064
+ };
1065
+ if (data.length === 0 && empty !== void 0) {
1066
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: empty });
1067
+ }
1068
+ const tableStyle = { ...vars, ...style };
1069
+ return /* @__PURE__ */ jsxRuntime.jsxs("table", { className: `nb-table ${className ?? ""}`.trim(), style: tableStyle, ...rest, children: [
1070
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx(
1071
+ "th",
1072
+ {
1073
+ scope: "col",
1074
+ style: { width: col.width, textAlign: col.align ?? "left" },
1075
+ children: col.header
1076
+ },
1077
+ col.key
1078
+ )) }) }),
1079
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: data.map((row, i) => {
1080
+ const clickable = Boolean(onRowClick);
1081
+ return /* @__PURE__ */ jsxRuntime.jsx(
1082
+ "tr",
1083
+ {
1084
+ className: clickable ? "nb-table__row--clickable" : void 0,
1085
+ tabIndex: clickable ? 0 : void 0,
1086
+ onClick: clickable ? () => onRowClick?.(row, i) : void 0,
1087
+ onKeyDown: clickable ? (e) => {
1088
+ if (e.key === "Enter" || e.key === " ") {
1089
+ e.preventDefault();
1090
+ onRowClick?.(row, i);
1091
+ }
1092
+ } : void 0,
1093
+ children: columns.map((col) => /* @__PURE__ */ jsxRuntime.jsx("td", { style: { textAlign: col.align ?? "left" }, children: col.render(row, i) }, col.key))
1094
+ },
1095
+ rowKey(row, i)
1096
+ );
1097
+ }) })
1098
+ ] });
1099
+ }
1100
+ var READING_MAX = 760;
1101
+ var ContentWidthCtx = react.createContext("full");
1102
+ function columnStyle(width) {
1103
+ return width === "reading" ? { maxWidth: READING_MAX, marginInline: "auto", width: "100%" } : {};
1104
+ }
1105
+ function AppFrameRoot({ contentWidth = "full", style, children, ...rest }) {
1106
+ return /* @__PURE__ */ jsxRuntime.jsx(ContentWidthCtx.Provider, { value: contentWidth, children: /* @__PURE__ */ jsxRuntime.jsx(
1107
+ "div",
1108
+ {
1109
+ style: {
1110
+ display: "flex",
1111
+ flexDirection: "column",
1112
+ height: "100%",
1113
+ minHeight: 0,
1114
+ background: tokens.bg,
1115
+ color: tokens.fg,
1116
+ fontFamily: tokens.fontSans,
1117
+ ...style
1118
+ },
1119
+ ...rest,
1120
+ children
1121
+ }
1122
+ ) });
1123
+ }
1124
+ function Header2({ style, children, ...rest }) {
1125
+ const width = react.useContext(ContentWidthCtx);
1126
+ return /* @__PURE__ */ jsxRuntime.jsx("header", { style: { flexShrink: 0, padding: "1.25rem 1.5rem 0.75rem", ...style }, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: columnStyle(width), children }) });
1127
+ }
1128
+ function Body2({ bleed = false, style, children, ...rest }) {
1129
+ const width = react.useContext(ContentWidthCtx);
1130
+ if (bleed) {
1131
+ return /* @__PURE__ */ jsxRuntime.jsx(
1132
+ "div",
1133
+ {
1134
+ style: {
1135
+ flex: 1,
1136
+ minHeight: 0,
1137
+ display: "flex",
1138
+ flexDirection: "column",
1139
+ overflow: "hidden",
1140
+ ...style
1141
+ },
1142
+ ...rest,
1143
+ children
1144
+ }
1145
+ );
1146
+ }
1147
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", ...style }, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...columnStyle(width), padding: "0.75rem 1.5rem 1.5rem" }, children }) });
1148
+ }
1149
+ function Footer2({ style, children, ...rest }) {
1150
+ const width = react.useContext(ContentWidthCtx);
1151
+ return /* @__PURE__ */ jsxRuntime.jsx(
1152
+ "footer",
1153
+ {
1154
+ style: {
1155
+ flexShrink: 0,
1156
+ padding: "0.75rem 1.5rem",
1157
+ borderTop: `${tokens.borderWidth} solid ${tokens.border}`,
1158
+ ...style
1159
+ },
1160
+ ...rest,
1161
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: columnStyle(width), children })
1162
+ }
1163
+ );
1164
+ }
1165
+ var AppFrame = Object.assign(AppFrameRoot, { Header: Header2, Body: Body2, Footer: Footer2 });
1166
+ function useBreakpoint(breakpoint) {
1167
+ const ref = react.useRef(null);
1168
+ const [width, setWidth] = react.useState(null);
1169
+ react.useLayoutEffect(() => {
1170
+ const el = ref.current;
1171
+ if (!el) return;
1172
+ setWidth(el.getBoundingClientRect().width);
1173
+ if (typeof ResizeObserver === "undefined") return;
1174
+ const ro = new ResizeObserver((entries) => {
1175
+ const entry = entries[0];
1176
+ const w = entry?.borderBoxSize?.[0]?.inlineSize ?? entry?.contentRect.width;
1177
+ if (typeof w === "number") setWidth(w);
1178
+ });
1179
+ ro.observe(el);
1180
+ return () => ro.disconnect();
1181
+ }, []);
1182
+ return { ref, isNarrow: width !== null && width < breakpoint };
1183
+ }
1184
+ var ListDetailCtx = react.createContext(null);
1185
+ function useListDetail() {
1186
+ const ctx = react.useContext(ListDetailCtx);
1187
+ if (!ctx) throw new Error("useListDetail must be used within <ListDetailLayout>");
1188
+ return ctx;
1189
+ }
1190
+ function ListDetailLayoutRoot({
1191
+ selected = false,
1192
+ onBack,
1193
+ listWidth = 320,
1194
+ breakpoint = 720,
1195
+ style,
1196
+ children,
1197
+ ...rest
1198
+ }) {
1199
+ const { ref, isNarrow } = useBreakpoint(breakpoint);
1200
+ return /* @__PURE__ */ jsxRuntime.jsx(ListDetailCtx.Provider, { value: { collapsed: isNarrow, selected, listWidth, onBack }, children: /* @__PURE__ */ jsxRuntime.jsx(
1201
+ "div",
1202
+ {
1203
+ ref,
1204
+ style: { display: "flex", flexDirection: "row", height: "100%", minHeight: 0, ...style },
1205
+ ...rest,
1206
+ children
1207
+ }
1208
+ ) });
1209
+ }
1210
+ function List({ style, children, ...rest }) {
1211
+ const { collapsed, selected, listWidth } = useListDetail();
1212
+ if (collapsed && selected) return null;
1213
+ const border = `${tokens.borderWidth} solid ${tokens.border}`;
1214
+ return /* @__PURE__ */ jsxRuntime.jsx(
1215
+ "section",
1216
+ {
1217
+ style: {
1218
+ overflowY: "auto",
1219
+ ...collapsed ? { flex: 1, minWidth: 0 } : { width: listWidth, flexShrink: 0, borderRight: border },
1220
+ ...style
1221
+ },
1222
+ ...rest,
1223
+ children
1224
+ }
1225
+ );
1226
+ }
1227
+ function Detail({ style, children, ...rest }) {
1228
+ const { collapsed, selected } = useListDetail();
1229
+ if (collapsed && !selected) return null;
1230
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minWidth: 0, minHeight: 0, overflowY: "auto", ...style }, ...rest, children });
1231
+ }
1232
+ function Back({ children, style }) {
1233
+ const { collapsed, selected, onBack } = useListDetail();
1234
+ if (!collapsed || !selected) return null;
1235
+ return /* @__PURE__ */ jsxRuntime.jsx(TextLink, { onClick: () => onBack?.(), style: { marginBottom: "0.5rem", ...style }, children: children ?? "\u2190 Back" });
1236
+ }
1237
+ var ListDetailLayout = Object.assign(ListDetailLayoutRoot, { List, Detail, Back });
1238
+ var SidebarCtx = react.createContext(null);
1239
+ function useSidebar() {
1240
+ const ctx = react.useContext(SidebarCtx);
1241
+ if (!ctx) throw new Error("useSidebar must be used within <SidebarLayout>");
1242
+ return ctx;
1243
+ }
1244
+ var STYLE_ID11 = "nb-synapse-sidebarlayout";
1245
+ var RULES10 = `
1246
+ .nb-sidebar-drawer { transition: transform 220ms cubic-bezier(0.2, 0, 0, 1); }
1247
+ .nb-sidebar-scrim { animation: nb-sidebar-fade 180ms ease; }
1248
+ @keyframes nb-sidebar-fade { from { opacity: 0; } to { opacity: 1; } }
1249
+ @media (prefers-reduced-motion: reduce) {
1250
+ .nb-sidebar-drawer { transition: none; }
1251
+ .nb-sidebar-scrim { animation: none; }
1252
+ }
1253
+ `;
1254
+ function SidebarLayoutRoot({
1255
+ side = "left",
1256
+ width = 240,
1257
+ breakpoint = 640,
1258
+ collapseMode = "reflow",
1259
+ style,
1260
+ children,
1261
+ ...rest
1262
+ }) {
1263
+ const { ref, isNarrow } = useBreakpoint(breakpoint);
1264
+ const [open, setOpen] = react.useState(false);
1265
+ react.useEffect(() => {
1266
+ if (!open) return;
1267
+ const onKey = (e) => {
1268
+ if (e.key === "Escape") setOpen(false);
1269
+ };
1270
+ window.addEventListener("keydown", onKey);
1271
+ return () => window.removeEventListener("keydown", onKey);
1272
+ }, [open]);
1273
+ react.useEffect(() => {
1274
+ if (!isNarrow && open) setOpen(false);
1275
+ }, [isNarrow, open]);
1276
+ const reflowed = isNarrow && collapseMode === "reflow";
1277
+ const rootStyle = {
1278
+ position: "relative",
1279
+ display: "flex",
1280
+ flexDirection: reflowed ? "column" : side === "right" ? "row-reverse" : "row",
1281
+ height: "100%",
1282
+ minHeight: 0,
1283
+ ...style
1284
+ };
1285
+ return /* @__PURE__ */ jsxRuntime.jsx(
1286
+ SidebarCtx.Provider,
1287
+ {
1288
+ value: { collapsed: isNarrow, mode: collapseMode, side, width, open, setOpen },
1289
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: rootStyle, ...rest, children })
1290
+ }
1291
+ );
1292
+ }
1293
+ function Sidebar({ style, children, ...rest }) {
1294
+ const { collapsed, mode, side, width, open, setOpen } = useSidebar();
1295
+ ensureStyle(STYLE_ID11, RULES10);
1296
+ if (!collapsed) {
1297
+ const border = `${tokens.borderWidth} solid ${tokens.border}`;
1298
+ return /* @__PURE__ */ jsxRuntime.jsx(
1299
+ "aside",
1300
+ {
1301
+ style: {
1302
+ width,
1303
+ flexShrink: 0,
1304
+ overflowY: "auto",
1305
+ display: "flex",
1306
+ flexDirection: "column",
1307
+ gap: "0.125rem",
1308
+ padding: "0.5rem 0.5rem",
1309
+ ...side === "right" ? { borderLeft: border } : { borderRight: border },
1310
+ ...style
1311
+ },
1312
+ ...rest,
1313
+ children
1314
+ }
1315
+ );
1316
+ }
1317
+ if (mode === "reflow") {
1318
+ return /* @__PURE__ */ jsxRuntime.jsx(
1319
+ "aside",
1320
+ {
1321
+ style: {
1322
+ display: "flex",
1323
+ flexDirection: "row",
1324
+ alignItems: "center",
1325
+ gap: "0.25rem",
1326
+ width: "100%",
1327
+ overflowX: "auto",
1328
+ padding: "0.5rem 0.75rem",
1329
+ borderBottom: `${tokens.borderWidth} solid ${tokens.border}`,
1330
+ ...style
1331
+ },
1332
+ ...rest,
1333
+ children
1334
+ }
1335
+ );
1336
+ }
1337
+ const closed = side === "right" ? "translateX(100%)" : "translateX(-100%)";
1338
+ const drawerStyle = {
1339
+ position: "absolute",
1340
+ top: 0,
1341
+ bottom: 0,
1342
+ [side]: 0,
1343
+ width,
1344
+ maxWidth: "85%",
1345
+ overflowY: "auto",
1346
+ background: tokens.bgRaised,
1347
+ boxShadow: tokens.shadowLg,
1348
+ transform: open ? "translateX(0)" : closed,
1349
+ zIndex: 11,
1350
+ ...side === "right" ? { borderLeft: `${tokens.borderWidth} solid ${tokens.border}` } : { borderRight: `${tokens.borderWidth} solid ${tokens.border}` },
1351
+ ...style
1352
+ };
1353
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1354
+ open ? /* @__PURE__ */ jsxRuntime.jsx(
1355
+ "button",
1356
+ {
1357
+ type: "button",
1358
+ "aria-label": "Close sidebar",
1359
+ className: "nb-sidebar-scrim",
1360
+ onClick: () => setOpen(false),
1361
+ style: {
1362
+ position: "absolute",
1363
+ inset: 0,
1364
+ border: "none",
1365
+ padding: 0,
1366
+ cursor: "pointer",
1367
+ background: "rgba(0,0,0,0.32)",
1368
+ zIndex: 10
1369
+ }
1370
+ }
1371
+ ) : null,
1372
+ /* @__PURE__ */ jsxRuntime.jsx("aside", { className: "nb-sidebar-drawer", inert: !open, style: drawerStyle, ...rest, children })
1373
+ ] });
1374
+ }
1375
+ function Main({ style, children, ...rest }) {
1376
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minWidth: 0, minHeight: 0, overflowY: "auto", ...style }, ...rest, children });
1377
+ }
1378
+ function Trigger({ children, style, onClick, ...rest }) {
1379
+ const ctx = react.useContext(SidebarCtx);
1380
+ if (!ctx?.collapsed || ctx.mode !== "drawer") return null;
1381
+ const { open, setOpen } = ctx;
1382
+ return /* @__PURE__ */ jsxRuntime.jsx(
1383
+ "button",
1384
+ {
1385
+ type: "button",
1386
+ "aria-label": "Toggle sidebar",
1387
+ "aria-expanded": open,
1388
+ onClick: (e) => {
1389
+ setOpen(!open);
1390
+ onClick?.(e);
1391
+ },
1392
+ style: {
1393
+ display: "inline-flex",
1394
+ alignItems: "center",
1395
+ justifyContent: "center",
1396
+ width: 32,
1397
+ height: 32,
1398
+ border: "none",
1399
+ background: "transparent",
1400
+ color: tokens.fg,
1401
+ cursor: "pointer",
1402
+ borderRadius: tokens.radiusSm,
1403
+ ...style
1404
+ },
1405
+ ...rest,
1406
+ children: children ?? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 18 18", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
1407
+ "path",
1408
+ {
1409
+ d: "M2 4.5h14M2 9h14M2 13.5h14",
1410
+ stroke: "currentColor",
1411
+ strokeWidth: "1.5",
1412
+ strokeLinecap: "round"
1413
+ }
1414
+ ) })
1415
+ }
1416
+ );
1417
+ }
1418
+ var SidebarLayout = Object.assign(SidebarLayoutRoot, { Sidebar, Main, Trigger });
1419
+
1420
+ exports.AppFrame = AppFrame;
1421
+ exports.Avatar = Avatar;
1422
+ exports.Badge = Badge;
1423
+ exports.Button = Button;
1424
+ exports.Card = Card;
1425
+ exports.Divider = Divider;
1426
+ exports.Drawer = Drawer;
1427
+ exports.EmptyState = EmptyState;
1428
+ exports.Heading = Heading;
1429
+ exports.Inline = Inline;
1430
+ exports.ListDetailLayout = ListDetailLayout;
1431
+ exports.ListRow = ListRow;
1432
+ exports.Pagination = Pagination;
1433
+ exports.Prose = Prose;
1434
+ exports.SearchField = SearchField;
1435
+ exports.SegmentedControl = SegmentedControl;
1436
+ exports.SidebarLayout = SidebarLayout;
1437
+ exports.Spacer = Spacer;
1438
+ exports.Spinner = Spinner;
1439
+ exports.Stack = Stack;
1440
+ exports.StatusDot = StatusDot;
1441
+ exports.Table = Table;
1442
+ exports.Text = Text;
1443
+ exports.TextLink = TextLink;
1444
+ exports.headingStyle = headingStyle;
1445
+ exports.textStyle = textStyle;
1446
+ exports.tokens = tokens;
1447
+ exports.useBreakpoint = useBreakpoint;
1448
+ exports.useListDetail = useListDetail;
1449
+ exports.useSidebar = useSidebar;
1450
+ //# sourceMappingURL=index.cjs.map
1451
+ //# sourceMappingURL=index.cjs.map