All files / web/src/components/create/abacus FilamentPlanPanel.tsx

74.39% Statements 805/1082
58.18% Branches 64/110
33.33% Functions 8/24
74.39% Lines 805/1082

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 10831x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 6x 6x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 33x 33x 33x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 30x 30x 30x 30x 30x 30x 30x 30x 6x 6x 6x 6x 33x 15x 15x 15x 15x 15x 15x 15x 15x 33x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x     3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 7x 7x 7x 7x 7x 7x 7x 4x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 32x 32x   3x 3x 3x 3x 3x 3x 32x           32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 32x 3x 3x 3x 3x 3x 3x 3x 3x 6x 6x 6x 6x 3x 6x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x                                                         3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x                                                                               3x 3x 33x 3x 3x 3x 3x 3x             3x 3x 3x 3x 3x 3x 3x         3x 3x 3x 3x 3x 3x 3x           3x 3x 3x 3x 3x 3x 3x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 1x 32x   32x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 32x 1x 33x   33x 33x 33x 33x                               33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 1x 32x   32x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 66x 33x 66x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x                 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x                     33x 33x 33x 66x 66x 66x 66x       66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 66x 32x 34x 66x 66x 66x                                               66x 66x 66x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x                                 33x 33x 33x 33x 33x 33x 33x 33x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 6x 6x 6x       6x 6x 6x 6x 6x 6x     6x 6x 6x 6x 6x 6x 6x 6x 6x 6x                                                                                                                                                                             6x 6x 6x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x       3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x       3x 3x 3x                 3x 3x 3x 3x       3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x   3x 3x 3x 3x 3x 3x 3x  
// Abacus Studio — the print-reduction panel (gh#163, Gitea #17).
//
// The ONE surface for the design→filament reconciliation: a part-aware mapping
// list where each row leads with a thumbnail of the actual abacus part (a bead in
// the user's shape, the frame, an ArUco marker), carries a flecked tile showing
// the filament it prints on (with a corner fleck of the designed color when it
// prints noticeably different), and expands in place to a co-print-grouped picker.
// Above it sits the plan's warning strip with per-role remediation chips. Extracted
// from AbacusStudioViewer so it stays presentational — no network, no three.js, no
// React Query — and Storybook drives it with fabricated catalogs
// (FilamentPlanPanel.stories.tsx).
//
// Hovering a row highlights that part on the 3D hero and x-rays the rest
// (onHighlightRole, which also passes the row label so the hero can caption what
// it's emphasizing); hovering a row's tile flips the whole hero to the designed
// colors (onRevealIntrinsic). The two compose. The parent owns `overrides` because
// the recolor pipeline needs the same pins; this panel re-derives the plan via
// materialize(design, catalog, { overrides }). materialize is pure, so the panel
// and the parent's recolor agree by construction — keep the options object in
// lockstep if it ever grows.
 
import type { FilamentPlanResponseV1 } from '@eink/print-dialog'
import { StandaloneBead } from '@soroban/abacus-react'
import {
  type CSSProperties,
  type Dispatch,
  type SetStateAction,
  useEffect,
  useMemo,
  useRef,
  useState,
} from 'react'
import { button, EYEBROW_RULED, notice, STUDIO } from '@/components/studio/theme'
import {
  coPrintGroup,
  type FilamentCatalog,
  type FilamentSpool,
  isSupportSpool,
} from './abacus-catalog'
import { filamentPlanFacts } from './abacus-commitment'
import type { AbacusDesign } from './abacus-design'
import { pickerInk } from './abacus-model'
import {
  materialize,
  NO_SPOOL,
  type PrintRoleKind,
  type RoleAssignment,
  roleShifted,
} from './abacus-plan'
import styles from './FilamentPlanPanel.module.css'
 
export { roleShifted } from './abacus-plan'
 
// gh#163 UX: mapping rows truncate spool names, and every spool from one brand
// starts with the same words ("Bambu Lab …") — the ellipsis was eating exactly
// the distinguishing tokens. The longest word-boundary prefix shared by the
// whole catalog is brand noise; row displays drop it, tooltips keep the full name.
function sharedNamePrefix(names: string[]): string {
  if (names.length < 2) return ''
  let prefix = names[0]
  for (const n of names) {
    while (prefix && !n.startsWith(prefix)) prefix = prefix.slice(0, -1)
  }
  const cut = prefix.lastIndexOf(' ')
  return cut > 0 ? prefix.slice(0, cut + 1) : ''
}
 
// One section of the role picker's swatch grid (gh#163 Layer 2): swatches
// bucketed by co-print (plate-temperature) group around the plan's anchor.
type PickerSection = {
  key: string
  label: string | null
  dim: boolean
  spools: { spool: FilamentSpool; idx: number }[]
}
 
// Warnings that name individual roles a user can act on get a chip row that
// deep-links into the mapping panel. budget-exceeded stays prose: its roleKeys
// are every bead (a catalog-size reality, not a per-role mistake).
const CHIP_WARNING_CODES = new Set([
  'marker-contrast',
  'material-mix',
  'support-material',
  'material-interface',
  'feet-material',
])
 
