@mediaradar/design-components 0.45.3 → 0.47.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.
package/dist/index.cjs CHANGED
@@ -98,8 +98,24 @@ var define_FONT_SIZE_KEYS_default = ["control-caption", "badge", "micro", "xs",
98
98
  var import_react = require("react");
99
99
  var import_react_dom = require("react-dom");
100
100
  var import_lucide_react = require("lucide-react");
101
+
102
+ // src/cn.ts
103
+ var import_clsx = require("clsx");
104
+ var import_tailwind_merge = require("tailwind-merge");
105
+ var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
106
+ extend: {
107
+ classGroups: {
108
+ "font-size": [{ text: define_FONT_SIZE_KEYS_default }]
109
+ }
110
+ }
111
+ });
112
+ function cn(...inputs) {
113
+ return twMerge((0, import_clsx.clsx)(inputs));
114
+ }
115
+
116
+ // src/InfoTip.tsx
101
117
  var import_jsx_runtime = require("react/jsx-runtime");
102
- function InfoTip({ text, size = 11, label = "More information", trigger = "click" }) {
118
+ function InfoTip({ text, size = 11, label = "More information", trigger = "click", className, testIdPrefix }) {
103
119
  const [open, setOpen] = (0, import_react.useState)(false);
104
120
  const [pos, setPos] = (0, import_react.useState)(null);
105
121
  const btnRef = (0, import_react.useRef)(null);
@@ -160,8 +176,12 @@ function InfoTip({ text, size = 11, label = "More information", trigger = "click
160
176
  "aria-label": label,
161
177
  "aria-expanded": open,
162
178
  "aria-describedby": textId,
179
+ "data-testid": testIdPrefix,
163
180
  ...hoverProps,
164
- className: "inline-flex cursor-pointer items-center text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
181
+ className: cn(
182
+ "inline-flex cursor-pointer items-center text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
183
+ className
184
+ ),
165
185
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Info, { size, "aria-hidden": "true" })
166
186
  }
167
187
  ),
@@ -190,8 +210,8 @@ var import_lucide_react3 = require("lucide-react");
190
210
  // src/AdvertiserSearchPrompt.tsx
191
211
  var import_lucide_react2 = require("lucide-react");
192
212
  var import_jsx_runtime2 = require("react/jsx-runtime");
193
- function AdvertiserSearchPrompt({ label = "an advertiser name" }) {
194
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col items-center gap-2 px-4 py-8 text-center", children: [
213
+ function AdvertiserSearchPrompt({ label = "an advertiser name", className, testIdPrefix }) {
214
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn("flex flex-col items-center gap-2 px-4 py-8 text-center", className), "data-testid": testIdPrefix, children: [
195
215
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "flex h-9 w-9 items-center justify-center rounded-full bg-subtle text-text-tertiary", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react2.Search, { size: 16, "aria-hidden": "true" }) }),
196
216
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-xs leading-snug text-text-tertiary", children: [
197
217
  "Start typing ",
@@ -201,20 +221,6 @@ function AdvertiserSearchPrompt({ label = "an advertiser name" }) {
201
221
  ] });
202
222
  }
203
223
 
204
- // src/cn.ts
205
- var import_clsx = require("clsx");
206
- var import_tailwind_merge = require("tailwind-merge");
207
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
208
- extend: {
209
- classGroups: {
210
- "font-size": [{ text: define_FONT_SIZE_KEYS_default }]
211
- }
212
- }
213
- });
214
- function cn(...inputs) {
215
- return twMerge((0, import_clsx.clsx)(inputs));
216
- }
217
-
218
224
  // src/ChipTrigger.tsx
219
225
  var import_jsx_runtime3 = require("react/jsx-runtime");
220
226
  function chipTriggerClass(_variant = "box") {
@@ -225,13 +231,20 @@ function chipTriggerClass(_variant = "box") {
225
231
  // a different kind of control. The variant no longer changes anything.
226
232
  );
227
233
  }
228
- function ChipContent({ caption, value, icon }) {
229
- const stack = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
230
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-control-caption leading-none uppercase tracking-wide text-text-tertiary", children: caption }),
231
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-xs leading-none font-medium text-text-primary", children: value })
232
- ] });
234
+ function ChipContent({ caption, value, icon, className, testIdPrefix }) {
235
+ const stack = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
236
+ "span",
237
+ {
238
+ className: cn("flex flex-col gap-1 text-left leading-none", !icon && className),
239
+ "data-testid": icon ? void 0 : testIdPrefix,
240
+ children: [
241
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-control-caption leading-none uppercase tracking-wide text-text-tertiary", children: caption }),
242
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-xs leading-none font-medium text-text-primary", children: value })
243
+ ]
244
+ }
245
+ );
233
246
  if (icon) {
234
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "flex items-center gap-2", children: [
247
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: cn("flex items-center gap-2", className), "data-testid": testIdPrefix, children: [
235
248
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
236
249
  stack
237
250
  ] });
