@apotech-os/support-kit 3.2.0 → 3.4.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/ui/index.cjs CHANGED
@@ -388,28 +388,109 @@ function dashboardSignals(totals, compare) {
388
388
  }
389
389
  return signals;
390
390
  }
391
- var DEFAULT_TOP_N = 6;
392
- function foldCategoryBreakdown(rows, categoryNames, topN = DEFAULT_TOP_N) {
393
- const measured = rows.map((row) => {
394
- const id = row["categoryId"];
391
+ function foldHumanReasons(rows) {
392
+ const reasons = { blocked: 0, invalidated: 0, expired: 0 };
393
+ for (const row of rows) {
394
+ if (outcomeOf(row["status"], row["autoSendDecision"]) !== "human") continue;
395
+ const count = Number(row["count"]) || 0;
396
+ if (row["status"] === "invalidated") reasons.invalidated += count;
397
+ else if (row["status"] === "expired") reasons.expired += count;
398
+ else reasons.blocked += count;
399
+ }
400
+ return reasons;
401
+ }
402
+ var CATEGORY_TOP_N = 10;
403
+ function foldCategoryOutcomes(triageRows, responseRows, categoryNames, topN = CATEGORY_TOP_N) {
404
+ const byId = /* @__PURE__ */ new Map();
405
+ const barFor = (id) => {
395
406
  const name = typeof id === "string" ? categoryNames.get(id) : void 0;
396
- return name ? { label: name, value: Number(row["count"]) || 0 } : null;
397
- }).filter((bar) => bar !== null).sort((a, b) => b.value - a.value);
398
- if (measured.length <= topN + 1) return measured;
399
- const tail = measured.slice(topN).reduce((sum, bar) => sum + bar.value, 0);
400
- return [...measured.slice(0, topN), { label: "Autres", value: tail }];
407
+ if (name === void 0) return null;
408
+ const existing = byId.get(id);
409
+ if (existing !== void 0) return existing;
410
+ const bar = {
411
+ label: name,
412
+ total: 0,
413
+ auto: 0,
414
+ human: 0,
415
+ noReply: 0,
416
+ undrafted: 0
417
+ };
418
+ byId.set(id, bar);
419
+ return bar;
420
+ };
421
+ for (const row of triageRows) {
422
+ const bar = barFor(row["categoryId"]);
423
+ if (bar !== null) bar.total += Number(row["count"]) || 0;
424
+ }
425
+ for (const row of responseRows) {
426
+ const bar = barFor(row["categoryId"]);
427
+ if (bar === null) continue;
428
+ const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
429
+ const count = Number(row["count"]) || 0;
430
+ if (outcome === "auto") bar.auto += count;
431
+ else if (outcome === "human") bar.human += count;
432
+ else if (outcome === "noReplyNeeded") bar.noReply += count;
433
+ }
434
+ const bars = [...byId.values()].map((bar) => {
435
+ const accounted = bar.auto + bar.human + bar.noReply;
436
+ return {
437
+ ...bar,
438
+ total: Math.max(bar.total, accounted),
439
+ undrafted: Math.max(0, bar.total - accounted)
440
+ };
441
+ }).filter((bar) => bar.total > 0).sort((a, b) => b.total - a.total);
442
+ if (bars.length <= topN + 1) return bars;
443
+ const tail = bars.slice(topN).reduce(
444
+ (sum, bar) => ({
445
+ label: "Autres",
446
+ total: sum.total + bar.total,
447
+ auto: sum.auto + bar.auto,
448
+ human: sum.human + bar.human,
449
+ noReply: sum.noReply + bar.noReply,
450
+ undrafted: sum.undrafted + bar.undrafted
451
+ }),
452
+ { label: "Autres", total: 0, auto: 0, human: 0, noReply: 0, undrafted: 0 }
453
+ );
454
+ return [...bars.slice(0, topN), tail];
401
455
  }
402
456
  var POINTS_FORMAT = new Intl.NumberFormat("fr-FR", {
403
457
  maximumFractionDigits: 1,
404
458
  signDisplay: "exceptZero"
405
459
  });
460
+ var DELTA_FORMAT = new Intl.NumberFormat("fr-FR", {
461
+ style: "percent",
462
+ maximumFractionDigits: 1,
463
+ signDisplay: "exceptZero"
464
+ });
465
+ function HeroSide({ label, value, compareValue, lowerIsBetter = false, formatValue }) {
466
+ const delta = uiSdk.relativeDelta(value, compareValue);
467
+ const improved = delta === null ? null : delta > 0 !== lowerIsBetter;
468
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: label }),
470
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xl font-semibold tabular-nums text-foreground", children: formatValue(value) }),
471
+ delta !== null && /* @__PURE__ */ jsxRuntime.jsxs(
472
+ "p",
473
+ {
474
+ className: `text-xs font-medium tabular-nums ${improved ? "text-status-success" : "text-status-blocked"}`,
475
+ children: [
476
+ DELTA_FORMAT.format(delta),
477
+ compareValue !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 font-normal text-muted-foreground", children: [
478
+ "vs ",
479
+ formatValue(compareValue)
480
+ ] })
481
+ ]
482
+ }
483
+ )
484
+ ] });
485
+ }
406
486
  function formatRate(value) {
407
487
  return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)} %`;
408
488
  }
409
489
  function AutonomyHero({
410
490
  rate,
411
491
  compareRate,
412
- caption
492
+ caption,
493
+ sides = []
413
494
  }) {
414
495
  const points = ratePoints(rate, compareRate);
415
496
  return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { className: "border-primary/25 bg-gradient-to-br from-primary/10 via-card to-card", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-1 p-4", children: [
@@ -434,7 +515,8 @@ function AutonomyHero({
434
515
  ]
435
516
  }
436
517
  ),
437
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption })
518
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption }),
519
+ sides.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-4 border-t border-border/60 pt-3 sm:max-w-md", children: sides.map((side) => /* @__PURE__ */ jsxRuntime.jsx(HeroSide, { ...side }, side.label)) })
438
520
  ] }) });
439
521
  }
440
522
  var DASHBOARD_PRESETS = [
@@ -483,8 +565,68 @@ function defaultPeriod(today = /* @__PURE__ */ new Date()) {
483
565
  ...compareRange === void 0 ? {} : { compareRange }
484
566
  };
485
567
  }
568
+ function sharePercent(value, total) {
569
+ return total > 0 ? `${Math.round(value / total * 100)} %` : null;
570
+ }
571
+ function StackedRow({
572
+ label,
573
+ segments,
574
+ total,
575
+ scale,
576
+ formatCount: formatCount2
577
+ }) {
578
+ const width = scale > 0 ? total / scale * 100 : 0;
579
+ return (
580
+ // Utilitaires standards seulement : une colonne en valeur arbitraire
581
+ // (`grid-cols-[minmax(6rem,9rem)_1fr_auto]`) n'est pas générée par le
582
+ // Tailwind de l'instance, qui ne scanne pas le dist du kit pour ça — la
583
+ // ligne retombait alors en trois blocs empilés.
584
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 text-xs", children: [
585
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-36 shrink-0 truncate text-muted-foreground", title: label, children: label }),
586
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full overflow-hidden rounded-sm", style: { width: `${width}%` }, children: segments.filter((segment) => segment.value > 0).map((segment) => /* @__PURE__ */ jsxRuntime.jsx(
587
+ "div",
588
+ {
589
+ role: "presentation",
590
+ title: `${segment.label} : ${formatCount2(segment.value)}${sharePercent(segment.value, total) === null ? "" : ` (${sharePercent(segment.value, total)})`}`,
591
+ style: {
592
+ width: `${segment.value / total * 100}%`,
593
+ backgroundColor: segment.color
594
+ }
595
+ },
596
+ segment.key
597
+ )) }) }),
598
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-14 shrink-0 text-right tabular-nums text-muted-foreground", children: formatCount2(total) })
599
+ ] })
600
+ );
601
+ }
602
+ function StackedLegend({ segments }) {
603
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: segments.map((segment) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
604
+ /* @__PURE__ */ jsxRuntime.jsx(
605
+ "span",
606
+ {
607
+ "aria-hidden": true,
608
+ className: "inline-block size-2 rounded-[2px]",
609
+ style: { backgroundColor: segment.color }
610
+ }
611
+ ),
612
+ segment.label
613
+ ] }, segment.key)) });
614
+ }
486
615
  var OUTCOME_METRICS = [{ op: "count", as: "count" }];
487
616
  var OUTCOME_GROUP_BY = ["status", "autoSendDecision"];
617
+ var CATEGORY_OUTCOME_GROUP_BY = ["categoryId", "status", "autoSendDecision"];
618
+ var CATEGORY_COLORS = {
619
+ auto: "var(--chart-1)",
620
+ human: "var(--chart-2)",
621
+ noReply: "var(--chart-4)",
622
+ undrafted: "var(--muted)"
623
+ };
624
+ var CATEGORY_LEGEND = [
625
+ { key: "auto", label: "R\xE9ponse automatis\xE9e par l\u2019agent", color: CATEGORY_COLORS.auto },
626
+ { key: "human", label: "Repris par un humain", color: CATEGORY_COLORS.human },
627
+ { key: "noReply", label: "Sans r\xE9ponse n\xE9cessaire", color: CATEGORY_COLORS.noReply },
628
+ { key: "undrafted", label: "Sans brouillon", color: CATEGORY_COLORS.undrafted }
629
+ ];
488
630
  function formatCount(value) {
489
631
  return Number.isNaN(value) ? "\u2026" : value.toLocaleString("fr-FR");
490
632
  }
@@ -525,6 +667,11 @@ function DashboardPage() {
525
667
  groupBy: ["categoryId"],
526
668
  metrics: OUTCOME_METRICS
527
669
  });
670
+ const { rows: categoryOutcomes } = useAggregate("generated-response", {
671
+ filter: currentFilter,
672
+ groupBy: CATEGORY_OUTCOME_GROUP_BY,
673
+ metrics: OUTCOME_METRICS
674
+ });
528
675
  const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
529
676
  const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
530
677
  const totals = react.useMemo(() => foldOutcomes(dailyRows), [dailyRows]);
@@ -540,20 +687,15 @@ function DashboardPage() {
540
687
  const compareRate = compareTotals === null ? Number.NaN : autonomyRate(compareTotals);
541
688
  const settled = settledCount(totals);
542
689
  const signals = react.useMemo(() => dashboardSignals(totals, compareTotals), [totals, compareTotals]);
543
- const categoryBars = foldCategoryBreakdown(categoryCounts, categoryNames);
690
+ const reasons = react.useMemo(() => foldHumanReasons(dailyRows), [dailyRows]);
691
+ const categoryBars = react.useMemo(
692
+ () => foldCategoryOutcomes(categoryCounts, categoryOutcomes, categoryNames),
693
+ [categoryCounts, categoryOutcomes, categoryNames]
694
+ );
695
+ const categoryScale = categoryBars.reduce((max, bar) => Math.max(max, bar.total), 0);
544
696
  const loading = dailyLoading || previousLoading;
545
697
  const chartData = daily.map((point) => ({ ...point, jour: dayLabel(point.day) }));
546
698
  const bucketWord = bounds.interval === "day" ? "jour" : "semaine";
547
- const aCreuser = signals.find((signal) => signal.level === "creuser");
548
- const lead = loading ? null : settled === 0 ? {
549
- alert: false,
550
- title: "Aucune demande r\xE9gl\xE9e sur cette p\xE9riode",
551
- detail: "Choisis une autre p\xE9riode, ou v\xE9rifie que le triage tourne (Param\xE8tres \u203A Triage)."
552
- } : aCreuser !== void 0 ? { alert: true, title: "Un point m\xE9rite ton attention", detail: aCreuser.text } : {
553
- alert: false,
554
- title: `${formatRate(rate)} des demandes r\xE9gl\xE9es sans personne`,
555
- detail: `${formatCount(totals.auto)} r\xE9ponses envoy\xE9es par l\u2019IA, ${formatCount(totals.human)} reprises par un humain, sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
556
- };
557
699
  return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