// The neutral part glyph stays a single slate so the flecked TILE is the row's
// only color object (Gitea #17) — the glyph says "which part", the tile "what
// color it prints".
const GLYPH_NEUTRAL = STUDIO.color.muted2
 
// A tiny, shape-honest thumbnail of the actual abacus part a row maps. Beads use
// StandaloneBead (reads the user's on-screen bead shape from AbacusDisplayProvider,
// falling back to defaults with no provider); the frame + ArUco marker get bespoke
// slate line glyphs. Text is defensive (inset text isn't emitted yet).
function PartGlyph({ kind }: { kind: PrintRoleKind }) {
  if (kind === 'bead') return <StandaloneBead size={16} color={GLYPH_NEUTRAL} />
  if (kind === 'markerBlack' || kind === 'markerWhite') {
    // a 3×3 fiducial: bordered square with a scatter of filled cells
    return (
      <svg width={16} height={16} viewBox="0 0 16 16" aria-hidden="true">
        <rect
          x={1.5}
          y={1.5}
          width={13}
          height={13}
          rx={2}
          fill="none"
          stroke={GLYPH_NEUTRAL}
          strokeWidth={1.25}
        />
        {[
          [0, 0],
          [2, 0],
          [1, 1],
          [0, 2],
          [2, 2],
        ].map(([gx, gy]) => (
          <rect
            key={`${gx}-${gy}`}
            x={4 + gx * 3}
            y={4 + gy * 3}
            width={2.4}
            height={2.4}
            fill={GLYPH_NEUTRAL}
          />
        ))}
      </svg>
    )
  }
  if (kind === 'text') {
    return (
      <svg width={16} height={16} viewBox="0 0 16 16" aria-hidden="true">
        <text x={8} y={12} textAnchor="middle" fontSize={11} fontWeight={700} fill={GLYPH_NEUTRAL}>
          T
        </text>
      </svg>
    )
  }
  if (kind === 'feet') {
    // a foot in profile: dovetail trapezoid (wide seat up) over its stand-off pad
    return (
      <svg width={16} height={16} viewBox="0 0 16 16" aria-hidden="true">
        <path
          d="M 3 4 L 13 4 L 11 10 L 5 10 Z"
          fill="none"
          stroke={GLYPH_NEUTRAL}
          strokeWidth={1.25}
        />
        <rect x={4.5} y={11} width={7} height={2.5} rx={1} fill={GLYPH_NEUTRAL} />
      </svg>
    )
  }
  // frame: a rounded-rect outline
  return (
    <svg width={16} height={16} viewBox="0 0 16 16" aria-hidden="true">
      <rect
        x={2}
        y={2}
        width={12}
        height={12}
        rx={2.5}
        fill="none"
        stroke={GLYPH_NEUTRAL}
        strokeWidth={1.5}
      />
    </svg>
  )
}
 
// filament-mapping panel — a calm summary at rest, one inline picker at a time.
// Section eyebrow above each role group (beads first, structure below).
const GROUP_LABEL: CSSProperties = {
  ...STUDIO.type.eyebrow,
  color: STUDIO.color.muted2,
  padding: '10px 6px 4px',
}
// The picker's own chrome rides the DESIGNED colour it sits on, so its ink comes
// from pickerInk (solved against that ground), not from the theme. Only the
// geometry is shared.
const PICKER_LABEL: CSSProperties = {
  fontSize: 10,
  fontWeight: 600,
  textTransform: 'uppercase',
  letterSpacing: STUDIO.type.eyebrow.letterSpacing,
}
 
export interface FilamentPlanPanelProps {
  /** the intrinsic design being reduced (colors as the user built them) */
  design: AbacusDesign
  /** the loaded spools the design quantizes onto (THH AMS or params-derived) */
  catalog: FilamentCatalog
  /** manual pins, roleKey → spoolId — parent-owned so its recolor sees them too */
  overrides: Record<string, string>
  /** THH's plan for this design INCLUDING the pins, fetched by the parent. Null
   *  while it loads, or when no printer is paired — the panel then shows the
   *  designed colors with nothing assigned, rather than a locally-invented match. */
  servicePlan?: FilamentPlanResponseV1 | null
  /** the same plan asked WITHOUT the pins — "what would the service pick?", which
   *  the picker badges as the recommendation and the Fix button restores. */
  unpinnedServicePlan?: FilamentPlanResponseV1 | null
  /** True while the service is (re)answering — first fetch, or a stale answer held
   *  by keepPreviousData while inputs changed. The mapping went async (Gitea #37):
   *  without this the seconds between a design change and the plan landing look
   *  like the studio ignoring the user. */
  planPending?: boolean
  onOverridesChange: Dispatch<SetStateAction<Record<string, string>>>
  /** deep link: open a specific role's picker on mount (stories, warning chips) */
  defaultOpenRole?: string | null
  /** hover a row's true-color fleck → preview designed colors on the 3D model */
  onRevealIntrinsic?: (reveal: boolean) => void
  /** hover/focus a row → highlight that part on the 3D model, x-ray the rest (#17).
   *  the label rides along so the hero can caption what's being emphasized. */
  onHighlightRole?: (roleKey: string | null, label?: string | null) => void
  /** hero→row (#18): a click on the 3D model, as `{ key, nonce }` — opens + scrolls
   *  that role's row. The nonce re-fires on repeat clicks of the same collapsed part. */
  modelPick?: { key: string; nonce: number } | null
}
 
