@bitcobblers/wod-wiki-ui 0.62.2261 → 0.62.2263

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.
@@ -8,7 +8,7 @@ import { computeWhiteboardEnterAction, whiteboardScriptLanguage, createParser, w
8
8
  import { mapNoteBlockChanges, validateNoteBlocks, reconcileNoteBlocks, parseDocumentSections, actionableSectionKind, patchFrontmatterProperty, formatDurationMMSS, metricToMs, createMetricOwnershipLedger, MetricType } from '@bitcobblers/wod-wiki-core';
9
9
  export { blockContentId } from '@bitcobblers/wod-wiki-core';
10
10
  import { invertedEffects, history, historyKeymap, cursorPageUp, cursorPageDown, cursorDocStart, cursorDocEnd, defaultKeymap, indentWithTab } from '@codemirror/commands';
11
- import { WQL_FIND_TARGETS, WQL_SOURCE_VALUES, WQL_RESULT_PLANES, WQL_AGGREGATORS, WQL_VIRTUAL_DIMS, WQL_TAG_KEYS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_CALC_TARGETS, WQL_DISPLAY_UNITS, WQL_INTENSITY_TIERS, parseQueryWidgetSuffix, resolveQueryExecutionScope, wqlLanguage, parseFrontmatterBody, isYamlQueryBlockBody, parseQueryBlock, queryBlockToDocumentText, parseDocument, queryBlockAttributes, substituteTokens, parseQuery, isDashboardWidgetType, isFindQuery, isPipelineQuery, unknownWidgetTypeMessage, unknownTokensMessage, wqlCompletionSource, SharedQueryDocumentRunner, serializeQueryBlock, resolveWidgetType, computeRowsRunSummary, serialize, DASHBOARD_WIDGET_TYPES, PLANNED_WIDGET_TYPES, resolveWqlCursorStage, CONTENT_GROUPING_DIMENSIONS, allowedFilterTypesForTarget, wqlGroupingDimensions, isAggregateQuery, wqlHighlightStyle, supportsWqlFilterKey, dimensionKeyOf, WQL_NOTE_DEFAULT_SOURCES, notebookSlugOfSourceId, wql } from '@bitcobblers/wod-wiki-wql';
11
+ import { WQL_FIND_TARGETS, WQL_SOURCE_VALUES, WQL_RESULT_PLANES, WQL_AGGREGATORS, WQL_VIRTUAL_DIMS, WQL_TAG_KEYS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_CALC_TARGETS, WQL_DISPLAY_UNITS, WQL_INTENSITY_TIERS, parseQueryWidgetSuffix, resolveQueryExecutionScope, wqlLanguage, parseFrontmatterBody, isYamlQueryBlockBody, parseQueryBlock, queryBlockToDocumentText, parseDocument, queryBlockAttributes, substituteTokens, parseQuery, isDashboardWidgetType, isFindQuery, isPipelineQuery, unknownWidgetTypeMessage, unknownTokensMessage, wqlCompletionSource, SharedQueryDocumentRunner, serializeQueryBlock, resolveWidgetType, computeRowsRunSummary, serialize, DASHBOARD_WIDGET_TYPES, PLANNED_WIDGET_TYPES, selectSplitSegmentEvents, resolveWqlCursorStage, CONTENT_GROUPING_DIMENSIONS, allowedFilterTypesForTarget, wqlGroupingDimensions, isAggregateQuery, wqlHighlightStyle, supportsWqlFilterKey, dimensionKeyOf, WQL_NOTE_DEFAULT_SOURCES, notebookSlugOfSourceId, wql } from '@bitcobblers/wod-wiki-wql';
12
12
  export { CONTENT_GROUPING_DIMENSIONS } from '@bitcobblers/wod-wiki-wql';
13
13
  import { snippet, completionStatus, selectedCompletionIndex, acceptCompletion, closeCompletion, startCompletion, autocompletion, currentCompletions, setSelectedCompletion, CompletionContext, moveCompletionSelection, closeBrackets, closeBracketsKeymap, ifNotIn, completeFromList, snippetCompletion } from '@codemirror/autocomplete';
14
14
  import { createRoot } from 'react-dom/client';
@@ -825,6 +825,15 @@ function formatMMSS(ms) {
825
825
  const s = totalSec % 60;
826
826
  return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
827
827
  }
828
+ function formatOffsetMMSS(deltaMs) {
829
+ if (!Number.isFinite(deltaMs)) return "+00:00";
830
+ if (deltaMs < 0) {
831
+ const absSec = Math.floor(-deltaMs / 1e3);
832
+ if (absSec === 0) return "+00:00";
833
+ return `-${formatMMSS(-deltaMs)}`;
834
+ }
835
+ return `+${formatMMSS(deltaMs)}`;
836
+ }
828
837
  function formatClockTime(d) {
829
838
  return d.toLocaleTimeString("en-US", {
830
839
  hour12: false,
@@ -919,10 +928,146 @@ function formatOutputTypeLabel(outputType) {
919
928
  if (!raw) return "System";
920
929
  return OUTPUT_TYPE_LABEL[raw] ?? raw.charAt(0).toUpperCase() + raw.slice(1);
921
930
  }
922
- function formatOutputRowTitle(outputType, elapsedStr) {
923
- const label = formatOutputTypeLabel(outputType);
931
+ var ACRONYMS = {
932
+ c2b: "C2B",
933
+ t2b: "T2B",
934
+ ghd: "GHD",
935
+ hspu: "HSPU",
936
+ amrap: "AMRAP",
937
+ emom: "EMOM",
938
+ rft: "RFT"
939
+ };
940
+ function humanizeSlug(slug) {
941
+ return slug.trim().split(/[-_\s]+/).filter(Boolean).map((word) => {
942
+ const lower = word.toLowerCase();
943
+ return ACRONYMS[lower] ?? word.charAt(0).toUpperCase() + word.slice(1);
944
+ }).join(" ");
945
+ }
946
+ var GENERIC_LABELS = /* @__PURE__ */ new Set(["segment", "statement", "completed", "system"]);
947
+ function resolveOutputRowLabel(out) {
948
+ const explicitLabel = out.label?.trim();
949
+ if (explicitLabel && !GENERIC_LABELS.has(explicitLabel.toLowerCase())) {
950
+ return explicitLabel;
951
+ }
952
+ const all = out.metrics ? Array.from(out.metrics) : [];
953
+ for (const m of all) {
954
+ const t = String(m.type ?? "").toLowerCase();
955
+ if (t === "effort" || t === "action" || t === "label" || t === "text") {
956
+ const rawText = typeof m.image === "string" && m.image.trim() || typeof m.value === "string" && m.value.trim() || "";
957
+ if (!rawText) continue;
958
+ const lower = rawText.toLowerCase();
959
+ if (lower === "ready to start") return "Start";
960
+ if (lower === "session" || lower === "session completed") return "Session";
961
+ if (!GENERIC_LABELS.has(lower)) return rawText;
962
+ }
963
+ }
964
+ if (out.effortSlug && out.effortSlug.trim()) {
965
+ return humanizeSlug(out.effortSlug);
966
+ }
967
+ const rawStatement = (out.statement ?? out.text ?? "").trim();
968
+ if (rawStatement) {
969
+ const firstLine = rawStatement.split("\n")[0]?.trim() ?? "";
970
+ if (firstLine && !GENERIC_LABELS.has(firstLine.toLowerCase())) {
971
+ return firstLine;
972
+ }
973
+ }
974
+ for (const m of all) {
975
+ const t = String(m.type ?? "").toLowerCase();
976
+ if (t === "current-round" || t === "rounds") {
977
+ const img = typeof m.image === "string" ? m.image.trim() : "";
978
+ if (/^completed\b/i.test(img)) return img;
979
+ const n = typeof m.value === "number" ? m.value : Number(m.value);
980
+ if (Number.isFinite(n) && n > 0) {
981
+ return t === "current-round" ? `Round ${n}` : `${n} ${n === 1 ? "Round" : "Rounds"}`;
982
+ }
983
+ }
984
+ }
985
+ const blockKey = String(out.sourceBlockKey ?? "").trim().toLowerCase();
986
+ if (blockKey.startsWith("waiting-to-start")) return "Start";
987
+ if (blockKey.startsWith("session-root") || blockKey === "root") return "Session";
988
+ if (blockKey.startsWith("rest")) return "Rest";
989
+ const roundMatch = /^round[-_:\s]*(\d+)/i.exec(blockKey);
990
+ if (roundMatch) return `Round ${roundMatch[1]}`;
991
+ if (blockKey.startsWith("rounds")) return "Rounds";
992
+ if (String(out.outputType ?? "").toLowerCase() === "analytics" && all.length > 0) {
993
+ const first = all[0];
994
+ const meta = first.metadata;
995
+ const summaryName = typeof meta?.originalKey === "string" && meta.originalKey || typeof meta?.canonicalKey === "string" && meta.canonicalKey || String(first.type ?? "");
996
+ if (summaryName) return summaryName;
997
+ }
998
+ return formatOutputTypeLabel(out.outputType);
999
+ }
1000
+ function resolveOutputTypeBadgeLabel(out) {
1001
+ const rawType = String(out.outputType ?? "system").trim().toLowerCase();
1002
+ if (rawType !== "segment") return formatOutputTypeLabel(out.outputType);
1003
+ const blockKey = String(out.sourceBlockKey ?? "").trim().toLowerCase();
1004
+ if (blockKey.startsWith("waiting-to-start")) return "Start";
1005
+ if (blockKey.startsWith("session-root") || blockKey === "root") return "Session";
1006
+ if (blockKey.startsWith("rest")) return "Rest";
1007
+ const all = out.metrics ? Array.from(out.metrics) : [];
1008
+ const hasEffort = Boolean(out.effortSlug) || all.some((m) => String(m.type ?? "").toLowerCase() === "effort");
1009
+ if (!hasEffort) {
1010
+ const hasRoundMetric = all.some((m) => {
1011
+ const t = String(m.type ?? "").toLowerCase();
1012
+ return t === "rounds" || t === "current-round";
1013
+ });
1014
+ if (hasRoundMetric || blockKey.startsWith("round")) return "Rounds";
1015
+ }
1016
+ return "Segment";
1017
+ }
1018
+ function formatOutputRowTitle(out, elapsedStr) {
1019
+ const label = resolveOutputRowLabel(out);
924
1020
  return elapsedStr ? `${label} (${elapsedStr})` : label;
925
1021
  }
1022
+ function resolveTimeOrigin(outputs, timeOrigin) {
1023
+ let minStarted;
1024
+ let maxStarted;
1025
+ for (const o of outputs) {
1026
+ const s = o.timeSpan?.started;
1027
+ if (typeof s !== "number" || !Number.isFinite(s)) continue;
1028
+ minStarted = minStarted === void 0 ? s : Math.min(minStarted, s);
1029
+ maxStarted = maxStarted === void 0 ? s : Math.max(maxStarted, s);
1030
+ }
1031
+ if (typeof timeOrigin === "number" && Number.isFinite(timeOrigin)) {
1032
+ if (minStarted !== void 0 && timeOrigin > minStarted && (maxStarted === void 0 || timeOrigin >= maxStarted)) {
1033
+ return minStarted;
1034
+ }
1035
+ return timeOrigin;
1036
+ }
1037
+ return minStarted;
1038
+ }
1039
+ function metricDurationToMs(m) {
1040
+ const rawVal = typeof m.value === "number" ? m.value : Number(m.value);
1041
+ if (!Number.isFinite(rawVal) || rawVal <= 0) return void 0;
1042
+ const unit = "unit" in m && typeof m.unit === "string" ? m.unit.trim().toLowerCase() : "";
1043
+ if (unit === "s" || unit === "sec" || unit === "secs" || unit === "second" || unit === "seconds") {
1044
+ return rawVal * 1e3;
1045
+ }
1046
+ if (unit === "min" || unit === "mins" || unit === "minute" || unit === "minutes") {
1047
+ return rawVal * 6e4;
1048
+ }
1049
+ return rawVal;
1050
+ }
1051
+ function resolveRowDurationMs(out) {
1052
+ const started = out.timeSpan?.started;
1053
+ const ended = out.timeSpan?.ended;
1054
+ if (started !== void 0 && ended !== void 0 && ended > started) {
1055
+ return ended - started;
1056
+ }
1057
+ if (out.metrics) {
1058
+ for (const m of out.metrics) {
1059
+ const t = String(m.type ?? "").toLowerCase();
1060
+ if (t === "elapsed" || t === "duration") {
1061
+ const ms = metricDurationToMs(m);
1062
+ if (ms !== void 0 && ms > 0) return ms;
1063
+ }
1064
+ }
1065
+ }
1066
+ if (started !== void 0 && ended !== void 0) {
1067
+ return Math.max(0, ended - started);
1068
+ }
1069
+ return void 0;
1070
+ }
926
1071
  var EFFORT_TYPES = /* @__PURE__ */ new Set(["effort", "text", "action", "label"]);
927
1072
  var LOAD_TYPES = /* @__PURE__ */ new Set([
928
1073
  "resistance",
@@ -1128,13 +1273,11 @@ function extractMetricsForColumn(out, col, dynamicLowerTypes) {
1128
1273
  case "effort": {
1129
1274
  const explicitEfforts = all.filter((m) => EFFORT_TYPES.has(String(m.type).toLowerCase()));
1130
1275
  if (explicitEfforts.length > 0) return explicitEfforts;
1131
- if (String(out.outputType ?? "").toLowerCase() === "analytics" && all.length > 0) {
1132
- const first = all[0];
1133
- const meta = first.metadata;
1134
- const summaryName = typeof meta?.originalKey === "string" && meta.originalKey || typeof meta?.canonicalKey === "string" && meta.canonicalKey || String(first.type ?? "");
1135
- if (summaryName) {
1136
- return [{ type: "label", value: summaryName, image: summaryName, origin: first.origin }];
1137
- }
1276
+ const resolved = resolveOutputRowLabel(out);
1277
+ const genericType = formatOutputTypeLabel(out.outputType);
1278
+ if (resolved && resolved !== genericType) {
1279
+ const origin = all[0]?.origin ?? "runtime";
1280
+ return [{ type: "label", value: resolved, image: resolved, origin }];
1138
1281
  }
1139
1282
  return [];
1140
1283
  }
@@ -1254,13 +1397,20 @@ function StatementCards({
1254
1397
  }
1255
1398
  return /* @__PURE__ */ jsx("ol", { className: "flex flex-col", "data-testid": "output-statements-cards", children: rows.map((out, idx) => {
1256
1399
  const cats = extractMetricsByCategory(out.metrics);
1400
+ if (cats.efforts.length === 0) {
1401
+ const resolved = resolveOutputRowLabel(out);
1402
+ const genericType = formatOutputTypeLabel(out.outputType);
1403
+ if (resolved && resolved !== genericType) {
1404
+ cats.efforts.push({ type: "label", value: resolved, image: resolved, origin: "runtime" });
1405
+ }
1406
+ }
1257
1407
  const started = out.timeSpan?.started;
1258
- const ended = out.timeSpan?.ended;
1259
- const elapsedStr = ended !== void 0 && started !== void 0 ? formatMMSS(ended - started) : "running";
1260
- const offsetStr = started !== void 0 && t0 !== void 0 ? `+${formatMMSS(started - t0)}` : "+00:00";
1408
+ const durationMs = resolveRowDurationMs(out);
1409
+ const elapsedStr = durationMs !== void 0 ? formatMMSS(durationMs) : "running";
1410
+ const offsetStr = started !== void 0 && t0 !== void 0 ? formatOffsetMMSS(started - t0) : "+00:00";
1261
1411
  const typeKey = String(out.outputType);
1262
- const typeLabel = formatOutputTypeLabel(out.outputType);
1263
- const rowTitle = formatOutputRowTitle(out.outputType, elapsedStr);
1412
+ const typeLabel = resolveOutputTypeBadgeLabel(out);
1413
+ const rowTitle = formatOutputRowTitle(out, elapsedStr);
1264
1414
  const pr = lookupPrHighlight(out, prHighlights);
1265
1415
  const bodyMetrics = [...cats.reps, ...cats.loads, ...cats.rounds, ...cats.durations, ...cats.distances];
1266
1416
  const hasBody = bodyMetrics.length > 0;
@@ -1381,7 +1531,7 @@ function OutputStatementsTable({
1381
1531
  onEditMetric,
1382
1532
  prHighlights
1383
1533
  }) {
1384
- const t0 = timeOrigin ?? (outputs.length > 0 ? outputs[0].timeSpan?.started : void 0);
1534
+ const t0 = useMemo(() => resolveTimeOrigin(outputs, timeOrigin), [outputs, timeOrigin]);
1385
1535
  const [internalSort, setInternalSort] = useState(
1386
1536
  controlledSort ? [...controlledSort] : []
1387
1537
  );
@@ -1548,11 +1698,12 @@ function OutputStatementsTable({
1548
1698
  /* @__PURE__ */ jsx("tbody", { className: "divide-y divide-border/40", children: rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: activeColumns.length, className: "p-8 text-center text-muted-foreground font-sans text-xs", children: outputs.length === 0 ? "No output statements recorded for this run." : "No output statements match the current filter." }) }) : rows.map((out, idx) => {
1549
1699
  const started = out.timeSpan?.started;
1550
1700
  const ended = out.timeSpan?.ended;
1551
- const elapsedStr = ended !== void 0 && started !== void 0 ? formatMMSS(ended - started) : "running";
1552
- const wallTimeStr = formatClockTime(new Date(ended ?? started ?? 0));
1553
- const offsetStr = started !== void 0 && t0 !== void 0 ? `+${formatMMSS(started - t0)}` : "+00:00";
1554
- const typeLabel = formatOutputTypeLabel(out.outputType);
1555
- const rowTitle = formatOutputRowTitle(out.outputType, elapsedStr);
1701
+ const durationMs = resolveRowDurationMs(out);
1702
+ const elapsedStr = durationMs !== void 0 ? formatMMSS(durationMs) : "running";
1703
+ const wallTimeStr = ended !== void 0 || started !== void 0 ? formatClockTime(new Date(ended ?? started ?? 0)) : "\u2014";
1704
+ const offsetStr = started !== void 0 && t0 !== void 0 ? formatOffsetMMSS(started - t0) : "+00:00";
1705
+ const typeLabel = resolveOutputTypeBadgeLabel(out);
1706
+ const rowTitle = formatOutputRowTitle(out, elapsedStr);
1556
1707
  const rowKey = String(out.id ?? `${out.sourceBlockKey ?? "row"}-${idx}`);
1557
1708
  const pr = lookupPrHighlight(out, prHighlights);
1558
1709
  const canInlineEditRow = Boolean(onEditMetric) && String(out.outputType ?? "").toLowerCase() === "segment" && Boolean(out.sourceBlockKey);
@@ -3580,7 +3731,18 @@ function formatPaceMMSS(secPerKm) {
3580
3731
  const secs = rounded % 60;
3581
3732
  return `${mins}:${String(secs).padStart(2, "0")} /km`;
3582
3733
  }
3583
- function humanizeSlug(slug) {
3734
+ function normalizePaceToSecPerKm(value, unit) {
3735
+ if (!Number.isFinite(value) || value <= 0) return null;
3736
+ const u = (unit ?? "").trim().toLowerCase();
3737
+ if (!u || u === "sec/km" || u === "s/km") return value;
3738
+ if (u === "min/km") return value * 60;
3739
+ if (u === "min/mi") return value * 60 / 1.609344;
3740
+ if (u === "sec/mi" || u === "s/mi") return value / 1.609344;
3741
+ if (u === "m/s") return 1e3 / value;
3742
+ if (u === "km/h" || u === "kph") return 3600 / value;
3743
+ return null;
3744
+ }
3745
+ function humanizeSlug2(slug) {
3584
3746
  return slug.split(/[-_\s]+/).filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
3585
3747
  }
3586
3748
  function normalizePrLookup(prHighlights) {
@@ -3632,25 +3794,7 @@ function extractVisibleMetrics(row) {
3632
3794
  }
3633
3795
  function buildSpreadsheetRows(run, prHighlights) {
3634
3796
  const prMap = normalizePrLookup(prHighlights);
3635
- const rawSegments = (run.events ?? []).filter((e) => {
3636
- if (e.outputType !== "segment") return false;
3637
- const key = String(e.sourceBlockKey ?? "").toLowerCase();
3638
- return !key.startsWith("waiting-to-start") && key !== "session-root" && key !== "root";
3639
- });
3640
- const maxStackLevel = rawSegments.reduce((max, e) => Math.max(max, e.stackLevel ?? 0), 0);
3641
- const hasEffortLeaves = rawSegments.some((e) => {
3642
- const metrics = extractVisibleMetrics(e);
3643
- return Boolean(e.effortSlug) || metrics.some((m) => String(m.type ?? "").toLowerCase() === "effort");
3644
- });
3645
- const segmentEvents = hasEffortLeaves ? rawSegments.filter((e) => {
3646
- if ((e.stackLevel ?? 0) >= maxStackLevel) return true;
3647
- const metrics = extractVisibleMetrics(e);
3648
- const hasMovement = Boolean(e.effortSlug) || metrics.some((m) => {
3649
- const t = String(m.type ?? "").toLowerCase();
3650
- return t === "effort" || t === "rep" || t === "reps" || t === "distance";
3651
- });
3652
- return hasMovement;
3653
- }) : rawSegments;
3797
+ const segmentEvents = selectSplitSegmentEvents(run.events ?? []);
3654
3798
  const sessionStart = segmentEvents.reduce(
3655
3799
  (min, e) => e.timeSpan?.started !== void 0 ? Math.min(min, e.timeSpan.started) : min,
3656
3800
  run.timestamp
@@ -3689,7 +3833,7 @@ function buildSpreadsheetRows(run, prHighlights) {
3689
3833
  if (lower === "effort" || canon === "effort") {
3690
3834
  const slugVal = typeof m.metadata?.effortSlug === "string" ? String(m.metadata.effortSlug) : typeof m.value === "string" ? m.value : "";
3691
3835
  if (!effortSlug && slugVal) effortSlug = slugVal;
3692
- movement = String(m.image ?? (slugVal ? humanizeSlug(slugVal) : m.value ?? "")).trim();
3836
+ movement = String(m.image ?? (slugVal ? humanizeSlug2(slugVal) : m.value ?? "")).trim();
3693
3837
  continue;
3694
3838
  }
3695
3839
  if (typeof m.value !== "number" || !Number.isFinite(m.value)) continue;
@@ -3739,13 +3883,20 @@ function buildSpreadsheetRows(run, prHighlights) {
3739
3883
  power = m.value;
3740
3884
  if (m.unit) powerUnit = m.unit;
3741
3885
  } else if (canon === "pace") {
3742
- paceSecPerKm = m.value;
3886
+ const normalized = normalizePaceToSecPerKm(m.value, m.unit);
3887
+ if (normalized !== null) {
3888
+ const u = (m.unit ?? "").trim().toLowerCase();
3889
+ const isExplicitPace = !u || u === "min/km" || u === "sec/km" || u === "s/km" || u === "min/mi" || u === "sec/mi" || u === "s/mi";
3890
+ if (paceSecPerKm === null || isExplicitPace || isUser) {
3891
+ paceSecPerKm = normalized;
3892
+ }
3893
+ }
3743
3894
  } else if (canon === "rounds" || canon === "currentround" || lower === "current-round") {
3744
3895
  round = Math.round(m.value);
3745
3896
  } else if (!KNOWN_CANONICAL_KEYS.has(canon) && !KNOWN_CANONICAL_KEYS.has(lower)) {
3746
3897
  const key = canon || lower;
3747
3898
  custom[key] = {
3748
- label: humanizeSlug(mType),
3899
+ label: humanizeSlug2(mType),
3749
3900
  value: m.value,
3750
3901
  ...m.unit ? { unit: m.unit } : {},
3751
3902
  modified: isUser
@@ -3753,7 +3904,7 @@ function buildSpreadsheetRows(run, prHighlights) {
3753
3904
  }
3754
3905
  }
3755
3906
  if (!movement) {
3756
- movement = effortSlug ? humanizeSlug(effortSlug) : `Split ${index + 1}`;
3907
+ movement = effortSlug ? humanizeSlug2(effortSlug) : `Split ${index + 1}`;
3757
3908
  }
3758
3909
  if (splitSec === null && ev.timeSpan?.started !== void 0 && ev.timeSpan?.ended !== void 0) {
3759
3910
  splitSec = Math.max(0, (ev.timeSpan.ended - ev.timeSpan.started) / 1e3);
@@ -4896,27 +5047,42 @@ function ResultsSpreadsheetGrid({
4896
5047
  );
4897
5048
  }) })
4898
5049
  ] }) }),
4899
- activeTab === "raw" && /* @__PURE__ */ jsxs("div", { "data-testid": "results-tab-panel-raw", className: "space-y-2.5", children: [
4900
- /* @__PURE__ */ jsx(
4901
- OutputFilterPills,
4902
- {
4903
- presets: DEFAULT_OUTPUT_FILTERS.map(normalizeOutputFilter),
4904
- filter: rawFilter,
4905
- onChange: setRawFilter
5050
+ activeTab === "raw" && (() => {
5051
+ const events = run.events ?? [];
5052
+ let activeMinStart;
5053
+ let anyMinStart;
5054
+ for (const e of events) {
5055
+ const s = e.timeSpan?.started;
5056
+ if (typeof s !== "number" || !Number.isFinite(s)) continue;
5057
+ anyMinStart = anyMinStart === void 0 ? s : Math.min(anyMinStart, s);
5058
+ const key = String(e.sourceBlockKey ?? "").toLowerCase();
5059
+ if (e.outputType === "segment" && !key.startsWith("waiting-to-start")) {
5060
+ activeMinStart = activeMinStart === void 0 ? s : Math.min(activeMinStart, s);
4906
5061
  }
4907
- ),
4908
- /* @__PURE__ */ jsx(
4909
- OutputStatementsTable,
4910
- {
4911
- outputs: run.events,
4912
- filter: rawFilter,
4913
- timeOrigin: run.timestamp,
4914
- onClearFilter: () => setRawFilter(""),
4915
- onEditMetric: onEditMetric ? (p) => onEditMetric(run.resultId, p) : void 0,
4916
- prHighlights
4917
- }
4918
- )
4919
- ] }),
5062
+ }
5063
+ const rawTimeOrigin = activeMinStart ?? anyMinStart ?? run.timestamp;
5064
+ return /* @__PURE__ */ jsxs("div", { "data-testid": "results-tab-panel-raw", className: "space-y-2.5", children: [
5065
+ /* @__PURE__ */ jsx(
5066
+ OutputFilterPills,
5067
+ {
5068
+ presets: DEFAULT_OUTPUT_FILTERS.map(normalizeOutputFilter),
5069
+ filter: rawFilter,
5070
+ onChange: setRawFilter
5071
+ }
5072
+ ),
5073
+ /* @__PURE__ */ jsx(
5074
+ OutputStatementsTable,
5075
+ {
5076
+ outputs: events,
5077
+ filter: rawFilter,
5078
+ timeOrigin: rawTimeOrigin,
5079
+ onClearFilter: () => setRawFilter(""),
5080
+ onEditMetric: onEditMetric ? (p) => onEditMetric(run.resultId, p) : void 0,
5081
+ prHighlights
5082
+ }
5083
+ )
5084
+ ] });
5085
+ })(),
4920
5086
  /* @__PURE__ */ jsx(
4921
5087
  EditorDialog,
4922
5088
  {
@@ -12856,6 +13022,26 @@ function createCloseIcon(size = "md") {
12856
13022
  function isAliasProperty(key) {
12857
13023
  return ["alias", "aliases"].includes(key.trim().toLowerCase());
12858
13024
  }
13025
+ function isSelfReferenceHref(docKind, meta, matchSlug, href, referenceProvider) {
13026
+ const normMatch = matchSlug.trim().toLowerCase();
13027
+ if (meta) {
13028
+ const metaSlug = typeof meta.slug === "string" ? meta.slug.trim().toLowerCase() : "";
13029
+ if (metaSlug && metaSlug === normMatch) return true;
13030
+ if (docKind === "effort" || docKind === "equipment") {
13031
+ const ownName = typeof meta.label === "string" && meta.label.trim() || typeof meta.title === "string" && meta.title.trim() || "";
13032
+ if (ownName) {
13033
+ const ownMatch = docKind === "effort" ? referenceProvider.resolveEffort(ownName) : referenceProvider.resolveEquipment(ownName);
13034
+ if (ownMatch && ownMatch.slug.trim().toLowerCase() === normMatch) return true;
13035
+ }
13036
+ }
13037
+ }
13038
+ if (typeof window !== "undefined" && window.location?.pathname) {
13039
+ const currentPath = window.location.pathname.replace(/\/+$/, "");
13040
+ const targetPath = href.split(/[?#]/)[0].replace(/\/+$/, "");
13041
+ if (currentPath && targetPath && currentPath === targetPath) return true;
13042
+ }
13043
+ return false;
13044
+ }
12859
13045
  function createSummaryPill(value, hash2, href) {
12860
13046
  const pill = document.createElement("span");
12861
13047
  pill.className = "inline-flex max-w-full items-center rounded-md border border-border/60 bg-muted/40 px-2 py-0.5 text-xs text-foreground";
@@ -12874,7 +13060,7 @@ function createSummaryPill(value, hash2, href) {
12874
13060
  pill.appendChild(label);
12875
13061
  return pill;
12876
13062
  }
12877
- function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProvider) {
13063
+ function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProvider, meta) {
12878
13064
  const summary = document.createElement("div");
12879
13065
  summary.dataset.frontmatterSummary = "true";
12880
13066
  summary.className = "divide-y divide-border/60";
@@ -12900,10 +13086,11 @@ function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProv
12900
13086
  const lower = val.toLowerCase();
12901
13087
  if (seenTags.has(lower)) continue;
12902
13088
  seenTags.add(lower);
13089
+ const match = referenceProvider?.resolveTag?.(val, normKey) ?? null;
12903
13090
  tagItems.push({
12904
13091
  text: val,
12905
13092
  hash: true,
12906
- href: referenceProvider?.openHref("tag", val, normKey)
13093
+ href: match && referenceProvider ? referenceProvider.openHref("tag", match.slug, match.type ?? normKey) : void 0
12907
13094
  });
12908
13095
  }
12909
13096
  }
@@ -12953,7 +13140,12 @@ function createFrontmatterSummary(entries, onShowDetails, docKind, referenceProv
12953
13140
  let href;
12954
13141
  if (referenceProvider && (docKind === "effort" || docKind === "equipment")) {
12955
13142
  const match = docKind === "effort" ? referenceProvider.resolveEffort(val) : referenceProvider.resolveEquipment(val);
12956
- if (match) href = referenceProvider.openHref(docKind, match.slug);
13143
+ if (match) {
13144
+ const candidateHref = referenceProvider.openHref(docKind, match.slug);
13145
+ if (!isSelfReferenceHref(docKind, meta, match.slug, candidateHref, referenceProvider)) {
13146
+ href = candidateHref;
13147
+ }
13148
+ }
12957
13149
  }
12958
13150
  aliasItems.push({ text: val, hash: false, href });
12959
13151
  }
@@ -13081,7 +13273,7 @@ var DefaultFrontmatterWidget = class extends WidgetType {
13081
13273
  persistedDetailed.set(view.dom, true);
13082
13274
  view.dispatch({ effects: setFrontmatterDetailed.of(true) });
13083
13275
  view.dom.querySelector('[aria-label="Show property summary"]')?.focus();
13084
- }, docKind, referenceProvider));
13276
+ }, docKind, referenceProvider, meta));
13085
13277
  } else {
13086
13278
  box.appendChild(createColumnHeader());
13087
13279
  if (entries.length === 0) {
@@ -13238,9 +13430,11 @@ var DefaultFrontmatterWidget = class extends WidgetType {
13238
13430
  const pill = document.createElement("span");
13239
13431
  pill.className = match ? "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-muted/50 text-foreground border border-border/60" : chipIsReference ? "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-destructive/10 text-destructive border border-destructive/30" : "group/pill inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-muted/40 text-foreground/90 border border-border/60";
13240
13432
  const pillText = document.createElement("span");
13241
- if (isAliasRow && match && referenceProvider) {
13433
+ const aliasHref = isAliasRow && match && referenceProvider ? referenceProvider.openHref(valueKind, match.slug) : void 0;
13434
+ const isSelfAlias = isAliasRow && match && referenceProvider && aliasHref ? isSelfReferenceHref(docKind, meta, match.slug, aliasHref, referenceProvider) : false;
13435
+ if (isAliasRow && match && referenceProvider && aliasHref && !isSelfAlias) {
13242
13436
  const aliasLink = document.createElement("a");
13243
- aliasLink.href = referenceProvider.openHref(valueKind, match.slug);
13437
+ aliasLink.href = aliasHref;
13244
13438
  aliasLink.textContent = chip;
13245
13439
  aliasLink.className = "hover:underline cursor-pointer";
13246
13440
  pillText.appendChild(aliasLink);
@@ -13248,7 +13442,7 @@ var DefaultFrontmatterWidget = class extends WidgetType {
13248
13442
  pillText.textContent = isAliasRow ? chip : match ? match.label : chip;
13249
13443
  }
13250
13444
  pill.appendChild(pillText);
13251
- if (match && referenceProvider && (!isAliasRow || idx === 0)) {
13445
+ if (match && referenceProvider && (!isAliasRow || idx === 0 && !isSelfAlias)) {
13252
13446
  const openLink = document.createElement("a");
13253
13447
  openLink.href = referenceProvider.openHref(valueKind, match.slug);
13254
13448
  openLink.title = `Open ${match.label} page`;
@@ -21898,5 +22092,5 @@ function editorPreset(optionsOrDialect = "markdown") {
21898
22092
  }
21899
22093
 
21900
22094
  export { AGG_OPTIONS, CANONICAL_BLOCK_TYPES, CLAUSE_META, ClauseIcon, ComposerRegistry, DEFAULT_DIAGNOSTICS_DEBOUNCE_MS, DEFAULT_OUTPUT_FILTERS, DEFAULT_PRIMARY_FILTER, DefaultFrontmatterWidget, EditorDialog, GROUPBY_OPTIONS, GoalRings, INTERNAL_FRONTMATTER_KEYS, KIND_OPTIONS, METRIC_OPTIONS, MULTI_VALUE_TYPES, MetricBadge, OUTPUT_TYPE_CLASS, OUTPUT_TYPE_DOT, OutputFilterPills, OutputStatementsTable, PLANE_OPTIONS, PRBadge, ProposedMetricBadge, QueryBlockView, QueryObjectBuilder, QueryValue, ROLLUP_OPTIONS, ResultsSpreadsheetGrid, RowsResultsChrome, RowsTable, RpePopoverControl, SERIES_COLORS, SOURCE_OPTIONS, SUGGESTION_BINDINGS, SessionSummaryCard, SingleLineYAxisTick, StackedBar, TARGET_OPTIONS, TIME_OPTIONS, TONE_CLASS, TokenSlotPill, TopList, UNIT_OPTIONS, WHERE_AGGREGATORS, WHERE_METRICS, WidgetChart, WidgetProblemBadge, WqlBars, WqlComposer, WqlDiagnosticsStrip, WqlEmptyState, WqlQueryInspectorModal, WqlScopeMap, WqlTable, WqlTimeseries, ZONE_META, ZONE_ORDER, ZoneDistribution, acceptCompletionOrFirst, activeCursorSection, addRuntimePanel, affiliateTagFacet, applyAmazonAffiliateTag, attachmentUrlFacet, autocompleteTooltipTheme, bindTokenParamIntoWql, bindTokenToQueryObject, blockTypesFromBlocks, buildAddableFilterGroups, buildScopeZones, buildSpreadsheetRows, canonicalSuggestionItems, compactNumber, composerRegistry, computeSessionPrHighlights, computeYAxisWidth, configureOverlayActions, createExecutorDocumentHost, cursorFocusExtension, customCompletionSources, cycleBaselineLayer, dateRangeSlot, dispatchAddRuntimePanel, dispatchExpandRuntimePanel, dispatchGutterHighlights, dispatchRemoveRuntimePanel, editQueryClause, editingQuerySectionsField, editingWidgetsField, editorFocusField, editorFocusTracker, editorPreset, editorTheme, embedPreviewDecorations, expandRuntimePanel, extractBlockQueries, extractMetricsByCategory, fenceCompletion, findQueryBlockSection, findWorkoutErrors, forceSectionParse, formatAnalyticsFloat, formatAxisTick, formatClockTime, formatCompactMetricValue, formatHumanQuerySummary, formatMMSS, formatMetricValue, formatSummaryDurationMMSS, formatTimeseriesTick, formatTimeseriesTooltipValue, formatTimestamp, frontmatterDebugMode, frontmatterDetailed, frontmatterKeymap, frontmatterPreview, frontmatterPreviewField, frontmatterReferenceIndex, frontmatterSource, frontmatterSuggestions, frontmatterVisibility, getClauseMeta, getClauseSupportError, getClauseZone, getCursorFocusState, getOverlayActions, getSuggestionBinding, gutterHighlightsField, gutterUnified, handleFenceAutoWrap, handleSmartUrlPaste, inlineButtonDecoration, insertMarkdownLinkCommand, insertWhiteboardNewline, invalidateSuggestions, isAmazonRetailHost, isEditorFocused, isInternalFrontmatterKey, isNavigableUrl, isWhiteboardScriptBody, lineIdsExtension, linkOpen, linkPreview, loadSuggestions, markdownSyntaxHiding, markdownTablePreview, matchFilterTypeahead, mergeSeries, mergeSuggestionItems, mergeTagSuggestions, mobileDockedCompletionFacet, navigationFacet, nestedCompletion, nestedCompletionOptions, normalizeOutputFilter, normalizeSimplePipelineToAggregate, notebookSlugsFromBlocks, outputToRunResult, outputsToRunResult, patchBlockQuery, presentBadges, previewDecorations, primaryQueryOf, promoteFindToChartObject, queryBlockPreview, readSessionRpe, referenceIndexReload, registeredSectionWidgets, removeRuntimePanel, removeSeriesLayer, resolveCodeLanguage, resolveQueryDraft, resolveWidgetDisplayUnit, runtimePanelField, saveBlockQuerySource, sectionAtPos, sectionField, sectionGeometry, sectionIdentity, sectionIdentityHistory, sectionMove, sectionRestore, sectionSaved, sessionQueryFence, sessionQueryInsert, sessionQueryWql, setEditorFocused, setFrontmatterDetailed, setFrontmatterSource, setGutterHighlights, setPrimaryQueryOnObject, setQuerySourceEditing, setSuggestionBinding, shouldTriggerBackspaceCompletion, slashBlockCompletion, smartIncrement, summarizeAggregate, summarizeFind, summarizePipeline, tagsFromStaticBlocks, toChartResult, toggleCompareLayer, toggleGoalLayer, toggleInlineMarkdown, toggleWidgetEdit, tooltipTimestamp, urlAtPos, useChartShape, useComposerSlots, useSessionPrHighlights, useSuggestions, useWqlStageCounts, widgetBlockPreview, wodAutoWrap, wodAutocompletion, wodBackspaceCompletion, wodCompletionIconOption, wodCompletionKeymap, wodCompletionSource, wodEditorKeymap, wodIndentKeymap, wodLinter, wodOverlayPanel, workoutLintSource, wqlToPills, wrapInTimeFence };
21901
- //# sourceMappingURL=chunk-C6BT5QVA.mjs.map
21902
- //# sourceMappingURL=chunk-C6BT5QVA.mjs.map
22095
+ //# sourceMappingURL=chunk-QGB3HYJU.mjs.map
22096
+ //# sourceMappingURL=chunk-QGB3HYJU.mjs.map