@thehammer/template-verification 0.2.21 → 0.2.23

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,9 +1,9 @@
1
- import { ref as M, watch as z, defineComponent as Y, computed as i, openBlock as u, createElementBlock as v, normalizeClass as w, createElementVNode as p, toDisplayString as k, createCommentVNode as S, createBlock as B, unref as d, Fragment as F, renderSlot as oe, createVNode as L, withModifiers as W, withDirectives as se, isRef as ue, vModelCheckbox as ce } from "vue";
2
- import { DanxSkeleton as de, useToast as fe, DanxIcon as ve, gearIcon as pe, DanxBadge as ge, DanxProgressBar as me, DanxToastContainer as be } from "@thehammer/danx-ui";
3
- import { CodeViewer as he } from "@thehammer/danx-ui/components/code-viewer";
4
- const R = "tv-chrome", we = "tv-editable", Z = "template-verification:enabled";
1
+ import { ref as F, watch as Y, defineComponent as M, openBlock as i, createElementBlock as u, normalizeClass as g, createCommentVNode as k, computed as o, createElementVNode as m, createVNode as T, createBlock as B, unref as f, Fragment as j, renderSlot as oe, toDisplayString as E, withModifiers as W, withDirectives as ie, isRef as se, vModelCheckbox as ue } from "vue";
2
+ import { DanxSkeleton as ce, useToast as de, DanxIcon as fe, gearIcon as ve, DanxBadge as pe, DanxProgressBar as me, DanxToastContainer as he } from "@thehammer/danx-ui";
3
+ import { CodeViewer as be } from "@thehammer/danx-ui/components/code-viewer";
4
+ const R = "tv-chrome", ge = "tv-editable", Z = "template-verification:enabled";
5
5
  let N = null;