export function FilamentPlanPanel({
  design,
  catalog,
  overrides,
  servicePlan = null,
  unpinnedServicePlan = null,
  planPending = false,
  onOverridesChange: setOverrides,
  defaultOpenRole = null,
  onRevealIntrinsic,
  onHighlightRole,
  modelPick = null,
}: FilamentPlanPanelProps) {
  // the design projected onto the loaded filaments, honoring the user's pins —
  // the source of truth for every warning and row below
  const plan = useMemo(
    () => materialize(design, catalog, { overrides, plan: servicePlan }),
    [design, catalog, overrides, servicePlan]
  )
  // roleKey → the spool THE SERVICE prefers, ignoring the user's pins. The picker
  // badges this so someone who has pinned a worse-matching filament still sees the
  // recommendation, and the warning strip's Fix button restores it.
  //
  // It is the service's pick now, not a local one: the parent asks the same
  // question with no `required` selectors, and this projects that answer through
  // the same `materialize`. Roles the service could not place are omitted rather
  // than badged with slot 0 — there is no recommendation to make.
  const preferredByRole = useMemo(() => {
    const m = new Map<string, number>()
    for (const a of materialize(design, catalog, { plan: unpinnedServicePlan }).assignments) {
      if (a.spoolIndex !== NO_SPOOL) m.set(a.role.key, a.spoolIndex)
    }
    return m
  }, [design, catalog, unpinnedServicePlan])
  // the lossy-reduction heads-up shown in print mode: contrast the camera can't
  // read, a palette that outruns the loaded spools, the material trio a pin can
  // raise (gh#163) — a plate split across temperature families, a visible part on
  // breakaway support media, a mixed-material frame/marker weld — and the two
  // inlay-text reductions (rainbow collapsed onto fewer inks; an inlay group on
  // the frame's own filament, i.e. writing you can't read). The per-role
  // collision detail lives in the filament-mapping panel below.
  const reductionWarnings = plan.warnings.filter(
    (w) =>
      w.code === 'marker-contrast' ||
      w.code === 'budget-exceeded' ||
      w.code === 'material-mix' ||
      w.code === 'support-material' ||
      w.code === 'material-interface' ||
      w.code === 'feet-material' ||
      w.code === 'rainbow-unrealizable' ||
      w.code === 'text-invisible'
  )
  // override rows, grouped frame → ArUco pair → beads. `activeOverrides` counts
  // pins that actually took (an ignored, unloaded-spool pin has overridden=false).
  const orderedAssignments = useMemo(() => {
    const order = { frame: 0, markerBlack: 1, markerWhite: 2, bead: 3, text: 4, feet: 5 } as const
    return [...plan.assignments].sort((a, b) => order[a.role.kind] - order[b.role.kind])
  }, [plan])
  const activeOverrides = plan.assignments.filter((a) => a.overridden).length
  // grouped for the panel: beads first (what users actually tweak), then the
  // welded structure (frame + ArUco markers), which is rarely retargeted.
  const beadRows = orderedAssignments.filter((a) => a.role.kind === 'bead')
  const structureRows = orderedAssignments.filter((a) => a.role.kind !== 'bead')
  // the demoted "N filaments loaded / N colors shift" caption, now the list footer.
  // The shift count spans the surfaces the user colored (frame + beads + text),
  // matching the old reconcile strip's subset (ArUco ink is excluded).
  const facts = filamentPlanFacts(catalog, plan)
  // show each spool's material only when it's informative (a mixed-material THH
  // catalog); the all-PLA params catalog would just print "PLA" on every row.
  const showMaterial = useMemo(
    () => new Set(catalog.spools.map((s) => s.material)).size > 1,
    [catalog]
  )
  // gh#163 Layer 1 — strip the catalog-wide brand prefix ("Bambu Lab ") so the
  // characters that survive truncation are the distinguishing ones.
  const namePrefix = useMemo(() => sharedNamePrefix(catalog.spools.map((s) => s.name)), [catalog])
  const shortName = (s: FilamentSpool) =>
    namePrefix && s.name.startsWith(namePrefix) && s.name.length > namePrefix.length
      ? s.name.slice(namePrefix.length)
      : s.name
  // tiny uppercase family token beside a spool name — only when the catalog is
  // mixed-material. Support media wear the amber variant: breakaway filament,
  // never a sensible pick for a visible part. Takes the whole spool so the
  // service's supportKind (authoritative, #367) drives the amber, not the
  // family-name heuristic.
  const materialTag = (spool: FilamentSpool) => {
    if (!showMaterial) return null
    const material = spool.material
    const support = isSupportSpool(spool)
    return (
      <span
        data-element="abacus-studio-material-tag"
        title={support ? `${material} — breakaway support filament` : material}
        style={{
          flex: '0 0 auto',
          fontSize: 10,
          fontWeight: 600,
          letterSpacing: STUDIO.type.eyebrow.letterSpacing,
          textTransform: 'uppercase',
          lineHeight: 1.6,
          padding: '0 4px',
          borderRadius: STUDIO.radius.swatch,
          border: `1px solid ${support ? STUDIO.color.tone.warn.bar : STUDIO.color.borderStrong}`,
          color: support ? STUDIO.color.warnInline : STUDIO.color.muted,
        }}
      >
        {material}
      </span>
    )
  }
  // gh#163 Layer 2 — the catalog bucketed for the picker: co-print groups plus
  // the support-media bucket, computed once and consumed by both section
  // orderings below (never fork the grouping).
  const pickerGroups = useMemo(() => {
    const entries = catalog.spools.map((spool, idx) => ({ spool, idx }))
    const support = entries.filter(({ spool }) => isSupportSpool(spool))
    const byGroup = new Map<string, typeof entries>()
    for (const entry of entries) {
      if (isSupportSpool(entry.spool)) continue
      const g = coPrintGroup(entry.spool.material)
      const arr = byGroup.get(g)
      if (arr) arr.push(entry)
      else byGroup.set(g, [entry])
    }
    return { entries, support, byGroup }
  }, [catalog])
  // The picker's swatches, sectioned by co-print group when the catalog knows
  // materials. The plan's anchor group leads undimmed; other temperature
  // families and support media follow, dimmed but fully clickable — an
  // off-anchor pin is allowed and answered by the warning strip, never
  // blocked. Color-only catalogs keep the flat grid (label-less section).
  const pickerSections = useMemo<PickerSection[]>(() => {
    const { entries, support, byGroup } = pickerGroups
    const anchor = plan.anchorGroup
    if (!showMaterial || !anchor) return [{ key: 'all', label: null, dim: false, spools: entries }]
    const sections: PickerSection[] = []
    const anchorSpools = byGroup.get(anchor)
    if (anchorSpools) {
      sections.push({
        key: anchor,
        label: `${anchor} · prints with this plate`,
        dim: false,
        spools: anchorSpools,
      })
    }
    for (const [g, groupSpools] of byGroup) {
      if (g === anchor) continue
      sections.push({
        key: g,
        label: `${g} · needs a different plate temperature`,
        dim: true,
        spools: groupSpools,
      })
    }
    if (support.length > 0) {
      sections.push({
        key: 'support',
        label: 'Support · breakaway material',
        dim: true,
        spools: support,
      })
    }
    return sections
  }, [pickerGroups, plan.anchorGroup, showMaterial])
  // The FEET row's ordering (Gitea #23) inverts the caution: TPU is off-anchor
  // by plate temperature, but for feet it's the part's NATURAL material (TPU
  // for AMS genuinely co-prints on a PLA-led plate — the mix is deliberate and
  // crossbar-retained), so it leads undimmed with its own reason line; the
  // anchor group follows undimmed (the rigid no-TPU fallback); every other
  // family keeps the dimmed temperature caution.
  const feetPickerSections = useMemo<PickerSection[]>(() => {
    const { support, byGroup } = pickerGroups
    const anchor = plan.anchorGroup
    if (!showMaterial || !anchor) return pickerSections
    const sections: PickerSection[] = []
    const tpu = byGroup.get('TPU')
    if (tpu) {
      sections.push({
        key: 'TPU',
        label: 'TPU · flexible — grips the desk',
        dim: false,
        spools: tpu,
      })
    }
    if (anchor !== 'TPU') {
      const anchorSpools = byGroup.get(anchor)
      if (anchorSpools) {
        sections.push({
          key: anchor,
          label: `${anchor} · prints rigid`,
          dim: false,
          spools: anchorSpools,
        })
      }
    }
    for (const [g, groupSpools] of byGroup) {
      if (g === 'TPU' || g === anchor) continue
      sections.push({
        key: g,
        label: `${g} · needs a different plate temperature`,
        dim: true,
        spools: groupSpools,
      })
    }
    if (support.length > 0) {
      sections.push({
        key: 'support',
        label: 'Support · breakaway material',
        dim: true,
        spools: support,
      })
    }
    return sections
  }, [pickerGroups, plan.anchorGroup, showMaterial, pickerSections])
  const pickerSectionsFor = (kind: PrintRoleKind) =>
    kind === 'feet' ? feetPickerSections : pickerSections
  // which role's picker is expanded (at most one — opening a row collapses the
  // rest). Single-open by construction; the row expands in place (no floating
  // popover to trap clicks over the WebGL canvas).
  const [openRole, setOpenRole] = useState<string | null>(defaultOpenRole)
  const setRoleSpool = (roleKey: string, spoolId: string) =>
    setOverrides((prev) => {
      const next = { ...prev }
      if (spoolId) next[roleKey] = spoolId
      else delete next[roleKey]
      return next
    })
  // gh#163 Layer 3 — deep link from a warning chip (or a story) to a role's row:
  // expand that row's picker and scroll it into view once the row exists (rAF
  // because the rows may be mounting this same commit).
  const mappingRowRefs = useRef(new Map<string, HTMLDivElement>())
  const revealRole = (roleKey: string) => setOpenRole(roleKey)
  useEffect(() => {
    if (!openRole) return
    const raf = requestAnimationFrame(() =>
      mappingRowRefs.current.get(openRole)?.scrollIntoView({ block: 'nearest' })
    )
    return () => cancelAnimationFrame(raf)
  }, [openRole])
  // hero→row (#18): a click on the 3D model opens + scrolls its role's row. Keyed on
  // the whole pick object (fresh per click via its nonce), so re-clicking a part the
  // user has since collapsed re-opens it — which setOpenRole(sameKey) alone wouldn't.
  // rAF because the target row may be mounting in this same commit.
  useEffect(() => {
    if (!modelPick) return
    setOpenRole(modelPick.key)
    const raf = requestAnimationFrame(() =>
      mappingRowRefs.current.get(modelPick.key)?.scrollIntoView({ block: 'nearest' })
    )
    return () => cancelAnimationFrame(raf)
  }, [modelPick])
 
  // One role row: a part glyph + name + a flecked tile (the filament it prints on,
  // corner-flecked with the designed color when it shifts) that expands in place to
  // a filament picker. Shared by both groups so the two never drift. A pinned row
  // earns the panel's only accent (cyan rail + ring).
  const renderMappingRow = (a: RoleAssignment) => {
    const interactive = catalog.spools.length > 1
    // TOTAL over materialize's contract: `spoolIndex` is NO_SPOOL for a role the
    // service could not place, and for a plan that names a spool this catalog no
    // longer holds (a roster move under a keepPreviousData placeholder). The
    // first live plans crashed right here — an unguarded [-1].name took the
    // whole panel down into the error boundary. An unplaced row renders the
    // DESIGNED color and says so; the picker still opens, because pinning a
    // spool by hand is exactly the remedy.
    const assigned: FilamentSpool | undefined = catalog.spools[a.spoolIndex]
    const preferred = preferredByRole.get(a.role.key)
    const isOpen = interactive && openRole === a.role.key
    const shifted = roleShifted(a)
    // the picker bathes in the DESIGNED color, so its inner UI composites over it
    // via one coordinated ink set solved against THIS ground (Gitea #17): polarity
    // by max contrast, a neutral ramp, and a floored warm caution tone. The tile is
    // the closest match to this ground — that's what the ✓ means.
    const { fg, fgSoft, fgHair, warn } = pickerInk(a.role.intrinsicHex)
    const rowStyle: CSSProperties = {
      display: 'flex',
      alignItems: 'center',
      gap: 7,
      width: '100%',
      padding: 6,
      textAlign: 'left',
      border: 'none',
      borderLeft: `2px solid ${a.overridden ? STUDIO.color.accentText : 'transparent'}`,
      borderRadius: STUDIO.radius.notice,
      background: isOpen ? STUDIO.color.surfaceRaised : undefined,
      color: STUDIO.color.text2,
      fontSize: 12,
      cursor: interactive ? 'pointer' : 'default',
    }
    // the flecked tile is the row's ONE color object (the neutral glyph carries no
    // color). Hovering it flips the whole 3D hero to the designed colors.
    const tile = (
      <span
        data-element="abacus-studio-role-tile"
        data-role={a.role.key}
        data-shifted={shifted}
        data-unplaced={assigned === undefined}
        onMouseEnter={() => onRevealIntrinsic?.(true)}
        onMouseLeave={() => onRevealIntrinsic?.(false)}
        title={
          assigned === undefined
            ? `no loaded spool can serve this — your color ${a.role.intrinsicHex}. Load a matching filament, or pick one here to force it.`
            : shifted
              ? `prints ${assigned.name} — your color ${a.role.intrinsicHex} (hover to preview)`
              : `prints true (${assigned.name})`
        }
        style={{
          position: 'relative',
          width: 22,
          height: 22,
          borderRadius: STUDIO.radius.swatch,
          flex: '0 0 auto',
          overflow: 'hidden',
          // an unplaced role's tile shows the color the user DESIGNED — the thing
          // nothing loaded can print — behind a dashed alarm border, not a blank.
          background: assigned ? assigned.hex : a.role.intrinsicHex,
          border: assigned
            ? `1px solid ${STUDIO.color.buttonBorder}`
            : `1px dashed ${STUDIO.color.tone.danger.bar}`,
          boxShadow: a.overridden
            ? `0 0 0 1px ${STUDIO.color.rail}, 0 0 0 2px ${STUDIO.color.accentText}`
            : 'none',
        }}
      >
        {shifted && (
          // the corner fleck is the user's TRUE (designed) color
          <span
            aria-hidden="true"
            data-element="abacus-studio-role-fleck"
            style={{
              position: 'absolute',
              right: 0,
              bottom: 0,
              width: 0,
              height: 0,
              borderStyle: 'solid',
              borderWidth: '0 0 9px 9px',
              borderColor: `transparent transparent ${a.role.intrinsicHex} transparent`,
            }}
          />
        )}
      </span>
    )
    const header = (
      <>
        <span
          data-element="abacus-studio-part-glyph"
          style={{ flex: '0 0 auto', display: 'inline-flex' }}
        >
          <PartGlyph kind={a.role.kind} />
        </span>
        <span
          style={{
            flex: '1 1 auto',
            minWidth: 0,
            overflow: 'hidden',
            textOverflow: 'ellipsis',
            whiteSpace: 'nowrap',
          }}
        >
          {a.role.label}
        </span>
        {tile}
        <span
          title={
            assigned === undefined
              ? 'no loaded spool can serve this role'
              : showMaterial
                ? `${assigned.name} · ${assigned.material}`
                : assigned.name
          }
          style={{
            flex: '0 1 auto',
            minWidth: 0,
            maxWidth: 96,
            overflow: 'hidden',
            textOverflow: 'ellipsis',
            whiteSpace: 'nowrap',
            fontSize: STUDIO.type.note.fontSize,
            // an unplaced role says so in the one-word inline danger colour —
            // the row is not a notice, it is a status
            color: assigned ? STUDIO.color.muted : STUDIO.color.dangerInline,
          }}
        >
          {assigned ? shortName(assigned) : 'no spool'}
        </span>
        {assigned !== undefined && materialTag(assigned)}
        {interactive && (
          <span
            aria-hidden="true"
            className={styles.chevron}
            style={{
              flex: '0 0 auto',
              fontSize: 10,
              color: STUDIO.color.muted2,
              transform: isOpen ? 'rotate(90deg)' : 'none',
            }}
          >
            ▸
          </span>
        )}
      </>
    )
    return (
      <div
        key={a.role.key}
        ref={(el) => {
          if (el) mappingRowRefs.current.set(a.role.key, el)
          else mappingRowRefs.current.delete(a.role.key)
        }}
        data-element="abacus-studio-mapping-row"
        data-role={a.role.key}
        style={{ display: 'flex', flexDirection: 'column' }}
      >
        {interactive ? (
          <button
            type="button"
            className={styles.mapRow}
            data-action="toggle-mapping-row"
            aria-expanded={isOpen}
            onClick={() => setOpenRole((prev) => (prev === a.role.key ? null : a.role.key))}
            onMouseEnter={() => onHighlightRole?.(a.role.key, a.role.label)}
            onMouseLeave={() => onHighlightRole?.(null)}
            onFocus={() => onHighlightRole?.(a.role.key, a.role.label)}
            onBlur={() => onHighlightRole?.(null)}
            style={rowStyle}
          >
            {header}
          </button>
        ) : (
          <div
            onMouseEnter={() => onHighlightRole?.(a.role.key, a.role.label)}
            onMouseLeave={() => onHighlightRole?.(null)}
            style={rowStyle}
          >
            {header}
          </div>
        )}
 
        {interactive && (
          <div
            className={styles.pickerWrap}
            data-open={isOpen}
            data-element="abacus-studio-role-picker"
          >
            <div className={styles.pickerInner}>
              <div
                style={{
                  display: 'flex',
                  flexDirection: 'column',
                  gap: 7,
                  margin: '4px 0 8px',
                  padding: '8px 10px',
                  borderRadius: STUDIO.radius.control,
                  // the picker IS the designed color — no separate "Match" swatch
                  background: a.role.intrinsicHex,
                  border: `1px solid ${fgHair}`,
                }}
              >
                <span style={{ ...PICKER_LABEL, color: fgSoft }}>Matching your {a.role.label}</span>
                <div
                  role="group"
                  aria-label={`filament for ${a.role.label}`}
                  style={{ display: 'flex', flexDirection: 'column', gap: 7 }}
                >
                  {pickerSectionsFor(a.role.kind).map((sec) => (
                    <div
                      key={sec.key}
                      data-element="abacus-studio-picker-group"
                      data-group={sec.key}
                      style={{ display: 'flex', flexDirection: 'column', gap: 4 }}
                    >
                      {sec.label && (
                        <span
                          style={{
                            ...PICKER_LABEL,
                            // dim sections carry the caution signal; both it and the
                            // anchor label ride the ground-solved ink (warn vs soft)
                            color: sec.dim ? warn : fgSoft,
                          }}
                        >
                          {sec.label}
                        </span>
                      )}
                      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
                        {sec.spools.map(({ spool: s, idx }) => {
                          const isAssigned = idx === a.spoolIndex
                          const isPreferred = idx === preferred
                          const ring = a.overridden ? STUDIO.color.accentText : fg
                          const dimNote = sec.dim
                            ? sec.key === 'support'
                              ? ' · breakaway support'
                              : ' · different plate temperature'
                            : ''
                          return (
                            <button
                              key={s.id}
                              type="button"
                              className={styles.swatch}
                              data-action="override-role-spool"
                              aria-label={`${a.role.label} uses ${s.name}${showMaterial ? ` ${s.material}` : ''} ${s.hex}${isPreferred ? ' (best match)' : ''}${dimNote}`}
                              aria-pressed={isAssigned}
                              title={`${showMaterial ? `${s.name} · ${s.material} · ${s.hex}` : `${s.name} · ${s.hex}`}${isPreferred ? ' · best match' : ''}${dimNote}`}
                              onClick={() => setRoleSpool(a.role.key, s.id)}
                              style={{
                                position: 'relative',
                                width: 22,
                                height: 22,
                                borderRadius: STUDIO.radius.swatch,
                                flex: '0 0 auto',
                                padding: 0,
                                background: s.hex,
                                border: `1px solid ${STUDIO.color.buttonBorder}`,
                                cursor: 'pointer',
                                // dimmed ≠ disabled: off-anchor picks stay clickable
                                // (the warning strip answers them); the current
                                // assignment stays legible even in a dim section.
                                opacity: sec.dim && !isAssigned ? 0.45 : 1,
                                boxShadow: isAssigned
                                  ? `0 0 0 2px ${a.role.intrinsicHex}, 0 0 0 4px ${ring}`
                                  : 'none',
                              }}
                            >
                              {isPreferred && (
                                <span
                                  aria-hidden="true"
                                  style={{
                                    position: 'absolute',
                                    top: -5,
                                    right: -5,
                                    width: 14,
                                    height: 14,
                                    borderRadius: '50%',
                                    display: 'flex',
                                    alignItems: 'center',
                                    justifyContent: 'center',
                                    // the badge stays a fixed dark disc rather than
                                    // ground-solved ink: it must read on ANY swatch
                                    background: STUDIO.color.rail,
                                    border: `1px solid ${STUDIO.color.text}`,
                                    color: STUDIO.color.text,
                                    fontSize: 10,
                                    lineHeight: 1,
                                  }}
                                >

                                </span>
                              )}
                            </button>
                          )
                        })}
                      </div>
                    </div>
                  ))}
                </div>
                <span
                  style={{
                    display: 'flex',
                    alignItems: 'center',
                    gap: 5,
                    fontSize: STUDIO.type.note.fontSize,
                    lineHeight: STUDIO.type.note.lineHeight,
                    color: fgSoft,
                  }}
                >
                  <span
                    aria-hidden="true"
                    style={{
                      width: 14,
                      height: 14,
                      borderRadius: '50%',
                      display: 'inline-flex',
                      alignItems: 'center',
                      justifyContent: 'center',
                      flex: '0 0 auto',
                      background: 'transparent',
                      border: `1px solid ${fgHair}`,
                      color: fg,
                      fontSize: 10,
                    }}
                  >
                    ✓
                  </span>
                  best match — closest color{showMaterial ? ' & compatible material' : ''}
                </span>
                {a.overridden && (
                  <button
                    type="button"
                    data-action="clear-role-override"
                    onClick={() => setRoleSpool(a.role.key, '')}
                    style={{
                      // a `fix` button, but on the picker's designed-colour ground:
                      // the ground-solved ink stays, the geometry comes from theme
                      ...button('fix'),
                      alignSelf: 'flex-start',
                      border: `1px solid ${fgHair}`,
                      background: 'transparent',
                      color: fg,
                    }}
                  >
                    ↺ Back to auto
                  </button>
                )}
              </div>
            </div>
          </div>
        )}
      </div>
    )
  }
 
  return (
    <div
      data-element="abacus-studio-print-preview"
      style={{ display: 'flex', flexDirection: 'column', gap: 8 }}
    >
      {reductionWarnings.length > 0 && (
        <div
          data-element="abacus-studio-plan-warnings"
          style={{ ...notice('warn'), display: 'flex', flexDirection: 'column', gap: 9 }}
        >
          {reductionWarnings.map((w) => {
            // the roles this warning names, resolved to live assignments;
            // each becomes a chip that deep-links into the mapping panel
            const offenders = CHIP_WARNING_CODES.has(w.code)
              ? (w.roleKeys ?? [])
                  .map((key) => plan.assignments.find((x) => x.role.key === key))
                  .filter((x): x is RoleAssignment => x !== undefined)
              : []
            // fixable ⇔ pinned away from auto-snap's pick (the solver is
            // pin-blind, so an un-pinned role already sits on the
            // preferred spool). "Fix" simply drops those pins — the
            // anchor-restricted auto-snap does the rest.
            const fixable = offenders.filter((x) => {
              const pref = preferredByRole.get(x.role.key)
              return pref !== undefined && pref !== x.spoolIndex
            })
            return (
              <div
                key={w.code}
                data-element="abacus-studio-plan-warning"
                data-code={w.code}
                style={{ display: 'flex', flexDirection: 'column', gap: 6 }}
              >
                <div>{w.message}</div>
                {offenders.length > 0 && (
                  <div
                    style={{
                      display: 'flex',
                      flexWrap: 'wrap',
                      gap: 5,
                      alignItems: 'center',
                    }}
                  >
                    {offenders.map((x) => {
                      const spool = catalog.spools[x.spoolIndex]
                      return (
                        <button
                          key={x.role.key}
                          type="button"
                          data-action="reveal-role-mapping"
                          data-role={x.role.key}
                          onClick={() => revealRole(x.role.key)}
                          aria-label={`${x.role.label} prints on ${spool.name}${showMaterial ? ` (${spool.material})` : ''} — show it in the filament mapping`}
                          title="Show in filament mapping"
                          style={{
                            ...button('chip'),
                            display: 'inline-flex',
                            alignItems: 'center',
                            gap: 5,
                            // on the warn wash: inherit the notice's tone text
                            color: 'inherit',
                          }}
                        >
                          <span
                            aria-hidden="true"
                            style={{
                              width: 10,
                              height: 10,
                              borderRadius: 3,
                              flex: '0 0 auto',
                              background: x.role.intrinsicHex,
                              border: `1px solid ${STUDIO.color.buttonBorder}`,
                            }}
                          />
                          <span>{x.role.label}</span>
                          <span aria-hidden="true" style={{ opacity: 0.7 }}>

                          </span>
                          <span
                            aria-hidden="true"
                            style={{
                              width: 10,
                              height: 10,
                              borderRadius: 3,
                              flex: '0 0 auto',
                              background: spool.hex,
                              border: `1px solid ${STUDIO.color.buttonBorder}`,
                            }}
                          />
                          <span
                            style={{
                              maxWidth: 84,
                              overflow: 'hidden',
                              textOverflow: 'ellipsis',
                              whiteSpace: 'nowrap',
                            }}
                          >
                            {shortName(spool)}
                          </span>
                          {materialTag(spool)}
                        </button>
                      )
                    })}
                    {fixable.length > 0 && (
                      <button
                        type="button"
                        data-action="fix-plan-warning"
                        data-code={w.code}
                        onClick={() =>
                          setOverrides((prev) => {
                            const next = { ...prev }
                            for (const x of fixable) delete next[x.role.key]
                            return next
                          })
                        }
                        style={button('fix')}
                      >
                        ↺ Fix — back to auto
                      </button>
                    )}
                  </div>
                )}
              </div>
            )
          })}
        </div>
      )}
 
      {/* the single part-aware mapping list — one surface for design↔filament (#17). */}
      {/* Auto-snap picks by nearest color within the plate's co-print anchor group */}
      {/* (gh#163); each row's picker is the escape hatch. A pin that leaves the */}
      {/* anchor, lands on support media, or splits the frame/marker weld lights the */}
      {/* warning strip above — allowed, never blocked. */}
      <div
        data-element="abacus-studio-filament-mapping"
        style={{ display: 'flex', flexDirection: 'column', gap: 2 }}
        // safety: never leave the model stuck in a reveal/highlight lens if a
        // per-row mouseleave is missed (e.g. the pointer exits the list diagonally)
        onMouseLeave={() => {
          onRevealIntrinsic?.(false)
          onHighlightRole?.(null)
        }}
      >
        <div
          data-element="abacus-studio-mapping-header"
          style={{
            ...EYEBROW_RULED,
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'space-between',
            gap: 8,
          }}
        >
          <span>
            Filament mapping
            {planPending && (
              // the one visible cost of the matching authority moving to the
              // printer (Gitea #37): the answer arrives over the wire. Say so —
              // a silent multi-second hold on stale colors reads as a hang.
              <span
                data-element="abacus-studio-plan-pending"
                className={styles.planPending}
                style={{
                  marginLeft: 6,
                  fontWeight: 400,
                  textTransform: 'none',
                  letterSpacing: 'normal',
                  color: STUDIO.color.muted,
                }}
              >
                · asking your printer…
              </span>
            )}
            {activeOverrides > 0 && (
              <span style={{ marginLeft: 6, color: STUDIO.color.accentText }}>
                · {activeOverrides} pinned
              </span>
            )}
          </span>
          {activeOverrides > 0 && (
            <button
              type="button"
              data-action="clear-all-overrides"
              onClick={() => setOverrides({})}
              style={{ ...button('chip'), textTransform: 'none', letterSpacing: 'normal' }}
            >
              ↺ Reset all to auto
            </button>
          )}
        </div>
 
        {catalog.spools.length === 1 && (
          <div style={{ ...STUDIO.type.note, padding: '4px 6px' }}>
            One filament loaded — load more to remap roles.
          </div>
        )}
 
        {beadRows.length > 0 && (
          <>
            <div data-element="abacus-studio-mapping-group" data-group="beads" style={GROUP_LABEL}>
              Beads
            </div>
            {beadRows.map(renderMappingRow)}
          </>
        )}
 
        {structureRows.length > 0 && (
          <>
            <div
              data-element="abacus-studio-mapping-group"
              data-group="structure"
              style={{ ...GROUP_LABEL, opacity: 0.8 }}
            >
              Structure <span style={{ fontWeight: 400, opacity: 0.7 }}>· rarely changed</span>
            </div>
            {structureRows.map(renderMappingRow)}
          </>
        )}
 
        {/* the demoted legend, now a slim footer: loaded count + shift status */}
        <div
          data-element="abacus-studio-mapping-footer"
          style={{
            ...STUDIO.type.note,
            display: 'flex',
            justifyContent: 'space-between',
            alignItems: 'baseline',
            gap: 8,
            marginTop: 6,
            padding: '8px 6px 0',
            borderTop: `1px solid ${STUDIO.color.border}`,
          }}
        >
          <span>
            {facts.loaded} filament{facts.loaded === 1 ? '' : 's'} loaded
          </span>
          <span
            data-element="abacus-studio-mapping-shift"
            style={{
              color: facts.shifted > 0 ? STUDIO.color.warnInline : STUDIO.color.muted2,
            }}
          >
            {facts.shifted > 0
              ? `${facts.shifted} color${facts.shifted === 1 ? '' : 's'} shift`
              : 'prints true'}
          </span>
        </div>
      </div>
    </div>
  )
}