558
700
  /* @__PURE__ */ jsxRuntime.jsx(
559
701
  PageHeader,
@@ -575,80 +717,35 @@ function DashboardPage() {
575
717
  ] })
576
718
  }
577
719
  ),
578
- lead !== null && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "flex items-start gap-3 p-4", children: [
579
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: lead.alert ? "warning" : "brand", children: lead.alert ? "\xC0 creuser" : "Cap" }),
580
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
581
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base font-semibold leading-snug", children: lead.title }),
582
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm leading-relaxed text-muted-foreground", children: lead.detail })
583
- ] })
584
- ] }) }),
585
- /* @__PURE__ */ jsxRuntime.jsxs(
586
- "div",
720
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "dashboard-kpis", children: /* @__PURE__ */ jsxRuntime.jsx(
721
+ AutonomyHero,
587
722
  {
588
- "data-testid": "dashboard-kpis",
589
- className: "grid grid-cols-1 gap-4 sm:grid-cols-[1.3fr_1fr_1fr]",
590
- children: [
591
- /* @__PURE__ */ jsxRuntime.jsx(
592
- AutonomyHero,
593
- {
594
- rate: loading ? Number.NaN : rate,
595
- compareRate,
596
- caption: loading ? "Calcul en cours\u2026" : `${formatCount(totals.auto)} r\xE9gl\xE9es par l\u2019IA sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
597
- }
598
- ),
599
- /* @__PURE__ */ jsxRuntime.jsx(
600
- uiSdk.KpiCard,
601
- {
602
- label: "R\xE9gl\xE9 par l\u2019IA",
603
- value: loading ? Number.NaN : totals.auto,
604
- ...compareTotals === null ? {} : { compareValue: compareTotals.auto },
605
- formatValue: formatCount
606
- }
607
- ),
608
- /* @__PURE__ */ jsxRuntime.jsx(
609
- uiSdk.KpiCard,
610
- {
611
- label: "Repris par un humain",
612
- value: loading ? Number.NaN : totals.human,
613
- ...compareTotals === null ? {} : { compareValue: compareTotals.human },
614
- formatValue: formatCount,
615
- lowerIsBetter: true
616
- }
617
- )
723
+ rate: loading ? Number.NaN : rate,
724
+ compareRate,
725
+ caption: loading ? "Calcul en cours\u2026" : `${formatCount(settled)} demandes r\xE9gl\xE9es sur la p\xE9riode.`,
726
+ sides: loading ? [] : [
727
+ {
728
+ label: "R\xE9ponse automatis\xE9e par l\u2019agent",
729
+ value: totals.auto,
730
+ formatValue: formatCount,
731
+ ...compareTotals === null ? {} : { compareValue: compareTotals.auto }
732
+ },
733
+ {
734
+ label: "Repris par un humain",
735
+ value: totals.human,
736
+ formatValue: formatCount,
737
+ lowerIsBetter: true,
738
+ ...compareTotals === null ? {} : { compareValue: compareTotals.human }
739
+ }
618
740
  ]
619
741
  }
620
- ),
621
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
622
- /* @__PURE__ */ jsxRuntime.jsx(
623
- uiSdk.KpiCard,
624
- {
625
- label: "Encore en cours",
626
- value: loading ? Number.NaN : totals.inProgress,
627
- formatValue: formatCount
628
- }
629
- ),
630
- /* @__PURE__ */ jsxRuntime.jsx(
631
- uiSdk.KpiCard,
632
- {
633
- label: "Sans r\xE9ponse n\xE9cessaire",
634
- value: loading ? Number.NaN : totals.noReplyNeeded,
635
- formatValue: formatCount
636
- }
637
- ),
638
- /* @__PURE__ */ jsxRuntime.jsx(
639
- uiSdk.KpiCard,
640
- {
641
- label: "\xC9checs techniques",
642
- value: loading ? Number.NaN : totals.failed,
643
- ...compareTotals === null ? {} : { compareValue: compareTotals.failed },
644
- formatValue: formatCount,
645
- lowerIsBetter: true
646
- }
647
- )
742
+ ) }),
743
+ /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "text-xs leading-relaxed text-muted-foreground", children: [
744
+ /* @__PURE__ */ jsxRuntime.jsx("summary", { className: "cursor-pointer select-none font-medium", children: "Comment le taux d\u2019autonomie est calcul\xE9" }),
745
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2", children: "Le taux d\u2019autonomie rapporte les r\xE9ponses envoy\xE9es par l\u2019IA \xE0 ces m\xEAmes r\xE9ponses plus celles qu\u2019un humain a reprises \u2014 bloqu\xE9es, escalad\xE9es, invalid\xE9es parce qu\u2019un agent avait d\xE9j\xE0 r\xE9pondu, ou expir\xE9es. \xB7 Une escalade est compt\xE9e UNE fois, du c\xF4t\xE9 humain : c\u2019est un motif de blocage, pas un camp de plus. \xB7 Les demandes encore en cours, celles sans r\xE9ponse n\xE9cessaire et les \xE9checs techniques sont hors du taux \u2014 les compter d\u2019un c\xF4t\xE9 ou de l\u2019autre le fausserait dans les deux sens. \xB7 Le d\xE9nominateur ne couvre que les demandes mises en file : un ticket escalad\xE9 avant toute g\xE9n\xE9ration n\u2019y figure pas." })
648
746
  ] }),
649
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Le taux d\u2019autonomie rapporte les r\xE9ponses envoy\xE9es par l\u2019IA \xE0 ces m\xEAmes r\xE9ponses plus celles qu\u2019un humain a reprises \u2014 bloqu\xE9es, escalad\xE9es, invalid\xE9es parce qu\u2019un agent avait d\xE9j\xE0 r\xE9pondu, ou expir\xE9es. \xB7 Une escalade est compt\xE9e UNE fois, du c\xF4t\xE9 humain : c\u2019est un motif de blocage, pas un camp de plus. \xB7 Les demandes encore en cours, celles sans r\xE9ponse n\xE9cessaire et les \xE9checs techniques sont hors du taux \u2014 les compter d\u2019un c\xF4t\xE9 ou de l\u2019autre le fausserait dans les deux sens. \xB7 Le d\xE9nominateur ne couvre que les demandes mises en file : un ticket escalad\xE9 avant toute g\xE9n\xE9ration n\u2019y figure pas." }),
650
747
  dailyError !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du calcul des chiffres cl\xE9s." }),
651
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
748
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4", children: [
652
749
  /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
653
750
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardTitle, { className: "text-sm", children: [
654
751
  "Automatique ou humain, ",
@@ -709,19 +806,105 @@ function DashboardPage() {
709
806
  ] }),
710
807
  /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
711
808
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "R\xE9partition par cat\xE9gorie" }) }),
712
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: categoryLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : categoryError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer la r\xE9partition par cat\xE9gorie." }) : categoryBars.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun volume calcul\xE9 pour l'instant sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
713
- /* @__PURE__ */ jsxRuntime.jsx(
714
- uiSdk.BarChart,
809
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { className: "space-y-3", children: categoryLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : categoryError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer la r\xE9partition par cat\xE9gorie." }) : categoryBars.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun volume calcul\xE9 pour l'instant sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
810
+ /* @__PURE__ */ jsxRuntime.jsx(StackedLegend, { segments: CATEGORY_LEGEND }),
811
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1.5", children: categoryBars.map((bar) => /* @__PURE__ */ jsxRuntime.jsx(
812
+ StackedRow,
715
813
  {
716
- data: categoryBars,
717
- x: "label",
718
- series: [{ key: "value", label: "Volume", colorIndex: 0 }]
719
- }
720
- ),
721
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-xs leading-relaxed text-muted-foreground", children: "Les d\xE9cisions de triage de la p\xE9riode, par cat\xE9gorie \u2014 le volume qui entre, avant toute id\xE9e de qui l\u2019a r\xE9gl\xE9." })
814
+ label: bar.label,
815
+ total: bar.total,
816
+ scale: categoryScale,
817
+ formatCount,
818
+ segments: [
819
+ {
820
+ key: "auto",
821
+ label: "R\xE9ponse automatis\xE9e par l\u2019agent",
822
+ value: bar.auto,
823
+ color: CATEGORY_COLORS.auto
824
+ },
825
+ {
826
+ key: "human",
827
+ label: "Repris par un humain",
828
+ value: bar.human,
829
+ color: CATEGORY_COLORS.human
830
+ },
831
+ {
832
+ key: "noReply",
833
+ label: "Sans r\xE9ponse n\xE9cessaire",
834
+ value: bar.noReply,
835
+ color: CATEGORY_COLORS.noReply
836
+ },
837
+ {
838
+ key: "undrafted",
839
+ label: "Sans brouillon",
840
+ value: bar.undrafted,
841
+ color: CATEGORY_COLORS.undrafted
842
+ }
843
+ ]
844
+ },
845
+ bar.label
846
+ )) }),
847
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Ce qui arrive, par cat\xE9gorie \u2014 et qui l\u2019a trait\xE9. La longueur d\u2019une barre est le volume tri\xE9 sur la p\xE9riode ; les couleurs sont ce que ce volume est devenu. \xAB\xA0Sans brouillon\xA0\xBB couvre ce que le triage a vu sans qu\u2019une r\xE9ponse soit g\xE9n\xE9r\xE9e : escalade imm\xE9diate, conversation d\xE9j\xE0 close, ou traitement encore en cours." })
722
848
  ] }) })
723
849
  ] })
724
850
  ] }),
851
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
852
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "Pourquoi un humain a repris" }) }),
853
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { className: "space-y-3", children: loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : totals.human === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune reprise humaine sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
854
+ /* @__PURE__ */ jsxRuntime.jsx(
855
+ StackedRow,
856
+ {
857
+ label: "Motifs",
858
+ total: totals.human,
859
+ scale: totals.human,
860
+ formatCount,
861
+ segments: [
862
+ {
863
+ key: "blocked",
864
+ label: "Bloqu\xE9 avant envoi",
865
+ value: reasons.blocked,
866
+ color: "var(--chart-2)"
867
+ },
868
+ {
869
+ key: "invalidated",
870
+ label: "Un agent avait d\xE9j\xE0 r\xE9pondu",
871
+ value: reasons.invalidated,
872
+ color: "var(--chart-3)"
873
+ },
874
+ {
875
+ key: "expired",
876
+ label: "Brouillon expir\xE9",
877
+ value: reasons.expired,
878
+ color: "var(--chart-5)"
879
+ }
880
+ ]
881
+ }
882
+ ),
883
+ /* @__PURE__ */ jsxRuntime.jsx(
884
+ StackedLegend,
885
+ {
886
+ segments: [
887
+ {
888
+ key: "blocked",
889
+ label: `Bloqu\xE9 avant envoi (${formatCount(reasons.blocked)})`,
890
+ color: "var(--chart-2)"
891
+ },
892
+ {
893
+ key: "invalidated",
894
+ label: `Un agent avait d\xE9j\xE0 r\xE9pondu (${formatCount(reasons.invalidated)})`,
895
+ color: "var(--chart-3)"
896
+ },
897
+ {
898
+ key: "expired",
899
+ label: `Brouillon expir\xE9 (${formatCount(reasons.expired)})`,
900
+ color: "var(--chart-5)"
901
+ }
902
+ ]
903
+ }
904
+ ),
905
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Les escalades sont dans \xAB\xA0bloqu\xE9\xA0\xBB : un ticket escalad\xE9 voit son brouillon retenu par le garde-fou, c\u2019est un motif de blocage et non un camp de plus. Le d\xE9tail ticket par ticket est sur la page Escalades." })
906
+ ] }) })
907
+ ] }),
725
908
  /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
726
909
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "Signaux \xE0 surveiller" }) }),
727
910
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: signals.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rien de notable sur cette p\xE9riode \u2014 ou pas assez de demandes r\xE9gl\xE9es pour qu\u2019une comparaison veuille dire quelque chose." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: signals.map((signal) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [