@thehammer/template-verification 0.2.10 → 0.2.12

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.
@@ -1,8 +1,8 @@
1
- import { ref as O, watch as ae, defineComponent as J, computed as g, openBlock as l, createElementBlock as c, normalizeClass as A, createElementVNode as i, toDisplayString as v, createCommentVNode as h, createBlock as V, unref as f, withCtx as S, createTextVNode as N, createVNode as I, Fragment as B, renderList as H, renderSlot as xe, onBeforeUnmount as Ge, withKeys as Qe, withModifiers as ye, withDirectives as We, isRef as Xe, vModelCheckbox as Ze } from "vue";
2
- import { DanxChip as M, CodeViewer as qe, DanxFile as et, DanxButton as re, DanxDialog as Oe, DanxFileViewer as tt, DanxAlert as ge, DanxTooltip as be, useToast as Le, DanxProgressBar as Ae, DanxTabs as at, DanxSkeleton as ve, DanxInput as lt, DanxIcon as nt, gearIcon as st, DanxBadge as it, DanxToastContainer as ot } from "@thehammer/danx-ui";
3
- const ee = "tv-chrome", ze = "template-verification:enabled";
4
- let fe = null;
5
- function rt(e) {
1
+ import { ref as P, watch as K, defineComponent as U, computed as l, openBlock as u, createElementBlock as g, normalizeClass as y, createElementVNode as p, toDisplayString as w, createCommentVNode as _, createBlock as j, unref as f, Fragment as M, renderSlot as ne, createTextVNode as re, withModifiers as G, createVNode as N, withDirectives as ae, isRef as le, vModelCheckbox as oe } from "vue";
2
+ import { DanxSkeleton as ie, useToast as se, DanxIcon as ue, gearIcon as ce, DanxBadge as de, DanxProgressBar as fe, DanxToastContainer as ve } from "@thehammer/danx-ui";
3
+ const $ = "tv-chrome", q = "template-verification:enabled";
4
+ let O = null;
5
+ function pe(e) {
6
6
  var t;
7
7
  try {
8
8
  return ((t = globalThis.localStorage) == null ? void 0 : t.getItem(e)) ?? null;
@@ -10,52 +10,48 @@ function rt(e) {
10
10
  return null;
11
11
  }
12
12
  }
13
- function ut(e, t) {
14
- var a;
13
+ function ge(e, t) {
14
+ var n;
15
15
  try {
16
- (a = globalThis.localStorage) == null || a.setItem(e, t);
16
+ (n = globalThis.localStorage) == null || n.setItem(e, t);
17
17
  } catch {
18
18
  }
19
19
  }
20
- function dt(e) {
21
- const t = rt(ze);
20
+ function be(e) {
21
+ const t = pe(q);
22
22
  return t === null ? e : t === "true";
23
23
  }
24
- function Pe(e) {
25
- const t = O(dt((e == null ? void 0 : e.defaultEnabled) ?? !1));
26
- return ae(
24
+ function J(e) {
25
+ const t = P(be((e == null ? void 0 : e.defaultEnabled) ?? !1));
26
+ return K(
27
27
  t,
28
- (a) => ut(ze, a ? "true" : "false")
28
+ (n) => ge(q, n ? "true" : "false")
29
29
  ), {
30
30
  enabled: t,
31
31
  data: (e == null ? void 0 : e.data) ?? {},
32
- saveOverride: e == null ? void 0 : e.saveOverride,
33
32
  workflowInputId: e == null ? void 0 : e.workflowInputId,
34
- detailUrl: e == null ? void 0 : e.detailUrl,
35
33
  loading: (e == null ? void 0 : e.loading) ?? !1
36
34
  };
37
35
  }
38
- function ct() {
39
- return fe || (fe = Pe()), fe;
36
+ function he() {
37
+ return O || (O = J()), O;
40
38
  }
41
- function pl(e) {
42
- fe = Pe(e);
39
+ function qe(e) {
40
+ O = J(e);
43
41
  }
44
- function we() {
45
- const e = ct();
42
+ function Q() {
43
+ const e = he();
46
44
  return {
47
45
  enabled: e.enabled,
48
46
  data: e.data,
49
- saveOverride: e.saveOverride,
50
47
  workflowInputId: e.workflowInputId,
51
- detailUrl: e.detailUrl,
52
48
  loading: e.loading
53
49
  };
54
50
  }
55
- function _e(e) {
51
+ function W(e) {
56
52
  return typeof e != "number" || Number.isNaN(e) ? "unverifiable" : e <= 2 ? "low" : e === 3 ? "medium" : "high";
57
53
  }
58
- const vt = {
54
+ const me = {
59
55
  high: "bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20",
60
56
  medium: "bg-yellow-50 text-yellow-700 ring-1 ring-inset ring-yellow-600/20",
61
57
  low: "bg-red-50 text-red-700 ring-1 ring-inset ring-red-600/20",
@@ -63,124 +59,141 @@ const vt = {
63
59
  // Same red family as 'low' (color-family-per-status is load-bearing, see docblock
64
60
  // above) but a visibly darker/more saturated shade so the two stay distinguishable.
65
61
  failed: "bg-red-100 text-red-800 ring-1 ring-inset ring-red-700/30"
66
- }, K = {
62
+ }, V = {
67
63
  high: "High",
68
64
  medium: "Medium",
69
65
  low: "Low",
70
66
  unverifiable: "Unverifiable",
71
67
  failed: "Failed"
72
- }, je = ["override", "extracted", "claim"];
73
- function Re(e) {
74
- return e ? e.resolved && e.resolved.source && e.resolved.source !== "none" ? e.resolved : ft(e.candidates) : { value: null, source: "none" };
68
+ }, X = ["override", "extracted", "claim"];
69
+ function we(e) {
70
+ return e ? e.resolved && e.resolved.source && e.resolved.source !== "none" ? e.resolved : ye(e.candidates) : { value: null, source: "none" };
75
71
  }
76
- function ft(e) {
72
+ function ye(e) {
77
73
  if (e)
78
- for (const t of je) {
79
- const a = e[t];
80
- if (a != null)
81
- return { value: a.value, source: t };
74
+ for (const t of X) {
75
+ const n = e[t];
76
+ if (n != null)
77
+ return { value: n.value, source: t };
82
78
  }
83
79
  return { value: null, source: "none" };
84
80
  }
85
- function ml(e) {
86
- var b, y;
87
- const t = (y = (b = e == null ? void 0 : e.candidates) == null ? void 0 : b.extracted) == null ? void 0 : y.reasoning;
88
- if (t == null) return null;
89
- const a = String(t).trim();
90
- return a === "" ? null : a;
91
- }
92
- function gt(e) {
93
- return e ? typeof e.discrepancy == "boolean" ? e.discrepancy : pt(e.candidates) : !1;
81
+ function xe(e) {
82
+ return e ? typeof e.discrepancy == "boolean" ? e.discrepancy : _e(e.candidates) : !1;
94
83
  }
95
- function pt(e) {
84
+ function _e(e) {
96
85
  if (!e) return !1;
97
- const t = je.map((a) => e[a]).filter((a) => a != null).map((a) => mt(a.value));
86
+ const t = X.map((n) => e[n]).filter((n) => n != null).map((n) => ke(n.value));
98
87
  return t.length < 2 ? !1 : new Set(t).size > 1;
99
88
  }
100
- function mt(e) {
89
+ function ke(e) {
101
90
  return JSON.stringify(e ?? null);
102
91
  }
103
- const xt = /* @__PURE__ */ new Set(["name", "type"]);
104
- function Ue(e, t = "") {
105
- const a = [];
106
- return he(e, t, a), a;
92
+ function Se(e) {
93
+ return !!(e != null && e.source_discrepancy);
94
+ }
95
+ function Ie(e) {
96
+ return !!(e != null && e.correction);
97
+ }
98
+ const Ce = "danxbot-template", Te = 1, $e = "data-point-activated";
99
+ function Ae() {
100
+ if (typeof window > "u") return null;
101
+ const e = window.location.ancestorOrigins, t = e && e.length > 0 ? e[0] : null;
102
+ if (t && t !== "null") return t;
103
+ const n = typeof document > "u" ? "" : document.referrer;
104
+ if (!n) return null;
105
+ try {
106
+ const c = new URL(n).origin;
107
+ return c === "null" ? null : c;
108
+ } catch {
109
+ return null;
110
+ }
111
+ }
112
+ function Ee(e) {
113
+ if (typeof window > "u") return !1;
114
+ const t = window.parent;
115
+ if (!t || t === window) return !1;
116
+ const n = Ae();
117
+ if (!n) return !1;
118
+ const c = {
119
+ source: Ce,
120
+ version: Te,
121
+ type: $e,
122
+ anchor: {
123
+ object_ids: [...e.anchor.object_ids],
124
+ field: e.anchor.field,
125
+ field_path: e.anchor.field_path
126
+ },
127
+ workflowInputId: e.workflowInputId ?? null,
128
+ label: e.label ?? null,
129
+ value: e.value ?? null
130
+ };
131
+ return t.postMessage(c, n), !0;
132
+ }
133
+ const Re = /* @__PURE__ */ new Set(["name", "type"]);
134
+ function Z(e, t = "") {
135
+ const n = [];
136
+ return B(e, t, n), n;
107
137
  }
108
- function he(e, t, a) {
138
+ function B(e, t, n) {
109
139
  if (Array.isArray(e)) {
110
- e.forEach((s, r) => he(s, `${t}[${r}]`, a));
140
+ e.forEach((r, i) => B(r, `${t}[${i}]`, n));
111
141
  return;
112
142
  }
113
- if (!Ie(e)) return;
114
- const y = e.__meta ?? {};
115
- for (const [s, r] of Object.entries(e)) {
116
- if (s === "__meta") continue;
117
- const n = t ? `${t}.${s}` : s;
118
- if (Array.isArray(r) || Ie(r)) {
119
- he(r, n, a);
143
+ if (!H(e)) return;
144
+ const b = e.__meta ?? {};
145
+ for (const [r, i] of Object.entries(e)) {
146
+ if (r === "__meta") continue;
147
+ const m = t ? `${t}.${r}` : r;
148
+ if (Array.isArray(i) || H(i)) {
149
+ B(i, m, n);
120
150
  continue;
121
151
  }
122
- const C = y[s];
123
- !C && xt.has(s) || a.push({
124
- path: n,
125
- label: s,
126
- meta: C ?? null,
127
- value: r,
128
- unanchored: !C
152
+ const v = b[r];
153
+ !v && Re.has(r) || n.push({
154
+ path: m,
155
+ label: r,
156
+ meta: v ?? null,
157
+ value: i,
158
+ unanchored: !v
129
159
  });
130
160
  }
131
161
  }
132
- function Ie(e) {
162
+ function H(e) {
133
163
  return typeof e == "object" && e !== null && !Array.isArray(e);
134
164
  }
135
- function Be(e) {
136
- var a;
165
+ function ee(e) {
166
+ var n;
137
167
  if (e.candidates.override) return !1;
138
- const t = (a = e.candidates.extracted) == null ? void 0 : a.confidence;
168
+ const t = (n = e.candidates.extracted) == null ? void 0 : n.confidence;
139
169
  return e.discrepancy || t == null || t <= 2;
140
170
  }
141
- function yt(e) {
142
- const t = Ue(e).filter(
143
- (s) => s.meta !== null
144
- ), a = t.length;
145
- let b = 0, y = 0;
146
- for (const s of t) {
147
- if (s.meta.candidates.override) {
148
- b++;
171
+ function Oe(e) {
172
+ const t = Z(e).filter(
173
+ (r) => r.meta !== null
174
+ ), n = t.length;
175
+ let c = 0, b = 0;
176
+ for (const r of t) {
177
+ if (r.meta.candidates.override) {
178
+ c++;
149
179
  continue;
150
180
  }
151
- Be(s.meta) && y++;
181
+ ee(r.meta) && b++;
152
182
  }
153
183
  return {
154
- total: a,
155
- verified: b,
156
- needsReview: y,
157
- percent: a === 0 ? 100 : Math.round(b / a * 100)
158
- };
159
- }
160
- function ht(e, t, a) {
161
- var s;
162
- const b = (s = t.value) == null ? void 0 : s.anchor;
163
- if (!e.saveOverride || !b) return null;
164
- const y = e.saveOverride;
165
- return async (r, n) => {
166
- const C = await y({
167
- workflow_input_id: e.workflowInputId,
168
- object_ids: b.object_ids,
169
- field: b.field,
170
- field_path: b.field_path,
171
- value: r,
172
- source_choice: n
173
- });
174
- return a(C), C;
184
+ total: n,
185
+ verified: c,
186
+ needsReview: b,
187
+ percent: n === 0 ? 100 : Math.round(c / n * 100)
175
188
  };
176
189
  }
177
- const bt = ["data-status", "title"], wt = {
190
+ const Ve = ["data-status", "title"], De = {
178
191
  class: "tv-confidence-glyph",
179
192
  "aria-hidden": "true"
180
- }, _t = {
193
+ }, Le = {
181
194
  key: 0,
182
195
  class: "tv-confidence-label"
183
- }, kt = /* @__PURE__ */ J({
196
+ }, Ne = /* @__PURE__ */ U({
184
197
  __name: "ConfidenceIcon",
185
198
  props: {
186
199
  confidence: {},
@@ -188,9 +201,9 @@ const bt = ["data-status", "title"], wt = {
188
201
  showLabel: { type: Boolean }
189
202
  },
190
203
  setup(e) {
191
- const t = e, a = g(
192
- () => t.status ?? _e(t.confidence)
193
- ), b = {
204
+ const t = e, n = l(
205
+ () => t.status ?? W(t.confidence)
206
+ ), c = {
194
207
  high: "✔",
195
208
  // check
196
209
  medium: "⚠",
@@ -200,1177 +213,25 @@ const bt = ["data-status", "title"], wt = {
200
213
  unverifiable: "?",
201
214
  failed: "⊗"
202
215
  // circled x — distinct from low's plain x
203
- }, y = g(() => b[a.value]), s = g(() => vt[a.value]), r = g(() => K[a.value]);
204
- return (n, C) => (l(), c("span", {
205
- class: A(["tv-confidence-icon inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-semibold leading-none", s.value]),
206
- "data-status": a.value,
207
- title: r.value
208
- }, [
209
- i("span", wt, v(y.value), 1),
210
- e.showLabel ? (l(), c("span", _t, v(r.value), 1)) : h("", !0)
211
- ], 10, bt));
212
- }
213
- });
214
- async function $t(e, t) {
215
- var n;
216
- const a = t.object_ids.at(-1), b = new URLSearchParams({
217
- object_id: String(a),
218
- field: t.field
219
- }), y = e.includes("?") ? "&" : "?", s = await fetch(`${e}${y}${b}`);
220
- if (!s.ok)
221
- throw new Error(
222
- `data-point-detail ${s.status}: ${await s.text()}`
223
- );
224
- const r = await s.json();
225
- return {
226
- extracted: r.extracted ?? null,
227
- audit: ((n = r.audit) == null ? void 0 : n.data) ?? []
228
- };
229
- }
230
- const Ct = "api_log", St = "user", Vt = "failed_file", Nt = {
231
- pages: [],
232
- documents: [],
233
- apiLogIds: [],
234
- unresolved: [],
235
- pageCount: 0,
236
- quoteCount: 0,
237
- isEmpty: !0
238
- };
239
- function me(e) {
240
- var r;
241
- if (!e || e.length === 0) return { ...Nt };
242
- const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), b = [], y = [];
243
- for (const n of e) {
244
- if (n.source_type === Vt) {
245
- y.push(n);
246
- continue;
247
- }
248
- if (n.api_log_id !== void 0 && n.api_log_id !== null && (b.includes(n.api_log_id) || b.push(n.api_log_id)), n.source_type === Ct || n.source_type === St || !qt(n)) continue;
249
- const C = It(n);
250
- let u = t.get(C);
251
- u || (u = {
252
- key: C,
253
- pageNumber: ue(n),
254
- label: "",
255
- documentName: null,
256
- file: null,
257
- url: null,
258
- document: null,
259
- quotes: [],
260
- explanations: [],
261
- sourceIds: []
262
- }, t.set(C, u)), !u.file && n.file && (u.file = Dt(n)), u.url || (u.url = ((r = n.file) == null ? void 0 : r.url) ?? n.file_url ?? null), !u.document && n.original_file && (u.document = n.original_file), u.pageNumber === null && (u.pageNumber = ue(n)), n.id !== void 0 && n.id !== null && u.sourceIds.push(n.id);
263
- for (const _ of n.texts ?? []) {
264
- const m = String(_).trim();
265
- m && !u.quotes.includes(m) && u.quotes.push(m);
266
- }
267
- if (n.explanation) {
268
- const _ = String(n.explanation).trim();
269
- _ && !u.explanations.includes(_) && u.explanations.push(_);
270
- }
271
- u.documentName || (u.documentName = Et(n)), n.original_file && a.set(String(n.original_file.id), n.original_file);
272
- }
273
- const s = [...t.values()];
274
- for (const n of s) n.label = Tt(n);
275
- return s.sort(Ot), {
276
- pages: s,
277
- documents: [...a.values()],
278
- apiLogIds: b,
279
- unresolved: y,
280
- pageCount: s.length,
281
- quoteCount: s.reduce((n, C) => n + C.quotes.length, 0),
282
- isEmpty: s.length === 0 && y.length === 0
283
- };
284
- }
285
- function qt(e) {
286
- var t;
287
- return !!(e.file || e.file_url || e.file_name || e.file_id !== void 0 || e.stored_file_id !== void 0 || ue(e) !== null || (((t = e.texts) == null ? void 0 : t.length) ?? 0) > 0);
288
- }
289
- function It(e) {
290
- var b;
291
- const t = ((b = e.file) == null ? void 0 : b.id) ?? e.stored_file_id ?? e.file_id ?? e.file_name, a = ue(e);
292
- return t != null ? a === null ? String(t) : `${t}#${a}` : a !== null ? `page-${a}` : `source-${e.id ?? "unknown"}`;
293
- }
294
- function ue(e) {
295
- const t = e.page ?? e.page_number;
296
- return t == null ? null : Number(t);
297
- }
298
- function Et(e) {
299
- var t;
300
- return ((t = e.original_file) == null ? void 0 : t.name) ?? e.file_name ?? null;
301
- }
302
- function Dt(e) {
303
- const t = e.file, a = ue(e);
304
- return a === null || t.page_number != null ? t : { ...t, page_number: a };
305
- }
306
- function Tt(e) {
307
- var t;
308
- return e.pageNumber !== null ? `Page ${e.pageNumber}` : (t = e.file) != null && t.name ? e.file.name : e.documentName ? e.documentName : "Cited source";
309
- }
310
- function Ot(e, t) {
311
- return e.pageNumber === null && t.pageNumber === null ? 0 : e.pageNumber === null ? 1 : t.pageNumber === null ? -1 : e.pageNumber - t.pageNumber;
312
- }
313
- function Me(e) {
314
- if (e.isEmpty) return "No citations recorded";
315
- const t = [
316
- `${e.pageCount} ${e.pageCount === 1 ? "page" : "pages"}`
317
- ];
318
- return e.quoteCount > 0 && t.push(
319
- `${e.quoteCount} ${e.quoteCount === 1 ? "quote" : "quotes"}`
320
- ), e.unresolved.length > 0 && t.push(`${e.unresolved.length} unresolved`), t.join(" · ");
321
- }
322
- function Ee(e) {
323
- typeof window > "u" || !window.top || window.top === window || window.top.postMessage(
324
- { source: "danxbot-template", type: "nested-viewer-active", active: e },
325
- "*"
326
- );
327
- }
328
- const Lt = { class: "tv-audit-call rounded-lg border border-gray-200 shadow-sm" }, At = { class: "tv-audit-call-header flex flex-wrap items-center gap-2 border-b border-gray-100 bg-gray-50 px-3 py-2" }, zt = {
329
- key: 3,
330
- class: "font-mono text-[11px] text-gray-400"
331
- }, Pt = {
332
- key: 4,
333
- class: "text-[11px] font-medium text-gray-500"
334
- }, jt = {
335
- key: 5,
336
- class: "text-[11px] text-gray-400"
337
- }, Rt = { class: "tv-audit-call-body flex flex-col gap-2 p-3" }, Ut = /* @__PURE__ */ J({
338
- __name: "AuditCallCard",
339
- props: {
340
- call: {}
341
- },
342
- setup(e) {
343
- const t = e, a = g(() => {
344
- const n = t.call.status_code;
345
- return n == null ? "muted" : n >= 200 && n < 300 ? "success" : n >= 400 ? "danger" : "warning";
346
- }), b = g(() => {
347
- const n = t.call.run_time_ms;
348
- return n == null ? null : n >= 1e3 ? `${(n / 1e3).toFixed(1)}s` : `${n}ms`;
349
- }), y = g(() => {
350
- if (!t.call.started_at) return null;
351
- const n = new Date(t.call.started_at);
352
- return Number.isNaN(n.getTime()) ? t.call.started_at : n.toLocaleString();
353
- }), s = g(
354
- () => JSON.stringify(t.call.request ?? null, null, 2)
355
- ), r = g(
356
- () => JSON.stringify(t.call.response ?? null, null, 2)
357
- );
358
- return (n, C) => (l(), c("div", Lt, [
359
- i("div", At, [
360
- e.call.stage ? (l(), V(f(M), {
361
- key: 0,
362
- variant: "muted",
363
- size: "xxs",
364
- class: "tv-audit-stage"
365
- }, {
366
- default: S(() => [
367
- N(v(e.call.stage), 1)
368
- ]),
369
- _: 1
370
- })) : h("", !0),
371
- e.call.model ? (l(), V(f(M), {
372
- key: 1,
373
- variant: "info",
374
- size: "xs",
375
- class: "tv-audit-model"
376
- }, {
377
- default: S(() => [
378
- N(v(e.call.model), 1)
379
- ]),
380
- _: 1
381
- })) : h("", !0),
382
- e.call.service ? (l(), V(f(M), {
383
- key: 2,
384
- variant: "muted",
385
- size: "xxs"
386
- }, {
387
- default: S(() => [
388
- N(v(e.call.service), 1)
389
- ]),
390
- _: 1
391
- })) : h("", !0),
392
- e.call.endpoint ? (l(), c("span", zt, v(e.call.endpoint), 1)) : h("", !0),
393
- C[0] || (C[0] = i("span", { class: "flex-1" }, null, -1)),
394
- I(f(M), {
395
- variant: a.value,
396
- size: "xxs",
397
- class: "tv-audit-status"
398
- }, {
399
- default: S(() => [
400
- N(v(e.call.status_code ?? "…"), 1)
401
- ]),
402
- _: 1
403
- }, 8, ["variant"]),
404
- b.value ? (l(), c("span", Pt, v(b.value), 1)) : h("", !0),
405
- y.value ? (l(), c("span", jt, v(y.value), 1)) : h("", !0)
406
- ]),
407
- i("div", Rt, [
408
- i("div", null, [
409
- C[1] || (C[1] = i("div", { class: "mb-1 text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Request ", -1)),
410
- I(f(qe), {
411
- "model-value": s.value,
412
- format: "json",
413
- collapsible: "",
414
- "default-collapsed": "",
415
- class: "tv-audit-request"
416
- }, null, 8, ["model-value"])
417
- ]),
418
- i("div", null, [
419
- C[2] || (C[2] = i("div", { class: "mb-1 text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Response ", -1)),
420
- I(f(qe), {
421
- "model-value": r.value,
422
- format: "json",
423
- collapsible: "",
424
- "default-collapsed": "",
425
- class: "tv-audit-response"
426
- }, null, 8, ["model-value"])
427
- ])
428
- ])
429
- ]));
430
- }
431
- }), Bt = {
432
- key: 0,
433
- class: "tv-citation-thumb shrink-0"
434
- }, Mt = { class: "tv-citation-quotes flex min-w-0 flex-1 flex-col gap-2" }, Ft = {
435
- key: 0,
436
- class: "tv-quote-list flex flex-col gap-2"
437
- }, Yt = { class: "tv-quote-index mr-1 not-italic text-[10px] font-semibold text-amber-600" }, Kt = {
438
- key: 1,
439
- class: "tv-quote-empty rounded-md border border-dashed border-gray-200 px-3 py-2 text-xs text-gray-400"
440
- }, Ht = { class: "tv-citation-actions mt-1 flex flex-wrap items-center gap-2" }, De = /* @__PURE__ */ J({
441
- __name: "CitationPage",
442
- props: {
443
- page: {},
444
- dense: { type: Boolean }
445
- },
446
- emits: ["view", "document"],
447
- setup(e, { emit: t }) {
448
- const a = t;
449
- return (b, y) => (l(), c("div", {
450
- class: A(["tv-citation-page flex gap-4", e.dense ? "tv-citation-page-dense" : ""])
216
+ }, b = l(() => c[n.value]), r = l(() => me[n.value]), i = l(() => V[n.value]);
217
+ return (m, v) => (u(), g("span", {
218
+ class: y(["tv-confidence-icon inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-semibold leading-none", r.value]),
219
+ "data-status": n.value,
220
+ title: i.value
451
221
  }, [
452
- e.page.file ? (l(), c("div", Bt, [
453
- I(f(et), {
454
- file: e.page.file,
455
- size: e.dense ? "md" : "lg",
456
- fit: "cover",
457
- downloadable: "",
458
- class: "cursor-zoom-in",
459
- onClick: y[0] || (y[0] = (s) => a("view"))
460
- }, null, 8, ["file", "size"])
461
- ])) : h("", !0),
462
- i("div", Mt, [
463
- e.page.quotes.length ? (l(), c("ol", Ft, [
464
- (l(!0), c(B, null, H(e.page.quotes, (s, r) => (l(), c("li", {
465
- key: r,
466
- class: "tv-quote rounded-r-md border-l-[3px] border-amber-300 bg-amber-50/60 py-1.5 pl-3 pr-3 text-sm italic leading-relaxed text-gray-700"
467
- }, [
468
- i("span", Yt, v(r + 1), 1),
469
- N("“" + v(s) + "” ", 1)
470
- ]))), 128))
471
- ])) : (l(), c("p", Kt, " This page was cited without a verbatim quote — the value was read from the page as a whole. ")),
472
- (l(!0), c(B, null, H(e.page.explanations, (s, r) => (l(), c("p", {
473
- key: `x${r}`,
474
- class: "tv-citation-explanation text-xs text-gray-500"
475
- }, v(s), 1))), 128)),
476
- i("div", Ht, [
477
- e.page.file ? (l(), V(f(re), {
478
- key: 0,
479
- size: "xs",
480
- variant: "info",
481
- class: "tv-view-page",
482
- onClick: y[1] || (y[1] = (s) => a("view"))
483
- }, {
484
- default: S(() => [...y[3] || (y[3] = [
485
- N("View page full screen", -1)
486
- ])]),
487
- _: 1
488
- })) : h("", !0),
489
- e.page.document ? (l(), V(f(re), {
490
- key: 1,
491
- size: "xs",
492
- variant: "muted",
493
- class: "tv-open-document",
494
- onClick: y[2] || (y[2] = (s) => a("document"))
495
- }, {
496
- default: S(() => [
497
- N("Open " + v(e.page.document.name), 1)
498
- ]),
499
- _: 1
500
- })) : h("", !0)
501
- ])
502
- ])
503
- ], 2));
504
- }
505
- }), Jt = { class: "tv-disclosure divide-y divide-gray-200" }, Gt = ["id", "aria-expanded", "aria-controls", "onClick"], Qt = { class: "min-w-0 flex-1" }, Wt = ["id", "aria-labelledby"], Fe = /* @__PURE__ */ J({
506
- __name: "TvDisclosure",
507
- props: {
508
- items: {},
509
- modelValue: {},
510
- idPrefix: { default: "tv-disclosure" }
511
- },
512
- emits: ["update:modelValue"],
513
- setup(e, { emit: t }) {
514
- const a = e, b = t, y = g(() => new Set(a.modelValue)), s = (u) => y.value.has(u);
515
- function r(u) {
516
- const _ = new Set(y.value);
517
- _.has(u) ? _.delete(u) : _.add(u), b("update:modelValue", [..._]);
518
- }
519
- const n = (u) => `${a.idPrefix}-h-${u}`, C = (u) => `${a.idPrefix}-p-${u}`;
520
- return (u, _) => (l(), c("div", Jt, [
521
- (l(!0), c(B, null, H(e.items, (m) => (l(), c("div", {
522
- key: m.value,
523
- class: A(["tv-disclosure__item", s(m.value) ? "is-open" : ""])
524
- }, [
525
- i("button", {
526
- id: n(m.value),
527
- type: "button",
528
- class: "tv-disclosure__header flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors hover:bg-gray-50",
529
- "aria-expanded": s(m.value),
530
- "aria-controls": C(m.value),
531
- onClick: (T) => r(m.value)
532
- }, [
533
- i("span", Qt, [
534
- xe(u.$slots, "header", {
535
- item: m,
536
- isOpen: s(m.value)
537
- }, () => [
538
- N(v(m.label), 1)
539
- ])
540
- ]),
541
- (l(), c("svg", {
542
- class: A(["tv-disclosure__chevron h-4 w-4 shrink-0 text-gray-400 transition-transform duration-200", s(m.value) ? "rotate-180" : ""]),
543
- viewBox: "0 0 20 20",
544
- fill: "none",
545
- "aria-hidden": "true"
546
- }, [..._[0] || (_[0] = [
547
- i("path", {
548
- d: "M5 7.5 10 12.5 15 7.5",
549
- stroke: "currentColor",
550
- "stroke-width": "1.75",
551
- "stroke-linecap": "round",
552
- "stroke-linejoin": "round"
553
- }, null, -1)
554
- ])], 2))
555
- ], 8, Gt),
556
- s(m.value) ? (l(), c("div", {
557
- key: 0,
558
- id: C(m.value),
559
- role: "region",
560
- "aria-labelledby": n(m.value),
561
- class: "tv-disclosure__panel border-t border-gray-100 bg-gray-50/40 px-3 py-3"
562
- }, [
563
- xe(u.$slots, "panel", {
564
- item: m,
565
- isOpen: !0
566
- })
567
- ], 8, Wt)) : h("", !0)
568
- ], 2))), 128))
569
- ]));
570
- }
571
- }), Xt = { class: "tv-citation-list flex flex-col gap-2" }, Zt = {
572
- key: 0,
573
- class: "tv-citation-list-controls flex justify-end"
574
- }, ea = { class: "tv-citation-header flex min-w-0 flex-1 items-center gap-3 text-left" }, ta = ["src", "alt"], aa = { class: "flex min-w-0 flex-1 flex-col" }, la = { class: "flex flex-wrap items-center gap-2" }, na = { class: "tv-citation-page-label text-sm font-semibold text-gray-900" }, sa = {
575
- key: 0,
576
- class: "tv-citation-document-name truncate text-xs text-gray-400"
577
- }, ia = {
578
- key: 0,
579
- class: "tv-citation-preview truncate text-xs italic text-gray-500"
580
- }, oa = { class: "tv-citation-header mb-2 flex flex-wrap items-center gap-2" }, ra = { class: "tv-citation-page-label text-sm font-semibold text-gray-900" }, ua = {
581
- key: 0,
582
- class: "tv-citation-document-name text-xs text-gray-400"
583
- }, da = { class: "tv-page-dialog flex h-full min-h-0 flex-col gap-3 lg:flex-row" }, ca = {
584
- key: 0,
585
- class: "tv-page-dialog-quotes max-h-40 shrink-0 overflow-y-auto rounded-lg border border-gray-200 bg-gray-50 p-3 lg:max-h-none lg:w-80"
586
- }, va = { class: "mb-2 text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, fa = { class: "flex flex-col gap-1.5" }, ga = /* @__PURE__ */ J({
587
- __name: "CitationPageList",
588
- props: {
589
- pages: {},
590
- collapsible: { type: Boolean, default: !0 },
591
- dense: { type: Boolean, default: !1 }
592
- },
593
- setup(e) {
594
- const t = e, a = g(
595
- () => t.pages.map((w) => ({ value: w.key, label: w.label }))
596
- ), b = O([]);
597
- ae(
598
- () => t.pages,
599
- (w) => {
600
- b.value = w.length ? [w[0].key] : [];
601
- },
602
- { immediate: !0 }
603
- );
604
- const y = g(
605
- () => t.pages.length > 0 && b.value.length === t.pages.length
606
- );
607
- function s() {
608
- b.value = y.value ? [] : t.pages.map((w) => w.key);
609
- }
610
- const r = g(
611
- () => new Map(t.pages.map((w) => [w.key, w]))
612
- );
613
- function n(w) {
614
- const D = w.quotes[0];
615
- return D ? D.length > 96 ? `${D.slice(0, 96)}…` : D : "";
616
- }
617
- const C = g(
618
- () => t.pages.map((w) => w.file).filter((w) => !!w)
619
- ), u = O(null), _ = O(!1), m = O(null), T = g({
620
- get: () => u.value !== null,
621
- set: (w) => {
622
- w || (u.value = null, m.value = null, _.value = !1);
623
- }
624
- }), z = g(
625
- () => _.value ? [] : C.value
626
- ), q = g(() => {
627
- if (_.value) return null;
628
- const w = m.value ?? u.value;
629
- return w ? t.pages.find(
630
- (D) => D.file && String(D.file.id) === String(w.id)
631
- ) ?? null : null;
632
- }), F = g(() => {
633
- if (!u.value) return "";
634
- if (_.value) return u.value.name;
635
- const w = q.value;
636
- return w ? w.documentName ? `${w.label} · ${w.documentName}` : w.label : u.value.name;
637
- });
638
- function Y(w) {
639
- w.file && (_.value = !1, m.value = w.file, u.value = w.file);
640
- }
641
- function U(w) {
642
- w.document && (_.value = !0, m.value = null, u.value = w.document);
643
- }
644
- return (w, D) => (l(), c("div", Xt, [
645
- e.collapsible && e.pages.length > 1 ? (l(), c("div", Zt, [
646
- I(f(re), {
647
- size: "xxs",
648
- variant: "muted",
649
- class: "tv-toggle-all-pages",
650
- onClick: s
651
- }, {
652
- default: S(() => [
653
- N(v(y.value ? "Collapse all" : "Expand all"), 1)
654
- ]),
655
- _: 1
656
- })
657
- ])) : h("", !0),
658
- e.collapsible ? (l(), V(Fe, {
659
- key: 1,
660
- modelValue: b.value,
661
- "onUpdate:modelValue": D[0] || (D[0] = (k) => b.value = k),
662
- items: a.value,
663
- "id-prefix": "tv-citation",
664
- class: "tv-citation-accordion overflow-hidden rounded-lg border border-gray-200"
665
- }, {
666
- header: S(({ item: k, isOpen: P }) => {
667
- var j, Q, W, X, p;
668
- return [
669
- i("span", ea, [
670
- (Q = (j = r.value.get(k.value)) == null ? void 0 : j.file) != null && Q.url ? (l(), c("img", {
671
- key: 0,
672
- src: r.value.get(k.value).file.url,
673
- alt: r.value.get(k.value).label,
674
- class: "tv-citation-header-thumb h-10 w-8 shrink-0 rounded border border-gray-200 object-cover",
675
- loading: "lazy"
676
- }, null, 8, ta)) : h("", !0),
677
- i("span", aa, [
678
- i("span", la, [
679
- i("span", na, v((W = r.value.get(k.value)) == null ? void 0 : W.label), 1),
680
- (X = r.value.get(k.value)) != null && X.documentName ? (l(), c("span", sa, v((p = r.value.get(k.value)) == null ? void 0 : p.documentName), 1)) : h("", !0),
681
- I(f(M), {
682
- variant: "warning",
683
- size: "xxs",
684
- class: "tv-citation-quote-count"
685
- }, {
686
- default: S(() => {
687
- var $, E;
688
- return [
689
- N(v(($ = r.value.get(k.value)) == null ? void 0 : $.quotes.length) + " " + v(((E = r.value.get(k.value)) == null ? void 0 : E.quotes.length) === 1 ? "quote" : "quotes"), 1)
690
- ];
691
- }),
692
- _: 2
693
- }, 1024)
694
- ]),
695
- !P && n(r.value.get(k.value)) ? (l(), c("span", ia, "“" + v(n(r.value.get(k.value))) + "”", 1)) : h("", !0)
696
- ])
697
- ])
698
- ];
699
- }),
700
- panel: S(({ item: k }) => [
701
- I(De, {
702
- page: r.value.get(k.value),
703
- dense: e.dense,
704
- onView: (P) => Y(r.value.get(k.value)),
705
- onDocument: (P) => U(r.value.get(k.value))
706
- }, null, 8, ["page", "dense", "onView", "onDocument"])
707
- ]),
708
- _: 1
709
- }, 8, ["modelValue", "items"])) : (l(!0), c(B, { key: 2 }, H(e.pages, (k) => (l(), c("div", {
710
- key: k.key,
711
- class: "tv-citation-flat rounded-lg border border-gray-200 p-3"
712
- }, [
713
- i("div", oa, [
714
- i("span", ra, v(k.label), 1),
715
- k.documentName ? (l(), c("span", ua, v(k.documentName), 1)) : h("", !0),
716
- I(f(M), {
717
- variant: "warning",
718
- size: "xxs",
719
- class: "tv-citation-quote-count"
720
- }, {
721
- default: S(() => [
722
- N(v(k.quotes.length) + " " + v(k.quotes.length === 1 ? "quote" : "quotes"), 1)
723
- ]),
724
- _: 2
725
- }, 1024)
726
- ]),
727
- I(De, {
728
- page: k,
729
- dense: e.dense,
730
- onView: (P) => Y(k),
731
- onDocument: (P) => U(k)
732
- }, null, 8, ["page", "dense", "onView", "onDocument"])
733
- ]))), 128)),
734
- u.value ? (l(), V(f(Oe), {
735
- key: 3,
736
- modelValue: T.value,
737
- "onUpdate:modelValue": D[2] || (D[2] = (k) => T.value = k),
738
- title: F.value,
739
- width: 95,
740
- height: 95,
741
- "close-x": "",
742
- class: A(f(ee))
743
- }, {
744
- default: S(() => {
745
- var k;
746
- return [
747
- i("div", da, [
748
- I(f(tt), {
749
- file: u.value,
750
- "file-in-preview": m.value,
751
- "onUpdate:fileInPreview": D[1] || (D[1] = (P) => m.value = P),
752
- "related-files": z.value,
753
- "layout-toggles": ["sidebar", "continuous"],
754
- downloadable: "",
755
- zoomable: "",
756
- "zoom-controls": "",
757
- "storage-key": "tv-page-viewer",
758
- class: "tv-page-viewer min-h-[22rem] min-w-0 flex-1"
759
- }, null, 8, ["file", "file-in-preview", "related-files"]),
760
- (k = q.value) != null && k.quotes.length ? (l(), c("aside", ca, [
761
- i("div", va, " Quoted from " + v(q.value.label), 1),
762
- i("ol", fa, [
763
- (l(!0), c(B, null, H(q.value.quotes, (P, j) => (l(), c("li", {
764
- key: j,
765
- class: "tv-quote rounded-r-md border-l-[3px] border-amber-300 bg-amber-50/70 py-1.5 pl-3 pr-2 text-sm italic leading-relaxed text-gray-700"
766
- }, " “" + v(P) + "” ", 1))), 128))
767
- ])
768
- ])) : h("", !0)
769
- ])
770
- ];
771
- }),
772
- _: 1
773
- }, 8, ["modelValue", "title", "class"])) : h("", !0)
774
- ]));
775
- }
776
- }), pa = { class: "tv-evidence flex flex-col gap-4" }, ma = {
777
- key: 1,
778
- class: "tv-reasoning-card rounded-lg border border-gray-200 bg-white p-3"
779
- }, xa = { class: "mb-1 flex flex-wrap items-center justify-between gap-2" }, ya = { class: "tv-reasoning text-sm leading-relaxed text-gray-700" }, ha = { class: "tv-cited-sources flex min-w-0 flex-col gap-2" }, ba = { class: "flex flex-wrap items-baseline justify-between gap-2" }, wa = { class: "tv-citation-summary text-xs text-gray-500" }, _a = {
780
- key: 1,
781
- class: "tv-no-source rounded-lg border border-dashed border-gray-200 p-6 text-center text-sm text-gray-400"
782
- }, ka = {
783
- key: 2,
784
- class: "tv-llm-provenance text-xs text-gray-400"
785
- }, $a = { class: "tv-llm-call-ids font-medium text-gray-500" }, Te = /* @__PURE__ */ J({
786
- __name: "CitationEvidence",
787
- props: {
788
- evidence: {},
789
- reasoning: { default: null },
790
- basis: { default: null },
791
- failed: { type: Boolean, default: !1 },
792
- collapsible: { type: Boolean, default: !0 },
793
- dense: { type: Boolean, default: !1 }
794
- },
795
- setup(e) {
796
- return (t, a) => (l(), c("div", pa, [
797
- e.failed && e.reasoning ? (l(), V(f(ge), {
798
- key: 0,
799
- variant: "danger",
800
- class: "tv-evidence-failed"
801
- }, {
802
- default: S(() => [
803
- N(v(e.reasoning), 1)
804
- ]),
805
- _: 1
806
- })) : e.reasoning ? (l(), c("section", ma, [
807
- i("div", xa, [
808
- a[0] || (a[0] = i("div", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Why this value ", -1)),
809
- e.basis ? (l(), V(f(be), {
810
- key: 0,
811
- tooltip: e.basis === "inferred" ? "The value was derived from the quotes below — computed, reformatted, or reasoned — rather than appearing as-is." : "The stored value appears word-for-word inside the quotes below, checked against the source document at store time.",
812
- placement: "top"
813
- }, {
814
- trigger: S(() => [
815
- I(f(M), {
816
- variant: e.basis === "inferred" ? "muted" : "success",
817
- size: "xxs",
818
- class: "tv-basis-chip"
819
- }, {
820
- default: S(() => [
821
- N(v(e.basis === "inferred" ? "inferred from quotes" : "✔ verbatim quote"), 1)
822
- ]),
823
- _: 1
824
- }, 8, ["variant"])
825
- ]),
826
- _: 1
827
- }, 8, ["tooltip"])) : h("", !0)
828
- ]),
829
- i("p", ya, v(e.reasoning), 1)
830
- ])) : h("", !0),
831
- i("section", ha, [
832
- i("div", ba, [
833
- a[1] || (a[1] = i("div", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Cited sources ", -1)),
834
- i("div", wa, v(f(Me)(e.evidence)), 1)
835
- ]),
836
- e.evidence.pages.length ? (l(), V(ga, {
837
- key: 0,
838
- pages: e.evidence.pages,
839
- collapsible: e.collapsible,
840
- dense: e.dense
841
- }, null, 8, ["pages", "collapsible", "dense"])) : e.evidence.unresolved.length ? h("", !0) : (l(), c("p", _a, " No source pages recorded for this data point ")),
842
- e.evidence.unresolved.length ? (l(), V(f(ge), {
843
- key: 2,
844
- variant: "warning",
845
- class: "tv-unresolved-citations"
846
- }, {
847
- default: S(() => [
848
- N(v(e.evidence.unresolved.length) + " " + v(e.evidence.unresolved.length === 1 ? "citation" : "citations") + " could not be matched to a page in the source documents. The value was kept, but this part of its provenance is unverified. ", 1)
849
- ]),
850
- _: 1
851
- })) : h("", !0)
852
- ]),
853
- e.evidence.apiLogIds.length ? (l(), c("p", ka, [
854
- N(" Produced by " + v(e.evidence.apiLogIds.length === 1 ? "LLM call" : "LLM calls") + " ", 1),
855
- i("span", $a, "#" + v(e.evidence.apiLogIds.join(", #")), 1),
856
- a[2] || (a[2] = N(" — open the Audit trail tab for the full request and response. ", -1))
857
- ])) : h("", !0)
858
- ]));
859
- }
860
- }), Ca = { class: "tv-modal flex h-full flex-col gap-4 overflow-y-auto p-1" }, Sa = { class: "tv-modal-resolved flex flex-col gap-3 rounded-xl border border-gray-200 bg-gradient-to-br from-gray-50 to-white p-4 shadow-sm" }, Va = { class: "flex flex-wrap items-start justify-between gap-4" }, Na = { class: "min-w-0 flex-1" }, qa = { class: "tv-resolved-value mt-1 break-words font-mono text-xl font-semibold leading-snug text-gray-900" }, Ia = { class: "mt-1 text-[11px] text-gray-400" }, Ea = { class: "tv-resolved-source font-medium text-gray-500" }, Da = { class: "tv-confidence-meter w-56 shrink-0" }, Ta = { class: "mt-2" }, Oa = {
861
- key: 1,
862
- class: "tv-confidence-value text-sm text-gray-400"
863
- }, La = {
864
- key: 0,
865
- class: "tv-tab-evidence flex min-h-0 flex-1 flex-col"
866
- }, Aa = {
867
- key: 1,
868
- class: "tv-tab-candidates flex flex-col gap-3"
869
- }, za = { class: "flex flex-wrap items-center justify-between gap-3" }, Pa = { class: "min-w-0 flex-1" }, ja = { class: "flex items-center gap-2" }, Ra = { class: "mt-2 break-words font-mono text-base text-gray-900" }, Ua = { class: "mt-1 text-xs text-gray-400" }, Ba = {
870
- key: 0,
871
- class: "tv-custom-entry flex items-center gap-2 rounded-lg border border-dashed border-gray-300 p-4"
872
- }, Ma = {
873
- key: 1,
874
- class: "tv-read-only text-center text-xs text-gray-400"
875
- }, Fa = {
876
- key: 2,
877
- class: "tv-tab-history flex flex-col gap-4"
878
- }, Ya = { class: "tv-history-current flex flex-col gap-2 rounded-xl border border-green-200 bg-green-50/40 p-4" }, Ka = { class: "flex flex-wrap items-center justify-between gap-3" }, Ha = { class: "flex flex-wrap items-center gap-2" }, Ja = { class: "tv-history-current-value break-words font-mono text-base font-semibold text-gray-900" }, Ga = {
879
- key: 0,
880
- class: "tv-history-current-confidence text-xs font-medium text-gray-500"
881
- }, Qa = {
882
- key: 1,
883
- class: "tv-history-current-confidence text-xs text-gray-400"
884
- }, Wa = {
885
- key: 0,
886
- class: "tv-history-current-reasoning text-sm italic leading-relaxed text-gray-600"
887
- }, Xa = { class: "tv-history-value min-w-0 break-words font-mono text-sm font-semibold text-gray-900" }, Za = {
888
- key: 2,
889
- class: "tv-history-confidence text-xs text-gray-500"
890
- }, el = { class: "tv-history-provenance text-xs text-gray-400" }, tl = { class: "tv-history-timestamp ml-auto text-xs text-gray-400" }, al = {
891
- key: 3,
892
- class: "tv-tab-audit flex flex-col gap-3"
893
- }, ll = {
894
- key: 2,
895
- class: "tv-audit-empty rounded-lg border border-dashed border-gray-200 p-6 text-center text-sm text-gray-400"
896
- }, nl = /* @__PURE__ */ J({
897
- __name: "VerificationModal",
898
- props: {
899
- modelValue: { type: Boolean },
900
- meta: {},
901
- label: {},
902
- save: { type: [Function, null] }
903
- },
904
- emits: ["update:modelValue", "saved"],
905
- setup(e, { emit: t }) {
906
- const a = e, b = t, y = we(), s = Le(), r = g({
907
- get: () => a.modelValue,
908
- set: (o) => b("update:modelValue", o)
909
- }), n = g(() => Re(a.meta)), C = O(null), u = g(
910
- () => C.value ?? a.meta.candidates.extracted
911
- ), _ = g(() => a.meta.candidates.claim), m = g(
912
- () => {
913
- var o;
914
- return de.value && ((o = u.value) == null ? void 0 : o.sources) === void 0;
915
- }
916
- ), T = g(() => a.meta.candidates.override), z = g(() => {
917
- var o;
918
- return ((o = u.value) == null ? void 0 : o.confidence) ?? null;
919
- }), q = g(() => {
920
- var o;
921
- return ((o = u.value) == null ? void 0 : o.state) === "failed" ? "failed" : _e(z.value);
922
- }), F = g(() => {
923
- var L;
924
- const o = (L = u.value) == null ? void 0 : L.reasoning;
925
- if (o == null) return null;
926
- const d = String(o).trim();
927
- return d === "" ? null : d;
928
- }), Y = g(() => {
929
- var o;
930
- return me((o = u.value) == null ? void 0 : o.sources);
931
- }), U = g(
932
- () => {
933
- var o;
934
- return ((o = u.value) == null ? void 0 : o.history) ?? [];
935
- }
936
- ), w = g(
937
- () => {
938
- var o;
939
- return ((o = u.value) == null ? void 0 : o.history_count) ?? U.value.length;
940
- }
941
- ), D = g(() => w.value > 0), k = g(() => (a.meta.anchor.field_path || a.label || "Data point").split(".").map(
942
- (d) => d.replace(/\[\d+\]/g, "").replace(/_/g, " ").replace(/^\w/, (L) => L.toUpperCase())
943
- ).join(" › ")), P = {
944
- high: "success",
945
- medium: "warning",
946
- low: "danger",
947
- unverifiable: "muted",
948
- failed: "danger"
949
- }, j = O("evidence"), Q = g(() => !!y.detailUrl), W = g(() => {
950
- var d;
951
- const o = [
952
- {
953
- value: "evidence",
954
- label: "Citations",
955
- count: Y.value.pageCount
956
- },
957
- {
958
- value: "candidates",
959
- label: "Candidates",
960
- count: X.value.length
961
- }
962
- ];
963
- return D.value && o.push({
964
- value: "history",
965
- label: "History",
966
- count: U.value.length
967
- }), Q.value && o.push({
968
- value: "audit",
969
- label: "Audit trail",
970
- count: ((d = Z.value) == null ? void 0 : d.length) ?? void 0
971
- }), o;
972
- });
973
- ae(
974
- r,
975
- (o) => Ee(o),
976
- { immediate: !0 }
977
- ), Ge(() => Ee(!1));
978
- const X = g(() => {
979
- const o = [];
980
- return T.value && o.push({
981
- key: "override",
982
- title: "Human override",
983
- variant: "success",
984
- value: T.value.value,
985
- detail: [
986
- T.value.source_choice ? `basis: ${T.value.source_choice}` : null,
987
- T.value.set_at ? new Date(T.value.set_at).toLocaleString() : null
988
- ].filter(Boolean).join(" · "),
989
- winner: n.value.source === "override"
990
- }), u.value && o.push({
991
- key: "extracted",
992
- title: "Extracted",
993
- variant: P[q.value],
994
- value: u.value.value,
995
- detail: q.value === "failed" ? u.value.reasoning ? `${K.failed}: ${u.value.reasoning}` : K.failed : z.value != null ? `Confidence ${z.value}/5 · ${K[q.value]}` : "No confidence recorded",
996
- accept: a.save ? () => {
997
- var d;
998
- return E(ne((d = u.value) == null ? void 0 : d.value), "extracted");
999
- } : void 0,
1000
- winner: n.value.source === "extracted"
1001
- }), _.value && o.push({
1002
- key: "claim",
1003
- title: "Claim",
1004
- variant: "info",
1005
- value: _.value.value,
1006
- detail: _.value.claim_set_label ?? "Reference output",
1007
- accept: a.save ? () => {
1008
- var d;
1009
- return E(ne((d = _.value) == null ? void 0 : d.value), "claim");
1010
- } : void 0,
1011
- winner: n.value.source === "claim"
1012
- }), o;
1013
- }), p = O(""), $ = O(!1);
1014
- async function E(o, d) {
1015
- if (!(!a.save || $.value)) {
1016
- $.value = !0;
1017
- try {
1018
- const L = await a.save(o, d);
1019
- b("saved", L), s.success(`Verified — ${k.value} locked in`);
1020
- } catch (L) {
1021
- console.error("template-verification: save failed", L), s.danger(`Could not save ${k.value} — try again`);
1022
- } finally {
1023
- $.value = !1;
1024
- }
1025
- }
1026
- }
1027
- const le = () => E(p.value, "custom");
1028
- function ne(o) {
1029
- return o == null ? null : String(o);
1030
- }
1031
- function G(o) {
1032
- return o == null ? "—" : String(o);
1033
- }
1034
- const te = (o, d) => String(o.id ?? `attempt-${d}`), Ye = g(
1035
- () => U.value.map((o, d) => ({
1036
- value: te(o, d),
1037
- label: G(o.value)
1038
- }))
1039
- ), pe = O([]);
1040
- ae(
1041
- U,
1042
- (o) => {
1043
- const d = o.findIndex((x) => x.is_chosen), L = d === -1 ? o.length - 1 : d;
1044
- pe.value = L >= 0 ? [te(o[L], L)] : [];
1045
- },
1046
- { immediate: !0 }
1047
- );
1048
- const R = g(
1049
- () => new Map(
1050
- U.value.map((o, d) => [te(o, d), o])
1051
- )
1052
- );
1053
- function Ke(o) {
1054
- return o.created_at ? new Date(o.created_at).toLocaleString() : "—";
1055
- }
1056
- function He(o) {
1057
- return Me(me(o.sources));
1058
- }
1059
- function Je(o) {
1060
- return o.is_chosen ? null : o.reasoning ?? null;
1061
- }
1062
- const Z = O(null), de = O(!1), ce = O(null), ke = O(!1);
1063
- return ae(
1064
- r,
1065
- async (o) => {
1066
- if (!(!o || ke.value || !y.detailUrl)) {
1067
- ke.value = !0, de.value = !0, ce.value = null;
1068
- try {
1069
- const d = await $t(
1070
- y.detailUrl,
1071
- a.meta.anchor
1072
- );
1073
- d.extracted && (C.value = d.extracted), Z.value = d.audit;
1074
- } catch (d) {
1075
- ce.value = d instanceof Error ? d.message : String(d);
1076
- } finally {
1077
- de.value = !1;
1078
- }
1079
- }
1080
- },
1081
- { immediate: !0 }
1082
- ), (o, d) => (l(), V(f(Oe), {
1083
- modelValue: r.value,
1084
- "onUpdate:modelValue": d[3] || (d[3] = (L) => r.value = L),
1085
- title: k.value,
1086
- width: 90,
1087
- height: 90,
1088
- "close-x": "",
1089
- class: A(f(ee))
1090
- }, {
1091
- default: S(() => {
1092
- var L;
1093
- return [
1094
- i("div", Ca, [
1095
- i("section", Sa, [
1096
- i("div", Va, [
1097
- i("div", Na, [
1098
- d[5] || (d[5] = i("div", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Resolved value ", -1)),
1099
- i("div", qa, v(G(n.value.value)), 1),
1100
- i("div", Ia, [
1101
- d[4] || (d[4] = N(" source of truth: ", -1)),
1102
- i("span", Ea, v(n.value.source), 1)
1103
- ])
1104
- ]),
1105
- i("div", Da, [
1106
- I(f(be), {
1107
- tooltip: "How certain the AI was when it extracted this value — not whether the quotes in the Citations tab were checked against the source (that tab's own badge says so).",
1108
- placement: "top"
1109
- }, {
1110
- trigger: S(() => [...d[6] || (d[6] = [
1111
- i("div", { class: "w-fit text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Extraction confidence ", -1)
1112
- ])]),
1113
- _: 1
1114
- }),
1115
- i("div", Ta, [
1116
- z.value != null ? (l(), V(f(Ae), {
1117
- key: 0,
1118
- value: z.value,
1119
- max: 5,
1120
- size: "md",
1121
- variant: P[q.value],
1122
- gradient: "",
1123
- shimmer: "",
1124
- "show-text": "",
1125
- "text-position": "beside",
1126
- label: `${z.value}/5`
1127
- }, null, 8, ["value", "variant", "label"])) : (l(), c("div", Oa, " No confidence recorded "))
1128
- ]),
1129
- i("div", {
1130
- class: A(["tv-confidence-label mt-1 text-right text-xs font-medium", {
1131
- "text-green-600": q.value === "high",
1132
- "text-yellow-600": q.value === "medium",
1133
- "text-red-600": q.value === "low",
1134
- "text-gray-400": q.value === "unverifiable",
1135
- "text-red-800": q.value === "failed"
1136
- }])
1137
- }, v(f(K)[q.value]), 3)
1138
- ])
1139
- ]),
1140
- e.meta.discrepancy ? (l(), V(f(ge), {
1141
- key: 0,
1142
- variant: "warning",
1143
- class: "tv-discrepancy"
1144
- }, {
1145
- default: S(() => [...d[7] || (d[7] = [
1146
- N(" Sources disagree on this value — review the candidates and pick a winner. ", -1)
1147
- ])]),
1148
- _: 1
1149
- })) : h("", !0)
1150
- ]),
1151
- I(f(at), {
1152
- modelValue: j.value,
1153
- "onUpdate:modelValue": d[0] || (d[0] = (x) => j.value = x),
1154
- tabs: W.value,
1155
- class: "tv-modal-tabs"
1156
- }, null, 8, ["modelValue", "tabs"]),
1157
- j.value === "evidence" ? (l(), c("section", La, [
1158
- m.value ? (l(), c(B, { key: 0 }, H(2, (x) => I(f(ve), {
1159
- key: x,
1160
- shape: "rounded",
1161
- class: "tv-evidence-skeleton h-24 w-full"
1162
- })), 64)) : (l(), V(Te, {
1163
- key: 1,
1164
- evidence: Y.value,
1165
- reasoning: F.value,
1166
- basis: (L = u.value) == null ? void 0 : L.basis,
1167
- failed: q.value === "failed"
1168
- }, null, 8, ["evidence", "reasoning", "basis", "failed"]))
1169
- ])) : h("", !0),
1170
- j.value === "candidates" ? (l(), c("section", Aa, [
1171
- (l(!0), c(B, null, H(X.value, (x) => (l(), c("div", {
1172
- key: x.key,
1173
- class: A(["tv-candidate-row rounded-lg border p-4 transition-shadow", [
1174
- x.winner ? "border-gray-300 bg-gray-50 shadow-sm" : "border-gray-200",
1175
- e.meta.discrepancy && !x.winner ? "tv-candidate-disagrees border-amber-200" : ""
1176
- ]])
1177
- }, [
1178
- i("div", za, [
1179
- i("div", Pa, [
1180
- i("div", ja, [
1181
- I(f(M), {
1182
- variant: x.variant,
1183
- size: "xs"
1184
- }, {
1185
- default: S(() => [
1186
- N(v(x.title), 1)
1187
- ]),
1188
- _: 2
1189
- }, 1032, ["variant"]),
1190
- x.winner ? (l(), V(f(M), {
1191
- key: 0,
1192
- variant: "success",
1193
- size: "xxs",
1194
- class: "tv-winner-chip"
1195
- }, {
1196
- default: S(() => [...d[8] || (d[8] = [
1197
- N("current value", -1)
1198
- ])]),
1199
- _: 1
1200
- })) : h("", !0)
1201
- ]),
1202
- i("div", Ra, v(G(x.value)), 1),
1203
- i("div", Ua, v(x.detail), 1)
1204
- ]),
1205
- x.accept && !x.winner ? (l(), V(f(re), {
1206
- key: 0,
1207
- size: "sm",
1208
- variant: x.variant,
1209
- loading: $.value,
1210
- class: A(`tv-accept-${x.key}`),
1211
- onClick: x.accept
1212
- }, {
1213
- default: S(() => [...d[9] || (d[9] = [
1214
- N("Accept this value", -1)
1215
- ])]),
1216
- _: 1
1217
- }, 8, ["variant", "loading", "class", "onClick"])) : h("", !0)
1218
- ])
1219
- ], 2))), 128)),
1220
- e.save ? (l(), c("div", Ba, [
1221
- I(f(lt), {
1222
- modelValue: p.value,
1223
- "onUpdate:modelValue": d[1] || (d[1] = (x) => p.value = x),
1224
- size: "sm",
1225
- class: "tv-custom-input flex-1",
1226
- placeholder: "Type the correct value…",
1227
- disabled: $.value
1228
- }, null, 8, ["modelValue", "disabled"]),
1229
- I(f(re), {
1230
- variant: "success",
1231
- size: "sm",
1232
- class: "tv-accept-custom",
1233
- loading: $.value,
1234
- disabled: !p.value,
1235
- onClick: le
1236
- }, {
1237
- default: S(() => [...d[10] || (d[10] = [
1238
- N("Save custom value", -1)
1239
- ])]),
1240
- _: 1
1241
- }, 8, ["loading", "disabled"])
1242
- ])) : (l(), c("div", Ma, " Read-only render — corrections are disabled here "))
1243
- ])) : h("", !0),
1244
- j.value === "history" ? (l(), c("section", Fa, [
1245
- i("section", Ya, [
1246
- i("div", Ka, [
1247
- i("div", Ha, [
1248
- I(f(M), {
1249
- variant: "success",
1250
- size: "xxs"
1251
- }, {
1252
- default: S(() => [...d[11] || (d[11] = [
1253
- N("current value", -1)
1254
- ])]),
1255
- _: 1
1256
- }),
1257
- i("span", Ja, v(G(n.value.value)), 1)
1258
- ]),
1259
- z.value != null ? (l(), c("span", Ga, "Confidence " + v(z.value) + "/5 · " + v(f(K)[q.value]), 1)) : (l(), c("span", Qa, v(f(K)[q.value]), 1))
1260
- ]),
1261
- F.value ? (l(), c("p", Wa, v(F.value), 1)) : h("", !0)
1262
- ]),
1263
- d[13] || (d[13] = i("div", { class: "flex flex-wrap items-baseline justify-between gap-2" }, [
1264
- i("div", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, " Every recorded attempt "),
1265
- i("div", { class: "text-xs text-gray-400" }, "oldest first")
1266
- ], -1)),
1267
- m.value ? (l(), c(B, { key: 0 }, H(2, (x) => I(f(ve), {
1268
- key: x,
1269
- shape: "rounded",
1270
- class: "tv-history-skeleton h-16 w-full"
1271
- })), 64)) : (l(), V(Fe, {
1272
- key: 1,
1273
- modelValue: pe.value,
1274
- "onUpdate:modelValue": d[2] || (d[2] = (x) => pe.value = x),
1275
- items: Ye.value,
1276
- "id-prefix": "tv-attempt",
1277
- class: "tv-history-accordion overflow-hidden rounded-lg border border-gray-200"
1278
- }, {
1279
- header: S(({ item: x }) => {
1280
- var se, ie, oe, $e, Ce, Se, Ve;
1281
- return [
1282
- i("span", {
1283
- class: A([
1284
- "tv-history-row flex min-w-0 flex-1 flex-wrap items-center gap-2 text-left",
1285
- (se = R.value.get(x.value)) != null && se.is_chosen ? "tv-history-chosen" : ""
1286
- ])
1287
- }, [
1288
- (ie = R.value.get(x.value)) != null && ie.is_chosen ? (l(), V(f(M), {
1289
- key: 0,
1290
- variant: "success",
1291
- size: "xxs",
1292
- class: "tv-history-chosen-chip"
1293
- }, {
1294
- default: S(() => [...d[12] || (d[12] = [
1295
- N("chosen", -1)
1296
- ])]),
1297
- _: 1
1298
- })) : h("", !0),
1299
- i("span", Xa, v(G((oe = R.value.get(x.value)) == null ? void 0 : oe.value)), 1),
1300
- ($e = R.value.get(x.value)) != null && $e.state ? (l(), V(f(M), {
1301
- key: 1,
1302
- variant: ((Ce = R.value.get(x.value)) == null ? void 0 : Ce.state) === "failed" ? "danger" : "muted",
1303
- size: "xxs",
1304
- class: "tv-history-state"
1305
- }, {
1306
- default: S(() => {
1307
- var Ne;
1308
- return [
1309
- N(v((Ne = R.value.get(x.value)) == null ? void 0 : Ne.state), 1)
1310
- ];
1311
- }),
1312
- _: 2
1313
- }, 1032, ["variant"])) : h("", !0),
1314
- ((Se = R.value.get(x.value)) == null ? void 0 : Se.confidence) != null ? (l(), c("span", Za, v((Ve = R.value.get(x.value)) == null ? void 0 : Ve.confidence) + "/5", 1)) : h("", !0),
1315
- i("span", el, v(He(
1316
- R.value.get(x.value)
1317
- )), 1),
1318
- i("span", tl, v(Ke(R.value.get(x.value))), 1)
1319
- ], 2)
1320
- ];
1321
- }),
1322
- panel: S(({ item: x }) => {
1323
- var se, ie, oe;
1324
- return [
1325
- I(Te, {
1326
- evidence: f(me)(
1327
- (se = R.value.get(x.value)) == null ? void 0 : se.sources
1328
- ),
1329
- reasoning: Je(R.value.get(x.value)),
1330
- basis: (ie = R.value.get(x.value)) == null ? void 0 : ie.basis,
1331
- failed: ((oe = R.value.get(x.value)) == null ? void 0 : oe.state) === "failed",
1332
- collapsible: !1,
1333
- dense: ""
1334
- }, null, 8, ["evidence", "reasoning", "basis", "failed"])
1335
- ];
1336
- }),
1337
- _: 1
1338
- }, 8, ["modelValue", "items"]))
1339
- ])) : h("", !0),
1340
- j.value === "audit" ? (l(), c("section", al, [
1341
- de.value && Z.value === null ? (l(), c(B, { key: 0 }, H(2, (x) => I(f(ve), {
1342
- key: x,
1343
- shape: "rounded",
1344
- class: "tv-audit-skeleton h-24 w-full"
1345
- })), 64)) : ce.value ? (l(), V(f(ge), {
1346
- key: 1,
1347
- variant: "danger",
1348
- class: "tv-audit-error"
1349
- }, {
1350
- default: S(() => [
1351
- N(" Could not load the audit trail: " + v(ce.value), 1)
1352
- ]),
1353
- _: 1
1354
- })) : Z.value && Z.value.length === 0 ? (l(), c("div", ll, " No LLM calls recorded for this data point ")) : Z.value ? (l(!0), c(B, { key: 3 }, H(Z.value, (x) => (l(), V(Ut, {
1355
- key: String(x.id),
1356
- call: x
1357
- }, null, 8, ["call"]))), 128)) : h("", !0)
1358
- ])) : h("", !0)
1359
- ])
1360
- ];
1361
- }),
1362
- _: 1
1363
- }, 8, ["modelValue", "title", "class"]));
222
+ p("span", De, w(b.value), 1),
223
+ e.showLabel ? (u(), g("span", Le, w(i.value), 1)) : _("", !0)
224
+ ], 10, Ve));
1364
225
  }
1365
- }), sl = ["contenteditable", "data-editable"], il = {
226
+ }), Pe = { class: "tv-mark-slot" }, je = ["aria-label", "title"], Me = {
1366
227
  key: 1,
1367
228
  class: "tv-verified-chip inline-flex items-center gap-1 rounded-full bg-green-600 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",
1368
229
  "data-status": "verified"
1369
- }, ol = {
1370
- key: 2,
1371
- class: "tv-discrepancy-indicator ml-0.5 text-amber-500",
1372
- "aria-label": "discrepancy"
1373
- }, xl = /* @__PURE__ */ J({
230
+ }, Be = {
231
+ key: 3,
232
+ class: "tv-correction-indicator ml-0.5 text-blue-500",
233
+ "aria-hidden": !0
234
+ }, Je = /* @__PURE__ */ U({
1374
235
  __name: "VerifiedField",
1375
236
  props: {
1376
237
  source: {},
@@ -1379,145 +240,126 @@ const Lt = { class: "tv-audit-call rounded-lg border border-gray-200 shadow-sm"
1379
240
  format: { type: Function }
1380
241
  },
1381
242
  setup(e) {
1382
- const t = e, a = we(), b = g(() => a.enabled.value), y = g(() => a.loading), s = O(null), r = g(() => {
1383
- var p;
1384
- return s.value ? s.value : t.source && t.field ? ((p = t.source.__meta) == null ? void 0 : p[t.field]) ?? null : null;
1385
- }), n = g(() => Re(r.value)), C = g(() => {
243
+ const t = e, n = Q(), c = l(() => n.enabled.value), b = l(() => n.loading), r = l(() => {
244
+ var a;
245
+ return t.source && t.field ? ((a = t.source.__meta) == null ? void 0 : a[t.field]) ?? null : null;
246
+ }), i = l(() => we(r.value)), m = l(() => {
1386
247
  if (t.original !== void 0 && t.original !== null)
1387
248
  return t.original;
1388
- if (r.value && n.value.value !== null && n.value.value !== void 0)
1389
- return n.value.value;
249
+ if (r.value && i.value.value !== null && i.value.value !== void 0)
250
+ return i.value.value;
1390
251
  if (t.source && t.field) return t.source[t.field];
1391
- }), u = g(() => {
1392
- const p = C.value;
1393
- return p == null ? "" : typeof t.format == "function" ? t.format(p) : String(p);
1394
- }), _ = g(() => {
1395
- var $, E;
1396
- const p = (E = ($ = r.value) == null ? void 0 : $.candidates) == null ? void 0 : E.extracted;
1397
- return (p == null ? void 0 : p.state) === "failed" ? "failed" : _e(p == null ? void 0 : p.confidence);
1398
- }), m = g(() => gt(r.value)), T = g(() => {
1399
- var p, $;
1400
- return !!(($ = (p = r.value) == null ? void 0 : p.candidates) != null && $.override);
1401
- }), z = g(() => {
1402
- var $;
1403
- const p = ($ = r.value) == null ? void 0 : $.candidates;
1404
- return !!(p != null && p.override || p != null && p.extracted || p != null && p.claim);
1405
- }), q = g(() => b.value), F = g(() => !!r.value), Y = g(() => {
1406
- const p = r.value;
1407
- return q.value && !!p && Be(p);
1408
- }), U = g(() => {
1409
- var ne, G, te;
1410
- const p = (G = (ne = r.value) == null ? void 0 : ne.candidates) == null ? void 0 : G.extracted;
1411
- if (!p) return "No verification data";
1412
- if (_.value === "failed")
1413
- return p.reasoning ? `${K.failed}: ${p.reasoning}` : K.failed;
1414
- const $ = [], E = K[_.value];
1415
- $.push(
1416
- p.confidence != null ? `${E} (${p.confidence}/5)` : E
1417
- );
1418
- const le = p.sources_count ?? ((te = p.sources) == null ? void 0 : te.length) ?? 0;
1419
- return le > 0 && $.push(`${le} source ${le === 1 ? "page" : "pages"}`), m.value && $.push("sources disagree"), $.join(" · ");
252
+ }), v = l(() => {
253
+ const a = m.value;
254
+ return a == null ? "" : typeof t.format == "function" ? t.format(a) : String(a);
255
+ }), A = l(() => {
256
+ var s, d;
257
+ const a = (d = (s = r.value) == null ? void 0 : s.candidates) == null ? void 0 : d.extracted;
258
+ return (a == null ? void 0 : a.state) === "failed" ? "failed" : W(a == null ? void 0 : a.confidence);
259
+ }), h = l(() => xe(r.value)), o = l(() => Se(r.value)), x = l(() => !h.value && Ie(r.value)), k = l(() => {
260
+ var a, s;
261
+ return !!((s = (a = r.value) == null ? void 0 : a.candidates) != null && s.override);
262
+ }), E = l(() => {
263
+ var s;
264
+ const a = (s = r.value) == null ? void 0 : s.candidates;
265
+ return !!(a != null && a.override || a != null && a.extracted || a != null && a.claim);
266
+ }), I = l(() => c.value), R = l(() => {
267
+ const a = r.value;
268
+ return I.value && !!a && ee(a);
269
+ }), C = l(() => {
270
+ var a;
271
+ return !!((a = r.value) != null && a.anchor);
272
+ }), T = l(() => {
273
+ var z, F, Y;
274
+ const a = t.field ?? "This value", s = C.value ? " — open in the review panel" : "";
275
+ if (k.value) return `${a}: verified by a person${s}`;
276
+ const d = (F = (z = r.value) == null ? void 0 : z.candidates) == null ? void 0 : F.extracted, D = A.value, S = [];
277
+ D === "failed" ? S.push(V.failed) : (d == null ? void 0 : d.confidence) != null ? S.push(`${V[D]} (${d.confidence}/5)`) : S.push(V[D]);
278
+ const L = (d == null ? void 0 : d.sources_count) ?? ((Y = d == null ? void 0 : d.sources) == null ? void 0 : Y.length) ?? 0;
279
+ return L > 0 && S.push(`${L} cited ${L === 1 ? "page" : "pages"}`), h.value ? S.push(o.value ? "source document conflict" : "sources disagree") : x.value && S.push("value corrected"), `${a}: ${S.join(", ")}${s}`;
1420
280
  });
1421
- function w(p) {
1422
- var $;
1423
- s.value = p, ($ = t.source) != null && $.__meta && t.field && (t.source.__meta[t.field] = p);
281
+ function te() {
282
+ var s;
283
+ const a = (s = r.value) == null ? void 0 : s.anchor;
284
+ a && Ee({
285
+ anchor: a,
286
+ workflowInputId: n.workflowInputId,
287
+ label: t.field ?? null,
288
+ value: v.value
289
+ });
1424
290
  }
1425
- const D = g(() => ht(a, r, w)), k = g(() => !!D.value), P = O(!1), j = O(!1);
1426
- function Q() {
1427
- r.value && (P.value = !0);
1428
- }
1429
- const W = g(() => F.value);
1430
- async function X(p) {
1431
- j.value = !1;
1432
- const E = (p.target.textContent ?? "").trim();
1433
- !D.value || E === u.value || await D.value(E, "custom");
1434
- }
1435
- return (p, $) => (l(), c("span", {
1436
- class: A(["tv-field inline-flex items-baseline gap-1", Y.value ? "tv-needs-review" : ""])
291
+ return (a, s) => (u(), g("span", {
292
+ class: y(["tv-field", R.value ? "tv-needs-review" : ""])
1437
293
  }, [
1438
- y.value ? (l(), V(f(ve), {
294
+ b.value ? (u(), j(f(ie), {
1439
295
  key: 0,
1440
296
  shape: "rounded",
1441
297
  class: "tv-field-skeleton inline-block h-[1em] w-16 align-middle"
1442
- })) : (l(), c(B, { key: 1 }, [
1443
- i("span", {
1444
- class: A([
298
+ })) : (u(), g(M, { key: 1 }, [
299
+ p("span", {
300
+ class: y([
1445
301
  "tv-field-value",
1446
- q.value && !z.value ? "tv-field-unverified cursor-pointer border-b border-dotted border-gray-300" : ""
1447
- ]),
1448
- contenteditable: k.value,
1449
- "data-editable": k.value ? "true" : "false",
1450
- onFocus: $[0] || ($[0] = (E) => j.value = !0),
1451
- onBlur: X,
1452
- onKeydown: $[1] || ($[1] = Qe(ye((E) => E.target.blur(), ["prevent"]), ["enter"])),
1453
- onClick: $[2] || ($[2] = (E) => q.value && !z.value ? Q() : void 0)
302
+ I.value && !E.value ? "tv-field-unverified border-b border-dotted border-gray-300" : ""
303
+ ])
1454
304
  }, [
1455
- xe(p.$slots, "default", {
1456
- value: C.value,
1457
- formatted: u.value
305
+ ne(a.$slots, "default", {
306
+ value: m.value,
307
+ formatted: v.value
1458
308
  }, () => [
1459
- N(v(u.value), 1)
309
+ re(w(v.value), 1)
1460
310
  ])
1461
- ], 42, sl),
1462
- q.value ? (l(), V(f(be), {
1463
- key: 0,
1464
- tooltip: U.value,
1465
- placement: "top"
1466
- }, {
1467
- trigger: S(() => [
1468
- i("button", {
1469
- type: "button",
1470
- class: A(["tv-overlay inline-flex items-center align-middle transition-transform duration-150", [f(ee), W.value ? "cursor-pointer hover:scale-110" : "cursor-default"]]),
1471
- onClick: $[3] || ($[3] = (E) => W.value ? Q() : void 0)
1472
- }, [
1473
- T.value ? (l(), c("span", il, "✔")) : (l(), V(kt, {
1474
- key: 0,
1475
- status: _.value
1476
- }, null, 8, ["status"])),
1477
- m.value && !T.value ? (l(), c("span", ol, "⚠")) : h("", !0)
1478
- ], 2)
1479
- ]),
1480
- _: 1
1481
- }, 8, ["tooltip"])) : h("", !0),
1482
- r.value ? (l(), V(nl, {
1483
- key: 1,
1484
- modelValue: P.value,
1485
- "onUpdate:modelValue": $[4] || ($[4] = (E) => P.value = E),
1486
- meta: r.value,
1487
- label: e.field,
1488
- save: D.value
1489
- }, null, 8, ["modelValue", "meta", "label", "save"])) : h("", !0)
311
+ ], 2),
312
+ p("span", Pe, [
313
+ I.value ? (u(), g("button", {
314
+ key: 0,
315
+ type: "button",
316
+ class: y(["tv-overlay", [f($), C.value ? "cursor-pointer" : "cursor-default"]]),
317
+ "aria-label": T.value,
318
+ title: T.value,
319
+ onClick: s[0] || (s[0] = (d) => C.value ? te() : void 0)
320
+ }, [
321
+ k.value ? (u(), g("span", Me, "✔")) : (u(), j(Ne, {
322
+ key: 0,
323
+ status: A.value
324
+ }, null, 8, ["status"])),
325
+ h.value && !k.value ? (u(), g("span", {
326
+ key: 2,
327
+ class: y(["tv-discrepancy-indicator ml-0.5 text-amber-500", o.value ? "tv-source-discrepancy-indicator" : ""]),
328
+ "aria-hidden": !0
329
+ }, "⚠", 2)) : x.value && !k.value ? (u(), g("span", Be, "✎")) : _("", !0)
330
+ ], 10, je)) : _("", !0)
331
+ ])
1490
332
  ], 64))
1491
333
  ], 2));
1492
334
  }
1493
- }), rl = { class: "tv-enable-toggle flex items-center justify-between text-sm font-medium text-gray-700" }, ul = { class: "tv-progress-block" }, dl = { class: "mb-1 flex items-baseline justify-between" }, cl = { class: "tv-progress-count text-xs font-semibold text-gray-600" }, vl = {
335
+ }), Ue = { class: "tv-enable-toggle flex items-center justify-between text-sm font-medium text-gray-700" }, ze = { class: "tv-progress-block" }, Fe = { class: "mb-1 flex items-baseline justify-between" }, Ye = { class: "tv-progress-count text-xs font-semibold text-gray-600" }, Ge = {
1494
336
  key: 0,
1495
337
  class: "tv-attempts-recorded mt-1 text-[11px] text-gray-400"
1496
- }, yl = /* @__PURE__ */ J({
338
+ }, Qe = /* @__PURE__ */ U({
1497
339
  __name: "VerificationChrome",
1498
340
  setup(e) {
1499
- const t = we(), { enabled: a } = t, b = Le(), y = O(!1), s = g(() => yt(t.data)), r = g(
1500
- () => Ue(t.data).reduce(
1501
- (_, m) => {
1502
- var T, z, q, F, Y, U, w;
1503
- return _ + (((q = (z = (T = m.meta) == null ? void 0 : T.candidates) == null ? void 0 : z.extracted) == null ? void 0 : q.history_count) ?? ((w = (U = (Y = (F = m.meta) == null ? void 0 : F.candidates) == null ? void 0 : Y.extracted) == null ? void 0 : U.history) == null ? void 0 : w.length) ?? 0);
341
+ const t = Q(), { enabled: n } = t, c = se(), b = P(!1), r = l(() => Oe(t.data)), i = l(
342
+ () => Z(t.data).reduce(
343
+ (h, o) => {
344
+ var x, k, E, I, R, C, T;
345
+ return h + (((E = (k = (x = o.meta) == null ? void 0 : x.candidates) == null ? void 0 : k.extracted) == null ? void 0 : E.history_count) ?? ((T = (C = (R = (I = o.meta) == null ? void 0 : I.candidates) == null ? void 0 : R.extracted) == null ? void 0 : C.history) == null ? void 0 : T.length) ?? 0);
1504
346
  },
1505
347
  0
1506
348
  )
1507
- ), n = O(!1);
1508
- ae(
1509
- () => s.value.percent,
1510
- (_) => {
1511
- _ === 100 && s.value.total > 0 && !n.value && (n.value = !0, b.success("All data points verified 🎯"));
349
+ ), m = P(!1);
350
+ K(
351
+ () => r.value.percent,
352
+ (h) => {
353
+ h === 100 && r.value.total > 0 && !m.value && (m.value = !0, c.success("All data points verified 🎯"));
1512
354
  }
1513
355
  );
1514
- let C = 0;
1515
- function u() {
1516
- const _ = document.querySelectorAll(".tv-needs-review");
1517
- if (!_.length) return;
1518
- C = C % _.length;
1519
- const m = _[C];
1520
- C++, m.scrollIntoView({ behavior: "smooth", block: "center" }), m.animate(
356
+ let v = 0;
357
+ function A() {
358
+ const h = document.querySelectorAll(".tv-needs-review");
359
+ if (!h.length) return;
360
+ v = v % h.length;
361
+ const o = h[v];
362
+ v++, o.scrollIntoView({ behavior: "smooth", block: "center" }), o.animate(
1521
363
  [
1522
364
  { boxShadow: "0 0 0 0 rgba(245, 158, 11, 0.8)" },
1523
365
  { boxShadow: "0 0 0 12px rgba(245, 158, 11, 0)" }
@@ -1525,97 +367,94 @@ const Lt = { class: "tv-audit-call rounded-lg border border-gray-200 shadow-sm"
1525
367
  { duration: 900, iterations: 2 }
1526
368
  );
1527
369
  }
1528
- return (_, m) => (l(), c(B, null, [
1529
- i("button", {
370
+ return (h, o) => (u(), g(M, null, [
371
+ p("button", {
1530
372
  type: "button",
1531
- class: A(["tv-settings-button fixed bottom-4 right-4 z-50 flex h-11 w-11 items-center justify-center rounded-full bg-gray-900 text-white shadow-lg transition-transform hover:scale-105", f(ee)]),
373
+ class: y(["tv-settings-button fixed bottom-4 right-4 z-50 flex h-11 w-11 items-center justify-center rounded-full bg-gray-900 text-white shadow-lg transition-transform hover:scale-105", f($)]),
1532
374
  title: "Verification",
1533
- onClick: m[0] || (m[0] = ye((T) => y.value = !y.value, ["stop"]))
375
+ onClick: o[0] || (o[0] = G((x) => b.value = !b.value, ["stop"]))
1534
376
  }, [
1535
- I(f(nt), {
1536
- icon: f(st),
377
+ N(f(ue), {
378
+ icon: f(ce),
1537
379
  class: "h-5 w-5"
1538
380
  }, null, 8, ["icon"]),
1539
- f(a) && s.value.needsReview > 0 ? (l(), V(f(it), {
381
+ f(n) && r.value.needsReview > 0 ? (u(), j(f(de), {
1540
382
  key: 0,
1541
- value: s.value.needsReview,
383
+ value: r.value.needsReview,
1542
384
  variant: "warning",
1543
385
  class: "tv-needs-review-badge absolute -right-1 -top-1"
1544
- }, null, 8, ["value"])) : h("", !0)
386
+ }, null, 8, ["value"])) : _("", !0)
1545
387
  ], 2),
1546
- y.value ? (l(), c("div", {
388
+ b.value ? (u(), g("div", {
1547
389
  key: 0,
1548
- class: A(["tv-settings-panel fixed bottom-20 right-4 z-50 flex w-72 flex-col gap-4 rounded-xl bg-white p-4 shadow-2xl ring-1 ring-gray-200", f(ee)])
390
+ class: y(["tv-settings-panel fixed bottom-20 right-4 z-50 flex w-72 flex-col gap-4 rounded-xl bg-white p-4 shadow-2xl ring-1 ring-gray-200", f($)])
1549
391
  }, [
1550
- i("label", rl, [
1551
- m[2] || (m[2] = i("span", null, "Verification overlay", -1)),
1552
- We(i("input", {
1553
- "onUpdate:modelValue": m[1] || (m[1] = (T) => Xe(a) ? a.value = T : null),
392
+ p("label", Ue, [
393
+ o[2] || (o[2] = p("span", null, "Verification overlay", -1)),
394
+ ae(p("input", {
395
+ "onUpdate:modelValue": o[1] || (o[1] = (x) => le(n) ? n.value = x : null),
1554
396
  type: "checkbox",
1555
397
  class: "tv-enable-checkbox h-4 w-4 accent-gray-900"
1556
398
  }, null, 512), [
1557
- [Ze, f(a)]
399
+ [oe, f(n)]
1558
400
  ])
1559
401
  ]),
1560
- f(a) && s.value.total > 0 ? (l(), c(B, { key: 0 }, [
1561
- i("div", ul, [
1562
- i("div", dl, [
1563
- m[3] || (m[3] = i("span", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, "Review progress", -1)),
1564
- i("span", cl, v(s.value.verified) + " / " + v(s.value.total), 1)
402
+ f(n) && r.value.total > 0 ? (u(), g(M, { key: 0 }, [
403
+ p("div", ze, [
404
+ p("div", Fe, [
405
+ o[3] || (o[3] = p("span", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, "Review progress", -1)),
406
+ p("span", Ye, w(r.value.verified) + " / " + w(r.value.total), 1)
1565
407
  ]),
1566
- I(f(Ae), {
1567
- value: s.value.verified,
1568
- max: s.value.total,
408
+ N(f(fe), {
409
+ value: r.value.verified,
410
+ max: r.value.total,
1569
411
  size: "md",
1570
- variant: s.value.percent === 100 ? "success" : "info",
1571
- striped: s.value.percent < 100,
1572
- "animate-stripes": s.value.percent < 100,
1573
- glow: s.value.percent === 100,
412
+ variant: r.value.percent === 100 ? "success" : "info",
413
+ striped: r.value.percent < 100,
414
+ "animate-stripes": r.value.percent < 100,
415
+ glow: r.value.percent === 100,
1574
416
  gradient: ""
1575
417
  }, null, 8, ["value", "max", "variant", "striped", "animate-stripes", "glow"]),
1576
- r.value > 0 ? (l(), c("div", vl, v(r.value) + " extraction attempt" + v(r.value === 1 ? "" : "s") + " recorded ", 1)) : h("", !0)
418
+ i.value > 0 ? (u(), g("div", Ge, w(i.value) + " extraction attempt" + w(i.value === 1 ? "" : "s") + " recorded ", 1)) : _("", !0)
1577
419
  ]),
1578
- s.value.needsReview > 0 ? (l(), c("button", {
420
+ r.value.needsReview > 0 ? (u(), g("button", {
1579
421
  key: 0,
1580
422
  type: "button",
1581
- class: A(["tv-next-flagged flex items-center justify-between rounded-lg bg-amber-50 px-3 py-2 text-left text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-600/20 transition hover:bg-amber-100", f(ee)]),
1582
- onClick: ye(u, ["stop"])
423
+ class: y(["tv-next-flagged flex items-center justify-between rounded-lg bg-amber-50 px-3 py-2 text-left text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-600/20 transition hover:bg-amber-100", f($)]),
424
+ onClick: G(A, ["stop"])
1583
425
  }, [
1584
- i("span", null, v(s.value.needsReview) + " need" + v(s.value.needsReview === 1 ? "s" : "") + " review", 1),
1585
- m[4] || (m[4] = i("span", { "aria-hidden": "true" }, "→", -1))
1586
- ], 2)) : h("", !0)
1587
- ], 64)) : h("", !0)
1588
- ], 2)) : h("", !0),
1589
- I(f(ot), {
1590
- class: A(f(ee))
426
+ p("span", null, w(r.value.needsReview) + " need" + w(r.value.needsReview === 1 ? "s" : "") + " review", 1),
427
+ o[4] || (o[4] = p("span", { "aria-hidden": "true" }, "→", -1))
428
+ ], 2)) : _("", !0)
429
+ ], 64)) : _("", !0)
430
+ ], 2)) : _("", !0),
431
+ N(f(ve), {
432
+ class: y(f($))
1591
433
  }, null, 8, ["class"])
1592
434
  ], 64));
1593
435
  }
1594
436
  });
1595
437
  export {
1596
- ee as CHROME_CLASS,
1597
- Te as CitationEvidence,
1598
- De as CitationPage,
1599
- ga as CitationPageList,
1600
- kt as ConfidenceIcon,
1601
- ze as ENABLED_STORAGE_KEY,
1602
- je as RESOLUTION_PRIORITY,
1603
- vt as STATUS_COLORS,
1604
- K as STATUS_LABELS,
1605
- yl as VerificationChrome,
1606
- nl as VerificationModal,
1607
- xl as VerifiedField,
1608
- _e as bucketConfidence,
1609
- pt as candidatesDisagree,
1610
- me as citationEvidence,
1611
- Me as citationSummary,
1612
- yt as computeProgress,
1613
- $t as fetchDataPointDetail,
1614
- gt as hasDiscrepancy,
1615
- pl as initVerification,
1616
- ml as reasoningOf,
1617
- ft as resolveCandidates,
1618
- Re as resolveDataPoint,
1619
- we as useVerification,
1620
- Ue as walkDataPoints
438
+ $ as CHROME_CLASS,
439
+ Ne as ConfidenceIcon,
440
+ $e as DATA_POINT_ACTIVATED,
441
+ q as ENABLED_STORAGE_KEY,
442
+ X as RESOLUTION_PRIORITY,
443
+ me as STATUS_COLORS,
444
+ V as STATUS_LABELS,
445
+ Ce as TEMPLATE_MESSAGE_SOURCE,
446
+ Te as TEMPLATE_PROTOCOL_VERSION,
447
+ Qe as VerificationChrome,
448
+ Je as VerifiedField,
449
+ W as bucketConfidence,
450
+ _e as candidatesDisagree,
451
+ Oe as computeProgress,
452
+ Ae as embedderOrigin,
453
+ xe as hasDiscrepancy,
454
+ qe as initVerification,
455
+ Ee as notifyDataPointActivated,
456
+ ye as resolveCandidates,
457
+ we as resolveDataPoint,
458
+ Q as useVerification,
459
+ Z as walkDataPoints
1621
460
  };