@@ -241,9 +254,6 @@ function ChipContent({ caption, value, icon }) {
241
254
 
242
255
  // src/AdvertiserQuickFilter.tsx
243
256
  var import_jsx_runtime4 = require("react/jsx-runtime");
244
- function cx(...parts) {
245
- return parts.filter(Boolean).join(" ");
246
- }
247
257
  var SELECT_ALL_THRESHOLD = 5;
248
258
  function usePaging(total, pageSize, resetKey) {
249
259
  const [pages, setPages] = (0, import_react2.useState)(1);
@@ -274,6 +284,7 @@ function AdvertiserQuickFilter({
274
284
  promptLabel = "an advertiser name",
275
285
  noResultsHint = "Try checking your spelling or searching for a broader brand name.",
276
286
  clearLabel = "Clear advertisers",
287
+ className,
277
288
  testIdPrefix
278
289
  }) {
279
290
  const [open, setOpen] = (0, import_react2.useState)(false);
@@ -354,7 +365,7 @@ function AdvertiserQuickFilter({
354
365
  const shown = open && !showFooter ? draft : selected;
355
366
  const counted = parked.length ? shown.filter((id) => !parked.includes(id)) : shown;
356
367
  const value = counted.length === 0 ? "All" : counted.length === 1 ? options.find((o) => o.id === counted[0])?.label ?? "1 selected" : `${counted.length} selected`;
357
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative", ref, children: [
368
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
358
369
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
359
370
  "button",
360
371
  {
@@ -371,7 +382,7 @@ function AdvertiserQuickFilter({
371
382
  {
372
383
  size: 14,
373
384
  "aria-hidden": "true",
374
- className: cx("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
385
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
375
386
  }
376
387
  )
377
388
  ]
@@ -380,7 +391,7 @@ function AdvertiserQuickFilter({
380
391
  open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
381
392
  "div",
382
393
  {
383
- className: cx(
394
+ className: cn(
384
395
  "absolute top-[calc(100%+8px)] z-30 flex w-72 flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
385
396
  align === "right" ? "right-0" : "left-0"
386
397
  ),
@@ -410,7 +421,7 @@ function AdvertiserQuickFilter({
410
421
  type: "button",
411
422
  onClick: clearSearch,
412
423
  "aria-label": "Clear search",
413
- className: "shrink-0 text-text-tertiary transition-colors hover:text-text-primary",
424
+ className: "shrink-0 text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
414
425
  children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.X, { size: 13 })
415
426
  }
416
427
  )
@@ -424,14 +435,14 @@ function AdvertiserQuickFilter({
424
435
  "data-testid": testIdPrefix && `${testIdPrefix}-selected-toggle`,
425
436
  onClick: () => setSelectedOpen((v) => !v),
426
437
  "aria-expanded": selectedOpen,
427
- className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary",
438
+ className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
428
439
  children: [
429
440
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
430
441
  import_lucide_react3.ChevronDown,
431
442
  {
432
443
  size: 13,
433
444
  "aria-hidden": "true",
434
- className: cx("transition-transform", !selectedOpen && "-rotate-90")
445
+ className: cn("transition-transform", !selectedOpen && "-rotate-90")
435
446
  }
436
447
  ),
437
448
  "Selected (",
@@ -469,7 +480,7 @@ function AdvertiserQuickFilter({
469
480
  type: "button",
470
481
  "data-testid": testIdPrefix && `${testIdPrefix}-select-all-visible`,
471
482
  onClick: toggleAllVisible,
472
- className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle",
483
+ className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
473
484
  children: [
474
485
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.ListChecks, { size: 14, "aria-hidden": "true" }),
475
486
  allVisibleSelected ? `Deselect ${results.length} visible` : `Select all ${results.length} visible`
@@ -511,7 +522,7 @@ function AdvertiserQuickFilter({
511
522
  "data-testid": testIdPrefix && `${testIdPrefix}-clear-all`,
512
523
  onClick: () => setDraft(clearValue),
513
524
  disabled: draft.length === 0,
514
- className: "text-dense font-medium text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",
525
+ className: "text-dense font-medium text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
515
526
  children: "Clear all"
516
527
  }
517
528
  ),
@@ -521,7 +532,7 @@ function AdvertiserQuickFilter({
521
532
  type: "button",
522
533
  "data-testid": testIdPrefix && `${testIdPrefix}-apply`,
523
534
  onClick: apply,
524
- className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition hover:brightness-110",
535
+ className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition hover:brightness-110 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
525
536
  children: "Apply"
526
537
  }
527
538
  )
@@ -535,7 +546,7 @@ function AdvertiserQuickFilter({
535
546
  {
536
547
  type: "button",
537
548
  onClick: () => setDraft([]),
538
- className: "text-xs font-medium text-text-link hover:underline",
549
+ className: "text-xs font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
539
550
  children: clearLabel
540
551
  }
541
552
  )
@@ -569,7 +580,7 @@ function OptionRow({
569
580
  e.stopPropagation();
570
581
  onToggle();
571
582
  },
572
- className: cx(
583
+ className: cn(
573
584
  "flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-[5px] border transition-colors",
574
585
  "focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus",
575
586
  checked ? "border-transparent bg-brand-primaryAction text-brand-onprimary" : "border-border-interactive bg-surface hover:border-brand-primaryAction"
@@ -637,23 +648,25 @@ var KIND = {
637
648
  // are harder to read than the sentence case they replaced.
638
649
  eyebrow: "px-2.5 py-1 uppercase tracking-wider",
639
650
  // What a thing IS (a topic, a category) rather than a signal about it.
640
- // Always the same quiet grey whatever `tone` says: colour here would read
651
+ // Quiet grey whatever `tone` says (only `highlight` changes it): colour here would read
641
652
  // as meaning, and a category has none. This is the old Tag.
642
653
  category: "px-2 py-1"
643
654
  };
644
655
  var CATEGORY = "bg-subtle font-medium text-text-tertiary";
645
- function Badge({ tone = "neutral", kind = "label", dot = false, children, className }) {
656
+ var CATEGORY_HIGHLIGHT = "bg-brand-primarySoft font-semibold text-brand-primaryAction";
657
+ function Badge({ tone = "neutral", kind = "label", dot = false, highlight = false, children, className, testIdPrefix }) {
646
658
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
647
659
  "span",
648
660
  {
649
661
  style: kind === "category" ? void 0 : TONE_STYLE[tone],
662
+ "data-testid": testIdPrefix,
650
663
  className: cn(
651
664
  // `inline-flex` + `gap` so a leading icon sits on the text baseline
652
665
  // without every caller re-inventing the spacing. `shrink-0` because a
653
666
  // badge is almost always beside flexible text that would otherwise
654
667
  // squash it. `whitespace-nowrap` because a wrapped badge is a bug.
655
668
  "inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-full text-micro leading-none",
656
- kind === "category" ? CATEGORY : cn("font-semibold", TONE[tone]),
669
+ kind === "category" ? highlight ? CATEGORY_HIGHLIGHT : CATEGORY : cn("font-semibold", TONE[tone]),
657
670
  KIND[kind],
658
671
  className
659
672
  ),
@@ -668,7 +681,7 @@ function Badge({ tone = "neutral", kind = "label", dot = false, children, classN
668
681
  // src/Delta.tsx
669
682
  var import_lucide_react4 = require("lucide-react");
670
683
  var import_jsx_runtime6 = require("react/jsx-runtime");
671
- function Delta({ value, suffix = "%", arrow = false, period, className }) {
684
+ function Delta({ value, suffix = "%", arrow = false, period, className, testIdPrefix }) {
672
685
  const up = value >= 0;
673
686
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
674
687
  "span",
@@ -678,6 +691,7 @@ function Delta({ value, suffix = "%", arrow = false, period, className }) {
678
691
  up ? "text-text-success" : "text-text-danger",
679
692
  className
680
693
  ),
694
+ "data-testid": testIdPrefix,
681
695
  children: [
682
696
  arrow && (up ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.ArrowUpRight, { size: 13, "aria-hidden": "true" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.ArrowDownRight, { size: 13, "aria-hidden": "true" })),
683
697
  up ? "+" : "\u2212",
@@ -690,6 +704,7 @@ function Delta({ value, suffix = "%", arrow = false, period, className }) {
690
704
  }
691
705
 
692
706
  // src/CheckBox.tsx
707
+ var import_react3 = require("react");
693
708
  var import_lucide_react5 = require("lucide-react");
694
709
  var import_jsx_runtime7 = require("react/jsx-runtime");
695
710
  function boxClass(on, disabled) {
@@ -703,28 +718,19 @@ function Glyph({ checked, indeterminate }) {
703
718
  if (indeterminate) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.Minus, { size: 13, strokeWidth: 3 });
704
719
  return checked ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.Check, { size: 13, strokeWidth: 3 }) : null;
705
720
  }
706
- function CheckBox({
707
- checked,
708
- indeterminate,
709
- onChange,
710
- ariaLabel,
711
- disabled,
712
- stopPropagation = true,
713
- testId,
714
- title,
715
- className
716
- }) {
721
+ var CheckBox = (0, import_react3.forwardRef)(function CheckBox2({ checked, indeterminate, onChange, ariaLabel, disabled, stopPropagation = true, testId, testIdPrefix, title, className }, ref) {
717
722
  const on = checked || !!indeterminate;
718
723
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
719
724
  "button",
720
725
  {
726
+ ref,
721
727
  type: "button",
722
728
  role: "checkbox",
723
729
  "aria-checked": indeterminate ? "mixed" : checked,
724
730
  "aria-label": ariaLabel,
725
731
  title,
726
732
  disabled,
727
- "data-testid": testId,
733
+ "data-testid": testId ?? testIdPrefix,
728
734
  onClick: (e) => {
729
735
  if (stopPropagation) e.stopPropagation();
730
736
  onChange();
@@ -742,13 +748,24 @@ function CheckBox({
742
748
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { checked, indeterminate })
743
749
  }
744
750
  );
745
- }
746
- function CheckBoxBox({ checked, indeterminate, disabled, className }) {
747
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: cn(boxClass(checked || !!indeterminate, disabled), className), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { checked, indeterminate }) });
748
- }
751
+ });
752
+ CheckBox.displayName = "CheckBox";
753
+ var CheckBoxBox = (0, import_react3.forwardRef)(function CheckBoxBox2({ checked, indeterminate, disabled, className, testIdPrefix }, ref) {
754
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
755
+ "span",
756
+ {
757
+ ref,
758
+ "aria-hidden": "true",
759
+ "data-testid": testIdPrefix,
760
+ className: cn(boxClass(checked || !!indeterminate, disabled), className),
761
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { checked, indeterminate })
762
+ }
763
+ );
764
+ });
765
+ CheckBoxBox.displayName = "CheckBoxBox";
749
766
 
750
767
  // src/DateRangeFilter.tsx
751
- var import_react3 = require("react");
768
+ var import_react4 = require("react");
752
769
  var import_lucide_react6 = require("lucide-react");
753
770
  var import_jsx_runtime8 = require("react/jsx-runtime");
754
771
  var DEFAULT_SHORTCUTS = [
@@ -905,6 +922,7 @@ function DateRangeFilter({
905
922
  initialRange,
906
923
  compare,
907
924
  onApply,
925
+ className,
908
926
  testIdPrefix,
909
927
  granularity = "day",
910
928
  formatDate,
@@ -921,39 +939,39 @@ function DateRangeFilter({
921
939
  const SHORTCUTS = (presetSet === "creativeIntel" ? CREATIVE_INTEL_SHORTCUTS : DEFAULT_SHORTCUTS).filter(
922
940
  (s) => !excludePresets.includes(s)
923
941
  );
924
- const today = (0, import_react3.useMemo)(() => todayProp ?? /* @__PURE__ */ new Date(), []);
942
+ const today = (0, import_react4.useMemo)(() => todayProp ?? /* @__PURE__ */ new Date(), []);
925
943
  const initShortcut = matchShortcut(SHORTCUTS, controlled ? controlledValue : defaultValue);
926
944
  const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
927
945
  const compareLabel = (id) => compare?.options.find((o) => o.id === id)?.label;
928
946
  const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : formatted ? showRange(s, e) : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
929
- const [open, setOpen] = (0, import_react3.useState)(false);
930
- const [uncontrolledValue, setUncontrolledValue] = (0, import_react3.useState)(
947
+ const [open, setOpen] = (0, import_react4.useState)(false);
948
+ const [uncontrolledValue, setUncontrolledValue] = (0, import_react4.useState)(
931
949
  startsEmpty ? emptyLabel : showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
932
950
  );
933
- const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react3.useState)(
951
+ const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react4.useState)(
934
952
  startsEmpty ? null : dateLine(initRange[0], initRange[1])
935
953
  );
936
- const committed = (0, import_react3.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1], set: !startsEmpty });
937
- const [cmp, setCmp] = (0, import_react3.useState)(compare?.value);
938
- const committedCmp = (0, import_react3.useRef)(compare?.value);
939
- const [appliedCmp, setAppliedCmp] = (0, import_react3.useState)(compare?.value);
940
- (0, import_react3.useEffect)(() => {
954
+ const committed = (0, import_react4.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1], set: !startsEmpty });
955
+ const [cmp, setCmp] = (0, import_react4.useState)(compare?.value);
956
+ const committedCmp = (0, import_react4.useRef)(compare?.value);
957
+ const [appliedCmp, setAppliedCmp] = (0, import_react4.useState)(compare?.value);
958
+ (0, import_react4.useEffect)(() => {
941
959
  committedCmp.current = compare?.value;
942
960
  setAppliedCmp(compare?.value);
943
961
  }, [compare?.value]);
944
- const compareName = `${(0, import_react3.useId)()}-compare`;
962
+ const compareName = `${(0, import_react4.useId)()}-compare`;
945
963
  const displayValue = controlled ? showDates ? presetLabel(initShortcut) : showValue(controlledValue, initRange[0], initRange[1]) : showValue(uncontrolledValue, committed.current.start, committed.current.end);
946
964
  const displayDatesLine = controlled ? dateLine(initRange[0], initRange[1]) : uncontrolledDatesLine;
947
- const [shortcut, setShortcut] = (0, import_react3.useState)(initShortcut);
948
- const [start, setStart] = (0, import_react3.useState)(initRange[0]);
949
- const [end, setEnd] = (0, import_react3.useState)(initRange[1]);
950
- const [leftMonth, setLeftMonth] = (0, import_react3.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
951
- const ref = (0, import_react3.useRef)(null);
952
- (0, import_react3.useEffect)(() => {
965
+ const [shortcut, setShortcut] = (0, import_react4.useState)(initShortcut);
966
+ const [start, setStart] = (0, import_react4.useState)(initRange[0]);
967
+ const [end, setEnd] = (0, import_react4.useState)(initRange[1]);
968
+ const [leftMonth, setLeftMonth] = (0, import_react4.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
969
+ const ref = (0, import_react4.useRef)(null);
970
+ (0, import_react4.useEffect)(() => {
953
971
  if (controlled || startsEmpty) return;
954
972
  onRangeChange?.(committed.current.start, committed.current.end);
955
973
  }, []);
956
- (0, import_react3.useEffect)(() => {
974
+ (0, import_react4.useEffect)(() => {
957
975
  if (!open) return;
958
976
  const committedShortcut = controlled ? initShortcut : committed.current.shortcut;
959
977
  const committedStart = controlled ? initRange[0] : committed.current.start;
@@ -1015,14 +1033,14 @@ function DateRangeFilter({
1015
1033
  onApply?.(shortcut === "Custom" ? `${fmt(s)} \u2013 ${fmt(e)}` : shortcut, s, e, cmp);
1016
1034
  setOpen(false);
1017
1035
  };
1018
- const popRef = (0, import_react3.useRef)(null);
1019
- const [flipBelow, setFlipBelow] = (0, import_react3.useState)(false);
1020
- (0, import_react3.useLayoutEffect)(() => {
1036
+ const popRef = (0, import_react4.useRef)(null);
1037
+ const [flipBelow, setFlipBelow] = (0, import_react4.useState)(false);
1038
+ (0, import_react4.useLayoutEffect)(() => {
1021
1039
  if (!open || placement !== "above" || !ref.current || !popRef.current) return;
1022
1040
  setFlipBelow(ref.current.getBoundingClientRect().top < popRef.current.offsetHeight + 16);
1023
1041
  }, [open, placement]);
1024
1042
  const above = placement === "above" && !flipBelow;
1025
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative", ref, children: [
1043
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
1026
1044
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1027
1045
  "button",
1028
1046
  {
@@ -1062,7 +1080,7 @@ function DateRangeFilter({
1062
1080
  type: "button",
1063
1081
  "data-testid": testIdPrefix && `${testIdPrefix}-option-${slug2(s)}`,
1064
1082
  onClick: () => choosePreset(s),
1065
- className: `rounded-control px-3 py-2 text-left text-dense font-medium transition-colors ${shortcut === s ? "bg-subtle text-text-primary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"}`,
1083
+ className: `rounded-control px-3 py-2 text-left text-dense font-medium transition-colors focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus ${shortcut === s ? "bg-subtle text-text-primary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"}`,
1066
1084
  children: s
1067
1085
  },
1068
1086
  s
@@ -1103,7 +1121,7 @@ function DateRangeFilter({
1103
1121
  else if (end && isEnd) band = "left-0 right-1/2";
1104
1122
  else band = "left-0 right-0";
1105
1123
  }
1106
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: () => pickDay(d), className: "relative flex h-9 items-center justify-center", children: [
1124
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: () => pickDay(d), className: "relative flex h-9 items-center justify-center focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus", children: [
1107
1125
  band && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `absolute inset-y-[3px] bg-ai-tint ${band}`, "aria-hidden": "true" }),
1108
1126
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1109
1127
  "span",
@@ -1148,8 +1166,8 @@ function DateRangeFilter({
1148
1166
  ] }),
1149
1167
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
1150
1168
  monthly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "mr-auto text-xs text-text-tertiary", children: "Data is monthly, so ranges cover whole months." }),
1151
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => setOpen(false), className: "rounded-control border border-border-default bg-surface px-5 py-2 text-dense font-semibold text-text-primary transition-colors hover:bg-subtle", children: "Cancel" }),
1152
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, disabled: !canApply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50", children: "Apply" })
1169
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => setOpen(false), className: "rounded-control border border-border-default bg-surface px-5 py-2 text-dense font-semibold text-text-primary transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Cancel" }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, disabled: !canApply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-dense font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Apply" })
1153
1171
  ] })
1154
1172
  ] })
1155
1173
  ]
@@ -1164,11 +1182,11 @@ function Field({ label, value }) {
1164
1182
  ] });
1165
1183
  }
1166
1184
  function NavBtn({ children, onClick, ...rest }) {
1167
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick, className: "flex h-7 w-7 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary", ...rest, children });
1185
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick, className: "flex h-7 w-7 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", ...rest, children });
1168
1186
  }
1169
1187
 
1170
1188
  // src/SearchBar.tsx
1171
- var import_react4 = require("react");
1189
+ var import_react5 = require("react");
1172
1190
  var import_lucide_react7 = require("lucide-react");
1173
1191
  var import_jsx_runtime9 = require("react/jsx-runtime");
1174
1192
  var HEIGHT = { sm: "h-8", md: "h-10", lg: "h-11" };
@@ -1196,10 +1214,7 @@ function mergeAdCodes(existing, incoming) {
1196
1214
  function slug3(value) {
1197
1215
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1198
1216
  }
1199
- function cx2(...classes) {
1200
- return classes.filter(Boolean).join(" ");
1201
- }
1202
- function SearchBar({
1217
+ var SearchBar = (0, import_react5.forwardRef)(function SearchBar2({
1203
1218
  placeholder = "Search\u2026",
1204
1219
  value,
1205
1220
  onChange,
@@ -1213,18 +1228,23 @@ function SearchBar({
1213
1228
  onDownloadAdCodes,
1214
1229
  className,
1215
1230
  testIdPrefix
1216
- }) {
1217
- const [open, setOpen] = (0, import_react4.useState)(false);
1218
- const ref = (0, import_react4.useRef)(null);
1219
- const input = (0, import_react4.useRef)(null);
1220
- const [codesOpen, setCodesOpen] = (0, import_react4.useState)(false);
1221
- const codesRef = (0, import_react4.useRef)(null);
1222
- const codesPopover = (0, import_react4.useRef)(null);
1223
- const refocus = (0, import_react4.useRef)(null);
1231
+ }, forwardedRef) {
1232
+ const [open, setOpen] = (0, import_react5.useState)(false);
1233
+ const ref = (0, import_react5.useRef)(null);
1234
+ const input = (0, import_react5.useRef)(null);
1235
+ const setInput = (el) => {
1236
+ input.current = el;
1237
+ if (typeof forwardedRef === "function") forwardedRef(el);
1238
+ else if (forwardedRef) forwardedRef.current = el;
1239
+ };
1240
+ const [codesOpen, setCodesOpen] = (0, import_react5.useState)(false);
1241
+ const codesRef = (0, import_react5.useRef)(null);
1242
+ const codesPopover = (0, import_react5.useRef)(null);
1243
+ const refocus = (0, import_react5.useRef)(null);
1224
1244
  const adCodeMode = variant === "filterable" && matchValue?.mode === "adCode" && !!onAdCodesChange;
1225
1245
  const matchedCount = adCodes.filter((c) => isAdCodeMatched?.(c)).length;
1226
1246
  const hasMisses = !!isAdCodeMatched && matchedCount < adCodes.length;
1227
- (0, import_react4.useEffect)(() => {
1247
+ (0, import_react5.useEffect)(() => {
1228
1248
  if (!codesOpen) return;
1229
1249
  const onKey = (e) => {
1230
1250
  if (e.key !== "Escape") return;
@@ -1241,7 +1261,7 @@ function SearchBar({
1241
1261
  window.removeEventListener("mousedown", onClick);
1242
1262
  };
1243
1263
  }, [codesOpen]);
1244
- (0, import_react4.useLayoutEffect)(() => {
1264
+ (0, import_react5.useLayoutEffect)(() => {
1245
1265
  const i = refocus.current;
1246
1266
  if (i === null) return;
1247
1267
  refocus.current = null;
@@ -1254,7 +1274,7 @@ function SearchBar({
1254
1274
  if (!next.length) setCodesOpen(false);
1255
1275
  onAdCodesChange?.(next);
1256
1276
  };
1257
- (0, import_react4.useEffect)(() => {
1277
+ (0, import_react5.useEffect)(() => {
1258
1278
  if (!open) return;
1259
1279
  const onKey = (e) => e.key === "Escape" && setOpen(false);
1260
1280
  const onClick = (e) => {
@@ -1271,11 +1291,12 @@ function SearchBar({
1271
1291
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1272
1292
  "div",
1273
1293
  {
1274
- className: cx2(
1294
+ className: cn(
1275
1295
  "relative flex min-w-[200px] flex-1 items-stretch rounded-control border border-border-strong bg-input focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-border-focus",
1276
1296
  HEIGHT[size],
1277
1297
  className
1278
1298
  ),
1299
+ "data-testid": testIdPrefix,
1279
1300
  children: [
1280
1301
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1281
1302
  "div",
@@ -1293,7 +1314,7 @@ function SearchBar({
1293
1314
  adCodeMode && adCodes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1294
1315
  "span",
1295
1316
  {
1296
- className: cx2(
1317
+ className: cn(
1297
1318
  "inline-flex shrink-0 items-center gap-1 rounded-full py-0.5 pl-2 pr-1 text-xs font-medium",
1298
1319
  hasMisses ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
1299
1320
  ),
@@ -1330,7 +1351,7 @@ function SearchBar({
1330
1351
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1331
1352
  "input",
1332
1353
  {
1333
- ref: input,
1354
+ ref: setInput,
1334
1355
  type: "text",
1335
1356
  value,
1336
1357
  onChange: (e) => onChange?.(e.target.value),
@@ -1363,7 +1384,7 @@ function SearchBar({
1363
1384
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1364
1385
  "li",
1365
1386
  {
1366
- className: cx2(
1387
+ className: cn(
1367
1388
  "inline-flex items-center gap-1 rounded-full py-1 pl-2.5 pr-1.5 text-card-title",
1368
1389
  missed ? "bg-status-danger/15 text-text-danger" : "bg-subtle text-text-primary"
1369
1390
  ),
@@ -1466,7 +1487,7 @@ function SearchBar({
1466
1487
  {
1467
1488
  size: 14,
1468
1489
  "aria-hidden": "true",
1469
- className: cx2("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1490
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1470
1491
  }
1471
1492
  )
1472
1493
  ]
@@ -1555,7 +1576,8 @@ function SearchBar({
1555
1576
  ]
1556
1577
  }
1557
1578
  );
1558
- }
1579
+ });
1580
+ SearchBar.displayName = "SearchBar";
1559
1581
  function Divider() {
1560
1582
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "my-2.5 border-t border-border-default", "aria-hidden": "true" });
1561
1583
  }
@@ -1569,7 +1591,7 @@ function ModeRow({
1569
1591
  onSelect,
1570
1592
  testId
1571
1593
  }) {
1572
- const descId = (0, import_react4.useId)();
1594
+ const descId = (0, import_react5.useId)();
1573
1595
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1574
1596
  "div",
1575
1597
  {
@@ -1624,12 +1646,12 @@ function RadioOption({
1624
1646
  },
1625
1647
  role: "radio",
1626
1648
  "aria-checked": checked,
1627
- className: "flex items-center gap-1.5 text-dense font-medium text-text-primary",
1649
+ className: "flex items-center gap-1.5 text-dense font-medium text-text-primary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
1628
1650
  children: [
1629
1651
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1630
1652
  "span",
1631
1653
  {
1632
- className: cx2(
1654
+ className: cn(
1633
1655
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-2 transition-colors",
1634
1656
  checked ? "border-brand-primaryAction" : "border-border-interactive"
1635
1657
  ),
@@ -1642,10 +1664,10 @@ function RadioOption({
1642
1664
  );
1643
1665
  }
1644
1666
  function RowInfoTip({ text }) {
1645
- const [open, setOpen] = (0, import_react4.useState)(false);
1646
- const id = (0, import_react4.useId)();
1647
- const ref = (0, import_react4.useRef)(null);
1648
- (0, import_react4.useEffect)(() => {
1667
+ const [open, setOpen] = (0, import_react5.useState)(false);
1668
+ const id = (0, import_react5.useId)();
1669
+ const ref = (0, import_react5.useRef)(null);
1670
+ (0, import_react5.useEffect)(() => {
1649
1671
  if (!open) return;
1650
1672
  const onDown = (e) => {
1651
1673
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -1682,7 +1704,7 @@ function RowInfoTip({ text }) {
1682
1704
  }
1683
1705
 
1684
1706
  // src/SectionRail.tsx
1685
- var import_react5 = require("react");
1707
+ var import_react6 = require("react");
1686
1708
  var import_lucide_react8 = require("lucide-react");
1687
1709
  var import_jsx_runtime10 = require("react/jsx-runtime");
1688
1710
  function SectionRail({
@@ -1691,13 +1713,15 @@ function SectionRail({
1691
1713
  subtitle,
1692
1714
  viewAllLabel,
1693
1715
  viewAllHref,
1694
- children
1716
+ children,
1717
+ className,
1718
+ testIdPrefix
1695
1719
  }) {
1696
- const scrollRef = (0, import_react5.useRef)(null);
1720
+ const scrollRef = (0, import_react6.useRef)(null);
1697
1721
  const scroll = (direction) => {
1698
1722
  scrollRef.current?.scrollBy({ left: direction * 320, behavior: "smooth" });
1699
1723
  };
1700
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "flex flex-col gap-4", children: [
1724
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: cn("flex flex-col gap-4", className), "data-testid": testIdPrefix, children: [
1701
1725
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between", children: [
1702
1726
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
1703
1727
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -1727,7 +1751,7 @@ function SectionRail({
1727
1751
  type: "button",
1728
1752
  onClick: () => scroll(-1),
1729
1753
  "aria-label": "Previous",
1730
- className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary sm:flex lg:hidden",
1754
+ className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus sm:flex lg:hidden",
1731
1755
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react8.ChevronLeft, { size: 16 })
1732
1756
  }
1733
1757
  ),
@@ -1737,7 +1761,7 @@ function SectionRail({
1737
1761
  type: "button",
1738
1762
  onClick: () => scroll(1),
1739
1763
  "aria-label": "Next",
1740
- className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary sm:flex lg:hidden",
1764
+ className: "hidden h-10 w-10 items-center justify-center rounded-control border border-border-default text-text-secondary transition-colors hover:bg-subtle hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus sm:flex lg:hidden",
1741
1765
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react8.ChevronRight, { size: 16 })
1742
1766
  }
1743
1767
  )
@@ -1755,18 +1779,15 @@ function SectionRail({
1755
1779
  }
1756
1780
 
1757
1781
  // src/DataScopeFilter.tsx
1758
- var import_react6 = require("react");
1782
+ var import_react7 = require("react");
1759
1783
  var import_lucide_react9 = require("lucide-react");
1760
1784
  var import_jsx_runtime11 = require("react/jsx-runtime");
1761
1785
  var FINAL_ONLY_TEXT = "Trims time periods to data that has finalized across the selected media formats. Some formats (e.g. Network TV and Cinema) finalize later, so the most recent periods may still change. Turn on for stable, report-ready numbers.";
1762
- function cx3(...classes) {
1763
- return classes.filter(Boolean).join(" ");
1764
- }
1765
- function DataScopeFilter({ value, onChange, align = "right" }) {
1766
- const [open, setOpen] = (0, import_react6.useState)(false);
1767
- const ref = (0, import_react6.useRef)(null);
1786
+ function DataScopeFilter({ value, onChange, align = "right", className, testIdPrefix }) {
1787
+ const [open, setOpen] = (0, import_react7.useState)(false);
1788
+ const ref = (0, import_react7.useRef)(null);
1768
1789
  const display = value ? "Final only" : "All";
1769
- (0, import_react6.useEffect)(() => {
1790
+ (0, import_react7.useEffect)(() => {
1770
1791
  if (!open) return;
1771
1792
  const onDown = (e) => {
1772
1793
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -1783,13 +1804,14 @@ function DataScopeFilter({ value, onChange, align = "right" }) {
1783
1804
  onChange(v);
1784
1805
  setOpen(false);
1785
1806
  };
1786
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative", ref, children: [
1807
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
1787
1808
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1788
1809
  "button",
1789
1810
  {
1790
1811
  type: "button",
1791
1812
  onClick: () => setOpen((o) => !o),
1792
1813
  "aria-expanded": open,
1814
+ "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
1793
1815
  className: chipTriggerClass(),
1794
1816
  children: [
1795
1817
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChipContent, { caption: "Data", value: display }),
@@ -1798,7 +1820,7 @@ function DataScopeFilter({ value, onChange, align = "right" }) {
1798
1820
  {
1799
1821
  size: 14,
1800
1822
  "aria-hidden": "true",
1801
- className: cx3("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1823
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1802
1824
  }
1803
1825
  )
1804
1826
  ]
@@ -1809,7 +1831,8 @@ function DataScopeFilter({ value, onChange, align = "right" }) {
1809
1831
  {
1810
1832
  role: "group",
1811
1833
  "aria-label": "Data",
1812
- className: cx3(
1834
+ "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
1835
+ className: cn(
1813
1836
  "absolute top-[calc(100%+8px)] z-30 min-w-[220px] overflow-hidden rounded-card border border-border-default bg-surface p-1 shadow-overlay",
1814
1837
  align === "right" ? "right-0" : "left-0"
1815
1838
  ),
@@ -1833,13 +1856,13 @@ function Option({
1833
1856
  type: "button",
1834
1857
  "aria-pressed": selected,
1835
1858
  onClick,
1836
- className: cx3(
1837
- "flex items-center gap-2 rounded-control px-2.5 py-2 text-left text-dense transition-colors hover:bg-subtle",
1859
+ className: cn(
1860
+ "flex items-center gap-2 rounded-control px-2.5 py-2 text-left text-dense transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
1838
1861
  hint ? "flex-1" : "w-full",
1839
1862
  selected ? "font-semibold text-text-primary" : "text-text-secondary"
1840
1863
  ),
1841
1864
  children: [
1842
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react9.Check, { size: 14, "aria-hidden": "true", className: cx3("shrink-0 text-brand-primaryAction", !selected && "invisible") }),
1865
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react9.Check, { size: 14, "aria-hidden": "true", className: cn("shrink-0 text-brand-primaryAction", !selected && "invisible") }),
1843
1866
  label
1844
1867
  ]
1845
1868
  }
@@ -1852,7 +1875,7 @@ function Option({
1852
1875
  }
1853
1876
 
1854
1877
  // src/SelectFilter.tsx
1855
- var import_react7 = require("react");
1878
+ var import_react8 = require("react");
1856
1879
  var import_react_dom2 = require("react-dom");
1857
1880
  var import_lucide_react10 = require("lucide-react");
1858
1881
 
@@ -1879,9 +1902,6 @@ function MenuError({ onRetry }) {
1879
1902
 
1880
1903
  // src/SelectFilter.tsx
1881
1904
  var import_jsx_runtime13 = require("react/jsx-runtime");
1882
- function cx4(...classes) {
1883
- return classes.filter(Boolean).join(" ");
1884
- }
1885
1905
  function slug4(value) {
1886
1906
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
1887
1907
  }
@@ -1913,12 +1933,12 @@ function SelectFilter({
1913
1933
  renderIcon
1914
1934
  }) {
1915
1935
  const sm = size === "sm";
1916
- const [open, setOpen] = (0, import_react7.useState)(false);
1917
- const [pos, setPos] = (0, import_react7.useState)(null);
1918
- const ref = (0, import_react7.useRef)(null);
1919
- const popoverRef = (0, import_react7.useRef)(null);
1920
- const close = (0, import_react7.useCallback)(() => setOpen(false), []);
1921
- const reposition = (0, import_react7.useCallback)(() => {
1936
+ const [open, setOpen] = (0, import_react8.useState)(false);
1937
+ const [pos, setPos] = (0, import_react8.useState)(null);
1938
+ const ref = (0, import_react8.useRef)(null);
1939
+ const popoverRef = (0, import_react8.useRef)(null);
1940
+ const close = (0, import_react8.useCallback)(() => setOpen(false), []);
1941
+ const reposition = (0, import_react8.useCallback)(() => {
1922
1942
  if (!ref.current) return;
1923
1943
  const r = ref.current.getBoundingClientRect();
1924
1944
  const h = Math.min(options.length * 36 + 8, 288);
@@ -1929,11 +1949,11 @@ function SelectFilter({
1929
1949
  width: r.width
1930
1950
  });
1931
1951
  }, [align, options.length]);
1932
- (0, import_react7.useLayoutEffect)(() => {
1952
+ (0, import_react8.useLayoutEffect)(() => {
1933
1953
  if (!open) return;
1934
1954
  reposition();
1935
1955
  }, [open, reposition]);
1936
- (0, import_react7.useEffect)(() => {
1956
+ (0, import_react8.useEffect)(() => {
1937
1957
  if (!open) return;
1938
1958
  const onKey = (e) => e.key === "Escape" && close();
1939
1959
  const onClick = (e) => {
@@ -1964,7 +1984,7 @@ function SelectFilter({
1964
1984
  " ",
1965
1985
  valueContent
1966
1986
  ] }) : valueContent;
1967
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cx4("relative", fullWidth && "w-full"), ref, children: [
1987
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cn("relative", fullWidth && "w-full"), ref, "data-testid": testIdPrefix, children: [
1968
1988
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1969
1989
  "button",
1970
1990
  {
@@ -1975,7 +1995,7 @@ function SelectFilter({
1975
1995
  "aria-haspopup": "listbox",
1976
1996
  "aria-label": sm && !inlineCaption ? caption : void 0,
1977
1997
  disabled,
1978
- className: cx4(
1998
+ className: cn(
1979
1999
  sm ? "flex h-8 items-center gap-1.5 rounded-control border border-border-strong bg-input pl-2.5 pr-2 text-dense font-medium text-text-primary transition-colors hover:bg-subtle focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus" : chipTriggerClass(),
1980
2000
  "disabled:pointer-events-none disabled:opacity-40",
1981
2001
  fullWidth && "w-full justify-between",
@@ -1988,7 +2008,7 @@ function SelectFilter({
1988
2008
  {
1989
2009
  size: 14,
1990
2010
  "aria-hidden": "true",
1991
- className: cx4("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
2011
+ className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180")
1992
2012
  }
1993
2013
  )
1994
2014
  ]
@@ -2001,7 +2021,7 @@ function SelectFilter({
2001
2021
  ref: popoverRef,
2002
2022
  "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
2003
2023
  style: { position: "fixed", top: pos.top, left: pos.left, right: pos.right, width: fullWidth ? pos.width : void 0 },
2004
- className: cx4(
2024
+ className: cn(
2005
2025
  "z-[65] flex flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-overlay",
2006
2026
  !fullWidth && (sm ? "w-max min-w-28 max-w-72" : "w-56")
2007
2027
  ),
@@ -2020,14 +2040,14 @@ function SelectFilter({
2020
2040
  onChange(o);
2021
2041
  close();
2022
2042
  },
2023
- className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
2043
+ className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
2024
2044
  children: [
2025
2045
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-brand-primaryAction", children: selected && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react10.Check, { size: 15, strokeWidth: 3 }) }),
2026
2046
  renderIcon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(OptionIcon, { children: renderIcon(o) }),
2027
2047
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2028
2048
  "span",
2029
2049
  {
2030
- className: cx4("flex-1 text-sm", selected ? "font-semibold text-text-primary" : "text-text-primary"),
2050
+ className: cn("flex-1 text-sm", selected ? "font-semibold text-text-primary" : "text-text-primary"),
2031
2051
  children: o
2032
2052
  }
2033
2053
  )
@@ -2044,19 +2064,20 @@ function SelectFilter({
2044
2064
  }
2045
2065
 
2046
2066
  // src/Card.tsx
2047
- var import_react8 = require("react");
2067
+ var import_react9 = require("react");
2048
2068
  var import_jsx_runtime14 = require("react/jsx-runtime");
2049
- var Card = (0, import_react8.forwardRef)(function Card2({ staticCard, title, titleAs: TitleTag = "h3", subtitle, action, className, children, ...rest }, ref) {
2069
+ var Card = (0, import_react9.forwardRef)(function Card2({ staticCard, title, titleAs: TitleTag = "h3", subtitle, action, className, testIdPrefix, children, ...rest }, ref) {
2050
2070
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2051
2071
  "article",
2052
2072
  {
2053
2073
  ref,
2054
- className: [
2074
+ className: cn(
2055
2075
  "flex h-full flex-col overflow-hidden rounded-card border border-border-default bg-surface shadow-raised",
2056
2076
  // Interactive hover: deeper drop shadow only -- no elevation/transform.
2057
2077
  !staticCard && "group transition-shadow hover:shadow-overlay",
2058
2078
  className
2059
- ].filter(Boolean).join(" "),
2079
+ ),
2080
+ "data-testid": testIdPrefix,
2060
2081
  ...rest,
2061
2082
  children: title ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-1 flex-col p-card-padding", children: [
2062
2083
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-start justify-between gap-2", children: [
@@ -2080,7 +2101,7 @@ var NO_RESULTS_BODY = "Your filters may be too narrow, conflict with each other,
2080
2101
  function noResultsBody(workspaceName) {
2081
2102
  return workspaceName ? `Nothing in the \u201C${workspaceName}\u201D workspace matches. ${NO_RESULTS_BODY}` : NO_RESULTS_BODY;
2082
2103
  }
2083
- var PRIMARY_ACTION_CLASS = "rounded-control bg-brand-primaryAction px-3.5 py-2 text-dense font-semibold text-brand-onprimary transition-colors hover:opacity-90";
2104
+ var PRIMARY_ACTION_CLASS = "rounded-control bg-brand-primaryAction px-3.5 py-2 text-dense font-semibold text-brand-onprimary transition-colors hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus";
2084
2105
  var QUIET_ACTION_CLASS = "rounded-control text-dense font-medium text-text-link transition-colors hover:underline focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-border-focus";
2085
2106
  function NoResultsEmptyState({
2086
2107
  title = NO_RESULTS_TITLE,
@@ -2090,13 +2111,14 @@ function NoResultsEmptyState({
2090
2111
  onClearFilters,
2091
2112
  onEditFilters,
2092
2113
  actions,
2114
+ className,
2093
2115
  testIdPrefix
2094
2116
  }) {
2095
2117
  const bodyText = body ?? noResultsBody(workspaceName);
2096
2118
  const showClear = hasFilters !== false && Boolean(onClearFilters);
2097
2119
  const showEdit = Boolean(onEditFilters);
2098
2120
  const hasActions = showClear || showEdit || Boolean(actions && actions.length > 0);
2099
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col items-center justify-center gap-3 text-center", "data-testid": testIdPrefix, children: [
2121
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("flex flex-col items-center justify-center gap-3 text-center", className), "data-testid": testIdPrefix, children: [
2100
2122
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex h-11 w-11 items-center justify-center rounded-full bg-subtle text-text-tertiary", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react11.FilterX, { size: 20, "aria-hidden": "true" }) }),
2101
2123
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h2", { className: "text-base font-semibold text-text-primary", children: title }),
2102
2124
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "max-w-[420px] text-dense leading-relaxed text-text-secondary", children: bodyText }),
@@ -2136,14 +2158,21 @@ function NoResultsEmptyState({
2136
2158
  }
2137
2159
 
2138
2160
  // src/WorkspaceSelectedCard.tsx
2139
- var import_react9 = require("react");
2161
+ var import_react10 = require("react");
2140
2162
  var import_lucide_react12 = require("lucide-react");
2141
2163
  var import_jsx_runtime16 = require("react/jsx-runtime");
2142
- function cx5(...parts) {
2143
- return parts.filter(Boolean).join(" ");
2144
- }
2145
- function WorkspaceSelectedCard({ groups, testIdPrefix }) {
2146
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("aside", { className: "sticky top-4 flex min-w-0 flex-col gap-4 self-start rounded-card border border-border-default bg-surface px-5 pb-5 pt-4 shadow-raised sm:px-6 sm:pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col divide-y divide-border-default", children: groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SummaryGroupItem, { group: g, testIdPrefix }, g.id)) }) });
2164
+ function WorkspaceSelectedCard({ groups, className, testIdPrefix }) {
2165
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2166
+ "aside",
2167
+ {
2168
+ className: cn(
2169
+ "sticky top-4 flex min-w-0 flex-col gap-4 self-start rounded-card border border-border-default bg-surface px-5 pb-5 pt-4 shadow-raised sm:px-6 sm:pb-6",
2170
+ className
2171
+ ),
2172
+ "data-testid": testIdPrefix,
2173
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex flex-col divide-y divide-border-default", children: groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SummaryGroupItem, { group: g, testIdPrefix }, g.id)) })
2174
+ }
2175
+ );
2147
2176
  }
2148
2177
  function SummaryGroupItem({
2149
2178
  group,
@@ -2153,9 +2182,9 @@ function SummaryGroupItem({
2153
2182
  const ownCount = group.items.length;
2154
2183
  const subCount = (group.subGroups ?? []).reduce((n, sg) => n + sg.items.length, 0);
2155
2184
  const expandCount = ownCount + subCount;
2156
- const [open, setOpen] = (0, import_react9.useState)(expandCount > 0);
2157
- const wasEmpty = (0, import_react9.useRef)(expandCount === 0);
2158
- (0, import_react9.useEffect)(() => {
2185
+ const [open, setOpen] = (0, import_react10.useState)(expandCount > 0);
2186
+ const wasEmpty = (0, import_react10.useRef)(expandCount === 0);
2187
+ (0, import_react10.useEffect)(() => {
2159
2188
  if (wasEmpty.current && expandCount > 0) setOpen(true);
2160
2189
  else if (expandCount === 0) setOpen(false);
2161
2190
  wasEmpty.current = expandCount === 0;
@@ -2168,17 +2197,17 @@ function SummaryGroupItem({
2168
2197
  onClick: () => setOpen((v) => !v),
2169
2198
  "aria-expanded": open,
2170
2199
  "data-testid": testIdPrefix && `${testIdPrefix}-group-${group.id}`,
2171
- className: "flex w-full min-w-0 items-center gap-2 text-left",
2200
+ className: "flex w-full min-w-0 items-center gap-2 text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
2172
2201
  children: [
2173
2202
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2174
2203
  import_lucide_react12.ChevronDown,
2175
2204
  {
2176
2205
  size: 14,
2177
2206
  "aria-hidden": "true",
2178
- className: cx5("shrink-0 text-text-secondary transition-transform", !open && "-rotate-90")
2207
+ className: cn("shrink-0 text-text-secondary transition-transform", !open && "-rotate-90")
2179
2208
  }
2180
2209
  ),
2181
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cx5("truncate font-semibold text-text-primary", nested ? "text-xs" : "text-dense"), children: group.label }),
2210
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cn("truncate font-semibold text-text-primary", nested ? "text-xs" : "text-dense"), children: group.label }),
2182
2211
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "shrink-0 rounded-full bg-subtle px-1.5 py-0.5 text-micro font-semibold text-text-secondary", children: ownCount })
2183
2212
  ]
2184
2213
  }
@@ -2200,7 +2229,7 @@ function SummaryGroupItem({
2200
2229
  type: "button",
2201
2230
  "aria-label": `Remove ${item.name}`,
2202
2231
  onClick: () => group.onRemove(item.id),
2203
- className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-control text-text-secondary hover:bg-subtle hover:text-text-danger",
2232
+ className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-control text-text-secondary hover:bg-subtle hover:text-text-danger focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
2204
2233
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react12.X, { size: 12, "aria-hidden": "true" })
2205
2234
  }
2206
2235
  )
@@ -2214,7 +2243,7 @@ function SummaryGroupItem({
2214
2243
  type: "button",
2215
2244
  onClick: group.onRemoveAll,
2216
2245
  "data-testid": testIdPrefix && `${testIdPrefix}-remove-all-${group.id}`,
2217
- className: "mt-0.5 self-start text-micro font-medium text-text-link hover:underline",
2246
+ className: "mt-0.5 self-start text-micro font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
2218
2247
  children: "Remove all"
2219
2248
  }
2220
2249
  )
@@ -2234,10 +2263,12 @@ var LEGEND_WIDTHS = [58, 44, 66, 50, 38, 62, 46, 54];
2234
2263
  function AxisFrame({
2235
2264
  height,
2236
2265
  xTicks,
2237
- children
2266
+ children,
2267
+ className,
2268
+ testIdPrefix
2238
2269
  }) {
2239
2270
  const gutter = xTicks > 0 ? X_AXIS_H : 0;
2240
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-full", style: { height }, role: "presentation", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative h-full w-full", children: [
2271
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("w-full", className), style: { height }, role: "presentation", "aria-hidden": "true", "data-testid": testIdPrefix, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative h-full w-full", children: [
2241
2272
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "absolute inset-y-0 right-0", style: { left: Y_AXIS_W, bottom: gutter }, children: [
2242
2273
  GRID_ROWS.map((pct) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2243
2274
  "div",
@@ -2294,8 +2325,8 @@ function BlankLegend({ rows, reverse = false }) {
2294
2325
  // src/BarChartPlaceholder.tsx
2295
2326
  var import_jsx_runtime18 = require("react/jsx-runtime");
2296
2327
  var BAR_PROFILE = [92, 86, 76, 65, 57, 40, 30, 24, 18, 13];
2297
- function BarChartPlaceholder({ height = 220 }) {
2298
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AxisFrame, { height, xTicks: BAR_PROFILE.length, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-full w-full items-end gap-2", children: BAR_PROFILE.map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1 rounded-t-small bg-subtle", style: { height: `${pct}%` } }, i)) }) });
2328
+ function BarChartPlaceholder({ height = 220, className, testIdPrefix }) {
2329
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AxisFrame, { height, xTicks: BAR_PROFILE.length, className, testIdPrefix, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-full w-full items-end gap-2", children: BAR_PROFILE.map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1 rounded-t-small bg-subtle", style: { height: `${pct}%` } }, i)) }) });
2299
2330
  }
2300
2331
 
2301
2332
  // src/LineChartPlaceholder.tsx
@@ -2307,9 +2338,9 @@ var LINE_SERIES = [
2307
2338
  [86, 82, 84, 77, 79, 71, 73, 66, 68, 61]
2308
2339
  ];
2309
2340
  var LINE_FORECAST_FROM = 7;
2310
- function LineChartPlaceholder({ height = 280 }) {
2341
+ function LineChartPlaceholder({ height = 280, className, testIdPrefix }) {
2311
2342
  const toPath = (pts, from, to) => pts.slice(from, to).map((y, i) => `${(i + from) / (pts.length - 1) * 100},${y}`).join(" ");
2312
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AxisFrame, { height, xTicks: LINE_SERIES[0].length, children: [
2343
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(AxisFrame, { height, xTicks: LINE_SERIES[0].length, className, testIdPrefix, children: [
2313
2344
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { viewBox: "0 0 100 100", preserveAspectRatio: "none", className: "absolute inset-0 h-full w-full", children: LINE_SERIES.map((pts, s) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("g", { children: [
2314
2345
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2315
2346
  "polyline",
@@ -2357,9 +2388,9 @@ function LineChartPlaceholder({ height = 280 }) {
2357
2388
  // src/PieChartPlaceholder.tsx
2358
2389
  var import_jsx_runtime20 = require("react/jsx-runtime");
2359
2390
  var PIE_SEAMS = [0, 115, 180, 230, 262, 288, 310, 332];
2360
- function PieChartPlaceholder({ height = 220, legendRows = 8 }) {
2391
+ function PieChartPlaceholder({ height = 220, legendRows = 8, className, testIdPrefix }) {
2361
2392
  const r = 45;
2362
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex w-full items-center gap-3", style: { height }, role: "presentation", "aria-hidden": "true", children: [
2393
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: cn("flex w-full items-center gap-3", className), style: { height }, role: "presentation", "aria-hidden": "true", "data-testid": testIdPrefix, children: [
2363
2394
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex h-full items-center justify-center", style: { width: "60%" }, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { viewBox: "0 0 100 100", className: "h-full", style: { aspectRatio: "1 / 1" }, children: [
2364
2395
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: "50", cy: "50", r, fill: "var(--mr-color-subtle)" }),
2365
2396
  PIE_SEAMS.map((deg) => {
@@ -2394,7 +2425,9 @@ function StackedColumnPlaceholder({
2394
2425
  height = 220,
2395
2426
  width = 96,
2396
2427
  legendRows = 4,
2397
- axis = false
2428
+ axis = false,
2429
+ className,
2430
+ testIdPrefix
2398
2431
  }) {
2399
2432
  const column = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex h-full flex-col overflow-hidden rounded-control bg-subtle", style: { width }, children: columnBands(legendRows).map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2400
2433
  "div",
@@ -2408,19 +2441,16 @@ function StackedColumnPlaceholder({
2408
2441
  },
2409
2442
  i
2410
2443
  )) });
2411
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-full gap-4", style: { height }, role: "presentation", "aria-hidden": "true", children: [
2444
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cn("flex w-full gap-4", className), style: { height }, role: "presentation", "aria-hidden": "true", "data-testid": testIdPrefix, children: [
2412
2445
  axis ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { style: { width: "55%" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AxisFrame, { height, xTicks: 0, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex h-full items-stretch justify-center", children: column }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "flex items-stretch py-1", children: column }),
2413
2446
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(BlankLegend, { rows: legendRows, reverse: !axis })
2414
2447
  ] });
2415
2448
  }
2416
2449
 
2417
2450
  // src/Tooltip.tsx
2418
- var import_react10 = require("react");
2451
+ var import_react11 = require("react");
2419
2452
  var import_react_dom3 = require("react-dom");
2420
2453
  var import_jsx_runtime22 = require("react/jsx-runtime");
2421
- function cx6(...parts) {
2422
- return parts.filter(Boolean).join(" ");
2423
- }
2424
2454
  function addDescribedBy(el, id) {
2425
2455
  const ids = (el.getAttribute("aria-describedby") ?? "").split(" ").filter(Boolean);
2426
2456
  if (!ids.includes(id)) el.setAttribute("aria-describedby", [...ids, id].join(" "));
@@ -2456,18 +2486,18 @@ function Tooltip({
2456
2486
  variant = "surface",
2457
2487
  testIdPrefix
2458
2488
  }) {
2459
- const [anchor, setAnchor] = (0, import_react10.useState)(null);
2460
- const [boxWidth, setBoxWidth] = (0, import_react10.useState)(null);
2461
- const ref = (0, import_react10.useRef)(null);
2462
- const boxRef = (0, import_react10.useRef)(null);
2463
- const hideTimer = (0, import_react10.useRef)(null);
2464
- const showTimer = (0, import_react10.useRef)(null);
2465
- const exitTimer = (0, import_react10.useRef)(null);
2466
- const [shown, setShown] = (0, import_react10.useState)(false);
2467
- const openRef = (0, import_react10.useRef)(false);
2468
- const mountedRef = (0, import_react10.useRef)(false);
2469
- const id = (0, import_react10.useId)();
2470
- const describedRef = (0, import_react10.useRef)(null);
2489
+ const [anchor, setAnchor] = (0, import_react11.useState)(null);
2490
+ const [boxWidth, setBoxWidth] = (0, import_react11.useState)(null);
2491
+ const ref = (0, import_react11.useRef)(null);
2492
+ const boxRef = (0, import_react11.useRef)(null);
2493
+ const hideTimer = (0, import_react11.useRef)(null);
2494
+ const showTimer = (0, import_react11.useRef)(null);
2495
+ const exitTimer = (0, import_react11.useRef)(null);
2496
+ const [shown, setShown] = (0, import_react11.useState)(false);
2497
+ const openRef = (0, import_react11.useRef)(false);
2498
+ const mountedRef = (0, import_react11.useRef)(false);
2499
+ const id = (0, import_react11.useId)();
2500
+ const describedRef = (0, import_react11.useRef)(null);
2471
2501
  const clearHideTimer = () => {
2472
2502
  if (hideTimer.current) {
2473
2503
  clearTimeout(hideTimer.current);
@@ -2486,7 +2516,7 @@ function Tooltip({
2486
2516
  exitTimer.current = null;
2487
2517
  }
2488
2518
  };
2489
- (0, import_react10.useEffect)(
2519
+ (0, import_react11.useEffect)(
2490
2520
  () => () => {
2491
2521
  clearHideTimer();
2492
2522
  clearShowTimer();
@@ -2560,7 +2590,7 @@ function Tooltip({
2560
2590
  clearHideTimer();
2561
2591
  hideTimer.current = setTimeout(hideNow, 120);
2562
2592
  };
2563
- (0, import_react10.useEffect)(() => {
2593
+ (0, import_react11.useEffect)(() => {
2564
2594
  if (!anchorRef) return;
2565
2595
  const el = anchorRef.current;
2566
2596
  if (!el) return;
@@ -2575,13 +2605,13 @@ function Tooltip({
2575
2605
  el.removeEventListener("blur", hide);
2576
2606
  };
2577
2607
  }, [anchorRef, placement, delay]);
2578
- (0, import_react10.useEffect)(() => {
2608
+ (0, import_react11.useEffect)(() => {
2579
2609
  if (!anchor) return;
2580
2610
  const onKey = (e) => e.key === "Escape" && hideNow();
2581
2611
  window.addEventListener("keydown", onKey);
2582
2612
  return () => window.removeEventListener("keydown", onKey);
2583
2613
  }, [anchor]);
2584
- (0, import_react10.useLayoutEffect)(() => {
2614
+ (0, import_react11.useLayoutEffect)(() => {
2585
2615
  if (!anchor) return;
2586
2616
  const el = boxRef.current;
2587
2617
  if (!el) return;
@@ -2617,7 +2647,7 @@ function Tooltip({
2617
2647
  onMouseEnter: interactive ? keepOpen : void 0,
2618
2648
  onMouseLeave: interactive ? hide : void 0,
2619
2649
  onTransitionEnd: onBoxTransitionEnd,
2620
- className: cx6(
2650
+ className: cn(
2621
2651
  "fixed z-[90] w-max max-w-xs whitespace-normal break-words px-2.5 py-1.5 text-xs leading-snug",
2622
2652
  // Fade in/out. The sys duration token rather than a ref one:
2623
2653
  // it is what Button's hover/press transition uses, and a
@@ -2642,6 +2672,7 @@ function Tooltip({
2642
2672
  {
2643
2673
  ref,
2644
2674
  className,
2675
+ "data-testid": testIdPrefix,
2645
2676
  onMouseEnter: show,
2646
2677
  onMouseLeave: hide,
2647
2678
  onFocus: (e) => {
@@ -2661,9 +2692,11 @@ function Tooltip({
2661
2692
  var import_jsx_runtime23 = require("react/jsx-runtime");
2662
2693
  function AdvertiserNoResults({
2663
2694
  query,
2664
- hint = "Try checking your spelling or searching for a broader brand name."
2695
+ hint = "Try checking your spelling or searching for a broader brand name.",
2696
+ className,
2697
+ testIdPrefix
2665
2698
  }) {
2666
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex flex-col items-center gap-1.5 px-4 py-8 text-center", children: [
2699
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: cn("flex flex-col items-center gap-1.5 px-4 py-8 text-center", className), "data-testid": testIdPrefix, children: [
2667
2700
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("p", { className: "text-dense font-medium text-text-primary", children: [
2668
2701
  "No results found for \u201C",
2669
2702
  query,
@@ -2676,14 +2709,17 @@ function AdvertiserNoResults({
2676
2709
  // src/SelectAllVisible.tsx
2677
2710
  var import_lucide_react13 = require("lucide-react");
2678
2711
  var import_jsx_runtime24 = require("react/jsx-runtime");
2679
- function SelectAllVisible({ count, allSelected, onToggle, testIdPrefix }) {
2712
+ function SelectAllVisible({ count, allSelected, onToggle, className, testIdPrefix }) {
2680
2713
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2681
2714
  "button",
2682
2715
  {
2683
2716
  type: "button",
2684
2717
  "data-testid": testIdPrefix && `${testIdPrefix}-select-all-visible`,
2685
2718
  onClick: onToggle,
2686
- className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle",
2719
+ className: cn(
2720
+ "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs font-semibold text-text-link transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
2721
+ className
2722
+ ),
2687
2723
  children: [
2688
2724
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react13.ListChecks, { size: 14, "aria-hidden": "true" }),
2689
2725
  allSelected ? `Deselect ${count} visible` : `Select all ${count} visible`
@@ -2695,12 +2731,9 @@ function SelectAllVisible({ count, allSelected, onToggle, testIdPrefix }) {
2695
2731
  // src/SelectedSection.tsx
2696
2732
  var import_lucide_react14 = require("lucide-react");
2697
2733
  var import_jsx_runtime25 = require("react/jsx-runtime");
2698
- function cx7(...parts) {
2699
- return parts.filter(Boolean).join(" ");
2700
- }
2701
- function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
2734
+ function SelectedSection({ count, open, onToggle, children, className, testIdPrefix }) {
2702
2735
  if (count === 0) return null;
2703
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col", children: [
2736
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("flex flex-col", className), "data-testid": testIdPrefix, children: [
2704
2737
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2705
2738
  "button",
2706
2739
  {
@@ -2708,9 +2741,9 @@ function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
2708
2741
  "data-testid": testIdPrefix && `${testIdPrefix}-selected-toggle`,
2709
2742
  onClick: onToggle,
2710
2743
  "aria-expanded": open,
2711
- className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary",
2744
+ className: "flex w-full items-center gap-1.5 rounded-control px-2 py-1 text-left text-micro font-semibold uppercase tracking-wide text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
2712
2745
  children: [
2713
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react14.ChevronDown, { size: 13, "aria-hidden": "true", className: cx7("transition-transform", !open && "-rotate-90") }),
2746
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react14.ChevronDown, { size: 13, "aria-hidden": "true", className: cn("transition-transform", !open && "-rotate-90") }),
2714
2747
  "Selected (",
2715
2748
  count,
2716
2749
  ")"
@@ -2722,12 +2755,12 @@ function SelectedSection({ count, open, onToggle, children, testIdPrefix }) {
2722
2755
  }
2723
2756
 
2724
2757
  // src/SelectionPicker.tsx
2725
- var import_react12 = require("react");
2758
+ var import_react13 = require("react");
2726
2759
  var import_react_dom4 = require("react-dom");
2727
2760
  var import_lucide_react15 = require("lucide-react");
2728
2761
 
2729
2762
  // src/Tabs.tsx
2730
- var import_react11 = require("react");
2763
+ var import_react12 = require("react");
2731
2764
  var import_jsx_runtime26 = require("react/jsx-runtime");
2732
2765
  function arrowKeys(e, row) {
2733
2766
  if (!row || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) return;
@@ -2738,14 +2771,15 @@ function arrowKeys(e, row) {
2738
2771
  items[next]?.focus();
2739
2772
  items[next]?.click();
2740
2773
  }
2741
- function Tabs({ items, value, onChange, idPrefix = "tabs", className, ...rest }) {
2742
- const row = (0, import_react11.useRef)(null);
2774
+ function Tabs({ items, value, onChange, idPrefix = "tabs", className, testIdPrefix, ...rest }) {
2775
+ const row = (0, import_react12.useRef)(null);
2743
2776
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2744
2777
  "div",
2745
2778
  {
2746
2779
  ref: row,
2747
2780
  role: "tablist",
2748
2781
  "aria-label": rest["aria-label"],
2782
+ "data-testid": testIdPrefix,
2749
2783
  onKeyDown: (e) => arrowKeys(e, row.current),
2750
2784
  className: cn("flex gap-6 border-b border-border-default", className),
2751
2785
  children: items.map((item) => {
@@ -2756,6 +2790,7 @@ function Tabs({ items, value, onChange, idPrefix = "tabs", className, ...rest })
2756
2790
  type: "button",
2757
2791
  role: "tab",
2758
2792
  id: `${idPrefix}-tab-${item.value}`,
2793
+ "data-testid": testIdPrefix && `${testIdPrefix}-tab-${item.value}`,
2759
2794
  "aria-controls": `${idPrefix}-panel-${item.value}`,
2760
2795
  "aria-selected": on,
2761
2796
  tabIndex: on ? 0 : -1,
@@ -2782,15 +2817,17 @@ function SegmentedControl({
2782
2817
  onChange,
2783
2818
  size = "sm",
2784
2819
  className,
2820
+ testIdPrefix,
2785
2821
  ...rest
2786
2822
  }) {
2787
- const row = (0, import_react11.useRef)(null);
2823
+ const row = (0, import_react12.useRef)(null);
2788
2824
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2789
2825
  "div",
2790
2826
  {
2791
2827
  ref: row,
2792
2828
  role: "radiogroup",
2793
2829
  "aria-label": rest["aria-label"],
2830
+ "data-testid": testIdPrefix,
2794
2831
  onKeyDown: (e) => arrowKeys(e, row.current),
2795
2832
  className: cn("inline-flex w-fit items-stretch gap-0.5 rounded-full bg-subtle p-1", size === "md" ? "h-10" : "h-8", className),
2796
2833
  children: options.map((o) => {
@@ -2803,7 +2840,7 @@ function SegmentedControl({
2803
2840
  "aria-checked": on,
2804
2841
  tabIndex: on ? 0 : -1,
2805
2842
  onClick: () => onChange(o.value),
2806
- "data-testid": o.testId,
2843
+ "data-testid": o.testId ?? (testIdPrefix && `${testIdPrefix}-option-${o.value}`),
2807
2844
  className: cn(
2808
2845
  "rounded-full px-3 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-border-focus",
2809
2846
  size === "md" ? "text-sm" : "text-xs",
@@ -2820,9 +2857,6 @@ function SegmentedControl({
2820
2857
 
2821
2858
  // src/SelectionPicker.tsx
2822
2859
  var import_jsx_runtime27 = require("react/jsx-runtime");
2823
- function cx8(...parts) {
2824
- return parts.filter(Boolean).join(" ");
2825
- }
2826
2860
  function slug5(value) {
2827
2861
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
2828
2862
  }
@@ -2852,18 +2886,19 @@ function SelectionPicker({
2852
2886
  loadingMore = false,
2853
2887
  onLoadMore,
2854
2888
  toolbarExtra,
2889
+ className,
2855
2890
  testIdPrefix
2856
2891
  }) {
2857
2892
  const hasAccountLists = !!accountLists;
2858
- const [source, setSource] = (0, import_react12.useState)("search");
2859
- const [query, setQuery] = (0, import_react12.useState)("");
2860
- const [activeFilters, setActiveFilters] = (0, import_react12.useState)(() => {
2893
+ const [source, setSource] = (0, import_react13.useState)("search");
2894
+ const [query, setQuery] = (0, import_react13.useState)("");
2895
+ const [activeFilters, setActiveFilters] = (0, import_react13.useState)(() => {
2861
2896
  const init = {};
2862
2897
  if (defaultFilters) for (const [label, opts] of Object.entries(defaultFilters)) init[label] = new Set(opts);
2863
2898
  return init;
2864
2899
  });
2865
- const [expanded, setExpanded] = (0, import_react12.useState)(/* @__PURE__ */ new Set());
2866
- const selectedIds = (0, import_react12.useMemo)(() => new Set(selected.map((s) => s.id)), [selected]);
2900
+ const [expanded, setExpanded] = (0, import_react13.useState)(/* @__PURE__ */ new Set());
2901
+ const selectedIds = (0, import_react13.useMemo)(() => new Set(selected.map((s) => s.id)), [selected]);
2867
2902
  const toggleFilter = (label, opt) => {
2868
2903
  setActiveFilters((prev) => {
2869
2904
  const next = { ...prev };
@@ -2875,7 +2910,7 @@ function SelectionPicker({
2875
2910
  };
2876
2911
  const activeFilterCount = filters.reduce((n, f) => n + (activeFilters[f.label]?.size ?? 0), 0);
2877
2912
  const hasSearched = showResultsWithoutSearch || query.trim().length > 0 || !requireQuery && activeFilterCount > 0;
2878
- const filteredCatalog = (0, import_react12.useMemo)(() => {
2913
+ const filteredCatalog = (0, import_react13.useMemo)(() => {
2879
2914
  if (!hasSearched || results !== void 0) return [];
2880
2915
  const q = query.trim().toLowerCase();
2881
2916
  return catalog.filter((row) => {
@@ -2914,7 +2949,7 @@ function SelectionPicker({
2914
2949
  }
2915
2950
  };
2916
2951
  const rowGridCols = showInfoColumn ? "grid-cols-[36px_1fr_44px]" : "grid-cols-[36px_1fr]";
2917
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col gap-4", children: [
2952
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: cn("flex flex-col gap-4", className), "data-testid": testIdPrefix, children: [
2918
2953
  helper && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
2919
2954
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-dense text-text-secondary", children: helper }),
2920
2955
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("hr", { className: "-mx-5 -mt-2 border-border-default sm:-mx-6" })
@@ -2974,7 +3009,7 @@ function SelectionPicker({
2974
3009
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2975
3010
  "div",
2976
3011
  {
2977
- className: cx8(
3012
+ className: cn(
2978
3013
  "grid items-center gap-2 border-b border-border-default bg-canvas px-3 py-2 text-micro font-semibold uppercase tracking-[0.06em] text-text-secondary",
2979
3014
  rowGridCols
2980
3015
  ),
@@ -2987,10 +3022,10 @@ function SelectionPicker({
2987
3022
  disabled: toggleable.length === 0,
2988
3023
  onChange: toggleAll,
2989
3024
  ariaLabel: "Select all",
2990
- testId: testIdPrefix && `${testIdPrefix}-select-all`
3025
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-select-all`
2991
3026
  }
2992
3027
  ),
2993
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("grid gap-2", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: c.className, children: c.header }, c.key)) }),
3028
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("grid gap-2", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: c.className, children: c.header }, c.key)) }),
2994
3029
  showInfoColumn && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-right", children: "Info" })
2995
3030
  ]
2996
3031
  }
@@ -3006,7 +3041,7 @@ function SelectionPicker({
3006
3041
  {
3007
3042
  onClick: isLocked ? void 0 : () => toggleRow(row),
3008
3043
  "aria-disabled": isLocked || void 0,
3009
- className: cx8(
3044
+ className: cn(
3010
3045
  "grid items-center gap-2 px-3 py-2.5",
3011
3046
  rowGridCols,
3012
3047
  isLocked ? "cursor-default opacity-50" : "cursor-pointer hover:bg-subtle",
@@ -3020,10 +3055,10 @@ function SelectionPicker({
3020
3055
  checked: isSel,
3021
3056
  onChange: () => toggleRow(row),
3022
3057
  ariaLabel: row.name,
3023
- testId: testIdPrefix && `${testIdPrefix}-row-${slug5(row.id)}`
3058
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-row-${slug5(row.id)}`
3024
3059
  }
3025
3060
  ),
3026
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("grid gap-2 text-dense text-text-primary", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx8("truncate", c.className), children: c.render(row) }, c.key)) }),
3061
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("grid gap-2 text-dense text-text-primary", gridForColumns(columns)), children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cn("truncate", c.className), children: c.render(row) }, c.key)) }),
3027
3062
  showInfoColumn && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex items-center justify-end", children: kids && kids.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3028
3063
  "button",
3029
3064
  {
@@ -3037,8 +3072,8 @@ function SelectionPicker({
3037
3072
  return n;
3038
3073
  });
3039
3074
  },
3040
- className: "flex h-7 w-7 items-center justify-center rounded-control text-text-secondary hover:bg-canvas hover:text-text-primary",
3041
- children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronRight, { size: 15, className: cx8("transition-transform", isOpen && "rotate-90") })
3075
+ className: "flex h-7 w-7 items-center justify-center rounded-control text-text-secondary hover:bg-canvas hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3076
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronRight, { size: 15, className: cn("transition-transform", isOpen && "rotate-90") })
3042
3077
  }
3043
3078
  ) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3044
3079
  "span",
@@ -3065,8 +3100,8 @@ function SelectionPicker({
3065
3100
  type: "button",
3066
3101
  disabled: kidSel,
3067
3102
  onClick: () => addRows([kid]),
3068
- className: cx8(
3069
- "inline-flex items-center gap-1 rounded-control px-2 py-1 text-xs font-medium",
3103
+ className: cn(
3104
+ "inline-flex items-center gap-1 rounded-control px-2 py-1 text-xs font-medium focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3070
3105
  kidSel ? "text-text-tertiary" : "text-text-link hover:bg-subtle"
3071
3106
  ),
3072
3107
  children: [
@@ -3089,7 +3124,7 @@ function SelectionPicker({
3089
3124
  onClick: onLoadMore,
3090
3125
  disabled: loadingMore,
3091
3126
  "data-testid": testIdPrefix && `${testIdPrefix}-load-more`,
3092
- className: "flex w-full items-center justify-center gap-2 border-t border-border-default px-2 py-1.5 text-dense text-brand-primaryAction transition-colors hover:bg-subtle disabled:opacity-50",
3127
+ className: "flex w-full items-center justify-center gap-2 border-t border-border-default px-2 py-1.5 text-dense text-brand-primaryAction transition-colors hover:bg-subtle disabled:opacity-50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
3093
3128
  children: [
3094
3129
  loadingMore ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.Loader2, { size: 13, className: "animate-spin", "aria-hidden": "true" }) : null,
3095
3130
  loadingMore ? "Loading\u2026" : "Load more"
@@ -3110,15 +3145,15 @@ function SelectionPicker({
3110
3145
  onClick: () => onToggleList?.(list.id),
3111
3146
  "aria-pressed": on,
3112
3147
  "data-testid": testIdPrefix && `${testIdPrefix}-list-${list.id}`,
3113
- className: cx8(
3114
- "flex items-center gap-3 rounded-control border px-3.5 py-3 text-left transition-colors",
3148
+ className: cn(
3149
+ "flex items-center gap-3 rounded-control border px-3.5 py-3 text-left transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3115
3150
  on ? "border-brand-primaryAction bg-brand-primarySoft" : "border-border-default bg-surface hover:bg-subtle"
3116
3151
  ),
3117
3152
  children: [
3118
3153
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3119
3154
  "span",
3120
3155
  {
3121
- className: cx8(
3156
+ className: cn(
3122
3157
  "flex h-5 w-5 shrink-0 items-center justify-center rounded-full",
3123
3158
  on ? "text-brand-primaryAction" : "text-text-secondary"
3124
3159
  ),
@@ -3135,7 +3170,7 @@ function SelectionPicker({
3135
3170
  formatListDate(list.updatedAt)
3136
3171
  ] })
3137
3172
  ] }),
3138
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx8("shrink-0 text-xs font-medium", on ? "text-brand-primaryAction" : "text-text-secondary"), children: on ? "Added" : "Add" })
3173
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cn("shrink-0 text-xs font-medium", on ? "text-brand-primaryAction" : "text-text-secondary"), children: on ? "Added" : "Add" })
3139
3174
  ]
3140
3175
  },
3141
3176
  list.id
@@ -3165,16 +3200,16 @@ function SelectionPicker({
3165
3200
  }
3166
3201
  var EDGE_FADE = 44;
3167
3202
  function ScrollFade({ className, children }) {
3168
- const elRef = (0, import_react12.useRef)(null);
3169
- const [edges, setEdges] = (0, import_react12.useState)({ top: false, bottom: false });
3170
- const sync = (0, import_react12.useCallback)(() => {
3203
+ const elRef = (0, import_react13.useRef)(null);
3204
+ const [edges, setEdges] = (0, import_react13.useState)({ top: false, bottom: false });
3205
+ const sync = (0, import_react13.useCallback)(() => {
3171
3206
  const el = elRef.current;
3172
3207
  if (!el) return;
3173
3208
  const top = el.scrollTop > 2;
3174
3209
  const bottom = el.scrollTop + el.clientHeight < el.scrollHeight - 2;
3175
3210
  setEdges((prev) => prev.top === top && prev.bottom === bottom ? prev : { top, bottom });
3176
3211
  }, []);
3177
- const attach = (0, import_react12.useCallback)(
3212
+ const attach = (0, import_react13.useCallback)(
3178
3213
  (el) => {
3179
3214
  elRef.current = el;
3180
3215
  if (!el) return;
@@ -3204,19 +3239,19 @@ function FilterDropdown({
3204
3239
  onToggle,
3205
3240
  testIdPrefix
3206
3241
  }) {
3207
- const [open, setOpen] = (0, import_react12.useState)(false);
3208
- const [q, setQ] = (0, import_react12.useState)("");
3209
- const btnRef = (0, import_react12.useRef)(null);
3210
- const menuRef = (0, import_react12.useRef)(null);
3211
- const [pos, setPos] = (0, import_react12.useState)(null);
3242
+ const [open, setOpen] = (0, import_react13.useState)(false);
3243
+ const [q, setQ] = (0, import_react13.useState)("");
3244
+ const btnRef = (0, import_react13.useRef)(null);
3245
+ const menuRef = (0, import_react13.useRef)(null);
3246
+ const [pos, setPos] = (0, import_react13.useState)(null);
3212
3247
  const searchable = filter.options.length > 8;
3213
3248
  const shownOptions = searchable && q.trim() ? filter.options.filter((o) => o.toLowerCase().includes(q.trim().toLowerCase())) : filter.options;
3214
- (0, import_react12.useLayoutEffect)(() => {
3249
+ (0, import_react13.useLayoutEffect)(() => {
3215
3250
  if (!open || !btnRef.current) return;
3216
3251
  const r = btnRef.current.getBoundingClientRect();
3217
3252
  setPos({ top: r.bottom + 6, left: r.left });
3218
3253
  }, [open]);
3219
- (0, import_react12.useEffect)(() => {
3254
+ (0, import_react13.useEffect)(() => {
3220
3255
  if (!open) {
3221
3256
  setQ("");
3222
3257
  return;
@@ -3248,10 +3283,10 @@ function FilterDropdown({
3248
3283
  onClick: () => setOpen((v) => !v),
3249
3284
  "aria-expanded": open,
3250
3285
  "data-testid": testIdPrefix && `${testIdPrefix}-filter-${filterSlug}`,
3251
- className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-control border border-border-strong bg-input px-3 text-dense font-medium text-text-secondary transition-colors hover:bg-subtle",
3286
+ className: "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-control border border-border-strong bg-input px-3 text-dense font-medium text-text-secondary transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3252
3287
  children: [
3253
3288
  label,
3254
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronDown, { size: 13, "aria-hidden": "true", className: cx8("transition-transform", open && "rotate-180") })
3289
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react15.ChevronDown, { size: 13, "aria-hidden": "true", className: cn("transition-transform", open && "rotate-180") })
3255
3290
  ]
3256
3291
  }
3257
3292
  ),
@@ -3278,7 +3313,7 @@ function FilterDropdown({
3278
3313
  }
3279
3314
  )
3280
3315
  ] }),
3281
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx8("flex flex-col gap-0.5", searchable && "max-h-60 overflow-y-auto"), children: shownOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-2 py-3 text-center text-xs text-text-secondary", children: "No matches." }) : shownOptions.map((opt) => {
3316
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("flex flex-col gap-0.5", searchable && "max-h-60 overflow-y-auto"), children: shownOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-2 py-3 text-center text-xs text-text-secondary", children: "No matches." }) : shownOptions.map((opt) => {
3282
3317
  const on = active.has(opt);
3283
3318
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3284
3319
  "label",
@@ -3291,7 +3326,7 @@ function FilterDropdown({
3291
3326
  checked: on,
3292
3327
  onChange: () => onToggle(opt),
3293
3328
  ariaLabel: opt,
3294
- testId: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${slug5(opt)}`
3329
+ testIdPrefix: testIdPrefix && `${testIdPrefix}-filter-${filterSlug}-${slug5(opt)}`
3295
3330
  }
3296
3331
  ),
3297
3332
  opt
@@ -3315,11 +3350,8 @@ function gridForColumns(columns) {
3315
3350
  }
3316
3351
 
3317
3352
  // src/PublisherBreakdownList.tsx
3318
- var import_react13 = require("react");
3353
+ var import_react14 = require("react");
3319
3354
  var import_jsx_runtime28 = require("react/jsx-runtime");
3320
- function cx9(...parts) {
3321
- return parts.filter(Boolean).join(" ");
3322
- }
3323
3355
  var fmtM = (v) => v >= 100 ? `$${Math.round(v)}M` : `$${v.toFixed(1)}M`;
3324
3356
  function priorYearAmt(spendN, yoy) {
3325
3357
  if (yoy === "NEW" || yoy <= -100) return null;
@@ -3361,7 +3393,7 @@ var COL_CURRENT = 76;
3361
3393
  var COL_PREVIOUS = 76;
3362
3394
  var COL_YOY = 44;
3363
3395
  function MetricListHeader({ className }) {
3364
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx9("flex items-baseline gap-2 pb-2", className), children: [
3396
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex items-baseline gap-2 pb-2", className), children: [
3365
3397
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex-1" }),
3366
3398
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex shrink-0 items-center gap-2 pr-1.5", children: [
3367
3399
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-right text-micro font-medium text-text-tertiary", style: { width: COL_CURRENT }, children: "Current" }),
@@ -3376,21 +3408,29 @@ function MetricCells({ spendN, yoy }) {
3376
3408
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "flex shrink-0 items-center gap-2 pr-1.5", children: [
3377
3409
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-right text-xs font-bold tabular-nums text-text-primary", style: { width: COL_CURRENT }, children: fmtM(spendN) }),
3378
3410
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "text-right text-xs font-normal tabular-nums text-text-primary", style: { width: COL_PREVIOUS }, children: prior ?? "\u2014" }),
3379
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex justify-end", style: { width: COL_YOY }, children: yoy === "NEW" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rounded-full bg-status-warning/15 px-1.5 text-badge font-semibold text-text-warning", children: "NEW" }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: cx9("text-right text-xs font-semibold tabular-nums", up ? "text-text-success" : "text-text-danger"), children: [
3411
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "flex justify-end", style: { width: COL_YOY }, children: yoy === "NEW" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rounded-full bg-status-warning/15 px-1.5 text-badge font-semibold text-text-warning", children: "NEW" }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: cn("text-right text-xs font-semibold tabular-nums", up ? "text-text-success" : "text-text-danger"), children: [
3380
3412
  up ? "+" : "\u2212",
3381
3413
  Math.abs(yoy),
3382
3414
  "%"
3383
3415
  ] }) })
3384
3416
  ] });
3385
3417
  }
3386
- function PublisherBreakdownList({ rows, defaultVisibleCount = 10, padded = true, viewAllHref, renderLogo }) {
3387
- const [showAll, setShowAll] = (0, import_react13.useState)(false);
3418
+ function PublisherBreakdownList({
3419
+ rows,
3420
+ defaultVisibleCount = 10,
3421
+ padded = true,
3422
+ viewAllHref,
3423
+ renderLogo,
3424
+ className,
3425
+ testIdPrefix
3426
+ }) {
3427
+ const [showAll, setShowAll] = (0, import_react14.useState)(false);
3388
3428
  const visible = showAll ? rows : rows.slice(0, defaultVisibleCount);
3389
3429
  const rowPad = padded ? "px-5" : "";
3390
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col", children: [
3430
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex flex-col", className), "data-testid": testIdPrefix, children: [
3391
3431
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-col", children: [
3392
3432
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MetricListHeader, { className: rowPad }),
3393
- visible.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx9("flex items-center justify-between gap-3 border-t border-border-default/60 py-2.5 first:border-t-0", rowPad), children: [
3433
+ visible.map((p) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex items-center justify-between gap-3 border-t border-border-default/60 py-2.5 first:border-t-0", rowPad), children: [
3394
3434
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex min-w-0 items-center gap-2.5", children: [
3395
3435
  renderLogo ? renderLogo(p) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Monogram, { name: p.brand, size: 28 }),
3396
3436
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "min-w-0", children: [
@@ -3404,24 +3444,24 @@ function PublisherBreakdownList({ rows, defaultVisibleCount = 10, padded = true,
3404
3444
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MetricCells, { spendN: p.spendN, yoy: p.yoy })
3405
3445
  ] }, p.brand))
3406
3446
  ] }),
3407
- rows.length > defaultVisibleCount && (viewAllHref ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx9("border-t border-border-default py-3", rowPad), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href: viewAllHref, className: "text-xs font-semibold text-text-link hover:underline", children: "See all publishers" }) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx9("flex items-center gap-2 border-t border-border-default py-3 text-xs text-text-tertiary", rowPad), children: [
3447
+ rows.length > defaultVisibleCount && (viewAllHref ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cn("border-t border-border-default py-3", rowPad), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href: viewAllHref, className: "text-xs font-semibold text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "See all publishers" }) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cn("flex items-center gap-2 border-t border-border-default py-3 text-xs text-text-tertiary", rowPad), children: [
3408
3448
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { children: [
3409
3449
  "Showing ",
3410
3450
  visible.length,
3411
3451
  " of ",
3412
3452
  rows.length
3413
3453
  ] }),
3414
- !showAll ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("button", { type: "button", onClick: () => setShowAll(true), className: "font-semibold text-text-link hover:underline", children: [
3454
+ !showAll ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("button", { type: "button", onClick: () => setShowAll(true), className: "font-semibold text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: [
3415
3455
  "See all (",
3416
3456
  rows.length - defaultVisibleCount,
3417
3457
  " more)"
3418
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", onClick: () => setShowAll(false), className: "font-semibold text-text-link hover:underline", children: "Show less" })
3458
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", onClick: () => setShowAll(false), className: "font-semibold text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: "Show less" })
3419
3459
  ] }))
3420
3460
  ] });
3421
3461
  }
3422
3462
 
3423
3463
  // src/Button.tsx
3424
- var import_react14 = require("react");
3464
+ var import_react15 = require("react");
3425
3465
  var import_react_slot = require("@radix-ui/react-slot");
3426
3466
  var import_class_variance_authority = require("class-variance-authority");
3427
3467
  var import_lucide_react16 = require("lucide-react");
@@ -3486,10 +3526,11 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
3486
3526
  }
3487
3527
  }
3488
3528
  );
3489
- var Button = (0, import_react14.forwardRef)(
3490
- ({ className, variant, size, iconOnly, asChild = false, loading = false, disabled, children, ...props }, ref) => {
3529
+ var Button = (0, import_react15.forwardRef)(
3530
+ ({ className, testIdPrefix, variant, size, iconOnly, asChild = false, loading = false, disabled, children, ...props }, ref) => {
3491
3531
  const shared = {
3492
3532
  className: cn(buttonVariants({ variant, size, iconOnly, className })),
3533
+ "data-testid": testIdPrefix,
3493
3534
  disabled: disabled || loading,
3494
3535
  "aria-busy": loading || void 0,
3495
3536
  ...props
@@ -3511,15 +3552,19 @@ function FilterDropdownFooter({
3511
3552
  onClear,
3512
3553
  onApply,
3513
3554
  clearLabel = "Clear all",
3514
- applyLabel = "Apply"
3555
+ applyLabel = "Apply",
3556
+ className,
3557
+ testIdPrefix
3515
3558
  }) {
3516
3559
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
3517
3560
  "div",
3518
3561
  {
3519
3562
  className: cn(
3520
3563
  "flex items-center gap-2 border-t border-border-default p-2",
3521
- onClear ? "justify-between" : "justify-end"
3564
+ onClear ? "justify-between" : "justify-end",
3565
+ className
3522
3566
  ),
3567
+ "data-testid": testIdPrefix,
3523
3568
  children: [
3524
3569
  onClear && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { type: "button", variant: "ghost", size: "sm", onClick: onClear, children: clearLabel }),
3525
3570
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { type: "button", variant: "primary", size: "sm", onClick: onApply, children: applyLabel })
@@ -3529,7 +3574,7 @@ function FilterDropdownFooter({
3529
3574
  }
3530
3575
 
3531
3576
  // src/NameListModal.tsx
3532
- var import_react15 = require("react");
3577
+ var import_react16 = require("react");
3533
3578
  var import_react_dom5 = require("react-dom");
3534
3579
  var import_jsx_runtime31 = require("react/jsx-runtime");
3535
3580
  function NameListModal({
@@ -3540,23 +3585,25 @@ function NameListModal({
3540
3585
  onSubmit,
3541
3586
  fieldLabel = "List name",
3542
3587
  placeholder = "e.g. Q4 prospecting targets",
3543
- options
3588
+ options,
3589
+ className,
3590
+ testIdPrefix
3544
3591
  }) {
3545
- const [name, setName] = (0, import_react15.useState)(initialName);
3546
- const [checked, setChecked] = (0, import_react15.useState)(
3592
+ const [name, setName] = (0, import_react16.useState)(initialName);
3593
+ const [checked, setChecked] = (0, import_react16.useState)(
3547
3594
  () => Object.fromEntries((options ?? []).map((o) => [o.key, !!o.initial]))
3548
3595
  );
3549
3596
  const toggle = (key) => setChecked((c) => ({ ...c, [key]: !c[key] }));
3550
- const dialogRef = (0, import_react15.useRef)(null);
3551
- const titleId = (0, import_react15.useId)();
3552
- const fieldId = (0, import_react15.useId)();
3553
- (0, import_react15.useEffect)(() => {
3597
+ const dialogRef = (0, import_react16.useRef)(null);
3598
+ const titleId = (0, import_react16.useId)();
3599
+ const fieldId = (0, import_react16.useId)();
3600
+ (0, import_react16.useEffect)(() => {
3554
3601
  const onKey = (e) => e.key === "Escape" && onCancel();
3555
3602
  window.addEventListener("keydown", onKey);
3556
3603
  return () => window.removeEventListener("keydown", onKey);
3557
3604
  }, [onCancel]);
3558
- const [opener] = (0, import_react15.useState)(() => typeof document === "undefined" ? null : document.activeElement);
3559
- (0, import_react15.useEffect)(
3605
+ const [opener] = (0, import_react16.useState)(() => typeof document === "undefined" ? null : document.activeElement);
3606
+ (0, import_react16.useEffect)(
3560
3607
  () => () => {
3561
3608
  const active = document.activeElement;
3562
3609
  if (!active || active === document.body) opener?.focus?.();
@@ -3596,7 +3643,8 @@ function NameListModal({
3596
3643
  "aria-modal": "true",
3597
3644
  "aria-labelledby": titleId,
3598
3645
  onKeyDown: trapTab,
3599
- className: "w-full max-w-110 rounded-card border border-border-default bg-surface p-5 shadow-overlay",
3646
+ "data-testid": testIdPrefix,
3647
+ className: cn("w-full max-w-110 rounded-card border border-border-default bg-surface p-5 shadow-overlay", className),
3600
3648
  children: [
3601
3649
  /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h2", { id: titleId, className: "text-base font-semibold text-text-primary", children: title }),
3602
3650
  /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "mt-4 flex flex-col gap-1.5", children: [
@@ -3633,9 +3681,9 @@ function NameListModal({
3633
3681
  // src/FilterChipBar.tsx
3634
3682
  var import_lucide_react17 = require("lucide-react");
3635
3683
  var import_jsx_runtime32 = require("react/jsx-runtime");
3636
- function FilterChipBar({ chips, onRemove, onClearAll, parkedKeys }) {
3684
+ function FilterChipBar({ chips, onRemove, onClearAll, parkedKeys, className, testIdPrefix }) {
3637
3685
  if (chips.length === 0) return null;
3638
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5 border-t border-border-default pt-2.5", children: [
3686
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: cn("flex flex-wrap items-center gap-1.5 border-t border-border-default pt-2.5", className), "data-testid": testIdPrefix, children: [
3639
3687
  chips.map((c) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3640
3688
  Chip,
3641
3689
  {
@@ -3646,7 +3694,15 @@ function FilterChipBar({ chips, onRemove, onClearAll, parkedKeys }) {
3646
3694
  },
3647
3695
  c.key
3648
3696
  )),
3649
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", onClick: onClearAll, className: "ml-1 text-xs font-medium text-text-link hover:underline", children: "Clear all" })
3697
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3698
+ "button",
3699
+ {
3700
+ type: "button",
3701
+ onClick: onClearAll,
3702
+ className: "ml-1 rounded-small text-xs font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3703
+ children: "Clear all"
3704
+ }
3705
+ )
3650
3706
  ] });
3651
3707
  }
3652
3708
  function Chip({
@@ -3676,7 +3732,7 @@ function Chip({
3676
3732
  type: "button",
3677
3733
  onClick: onRemove,
3678
3734
  "aria-label": `Remove ${groupLabel}: ${label}`,
3679
- className: "text-text-tertiary transition-colors hover:text-text-primary",
3735
+ className: "rounded-full text-text-tertiary transition-colors hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3680
3736
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react17.X, { size: 12 })
3681
3737
  }
3682
3738
  )
@@ -3695,6 +3751,7 @@ function Chip({
3695
3751
  }
3696
3752
 
3697
3753
  // src/SortButton.tsx
3754
+ var import_react17 = require("react");
3698
3755
  var import_lucide_react18 = require("lucide-react");
3699
3756
  var import_jsx_runtime33 = require("react/jsx-runtime");
3700
3757
  var ALIGN = {
@@ -3702,59 +3759,65 @@ var ALIGN = {
3702
3759
  center: "justify-center text-center",
3703
3760
  right: "justify-end text-right"
3704
3761
  };
3705
- function SortButton({
3706
- label,
3707
- sortKey,
3708
- sort,
3709
- onSort,
3710
- disabled = false,
3711
- sortable = true,
3712
- align = "left",
3713
- testIdPrefix
3714
- }) {
3715
- if (!sortable) return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: cn("inline-flex", ALIGN[align]), children: label });
3716
- const active = !disabled && sort.key === sortKey;
3717
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
3718
- "button",
3719
- {
3720
- type: "button",
3721
- disabled,
3722
- onClick: () => onSort(sortKey),
3723
- "data-testid": testIdPrefix && `${testIdPrefix}-sort-${sortKey}`,
3724
- className: cn(
3725
- // ALIGN's text-* overrides the UA default on <button>, which would centre a
3726
- // label that wraps onto two lines, out of step with the column under it.
3727
- // `uppercase` is NOT this control imposing a treatment -- it is
3728
- // restoring one. Every table header row sets uppercase on the <tr>,
3729
- // and a <button> does not inherit text-transform from its parent
3730
- // (measured: the <th> computes `uppercase`, the button inside it
3731
- // computes `none`), so without this a sortable label renders
3732
- // sentence case beside caps neighbours in the same band.
3733
- //
3734
- // Letter-spacing DOES inherit, which is why no tracking is set here.
3735
- // This control used to set its own `tracking-wide` while every
3736
- // header row sets `tracking-wider`, so sortable labels rendered
3737
- // subtly tighter than the fixed headers next to them. A control
3738
- // should carry exactly the properties that do not inherit, and
3739
- // nothing more.
3740
- "group inline-flex items-center gap-1 uppercase transition-colors focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3741
- ALIGN[align],
3742
- !disabled && "hover:text-text-primary"
3743
- ),
3744
- children: [
3745
- label,
3746
- !disabled && (active ? sort.dir === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3747
- import_lucide_react18.ArrowUpDown,
3748
- {
3749
- size: 12,
3750
- "aria-hidden": "true",
3751
- className: "shrink-0 text-text-tertiary opacity-50 transition-opacity group-hover:opacity-100"
3752
- }
3753
- ))
3754
- ]
3755
- }
3756
- );
3757
- }
3762
+ var SortButton = (0, import_react17.forwardRef)(
3763
+ function SortButton2({
3764
+ label,
3765
+ sortKey,
3766
+ sort,
3767
+ onSort,
3768
+ disabled = false,
3769
+ sortable = true,
3770
+ align = "left",
3771
+ className,
3772
+ testIdPrefix
3773
+ }, ref) {
3774
+ if (!sortable) return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: cn("inline-flex", ALIGN[align], className), children: label });
3775
+ const active = !disabled && sort.key === sortKey;
3776
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
3777
+ "button",
3778
+ {
3779
+ ref,
3780
+ type: "button",
3781
+ disabled,
3782
+ onClick: () => onSort(sortKey),
3783
+ "data-testid": testIdPrefix && `${testIdPrefix}-sort-${sortKey}`,
3784
+ className: cn(
3785
+ // ALIGN's text-* overrides the UA default on <button>, which would centre a
3786
+ // label that wraps onto two lines, out of step with the column under it.
3787
+ // `uppercase` is NOT this control imposing a treatment -- it is
3788
+ // restoring one. Every table header row sets uppercase on the <tr>,
3789
+ // and a <button> does not inherit text-transform from its parent
3790
+ // (measured: the <th> computes `uppercase`, the button inside it
3791
+ // computes `none`), so without this a sortable label renders
3792
+ // sentence case beside caps neighbours in the same band.
3793
+ //
3794
+ // Letter-spacing DOES inherit, which is why no tracking is set here.
3795
+ // This control used to set its own `tracking-wide` while every
3796
+ // header row sets `tracking-wider`, so sortable labels rendered
3797
+ // subtly tighter than the fixed headers next to them. A control
3798
+ // should carry exactly the properties that do not inherit, and
3799
+ // nothing more.
3800
+ "group inline-flex items-center gap-1 uppercase transition-colors focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
3801
+ ALIGN[align],
3802
+ !disabled && "hover:text-text-primary",
3803
+ className
3804
+ ),
3805
+ children: [
3806
+ label,
3807
+ !disabled && (active ? sort.dir === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowUp, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_lucide_react18.ArrowDown, { size: 12, "aria-hidden": "true", className: "shrink-0 text-brand-primaryAction" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3808
+ import_lucide_react18.ArrowUpDown,
3809
+ {
3810
+ size: 12,
3811
+ "aria-hidden": "true",
3812
+ className: "shrink-0 text-text-tertiary opacity-50 transition-opacity group-hover:opacity-100"
3813
+ }
3814
+ ))
3815
+ ]
3816
+ }
3817
+ );
3818
+ }
3819
+ );
3820
+ SortButton.displayName = "SortButton";
3758
3821
 
3759
3822
  // src/tableSort.ts
3760
3823
  function cycleSort(current, key, firstDir = "desc") {
@@ -3786,9 +3849,9 @@ function pageWindow(current, total) {
3786
3849
  }
3787
3850
  return out;
3788
3851
  }
3789
- function Pager({ page, totalPages, onPage, disabled = false, label = "Pagination" }) {
3790
- const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors disabled:pointer-events-none disabled:opacity-30";
3791
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("nav", { "aria-label": label, className: "flex items-center gap-1", children: [
3852
+ function Pager({ page, totalPages, onPage, disabled = false, label = "Pagination", className, testIdPrefix }) {
3853
+ const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors disabled:pointer-events-none disabled:opacity-30 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus";
3854
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("nav", { "aria-label": label, className: cn("flex items-center gap-1", className), "data-testid": testIdPrefix, children: [
3792
3855
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3793
3856
  "button",
3794
3857
  {
@@ -3850,22 +3913,24 @@ var SIZES = {
3850
3913
  md: "h-7 w-7 text-micro",
3851
3914
  lg: "h-11 w-11 text-panel-title"
3852
3915
  };
3853
- function WorkspaceAvatar({ name, size = "md" }) {
3916
+ function WorkspaceAvatar({ name, size = "md", className, testIdPrefix }) {
3854
3917
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3855
3918
  "span",
3856
3919
  {
3857
3920
  "aria-hidden": "true",
3858
3921
  className: cn(
3859
3922
  "flex shrink-0 items-center justify-center rounded-control bg-subtle font-semibold leading-none text-text-secondary",
3860
- SIZES[size]
3923
+ SIZES[size],
3924
+ className
3861
3925
  ),
3926
+ "data-testid": testIdPrefix,
3862
3927
  children: size === "xs" ? workspaceInitials(name ?? "All data").slice(0, 1) : workspaceInitials(name ?? "All data")
3863
3928
  }
3864
3929
  );
3865
3930
  }
3866
3931
 
3867
3932
  // src/Toast.tsx
3868
- var import_react16 = require("react");
3933
+ var import_react18 = require("react");
3869
3934
  var import_react_dom6 = require("react-dom");
3870
3935
  var import_lucide_react20 = require("lucide-react");
3871
3936
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -3874,11 +3939,11 @@ var ICON = {
3874
3939
  success: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react20.Check, { size: 15, className: "shrink-0", "aria-hidden": "true" }),
3875
3940
  warning: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react20.AlertTriangle, { size: 15, className: "shrink-0", "aria-hidden": "true" })
3876
3941
  };
3877
- function Toast({ message, action, onClose, tone = "neutral", duration, className }) {
3942
+ function Toast({ message, action, onClose, tone = "neutral", duration, className, testIdPrefix }) {
3878
3943
  const ms = duration ?? (action ? 1e4 : 5e3);
3879
- const [paused, setPaused] = (0, import_react16.useState)(false);
3880
- const closed = (0, import_react16.useRef)(false);
3881
- (0, import_react16.useEffect)(() => {
3944
+ const [paused, setPaused] = (0, import_react18.useState)(false);
3945
+ const closed = (0, import_react18.useRef)(false);
3946
+ (0, import_react18.useEffect)(() => {
3882
3947
  if (paused) return;
3883
3948
  const t = window.setTimeout(() => {
3884
3949
  if (closed.current) return;
@@ -3893,6 +3958,7 @@ function Toast({ message, action, onClose, tone = "neutral", duration, className
3893
3958
  {
3894
3959
  role: "status",
3895
3960
  "aria-live": "polite",
3961
+ "data-testid": testIdPrefix,
3896
3962
  onMouseEnter: () => setPaused(true),
3897
3963
  onMouseLeave: () => setPaused(false),
3898
3964
  onFocusCapture: () => setPaused(true),
@@ -3939,8 +4005,8 @@ function Toast({ message, action, onClose, tone = "neutral", duration, className
3939
4005
 
3940
4006
  // src/Tag.tsx
3941
4007
  var import_jsx_runtime37 = require("react/jsx-runtime");
3942
- function Tag({ children, className }) {
3943
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { kind: "category", className, children });
4008
+ function Tag({ children, className, testIdPrefix }) {
4009
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { kind: "category", className, testIdPrefix, children });
3944
4010
  }
3945
4011
 
3946
4012
  // src/TablePagination.tsx
@@ -3962,7 +4028,7 @@ function TablePagination({
3962
4028
  const current = Math.min(page, totalPages);
3963
4029
  const rangeStart = totalItems === 0 ? 0 : (current - 1) * perPage + 1;
3964
4030
  const rangeEnd = Math.min(current * perPage, totalItems);
3965
- const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors";
4031
+ const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus";
3966
4032
  const off = "disabled:pointer-events-none disabled:opacity-30";
3967
4033
  const stepBtn = cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary", off);
3968
4034
  const range = /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("span", { className: "text-dense text-text-tertiary tabular-nums", children: [
@@ -4070,7 +4136,7 @@ function TablePagination({
4070
4136
  }
4071
4137
 
4072
4138
  // src/DateRangePicker.tsx
4073
- var import_react17 = require("react");
4139
+ var import_react19 = require("react");
4074
4140
  var import_lucide_react22 = require("lucide-react");
4075
4141
  var import_jsx_runtime39 = require("react/jsx-runtime");
4076
4142
  var MONTH_ABBR = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
@@ -4134,21 +4200,23 @@ function DateRangePicker({
4134
4200
  today,
4135
4201
  years,
4136
4202
  formatDate,
4137
- formatRange
4203
+ formatRange,
4204
+ className,
4205
+ testIdPrefix
4138
4206
  }) {
4139
- const end = (0, import_react17.useMemo)(() => today ?? startOfToday(), [today]);
4207
+ const end = (0, import_react19.useMemo)(() => today ?? startOfToday(), [today]);
4140
4208
  const yearOptions = years ?? [3, 2, 1, 0].map((n) => end.getFullYear() - n);
4141
- const [open, setOpen] = (0, import_react17.useState)(false);
4142
- const [value, setValue] = (0, import_react17.useState)(defaultValue);
4143
- const [draft, setDraft] = (0, import_react17.useState)(defaultValue);
4144
- const ref = (0, import_react17.useRef)(null);
4145
- const [fromMo, setFromMo] = (0, import_react17.useState)(end.getMonth());
4146
- const [fromYr, setFromYr] = (0, import_react17.useState)(end.getFullYear() - 1);
4147
- const [toMo, setToMo] = (0, import_react17.useState)(end.getMonth());
4148
- const [toYr, setToYr] = (0, import_react17.useState)(end.getFullYear());
4149
- const [fromQ, setFromQ] = (0, import_react17.useState)(Math.floor(end.getMonth() / 3));
4150
- const [toQ, setToQ] = (0, import_react17.useState)(Math.floor(end.getMonth() / 3));
4151
- (0, import_react17.useEffect)(() => {
4209
+ const [open, setOpen] = (0, import_react19.useState)(false);
4210
+ const [value, setValue] = (0, import_react19.useState)(defaultValue);
4211
+ const [draft, setDraft] = (0, import_react19.useState)(defaultValue);
4212
+ const ref = (0, import_react19.useRef)(null);
4213
+ const [fromMo, setFromMo] = (0, import_react19.useState)(end.getMonth());
4214
+ const [fromYr, setFromYr] = (0, import_react19.useState)(end.getFullYear() - 1);
4215
+ const [toMo, setToMo] = (0, import_react19.useState)(end.getMonth());
4216
+ const [toYr, setToYr] = (0, import_react19.useState)(end.getFullYear());
4217
+ const [fromQ, setFromQ] = (0, import_react19.useState)(Math.floor(end.getMonth() / 3));
4218
+ const [toQ, setToQ] = (0, import_react19.useState)(Math.floor(end.getMonth() / 3));
4219
+ (0, import_react19.useEffect)(() => {
4152
4220
  const [s, e] = resolveRange(value, end);
4153
4221
  onRangeChange?.(s, e);
4154
4222
  }, [value]);
@@ -4156,7 +4224,7 @@ function DateRangePicker({
4156
4224
  if (!open) setDraft(value);
4157
4225
  setOpen((o) => !o);
4158
4226
  };
4159
- (0, import_react17.useEffect)(() => {
4227
+ (0, import_react19.useEffect)(() => {
4160
4228
  if (!open) return;
4161
4229
  const onDown = (e) => {
4162
4230
  if (ref.current && !ref.current.contains(e.target)) setOpen(false);
@@ -4182,7 +4250,7 @@ function DateRangePicker({
4182
4250
  if (showFooter) setDraft(label);
4183
4251
  else commit(label);
4184
4252
  };
4185
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "relative", ref, children: [
4253
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: cn("relative", className), ref, "data-testid": testIdPrefix, children: [
4186
4254
  /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
4187
4255
  "button",
4188
4256
  {
@@ -4206,7 +4274,7 @@ function DateRangePicker({
4206
4274
  {
4207
4275
  type: "button",
4208
4276
  onClick: () => showFooter ? setDraft(p) : commit(p),
4209
- className: cn("block w-full px-3 py-2 text-left text-dense transition-colors hover:bg-subtle", (showFooter ? draft : value) === p ? "font-semibold text-brand-primaryAction" : "text-text-secondary"),
4277
+ className: cn("block w-full px-3 py-2 text-left text-dense transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus", (showFooter ? draft : value) === p ? "font-semibold text-brand-primaryAction" : "text-text-secondary"),
4210
4278
  children: p
4211
4279
  },
4212
4280
  p
@@ -4236,7 +4304,7 @@ function DateRangePicker({
4236
4304
  type: "button",
4237
4305
  onClick: applyCustom,
4238
4306
  disabled: !valid,
4239
- className: "self-start text-dense font-semibold text-brand-primaryAction transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-40",
4307
+ className: "self-start text-dense font-semibold text-brand-primaryAction transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
4240
4308
  children: showFooter ? "Use custom range" : "Apply"
4241
4309
  }
4242
4310
  )
@@ -4248,7 +4316,7 @@ function DateRangePicker({
4248
4316
  }
4249
4317
 
4250
4318
  // src/MultiSelectFilter.tsx
4251
- var import_react18 = require("react");
4319
+ var import_react20 = require("react");
4252
4320
  var import_lucide_react23 = require("lucide-react");
4253
4321
  var import_jsx_runtime40 = require("react/jsx-runtime");
4254
4322
  function MultiSelectFilter({
@@ -4276,15 +4344,17 @@ function MultiSelectFilter({
4276
4344
  onRetry,
4277
4345
  valueLabel,
4278
4346
  hints,
4279
- note
4347
+ note,
4348
+ className,
4349
+ testIdPrefix
4280
4350
  }) {
4281
4351
  const groupLeaves = (g) => g.children.length ? g.children : [{ id: g.id, label: g.label }];
4282
4352
  const leafOptions = groups ? groups.flatMap(groupLeaves) : options;
4283
- const [open, setOpen] = (0, import_react18.useState)(false);
4284
- const [q, setQ] = (0, import_react18.useState)("");
4285
- const [draft, setDraft] = (0, import_react18.useState)(selected);
4286
- const ref = (0, import_react18.useRef)(null);
4287
- const close = (0, import_react18.useCallback)(() => {
4353
+ const [open, setOpen] = (0, import_react20.useState)(false);
4354
+ const [q, setQ] = (0, import_react20.useState)("");
4355
+ const [draft, setDraft] = (0, import_react20.useState)(selected);
4356
+ const ref = (0, import_react20.useRef)(null);
4357
+ const close = (0, import_react20.useCallback)(() => {
4288
4358
  setOpen(false);
4289
4359
  setQ("");
4290
4360
  if (showFooter) return;
@@ -4301,7 +4371,7 @@ function MultiSelectFilter({
4301
4371
  setOpen(false);
4302
4372
  setQ("");
4303
4373
  };
4304
- (0, import_react18.useEffect)(() => {
4374
+ (0, import_react20.useEffect)(() => {
4305
4375
  if (!open) return;
4306
4376
  const onKey = (e) => e.key === "Escape" && close();
4307
4377
  const onClick = (e) => {
@@ -4351,13 +4421,14 @@ function MultiSelectFilter({
4351
4421
  const kids = live.filter((c) => c.label.toLowerCase().includes(ql));
4352
4422
  return kids.length ? { ...g, children: kids } : null;
4353
4423
  }).filter((g) => g !== null) : [];
4354
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: cn("relative", fullWidth && "w-full"), ref, children: [
4424
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: cn("relative", fullWidth && "w-full", className), ref, "data-testid": testIdPrefix, children: [
4355
4425
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
4356
4426
  "button",
4357
4427
  {
4358
4428
  type: "button",
4359
4429
  onClick: () => open ? close() : openTray(),
4360
4430
  "aria-expanded": open,
4431
+ "data-testid": testIdPrefix && `${testIdPrefix}-trigger`,
4361
4432
  className: cn(chipTriggerClass(variant), fullWidth && "w-full justify-between"),
4362
4433
  children: [
4363
4434
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ChipContent, { caption, value, icon }),
@@ -4380,6 +4451,7 @@ function MultiSelectFilter({
4380
4451
  menuWidthClass,
4381
4452
  align === "right" ? "right-0" : "left-0"
4382
4453
  ),
4454
+ "data-testid": testIdPrefix && `${testIdPrefix}-popover`,
4383
4455
  role: "dialog",
4384
4456
  "aria-label": caption,
4385
4457
  children: loading ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(MenuLoading, {}) : error ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(MenuError, { onRetry }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
@@ -4395,7 +4467,7 @@ function MultiSelectFilter({
4395
4467
  className: "h-full flex-1 bg-transparent text-dense outline-hidden placeholder:text-text-tertiary"
4396
4468
  }
4397
4469
  ),
4398
- q && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { type: "button", onClick: () => setQ(""), "aria-label": "Clear search", className: "text-text-tertiary hover:text-text-primary", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react23.X, { size: 13 }) })
4470
+ q && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { type: "button", onClick: () => setQ(""), "aria-label": "Clear search", className: "text-text-tertiary hover:text-text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react23.X, { size: 13 }) })
4399
4471
  ] }) }),
4400
4472
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "max-h-[280px] overflow-y-auto p-1", children: [
4401
4473
  groups ? visibleGroups.map((g) => {
@@ -4406,7 +4478,7 @@ function MultiSelectFilter({
4406
4478
  {
4407
4479
  type: "button",
4408
4480
  onClick: () => toggleGroup(g),
4409
- className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
4481
+ className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4410
4482
  children: [
4411
4483
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked: state === "all", indeterminate: state === "some" }),
4412
4484
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: cn("flex-1 text-sm text-text-primary", !plainParent && "font-semibold"), children: labelled(g.id, g.label) }),
@@ -4421,7 +4493,7 @@ function MultiSelectFilter({
4421
4493
  {
4422
4494
  type: "button",
4423
4495
  onClick: () => toggle(c.id),
4424
- className: "flex w-full items-center gap-2.5 rounded-control py-2 pl-9 pr-2 text-left transition-colors hover:bg-subtle",
4496
+ className: "flex w-full items-center gap-2.5 rounded-control py-2 pl-9 pr-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4425
4497
  children: [
4426
4498
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked }),
4427
4499
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-sm text-text-primary", children: labelled(c.id, c.label) }),
@@ -4439,7 +4511,7 @@ function MultiSelectFilter({
4439
4511
  {
4440
4512
  type: "button",
4441
4513
  onClick: () => toggle(o.id),
4442
- className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
4514
+ className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
4443
4515
  children: [
4444
4516
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CheckBoxBox, { checked }),
4445
4517
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "flex-1 text-sm text-text-primary", children: labelled(o.id, o.label) }),
@@ -4457,7 +4529,7 @@ function MultiSelectFilter({
4457
4529
  {
4458
4530
  type: "button",
4459
4531
  onClick: () => setDraft([]),
4460
- className: "text-xs font-medium text-text-link hover:underline",
4532
+ className: "text-xs font-medium text-text-link hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
4461
4533
  children: [
4462
4534
  "Clear ",
4463
4535
  caption.toLowerCase()
@@ -4478,17 +4550,19 @@ function OptionCount({ n }) {
4478
4550
  }
4479
4551
 
4480
4552
  // src/Toggle.tsx
4553
+ var import_react21 = require("react");
4481
4554
  var import_jsx_runtime41 = require("react/jsx-runtime");
4482
4555
  var SIZES2 = {
4483
4556
  sm: { track: "h-5 w-9", knob: "h-4 w-4", on: "translate-x-[18px]" },
4484
4557
  md: { track: "h-6 w-11", knob: "h-5 w-5", on: "translate-x-[22px]" }
4485
4558
  };
4486
4559
  var OFF_TRACK = "color-mix(in srgb, var(--mr-color-border-interactive) 70%, var(--mr-color-text-secondary))";
4487
- function Toggle({ checked, onChange, label, size = "md", disabled, className, testIdPrefix }) {
4560
+ var Toggle = (0, import_react21.forwardRef)(function Toggle2({ checked, onChange, label, size = "md", disabled, className, testIdPrefix }, ref) {
4488
4561
  const s = SIZES2[size];
4489
4562
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4490
4563
  "button",
4491
4564
  {
4565
+ ref,
4492
4566
  type: "button",
4493
4567
  role: "switch",
4494
4568
  "aria-checked": checked,
@@ -4516,20 +4590,21 @@ function Toggle({ checked, onChange, label, size = "md", disabled, className, te
4516
4590
  )
4517
4591
  }
4518
4592
  );
4519
- }
4593
+ });
4594
+ Toggle.displayName = "Toggle";
4520
4595
 
4521
4596
  // src/AISpark.tsx
4522
- var import_react19 = require("react");
4597
+ var import_react22 = require("react");
4523
4598
  var import_lucide_react24 = require("lucide-react");
4524
4599
  var import_jsx_runtime42 = require("react/jsx-runtime");
4525
- function AISpark({ size = 16, className }) {
4526
- const id = (0, import_react19.useId)();
4600
+ function AISpark({ size = 16, className, testIdPrefix }) {
4601
+ const id = (0, import_react22.useId)();
4527
4602
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
4528
4603
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("svg", { width: "0", height: "0", "aria-hidden": "true", style: { position: "absolute" }, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "1", children: [
4529
4604
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("stop", { offset: "0%", stopColor: "var(--mr-color-brand-primary)" }),
4530
4605
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("stop", { offset: "100%", className: "[stop-color:#9474ff] in-data-[theme=dark]:[stop-color:#a488ff]" })
4531
4606
  ] }) }) }),
4532
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react24.Sparkles, { size, stroke: `url(#${id})`, className, "aria-hidden": "true" })
4607
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react24.Sparkles, { size, stroke: `url(#${id})`, className, "data-testid": testIdPrefix, "aria-hidden": "true" })
4533
4608
  ] });
4534
4609
  }
4535
4610
 
@@ -4545,11 +4620,12 @@ var srLabel = {
4545
4620
  recent: "Recent (today)",
4546
4621
  stale: "Older than a day"
4547
4622
  };
4548
- function Freshness({ level }) {
4623
+ function Freshness({ level, className, testIdPrefix }) {
4549
4624
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4550
4625
  "span",
4551
4626
  {
4552
- className: cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full", dotColor[level]),
4627
+ className: cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full", dotColor[level], className),
4628
+ "data-testid": testIdPrefix,
4553
4629
  role: "img",
4554
4630
  "aria-label": srLabel[level]
4555
4631
  }
@@ -4558,8 +4634,8 @@ function Freshness({ level }) {
4558
4634
 
4559
4635
  // src/SectionHeading.tsx
4560
4636
  var import_jsx_runtime44 = require("react/jsx-runtime");
4561
- function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, className }) {
4562
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: cn("flex flex-wrap items-end justify-between gap-x-4 gap-y-2", className), children: [
4637
+ function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, className, testIdPrefix }) {
4638
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: cn("flex flex-wrap items-end justify-between gap-x-4 gap-y-2", className), "data-testid": testIdPrefix, children: [
4563
4639
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "min-w-0", children: [
4564
4640
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Tag2, { id, className: "text-base font-semibold text-text-primary", children: title }),
4565
4641
  description && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "mt-0.5 text-dense text-text-secondary", children: description })
@@ -4571,8 +4647,8 @@ function SectionHeading({ title, description, actions, as: Tag2 = "h2", id, clas
4571
4647
  // src/PageHeader.tsx
4572
4648
  var import_lucide_react25 = require("lucide-react");
4573
4649
  var import_jsx_runtime45 = require("react/jsx-runtime");
4574
- function PageHeader({ title, description, actions, meta, back, className }) {
4575
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("header", { className: cn("flex flex-wrap items-center justify-between gap-x-6 gap-y-3", className), children: [
4650
+ function PageHeader({ title, description, actions, meta, back, className, testIdPrefix }) {
4651
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("header", { className: cn("flex flex-wrap items-center justify-between gap-x-6 gap-y-3", className), "data-testid": testIdPrefix, children: [
4576
4652
  /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "min-w-0", children: [
4577
4653
  back && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4578
4654
  "a",
@@ -4597,7 +4673,7 @@ function PageHeader({ title, description, actions, meta, back, className }) {
4597
4673
  }
4598
4674
 
4599
4675
  // src/Modal.tsx
4600
- var import_react20 = require("react");
4676
+ var import_react23 = require("react");
4601
4677
  var import_react_dom7 = require("react-dom");
4602
4678
  var import_lucide_react26 = require("lucide-react");
4603
4679
  var import_jsx_runtime46 = require("react/jsx-runtime");
@@ -4610,13 +4686,13 @@ var WIDTH = {
4610
4686
  xl: "max-w-300"
4611
4687
  };
4612
4688
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
4613
- function Modal({ open, onClose, title, description, size = "md", footer, children, className }) {
4614
- const titleId = (0, import_react20.useId)();
4615
- const descId = (0, import_react20.useId)();
4616
- const panel = (0, import_react20.useRef)(null);
4617
- const close = (0, import_react20.useRef)(onClose);
4689
+ function Modal({ open, onClose, title, description, size = "md", footer, children, className, testIdPrefix }) {
4690
+ const titleId = (0, import_react23.useId)();
4691
+ const descId = (0, import_react23.useId)();
4692
+ const panel = (0, import_react23.useRef)(null);
4693
+ const close = (0, import_react23.useRef)(onClose);
4618
4694
  close.current = onClose;
4619
- (0, import_react20.useEffect)(() => {
4695
+ (0, import_react23.useEffect)(() => {
4620
4696
  if (!open) return;
4621
4697
  const opener = document.activeElement;
4622
4698
  const firstIn = (region) => panel.current?.querySelector(region)?.querySelector(FOCUSABLE) ?? null;
@@ -4662,6 +4738,7 @@ function Modal({ open, onClose, title, description, size = "md", footer, childre
4662
4738
  ref: panel,
4663
4739
  role: "dialog",
4664
4740
  "aria-modal": "true",
4741
+ "data-testid": testIdPrefix,
4665
4742
  "aria-labelledby": titleId,
4666
4743
  "aria-describedby": description ? descId : void 0,
4667
4744
  tabIndex: -1,
@@ -4700,7 +4777,7 @@ function Modal({ open, onClose, title, description, size = "md", footer, childre
4700
4777
 
4701
4778
  // src/EmptyState.tsx
4702
4779
  var import_jsx_runtime47 = require("react/jsx-runtime");
4703
- function EmptyState({ icon, title, description, action, size = "sm", className }) {
4780
+ function EmptyState({ icon, title, description, action, size = "sm", className, testIdPrefix }) {
4704
4781
  const md = size === "md";
4705
4782
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
4706
4783
  "div",
@@ -4710,6 +4787,7 @@ function EmptyState({ icon, title, description, action, size = "sm", className }
4710
4787
  md ? "gap-2 px-6 py-16" : "gap-1.5 px-4 py-8",
4711
4788
  className
4712
4789
  ),
4790
+ "data-testid": testIdPrefix,
4713
4791
  children: [
4714
4792
  icon && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
4715
4793
  "span",
@@ -4731,16 +4809,16 @@ function EmptyState({ icon, title, description, action, size = "sm", className }
4731
4809
  }
4732
4810
 
4733
4811
  // src/TextField.tsx
4734
- var import_react21 = require("react");
4812
+ var import_react24 = require("react");
4735
4813
  var import_jsx_runtime48 = require("react/jsx-runtime");
4736
4814
  var HEIGHT2 = { sm: "h-8", md: "h-10", lg: "h-11" };
4737
- var TextField = (0, import_react21.forwardRef)(
4738
- ({ label, hint, error, size = "md", icon, className, id, disabled, ...props }, ref) => {
4739
- const auto = (0, import_react21.useId)();
4815
+ var TextField = (0, import_react24.forwardRef)(
4816
+ ({ label, hint, error, size = "md", icon, className, testIdPrefix, id, disabled, ...props }, ref) => {
4817
+ const auto = (0, import_react24.useId)();
4740
4818
  const fieldId = id ?? auto;
4741
4819
  const noteId = `${fieldId}-note`;
4742
4820
  const note = error ?? hint;
4743
- return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn("flex flex-col gap-1.5", className), children: [
4821
+ return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: cn("flex flex-col gap-1.5", className), "data-testid": testIdPrefix, children: [
4744
4822
  label && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("label", { htmlFor: fieldId, className: "text-xs font-medium text-text-secondary", children: label }),
4745
4823
  /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
4746
4824
  "div",
@@ -4775,7 +4853,7 @@ var TextField = (0, import_react21.forwardRef)(
4775
4853
  TextField.displayName = "TextField";
4776
4854
 
4777
4855
  // src/Drawer.tsx
4778
- var import_react22 = require("react");
4856
+ var import_react25 = require("react");
4779
4857
  var import_react_dom8 = require("react-dom");
4780
4858
  var import_lucide_react27 = require("lucide-react");
4781
4859
  var import_jsx_runtime49 = require("react/jsx-runtime");
@@ -4786,15 +4864,15 @@ var WIDTH2 = {
4786
4864
  };
4787
4865
  var EXIT_MS = 200;
4788
4866
  var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
4789
- function Drawer({ open, onClose, title, description, size = "sm", footer, children, className }) {
4790
- const titleId = (0, import_react22.useId)();
4791
- const descId = (0, import_react22.useId)();
4792
- const panel = (0, import_react22.useRef)(null);
4793
- const close = (0, import_react22.useRef)(onClose);
4867
+ function Drawer({ open, onClose, title, description, size = "sm", footer, children, className, testIdPrefix }) {
4868
+ const titleId = (0, import_react25.useId)();
4869
+ const descId = (0, import_react25.useId)();
4870
+ const panel = (0, import_react25.useRef)(null);
4871
+ const close = (0, import_react25.useRef)(onClose);
4794
4872
  close.current = onClose;
4795
- const [mounted, setMounted] = (0, import_react22.useState)(open);
4796
- const [shown, setShown] = (0, import_react22.useState)(false);
4797
- (0, import_react22.useEffect)(() => {
4873
+ const [mounted, setMounted] = (0, import_react25.useState)(open);
4874
+ const [shown, setShown] = (0, import_react25.useState)(false);
4875
+ (0, import_react25.useEffect)(() => {
4798
4876
  if (open) {
4799
4877
  setMounted(true);
4800
4878
  const raf = requestAnimationFrame(() => requestAnimationFrame(() => setShown(true)));
@@ -4804,7 +4882,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
4804
4882
  const t = setTimeout(() => setMounted(false), EXIT_MS);
4805
4883
  return () => clearTimeout(t);
4806
4884
  }, [open]);
4807
- (0, import_react22.useEffect)(() => {
4885
+ (0, import_react25.useEffect)(() => {
4808
4886
  if (!open || !mounted) return;
4809
4887
  const opener = document.activeElement;
4810
4888
  const firstIn = (region) => panel.current?.querySelector(region)?.querySelector(FOCUSABLE2) ?? null;
@@ -4860,6 +4938,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
4860
4938
  ref: panel,
4861
4939
  role: "dialog",
4862
4940
  "aria-modal": "true",
4941
+ "data-testid": testIdPrefix,
4863
4942
  "aria-labelledby": titleId,
4864
4943
  "aria-describedby": description ? descId : void 0,
4865
4944
  tabIndex: -1,
@@ -4897,7 +4976,7 @@ function Drawer({ open, onClose, title, description, size = "sm", footer, childr
4897
4976
  }
4898
4977
 
4899
4978
  // src/DataTable.tsx
4900
- var import_react23 = require("react");
4979
+ var import_react26 = require("react");
4901
4980
  var import_jsx_runtime50 = require("react/jsx-runtime");
4902
4981
  var WIDTH3 = { fill: "", sm: "w-24", md: "w-36", lg: "w-48" };
4903
4982
  var MAX_H = { sm: "max-h-80", md: "max-h-120", lg: "max-h-160" };
@@ -4919,9 +4998,10 @@ function DataTable({
4919
4998
  maxHeight,
4920
4999
  footer,
4921
5000
  className,
5001
+ testIdPrefix,
4922
5002
  ...rest
4923
5003
  }) {
4924
- const titleId = (0, import_react23.useId)();
5004
+ const titleId = (0, import_react26.useId)();
4925
5005
  const head = HEAD_PAD[density];
4926
5006
  const pad = CELL_PAD[density];
4927
5007
  const align = (c) => c.numeric ? "text-right" : "text-left";
@@ -4930,62 +5010,70 @@ function DataTable({
4930
5010
  const col = columns.find((c) => c.key === key);
4931
5011
  onSortChange?.(cycleSort(sort, key, col?.firstDir ?? (col?.numeric ? "desc" : "asc")));
4932
5012
  };
4933
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className), children: [
4934
- title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
4935
- /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "min-w-0", children: [
4936
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
4937
- subtitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
4938
- ] }),
4939
- action && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "shrink-0", children: action })
4940
- ] }),
4941
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
4942
- "table",
4943
- {
4944
- "aria-labelledby": title ? titleId : void 0,
4945
- "aria-label": title ? void 0 : rest["aria-label"],
4946
- "aria-busy": loading || void 0,
4947
- className: "w-full border-collapse text-left",
4948
- children: [
4949
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4950
- "th",
4951
- {
4952
- scope: "col",
4953
- "aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
4954
- className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
4955
- children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4956
- SortButton,
5013
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5014
+ "div",
5015
+ {
5016
+ className: cn("flex w-full flex-col overflow-hidden rounded-card border border-border-default bg-surface", className),
5017
+ "data-testid": testIdPrefix,
5018
+ children: [
5019
+ title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-start justify-between gap-2 p-card-padding", children: [
5020
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "min-w-0", children: [
5021
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { id: titleId, className: "text-style-card-title", children: title }),
5022
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "mt-0.5 text-xs text-text-tertiary", children: subtitle })
5023
+ ] }),
5024
+ action && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "shrink-0", children: action })
5025
+ ] }),
5026
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: cn("overflow-x-auto", maxHeight && cn("overflow-y-auto", MAX_H[maxHeight])), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5027
+ "table",
5028
+ {
5029
+ "aria-labelledby": title ? titleId : void 0,
5030
+ "aria-label": title ? void 0 : rest["aria-label"],
5031
+ "aria-busy": loading || void 0,
5032
+ className: "w-full border-collapse text-left",
5033
+ children: [
5034
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("thead", { className: cn(maxHeight && "sticky top-0 z-10"), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "bg-subtle text-micro font-semibold uppercase tracking-wider text-text-secondary", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5035
+ "th",
5036
+ {
5037
+ scope: "col",
5038
+ "aria-sort": c.sortable ? ariaSortFor(sort, c.key) : void 0,
5039
+ className: cn("border-b border-border-default font-semibold", head, align(c), width(c)),
5040
+ children: c.sortable && onSortChange ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5041
+ SortButton,
5042
+ {
5043
+ label: c.label,
5044
+ sortKey: c.key,
5045
+ align: c.numeric ? "right" : "left",
5046
+ sort: sortProp(sort),
5047
+ onSort,
5048
+ testIdPrefix
5049
+ }
5050
+ ) : c.label
5051
+ },
5052
+ c.key
5053
+ )) }) }),
5054
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { className: cn("border-b border-border-default", pad, align(c)), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5055
+ "span",
4957
5056
  {
4958
- label: c.label,
4959
- sortKey: c.key,
4960
- align: c.numeric ? "right" : "left",
4961
- sort: sortProp(sort),
4962
- onSort
5057
+ className: cn(
5058
+ "inline-block h-3 animate-pulse rounded-full bg-subtle",
5059
+ c.numeric ? "w-12" : "w-2/3"
5060
+ )
4963
5061
  }
4964
- ) : c.label
4965
- },
4966
- c.key
4967
- )) }) }),
4968
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tbody", { className: "text-dense text-text-primary", children: loading ? Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { "aria-hidden": "true", className: "[&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { className: cn("border-b border-border-default", pad, align(c)), children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4969
- "span",
4970
- {
4971
- className: cn(
4972
- "inline-block h-3 animate-pulse rounded-full bg-subtle",
4973
- c.numeric ? "w-12" : "w-2/3"
4974
- )
4975
- }
4976
- ) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { colSpan: columns.length, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
4977
- "td",
4978
- {
4979
- className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
4980
- children: c.cell(row)
4981
- },
4982
- c.key
4983
- )) }, rowKey(row))) })
4984
- ]
4985
- }
4986
- ) }),
4987
- footer && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
4988
- ] });
5062
+ ) }, c.key)) }, i)) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { colSpan: columns.length, className: "px-6 py-12", children: empty ?? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(NoResultsEmptyState, {}) }) }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "hover:bg-subtle [&:last-child>td]:border-b-0", children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5063
+ "td",
5064
+ {
5065
+ className: cn("border-b border-border-default", pad, align(c), c.numeric && "tabular-nums"),
5066
+ children: c.cell(row)
5067
+ },
5068
+ c.key
5069
+ )) }, rowKey(row))) })
5070
+ ]
5071
+ }
5072
+ ) }),
5073
+ footer && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "border-t border-border-default px-4 py-3", children: footer })
5074
+ ]
5075
+ }
5076
+ );
4989
5077
  }
4990
5078
 
4991
5079
  // src/MediaLabel.tsx
@@ -4999,7 +5087,7 @@ var FILL = {
4999
5087
  Newspaper: "bg-media-newspaper",
5000
5088
  Magazine: "bg-media-magazine"
5001
5089
  };
5002
- function MediaLabel({ type, className }) {
5090
+ function MediaLabel({ type, className, testIdPrefix }) {
5003
5091
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
5004
5092
  "span",
5005
5093
  {
@@ -5008,18 +5096,22 @@ function MediaLabel({ type, className }) {
5008
5096
  FILL[type] ?? "bg-media-other",
5009
5097
  className
5010
5098
  ),
5099
+ "data-testid": testIdPrefix,
5011
5100
  children: type
5012
5101
  }
5013
5102
  );
5014
5103
  }
5015
5104
 
5016
5105
  // src/SuggestionChip.tsx
5106
+ var import_react27 = require("react");
5017
5107
  var import_jsx_runtime52 = require("react/jsx-runtime");
5018
- function SuggestionChip({ children, className, type = "button", ...props }) {
5108
+ var SuggestionChip = (0, import_react27.forwardRef)(function SuggestionChip2({ children, className, testIdPrefix, type = "button", ...props }, ref) {
5019
5109
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
5020
5110
  "button",
5021
5111
  {
5112
+ ref,
5022
5113
  type,
5114
+ "data-testid": testIdPrefix,
5023
5115
  ...props,
5024
5116
  className: cn(
5025
5117
  "inline-flex h-8 max-w-full items-center rounded-full border border-border-default bg-surface px-3 text-sm text-text-primary transition-colors duration-(--mr-motion-duration-interactive) ease-interactive hover:border-border-strong hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-border-focus",
@@ -5028,17 +5120,21 @@ function SuggestionChip({ children, className, type = "button", ...props }) {
5028
5120
  children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "truncate", children })
5029
5121
  }
5030
5122
  );
5031
- }
5123
+ });
5124
+ SuggestionChip.displayName = "SuggestionChip";
5032
5125
 
5033
5126
  // src/ToggleChip.tsx
5127
+ var import_react28 = require("react");
5034
5128
  var import_lucide_react28 = require("lucide-react");
5035
5129
  var import_jsx_runtime53 = require("react/jsx-runtime");
5036
- function ToggleChip({ selected, onChange, children, className, type = "button", onClick, ...props }) {
5130
+ var ToggleChip = (0, import_react28.forwardRef)(function ToggleChip2({ selected, onChange, children, className, testIdPrefix, type = "button", onClick, ...props }, ref) {
5037
5131
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
5038
5132
  "button",
5039
5133
  {
5134
+ ref,
5040
5135
  type,
5041
5136
  "aria-pressed": selected,
5137
+ "data-testid": testIdPrefix,
5042
5138
  ...props,
5043
5139
  onClick: (e) => {
5044
5140
  onClick?.(e);
@@ -5055,17 +5151,18 @@ function ToggleChip({ selected, onChange, children, className, type = "button",
5055
5151
  ]
5056
5152
  }
5057
5153
  );
5058
- }
5154
+ });
5155
+ ToggleChip.displayName = "ToggleChip";
5059
5156
 
5060
5157
  // src/CopyButton.tsx
5061
- var import_react24 = require("react");
5158
+ var import_react29 = require("react");
5062
5159
  var import_lucide_react29 = require("lucide-react");
5063
5160
  var import_jsx_runtime54 = require("react/jsx-runtime");
5064
5161
  var CONFIRM_MS = 2e3;
5065
- function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", className }) {
5066
- const [copied, setCopied] = (0, import_react24.useState)(false);
5067
- const timer = (0, import_react24.useRef)(void 0);
5068
- (0, import_react24.useEffect)(() => () => clearTimeout(timer.current), []);
5162
+ var CopyButton = (0, import_react29.forwardRef)(function CopyButton2({ value, label, "aria-label": ariaLabel, size = "xs", className, testIdPrefix }, ref) {
5163
+ const [copied, setCopied] = (0, import_react29.useState)(false);
5164
+ const timer = (0, import_react29.useRef)(void 0);
5165
+ (0, import_react29.useEffect)(() => () => clearTimeout(timer.current), []);
5069
5166
  const copy = async () => {
5070
5167
  try {
5071
5168
  await navigator.clipboard.writeText(typeof value === "function" ? value() : value);
@@ -5081,7 +5178,9 @@ function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", classN
5081
5178
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
5082
5179
  Button,
5083
5180
  {
5181
+ ref,
5084
5182
  type: "button",
5183
+ "data-testid": testIdPrefix,
5085
5184
  variant: "ghost",
5086
5185
  size,
5087
5186
  iconOnly: !label,
@@ -5095,7 +5194,8 @@ function CopyButton({ value, label, "aria-label": ariaLabel, size = "xs", classN
5095
5194
  ]
5096
5195
  }
5097
5196
  );
5098
- }
5197
+ });
5198
+ CopyButton.displayName = "CopyButton";
5099
5199
 
5100
5200
  // src/InlineMessage.tsx
5101
5201
  var import_lucide_react30 = require("lucide-react");
@@ -5114,13 +5214,14 @@ var ICON_INK = {
5114
5214
  danger: "text-text-danger"
5115
5215
  };
5116
5216
  var ICON2 = { info: import_lucide_react30.Info, success: import_lucide_react30.CheckCircle2, warning: import_lucide_react30.AlertTriangle, danger: import_lucide_react30.XCircle };
5117
- function InlineMessage({ tone = "info", title, children, actions, onDismiss, className }) {
5217
+ function InlineMessage({ tone = "info", title, children, actions, onDismiss, className, testIdPrefix }) {
5118
5218
  const Icon = ICON2[tone];
5119
5219
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
5120
5220
  "div",
5121
5221
  {
5122
5222
  role: tone === "warning" || tone === "danger" ? "alert" : "status",
5123
5223
  className: cn("flex items-start gap-2.5 rounded-control border px-3 py-2.5 text-sm", BOX[tone], className),
5224
+ "data-testid": testIdPrefix,
5124
5225
  children: [
5125
5226
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { size: 16, "aria-hidden": "true", className: cn("mt-0.5 shrink-0", ICON_INK[tone]) }),
5126
5227
  /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "min-w-0 flex-1", children: [