6
- function ye(e) {
6
+ function we(e) {
7
7
  var t;
8
8
  try {
9
9
  return ((t = globalThis.localStorage) == null ? void 0 : t.getItem(e)) ?? null;
@@ -11,22 +11,22 @@ function ye(e) {
11
11
  return null;
12
12
  }
13
13
  }
14
- function xe(e, t) {
14
+ function ye(e, t) {
15
15
  var n;
16
16
  try {
17
17
  (n = globalThis.localStorage) == null || n.setItem(e, t);
18
18
  } catch {
19
19
  }
20
20
  }
21
- function _e(e) {
22
- const t = ye(Z);
21
+ function xe(e) {
22
+ const t = we(Z);
23
23
  return t === null ? e : t === "true";
24
24
  }
25
25
  function ee(e) {
26
- const t = M(_e((e == null ? void 0 : e.defaultEnabled) ?? !1));
27
- return z(
26
+ const t = F(xe((e == null ? void 0 : e.defaultEnabled) ?? !1));
27
+ return Y(
28
28
  t,
29
- (n) => xe(Z, n ? "true" : "false")
29
+ (n) => ye(Z, n ? "true" : "false")
30
30
  ), {
31
31
  enabled: t,
32
32
  data: (e == null ? void 0 : e.data) ?? {},
@@ -34,14 +34,14 @@ function ee(e) {
34
34
  loading: (e == null ? void 0 : e.loading) ?? !1
35
35
  };
36
36
  }
37
- function ke() {
37
+ function _e() {
38
38
  return N || (N = ee()), N;
39
39
  }
40
- function rt(e) {
40
+ function ct(e) {
41
41
  N = ee(e);
42
42
  }
43
43
  function te() {
44
- const e = ke();
44
+ const e = _e();
45
45
  return {
46
46
  enabled: e.enabled,
47
47
  data: e.data,
@@ -49,77 +49,82 @@ function te() {
49
49
  loading: e.loading
50
50
  };
51
51
  }
52
- function ne(e) {
53
- return typeof e != "number" || Number.isNaN(e) ? "unverifiable" : e <= 2 ? "low" : e === 3 ? "medium" : "high";
52
+ function ke(e, t) {
53
+ if (!Number.isFinite(e) || !Number.isFinite(t) || t <= 0 || e <= 0) return null;
54
+ const n = Math.round(Math.min(e, t) / t * 5);
55
+ return Math.max(1, Math.min(5, n));
54
56
  }
55
57
  const Se = {
56
- high: "bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20",
57
- medium: "bg-yellow-50 text-yellow-700 ring-1 ring-inset ring-yellow-600/20",
58
- low: "bg-red-50 text-red-700 ring-1 ring-inset ring-red-600/20",
59
- unverifiable: "bg-gray-50 text-gray-500 ring-1 ring-inset ring-gray-400/20",
60
- // Same red family as 'low' (color-family-per-status is load-bearing, see docblock
61
- // above) but a visibly darker/more saturated shade so the two stay distinguishable.
62
- failed: "bg-red-100 text-red-800 ring-1 ring-inset ring-red-700/30"
63
- }, P = {
64
- high: "High",
65
- medium: "Medium",
66
- low: "Low",
67
- unverifiable: "Unverifiable",
68
- failed: "Failed"
69
- }, re = ["override", "extracted", "claim"];
70
- function Ie(e) {
71
- return e ? e.resolved && e.resolved.source && e.resolved.source !== "none" ? e.resolved : Ce(e.candidates) : { value: null, source: "none" };
58
+ 1: "Just a guess",
59
+ 2: "Somewhat unsure",
60
+ 3: "Fairly confident",
61
+ 4: "Confident",
62
+ 5: "Highly confident"
63
+ }, Ie = 5;
64
+ function Ee(e) {
65
+ return typeof e != "number" || !Number.isFinite(e) ? null : ke(e, Ie);
66
+ }
67
+ function Ce(e, t) {
68
+ return t ? "failed" : Ee(e) ?? "unrated";
69
+ }
70
+ const $e = "Not rated", Ae = "Failed";
71
+ function z(e) {
72
+ return e === "failed" ? Ae : e === "unrated" ? $e : Se[e];
73
+ }
74
+ const ne = ["override", "extracted", "claim"];
75
+ function Re(e) {
76
+ return e ? e.resolved && e.resolved.source && e.resolved.source !== "none" ? e.resolved : Te(e.candidates) : { value: null, source: "none" };
72
77
  }
73
- function Ce(e) {
78
+ function Te(e) {
74
79
  if (e)
75
- for (const t of re) {
80
+ for (const t of ne) {
76
81
  const n = e[t];
77
82
  if (n != null)
78
83
  return { value: n.value, source: t };
79
84
  }
80
85
  return { value: null, source: "none" };
81
86
  }
82
- function $e(e) {
83
- return e ? typeof e.discrepancy == "boolean" ? e.discrepancy : Ae(e.candidates) : !1;
87
+ function De(e) {
88
+ return e ? typeof e.discrepancy == "boolean" ? e.discrepancy : Le(e.candidates) : !1;
84
89
  }
85
- function Ae(e) {
90
+ function Le(e) {
86
91
  if (!e) return !1;
87
- const t = re.map((n) => e[n]).filter((n) => n != null).map((n) => Ee(n.value));
92
+ const t = ne.map((n) => e[n]).filter((n) => n != null).map((n) => Oe(n.value));
88
93
  return t.length < 2 ? !1 : new Set(t).size > 1;
89
94
  }
90
- function Ee(e) {
95
+ function Oe(e) {
91
96
  return JSON.stringify(e ?? null);
92
97
  }
93
- function Te(e) {
98
+ function Ve(e) {
94
99
  return !!(e != null && e.source_discrepancy);
95
100
  }
96
- function Re(e) {
101
+ function Ne(e) {
97
102
  return !!(e != null && e.correction);
98
103
  }
99
- const Oe = "danxbot-template", Ve = 1, De = "data-point-activated";
100
- function Le() {
104
+ const Fe = "danxbot-template", Me = 1, Pe = "data-point-activated";
105
+ function Be() {
101
106
  if (typeof window > "u") return null;
102
107
  const e = window.location.ancestorOrigins, t = e && e.length > 0 ? e[0] : null;
103
108
  if (t && t !== "null") return t;
104
109
  const n = typeof document > "u" ? "" : document.referrer;
105
110
  if (!n) return null;
106
111
  try {
107
- const f = new URL(n).origin;
108
- return f === "null" ? null : f;
112
+ const d = new URL(n).origin;
113
+ return d === "null" ? null : d;
109
114
  } catch {
110
115
  return null;
111
116
  }
112
117
  }
113
- function Ne(e) {
118
+ function je(e) {
114
119
  if (typeof window > "u") return !1;
115
120
  const t = window.parent;
116
121
  if (!t || t === window) return !1;
117
- const n = Le();
122
+ const n = Be();
118
123
  if (!n) return !1;
119
- const f = {
120
- source: Oe,
121
- version: Ve,
122
- type: De,
124
+ const d = {
125
+ source: Fe,
126
+ version: Me,
127
+ type: Pe,
123
128
  anchor: {
124
129
  object_ids: [...e.anchor.object_ids],
125
130
  field: e.anchor.field,
@@ -129,199 +134,216 @@ function Ne(e) {
129
134
  label: e.label ?? null,
130
135
  value: e.value ?? null
131
136
  };
132
- return t.postMessage(f, n), !0;
137
+ return t.postMessage(d, n), !0;
133
138
  }
134
- const Pe = /* @__PURE__ */ new Set(["name", "type"]);
135
- function ae(e, t = "") {
139
+ const ze = /* @__PURE__ */ new Set(["name", "type"]);
140
+ function re(e, t = "") {
136
141
  const n = [];
137
142
  return U(e, t, n), n;
138
143
  }
139
144
  function U(e, t, n) {
140
145
  if (Array.isArray(e)) {
141
- e.forEach((r, c) => U(r, `${t}[${c}]`, n));
146
+ e.forEach((r, v) => U(r, `${t}[${v}]`, n));
142
147
  return;
143
148
  }
144
149
  if (!X(e)) return;
145
- const m = e.__meta ?? {};
146
- for (const [r, c] of Object.entries(e)) {
150
+ const h = e.__meta ?? {};
151
+ for (const [r, v] of Object.entries(e)) {
147
152
  if (r === "__meta") continue;
148
- const h = t ? `${t}.${r}` : r;
149
- if (Array.isArray(c) || X(c)) {
150
- U(c, h, n);
153
+ const w = t ? `${t}.${r}` : r;
154
+ if (Array.isArray(v) || X(v)) {
155
+ U(v, w, n);
151
156
  continue;
152
157
  }
153
- const g = m[r];
154
- !g && Pe.has(r) || n.push({
155
- path: h,
158
+ const p = h[r];
159
+ !p && ze.has(r) || n.push({
160
+ path: w,
156
161
  label: r,
157
- meta: g ?? null,
158
- value: c,
159
- unanchored: !g
162
+ meta: p ?? null,
163
+ value: v,
164
+ unanchored: !p
160
165
  });
161
166
  }
162
167
  }
163
168
  function X(e) {
164
169
  return typeof e == "object" && e !== null && !Array.isArray(e);
165
170
  }
166
- function le(e) {
171
+ function ae(e) {
167
172
  var n;
168
173
  if (e.candidates.override) return !1;
169
174
  const t = (n = e.candidates.extracted) == null ? void 0 : n.confidence;
170
175
  return e.discrepancy || t == null || t <= 2;
171
176
  }
172
- function Me(e) {
173
- const t = ae(e).filter(
177
+ function Ue(e) {
178
+ const t = re(e).filter(
174
179
  (r) => r.meta !== null
175
180
  ), n = t.length;
176
- let f = 0, m = 0;
181
+ let d = 0, h = 0;
177
182
  for (const r of t) {
178
183
  if (r.meta.candidates.override) {
179
- f++;
184
+ d++;
180
185
  continue;
181
186
  }
182
- le(r.meta) && m++;
187
+ ae(r.meta) && h++;
183
188
  }
184
189
  return {
185
190
  total: n,
186
- verified: f,
187
- needsReview: m,
188
- percent: n === 0 ? 100 : Math.round(f / n * 100)
191
+ verified: d,
192
+ needsReview: h,
193
+ percent: n === 0 ? 100 : Math.round(d / n * 100)
189
194
  };
190
195
  }
191
- const je = ["data-status", "title"], Be = {
192
- class: "tv-confidence-glyph",
193
- "aria-hidden": "true"
194
- }, Fe = {
195
- key: 0,
196
- class: "tv-confidence-label"
197
- }, Ue = /* @__PURE__ */ Y({
196
+ const Ye = ["data-level"], qe = /* @__PURE__ */ M({
197
+ __name: "ConfidenceBar",
198
+ props: {
199
+ level: {}
200
+ },
201
+ setup(e) {
202
+ const t = e, n = {
203
+ 1: "w-1/5 bg-(--confidence-1)",
204
+ 2: "w-2/5 bg-(--confidence-2)",
205
+ 3: "w-3/5 bg-(--confidence-3)",
206
+ 4: "w-4/5 bg-(--confidence-4)",
207
+ 5: "w-full bg-(--confidence-5)"
208
+ };
209
+ return (d, h) => (i(), u("span", {
210
+ class: g(["tv-confidence-bar flex h-[3px] w-[19px] shrink-0 overflow-hidden rounded-full", t.level === null ? "border border-dotted border-(--confidence-none)" : ""]),
211
+ "data-theme": "light",
212
+ "data-level": t.level ?? "none",
213
+ "aria-hidden": "true"
214
+ }, [
215
+ t.level !== null ? (i(), u("span", {
216
+ key: 0,
217
+ class: g(["tv-confidence-fill h-full rounded-full", n[t.level]])
218
+ }, null, 2)) : k("", !0)
219
+ ], 10, Ye));
220
+ }
221
+ }), Ge = ["title"], He = ["data-status", "title"], Je = /* @__PURE__ */ M({
198
222
  __name: "ConfidenceIcon",
199
223
  props: {
200
- confidence: {},
201
- status: {},
202
- showLabel: { type: Boolean }
224
+ state: {}
203
225
  },
204
226
  setup(e) {
205
- const t = e, n = i(
206
- () => t.status ?? ne(t.confidence)
207
- ), f = {
208
- high: "",
209
- // check
210
- medium: "",
211
- // warning triangle
212
- low: "✕",
213
- // x
214
- unverifiable: "?",
215
- failed: ""
216
- // circled x — distinct from low's plain x
217
- }, m = i(() => f[n.value]), r = i(() => Se[n.value]), c = i(() => P[n.value]);
218
- return (h, g) => (u(), v("span", {
219
- class: w(["tv-confidence-icon inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-semibold leading-none", r.value]),
220
- "data-status": n.value,
221
- title: c.value
227
+ const t = e, n = o(() => z(t.state)), d = o(
228
+ () => t.state === "failed" || t.state === "unrated" ? null : t.state
229
+ );
230
+ return (h, r) => t.state === "failed" ? (i(), u("span", {
231
+ key: 0,
232
+ class: "tv-confidence-icon inline-flex items-center rounded-full bg-red-100 px-2 py-0.5 text-[11px] font-semibold leading-none text-red-800 ring-1 ring-inset ring-red-700/30",
233
+ "data-status": "failed",
234
+ title: n.value
235
+ }, [...r[0] || (r[0] = [
236
+ m("span", { "aria-hidden": "true" }, "⊗", -1)
237
+ ])], 8, Ge)) : (i(), u("span", {
238
+ key: 1,
239
+ class: "tv-confidence-icon inline-flex items-center rounded-full bg-white px-1.5 py-1.5 ring-1 ring-inset ring-gray-300",
240
+ "data-status": String(t.state),
241
+ title: n.value
222
242
  }, [
223
- p("span", Be, k(m.value), 1),
224
- e.showLabel ? (u(), v("span", Fe, k(c.value), 1)) : S("", !0)
225
- ], 10, je));
243
+ T(qe, { level: d.value }, null, 8, ["level"])
244
+ ], 8, He));
226
245
  }
227
- }), ze = {
246
+ }), Ke = {
247
+ key: 0,
248
+ class: "tv-field-placeholder"
249
+ }, Qe = {
228
250
  key: 0,
229
251
  class: "tv-mark-anchor"
230
- }, Ye = ["aria-label", "title"], Ge = {
252
+ }, We = ["aria-label", "title"], Xe = {
231
253
  key: 1,
232
254
  class: "tv-verified-chip tv-audit-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",
233
255
  "data-status": "audited"
234
- }, He = {
256
+ }, Ze = {
235
257
  key: 2,
236
258
  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",
237
259
  "data-status": "verified"
238
- }, qe = {
260
+ }, et = {
239
261
  key: 3,
240
262
  class: "tv-verified-chip tv-verified-chip-empty inline-flex items-center gap-1 rounded-full border-2 border-dashed border-green-600 bg-transparent px-2 py-0.5 text-[11px] font-semibold leading-none text-green-600",
241
263
  "data-status": "verified-empty"
242
- }, Ke = {
264
+ }, tt = {
243
265
  key: 5,
244
266
  class: "tv-correction-indicator ml-0.5 text-blue-500",
245
267
  "aria-hidden": !0
246
- }, at = /* @__PURE__ */ Y({
268
+ }, dt = /* @__PURE__ */ M({
247
269
  __name: "VerifiedField",
248
270
  props: {
249
271
  source: {},
250
272
  field: {},
251
273
  original: {},
252
- format: { type: Function }
274
+ format: { type: Function },
275
+ placeholder: {}
253
276
  },
254
277
  setup(e) {
255
- const t = e, n = te(), f = i(() => n.enabled.value), m = i(() => n.loading), r = i(() => {
278
+ const t = e, n = te(), d = o(() => n.enabled.value), h = o(() => n.loading), r = o(() => {
256
279
  var a;
257
280
  return t.source && t.field ? ((a = t.source.__meta) == null ? void 0 : a[t.field]) ?? null : null;
258
- }), c = i(() => Ie(r.value)), h = i(() => {
281
+ }), v = o(() => Re(r.value)), w = o(() => {
259
282
  if (t.original !== void 0 && t.original !== null)
260
283
  return t.original;
261
- if (r.value && c.value.value !== null && c.value.value !== void 0)
262
- return c.value.value;
284
+ if (r.value && v.value.value !== null && v.value.value !== void 0)
285
+ return v.value.value;
263
286
  if (t.source && t.field) return t.source[t.field];
264
- }), g = i(() => {
265
- const a = h.value;
287
+ }), p = o(() => {
288
+ const a = w.value;
266
289
  return a == null ? "" : typeof t.format == "function" ? t.format(a) : String(a);
267
- }), O = i(() => {
268
- var l, o;
269
- const a = (o = (l = r.value) == null ? void 0 : l.candidates) == null ? void 0 : o.extracted;
270
- return (a == null ? void 0 : a.state) === "failed" ? "failed" : ne(a == null ? void 0 : a.confidence);
271
- }), b = i(() => $e(r.value)), s = i(() => Te(r.value)), y = i(() => !b.value && Re(r.value)), x = i(() => {
290
+ }), D = o(() => {
291
+ var l, c;
292
+ const a = (c = (l = r.value) == null ? void 0 : l.candidates) == null ? void 0 : c.extracted;
293
+ return Ce(a == null ? void 0 : a.confidence, (a == null ? void 0 : a.state) === "failed");
294
+ }), b = o(() => De(r.value)), s = o(() => Ve(r.value)), y = o(() => !b.value && Ne(r.value)), x = o(() => {
272
295
  var a, l;
273
296
  return !!((l = (a = r.value) == null ? void 0 : a.candidates) != null && l.override);
274
- }), V = i(() => {
275
- var a, l, o;
276
- return ((o = (l = (a = r.value) == null ? void 0 : a.candidates) == null ? void 0 : l.extracted) == null ? void 0 : o.source) ?? null;
277
- }), $ = i(() => !x.value && V.value === "audit"), I = i(() => {
278
- var a, l, o;
279
- return x.value ? ((o = (l = (a = r.value) == null ? void 0 : a.candidates) == null ? void 0 : l.override) == null ? void 0 : o.value) === null ? "confirmed-empty" : "confirmed" : "unverified";
280
- }), A = i(() => f.value), D = i(() => {
297
+ }), L = o(() => {
298
+ var a, l, c;
299
+ return ((c = (l = (a = r.value) == null ? void 0 : a.candidates) == null ? void 0 : l.extracted) == null ? void 0 : c.source) ?? null;
300
+ }), C = o(() => !x.value && L.value === "audit"), S = o(() => {
301
+ var a, l, c;
302
+ return x.value ? ((c = (l = (a = r.value) == null ? void 0 : a.candidates) == null ? void 0 : l.override) == null ? void 0 : c.value) === null ? "confirmed-empty" : "confirmed" : "unverified";
303
+ }), $ = o(() => d.value), O = o(() => {
281
304
  const a = r.value;
282
- return A.value && !!a && le(a);
283
- }), T = i(() => {
305
+ return $.value && !!a && ae(a);
306
+ }), A = o(() => {
284
307
  var a;
285
- return A.value && !!((a = r.value) != null && a.anchor);
286
- }), G = i(() => {
287
- var K, J, Q;
288
- const a = t.field ?? "This value", l = T.value ? " — open in the review panel" : " — no place to record a correction";
289
- if (I.value === "confirmed-empty")
308
+ return $.value && !!((a = r.value) != null && a.anchor);
309
+ }), q = o(() => {
310
+ var J, K, Q;
311
+ const a = t.field ?? "This value", l = A.value ? " — open in the review panel" : " — no place to record a correction";
312
+ if (S.value === "confirmed-empty")
290
313
  return `${a}: a person confirmed this field is genuinely blank${l}`;
291
314
  if (x.value) return `${a}: verified by a person${l}`;
292
- const o = (J = (K = r.value) == null ? void 0 : K.candidates) == null ? void 0 : J.extracted, E = O.value, _ = [];
293
- let C;
294
- E === "failed" ? C = P.failed : (o == null ? void 0 : o.confidence) != null ? C = `${P[E]} (${o.confidence}/5)` : C = P[E], _.push($.value ? `Verified by audit ${C}` : C);
295
- const j = (o == null ? void 0 : o.sources_count) ?? ((Q = o == null ? void 0 : o.sources) == null ? void 0 : Q.length) ?? 0;
296
- return j > 0 && _.push(`${j} cited ${j === 1 ? "page" : "pages"}`), b.value ? _.push(s.value ? "source document conflict" : "sources disagree") : y.value && _.push("value corrected"), `${a}: ${_.join(", ")}${l}`;
315
+ const c = (K = (J = r.value) == null ? void 0 : J.candidates) == null ? void 0 : K.extracted, I = D.value, _ = [], V = typeof I == "number" ? `${z(I)} (${I}/5)` : z(I);
316
+ _.push(C.value ? `Verified by audit — ${V}` : V);
317
+ const P = (c == null ? void 0 : c.sources_count) ?? ((Q = c == null ? void 0 : c.sources) == null ? void 0 : Q.length) ?? 0;
318
+ return P > 0 && _.push(`${P} cited ${P === 1 ? "page" : "pages"}`), b.value ? _.push(s.value ? "source document conflict" : "sources disagree") : y.value && _.push("value corrected"), `${a}: ${_.join(", ")}${l}`;
297
319
  });
298
- function H() {
320
+ function G() {
299
321
  var l;
300
322
  const a = (l = r.value) == null ? void 0 : l.anchor;
301
- a && Ne({
323
+ a && je({
302
324
  anchor: a,
303
325
  workflowInputId: n.workflowInputId,
304
326
  label: t.field ?? null,
305
- value: g.value
327
+ value: p.value
306
328
  });
307
329
  }
308
- function ie() {
330
+ function le() {
309
331
  var l;
310
- if (!T.value) return;
332
+ if (!A.value) return;
311
333
  const a = typeof window > "u" ? null : (l = window.getSelection) == null ? void 0 : l.call(window);
312
- a && !a.isCollapsed || H();
334
+ a && !a.isCollapsed || G();
313
335
  }
314
- const q = M(null);
315
- return z(
316
- q,
317
- (a, l, o) => {
336
+ const H = F(null);
337
+ return Y(
338
+ H,
339
+ (a, l, c) => {
318
340
  if (!a || typeof MutationObserver > "u") return;
319
- const E = () => {
320
- a.querySelectorAll(".dx-language-badge-container").forEach((C) => C.remove());
341
+ const I = () => {
342
+ a.querySelectorAll(".dx-language-badge-container").forEach((V) => V.remove());
321
343
  };
322
- E();
323
- const _ = new MutationObserver(E);
324
- _.observe(a, { childList: !0, subtree: !0 }), o(() => _.disconnect());
344
+ I();
345
+ const _ = new MutationObserver(I);
346
+ _.observe(a, { childList: !0, subtree: !0 }), c(() => _.disconnect());
325
347
  },
326
348
  // `flush: "sync"` — a template ref is populated by Vue's own patch process,
327
349
  // and the DEFAULT ("pre") flush timing runs a watcher reacting to that
@@ -331,29 +353,30 @@ const je = ["data-status", "title"], Be = {
331
353
  // conceivably a synchronous export/print path) must never observe the
332
354
  // badge even for one tick, so this cannot wait for the async scheduler.
333
355
  { immediate: !0, flush: "sync" }
334
- ), (a, l) => (u(), v("span", {
335
- class: w(["tv-field", D.value ? "tv-needs-review" : ""])
356
+ ), (a, l) => (i(), u("span", {
357
+ class: g(["tv-field", O.value ? "tv-needs-review" : ""])
336
358
  }, [
337
- m.value ? (u(), B(d(de), {
359
+ h.value ? (i(), B(f(ce), {
338
360
  key: 0,
339
361
  shape: "rounded",
340
362
  class: "tv-field-skeleton inline-block h-[1em] w-16 align-middle"
341
- })) : (u(), v(F, { key: 1 }, [
342
- p("span", {
343
- class: w(["tv-field-value", T.value ? d(we) : ""]),
344
- onClick: ie
363
+ })) : (i(), u(j, { key: 1 }, [
364
+ m("span", {
365
+ class: g(["tv-field-value", A.value ? f(ge) : ""]),
366
+ onClick: le
345
367
  }, [
346
368
  oe(a.$slots, "default", {
347
- value: h.value,
348
- formatted: g.value
369
+ value: w.value,
370
+ formatted: p.value
349
371
  }, () => [
350
- p("span", {
372
+ !p.value && e.placeholder ? (i(), u("em", Ke, E(e.placeholder), 1)) : (i(), u("span", {
373
+ key: 1,
351
374
  ref_key: "markdownFallbackRef",
352
- ref: q,
375
+ ref: H,
353
376
  class: "tv-markdown-fallback-wrap"
354
377
  }, [
355
- L(d(he), {
356
- "model-value": g.value,
378
+ T(f(be), {
379
+ "model-value": p.value,
357
380
  format: "markdown",
358
381
  theme: "light",
359
382
  "can-edit": !1,
@@ -361,59 +384,59 @@ const je = ["data-status", "title"], Be = {
361
384
  "hide-footer": "",
362
385
  class: "tv-markdown-fallback"
363
386
  }, null, 8, ["model-value"])
364
- ], 512)
387
+ ], 512))
365
388
  ])
366
389
  ], 2),
367
- A.value ? (u(), v("span", ze, [
368
- p("button", {
390
+ $.value ? (i(), u("span", Qe, [
391
+ m("button", {
369
392
  type: "button",
370
- class: w(["tv-overlay", [d(R), T.value ? "cursor-pointer" : "cursor-default"]]),
371
- "aria-label": G.value,
372
- title: G.value,
373
- onClick: l[0] || (l[0] = (o) => T.value ? H() : void 0)
393
+ class: g(["tv-overlay", [f(R), A.value ? "cursor-pointer" : "cursor-default"]]),
394
+ "aria-label": q.value,
395
+ title: q.value,
396
+ onClick: l[0] || (l[0] = (c) => A.value ? G() : void 0)
374
397
  }, [
375
- I.value === "unverified" && !$.value ? (u(), B(Ue, {
398
+ S.value === "unverified" && !C.value ? (i(), B(Je, {
376
399
  key: 0,
377
- status: O.value
378
- }, null, 8, ["status"])) : I.value === "unverified" && $.value ? (u(), v("span", Ge, "A")) : I.value === "confirmed" ? (u(), v("span", He, "✔")) : (u(), v("span", qe, "✔")),
379
- b.value && !x.value ? (u(), v("span", {
400
+ state: D.value
401
+ }, null, 8, ["state"])) : S.value === "unverified" && C.value ? (i(), u("span", Xe, "A")) : S.value === "confirmed" ? (i(), u("span", Ze, "✔")) : (i(), u("span", et, "✔")),
402
+ b.value && !x.value ? (i(), u("span", {
380
403
  key: 4,
381
- class: w(["tv-discrepancy-indicator ml-0.5 text-amber-500", s.value ? "tv-source-discrepancy-indicator" : ""]),
404
+ class: g(["tv-discrepancy-indicator ml-0.5 text-amber-500", s.value ? "tv-source-discrepancy-indicator" : ""]),
382
405
  "aria-hidden": !0
383
- }, "⚠", 2)) : y.value && !x.value ? (u(), v("span", Ke, "✎")) : S("", !0)
384
- ], 10, Ye)
385
- ])) : S("", !0)
406
+ }, "⚠", 2)) : y.value && !x.value ? (i(), u("span", tt, "✎")) : k("", !0)
407
+ ], 10, We)
408
+ ])) : k("", !0)
386
409
  ], 64))
387
410
  ], 2));
388
411
  }
389
- }), Je = { class: "tv-enable-toggle flex items-center justify-between text-sm font-medium text-gray-700" }, Qe = { class: "tv-progress-block" }, We = { class: "mb-1 flex items-baseline justify-between" }, Xe = { class: "tv-progress-count text-xs font-semibold text-gray-600" }, Ze = {
412
+ }), nt = { class: "tv-enable-toggle flex items-center justify-between text-sm font-medium text-gray-700" }, rt = { class: "tv-progress-block" }, at = { class: "mb-1 flex items-baseline justify-between" }, lt = { class: "tv-progress-count text-xs font-semibold text-gray-600" }, ot = {
390
413
  key: 0,
391
414
  class: "tv-attempts-recorded mt-1 text-[11px] text-gray-400"
392
- }, lt = /* @__PURE__ */ Y({
415
+ }, ft = /* @__PURE__ */ M({
393
416
  __name: "VerificationChrome",
394
417
  setup(e) {
395
- const t = te(), { enabled: n } = t, f = fe(), m = M(!1), r = i(() => Me(t.data)), c = i(
396
- () => ae(t.data).reduce(
418
+ const t = te(), { enabled: n } = t, d = de(), h = F(!1), r = o(() => Ue(t.data)), v = o(
419
+ () => re(t.data).reduce(
397
420
  (b, s) => {
398
- var y, x, V, $, I, A, D;
399
- return b + (((V = (x = (y = s.meta) == null ? void 0 : y.candidates) == null ? void 0 : x.extracted) == null ? void 0 : V.history_count) ?? ((D = (A = (I = ($ = s.meta) == null ? void 0 : $.candidates) == null ? void 0 : I.extracted) == null ? void 0 : A.history) == null ? void 0 : D.length) ?? 0);
421
+ var y, x, L, C, S, $, O;
422
+ return b + (((L = (x = (y = s.meta) == null ? void 0 : y.candidates) == null ? void 0 : x.extracted) == null ? void 0 : L.history_count) ?? ((O = ($ = (S = (C = s.meta) == null ? void 0 : C.candidates) == null ? void 0 : S.extracted) == null ? void 0 : $.history) == null ? void 0 : O.length) ?? 0);
400
423
  },
401
424
  0
402
425
  )
403
- ), h = M(!1);
404
- z(
426
+ ), w = F(!1);
427
+ Y(
405
428
  () => r.value.percent,
406
429
  (b) => {
407
- b === 100 && r.value.total > 0 && !h.value && (h.value = !0, f.success("All data points verified 🎯"));
430
+ b === 100 && r.value.total > 0 && !w.value && (w.value = !0, d.success("All data points verified 🎯"));
408
431
  }
409
432
  );
410
- let g = 0;
411
- function O() {
433
+ let p = 0;
434
+ function D() {
412
435
  const b = document.querySelectorAll(".tv-needs-review");
413
436
  if (!b.length) return;
414
- g = g % b.length;
415
- const s = b[g];
416
- g++, s.scrollIntoView({ behavior: "smooth", block: "center" }), s.animate(
437
+ p = p % b.length;
438
+ const s = b[p];
439
+ p++, s.scrollIntoView({ behavior: "smooth", block: "center" }), s.animate(
417
440
  [
418
441
  { boxShadow: "0 0 0 0 rgba(245, 158, 11, 0.8)" },
419
442
  { boxShadow: "0 0 0 12px rgba(245, 158, 11, 0)" }
@@ -421,45 +444,45 @@ const je = ["data-status", "title"], Be = {
421
444
  { duration: 900, iterations: 2 }
422
445
  );
423
446
  }
424
- return (b, s) => (u(), v(F, null, [
425
- p("button", {
447
+ return (b, s) => (i(), u(j, null, [
448
+ m("button", {
426
449
  type: "button",
427
- class: w(["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", d(R)]),
450
+ class: g(["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(R)]),
428
451
  title: "Verification",
429
- onClick: s[0] || (s[0] = W((y) => m.value = !m.value, ["stop"]))
452
+ onClick: s[0] || (s[0] = W((y) => h.value = !h.value, ["stop"]))
430
453
  }, [
431
- L(d(ve), {
432
- icon: d(pe),
454
+ T(f(fe), {
455
+ icon: f(ve),
433
456
  class: "h-5 w-5"
434
457
  }, null, 8, ["icon"]),
435
- d(n) && r.value.needsReview > 0 ? (u(), B(d(ge), {
458
+ f(n) && r.value.needsReview > 0 ? (i(), B(f(pe), {
436
459
  key: 0,
437
460
  value: r.value.needsReview,
438
461
  variant: "warning",
439
462
  class: "tv-needs-review-badge absolute -right-1 -top-1"
440
- }, null, 8, ["value"])) : S("", !0)
463
+ }, null, 8, ["value"])) : k("", !0)
441
464
  ], 2),
442
- m.value ? (u(), v("div", {
465
+ h.value ? (i(), u("div", {
443
466
  key: 0,
444
- class: w(["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", d(R)])
467
+ class: g(["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(R)])
445
468
  }, [
446
- p("label", Je, [
447
- s[2] || (s[2] = p("span", null, "Verification overlay", -1)),
448
- se(p("input", {
449
- "onUpdate:modelValue": s[1] || (s[1] = (y) => ue(n) ? n.value = y : null),
469
+ m("label", nt, [
470
+ s[2] || (s[2] = m("span", null, "Verification overlay", -1)),
471
+ ie(m("input", {
472
+ "onUpdate:modelValue": s[1] || (s[1] = (y) => se(n) ? n.value = y : null),
450
473
  type: "checkbox",
451
474
  class: "tv-enable-checkbox h-4 w-4 accent-gray-900"
452
475
  }, null, 512), [
453
- [ce, d(n)]
476
+ [ue, f(n)]
454
477
  ])
455
478
  ]),
456
- d(n) && r.value.total > 0 ? (u(), v(F, { key: 0 }, [
457
- p("div", Qe, [
458
- p("div", We, [
459
- s[3] || (s[3] = p("span", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, "Review progress", -1)),
460
- p("span", Xe, k(r.value.verified) + " / " + k(r.value.total), 1)
479
+ f(n) && r.value.total > 0 ? (i(), u(j, { key: 0 }, [
480
+ m("div", rt, [
481
+ m("div", at, [
482
+ s[3] || (s[3] = m("span", { class: "text-[11px] font-semibold uppercase tracking-wider text-gray-400" }, "Review progress", -1)),
483
+ m("span", lt, E(r.value.verified) + " / " + E(r.value.total), 1)
461
484
  ]),
462
- L(d(me), {
485
+ T(f(me), {
463
486
  value: r.value.verified,
464
487
  max: r.value.total,
465
488
  size: "md",
@@ -469,47 +492,48 @@ const je = ["data-status", "title"], Be = {
469
492
  glow: r.value.percent === 100,
470
493
  gradient: ""
471
494
  }, null, 8, ["value", "max", "variant", "striped", "animate-stripes", "glow"]),
472
- c.value > 0 ? (u(), v("div", Ze, k(c.value) + " extraction attempt" + k(c.value === 1 ? "" : "s") + " recorded ", 1)) : S("", !0)
495
+ v.value > 0 ? (i(), u("div", ot, E(v.value) + " extraction attempt" + E(v.value === 1 ? "" : "s") + " recorded ", 1)) : k("", !0)
473
496
  ]),
474
- r.value.needsReview > 0 ? (u(), v("button", {
497
+ r.value.needsReview > 0 ? (i(), u("button", {
475
498
  key: 0,
476
499
  type: "button",
477
- class: w(["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", d(R)]),
478
- onClick: W(O, ["stop"])
500
+ class: g(["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(R)]),
501
+ onClick: W(D, ["stop"])
479
502
  }, [
480
- p("span", null, k(r.value.needsReview) + " need" + k(r.value.needsReview === 1 ? "s" : "") + " review", 1),
481
- s[4] || (s[4] = p("span", { "aria-hidden": "true" }, "→", -1))
482
- ], 2)) : S("", !0)
483
- ], 64)) : S("", !0)
484
- ], 2)) : S("", !0),
485
- L(d(be), {
486
- class: w(d(R))
503
+ m("span", null, E(r.value.needsReview) + " need" + E(r.value.needsReview === 1 ? "s" : "") + " review", 1),
504
+ s[4] || (s[4] = m("span", { "aria-hidden": "true" }, "→", -1))
505
+ ], 2)) : k("", !0)
506
+ ], 64)) : k("", !0)
507
+ ], 2)) : k("", !0),
508
+ T(f(he), {
509
+ class: g(f(R))
487
510
  }, null, 8, ["class"])
488
511
  ], 64));
489
512
  }
490
513
  });
491
514
  export {
492
515
  R as CHROME_CLASS,
493
- Ue as ConfidenceIcon,
494
- De as DATA_POINT_ACTIVATED,
495
- we as EDITABLE_CLASS,
516
+ Ie as CONFIDENCE_SCALE,
517
+ Je as ConfidenceIcon,
518
+ Pe as DATA_POINT_ACTIVATED,
519
+ ge as EDITABLE_CLASS,
496
520
  Z as ENABLED_STORAGE_KEY,
497
- re as RESOLUTION_PRIORITY,
498
- Se as STATUS_COLORS,
499
- P as STATUS_LABELS,
500
- Oe as TEMPLATE_MESSAGE_SOURCE,
501
- Ve as TEMPLATE_PROTOCOL_VERSION,
502
- lt as VerificationChrome,
503
- at as VerifiedField,
504
- ne as bucketConfidence,
505
- Ae as candidatesDisagree,
506
- Me as computeProgress,
507
- Le as embedderOrigin,
508
- $e as hasDiscrepancy,
509
- rt as initVerification,
510
- Ne as notifyDataPointActivated,
511
- Ce as resolveCandidates,
512
- Ie as resolveDataPoint,
521
+ ne as RESOLUTION_PRIORITY,
522
+ Fe as TEMPLATE_MESSAGE_SOURCE,
523
+ Me as TEMPLATE_PROTOCOL_VERSION,
524
+ ft as VerificationChrome,
525
+ dt as VerifiedField,
526
+ Le as candidatesDisagree,
527
+ Ue as computeProgress,
528
+ z as confidenceStateLabel,
529
+ Ce as confidenceStateOf,
530
+ Be as embedderOrigin,
531
+ De as hasDiscrepancy,
532
+ ct as initVerification,
533
+ je as notifyDataPointActivated,
534
+ Ee as ratingLevel,
535
+ Te as resolveCandidates,
536
+ Re as resolveDataPoint,
513
537
  te as useVerification,
514
- ae as walkDataPoints
538
+ re as walkDataPoints
515
539
  };