@docling/docling-components 0.0.6 → 0.0.7

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.
@@ -0,0 +1,1885 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const v = (i) => (t, e) => {
7
+ e !== void 0 ? e.addInitializer(() => {
8
+ customElements.define(i, t);
9
+ }) : customElements.define(i, t);
10
+ };
11
+ /**
12
+ * @license
13
+ * Copyright 2019 Google LLC
14
+ * SPDX-License-Identifier: BSD-3-Clause
15
+ */
16
+ const it = globalThis, Pt = it.ShadowRoot && (it.ShadyCSS === void 0 || it.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, xt = Symbol(), Tt = /* @__PURE__ */ new WeakMap();
17
+ let Wt = class {
18
+ constructor(t, e, s) {
19
+ if (this._$cssResult$ = !0, s !== xt) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
20
+ this.cssText = t, this.t = e;
21
+ }
22
+ get styleSheet() {
23
+ let t = this.o;
24
+ const e = this.t;
25
+ if (Pt && t === void 0) {
26
+ const s = e !== void 0 && e.length === 1;
27
+ s && (t = Tt.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && Tt.set(e, t));
28
+ }
29
+ return t;
30
+ }
31
+ toString() {
32
+ return this.cssText;
33
+ }
34
+ };
35
+ const ie = (i) => new Wt(typeof i == "string" ? i : i + "", void 0, xt), O = (i, ...t) => {
36
+ const e = i.length === 1 ? i[0] : t.reduce((s, r, o) => s + ((n) => {
37
+ if (n._$cssResult$ === !0) return n.cssText;
38
+ if (typeof n == "number") return n;
39
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + n + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
40
+ })(r) + i[o + 1], i[0]);
41
+ return new Wt(e, i, xt);
42
+ }, oe = (i, t) => {
43
+ if (Pt) i.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
44
+ else for (const e of t) {
45
+ const s = document.createElement("style"), r = it.litNonce;
46
+ r !== void 0 && s.setAttribute("nonce", r), s.textContent = e.cssText, i.appendChild(s);
47
+ }
48
+ }, jt = Pt ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
49
+ let e = "";
50
+ for (const s of t.cssRules) e += s.cssText;
51
+ return ie(e);
52
+ })(i) : i;
53
+ /**
54
+ * @license
55
+ * Copyright 2017 Google LLC
56
+ * SPDX-License-Identifier: BSD-3-Clause
57
+ */
58
+ const { is: ne, defineProperty: ae, getOwnPropertyDescriptor: he, getOwnPropertyNames: le, getOwnPropertySymbols: ce, getPrototypeOf: pe } = Object, j = globalThis, kt = j.trustedTypes, de = kt ? kt.emptyScript : "", ut = j.reactiveElementPolyfillSupport, J = (i, t) => i, ot = { toAttribute(i, t) {
59
+ switch (t) {
60
+ case Boolean:
61
+ i = i ? de : null;
62
+ break;
63
+ case Object:
64
+ case Array:
65
+ i = i == null ? i : JSON.stringify(i);
66
+ }
67
+ return i;
68
+ }, fromAttribute(i, t) {
69
+ let e = i;
70
+ switch (t) {
71
+ case Boolean:
72
+ e = i !== null;
73
+ break;
74
+ case Number:
75
+ e = i === null ? null : Number(i);
76
+ break;
77
+ case Object:
78
+ case Array:
79
+ try {
80
+ e = JSON.parse(i);
81
+ } catch {
82
+ e = null;
83
+ }
84
+ }
85
+ return e;
86
+ } }, ct = (i, t) => !ne(i, t), Ut = { attribute: !0, type: String, converter: ot, reflect: !1, useDefault: !1, hasChanged: ct };
87
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), j.litPropertyMetadata ?? (j.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
88
+ let L = class extends HTMLElement {
89
+ static addInitializer(t) {
90
+ this._$Ei(), (this.l ?? (this.l = [])).push(t);
91
+ }
92
+ static get observedAttributes() {
93
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
94
+ }
95
+ static createProperty(t, e = Ut) {
96
+ if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
97
+ const s = Symbol(), r = this.getPropertyDescriptor(t, s, e);
98
+ r !== void 0 && ae(this.prototype, t, r);
99
+ }
100
+ }
101
+ static getPropertyDescriptor(t, e, s) {
102
+ const { get: r, set: o } = he(this.prototype, t) ?? { get() {
103
+ return this[e];
104
+ }, set(n) {
105
+ this[e] = n;
106
+ } };
107
+ return { get: r, set(n) {
108
+ const h = r == null ? void 0 : r.call(this);
109
+ o == null || o.call(this, n), this.requestUpdate(t, h, s);
110
+ }, configurable: !0, enumerable: !0 };
111
+ }
112
+ static getPropertyOptions(t) {
113
+ return this.elementProperties.get(t) ?? Ut;
114
+ }
115
+ static _$Ei() {
116
+ if (this.hasOwnProperty(J("elementProperties"))) return;
117
+ const t = pe(this);
118
+ t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
119
+ }
120
+ static finalize() {
121
+ if (this.hasOwnProperty(J("finalized"))) return;
122
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(J("properties"))) {
123
+ const e = this.properties, s = [...le(e), ...ce(e)];
124
+ for (const r of s) this.createProperty(r, e[r]);
125
+ }
126
+ const t = this[Symbol.metadata];
127
+ if (t !== null) {
128
+ const e = litPropertyMetadata.get(t);
129
+ if (e !== void 0) for (const [s, r] of e) this.elementProperties.set(s, r);
130
+ }
131
+ this._$Eh = /* @__PURE__ */ new Map();
132
+ for (const [e, s] of this.elementProperties) {
133
+ const r = this._$Eu(e, s);
134
+ r !== void 0 && this._$Eh.set(r, e);
135
+ }
136
+ this.elementStyles = this.finalizeStyles(this.styles);
137
+ }
138
+ static finalizeStyles(t) {
139
+ const e = [];
140
+ if (Array.isArray(t)) {
141
+ const s = new Set(t.flat(1 / 0).reverse());
142
+ for (const r of s) e.unshift(jt(r));
143
+ } else t !== void 0 && e.push(jt(t));
144
+ return e;
145
+ }
146
+ static _$Eu(t, e) {
147
+ const s = e.attribute;
148
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
149
+ }
150
+ constructor() {
151
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
152
+ }
153
+ _$Ev() {
154
+ var t;
155
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
156
+ }
157
+ addController(t) {
158
+ var e;
159
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
160
+ }
161
+ removeController(t) {
162
+ var e;
163
+ (e = this._$EO) == null || e.delete(t);
164
+ }
165
+ _$E_() {
166
+ const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
167
+ for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
168
+ t.size > 0 && (this._$Ep = t);
169
+ }
170
+ createRenderRoot() {
171
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
172
+ return oe(t, this.constructor.elementStyles), t;
173
+ }
174
+ connectedCallback() {
175
+ var t;
176
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
177
+ var s;
178
+ return (s = e.hostConnected) == null ? void 0 : s.call(e);
179
+ });
180
+ }
181
+ enableUpdating(t) {
182
+ }
183
+ disconnectedCallback() {
184
+ var t;
185
+ (t = this._$EO) == null || t.forEach((e) => {
186
+ var s;
187
+ return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
188
+ });
189
+ }
190
+ attributeChangedCallback(t, e, s) {
191
+ this._$AK(t, s);
192
+ }
193
+ _$ET(t, e) {
194
+ var o;
195
+ const s = this.constructor.elementProperties.get(t), r = this.constructor._$Eu(t, s);
196
+ if (r !== void 0 && s.reflect === !0) {
197
+ const n = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : ot).toAttribute(e, s.type);
198
+ this._$Em = t, n == null ? this.removeAttribute(r) : this.setAttribute(r, n), this._$Em = null;
199
+ }
200
+ }
201
+ _$AK(t, e) {
202
+ var o, n;
203
+ const s = this.constructor, r = s._$Eh.get(t);
204
+ if (r !== void 0 && this._$Em !== r) {
205
+ const h = s.getPropertyOptions(r), a = typeof h.converter == "function" ? { fromAttribute: h.converter } : ((o = h.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? h.converter : ot;
206
+ this._$Em = r, this[r] = a.fromAttribute(e, h.type) ?? ((n = this._$Ej) == null ? void 0 : n.get(r)) ?? null, this._$Em = null;
207
+ }
208
+ }
209
+ requestUpdate(t, e, s) {
210
+ var r;
211
+ if (t !== void 0) {
212
+ const o = this.constructor, n = this[t];
213
+ if (s ?? (s = o.getPropertyOptions(t)), !((s.hasChanged ?? ct)(n, e) || s.useDefault && s.reflect && n === ((r = this._$Ej) == null ? void 0 : r.get(t)) && !this.hasAttribute(o._$Eu(t, s)))) return;
214
+ this.C(t, e, s);
215
+ }
216
+ this.isUpdatePending === !1 && (this._$ES = this._$EP());
217
+ }
218
+ C(t, e, { useDefault: s, reflect: r, wrapped: o }, n) {
219
+ s && !(this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Map())).has(t) && (this._$Ej.set(t, n ?? e ?? this[t]), o !== !0 || n !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), r === !0 && this._$Em !== t && (this._$Eq ?? (this._$Eq = /* @__PURE__ */ new Set())).add(t));
220
+ }
221
+ async _$EP() {
222
+ this.isUpdatePending = !0;
223
+ try {
224
+ await this._$ES;
225
+ } catch (e) {
226
+ Promise.reject(e);
227
+ }
228
+ const t = this.scheduleUpdate();
229
+ return t != null && await t, !this.isUpdatePending;
230
+ }
231
+ scheduleUpdate() {
232
+ return this.performUpdate();
233
+ }
234
+ performUpdate() {
235
+ var s;
236
+ if (!this.isUpdatePending) return;
237
+ if (!this.hasUpdated) {
238
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
239
+ for (const [o, n] of this._$Ep) this[o] = n;
240
+ this._$Ep = void 0;
241
+ }
242
+ const r = this.constructor.elementProperties;
243
+ if (r.size > 0) for (const [o, n] of r) {
244
+ const { wrapped: h } = n, a = this[o];
245
+ h !== !0 || this._$AL.has(o) || a === void 0 || this.C(o, void 0, n, a);
246
+ }
247
+ }
248
+ let t = !1;
249
+ const e = this._$AL;
250
+ try {
251
+ t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((r) => {
252
+ var o;
253
+ return (o = r.hostUpdate) == null ? void 0 : o.call(r);
254
+ }), this.update(e)) : this._$EM();
255
+ } catch (r) {
256
+ throw t = !1, this._$EM(), r;
257
+ }
258
+ t && this._$AE(e);
259
+ }
260
+ willUpdate(t) {
261
+ }
262
+ _$AE(t) {
263
+ var e;
264
+ (e = this._$EO) == null || e.forEach((s) => {
265
+ var r;
266
+ return (r = s.hostUpdated) == null ? void 0 : r.call(s);
267
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
268
+ }
269
+ _$EM() {
270
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
271
+ }
272
+ get updateComplete() {
273
+ return this.getUpdateComplete();
274
+ }
275
+ getUpdateComplete() {
276
+ return this._$ES;
277
+ }
278
+ shouldUpdate(t) {
279
+ return !0;
280
+ }
281
+ update(t) {
282
+ this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM();
283
+ }
284
+ updated(t) {
285
+ }
286
+ firstUpdated(t) {
287
+ }
288
+ };
289
+ L.elementStyles = [], L.shadowRootOptions = { mode: "open" }, L[J("elementProperties")] = /* @__PURE__ */ new Map(), L[J("finalized")] = /* @__PURE__ */ new Map(), ut == null || ut({ ReactiveElement: L }), (j.reactiveElementVersions ?? (j.reactiveElementVersions = [])).push("2.1.0");
290
+ /**
291
+ * @license
292
+ * Copyright 2017 Google LLC
293
+ * SPDX-License-Identifier: BSD-3-Clause
294
+ */
295
+ const ue = { attribute: !0, type: String, converter: ot, reflect: !1, hasChanged: ct }, me = (i = ue, t, e) => {
296
+ const { kind: s, metadata: r } = e;
297
+ let o = globalThis.litPropertyMetadata.get(r);
298
+ if (o === void 0 && globalThis.litPropertyMetadata.set(r, o = /* @__PURE__ */ new Map()), s === "setter" && ((i = Object.create(i)).wrapped = !0), o.set(e.name, i), s === "accessor") {
299
+ const { name: n } = e;
300
+ return { set(h) {
301
+ const a = t.get.call(this);
302
+ t.set.call(this, h), this.requestUpdate(n, a, i);
303
+ }, init(h) {
304
+ return h !== void 0 && this.C(n, void 0, i, h), h;
305
+ } };
306
+ }
307
+ if (s === "setter") {
308
+ const { name: n } = e;
309
+ return function(h) {
310
+ const a = this[n];
311
+ t.call(this, h), this.requestUpdate(n, a, i);
312
+ };
313
+ }
314
+ throw Error("Unsupported decorator location: " + s);
315
+ };
316
+ function d(i) {
317
+ return (t, e) => typeof e == "object" ? me(i, t, e) : ((s, r, o) => {
318
+ const n = r.hasOwnProperty(o);
319
+ return r.constructor.createProperty(o, s), n ? Object.getOwnPropertyDescriptor(r, o) : void 0;
320
+ })(i, t, e);
321
+ }
322
+ const $t = [];
323
+ function Vt(i) {
324
+ const t = v(i);
325
+ return function(e, s) {
326
+ return $t.push(
327
+ e
328
+ ), t(e, s);
329
+ };
330
+ }
331
+ /**
332
+ * @license
333
+ * Copyright 2017 Google LLC
334
+ * SPDX-License-Identifier: BSD-3-Clause
335
+ */
336
+ const Z = globalThis, nt = Z.trustedTypes, Mt = nt ? nt.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, Ft = "$lit$", T = `lit$${Math.random().toFixed(9).slice(2)}$`, Gt = "?" + T, fe = `<${Gt}>`, R = document, X = () => R.createComment(""), Y = (i) => i === null || typeof i != "object" && typeof i != "function", Ct = Array.isArray, ge = (i) => Ct(i) || typeof (i == null ? void 0 : i[Symbol.iterator]) == "function", mt = `[
337
+ \f\r]`, K = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Nt = /-->/g, Ht = />/g, M = RegExp(`>|${mt}(?:([^\\s"'>=/]+)(${mt}*=${mt}*(?:[^
338
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Rt = /'/g, zt = /"/g, Kt = /^(?:script|style|textarea|title)$/i, Jt = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), m = Jt(1), st = Jt(2), W = Symbol.for("lit-noChange"), f = Symbol.for("lit-nothing"), Bt = /* @__PURE__ */ new WeakMap(), N = R.createTreeWalker(R, 129);
339
+ function Zt(i, t) {
340
+ if (!Ct(i) || !i.hasOwnProperty("raw")) throw Error("invalid template strings array");
341
+ return Mt !== void 0 ? Mt.createHTML(t) : t;
342
+ }
343
+ const $e = (i, t) => {
344
+ const e = i.length - 1, s = [];
345
+ let r, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", n = K;
346
+ for (let h = 0; h < e; h++) {
347
+ const a = i[h];
348
+ let l, p, c = -1, u = 0;
349
+ for (; u < a.length && (n.lastIndex = u, p = n.exec(a), p !== null); ) u = n.lastIndex, n === K ? p[1] === "!--" ? n = Nt : p[1] !== void 0 ? n = Ht : p[2] !== void 0 ? (Kt.test(p[2]) && (r = RegExp("</" + p[2], "g")), n = M) : p[3] !== void 0 && (n = M) : n === M ? p[0] === ">" ? (n = r ?? K, c = -1) : p[1] === void 0 ? c = -2 : (c = n.lastIndex - p[2].length, l = p[1], n = p[3] === void 0 ? M : p[3] === '"' ? zt : Rt) : n === zt || n === Rt ? n = M : n === Nt || n === Ht ? n = K : (n = M, r = void 0);
350
+ const g = n === M && i[h + 1].startsWith("/>") ? " " : "";
351
+ o += n === K ? a + fe : c >= 0 ? (s.push(l), a.slice(0, c) + Ft + a.slice(c) + T + g) : a + T + (c === -2 ? h : g);
352
+ }
353
+ return [Zt(i, o + (i[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
354
+ };
355
+ class Q {
356
+ constructor({ strings: t, _$litType$: e }, s) {
357
+ let r;
358
+ this.parts = [];
359
+ let o = 0, n = 0;
360
+ const h = t.length - 1, a = this.parts, [l, p] = $e(t, e);
361
+ if (this.el = Q.createElement(l, s), N.currentNode = this.el.content, e === 2 || e === 3) {
362
+ const c = this.el.content.firstChild;
363
+ c.replaceWith(...c.childNodes);
364
+ }
365
+ for (; (r = N.nextNode()) !== null && a.length < h; ) {
366
+ if (r.nodeType === 1) {
367
+ if (r.hasAttributes()) for (const c of r.getAttributeNames()) if (c.endsWith(Ft)) {
368
+ const u = p[n++], g = r.getAttribute(c).split(T), _ = /([.?@])?(.*)/.exec(u);
369
+ a.push({ type: 1, index: o, name: _[2], strings: g, ctor: _[1] === "." ? ye : _[1] === "?" ? ve : _[1] === "@" ? be : pt }), r.removeAttribute(c);
370
+ } else c.startsWith(T) && (a.push({ type: 6, index: o }), r.removeAttribute(c));
371
+ if (Kt.test(r.tagName)) {
372
+ const c = r.textContent.split(T), u = c.length - 1;
373
+ if (u > 0) {
374
+ r.textContent = nt ? nt.emptyScript : "";
375
+ for (let g = 0; g < u; g++) r.append(c[g], X()), N.nextNode(), a.push({ type: 2, index: ++o });
376
+ r.append(c[u], X());
377
+ }
378
+ }
379
+ } else if (r.nodeType === 8) if (r.data === Gt) a.push({ type: 2, index: o });
380
+ else {
381
+ let c = -1;
382
+ for (; (c = r.data.indexOf(T, c + 1)) !== -1; ) a.push({ type: 7, index: o }), c += T.length - 1;
383
+ }
384
+ o++;
385
+ }
386
+ }
387
+ static createElement(t, e) {
388
+ const s = R.createElement("template");
389
+ return s.innerHTML = t, s;
390
+ }
391
+ }
392
+ function V(i, t, e = i, s) {
393
+ var n, h;
394
+ if (t === W) return t;
395
+ let r = s !== void 0 ? (n = e._$Co) == null ? void 0 : n[s] : e._$Cl;
396
+ const o = Y(t) ? void 0 : t._$litDirective$;
397
+ return (r == null ? void 0 : r.constructor) !== o && ((h = r == null ? void 0 : r._$AO) == null || h.call(r, !1), o === void 0 ? r = void 0 : (r = new o(i), r._$AT(i, e, s)), s !== void 0 ? (e._$Co ?? (e._$Co = []))[s] = r : e._$Cl = r), r !== void 0 && (t = V(i, r._$AS(i, t.values), r, s)), t;
398
+ }
399
+ class _e {
400
+ constructor(t, e) {
401
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
402
+ }
403
+ get parentNode() {
404
+ return this._$AM.parentNode;
405
+ }
406
+ get _$AU() {
407
+ return this._$AM._$AU;
408
+ }
409
+ u(t) {
410
+ const { el: { content: e }, parts: s } = this._$AD, r = ((t == null ? void 0 : t.creationScope) ?? R).importNode(e, !0);
411
+ N.currentNode = r;
412
+ let o = N.nextNode(), n = 0, h = 0, a = s[0];
413
+ for (; a !== void 0; ) {
414
+ if (n === a.index) {
415
+ let l;
416
+ a.type === 2 ? l = new et(o, o.nextSibling, this, t) : a.type === 1 ? l = new a.ctor(o, a.name, a.strings, this, t) : a.type === 6 && (l = new we(o, this, t)), this._$AV.push(l), a = s[++h];
417
+ }
418
+ n !== (a == null ? void 0 : a.index) && (o = N.nextNode(), n++);
419
+ }
420
+ return N.currentNode = R, r;
421
+ }
422
+ p(t) {
423
+ let e = 0;
424
+ for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
425
+ }
426
+ }
427
+ class et {
428
+ get _$AU() {
429
+ var t;
430
+ return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
431
+ }
432
+ constructor(t, e, s, r) {
433
+ this.type = 2, this._$AH = f, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = r, this._$Cv = (r == null ? void 0 : r.isConnected) ?? !0;
434
+ }
435
+ get parentNode() {
436
+ let t = this._$AA.parentNode;
437
+ const e = this._$AM;
438
+ return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
439
+ }
440
+ get startNode() {
441
+ return this._$AA;
442
+ }
443
+ get endNode() {
444
+ return this._$AB;
445
+ }
446
+ _$AI(t, e = this) {
447
+ t = V(this, t, e), Y(t) ? t === f || t == null || t === "" ? (this._$AH !== f && this._$AR(), this._$AH = f) : t !== this._$AH && t !== W && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : ge(t) ? this.k(t) : this._(t);
448
+ }
449
+ O(t) {
450
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
451
+ }
452
+ T(t) {
453
+ this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
454
+ }
455
+ _(t) {
456
+ this._$AH !== f && Y(this._$AH) ? this._$AA.nextSibling.data = t : this.T(R.createTextNode(t)), this._$AH = t;
457
+ }
458
+ $(t) {
459
+ var o;
460
+ const { values: e, _$litType$: s } = t, r = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = Q.createElement(Zt(s.h, s.h[0]), this.options)), s);
461
+ if (((o = this._$AH) == null ? void 0 : o._$AD) === r) this._$AH.p(e);
462
+ else {
463
+ const n = new _e(r, this), h = n.u(this.options);
464
+ n.p(e), this.T(h), this._$AH = n;
465
+ }
466
+ }
467
+ _$AC(t) {
468
+ let e = Bt.get(t.strings);
469
+ return e === void 0 && Bt.set(t.strings, e = new Q(t)), e;
470
+ }
471
+ k(t) {
472
+ Ct(this._$AH) || (this._$AH = [], this._$AR());
473
+ const e = this._$AH;
474
+ let s, r = 0;
475
+ for (const o of t) r === e.length ? e.push(s = new et(this.O(X()), this.O(X()), this, this.options)) : s = e[r], s._$AI(o), r++;
476
+ r < e.length && (this._$AR(s && s._$AB.nextSibling, r), e.length = r);
477
+ }
478
+ _$AR(t = this._$AA.nextSibling, e) {
479
+ var s;
480
+ for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) {
481
+ const r = t.nextSibling;
482
+ t.remove(), t = r;
483
+ }
484
+ }
485
+ setConnected(t) {
486
+ var e;
487
+ this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
488
+ }
489
+ }
490
+ class pt {
491
+ get tagName() {
492
+ return this.element.tagName;
493
+ }
494
+ get _$AU() {
495
+ return this._$AM._$AU;
496
+ }
497
+ constructor(t, e, s, r, o) {
498
+ this.type = 1, this._$AH = f, this._$AN = void 0, this.element = t, this.name = e, this._$AM = r, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = f;
499
+ }
500
+ _$AI(t, e = this, s, r) {
501
+ const o = this.strings;
502
+ let n = !1;
503
+ if (o === void 0) t = V(this, t, e, 0), n = !Y(t) || t !== this._$AH && t !== W, n && (this._$AH = t);
504
+ else {
505
+ const h = t;
506
+ let a, l;
507
+ for (t = o[0], a = 0; a < o.length - 1; a++) l = V(this, h[s + a], e, a), l === W && (l = this._$AH[a]), n || (n = !Y(l) || l !== this._$AH[a]), l === f ? t = f : t !== f && (t += (l ?? "") + o[a + 1]), this._$AH[a] = l;
508
+ }
509
+ n && !r && this.j(t);
510
+ }
511
+ j(t) {
512
+ t === f ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
513
+ }
514
+ }
515
+ class ye extends pt {
516
+ constructor() {
517
+ super(...arguments), this.type = 3;
518
+ }
519
+ j(t) {
520
+ this.element[this.name] = t === f ? void 0 : t;
521
+ }
522
+ }
523
+ class ve extends pt {
524
+ constructor() {
525
+ super(...arguments), this.type = 4;
526
+ }
527
+ j(t) {
528
+ this.element.toggleAttribute(this.name, !!t && t !== f);
529
+ }
530
+ }
531
+ class be extends pt {
532
+ constructor(t, e, s, r, o) {
533
+ super(t, e, s, r, o), this.type = 5;
534
+ }
535
+ _$AI(t, e = this) {
536
+ if ((t = V(this, t, e, 0) ?? f) === W) return;
537
+ const s = this._$AH, r = t === f && s !== f || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, o = t !== f && (s === f || r);
538
+ r && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
539
+ }
540
+ handleEvent(t) {
541
+ var e;
542
+ typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
543
+ }
544
+ }
545
+ class we {
546
+ constructor(t, e, s) {
547
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
548
+ }
549
+ get _$AU() {
550
+ return this._$AM._$AU;
551
+ }
552
+ _$AI(t) {
553
+ V(this, t);
554
+ }
555
+ }
556
+ const ft = Z.litHtmlPolyfillSupport;
557
+ ft == null || ft(Q, et), (Z.litHtmlVersions ?? (Z.litHtmlVersions = [])).push("3.3.0");
558
+ const Ae = (i, t, e) => {
559
+ const s = (e == null ? void 0 : e.renderBefore) ?? t;
560
+ let r = s._$litPart$;
561
+ if (r === void 0) {
562
+ const o = (e == null ? void 0 : e.renderBefore) ?? null;
563
+ s._$litPart$ = r = new et(t.insertBefore(X(), o), o, void 0, e ?? {});
564
+ }
565
+ return r._$AI(i), r;
566
+ };
567
+ /**
568
+ * @license
569
+ * Copyright 2017 Google LLC
570
+ * SPDX-License-Identifier: BSD-3-Clause
571
+ */
572
+ const H = globalThis;
573
+ let A = class extends L {
574
+ constructor() {
575
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
576
+ }
577
+ createRenderRoot() {
578
+ var e;
579
+ const t = super.createRenderRoot();
580
+ return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
581
+ }
582
+ update(t) {
583
+ const e = this.render();
584
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ae(e, this.renderRoot, this.renderOptions);
585
+ }
586
+ connectedCallback() {
587
+ var t;
588
+ super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0);
589
+ }
590
+ disconnectedCallback() {
591
+ var t;
592
+ super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
593
+ }
594
+ render() {
595
+ return W;
596
+ }
597
+ };
598
+ var qt;
599
+ A._$litElement$ = !0, A.finalized = !0, (qt = H.litElementHydrateSupport) == null || qt.call(H, { LitElement: A });
600
+ const gt = H.litElementPolyfillSupport;
601
+ gt == null || gt({ LitElement: A });
602
+ (H.litElementVersions ?? (H.litElementVersions = [])).push("4.2.0");
603
+ var Pe = Object.defineProperty, dt = (i, t, e, s) => {
604
+ for (var r = void 0, o = i.length - 1, n; o >= 0; o--)
605
+ (n = i[o]) && (r = n(t, e, r) || r);
606
+ return r && Pe(t, e, r), r;
607
+ };
608
+ class z extends A {
609
+ render() {
610
+ if (this.annotation && this.item && this.page && this.canDrawAnnotation(this.annotation) && this.canDrawItem(this.item))
611
+ return this.renderAnnotation(
612
+ this.annotation,
613
+ this.item,
614
+ this.page,
615
+ this.prov
616
+ );
617
+ }
618
+ }
619
+ dt([
620
+ d({ attribute: !1 })
621
+ ], z.prototype, "annotation");
622
+ dt([
623
+ d({ attribute: !1 })
624
+ ], z.prototype, "item");
625
+ dt([
626
+ d({ attribute: !1 })
627
+ ], z.prototype, "page");
628
+ dt([
629
+ d({ attribute: !1 })
630
+ ], z.prototype, "prov");
631
+ function B(...i) {
632
+ return function(t) {
633
+ return b.DocItem(t) && i.includes(t.label);
634
+ };
635
+ }
636
+ var I = {
637
+ CodeItem: B("code"),
638
+ ListItem: B("list_item"),
639
+ PictureItem: B("chart", "picture"),
640
+ SectionHeaderItem: B("section_header"),
641
+ TableItem: B("document_index", "table"),
642
+ TextItem: B(
643
+ "caption",
644
+ "checkbox_selected",
645
+ "checkbox_unselected",
646
+ "footnote",
647
+ "page_footer",
648
+ "page_header",
649
+ "paragraph",
650
+ "reference",
651
+ "text"
652
+ )
653
+ };
654
+ function S(...i) {
655
+ return function(t) {
656
+ return i.includes(t.kind);
657
+ };
658
+ }
659
+ var Ot = {
660
+ PictureBarChart: S("bar_chart_data"),
661
+ PictureClassification: S("classification"),
662
+ PictureDescription: S("description"),
663
+ PictureMisc: S("misc"),
664
+ PictureMolecule: S("molecule_data"),
665
+ PictureLineChart: S("line_chart_data"),
666
+ PicturePieChart: S("pie_chart_data"),
667
+ PictureScatterChart: S("scatter_chart_data"),
668
+ PictureStackedBarChart: S(
669
+ "stacked_bar_chart_data"
670
+ )
671
+ }, b = {
672
+ DocItem(i) {
673
+ return b.NodeItem(i) && !b.GroupItem(i);
674
+ },
675
+ Document(i) {
676
+ return "schema_name" in i && i.schema_name === "DoclingDocument";
677
+ },
678
+ GroupItem(i) {
679
+ return b.NodeItem(i) && (i.self_ref.startsWith("#/groups/") || i.self_ref === "#/body");
680
+ },
681
+ NodeItem(i) {
682
+ return "self_ref" in i;
683
+ },
684
+ ...Ot,
685
+ ...I
686
+ };
687
+ function* xe(i, t = {}) {
688
+ i && (yield* e(t.root ?? i.body));
689
+ function* e(s, r = 0) {
690
+ var o;
691
+ if ((!b.GroupItem(s) || t.withGroups) && (b.DocItem(s) ? (t.pageNo === void 0 || (o = s.prov) != null && o.some((n) => n.page_no === t.pageNo)) && (yield [s, r]) : yield [s, r]), !(b.PictureItem(s) && !t.traversePictures))
692
+ for (const n of s.children ?? []) {
693
+ const h = Ce(i, n);
694
+ b.NodeItem(h) && (yield* e(h, r + 1));
695
+ }
696
+ }
697
+ }
698
+ function Ce(i, t) {
699
+ return t.$ref.split("/").slice(1).reduce(
700
+ (s, r) => s[r],
701
+ i
702
+ );
703
+ }
704
+ var Oe = Object.defineProperty, Ee = Object.getOwnPropertyDescriptor, Xt = (i, t, e, s) => {
705
+ for (var r = s > 1 ? void 0 : s ? Ee(t, e) : t, o = i.length - 1, n; o >= 0; o--)
706
+ (n = i[o]) && (r = (s ? n(t, e, r) : n(r)) || r);
707
+ return s && r && Oe(t, e, r), r;
708
+ };
709
+ let at = class extends z {
710
+ constructor() {
711
+ super(...arguments), this.precision = 2;
712
+ }
713
+ renderAnnotation(i, t, e, s) {
714
+ const r = i.predicted_classes ?? [], o = Math.pow(10, -1 * this.precision), n = r.filter((l) => o < l.confidence), h = r.filter((l) => l.confidence < o), a = (l) => l.toLocaleString(void 0, {
715
+ maximumFractionDigits: this.precision
716
+ });
717
+ return m`<table>
718
+ <thead>
719
+ <tr>
720
+ <th>Class</th>
721
+ <th>Confidence</th>
722
+ </tr>
723
+ </thead>
724
+ <tbody>
725
+ ${n.map(
726
+ ({ class_name: l, confidence: p }) => m`<tr>
727
+ <td>${l}</td>
728
+ <td>${a(p)}</td>
729
+ </tr>`
730
+ )}
731
+ ${h.length === 0 ? f : m`<tr
732
+ class="more"
733
+ title=${h.map((l) => `${l.class_name} ${l.confidence}`).join(`
734
+ `)}
735
+ >
736
+ <td>${h.length} more</td>
737
+ <td>< ${a(o)}</td>
738
+ </tr>`}
739
+ </tbody>
740
+ </table>`;
741
+ }
742
+ canDrawAnnotation(i) {
743
+ return Ot.PictureClassification(i);
744
+ }
745
+ canDrawItem(i) {
746
+ return I.PictureItem(i);
747
+ }
748
+ };
749
+ at.styles = O`
750
+ table {
751
+ margin: 0.5rem;
752
+ font-size: inherit;
753
+ line-height: 1.25;
754
+ }
755
+
756
+ td,
757
+ th {
758
+ padding: 0 1rem 0 0;
759
+ }
760
+
761
+ th {
762
+ font-weight: bold;
763
+ text-align: left;
764
+ }
765
+
766
+ tr.more td {
767
+ padding-top: 0.25rem;
768
+ color: gray;
769
+ }
770
+ `;
771
+ Xt([
772
+ d()
773
+ ], at.prototype, "precision", 2);
774
+ at = Xt([
775
+ Vt("docling-picture-classification")
776
+ ], at);
777
+ var Se = Object.getOwnPropertyDescriptor, Ie = (i, t, e, s) => {
778
+ for (var r = s > 1 ? void 0 : s ? Se(t, e) : t, o = i.length - 1, n; o >= 0; o--)
779
+ (n = i[o]) && (r = n(r) || r);
780
+ return r;
781
+ };
782
+ let _t = class extends z {
783
+ renderAnnotation(i, t, e, s) {
784
+ return m`<p><span>Description</span>${i.text}</p>`;
785
+ }
786
+ canDrawAnnotation(i) {
787
+ return Ot.PictureDescription(i);
788
+ }
789
+ canDrawItem(i) {
790
+ return I.PictureItem(i);
791
+ }
792
+ };
793
+ _t.styles = O`
794
+ p {
795
+ margin: 0.5rem;
796
+ font-size: inherit;
797
+ line-height: 1.25;
798
+ white-space: pre-line;
799
+ }
800
+
801
+ span {
802
+ padding-right: 0.5rem;
803
+ font-weight: bold;
804
+ }
805
+ `;
806
+ _t = Ie([
807
+ Vt("docling-picture-description")
808
+ ], _t);
809
+ const yt = [];
810
+ function Yt(i) {
811
+ const t = v(i);
812
+ return function(e, s) {
813
+ return yt.push(e), t(e, s);
814
+ };
815
+ }
816
+ var De = Object.defineProperty, Et = (i, t, e, s) => {
817
+ for (var r = void 0, o = i.length - 1, n; o >= 0; o--)
818
+ (n = i[o]) && (r = n(t, e, r) || r);
819
+ return r && De(t, e, r), r;
820
+ };
821
+ class D extends A {
822
+ render() {
823
+ if (this.item && this.page && this.canDrawItem(this.item))
824
+ return this.renderItem(this.item, this.page, this.prov);
825
+ }
826
+ }
827
+ Et([
828
+ d({ attribute: !1 })
829
+ ], D.prototype, "item");
830
+ Et([
831
+ d({ attribute: !1 })
832
+ ], D.prototype, "page");
833
+ Et([
834
+ d({ attribute: !1 })
835
+ ], D.prototype, "prov");
836
+ var Te = Object.getOwnPropertyDescriptor, je = (i, t, e, s) => {
837
+ for (var r = s > 1 ? void 0 : s ? Te(t, e) : t, o = i.length - 1, n; o >= 0; o--)
838
+ (n = i[o]) && (r = n(r) || r);
839
+ return r;
840
+ };
841
+ let ht = class extends D {
842
+ renderItem(i, t) {
843
+ var r;
844
+ const { image: e } = t, s = (r = i.prov) == null ? void 0 : r.find((o) => {
845
+ var n;
846
+ return o.page_no === ((n = this.page) == null ? void 0 : n.page_no);
847
+ });
848
+ if (e && s) {
849
+ const { width: o = 1, height: n = 1 } = this.page.size, { l: h, r: a, t: l, b: p } = q(s.bbox, t);
850
+ return m`
851
+ <svg
852
+ width=${(a - h) * ((e.size.width ?? 1) / o)}
853
+ viewBox="${h} ${l} ${a - h} ${p - l}"
854
+ >
855
+ <image href=${e.uri} width=${o} height=${n} />
856
+ </svg>
857
+ `;
858
+ } else
859
+ return m`<span>Invalid provenance.</span>`;
860
+ }
861
+ canDrawItem(i) {
862
+ return b.DocItem(i);
863
+ }
864
+ };
865
+ ht.styles = O`
866
+ svg {
867
+ max-width: 100%;
868
+ }
869
+ `;
870
+ ht = je([
871
+ v("docling-item-provenance")
872
+ ], ht);
873
+ var ke = Object.getOwnPropertyDescriptor, Ue = (i, t, e, s) => {
874
+ for (var r = s > 1 ? void 0 : s ? ke(t, e) : t, o = i.length - 1, n; o >= 0; o--)
875
+ (n = i[o]) && (r = n(r) || r);
876
+ return r;
877
+ };
878
+ let vt = class extends D {
879
+ renderItem(i) {
880
+ const t = /* @__PURE__ */ new Set();
881
+ return m`
882
+ <div class="container">
883
+ <table>
884
+ <tbody>
885
+ ${i.data.grid.map(
886
+ (s) => m`<tr>
887
+ ${s.map((r) => {
888
+ if (!e(r))
889
+ return m`<td
890
+ class=${r.column_header || r.row_header ? "header" : ""}
891
+ colspan=${r.col_span ?? 1}
892
+ rowspan=${r.row_span ?? 1}
893
+ >
894
+ ${r.text}
895
+ </td>`;
896
+ })}
897
+ </tr>`
898
+ )}
899
+ </tbody>
900
+ </table>
901
+ </div>
902
+ `;
903
+ function e(s) {
904
+ const r = t.has(
905
+ [s.start_col_offset_idx, s.start_row_offset_idx].join()
906
+ );
907
+ if (!r)
908
+ for (let o = s.start_col_offset_idx; o < s.end_col_offset_idx; o++)
909
+ for (let n = s.start_row_offset_idx; n < s.end_row_offset_idx; n++)
910
+ t.add([o, n].join());
911
+ return r;
912
+ }
913
+ }
914
+ canDrawItem(i) {
915
+ return I.TableItem(i);
916
+ }
917
+ };
918
+ vt.styles = O`
919
+ .container {
920
+ position: relative;
921
+ min-width: 0;
922
+ max-width: 100%;
923
+ min-height: 0;
924
+ overflow: auto;
925
+ }
926
+
927
+ table {
928
+ border-collapse: collapse;
929
+ font-size: 75%;
930
+ line-height: 1.25;
931
+ }
932
+
933
+ td {
934
+ padding: 0.125rem 0.25rem;
935
+ background-color: var(--cds-layer);
936
+ border: 1px solid rgb(220, 220, 220);
937
+
938
+ color: black;
939
+ text-decoration: none;
940
+ word-break: normal;
941
+ text-align: left;
942
+ }
943
+
944
+ td.header {
945
+ font-weight: bold;
946
+ }
947
+
948
+ td:hover {
949
+ filter: brightness(95%);
950
+ }
951
+
952
+ td:target {
953
+ outline: 3px solid blue;
954
+ }
955
+ `;
956
+ vt = Ue([
957
+ Yt("docling-item-table")
958
+ ], vt);
959
+ var Me = Object.getOwnPropertyDescriptor, Ne = (i, t, e, s) => {
960
+ for (var r = s > 1 ? void 0 : s ? Me(t, e) : t, o = i.length - 1, n; o >= 0; o--)
961
+ (n = i[o]) && (r = n(r) || r);
962
+ return r;
963
+ };
964
+ let Lt = class extends D {
965
+ constructor() {
966
+ super(...arguments), this.renderItem = Function(
967
+ "item",
968
+ "page",
969
+ `"use strict"; return this.html\`${this.innerHTML}\`;`
970
+ ).bind({ html: m });
971
+ }
972
+ canDrawItem(i) {
973
+ return b.DocItem(i);
974
+ }
975
+ };
976
+ Lt = Ne([
977
+ v("docling-item-template")
978
+ ], Lt);
979
+ var He = Object.getOwnPropertyDescriptor, Re = (i, t, e, s) => {
980
+ for (var r = s > 1 ? void 0 : s ? He(t, e) : t, o = i.length - 1, n; o >= 0; o--)
981
+ (n = i[o]) && (r = n(r) || r);
982
+ return r;
983
+ };
984
+ let bt = class extends D {
985
+ renderItem(i, t, e) {
986
+ const s = I.SectionHeaderItem(i) ? "header" : "";
987
+ if (e) {
988
+ const { l: r, r: o, t: n, b: h } = q(e.bbox, t), a = Math.sqrt((o - r) * (h - n) / i.text.length), l = Math.min(Math.floor(1.25 * a), (h - n) / 1.25), [p, c] = e.charspan ?? [
989
+ 0,
990
+ i.text.length
991
+ ], u = i.text.substring(p, c);
992
+ return m`<p
993
+ class=${s}
994
+ style="font-size: ${l}px; line-height: ${1.25 * l}px"
995
+ >
996
+ ${u}
997
+ </p>`;
998
+ } else
999
+ return m`<p class=${s}>${i.text}</p>`;
1000
+ }
1001
+ canDrawItem(i) {
1002
+ return I.TextItem(i) || I.SectionHeaderItem(i) || I.ListItem(i);
1003
+ }
1004
+ };
1005
+ bt.styles = O`
1006
+ p {
1007
+ margin: 0;
1008
+ overflow-wrap: anywhere;
1009
+ font-size: 1rem;
1010
+ line-height: 1.25rem;
1011
+ }
1012
+
1013
+ .header {
1014
+ font-weight: bold;
1015
+ }
1016
+ `;
1017
+ bt = Re([
1018
+ Yt("docling-item-text")
1019
+ ], bt);
1020
+ var ze = Object.getOwnPropertyDescriptor, St = (i, t, e, s) => {
1021
+ for (var r = s > 1 ? void 0 : s ? ze(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1022
+ (n = i[o]) && (r = n(r) || r);
1023
+ return r;
1024
+ };
1025
+ let tt = class extends D {
1026
+ get itemChildren() {
1027
+ return Array.from(this.childNodes ?? []).filter(
1028
+ (i) => i instanceof D
1029
+ );
1030
+ }
1031
+ get annotationChildren() {
1032
+ return Array.from(this.childNodes).filter(
1033
+ (i) => i instanceof z
1034
+ );
1035
+ }
1036
+ get isCustomized() {
1037
+ return this.itemChildren.length > 0 || this.annotationChildren.length > 0;
1038
+ }
1039
+ renderItem(i, t, e) {
1040
+ const s = [], r = this.isCustomized;
1041
+ r ? this.itemChildren.filter((n) => n.canDrawItem(i)).forEach((n) => s.push(n)) : yt.filter((n) => n.prototype.canDrawItem(i)).forEach((n) => s.push(new n()));
1042
+ const o = i.annotations ?? [];
1043
+ for (const n of o) {
1044
+ const h = [];
1045
+ r ? this.annotationChildren.filter((a) => a.canDrawItem(a) && a.canDrawAnnotation(n)).forEach(
1046
+ (a) => h.push(a.cloneNode(!0))
1047
+ ) : $t.filter(
1048
+ (a) => a.prototype.canDrawItem(i) && a.prototype.canDrawAnnotation(n)
1049
+ ).forEach((a) => h.push(new a()));
1050
+ for (const a of h)
1051
+ a.annotation = n;
1052
+ s.push(...h);
1053
+ }
1054
+ for (const n of s)
1055
+ n.item = i, n.page = t, n.prov = e;
1056
+ return m`${s}`;
1057
+ }
1058
+ canDrawItem(i) {
1059
+ return b.DocItem(i) && this.isCustomized ? this.itemChildren.some((t) => t.canDrawItem(i)) || this.annotationChildren.some(
1060
+ (t) => {
1061
+ var e;
1062
+ return t.canDrawItem(i) && ((e = i.annotations) == null ? void 0 : e.some((s) => t.canDrawAnnotation(s)));
1063
+ }
1064
+ ) : yt.some((t) => t.prototype.canDrawItem(i)) || $t.some(
1065
+ (t) => {
1066
+ var e;
1067
+ return t.prototype.canDrawItem(i) && ((e = i.annotations) == null ? void 0 : e.some(
1068
+ (s) => t.prototype.canDrawAnnotation(s)
1069
+ ));
1070
+ }
1071
+ );
1072
+ }
1073
+ };
1074
+ tt = St([
1075
+ v("docling-view")
1076
+ ], tt);
1077
+ let wt = class extends tt {
1078
+ constructor() {
1079
+ super(...arguments), this.type = "overlay";
1080
+ }
1081
+ };
1082
+ wt = St([
1083
+ v("docling-overlay")
1084
+ ], wt);
1085
+ let At = class extends tt {
1086
+ constructor() {
1087
+ super(...arguments), this.type = "tooltip";
1088
+ }
1089
+ };
1090
+ At = St([
1091
+ v("docling-tooltip")
1092
+ ], At);
1093
+ function q(i, t) {
1094
+ const { height: e = 1 } = t.size;
1095
+ return i.coord_origin === "TOPLEFT" ? i : { ...i, t: e - i.t, b: e - i.b };
1096
+ }
1097
+ var Be = Object.defineProperty, Le = Object.getOwnPropertyDescriptor, P = (i, t, e, s) => {
1098
+ for (var r = s > 1 ? void 0 : s ? Le(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1099
+ (n = i[o]) && (r = (s ? n(t, e, r) : n(r)) || r);
1100
+ return s && r && Be(t, e, r), r;
1101
+ };
1102
+ let y = class extends A {
1103
+ constructor() {
1104
+ super(...arguments), this.pagenumbers = !1;
1105
+ }
1106
+ render() {
1107
+ var i, t, e;
1108
+ if ((i = this.page) != null && i.image) {
1109
+ const { image: s, size: r, page_no: o } = this.page, { width: n = 1, height: h = 1 } = r, a = this.onClickItem && this.page ? (l, p) => {
1110
+ var c;
1111
+ return (c = this.onClickItem) == null ? void 0 : c.call(this, l, this.page, p);
1112
+ } : void 0;
1113
+ return m`
1114
+ <div class="page" @onclick=${(l) => a == null ? void 0 : a(l)}>
1115
+ <svg
1116
+ class="base"
1117
+ width=${s.size.width}
1118
+ viewBox="0 0 ${n} ${h}"
1119
+ >
1120
+ ${this.backdrop ? st`
1121
+ <image
1122
+ class="backdrop"
1123
+ href=${s.uri}
1124
+ width=${n}
1125
+ height=${h}
1126
+ />
1127
+
1128
+ <clippath id="clip-page-${o}">
1129
+ ${(t = this.items) == null ? void 0 : t.map((l) => {
1130
+ var c;
1131
+ const p = (c = l.prov) == null ? void 0 : c.find((u) => u.page_no === o);
1132
+ if (p) {
1133
+ const { l: u, r: g, t: _, b: $ } = q(p.bbox, this.page);
1134
+ return st`<rect
1135
+ x=${u}
1136
+ y=${_}
1137
+ width=${g - u}
1138
+ height=${$ - _}
1139
+ />`;
1140
+ }
1141
+ })}
1142
+ </clippath>
1143
+ ` : f}
1144
+
1145
+ <image
1146
+ id="image"
1147
+ href=${s.uri}
1148
+ clip-path="url(#clip-page-${o})"
1149
+ width=${n}
1150
+ height=${h}
1151
+ />
1152
+
1153
+ ${(e = this.items) == null ? void 0 : e.flatMap(
1154
+ (l) => (l.prov ?? []).filter((p) => p.page_no === o).map((p) => {
1155
+ var $;
1156
+ const { l: c, r: u, t: g, b: _ } = q(p.bbox, this.page);
1157
+ return st`
1158
+ ${this.layOver(l, p)}
1159
+
1160
+ <rect
1161
+ part=${"item" + (this.itemPart ? " " + this.itemPart(this.page, l) : "")}
1162
+ style=${($ = this.itemStyle) == null ? void 0 : $.call(this, this.page, l)}
1163
+ x=${c}
1164
+ y=${g}
1165
+ width=${u - c}
1166
+ height=${_ - g}
1167
+ vector-effect="non-scaling-stroke"
1168
+ @click=${(rt) => {
1169
+ rt.stopPropagation(), a == null || a(rt, l);
1170
+ }}
1171
+ @mouseenter=${(rt) => {
1172
+ const G = rt.currentTarget.getBoundingClientRect(), Dt = [
1173
+ G.top * window.innerWidth,
1174
+ (window.innerWidth - G.right) * window.innerHeight,
1175
+ (window.innerHeight - G.bottom) * window.innerWidth,
1176
+ G.left * window.innerHeight
1177
+ ], ee = Math.max(...Dt), re = Dt.findIndex((se) => se === ee);
1178
+ this.attachTooltip(l, p, G, re);
1179
+ }}
1180
+ @mouseleave=${() => this.removeTooltip()}
1181
+ />
1182
+ `;
1183
+ })
1184
+ )}
1185
+ </svg>
1186
+
1187
+ ${this.renderTrace()}
1188
+ ${this.pagenumbers ? m`<header
1189
+ part="page-number-top"
1190
+ class="page-number-top"
1191
+ title="Page ${o}"
1192
+ >
1193
+ ${o}
1194
+ </header>
1195
+
1196
+ <header
1197
+ part="page-number-bottom"
1198
+ class="page-number-bottom"
1199
+ title="Page ${o}"
1200
+ >
1201
+ ${o}
1202
+ </header>` : f}
1203
+ </div>
1204
+ `;
1205
+ } else
1206
+ return m`Invalid page image.`;
1207
+ }
1208
+ layOver(i, t) {
1209
+ var e;
1210
+ if ((e = this.overlay) != null && e.canDrawItem(i)) {
1211
+ const s = this.overlay.cloneNode(!0);
1212
+ s.item = i, s.page = this.page, s.prov = t;
1213
+ const { l: r, r: o, t: n, b: h } = q(t.bbox, this.page), a = I.PictureItem(i) ? "softOverlay" : "hardOverlay";
1214
+ return st`<foreignObject part="overlay" class=${a} x=${r} y=${n} width=${o - r} height=${h - n}>${s}</foreignObject>`;
1215
+ }
1216
+ }
1217
+ attachTooltip(i, t, e, s) {
1218
+ var r;
1219
+ if ((r = this.tooltip) != null && r.canDrawItem(i)) {
1220
+ const o = this.tooltip.cloneNode(!0);
1221
+ o.id = "tooltip", o.setAttribute("part", "tooltip"), o.className = "tooltip", o.setAttribute(
1222
+ "style",
1223
+ `
1224
+ ${s === 1 ? `left: ${e.right}px` : s === 3 ? `right: ${window.outerWidth - e.left}px` : `left: calc(${e.left}px - 2rem)`};
1225
+ ${s === 0 ? `bottom: ${window.innerHeight - e.top}px` : s === 2 ? `top: ${e.bottom}px` : `top: calc(${e.top}px - 2rem)`};
1226
+ max-width: ${2 * Math.max(t.bbox.r - t.bbox.l, 200)}px;
1227
+ `
1228
+ ), o.item = i, o.page = this.page, this.renderRoot.appendChild(o);
1229
+ }
1230
+ }
1231
+ removeTooltip() {
1232
+ var i;
1233
+ (i = this.renderRoot.querySelector("#tooltip")) == null || i.remove();
1234
+ }
1235
+ renderTrace() {
1236
+ if (this.trace) {
1237
+ const i = this.trace.cloneNode(!0);
1238
+ return i.page = this.page, i.items = this.items, i;
1239
+ }
1240
+ }
1241
+ };
1242
+ y.styles = O`
1243
+ .page {
1244
+ position: relative;
1245
+ width: fit-content;
1246
+ color: black;
1247
+ }
1248
+
1249
+ .base {
1250
+ max-width: 100%;
1251
+ }
1252
+
1253
+ svg:not(.base) {
1254
+ position: absolute;
1255
+ inset: 0;
1256
+ }
1257
+
1258
+ .backdrop {
1259
+ opacity: 0.3;
1260
+ }
1261
+
1262
+ .page-number-top,
1263
+ .page-number-bottom {
1264
+ position: absolute;
1265
+ left: 0;
1266
+ width: fit-content;
1267
+ padding: 0 0.25rem;
1268
+
1269
+ font-size: 0.75rem;
1270
+ line-height: 1rem;
1271
+ color: rgb(120, 120, 120);
1272
+ mix-blend-mode: difference;
1273
+ }
1274
+
1275
+ .page-number-top {
1276
+ top: 0;
1277
+ }
1278
+
1279
+ .page-number-bottom {
1280
+ bottom: 0;
1281
+ }
1282
+
1283
+ rect {
1284
+ fill: blue;
1285
+ fill-opacity: 0.0001; /* To activate hover. */
1286
+ stroke: grey;
1287
+ stroke-width: 1px;
1288
+ stroke-dasharray: 1;
1289
+ cursor: pointer;
1290
+ }
1291
+
1292
+ rect:hover {
1293
+ fill-opacity: 0.1;
1294
+ stroke: blue;
1295
+ }
1296
+
1297
+ rect:target {
1298
+ stroke: blue;
1299
+ stroke-width: 3px;
1300
+ stroke-dasharray: none;
1301
+ }
1302
+
1303
+ .hardOverlay,
1304
+ .softOverlay {
1305
+ font-size: 62.5%;
1306
+ background-color: white;
1307
+ }
1308
+
1309
+ .softOverlay {
1310
+ opacity: 0.9;
1311
+ }
1312
+
1313
+ .tooltip {
1314
+ position: fixed;
1315
+ z-index: 100;
1316
+ padding: 1rem;
1317
+ margin: 1rem;
1318
+
1319
+ background: white;
1320
+ border: 1px solid rgb(230, 230, 230);
1321
+ box-shadow: 0 0.5rem 1rem 0 rgba(0, 0, 0, 0.2);
1322
+ }
1323
+ `;
1324
+ P([
1325
+ d({ type: Object })
1326
+ ], y.prototype, "page", 2);
1327
+ P([
1328
+ d({ type: Array })
1329
+ ], y.prototype, "items", 2);
1330
+ P([
1331
+ d({ type: Boolean })
1332
+ ], y.prototype, "pagenumbers", 2);
1333
+ P([
1334
+ d()
1335
+ ], y.prototype, "itemPart", 2);
1336
+ P([
1337
+ d()
1338
+ ], y.prototype, "itemStyle", 2);
1339
+ P([
1340
+ d()
1341
+ ], y.prototype, "onClickItem", 2);
1342
+ P([
1343
+ d({ type: Boolean })
1344
+ ], y.prototype, "backdrop", 2);
1345
+ P([
1346
+ d({ type: Object })
1347
+ ], y.prototype, "overlay", 2);
1348
+ P([
1349
+ d({ type: Object })
1350
+ ], y.prototype, "tooltip", 2);
1351
+ P([
1352
+ d({ type: Object })
1353
+ ], y.prototype, "trace", 2);
1354
+ y = P([
1355
+ v("docling-img-page")
1356
+ ], y);
1357
+ /**
1358
+ * @license
1359
+ * Copyright 2017 Google LLC
1360
+ * SPDX-License-Identifier: BSD-3-Clause
1361
+ */
1362
+ const qe = Symbol();
1363
+ class Qt {
1364
+ get taskComplete() {
1365
+ return this.t || (this.i === 1 ? this.t = new Promise((t, e) => {
1366
+ this.o = t, this.h = e;
1367
+ }) : this.i === 3 ? this.t = Promise.reject(this.l) : this.t = Promise.resolve(this.u)), this.t;
1368
+ }
1369
+ constructor(t, e, s) {
1370
+ var o;
1371
+ this.p = 0, this.i = 0, (this._ = t).addController(this);
1372
+ const r = typeof e == "object" ? e : { task: e, args: s };
1373
+ this.v = r.task, this.j = r.args, this.m = r.argsEqual ?? We, this.k = r.onComplete, this.A = r.onError, this.autoRun = r.autoRun ?? !0, "initialValue" in r && (this.u = r.initialValue, this.i = 2, this.O = (o = this.T) == null ? void 0 : o.call(this));
1374
+ }
1375
+ hostUpdate() {
1376
+ this.autoRun === !0 && this.S();
1377
+ }
1378
+ hostUpdated() {
1379
+ this.autoRun === "afterUpdate" && this.S();
1380
+ }
1381
+ T() {
1382
+ if (this.j === void 0) return;
1383
+ const t = this.j();
1384
+ if (!Array.isArray(t)) throw Error("The args function must return an array");
1385
+ return t;
1386
+ }
1387
+ async S() {
1388
+ const t = this.T(), e = this.O;
1389
+ this.O = t, t === e || t === void 0 || e !== void 0 && this.m(e, t) || await this.run(t);
1390
+ }
1391
+ async run(t) {
1392
+ var n, h, a, l, p;
1393
+ let e, s;
1394
+ t ?? (t = this.T()), this.O = t, this.i === 1 ? (n = this.q) == null || n.abort() : (this.t = void 0, this.o = void 0, this.h = void 0), this.i = 1, this.autoRun === "afterUpdate" ? queueMicrotask(() => this._.requestUpdate()) : this._.requestUpdate();
1395
+ const r = ++this.p;
1396
+ this.q = new AbortController();
1397
+ let o = !1;
1398
+ try {
1399
+ e = await this.v(t, { signal: this.q.signal });
1400
+ } catch (c) {
1401
+ o = !0, s = c;
1402
+ }
1403
+ if (this.p === r) {
1404
+ if (e === qe) this.i = 0;
1405
+ else {
1406
+ if (o === !1) {
1407
+ try {
1408
+ (h = this.k) == null || h.call(this, e);
1409
+ } catch {
1410
+ }
1411
+ this.i = 2, (a = this.o) == null || a.call(this, e);
1412
+ } else {
1413
+ try {
1414
+ (l = this.A) == null || l.call(this, s);
1415
+ } catch {
1416
+ }
1417
+ this.i = 3, (p = this.h) == null || p.call(this, s);
1418
+ }
1419
+ this.u = e, this.l = s;
1420
+ }
1421
+ this._.requestUpdate();
1422
+ }
1423
+ }
1424
+ abort(t) {
1425
+ var e;
1426
+ this.i === 1 && ((e = this.q) == null || e.abort(t));
1427
+ }
1428
+ get value() {
1429
+ return this.u;
1430
+ }
1431
+ get error() {
1432
+ return this.l;
1433
+ }
1434
+ get status() {
1435
+ return this.i;
1436
+ }
1437
+ render(t) {
1438
+ var e, s, r, o;
1439
+ switch (this.i) {
1440
+ case 0:
1441
+ return (e = t.initial) == null ? void 0 : e.call(t);
1442
+ case 1:
1443
+ return (s = t.pending) == null ? void 0 : s.call(t);
1444
+ case 2:
1445
+ return (r = t.complete) == null ? void 0 : r.call(t, this.value);
1446
+ case 3:
1447
+ return (o = t.error) == null ? void 0 : o.call(t, this.error);
1448
+ default:
1449
+ throw Error("Unexpected status: " + this.i);
1450
+ }
1451
+ }
1452
+ }
1453
+ const We = (i, t) => i === t || i.length === t.length && i.every((e, s) => !ct(e, t[s]));
1454
+ function Ve(i) {
1455
+ return Object.values((i == null ? void 0 : i.pages) ?? {}).sort(
1456
+ (t, e) => t.page_no - e.page_no
1457
+ );
1458
+ }
1459
+ async function te(i, t = {}) {
1460
+ var a, l, p;
1461
+ let e;
1462
+ typeof i == "string" ? e = await (await fetch(i)).json() : typeof i == "object" && b.Document(i) && (e = i);
1463
+ const s = Ve(e), r = Array.from(
1464
+ xe(e, { traversePictures: !0 })
1465
+ ).map(([c]) => c);
1466
+ let o = r;
1467
+ const n = /* @__PURE__ */ new Set();
1468
+ if (typeof t.items == "string") {
1469
+ const c = new Set(
1470
+ t.items.split(",").map((u) => u.trim()).filter((u) => u.length > 0)
1471
+ );
1472
+ if (c.size > 0) {
1473
+ o = [];
1474
+ for (const u of r) {
1475
+ const g = u.self_ref.split("/"), _ = [];
1476
+ for (let $ = 2; $ < g.length + 1; $++)
1477
+ _.push(g.slice(0, $).join("/"));
1478
+ (a = u.prov) == null || a.forEach(($) => _.push(`#/pages/${$.page_no}`)), _.some(($) => c.has($)) ? o.push(u) : (l = u.prov) == null || l.forEach(($) => n.add($.page_no));
1479
+ }
1480
+ }
1481
+ } else if (Array.isArray(t.items)) {
1482
+ o = [];
1483
+ const c = new Set(t.items);
1484
+ for (const u of r)
1485
+ c.has(u) ? o.push(u) : (p = u.prov) == null || p.forEach((g) => n.add(g.page_no));
1486
+ }
1487
+ const h = {};
1488
+ for (const c of s)
1489
+ h[c.page_no] = [];
1490
+ for (const c of o)
1491
+ for (const u of c.prov ?? [])
1492
+ h[u.page_no].at(-1) !== c && h[u.page_no].push(c);
1493
+ return s.map((c) => ({
1494
+ page: c,
1495
+ items: h[c.page_no],
1496
+ trimmed: n.has(c.page_no)
1497
+ }));
1498
+ }
1499
+ var Fe = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, It = (i, t, e, s) => {
1500
+ for (var r = s > 1 ? void 0 : s ? Ge(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1501
+ (n = i[o]) && (r = (s ? n(t, e, r) : n(r)) || r);
1502
+ return s && r && Fe(t, e, r), r;
1503
+ };
1504
+ let F = class extends A {
1505
+ render() {
1506
+ if (this.page && this.items && this.items.length > 0) {
1507
+ const { page_no: i, size: t } = this.page, { width: e = 1, height: s = 1 } = t, r = this.items.map((n) => {
1508
+ var a, l;
1509
+ const h = q((l = (a = n.prov) == null ? void 0 : a.find((p) => p.page_no === i)) == null ? void 0 : l.bbox, this.page);
1510
+ return [
1511
+ (h.l + h.r) / 2,
1512
+ (h.t + h.b) / 2
1513
+ ];
1514
+ }), o = `M${r[0][0]} 0 ${r.slice(0).map((n) => `L${n[0]} ${n[1]}`)} L${r.at(-1)[0]} ${s}`;
1515
+ return m`<svg viewBox="0 0 ${e} ${s}">
1516
+ <marker
1517
+ id="arrow"
1518
+ viewBox="0 0 10 10"
1519
+ refX="0"
1520
+ refY="5"
1521
+ markerWidth="4"
1522
+ markerHeight="4"
1523
+ orient="auto"
1524
+ >
1525
+ <path d="M 0 0 L 10 5 L 0 10" />
1526
+ </marker>
1527
+
1528
+ <path
1529
+ class="halo"
1530
+ vector-effect="non-scaling-stroke"
1531
+ d=${o}
1532
+ marker-start="url(#arrow)"
1533
+ />
1534
+
1535
+ <path
1536
+ class="trace"
1537
+ vector-effect="non-scaling-stroke"
1538
+ d=${o}
1539
+ marker-start="url(#arrow)"
1540
+ />
1541
+ </svg>`;
1542
+ }
1543
+ }
1544
+ };
1545
+ F.styles = O`
1546
+ svg {
1547
+ position: absolute;
1548
+ inset: 0;
1549
+ pointer-events: none;
1550
+ }
1551
+
1552
+ .halo {
1553
+ fill: none;
1554
+ stroke-width: 5px;
1555
+ stroke: white;
1556
+ stroke-linejoin: round;
1557
+ }
1558
+
1559
+ .trace {
1560
+ fill: none;
1561
+ stroke-width: 3px;
1562
+ stroke: rgba(0, 0, 255);
1563
+ stroke-linejoin: round;
1564
+ }
1565
+
1566
+ marker > path {
1567
+ fill: rgba(0, 0, 255);
1568
+ stroke: none;
1569
+ }
1570
+ `;
1571
+ It([
1572
+ d({ type: Object })
1573
+ ], F.prototype, "page", 2);
1574
+ It([
1575
+ d({ type: Array })
1576
+ ], F.prototype, "items", 2);
1577
+ F = It([
1578
+ v("docling-trace")
1579
+ ], F);
1580
+ var Ke = Object.defineProperty, Je = Object.getOwnPropertyDescriptor, E = (i, t, e, s) => {
1581
+ for (var r = s > 1 ? void 0 : s ? Je(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1582
+ (n = i[o]) && (r = (s ? n(t, e, r) : n(r)) || r);
1583
+ return s && r && Ke(t, e, r), r;
1584
+ };
1585
+ let w = class extends A {
1586
+ constructor() {
1587
+ super(...arguments), this.src = "", this.trim = "pages", this.fetchTask = new Qt(this, {
1588
+ task: async ([i, t]) => te(i, { items: t }),
1589
+ args: () => [this.src, this.items]
1590
+ });
1591
+ }
1592
+ render() {
1593
+ const i = Array.from(this.childNodes);
1594
+ return this.fetchTask.render({
1595
+ pending: () => m`<p>...</p>`,
1596
+ complete: (t) => m`
1597
+ ${t.filter((e) => !this.trim || e.items.length > 0).map(
1598
+ ({ page: e, items: s }) => m`<docling-img-page
1599
+ part="page"
1600
+ .page=${e}
1601
+ .items=${s}
1602
+ .pagenumbers=${this.pagenumbers !== void 0}
1603
+ .itemPart=${this.itemPart}
1604
+ .itemStyle=${this.itemStyle}
1605
+ .onClickItem=${this.onClickItem}
1606
+ .backdrop=${this.backdrop !== void 0}
1607
+ .overlay=${i.find((r) => r instanceof wt)}
1608
+ .tooltip=${i.find((r) => r instanceof At)}
1609
+ .trace=${i.find((r) => r instanceof F)}
1610
+ />`
1611
+ )}
1612
+ `
1613
+ });
1614
+ }
1615
+ };
1616
+ w.styles = O`
1617
+ :host {
1618
+ width: fit-content;
1619
+
1620
+ display: flex;
1621
+ flex-direction: column;
1622
+ align-items: center;
1623
+ gap: 2px;
1624
+
1625
+ color: black;
1626
+ }
1627
+ `;
1628
+ E([
1629
+ d()
1630
+ ], w.prototype, "alt", 2);
1631
+ E([
1632
+ d()
1633
+ ], w.prototype, "backdrop", 2);
1634
+ E([
1635
+ d()
1636
+ ], w.prototype, "items", 2);
1637
+ E([
1638
+ d({ type: Boolean })
1639
+ ], w.prototype, "pagenumbers", 2);
1640
+ E([
1641
+ d()
1642
+ ], w.prototype, "src", 2);
1643
+ E([
1644
+ d()
1645
+ ], w.prototype, "trim", 2);
1646
+ E([
1647
+ d()
1648
+ ], w.prototype, "itemPart", 2);
1649
+ E([
1650
+ d()
1651
+ ], w.prototype, "itemStyle", 2);
1652
+ E([
1653
+ d()
1654
+ ], w.prototype, "onClickItem", 2);
1655
+ w = E([
1656
+ v("docling-img")
1657
+ ], w);
1658
+ /**
1659
+ * @license
1660
+ * Copyright 2018 Google LLC
1661
+ * SPDX-License-Identifier: BSD-3-Clause
1662
+ */
1663
+ const Ze = (i) => i ?? f;
1664
+ var Xe = Object.defineProperty, Ye = Object.getOwnPropertyDescriptor, k = (i, t, e, s) => {
1665
+ for (var r = s > 1 ? void 0 : s ? Ye(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1666
+ (n = i[o]) && (r = (s ? n(t, e, r) : n(r)) || r);
1667
+ return s && r && Xe(t, e, r), r;
1668
+ };
1669
+ let x = class extends A {
1670
+ constructor() {
1671
+ super(...arguments), this.columns = [];
1672
+ }
1673
+ render() {
1674
+ var i, t, e, s, r, o, n;
1675
+ return m`
1676
+ ${this.pagenumbers ? m`
1677
+ <tr>
1678
+ <td
1679
+ part="page-number-top"
1680
+ class="page-number"
1681
+ title="Page ${(i = this.page) == null ? void 0 : i.page_no}"
1682
+ colspan=${((t = this.columns) == null ? void 0 : t.length) ?? 1}
1683
+ >
1684
+ ${(e = this.page) == null ? void 0 : e.page_no}
1685
+ </td>
1686
+ </tr>
1687
+ ` : f}
1688
+ ${(s = this.items) == null ? void 0 : s.map(
1689
+ (h) => {
1690
+ var a;
1691
+ return m`<tr
1692
+ part=${"item" + (this.itemPart ? " " + this.itemPart(this.page, h) : "")}
1693
+ style=${Ze((a = this.itemStyle) == null ? void 0 : a.call(this, this.page, h))}
1694
+ >
1695
+ ${this.columns.map((l) => {
1696
+ const p = l.cloneNode(!0);
1697
+ return p.item = h, p.page = this.page, m`
1698
+ <td
1699
+ @onclick=${(c) => {
1700
+ var u;
1701
+ return (u = this.onClickItem) == null ? void 0 : u.call(this, c, this.page, h);
1702
+ }}
1703
+ >
1704
+ ${p}
1705
+ </td>
1706
+ `;
1707
+ })}
1708
+ </tr>`;
1709
+ }
1710
+ )}
1711
+ ${this.pagenumbers ? m`<tr>
1712
+ <td
1713
+ part="page-number-bottom"
1714
+ class="page-number"
1715
+ title="Page ${(r = this.page) == null ? void 0 : r.page_no}"
1716
+ colspan=${((o = this.columns) == null ? void 0 : o.length) ?? 1}
1717
+ >
1718
+ ${(n = this.page) == null ? void 0 : n.page_no}
1719
+ </td>
1720
+ </tr>` : f}
1721
+ `;
1722
+ }
1723
+ };
1724
+ x.styles = O`
1725
+ :host {
1726
+ display: table-row-group;
1727
+ }
1728
+
1729
+ tbody {
1730
+ border-bottom: 1px solid rgb(220, 220, 220);
1731
+ }
1732
+
1733
+ .page-number {
1734
+ padding: 0.25rem;
1735
+
1736
+ background-color: white;
1737
+ color: rgb(120, 120, 120);
1738
+ font-size: 0.75rem;
1739
+ line-height: 1rem;
1740
+ }
1741
+
1742
+ tr {
1743
+ cursor: pointer;
1744
+ }
1745
+
1746
+ tr:not(:nth-last-child(2)) {
1747
+ border-bottom: 1px dotted rgb(220, 220, 220);
1748
+ }
1749
+
1750
+ td {
1751
+ padding: 1rem;
1752
+ background-color: white;
1753
+ vertical-align: top;
1754
+ }
1755
+
1756
+ tr:hover td {
1757
+ filter: brightness(95%);
1758
+ }
1759
+ `;
1760
+ k([
1761
+ d({ type: Object })
1762
+ ], x.prototype, "page", 2);
1763
+ k([
1764
+ d({ type: Array })
1765
+ ], x.prototype, "items", 2);
1766
+ k([
1767
+ d({ type: Array })
1768
+ ], x.prototype, "columns", 2);
1769
+ k([
1770
+ d({ type: Boolean })
1771
+ ], x.prototype, "pagenumbers", 2);
1772
+ k([
1773
+ d()
1774
+ ], x.prototype, "itemPart", 2);
1775
+ k([
1776
+ d()
1777
+ ], x.prototype, "itemStyle", 2);
1778
+ k([
1779
+ d()
1780
+ ], x.prototype, "onClickItem", 2);
1781
+ x = k([
1782
+ v("docling-table-page")
1783
+ ], x);
1784
+ var Qe = Object.getOwnPropertyDescriptor, tr = (i, t, e, s) => {
1785
+ for (var r = s > 1 ? void 0 : s ? Qe(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1786
+ (n = i[o]) && (r = n(r) || r);
1787
+ return r;
1788
+ };
1789
+ let lt = class extends tt {
1790
+ constructor() {
1791
+ super(...arguments), this.type = "column";
1792
+ }
1793
+ };
1794
+ lt = tr([
1795
+ v("docling-column")
1796
+ ], lt);
1797
+ var er = Object.defineProperty, rr = Object.getOwnPropertyDescriptor, U = (i, t, e, s) => {
1798
+ for (var r = s > 1 ? void 0 : s ? rr(t, e) : t, o = i.length - 1, n; o >= 0; o--)
1799
+ (n = i[o]) && (r = (s ? n(t, e, r) : n(r)) || r);
1800
+ return s && r && er(t, e, r), r;
1801
+ };
1802
+ let C = class extends A {
1803
+ constructor() {
1804
+ super(...arguments), this.src = "", this.fetchTask = new Qt(this, {
1805
+ task: async ([i, t]) => te(i, { items: t }),
1806
+ args: () => [this.src, this.items]
1807
+ });
1808
+ }
1809
+ render() {
1810
+ const i = Array.from(this.childNodes).filter(
1811
+ (e) => e.nodeName.toLowerCase().startsWith("docling-column")
1812
+ ), t = i.length > 0 ? i : [new lt(), new lt()];
1813
+ return i.length === 0 && t[1].appendChild(new ht()), this.fetchTask.render({
1814
+ pending: () => m`<p>...</p>`,
1815
+ complete: (e) => m`
1816
+ <table part="pages">
1817
+ ${e.filter((s) => s.items.length > 0).map(
1818
+ ({ page: s, items: r }) => m`<docling-table-page
1819
+ .page=${s}
1820
+ .items=${r}
1821
+ .columns=${t}
1822
+ .pagenumbers=${this.pagenumbers !== void 0}
1823
+ .itemPart=${this.itemPart}
1824
+ .itemStyle=${this.itemStyle}
1825
+ .onClickItem=${this.onClickItem}
1826
+ />`
1827
+ )}
1828
+ </table>
1829
+ `
1830
+ });
1831
+ }
1832
+ };
1833
+ C.styles = O`
1834
+ table {
1835
+ width: 100%;
1836
+ border-collapse: collapse;
1837
+ table-layout: fixed;
1838
+ background-color: white;
1839
+ }
1840
+ `;
1841
+ U([
1842
+ d()
1843
+ ], C.prototype, "alt", 2);
1844
+ U([
1845
+ d()
1846
+ ], C.prototype, "items", 2);
1847
+ U([
1848
+ d({ type: Boolean })
1849
+ ], C.prototype, "pagenumbers", 2);
1850
+ U([
1851
+ d()
1852
+ ], C.prototype, "src", 2);
1853
+ U([
1854
+ d()
1855
+ ], C.prototype, "itemPart", 2);
1856
+ U([
1857
+ d()
1858
+ ], C.prototype, "itemStyle", 2);
1859
+ U([
1860
+ d()
1861
+ ], C.prototype, "onClickItem", 2);
1862
+ C = U([
1863
+ v("docling-table")
1864
+ ], C);
1865
+ export {
1866
+ at as AnnotationPictureClassification,
1867
+ _t as AnnotationPictureDescription,
1868
+ z as DoclingAnnotationElement,
1869
+ D as DoclingItemElement,
1870
+ y as ImgPage,
1871
+ w as ImgPages,
1872
+ F as ImgTrace,
1873
+ wt as ItemOverlay,
1874
+ ht as ItemProvenance,
1875
+ vt as ItemTable,
1876
+ Lt as ItemTemplate,
1877
+ bt as ItemText,
1878
+ At as ItemTooltip,
1879
+ tt as ItemView,
1880
+ x as TablePage,
1881
+ C as TablePages,
1882
+ Vt as customDoclingAnnotationElement,
1883
+ Yt as customDoclingItemElement,
1884
+ q as normalBbox
1885
+ };