@docling/docling-components 0.0.7 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2796 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i5 = decorators.length - 1, decorator; i5 >= 0; i5--)
6
+ if (decorator = decorators[i5])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // node_modules/@lit/reactive-element/node/decorators/custom-element.js
13
+ var t = (t4) => (e4, o6) => {
14
+ void 0 !== o6 ? o6.addInitializer((() => {
15
+ customElements.define(t4, e4);
16
+ })) : customElements.define(t4, e4);
17
+ };
18
+
19
+ // node_modules/@lit-labs/ssr-dom-shim/lib/element-internals.js
20
+ var ElementInternalsShim = class ElementInternals {
21
+ get shadowRoot() {
22
+ return this.__host.__shadowRoot;
23
+ }
24
+ constructor(_host) {
25
+ this.ariaAtomic = "";
26
+ this.ariaAutoComplete = "";
27
+ this.ariaBrailleLabel = "";
28
+ this.ariaBrailleRoleDescription = "";
29
+ this.ariaBusy = "";
30
+ this.ariaChecked = "";
31
+ this.ariaColCount = "";
32
+ this.ariaColIndex = "";
33
+ this.ariaColSpan = "";
34
+ this.ariaCurrent = "";
35
+ this.ariaDescription = "";
36
+ this.ariaDisabled = "";
37
+ this.ariaExpanded = "";
38
+ this.ariaHasPopup = "";
39
+ this.ariaHidden = "";
40
+ this.ariaInvalid = "";
41
+ this.ariaKeyShortcuts = "";
42
+ this.ariaLabel = "";
43
+ this.ariaLevel = "";
44
+ this.ariaLive = "";
45
+ this.ariaModal = "";
46
+ this.ariaMultiLine = "";
47
+ this.ariaMultiSelectable = "";
48
+ this.ariaOrientation = "";
49
+ this.ariaPlaceholder = "";
50
+ this.ariaPosInSet = "";
51
+ this.ariaPressed = "";
52
+ this.ariaReadOnly = "";
53
+ this.ariaRequired = "";
54
+ this.ariaRoleDescription = "";
55
+ this.ariaRowCount = "";
56
+ this.ariaRowIndex = "";
57
+ this.ariaRowSpan = "";
58
+ this.ariaSelected = "";
59
+ this.ariaSetSize = "";
60
+ this.ariaSort = "";
61
+ this.ariaValueMax = "";
62
+ this.ariaValueMin = "";
63
+ this.ariaValueNow = "";
64
+ this.ariaValueText = "";
65
+ this.role = "";
66
+ this.form = null;
67
+ this.labels = [];
68
+ this.states = /* @__PURE__ */ new Set();
69
+ this.validationMessage = "";
70
+ this.validity = {};
71
+ this.willValidate = true;
72
+ this.__host = _host;
73
+ }
74
+ checkValidity() {
75
+ console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true.");
76
+ return true;
77
+ }
78
+ reportValidity() {
79
+ return true;
80
+ }
81
+ setFormValue() {
82
+ }
83
+ setValidity() {
84
+ }
85
+ };
86
+
87
+ // node_modules/@lit-labs/ssr-dom-shim/lib/events.js
88
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f3) {
89
+ if (kind === "m") throw new TypeError("Private method is not writable");
90
+ if (kind === "a" && !f3) throw new TypeError("Private accessor was defined without a setter");
91
+ if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
92
+ return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value : state.set(receiver, value), value;
93
+ };
94
+ var __classPrivateFieldGet = function(receiver, state, kind, f3) {
95
+ if (kind === "a" && !f3) throw new TypeError("Private accessor was defined without a getter");
96
+ if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
97
+ return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value : state.get(receiver);
98
+ };
99
+ var _Event_cancelable;
100
+ var _Event_bubbles;
101
+ var _Event_composed;
102
+ var _Event_defaultPrevented;
103
+ var _Event_timestamp;
104
+ var _Event_propagationStopped;
105
+ var _Event_type;
106
+ var _Event_target;
107
+ var _Event_isBeingDispatched;
108
+ var _a;
109
+ var _CustomEvent_detail;
110
+ var _b;
111
+ var isCaptureEventListener = (options) => typeof options === "boolean" ? options : options?.capture ?? false;
112
+ var NONE = 0;
113
+ var CAPTURING_PHASE = 1;
114
+ var AT_TARGET = 2;
115
+ var BUBBLING_PHASE = 3;
116
+ var EventTargetShim = class EventTarget {
117
+ constructor() {
118
+ this.__eventListeners = /* @__PURE__ */ new Map();
119
+ this.__captureEventListeners = /* @__PURE__ */ new Map();
120
+ }
121
+ addEventListener(type, callback, options) {
122
+ if (callback === void 0 || callback === null) {
123
+ return;
124
+ }
125
+ const eventListenersMap = isCaptureEventListener(options) ? this.__captureEventListeners : this.__eventListeners;
126
+ let eventListeners = eventListenersMap.get(type);
127
+ if (eventListeners === void 0) {
128
+ eventListeners = /* @__PURE__ */ new Map();
129
+ eventListenersMap.set(type, eventListeners);
130
+ } else if (eventListeners.has(callback)) {
131
+ return;
132
+ }
133
+ const normalizedOptions = typeof options === "object" && options ? options : {};
134
+ normalizedOptions.signal?.addEventListener("abort", () => this.removeEventListener(type, callback, options));
135
+ eventListeners.set(callback, normalizedOptions ?? {});
136
+ }
137
+ removeEventListener(type, callback, options) {
138
+ if (callback === void 0 || callback === null) {
139
+ return;
140
+ }
141
+ const eventListenersMap = isCaptureEventListener(options) ? this.__captureEventListeners : this.__eventListeners;
142
+ const eventListeners = eventListenersMap.get(type);
143
+ if (eventListeners !== void 0) {
144
+ eventListeners.delete(callback);
145
+ if (!eventListeners.size) {
146
+ eventListenersMap.delete(type);
147
+ }
148
+ }
149
+ }
150
+ dispatchEvent(event) {
151
+ const composedPath = [this];
152
+ let parent = this.__eventTargetParent;
153
+ if (event.composed) {
154
+ while (parent) {
155
+ composedPath.push(parent);
156
+ parent = parent.__eventTargetParent;
157
+ }
158
+ } else {
159
+ while (parent && parent !== this.__host) {
160
+ composedPath.push(parent);
161
+ parent = parent.__eventTargetParent;
162
+ }
163
+ }
164
+ let stopPropagation = false;
165
+ let stopImmediatePropagation = false;
166
+ let eventPhase = NONE;
167
+ let target = null;
168
+ let tmpTarget = null;
169
+ let currentTarget = null;
170
+ const originalStopPropagation = event.stopPropagation;
171
+ const originalStopImmediatePropagation = event.stopImmediatePropagation;
172
+ Object.defineProperties(event, {
173
+ target: {
174
+ get() {
175
+ return target ?? tmpTarget;
176
+ },
177
+ ...enumerableProperty
178
+ },
179
+ srcElement: {
180
+ get() {
181
+ return event.target;
182
+ },
183
+ ...enumerableProperty
184
+ },
185
+ currentTarget: {
186
+ get() {
187
+ return currentTarget;
188
+ },
189
+ ...enumerableProperty
190
+ },
191
+ eventPhase: {
192
+ get() {
193
+ return eventPhase;
194
+ },
195
+ ...enumerableProperty
196
+ },
197
+ composedPath: {
198
+ value: () => composedPath,
199
+ ...enumerableProperty
200
+ },
201
+ stopPropagation: {
202
+ value: () => {
203
+ stopPropagation = true;
204
+ originalStopPropagation.call(event);
205
+ },
206
+ ...enumerableProperty
207
+ },
208
+ stopImmediatePropagation: {
209
+ value: () => {
210
+ stopImmediatePropagation = true;
211
+ originalStopImmediatePropagation.call(event);
212
+ },
213
+ ...enumerableProperty
214
+ }
215
+ });
216
+ const invokeEventListener = (listener, options, eventListenerMap) => {
217
+ if (typeof listener === "function") {
218
+ listener(event);
219
+ } else if (typeof listener?.handleEvent === "function") {
220
+ listener.handleEvent(event);
221
+ }
222
+ if (options.once) {
223
+ eventListenerMap.delete(listener);
224
+ }
225
+ };
226
+ const finishDispatch = () => {
227
+ currentTarget = null;
228
+ eventPhase = NONE;
229
+ return !event.defaultPrevented;
230
+ };
231
+ const captureEventPath = composedPath.slice().reverse();
232
+ target = !this.__host || !event.composed ? this : null;
233
+ const retarget = (eventTargets) => {
234
+ tmpTarget = this;
235
+ while (tmpTarget.__host && eventTargets.includes(tmpTarget.__host)) {
236
+ tmpTarget = tmpTarget.__host;
237
+ }
238
+ };
239
+ for (const eventTarget of captureEventPath) {
240
+ if (!target && (!tmpTarget || tmpTarget === eventTarget.__host)) {
241
+ retarget(captureEventPath.slice(captureEventPath.indexOf(eventTarget)));
242
+ }
243
+ currentTarget = eventTarget;
244
+ eventPhase = eventTarget === event.target ? AT_TARGET : CAPTURING_PHASE;
245
+ const captureEventListeners = eventTarget.__captureEventListeners.get(event.type);
246
+ if (captureEventListeners) {
247
+ for (const [listener, options] of captureEventListeners) {
248
+ invokeEventListener(listener, options, captureEventListeners);
249
+ if (stopImmediatePropagation) {
250
+ return finishDispatch();
251
+ }
252
+ }
253
+ }
254
+ if (stopPropagation) {
255
+ return finishDispatch();
256
+ }
257
+ }
258
+ const bubbleEventPath = event.bubbles ? composedPath : [this];
259
+ tmpTarget = null;
260
+ for (const eventTarget of bubbleEventPath) {
261
+ if (!target && (!tmpTarget || eventTarget === tmpTarget.__host)) {
262
+ retarget(bubbleEventPath.slice(0, bubbleEventPath.indexOf(eventTarget) + 1));
263
+ }
264
+ currentTarget = eventTarget;
265
+ eventPhase = eventTarget === event.target ? AT_TARGET : BUBBLING_PHASE;
266
+ const captureEventListeners = eventTarget.__eventListeners.get(event.type);
267
+ if (captureEventListeners) {
268
+ for (const [listener, options] of captureEventListeners) {
269
+ invokeEventListener(listener, options, captureEventListeners);
270
+ if (stopImmediatePropagation) {
271
+ return finishDispatch();
272
+ }
273
+ }
274
+ }
275
+ if (stopPropagation) {
276
+ return finishDispatch();
277
+ }
278
+ }
279
+ return finishDispatch();
280
+ }
281
+ };
282
+ var EventTargetShimWithRealType = EventTargetShim;
283
+ var enumerableProperty = { __proto__: null };
284
+ enumerableProperty.enumerable = true;
285
+ Object.freeze(enumerableProperty);
286
+ var EventShim = (_a = class Event {
287
+ constructor(type, options = {}) {
288
+ _Event_cancelable.set(this, false);
289
+ _Event_bubbles.set(this, false);
290
+ _Event_composed.set(this, false);
291
+ _Event_defaultPrevented.set(this, false);
292
+ _Event_timestamp.set(this, Date.now());
293
+ _Event_propagationStopped.set(this, false);
294
+ _Event_type.set(this, void 0);
295
+ _Event_target.set(this, void 0);
296
+ _Event_isBeingDispatched.set(this, void 0);
297
+ this.NONE = NONE;
298
+ this.CAPTURING_PHASE = CAPTURING_PHASE;
299
+ this.AT_TARGET = AT_TARGET;
300
+ this.BUBBLING_PHASE = BUBBLING_PHASE;
301
+ if (arguments.length === 0)
302
+ throw new Error(`The type argument must be specified`);
303
+ if (typeof options !== "object" || !options) {
304
+ throw new Error(`The "options" argument must be an object`);
305
+ }
306
+ const { bubbles, cancelable, composed } = options;
307
+ __classPrivateFieldSet(this, _Event_cancelable, !!cancelable, "f");
308
+ __classPrivateFieldSet(this, _Event_bubbles, !!bubbles, "f");
309
+ __classPrivateFieldSet(this, _Event_composed, !!composed, "f");
310
+ __classPrivateFieldSet(this, _Event_type, `${type}`, "f");
311
+ __classPrivateFieldSet(this, _Event_target, null, "f");
312
+ __classPrivateFieldSet(this, _Event_isBeingDispatched, false, "f");
313
+ }
314
+ initEvent(_type, _bubbles, _cancelable) {
315
+ throw new Error("Method not implemented.");
316
+ }
317
+ stopImmediatePropagation() {
318
+ this.stopPropagation();
319
+ }
320
+ preventDefault() {
321
+ __classPrivateFieldSet(this, _Event_defaultPrevented, true, "f");
322
+ }
323
+ get target() {
324
+ return __classPrivateFieldGet(this, _Event_target, "f");
325
+ }
326
+ get currentTarget() {
327
+ return __classPrivateFieldGet(this, _Event_target, "f");
328
+ }
329
+ get srcElement() {
330
+ return __classPrivateFieldGet(this, _Event_target, "f");
331
+ }
332
+ get type() {
333
+ return __classPrivateFieldGet(this, _Event_type, "f");
334
+ }
335
+ get cancelable() {
336
+ return __classPrivateFieldGet(this, _Event_cancelable, "f");
337
+ }
338
+ get defaultPrevented() {
339
+ return __classPrivateFieldGet(this, _Event_cancelable, "f") && __classPrivateFieldGet(this, _Event_defaultPrevented, "f");
340
+ }
341
+ get timeStamp() {
342
+ return __classPrivateFieldGet(this, _Event_timestamp, "f");
343
+ }
344
+ composedPath() {
345
+ return __classPrivateFieldGet(this, _Event_isBeingDispatched, "f") ? [__classPrivateFieldGet(this, _Event_target, "f")] : [];
346
+ }
347
+ get returnValue() {
348
+ return !__classPrivateFieldGet(this, _Event_cancelable, "f") || !__classPrivateFieldGet(this, _Event_defaultPrevented, "f");
349
+ }
350
+ get bubbles() {
351
+ return __classPrivateFieldGet(this, _Event_bubbles, "f");
352
+ }
353
+ get composed() {
354
+ return __classPrivateFieldGet(this, _Event_composed, "f");
355
+ }
356
+ get eventPhase() {
357
+ return __classPrivateFieldGet(this, _Event_isBeingDispatched, "f") ? _a.AT_TARGET : _a.NONE;
358
+ }
359
+ get cancelBubble() {
360
+ return __classPrivateFieldGet(this, _Event_propagationStopped, "f");
361
+ }
362
+ set cancelBubble(value) {
363
+ if (value) {
364
+ __classPrivateFieldSet(this, _Event_propagationStopped, true, "f");
365
+ }
366
+ }
367
+ stopPropagation() {
368
+ __classPrivateFieldSet(this, _Event_propagationStopped, true, "f");
369
+ }
370
+ get isTrusted() {
371
+ return false;
372
+ }
373
+ }, _Event_cancelable = /* @__PURE__ */ new WeakMap(), _Event_bubbles = /* @__PURE__ */ new WeakMap(), _Event_composed = /* @__PURE__ */ new WeakMap(), _Event_defaultPrevented = /* @__PURE__ */ new WeakMap(), _Event_timestamp = /* @__PURE__ */ new WeakMap(), _Event_propagationStopped = /* @__PURE__ */ new WeakMap(), _Event_type = /* @__PURE__ */ new WeakMap(), _Event_target = /* @__PURE__ */ new WeakMap(), _Event_isBeingDispatched = /* @__PURE__ */ new WeakMap(), _a.NONE = NONE, _a.CAPTURING_PHASE = CAPTURING_PHASE, _a.AT_TARGET = AT_TARGET, _a.BUBBLING_PHASE = BUBBLING_PHASE, _a);
374
+ Object.defineProperties(EventShim.prototype, {
375
+ initEvent: enumerableProperty,
376
+ stopImmediatePropagation: enumerableProperty,
377
+ preventDefault: enumerableProperty,
378
+ target: enumerableProperty,
379
+ currentTarget: enumerableProperty,
380
+ srcElement: enumerableProperty,
381
+ type: enumerableProperty,
382
+ cancelable: enumerableProperty,
383
+ defaultPrevented: enumerableProperty,
384
+ timeStamp: enumerableProperty,
385
+ composedPath: enumerableProperty,
386
+ returnValue: enumerableProperty,
387
+ bubbles: enumerableProperty,
388
+ composed: enumerableProperty,
389
+ eventPhase: enumerableProperty,
390
+ cancelBubble: enumerableProperty,
391
+ stopPropagation: enumerableProperty,
392
+ isTrusted: enumerableProperty
393
+ });
394
+ var CustomEventShim = (_b = class CustomEvent extends EventShim {
395
+ constructor(type, options = {}) {
396
+ super(type, options);
397
+ _CustomEvent_detail.set(this, void 0);
398
+ __classPrivateFieldSet(this, _CustomEvent_detail, options?.detail ?? null, "f");
399
+ }
400
+ initCustomEvent(_type, _bubbles, _cancelable, _detail) {
401
+ throw new Error("Method not implemented.");
402
+ }
403
+ get detail() {
404
+ return __classPrivateFieldGet(this, _CustomEvent_detail, "f");
405
+ }
406
+ }, _CustomEvent_detail = /* @__PURE__ */ new WeakMap(), _b);
407
+ Object.defineProperties(CustomEventShim.prototype, {
408
+ detail: enumerableProperty
409
+ });
410
+ var EventShimWithRealType = EventShim;
411
+ var CustomEventShimWithRealType = CustomEventShim;
412
+
413
+ // node_modules/@lit-labs/ssr-dom-shim/index.js
414
+ globalThis.Event ??= EventShimWithRealType;
415
+ globalThis.CustomEvent ??= CustomEventShimWithRealType;
416
+ var attributes = /* @__PURE__ */ new WeakMap();
417
+ var attributesForElement = (element) => {
418
+ let attrs = attributes.get(element);
419
+ if (attrs === void 0) {
420
+ attributes.set(element, attrs = /* @__PURE__ */ new Map());
421
+ }
422
+ return attrs;
423
+ };
424
+ var ElementShim = class Element extends EventTargetShimWithRealType {
425
+ constructor() {
426
+ super(...arguments);
427
+ this.__shadowRootMode = null;
428
+ this.__shadowRoot = null;
429
+ this.__internals = null;
430
+ }
431
+ get attributes() {
432
+ return Array.from(attributesForElement(this)).map(([name, value]) => ({
433
+ name,
434
+ value
435
+ }));
436
+ }
437
+ get shadowRoot() {
438
+ if (this.__shadowRootMode === "closed") {
439
+ return null;
440
+ }
441
+ return this.__shadowRoot;
442
+ }
443
+ get localName() {
444
+ return this.constructor.__localName;
445
+ }
446
+ get tagName() {
447
+ return this.localName?.toUpperCase();
448
+ }
449
+ setAttribute(name, value) {
450
+ attributesForElement(this).set(name, String(value));
451
+ }
452
+ removeAttribute(name) {
453
+ attributesForElement(this).delete(name);
454
+ }
455
+ toggleAttribute(name, force) {
456
+ if (this.hasAttribute(name)) {
457
+ if (force === void 0 || !force) {
458
+ this.removeAttribute(name);
459
+ return false;
460
+ }
461
+ } else {
462
+ if (force === void 0 || force) {
463
+ this.setAttribute(name, "");
464
+ return true;
465
+ } else {
466
+ return false;
467
+ }
468
+ }
469
+ return true;
470
+ }
471
+ hasAttribute(name) {
472
+ return attributesForElement(this).has(name);
473
+ }
474
+ attachShadow(init) {
475
+ const shadowRoot = { host: this };
476
+ this.__shadowRootMode = init.mode;
477
+ if (init && init.mode === "open") {
478
+ this.__shadowRoot = shadowRoot;
479
+ }
480
+ return shadowRoot;
481
+ }
482
+ attachInternals() {
483
+ if (this.__internals !== null) {
484
+ throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);
485
+ }
486
+ const internals = new ElementInternalsShim(this);
487
+ this.__internals = internals;
488
+ return internals;
489
+ }
490
+ getAttribute(name) {
491
+ const value = attributesForElement(this).get(name);
492
+ return value ?? null;
493
+ }
494
+ };
495
+ var HTMLElementShim = class HTMLElement extends ElementShim {
496
+ };
497
+ var HTMLElementShimWithRealType = HTMLElementShim;
498
+ globalThis.litServerRoot ??= Object.defineProperty(new HTMLElementShimWithRealType(), "localName", {
499
+ // Patch localName (and tagName) to return a unique name.
500
+ get() {
501
+ return "lit-server-root";
502
+ }
503
+ });
504
+ var CustomElementRegistryShim = class CustomElementRegistry {
505
+ constructor() {
506
+ this.__definitions = /* @__PURE__ */ new Map();
507
+ }
508
+ define(name, ctor) {
509
+ if (this.__definitions.has(name)) {
510
+ if (process.env.NODE_ENV === "development") {
511
+ console.warn(`'CustomElementRegistry' already has "${name}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
512
+ Make sure to test your application with a production build as repeat registrations will throw in production.`);
513
+ } else {
514
+ throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${name}" has already been used with this registry`);
515
+ }
516
+ }
517
+ ctor.__localName = name;
518
+ this.__definitions.set(name, {
519
+ ctor,
520
+ // Note it's important we read `observedAttributes` in case it is a getter
521
+ // with side-effects, as is the case in Lit, where it triggers class
522
+ // finalization.
523
+ //
524
+ // TODO(aomarks) To be spec compliant, we should also capture the
525
+ // registration-time lifecycle methods like `connectedCallback`. For them
526
+ // to be actually accessible to e.g. the Lit SSR element renderer, though,
527
+ // we'd need to introduce a new API for accessing them (since `get` only
528
+ // returns the constructor).
529
+ observedAttributes: ctor.observedAttributes ?? []
530
+ });
531
+ }
532
+ get(name) {
533
+ const definition = this.__definitions.get(name);
534
+ return definition?.ctor;
535
+ }
536
+ };
537
+ var CustomElementRegistryShimWithRealType = CustomElementRegistryShim;
538
+ var customElements2 = new CustomElementRegistryShimWithRealType();
539
+
540
+ // node_modules/@lit/reactive-element/node/css-tag.js
541
+ var t2 = globalThis;
542
+ var e = t2.ShadowRoot && (void 0 === t2.ShadyCSS || t2.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
543
+ var s = /* @__PURE__ */ Symbol();
544
+ var o = /* @__PURE__ */ new WeakMap();
545
+ var n = class {
546
+ constructor(t4, e4, o6) {
547
+ if (this._$cssResult$ = true, o6 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
548
+ this.cssText = t4, this.t = e4;
549
+ }
550
+ get styleSheet() {
551
+ let t4 = this.o;
552
+ const s5 = this.t;
553
+ if (e && void 0 === t4) {
554
+ const e4 = void 0 !== s5 && 1 === s5.length;
555
+ e4 && (t4 = o.get(s5)), void 0 === t4 && ((this.o = t4 = new CSSStyleSheet()).replaceSync(this.cssText), e4 && o.set(s5, t4));
556
+ }
557
+ return t4;
558
+ }
559
+ toString() {
560
+ return this.cssText;
561
+ }
562
+ };
563
+ var r = (t4) => new n("string" == typeof t4 ? t4 : t4 + "", void 0, s);
564
+ var i = (t4, ...e4) => {
565
+ const o6 = 1 === t4.length ? t4[0] : e4.reduce(((e5, s5, o7) => e5 + ((t5) => {
566
+ if (true === t5._$cssResult$) return t5.cssText;
567
+ if ("number" == typeof t5) return t5;
568
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + t5 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
569
+ })(s5) + t4[o7 + 1]), t4[0]);
570
+ return new n(o6, t4, s);
571
+ };
572
+ var S = (s5, o6) => {
573
+ if (e) s5.adoptedStyleSheets = o6.map(((t4) => t4 instanceof CSSStyleSheet ? t4 : t4.styleSheet));
574
+ else for (const e4 of o6) {
575
+ const o7 = document.createElement("style"), n5 = t2.litNonce;
576
+ void 0 !== n5 && o7.setAttribute("nonce", n5), o7.textContent = e4.cssText, s5.appendChild(o7);
577
+ }
578
+ };
579
+ var c = e || void 0 === t2.CSSStyleSheet ? (t4) => t4 : (t4) => t4 instanceof CSSStyleSheet ? ((t5) => {
580
+ let e4 = "";
581
+ for (const s5 of t5.cssRules) e4 += s5.cssText;
582
+ return r(e4);
583
+ })(t4) : t4;
584
+
585
+ // node_modules/@lit/reactive-element/node/reactive-element.js
586
+ var { is: h, defineProperty: r2, getOwnPropertyDescriptor: o2, getOwnPropertyNames: n2, getOwnPropertySymbols: a, getPrototypeOf: c2 } = Object;
587
+ var l = globalThis;
588
+ l.customElements ??= customElements2;
589
+ var p = l.trustedTypes;
590
+ var d = p ? p.emptyScript : "";
591
+ var u = l.reactiveElementPolyfillSupport;
592
+ var f = (t4, s5) => t4;
593
+ var b = { toAttribute(t4, s5) {
594
+ switch (s5) {
595
+ case Boolean:
596
+ t4 = t4 ? d : null;
597
+ break;
598
+ case Object:
599
+ case Array:
600
+ t4 = null == t4 ? t4 : JSON.stringify(t4);
601
+ }
602
+ return t4;
603
+ }, fromAttribute(t4, s5) {
604
+ let i5 = t4;
605
+ switch (s5) {
606
+ case Boolean:
607
+ i5 = null !== t4;
608
+ break;
609
+ case Number:
610
+ i5 = null === t4 ? null : Number(t4);
611
+ break;
612
+ case Object:
613
+ case Array:
614
+ try {
615
+ i5 = JSON.parse(t4);
616
+ } catch (t5) {
617
+ i5 = null;
618
+ }
619
+ }
620
+ return i5;
621
+ } };
622
+ var m = (t4, s5) => !h(t4, s5);
623
+ var y = { attribute: true, type: String, converter: b, reflect: false, useDefault: false, hasChanged: m };
624
+ Symbol.metadata ??= /* @__PURE__ */ Symbol("metadata"), l.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
625
+ var g = class extends (globalThis.HTMLElement ?? HTMLElementShimWithRealType) {
626
+ static addInitializer(t4) {
627
+ this._$Ei(), (this.l ??= []).push(t4);
628
+ }
629
+ static get observedAttributes() {
630
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
631
+ }
632
+ static createProperty(t4, s5 = y) {
633
+ if (s5.state && (s5.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t4) && ((s5 = Object.create(s5)).wrapped = true), this.elementProperties.set(t4, s5), !s5.noAccessor) {
634
+ const i5 = /* @__PURE__ */ Symbol(), e4 = this.getPropertyDescriptor(t4, i5, s5);
635
+ void 0 !== e4 && r2(this.prototype, t4, e4);
636
+ }
637
+ }
638
+ static getPropertyDescriptor(t4, s5, i5) {
639
+ const { get: e4, set: h4 } = o2(this.prototype, t4) ?? { get() {
640
+ return this[s5];
641
+ }, set(t5) {
642
+ this[s5] = t5;
643
+ } };
644
+ return { get: e4, set(s6) {
645
+ const r6 = e4?.call(this);
646
+ h4?.call(this, s6), this.requestUpdate(t4, r6, i5);
647
+ }, configurable: true, enumerable: true };
648
+ }
649
+ static getPropertyOptions(t4) {
650
+ return this.elementProperties.get(t4) ?? y;
651
+ }
652
+ static _$Ei() {
653
+ if (this.hasOwnProperty(f("elementProperties"))) return;
654
+ const t4 = c2(this);
655
+ t4.finalize(), void 0 !== t4.l && (this.l = [...t4.l]), this.elementProperties = new Map(t4.elementProperties);
656
+ }
657
+ static finalize() {
658
+ if (this.hasOwnProperty(f("finalized"))) return;
659
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(f("properties"))) {
660
+ const t5 = this.properties, s5 = [...n2(t5), ...a(t5)];
661
+ for (const i5 of s5) this.createProperty(i5, t5[i5]);
662
+ }
663
+ const t4 = this[Symbol.metadata];
664
+ if (null !== t4) {
665
+ const s5 = litPropertyMetadata.get(t4);
666
+ if (void 0 !== s5) for (const [t5, i5] of s5) this.elementProperties.set(t5, i5);
667
+ }
668
+ this._$Eh = /* @__PURE__ */ new Map();
669
+ for (const [t5, s5] of this.elementProperties) {
670
+ const i5 = this._$Eu(t5, s5);
671
+ void 0 !== i5 && this._$Eh.set(i5, t5);
672
+ }
673
+ this.elementStyles = this.finalizeStyles(this.styles);
674
+ }
675
+ static finalizeStyles(t4) {
676
+ const s5 = [];
677
+ if (Array.isArray(t4)) {
678
+ const e4 = new Set(t4.flat(1 / 0).reverse());
679
+ for (const t5 of e4) s5.unshift(c(t5));
680
+ } else void 0 !== t4 && s5.push(c(t4));
681
+ return s5;
682
+ }
683
+ static _$Eu(t4, s5) {
684
+ const i5 = s5.attribute;
685
+ return false === i5 ? void 0 : "string" == typeof i5 ? i5 : "string" == typeof t4 ? t4.toLowerCase() : void 0;
686
+ }
687
+ constructor() {
688
+ super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
689
+ }
690
+ _$Ev() {
691
+ this._$ES = new Promise(((t4) => this.enableUpdating = t4)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t4) => t4(this)));
692
+ }
693
+ addController(t4) {
694
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(t4), void 0 !== this.renderRoot && this.isConnected && t4.hostConnected?.();
695
+ }
696
+ removeController(t4) {
697
+ this._$EO?.delete(t4);
698
+ }
699
+ _$E_() {
700
+ const t4 = /* @__PURE__ */ new Map(), s5 = this.constructor.elementProperties;
701
+ for (const i5 of s5.keys()) this.hasOwnProperty(i5) && (t4.set(i5, this[i5]), delete this[i5]);
702
+ t4.size > 0 && (this._$Ep = t4);
703
+ }
704
+ createRenderRoot() {
705
+ const t4 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
706
+ return S(t4, this.constructor.elementStyles), t4;
707
+ }
708
+ connectedCallback() {
709
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(((t4) => t4.hostConnected?.()));
710
+ }
711
+ enableUpdating(t4) {
712
+ }
713
+ disconnectedCallback() {
714
+ this._$EO?.forEach(((t4) => t4.hostDisconnected?.()));
715
+ }
716
+ attributeChangedCallback(t4, s5, i5) {
717
+ this._$AK(t4, i5);
718
+ }
719
+ _$ET(t4, s5) {
720
+ const i5 = this.constructor.elementProperties.get(t4), e4 = this.constructor._$Eu(t4, i5);
721
+ if (void 0 !== e4 && true === i5.reflect) {
722
+ const h4 = (void 0 !== i5.converter?.toAttribute ? i5.converter : b).toAttribute(s5, i5.type);
723
+ this._$Em = t4, null == h4 ? this.removeAttribute(e4) : this.setAttribute(e4, h4), this._$Em = null;
724
+ }
725
+ }
726
+ _$AK(t4, s5) {
727
+ const i5 = this.constructor, e4 = i5._$Eh.get(t4);
728
+ if (void 0 !== e4 && this._$Em !== e4) {
729
+ const t5 = i5.getPropertyOptions(e4), h4 = "function" == typeof t5.converter ? { fromAttribute: t5.converter } : void 0 !== t5.converter?.fromAttribute ? t5.converter : b;
730
+ this._$Em = e4, this[e4] = h4.fromAttribute(s5, t5.type) ?? this._$Ej?.get(e4) ?? null, this._$Em = null;
731
+ }
732
+ }
733
+ requestUpdate(t4, s5, i5) {
734
+ if (void 0 !== t4) {
735
+ const e4 = this.constructor, h4 = this[t4];
736
+ if (i5 ??= e4.getPropertyOptions(t4), !((i5.hasChanged ?? m)(h4, s5) || i5.useDefault && i5.reflect && h4 === this._$Ej?.get(t4) && !this.hasAttribute(e4._$Eu(t4, i5)))) return;
737
+ this.C(t4, s5, i5);
738
+ }
739
+ false === this.isUpdatePending && (this._$ES = this._$EP());
740
+ }
741
+ C(t4, s5, { useDefault: i5, reflect: e4, wrapped: h4 }, r6) {
742
+ i5 && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t4) && (this._$Ej.set(t4, r6 ?? s5 ?? this[t4]), true !== h4 || void 0 !== r6) || (this._$AL.has(t4) || (this.hasUpdated || i5 || (s5 = void 0), this._$AL.set(t4, s5)), true === e4 && this._$Em !== t4 && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t4));
743
+ }
744
+ async _$EP() {
745
+ this.isUpdatePending = true;
746
+ try {
747
+ await this._$ES;
748
+ } catch (t5) {
749
+ Promise.reject(t5);
750
+ }
751
+ const t4 = this.scheduleUpdate();
752
+ return null != t4 && await t4, !this.isUpdatePending;
753
+ }
754
+ scheduleUpdate() {
755
+ return this.performUpdate();
756
+ }
757
+ performUpdate() {
758
+ if (!this.isUpdatePending) return;
759
+ if (!this.hasUpdated) {
760
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
761
+ for (const [t6, s6] of this._$Ep) this[t6] = s6;
762
+ this._$Ep = void 0;
763
+ }
764
+ const t5 = this.constructor.elementProperties;
765
+ if (t5.size > 0) for (const [s6, i5] of t5) {
766
+ const { wrapped: t6 } = i5, e4 = this[s6];
767
+ true !== t6 || this._$AL.has(s6) || void 0 === e4 || this.C(s6, void 0, i5, e4);
768
+ }
769
+ }
770
+ let t4 = false;
771
+ const s5 = this._$AL;
772
+ try {
773
+ t4 = this.shouldUpdate(s5), t4 ? (this.willUpdate(s5), this._$EO?.forEach(((t5) => t5.hostUpdate?.())), this.update(s5)) : this._$EM();
774
+ } catch (s6) {
775
+ throw t4 = false, this._$EM(), s6;
776
+ }
777
+ t4 && this._$AE(s5);
778
+ }
779
+ willUpdate(t4) {
780
+ }
781
+ _$AE(t4) {
782
+ this._$EO?.forEach(((t5) => t5.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t4)), this.updated(t4);
783
+ }
784
+ _$EM() {
785
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
786
+ }
787
+ get updateComplete() {
788
+ return this.getUpdateComplete();
789
+ }
790
+ getUpdateComplete() {
791
+ return this._$ES;
792
+ }
793
+ shouldUpdate(t4) {
794
+ return true;
795
+ }
796
+ update(t4) {
797
+ this._$Eq &&= this._$Eq.forEach(((t5) => this._$ET(t5, this[t5]))), this._$EM();
798
+ }
799
+ updated(t4) {
800
+ }
801
+ firstUpdated(t4) {
802
+ }
803
+ };
804
+ g.elementStyles = [], g.shadowRootOptions = { mode: "open" }, g[f("elementProperties")] = /* @__PURE__ */ new Map(), g[f("finalized")] = /* @__PURE__ */ new Map(), u?.({ ReactiveElement: g }), (l.reactiveElementVersions ??= []).push("2.1.0");
805
+
806
+ // node_modules/@lit/reactive-element/node/decorators/property.js
807
+ var o3 = { attribute: true, type: String, converter: b, reflect: false, hasChanged: m };
808
+ var r3 = (t4 = o3, e4, r6) => {
809
+ const { kind: n5, metadata: i5 } = r6;
810
+ let s5 = globalThis.litPropertyMetadata.get(i5);
811
+ if (void 0 === s5 && globalThis.litPropertyMetadata.set(i5, s5 = /* @__PURE__ */ new Map()), "setter" === n5 && ((t4 = Object.create(t4)).wrapped = true), s5.set(r6.name, t4), "accessor" === n5) {
812
+ const { name: o6 } = r6;
813
+ return { set(r7) {
814
+ const n6 = e4.get.call(this);
815
+ e4.set.call(this, r7), this.requestUpdate(o6, n6, t4);
816
+ }, init(e5) {
817
+ return void 0 !== e5 && this.C(o6, void 0, t4, e5), e5;
818
+ } };
819
+ }
820
+ if ("setter" === n5) {
821
+ const { name: o6 } = r6;
822
+ return function(r7) {
823
+ const n6 = this[o6];
824
+ e4.call(this, r7), this.requestUpdate(o6, n6, t4);
825
+ };
826
+ }
827
+ throw Error("Unsupported decorator location: " + n5);
828
+ };
829
+ function n3(t4) {
830
+ return (e4, o6) => "object" == typeof o6 ? r3(t4, e4, o6) : ((t5, e5, o7) => {
831
+ const r6 = e5.hasOwnProperty(o7);
832
+ return e5.constructor.createProperty(o7, t5), r6 ? Object.getOwnPropertyDescriptor(e5, o7) : void 0;
833
+ })(t4, e4, o6);
834
+ }
835
+
836
+ // src/annotation/registry.ts
837
+ var customDoclingAnnotationElements = [];
838
+ function customDoclingAnnotationElement(tagName) {
839
+ const decorator = t(tagName);
840
+ return function(target, context) {
841
+ customDoclingAnnotationElements.push(
842
+ target
843
+ );
844
+ return decorator(target, context);
845
+ };
846
+ }
847
+
848
+ // node_modules/lit-html/node/lit-html.js
849
+ var t3 = globalThis;
850
+ var i2 = t3.trustedTypes;
851
+ var s2 = i2 ? i2.createPolicy("lit-html", { createHTML: (t4) => t4 }) : void 0;
852
+ var e3 = "$lit$";
853
+ var h2 = `lit$${Math.random().toFixed(9).slice(2)}$`;
854
+ var o4 = "?" + h2;
855
+ var n4 = `<${o4}>`;
856
+ var r4 = void 0 === t3.document ? { createTreeWalker: () => ({}) } : document;
857
+ var l2 = () => r4.createComment("");
858
+ var c3 = (t4) => null === t4 || "object" != typeof t4 && "function" != typeof t4;
859
+ var a2 = Array.isArray;
860
+ var u2 = (t4) => a2(t4) || "function" == typeof t4?.[Symbol.iterator];
861
+ var d2 = "[ \n\f\r]";
862
+ var f2 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
863
+ var v = /-->/g;
864
+ var _ = />/g;
865
+ var m2 = RegExp(`>|${d2}(?:([^\\s"'>=/]+)(${d2}*=${d2}*(?:[^
866
+ \f\r"'\`<>=]|("|')|))|$)`, "g");
867
+ var p2 = /'/g;
868
+ var g2 = /"/g;
869
+ var $ = /^(?:script|style|textarea|title)$/i;
870
+ var y2 = (t4) => (i5, ...s5) => ({ _$litType$: t4, strings: i5, values: s5 });
871
+ var x = y2(1);
872
+ var T = y2(2);
873
+ var b2 = y2(3);
874
+ var w = /* @__PURE__ */ Symbol.for("lit-noChange");
875
+ var E = /* @__PURE__ */ Symbol.for("lit-nothing");
876
+ var A = /* @__PURE__ */ new WeakMap();
877
+ var C = r4.createTreeWalker(r4, 129);
878
+ function P(t4, i5) {
879
+ if (!a2(t4) || !t4.hasOwnProperty("raw")) throw Error("invalid template strings array");
880
+ return void 0 !== s2 ? s2.createHTML(i5) : i5;
881
+ }
882
+ var V = (t4, i5) => {
883
+ const s5 = t4.length - 1, o6 = [];
884
+ let r6, l3 = 2 === i5 ? "<svg>" : 3 === i5 ? "<math>" : "", c4 = f2;
885
+ for (let i6 = 0; i6 < s5; i6++) {
886
+ const s6 = t4[i6];
887
+ let a3, u3, d3 = -1, y3 = 0;
888
+ for (; y3 < s6.length && (c4.lastIndex = y3, u3 = c4.exec(s6), null !== u3); ) y3 = c4.lastIndex, c4 === f2 ? "!--" === u3[1] ? c4 = v : void 0 !== u3[1] ? c4 = _ : void 0 !== u3[2] ? ($.test(u3[2]) && (r6 = RegExp("</" + u3[2], "g")), c4 = m2) : void 0 !== u3[3] && (c4 = m2) : c4 === m2 ? ">" === u3[0] ? (c4 = r6 ?? f2, d3 = -1) : void 0 === u3[1] ? d3 = -2 : (d3 = c4.lastIndex - u3[2].length, a3 = u3[1], c4 = void 0 === u3[3] ? m2 : '"' === u3[3] ? g2 : p2) : c4 === g2 || c4 === p2 ? c4 = m2 : c4 === v || c4 === _ ? c4 = f2 : (c4 = m2, r6 = void 0);
889
+ const x2 = c4 === m2 && t4[i6 + 1].startsWith("/>") ? " " : "";
890
+ l3 += c4 === f2 ? s6 + n4 : d3 >= 0 ? (o6.push(a3), s6.slice(0, d3) + e3 + s6.slice(d3) + h2 + x2) : s6 + h2 + (-2 === d3 ? i6 : x2);
891
+ }
892
+ return [P(t4, l3 + (t4[s5] || "<?>") + (2 === i5 ? "</svg>" : 3 === i5 ? "</math>" : "")), o6];
893
+ };
894
+ var N = class _N {
895
+ constructor({ strings: t4, _$litType$: s5 }, n5) {
896
+ let r6;
897
+ this.parts = [];
898
+ let c4 = 0, a3 = 0;
899
+ const u3 = t4.length - 1, d3 = this.parts, [f3, v2] = V(t4, s5);
900
+ if (this.el = _N.createElement(f3, n5), C.currentNode = this.el.content, 2 === s5 || 3 === s5) {
901
+ const t5 = this.el.content.firstChild;
902
+ t5.replaceWith(...t5.childNodes);
903
+ }
904
+ for (; null !== (r6 = C.nextNode()) && d3.length < u3; ) {
905
+ if (1 === r6.nodeType) {
906
+ if (r6.hasAttributes()) for (const t5 of r6.getAttributeNames()) if (t5.endsWith(e3)) {
907
+ const i5 = v2[a3++], s6 = r6.getAttribute(t5).split(h2), e4 = /([.?@])?(.*)/.exec(i5);
908
+ d3.push({ type: 1, index: c4, name: e4[2], strings: s6, ctor: "." === e4[1] ? H : "?" === e4[1] ? I : "@" === e4[1] ? L : R }), r6.removeAttribute(t5);
909
+ } else t5.startsWith(h2) && (d3.push({ type: 6, index: c4 }), r6.removeAttribute(t5));
910
+ if ($.test(r6.tagName)) {
911
+ const t5 = r6.textContent.split(h2), s6 = t5.length - 1;
912
+ if (s6 > 0) {
913
+ r6.textContent = i2 ? i2.emptyScript : "";
914
+ for (let i5 = 0; i5 < s6; i5++) r6.append(t5[i5], l2()), C.nextNode(), d3.push({ type: 2, index: ++c4 });
915
+ r6.append(t5[s6], l2());
916
+ }
917
+ }
918
+ } else if (8 === r6.nodeType) if (r6.data === o4) d3.push({ type: 2, index: c4 });
919
+ else {
920
+ let t5 = -1;
921
+ for (; -1 !== (t5 = r6.data.indexOf(h2, t5 + 1)); ) d3.push({ type: 7, index: c4 }), t5 += h2.length - 1;
922
+ }
923
+ c4++;
924
+ }
925
+ }
926
+ static createElement(t4, i5) {
927
+ const s5 = r4.createElement("template");
928
+ return s5.innerHTML = t4, s5;
929
+ }
930
+ };
931
+ function S2(t4, i5, s5 = t4, e4) {
932
+ if (i5 === w) return i5;
933
+ let h4 = void 0 !== e4 ? s5._$Co?.[e4] : s5._$Cl;
934
+ const o6 = c3(i5) ? void 0 : i5._$litDirective$;
935
+ return h4?.constructor !== o6 && (h4?._$AO?.(false), void 0 === o6 ? h4 = void 0 : (h4 = new o6(t4), h4._$AT(t4, s5, e4)), void 0 !== e4 ? (s5._$Co ??= [])[e4] = h4 : s5._$Cl = h4), void 0 !== h4 && (i5 = S2(t4, h4._$AS(t4, i5.values), h4, e4)), i5;
936
+ }
937
+ var M = class {
938
+ constructor(t4, i5) {
939
+ this._$AV = [], this._$AN = void 0, this._$AD = t4, this._$AM = i5;
940
+ }
941
+ get parentNode() {
942
+ return this._$AM.parentNode;
943
+ }
944
+ get _$AU() {
945
+ return this._$AM._$AU;
946
+ }
947
+ u(t4) {
948
+ const { el: { content: i5 }, parts: s5 } = this._$AD, e4 = (t4?.creationScope ?? r4).importNode(i5, true);
949
+ C.currentNode = e4;
950
+ let h4 = C.nextNode(), o6 = 0, n5 = 0, l3 = s5[0];
951
+ for (; void 0 !== l3; ) {
952
+ if (o6 === l3.index) {
953
+ let i6;
954
+ 2 === l3.type ? i6 = new k(h4, h4.nextSibling, this, t4) : 1 === l3.type ? i6 = new l3.ctor(h4, l3.name, l3.strings, this, t4) : 6 === l3.type && (i6 = new z(h4, this, t4)), this._$AV.push(i6), l3 = s5[++n5];
955
+ }
956
+ o6 !== l3?.index && (h4 = C.nextNode(), o6++);
957
+ }
958
+ return C.currentNode = r4, e4;
959
+ }
960
+ p(t4) {
961
+ let i5 = 0;
962
+ for (const s5 of this._$AV) void 0 !== s5 && (void 0 !== s5.strings ? (s5._$AI(t4, s5, i5), i5 += s5.strings.length - 2) : s5._$AI(t4[i5])), i5++;
963
+ }
964
+ };
965
+ var k = class _k {
966
+ get _$AU() {
967
+ return this._$AM?._$AU ?? this._$Cv;
968
+ }
969
+ constructor(t4, i5, s5, e4) {
970
+ this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = t4, this._$AB = i5, this._$AM = s5, this.options = e4, this._$Cv = e4?.isConnected ?? true;
971
+ }
972
+ get parentNode() {
973
+ let t4 = this._$AA.parentNode;
974
+ const i5 = this._$AM;
975
+ return void 0 !== i5 && 11 === t4?.nodeType && (t4 = i5.parentNode), t4;
976
+ }
977
+ get startNode() {
978
+ return this._$AA;
979
+ }
980
+ get endNode() {
981
+ return this._$AB;
982
+ }
983
+ _$AI(t4, i5 = this) {
984
+ t4 = S2(this, t4, i5), c3(t4) ? t4 === E || null == t4 || "" === t4 ? (this._$AH !== E && this._$AR(), this._$AH = E) : t4 !== this._$AH && t4 !== w && this._(t4) : void 0 !== t4._$litType$ ? this.$(t4) : void 0 !== t4.nodeType ? this.T(t4) : u2(t4) ? this.k(t4) : this._(t4);
985
+ }
986
+ O(t4) {
987
+ return this._$AA.parentNode.insertBefore(t4, this._$AB);
988
+ }
989
+ T(t4) {
990
+ this._$AH !== t4 && (this._$AR(), this._$AH = this.O(t4));
991
+ }
992
+ _(t4) {
993
+ this._$AH !== E && c3(this._$AH) ? this._$AA.nextSibling.data = t4 : this.T(r4.createTextNode(t4)), this._$AH = t4;
994
+ }
995
+ $(t4) {
996
+ const { values: i5, _$litType$: s5 } = t4, e4 = "number" == typeof s5 ? this._$AC(t4) : (void 0 === s5.el && (s5.el = N.createElement(P(s5.h, s5.h[0]), this.options)), s5);
997
+ if (this._$AH?._$AD === e4) this._$AH.p(i5);
998
+ else {
999
+ const t5 = new M(e4, this), s6 = t5.u(this.options);
1000
+ t5.p(i5), this.T(s6), this._$AH = t5;
1001
+ }
1002
+ }
1003
+ _$AC(t4) {
1004
+ let i5 = A.get(t4.strings);
1005
+ return void 0 === i5 && A.set(t4.strings, i5 = new N(t4)), i5;
1006
+ }
1007
+ k(t4) {
1008
+ a2(this._$AH) || (this._$AH = [], this._$AR());
1009
+ const i5 = this._$AH;
1010
+ let s5, e4 = 0;
1011
+ for (const h4 of t4) e4 === i5.length ? i5.push(s5 = new _k(this.O(l2()), this.O(l2()), this, this.options)) : s5 = i5[e4], s5._$AI(h4), e4++;
1012
+ e4 < i5.length && (this._$AR(s5 && s5._$AB.nextSibling, e4), i5.length = e4);
1013
+ }
1014
+ _$AR(t4 = this._$AA.nextSibling, i5) {
1015
+ for (this._$AP?.(false, true, i5); t4 && t4 !== this._$AB; ) {
1016
+ const i6 = t4.nextSibling;
1017
+ t4.remove(), t4 = i6;
1018
+ }
1019
+ }
1020
+ setConnected(t4) {
1021
+ void 0 === this._$AM && (this._$Cv = t4, this._$AP?.(t4));
1022
+ }
1023
+ };
1024
+ var R = class {
1025
+ get tagName() {
1026
+ return this.element.tagName;
1027
+ }
1028
+ get _$AU() {
1029
+ return this._$AM._$AU;
1030
+ }
1031
+ constructor(t4, i5, s5, e4, h4) {
1032
+ this.type = 1, this._$AH = E, this._$AN = void 0, this.element = t4, this.name = i5, this._$AM = e4, this.options = h4, s5.length > 2 || "" !== s5[0] || "" !== s5[1] ? (this._$AH = Array(s5.length - 1).fill(new String()), this.strings = s5) : this._$AH = E;
1033
+ }
1034
+ _$AI(t4, i5 = this, s5, e4) {
1035
+ const h4 = this.strings;
1036
+ let o6 = false;
1037
+ if (void 0 === h4) t4 = S2(this, t4, i5, 0), o6 = !c3(t4) || t4 !== this._$AH && t4 !== w, o6 && (this._$AH = t4);
1038
+ else {
1039
+ const e5 = t4;
1040
+ let n5, r6;
1041
+ for (t4 = h4[0], n5 = 0; n5 < h4.length - 1; n5++) r6 = S2(this, e5[s5 + n5], i5, n5), r6 === w && (r6 = this._$AH[n5]), o6 ||= !c3(r6) || r6 !== this._$AH[n5], r6 === E ? t4 = E : t4 !== E && (t4 += (r6 ?? "") + h4[n5 + 1]), this._$AH[n5] = r6;
1042
+ }
1043
+ o6 && !e4 && this.j(t4);
1044
+ }
1045
+ j(t4) {
1046
+ t4 === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t4 ?? "");
1047
+ }
1048
+ };
1049
+ var H = class extends R {
1050
+ constructor() {
1051
+ super(...arguments), this.type = 3;
1052
+ }
1053
+ j(t4) {
1054
+ this.element[this.name] = t4 === E ? void 0 : t4;
1055
+ }
1056
+ };
1057
+ var I = class extends R {
1058
+ constructor() {
1059
+ super(...arguments), this.type = 4;
1060
+ }
1061
+ j(t4) {
1062
+ this.element.toggleAttribute(this.name, !!t4 && t4 !== E);
1063
+ }
1064
+ };
1065
+ var L = class extends R {
1066
+ constructor(t4, i5, s5, e4, h4) {
1067
+ super(t4, i5, s5, e4, h4), this.type = 5;
1068
+ }
1069
+ _$AI(t4, i5 = this) {
1070
+ if ((t4 = S2(this, t4, i5, 0) ?? E) === w) return;
1071
+ const s5 = this._$AH, e4 = t4 === E && s5 !== E || t4.capture !== s5.capture || t4.once !== s5.once || t4.passive !== s5.passive, h4 = t4 !== E && (s5 === E || e4);
1072
+ e4 && this.element.removeEventListener(this.name, this, s5), h4 && this.element.addEventListener(this.name, this, t4), this._$AH = t4;
1073
+ }
1074
+ handleEvent(t4) {
1075
+ "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t4) : this._$AH.handleEvent(t4);
1076
+ }
1077
+ };
1078
+ var z = class {
1079
+ constructor(t4, i5, s5) {
1080
+ this.element = t4, this.type = 6, this._$AN = void 0, this._$AM = i5, this.options = s5;
1081
+ }
1082
+ get _$AU() {
1083
+ return this._$AM._$AU;
1084
+ }
1085
+ _$AI(t4) {
1086
+ S2(this, t4);
1087
+ }
1088
+ };
1089
+ var Z = t3.litHtmlPolyfillSupport;
1090
+ Z?.(N, k), (t3.litHtmlVersions ??= []).push("3.3.0");
1091
+ var j = (t4, i5, s5) => {
1092
+ const e4 = s5?.renderBefore ?? i5;
1093
+ let h4 = e4._$litPart$;
1094
+ if (void 0 === h4) {
1095
+ const t5 = s5?.renderBefore ?? null;
1096
+ e4._$litPart$ = h4 = new k(i5.insertBefore(l2(), t5), t5, void 0, s5 ?? {});
1097
+ }
1098
+ return h4._$AI(t4), h4;
1099
+ };
1100
+
1101
+ // node_modules/lit-element/lit-element.js
1102
+ var s3 = globalThis;
1103
+ var i3 = class extends g {
1104
+ constructor() {
1105
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
1106
+ }
1107
+ createRenderRoot() {
1108
+ const t4 = super.createRenderRoot();
1109
+ return this.renderOptions.renderBefore ??= t4.firstChild, t4;
1110
+ }
1111
+ update(t4) {
1112
+ const r6 = this.render();
1113
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t4), this._$Do = j(r6, this.renderRoot, this.renderOptions);
1114
+ }
1115
+ connectedCallback() {
1116
+ super.connectedCallback(), this._$Do?.setConnected(true);
1117
+ }
1118
+ disconnectedCallback() {
1119
+ super.disconnectedCallback(), this._$Do?.setConnected(false);
1120
+ }
1121
+ render() {
1122
+ return w;
1123
+ }
1124
+ };
1125
+ i3._$litElement$ = true, i3["finalized"] = true, s3.litElementHydrateSupport?.({ LitElement: i3 });
1126
+ var o5 = s3.litElementPolyfillSupport;
1127
+ o5?.({ LitElement: i3 });
1128
+ (s3.litElementVersions ??= []).push("4.2.0");
1129
+
1130
+ // src/annotation/AnnotationElement.ts
1131
+ var DoclingAnnotationElement = class extends i3 {
1132
+ render() {
1133
+ if (this.annotation && this.item && this.page && this.canDrawAnnotation(this.annotation) && this.canDrawItem(this.item)) {
1134
+ return this.renderAnnotation(
1135
+ this.annotation,
1136
+ this.item,
1137
+ this.page,
1138
+ this.prov
1139
+ );
1140
+ }
1141
+ }
1142
+ };
1143
+ __decorateClass([
1144
+ n3({ attribute: false })
1145
+ ], DoclingAnnotationElement.prototype, "annotation", 2);
1146
+ __decorateClass([
1147
+ n3({ attribute: false })
1148
+ ], DoclingAnnotationElement.prototype, "item", 2);
1149
+ __decorateClass([
1150
+ n3({ attribute: false })
1151
+ ], DoclingAnnotationElement.prototype, "page", 2);
1152
+ __decorateClass([
1153
+ n3({ attribute: false })
1154
+ ], DoclingAnnotationElement.prototype, "prov", 2);
1155
+
1156
+ // node_modules/@docling/docling-core/dist/index.js
1157
+ var DEFAULT_EXPORT_LABELS = [
1158
+ "title",
1159
+ "document_index",
1160
+ "section_header",
1161
+ "paragraph",
1162
+ "table",
1163
+ "picture",
1164
+ "formula",
1165
+ "checkbox_unselected",
1166
+ "checkbox_selected",
1167
+ "text",
1168
+ "list_item",
1169
+ "code",
1170
+ "reference",
1171
+ "page_header",
1172
+ "page_footer",
1173
+ "key_value_region",
1174
+ "empty_value",
1175
+ "field_key",
1176
+ "field_value",
1177
+ "field_heading",
1178
+ "field_hint",
1179
+ "marker",
1180
+ "handwritten_text"
1181
+ ];
1182
+ var DOCUMENT_TOKENS_EXPORT_LABELS = [
1183
+ ...DEFAULT_EXPORT_LABELS,
1184
+ "footnote",
1185
+ "caption",
1186
+ "form"
1187
+ ];
1188
+ function isItemByLabel(...labels) {
1189
+ return function(item) {
1190
+ return isDocling.DocItem(item) && labels.includes(item.label);
1191
+ };
1192
+ }
1193
+ var isDoclingDocItem = {
1194
+ CodeItem: isItemByLabel("code"),
1195
+ FieldHeadingItem: isItemByLabel("field_heading"),
1196
+ FieldItem: isItemByLabel("field_item"),
1197
+ FieldRegionItem: isItemByLabel("field_region"),
1198
+ FieldValueItem: isItemByLabel("field_value"),
1199
+ FormItem: isItemByLabel("form"),
1200
+ FormulaItem: isItemByLabel("formula"),
1201
+ KeyValueItem: isItemByLabel("key_value_region"),
1202
+ ListItem: isItemByLabel("list_item"),
1203
+ PictureItem: isItemByLabel("chart", "picture"),
1204
+ SectionHeaderItem: isItemByLabel("section_header"),
1205
+ TableItem: isItemByLabel("document_index", "table"),
1206
+ TextItem: isItemByLabel(
1207
+ "caption",
1208
+ "checkbox_selected",
1209
+ "checkbox_unselected",
1210
+ "empty_value",
1211
+ "field_hint",
1212
+ "field_key",
1213
+ "footnote",
1214
+ "grading_scale",
1215
+ "handwritten_text",
1216
+ "marker",
1217
+ "page_footer",
1218
+ "page_header",
1219
+ "paragraph",
1220
+ "reference",
1221
+ "text"
1222
+ ),
1223
+ TitleItem: isItemByLabel("title")
1224
+ };
1225
+ function isPictureAnnotationByKind(...kinds) {
1226
+ return function(item) {
1227
+ return kinds.includes(item.kind);
1228
+ };
1229
+ }
1230
+ var isDoclingAnnotation = {
1231
+ PictureBarChart: isPictureAnnotationByKind("bar_chart_data"),
1232
+ PictureClassification: isPictureAnnotationByKind("classification"),
1233
+ PictureDescription: isPictureAnnotationByKind("description"),
1234
+ PictureMisc: isPictureAnnotationByKind("misc"),
1235
+ PictureMolecule: isPictureAnnotationByKind("molecule_data"),
1236
+ PictureLineChart: isPictureAnnotationByKind("line_chart_data"),
1237
+ PicturePieChart: isPictureAnnotationByKind("pie_chart_data"),
1238
+ PictureScatterChart: isPictureAnnotationByKind("scatter_chart_data"),
1239
+ PictureStackedBarChart: isPictureAnnotationByKind(
1240
+ "stacked_bar_chart_data"
1241
+ ),
1242
+ PictureTabularChart: isPictureAnnotationByKind("tabular_chart_data")
1243
+ };
1244
+ var isDocling = {
1245
+ DocItem(item) {
1246
+ return isDocling.NodeItem(item) && !isDocling.GroupItem(item);
1247
+ },
1248
+ Document(item) {
1249
+ return "schema_name" in item && item.schema_name === "DoclingDocument";
1250
+ },
1251
+ GroupItem(item) {
1252
+ return isDocling.NodeItem(item) && (item.self_ref.startsWith("#/groups/") || item.self_ref === "#/body" || item.self_ref === "#/furniture");
1253
+ },
1254
+ ListGroup(item) {
1255
+ return isDocling.GroupItem(item) && "label" in item && item.label === "list";
1256
+ },
1257
+ OrderedList(item) {
1258
+ return isDocling.GroupItem(item) && "label" in item && item.label === "ordered_list";
1259
+ },
1260
+ InlineGroup(item) {
1261
+ return isDocling.GroupItem(item) && "label" in item && item.label === "inline";
1262
+ },
1263
+ NodeItem(item) {
1264
+ return "self_ref" in item;
1265
+ },
1266
+ ...isDoclingAnnotation,
1267
+ ...isDoclingDocItem
1268
+ };
1269
+ function* iterateDocumentItems(doc, options = {}) {
1270
+ if (doc) {
1271
+ yield* traverse(options.root ?? doc.body);
1272
+ }
1273
+ function* traverse(item, level = 0) {
1274
+ if (!isDocling.GroupItem(item) || options.withGroups) {
1275
+ if (isDocling.DocItem(item)) {
1276
+ if (options.pageNo === void 0 || item.prov?.some((prov) => prov.page_no === options.pageNo)) {
1277
+ yield [item, level];
1278
+ }
1279
+ } else {
1280
+ yield [item, level];
1281
+ }
1282
+ }
1283
+ const rootIsPicture = isDocling.PictureItem(item);
1284
+ const allowedPicRefs = new Set(
1285
+ rootIsPicture ? (item.captions ?? []).map((r6) => r6.$ref) : []
1286
+ );
1287
+ for (const childRef of item.children ?? []) {
1288
+ if (rootIsPicture && !options.traversePictures && !allowedPicRefs.has(childRef.$ref)) {
1289
+ continue;
1290
+ }
1291
+ const child = resolveDocumentItem(doc, childRef);
1292
+ if (isDocling.NodeItem(child)) {
1293
+ yield* traverse(child, level + 1);
1294
+ }
1295
+ }
1296
+ }
1297
+ }
1298
+ function resolveDocumentItem(doc, item) {
1299
+ const parts = item.$ref.split("/").slice(1);
1300
+ return parts.reduce(
1301
+ (item2, p3) => item2[p3],
1302
+ doc
1303
+ );
1304
+ }
1305
+
1306
+ // src/annotation/AnnotationPictureClassification.ts
1307
+ var AnnotationPictureClassification = class extends DoclingAnnotationElement {
1308
+ constructor() {
1309
+ super(...arguments);
1310
+ this.precision = 2;
1311
+ }
1312
+ renderAnnotation(annotation, _item, _page, _prov) {
1313
+ const classes = annotation.predicted_classes ?? [];
1314
+ const threshold = Math.pow(10, -1 * this.precision);
1315
+ const topClasses = classes.filter((c4) => threshold < c4.confidence);
1316
+ const restClasses = classes.filter((c4) => c4.confidence < threshold);
1317
+ const format = (value) => value.toLocaleString(void 0, {
1318
+ maximumFractionDigits: this.precision
1319
+ });
1320
+ return x`<table>
1321
+ <thead>
1322
+ <tr>
1323
+ <th>Class</th>
1324
+ <th>Confidence</th>
1325
+ </tr>
1326
+ </thead>
1327
+ <tbody>
1328
+ ${topClasses.map(
1329
+ ({ class_name, confidence }) => x`<tr>
1330
+ <td>${class_name}</td>
1331
+ <td>${format(confidence)}</td>
1332
+ </tr>`
1333
+ )}
1334
+ ${restClasses.length === 0 ? E : x`<tr
1335
+ class="more"
1336
+ title=${restClasses.map((c4) => `${c4.class_name} ${c4.confidence}`).join("\n")}
1337
+ >
1338
+ <td>${restClasses.length} more</td>
1339
+ <td>< ${format(threshold)}</td>
1340
+ </tr>`}
1341
+ </tbody>
1342
+ </table>`;
1343
+ }
1344
+ canDrawAnnotation(annotation) {
1345
+ return isDoclingAnnotation.PictureClassification(annotation);
1346
+ }
1347
+ canDrawItem(item) {
1348
+ return isDoclingDocItem.PictureItem(item);
1349
+ }
1350
+ };
1351
+ AnnotationPictureClassification.styles = i`
1352
+ table {
1353
+ margin: 0.5rem;
1354
+ font-size: inherit;
1355
+ line-height: 1.25;
1356
+ }
1357
+
1358
+ td,
1359
+ th {
1360
+ padding: 0 1rem 0 0;
1361
+ }
1362
+
1363
+ th {
1364
+ font-weight: bold;
1365
+ text-align: left;
1366
+ }
1367
+
1368
+ tr.more td {
1369
+ padding-top: 0.25rem;
1370
+ color: gray;
1371
+ }
1372
+ `;
1373
+ __decorateClass([
1374
+ n3()
1375
+ ], AnnotationPictureClassification.prototype, "precision", 2);
1376
+ AnnotationPictureClassification = __decorateClass([
1377
+ customDoclingAnnotationElement("docling-picture-classification")
1378
+ ], AnnotationPictureClassification);
1379
+
1380
+ // src/annotation/AnnotationPictureDescription.ts
1381
+ var AnnotationPictureDescription = class extends DoclingAnnotationElement {
1382
+ renderAnnotation(annotation, _item, _page, _prov) {
1383
+ return x`<p><span>Description</span>${annotation.text}</p>`;
1384
+ }
1385
+ canDrawAnnotation(annotation) {
1386
+ return isDoclingAnnotation.PictureDescription(annotation);
1387
+ }
1388
+ canDrawItem(item) {
1389
+ return isDoclingDocItem.PictureItem(item);
1390
+ }
1391
+ };
1392
+ AnnotationPictureDescription.styles = i`
1393
+ p {
1394
+ margin: 0.5rem;
1395
+ font-size: inherit;
1396
+ line-height: 1.25;
1397
+ white-space: pre-line;
1398
+ }
1399
+
1400
+ span {
1401
+ padding-right: 0.5rem;
1402
+ font-weight: bold;
1403
+ }
1404
+ `;
1405
+ AnnotationPictureDescription = __decorateClass([
1406
+ customDoclingAnnotationElement("docling-picture-description")
1407
+ ], AnnotationPictureDescription);
1408
+
1409
+ // src/item/registry.ts
1410
+ var customDoclingItemElements = [];
1411
+ function customDoclingItemElement(tagName) {
1412
+ const decorator = t(tagName);
1413
+ return function(target, context) {
1414
+ customDoclingItemElements.push(target);
1415
+ return decorator(target, context);
1416
+ };
1417
+ }
1418
+
1419
+ // src/item/ItemElement.ts
1420
+ var DoclingItemElement = class extends i3 {
1421
+ render() {
1422
+ if (this.item && this.page && this.canDrawItem(this.item)) {
1423
+ const level = this.item.level ?? 0;
1424
+ this.setAttribute("data-level", String(level));
1425
+ this.style.setProperty("--docling-level", String(level));
1426
+ this.setAttribute("data-layer", this.item.content_layer ?? "");
1427
+ return this.renderItem(this.item, this.page, this.prov);
1428
+ }
1429
+ }
1430
+ static {
1431
+ this.styles = i`
1432
+ :host([data-layer='furniture']) {
1433
+ opacity: 0.33;
1434
+ }
1435
+ `;
1436
+ }
1437
+ };
1438
+ __decorateClass([
1439
+ n3({ attribute: false })
1440
+ ], DoclingItemElement.prototype, "item", 2);
1441
+ __decorateClass([
1442
+ n3({ attribute: false })
1443
+ ], DoclingItemElement.prototype, "page", 2);
1444
+ __decorateClass([
1445
+ n3({ attribute: false })
1446
+ ], DoclingItemElement.prototype, "prov", 2);
1447
+
1448
+ // src/item/ItemCode.ts
1449
+ var ItemCode = class extends DoclingItemElement {
1450
+ renderItem(item, _page, _prov) {
1451
+ return x`
1452
+ <div class="code-block">
1453
+ ${item.code_language ? x`<span class="lang">${item.code_language}</span>` : E}
1454
+ <pre><code>${item.text}</code></pre>
1455
+ </div>
1456
+ `;
1457
+ }
1458
+ canDrawItem(item) {
1459
+ return isDoclingDocItem.CodeItem(item);
1460
+ }
1461
+ };
1462
+ ItemCode.styles = i`
1463
+ .code-block {
1464
+ position: relative;
1465
+ margin: 0;
1466
+ background: #f4f4f4;
1467
+ border-left: 3px solid #bbb;
1468
+ border-radius: 2px;
1469
+ overflow: auto;
1470
+ }
1471
+
1472
+ .lang {
1473
+ position: absolute;
1474
+ top: 0.15rem;
1475
+ right: 0.4rem;
1476
+ font-size: 0.65rem;
1477
+ color: #888;
1478
+ font-family: monospace;
1479
+ text-transform: uppercase;
1480
+ letter-spacing: 0.05em;
1481
+ }
1482
+
1483
+ pre {
1484
+ margin: 0;
1485
+ padding: 0.4rem 0.5rem;
1486
+ font-size: 0.75rem;
1487
+ line-height: 1.4;
1488
+ white-space: pre-wrap;
1489
+ overflow-wrap: anywhere;
1490
+ font-family: monospace;
1491
+ }
1492
+
1493
+ code {
1494
+ font-family: inherit;
1495
+ }
1496
+ `;
1497
+ ItemCode = __decorateClass([
1498
+ customDoclingItemElement("docling-item-code")
1499
+ ], ItemCode);
1500
+
1501
+ // src/item/ItemKeyValue.ts
1502
+ var ItemKeyValue = class extends DoclingItemElement {
1503
+ renderItem(item, _page, _prov) {
1504
+ const cells = item.graph?.cells ?? [];
1505
+ const links = item.graph?.links ?? [];
1506
+ const cellById = new Map(cells.map((c4) => [c4.cell_id, c4]));
1507
+ const pairs = [];
1508
+ for (const link of links) {
1509
+ if (link.label === "to_value") {
1510
+ const keyCell = cellById.get(link.source_cell_id);
1511
+ const valCell = cellById.get(link.target_cell_id);
1512
+ if (keyCell && valCell) {
1513
+ pairs.push({ key: keyCell.text, value: valCell.text });
1514
+ }
1515
+ }
1516
+ }
1517
+ if (pairs.length === 0) {
1518
+ const keys = cells.filter((c4) => c4.label === "key");
1519
+ const values = cells.filter((c4) => c4.label === "value");
1520
+ const len = Math.max(keys.length, values.length);
1521
+ for (let i5 = 0; i5 < len; i5++) {
1522
+ pairs.push({ key: keys[i5]?.text ?? "", value: values[i5]?.text ?? "" });
1523
+ }
1524
+ }
1525
+ if (pairs.length === 0) return x`${E}`;
1526
+ return x`
1527
+ <table class="kv">
1528
+ <tbody>
1529
+ ${pairs.map(
1530
+ ({ key, value }) => x`
1531
+ <tr>
1532
+ <td class="key">${key}</td>
1533
+ <td class="value">${value}</td>
1534
+ </tr>
1535
+ `
1536
+ )}
1537
+ </tbody>
1538
+ </table>
1539
+ `;
1540
+ }
1541
+ canDrawItem(item) {
1542
+ return isDoclingDocItem.KeyValueItem(item);
1543
+ }
1544
+ };
1545
+ ItemKeyValue.styles = i`
1546
+ .kv {
1547
+ border-collapse: collapse;
1548
+ font-size: 75%;
1549
+ line-height: 1.25;
1550
+ width: 100%;
1551
+ }
1552
+
1553
+ td {
1554
+ padding: 0.1rem 0.3rem;
1555
+ border: 1px solid rgb(220, 220, 220);
1556
+ vertical-align: top;
1557
+ word-break: break-word;
1558
+ }
1559
+
1560
+ td.key {
1561
+ font-weight: bold;
1562
+ white-space: nowrap;
1563
+ color: #444;
1564
+ width: 40%;
1565
+ }
1566
+
1567
+ td.value {
1568
+ color: #111;
1569
+ }
1570
+ `;
1571
+ ItemKeyValue = __decorateClass([
1572
+ customDoclingItemElement("docling-item-key-value")
1573
+ ], ItemKeyValue);
1574
+
1575
+ // src/item/ItemProvenance.ts
1576
+ var ItemProvenance = class extends DoclingItemElement {
1577
+ renderItem(item, page) {
1578
+ const { image } = page;
1579
+ const prov = item.prov?.find((p3) => p3.page_no === this.page?.page_no);
1580
+ if (image && prov) {
1581
+ const { width = 1, height = 1 } = this.page.size;
1582
+ const { l: l3, r: r6, t: t4, b: b3 } = normalBbox(prov.bbox, page);
1583
+ const pixelRatio = (image.size.width ?? 1) / width;
1584
+ const w2 = (r6 - l3) * pixelRatio;
1585
+ const h4 = (b3 - t4) * pixelRatio;
1586
+ return x`
1587
+ <svg
1588
+ data-width=${w2}
1589
+ data-height=${h4}
1590
+ style="--docling-width: ${w2}px; --docling-height: ${h4}px;"
1591
+ viewBox="${l3} ${t4} ${r6 - l3} ${b3 - t4}"
1592
+ >
1593
+ <image href=${image.uri} width=${width} height=${height} />
1594
+ </svg>
1595
+ `;
1596
+ } else {
1597
+ return x`<span>Invalid provenance.</span>`;
1598
+ }
1599
+ }
1600
+ canDrawItem(item) {
1601
+ return isDocling.DocItem(item);
1602
+ }
1603
+ };
1604
+ ItemProvenance.styles = i`
1605
+ svg {
1606
+ width: calc(
1607
+ var(--docling-width, 100%) * var(--docling-provenance-scale, 1)
1608
+ );
1609
+ max-width: 100%;
1610
+ }
1611
+ `;
1612
+ ItemProvenance = __decorateClass([
1613
+ t("docling-item-provenance")
1614
+ ], ItemProvenance);
1615
+
1616
+ // src/item/ItemTable.ts
1617
+ var ItemTable = class extends DoclingItemElement {
1618
+ renderItem(item) {
1619
+ const coveredCells = /* @__PURE__ */ new Set();
1620
+ return x`
1621
+ <div class="container">
1622
+ <table>
1623
+ <tbody>
1624
+ ${item.data.grid.map(
1625
+ (row) => x`<tr>
1626
+ ${row.map((cell) => {
1627
+ if (!isCovered(cell)) {
1628
+ return x`<td
1629
+ class=${cell.column_header || cell.row_header ? "header" : ""}
1630
+ colspan=${cell.col_span ?? 1}
1631
+ rowspan=${cell.row_span ?? 1}
1632
+ >
1633
+ ${cell.text}
1634
+ </td>`;
1635
+ }
1636
+ })}
1637
+ </tr>`
1638
+ )}
1639
+ </tbody>
1640
+ </table>
1641
+ </div>
1642
+ `;
1643
+ function isCovered(cell) {
1644
+ const covered = coveredCells.has(
1645
+ [cell.start_col_offset_idx, cell.start_row_offset_idx].join()
1646
+ );
1647
+ if (!covered) {
1648
+ for (let x2 = cell.start_col_offset_idx; x2 < cell.end_col_offset_idx; x2++) {
1649
+ for (let y3 = cell.start_row_offset_idx; y3 < cell.end_row_offset_idx; y3++) {
1650
+ coveredCells.add([x2, y3].join());
1651
+ }
1652
+ }
1653
+ }
1654
+ return covered;
1655
+ }
1656
+ }
1657
+ canDrawItem(item) {
1658
+ return isDoclingDocItem.TableItem(item);
1659
+ }
1660
+ };
1661
+ ItemTable.styles = i`
1662
+ .container {
1663
+ position: relative;
1664
+ min-width: 0;
1665
+ max-width: 100%;
1666
+ min-height: 0;
1667
+ overflow: auto;
1668
+ }
1669
+
1670
+ table {
1671
+ border-collapse: collapse;
1672
+ font-size: 75%;
1673
+ line-height: 1.25;
1674
+ }
1675
+
1676
+ td {
1677
+ padding: 0.125rem 0.25rem;
1678
+ background-color: var(--cds-layer);
1679
+ border: 1px solid rgb(220, 220, 220);
1680
+
1681
+ color: black;
1682
+ text-decoration: none;
1683
+ word-break: normal;
1684
+ text-align: left;
1685
+ }
1686
+
1687
+ td.header {
1688
+ font-weight: bold;
1689
+ }
1690
+
1691
+ td:hover {
1692
+ filter: brightness(95%);
1693
+ }
1694
+
1695
+ td:target {
1696
+ outline: 3px solid blue;
1697
+ }
1698
+ `;
1699
+ ItemTable = __decorateClass([
1700
+ customDoclingItemElement("docling-item-table")
1701
+ ], ItemTable);
1702
+
1703
+ // src/item/ItemTemplate.ts
1704
+ var ItemTemplate = class extends DoclingItemElement {
1705
+ constructor() {
1706
+ super(...arguments);
1707
+ this.renderItem = Function(
1708
+ "item",
1709
+ "page",
1710
+ `"use strict"; return this.html\`${this.innerHTML}\`;`
1711
+ ).bind({ html: x });
1712
+ }
1713
+ canDrawItem(item) {
1714
+ return isDocling.DocItem(item);
1715
+ }
1716
+ };
1717
+ ItemTemplate = __decorateClass([
1718
+ t("docling-item-template")
1719
+ ], ItemTemplate);
1720
+
1721
+ // src/item/ItemText.ts
1722
+ var ItemText = class extends DoclingItemElement {
1723
+ renderItem(item, page, prov) {
1724
+ const fmt = item.formatting;
1725
+ const fmtStyle = [
1726
+ fmt?.bold ? "font-weight:bold" : "",
1727
+ fmt?.italic ? "font-style:italic" : "",
1728
+ fmt?.underline ? "text-decoration:underline" : "",
1729
+ fmt?.strikethrough ? "text-decoration:line-through" : ""
1730
+ ].filter(Boolean).join(";");
1731
+ if (prov) {
1732
+ const { l: l3, r: r6, t: t4, b: b3 } = normalBbox(prov.bbox, page);
1733
+ const sizeApprox = Math.sqrt((r6 - l3) * (b3 - t4) / item.text.length);
1734
+ const size = Math.min(Math.floor(1.25 * sizeApprox), (b3 - t4) / 1.25);
1735
+ const [tl, tu] = prov.charspan ?? [
1736
+ 0,
1737
+ item.text.length
1738
+ ];
1739
+ const text = item.text.substring(tl, tu);
1740
+ return x`<p
1741
+ class=${this.textClass(item)}
1742
+ style="font-size:${size}px;line-height:${1.25 * size}px;${fmtStyle}"
1743
+ >
1744
+ ${this.listPrefix(item)}${text}
1745
+ </p>`;
1746
+ } else {
1747
+ return x`<p class=${this.textClass(item)} style=${fmtStyle || E}>
1748
+ ${this.listPrefix(item)}${item.text}
1749
+ </p>`;
1750
+ }
1751
+ }
1752
+ textClass(item) {
1753
+ if (isDoclingDocItem.TitleItem(item)) return "title";
1754
+ if (isDoclingDocItem.SectionHeaderItem(item)) {
1755
+ const lvl = item.level ?? 1;
1756
+ return `header header-${Math.min(lvl, 6)}`;
1757
+ }
1758
+ if (isDoclingDocItem.ListItem(item)) return "list-item";
1759
+ return "";
1760
+ }
1761
+ /** Render bullet or numbered prefix for list items. */
1762
+ listPrefix(item) {
1763
+ if (!isDoclingDocItem.ListItem(item)) return E;
1764
+ const li = item;
1765
+ if (li.marker) return x`<span class="marker">${li.marker}</span>`;
1766
+ if (li.enumerated) return x`<span class="marker bullet">•</span>`;
1767
+ return x`<span class="marker bullet">–</span>`;
1768
+ }
1769
+ canDrawItem(item) {
1770
+ return isDoclingDocItem.TextItem(item) || isDoclingDocItem.TitleItem(item) || isDoclingDocItem.SectionHeaderItem(item) || isDoclingDocItem.ListItem(item) || isDoclingDocItem.FormulaItem(item);
1771
+ }
1772
+ };
1773
+ ItemText.styles = i`
1774
+ p {
1775
+ margin: 0;
1776
+ overflow-wrap: anywhere;
1777
+ font-size: 1rem;
1778
+ line-height: 1.25rem;
1779
+ }
1780
+
1781
+ .title {
1782
+ font-size: 1.1rem;
1783
+ font-weight: bold;
1784
+ }
1785
+
1786
+ /* header-1 is largest (document section), header-6 is smallest. */
1787
+ .header {
1788
+ font-weight: bold;
1789
+ }
1790
+ .header-1 {
1791
+ font-size: 1rem;
1792
+ }
1793
+ .header-2 {
1794
+ font-size: 0.95rem;
1795
+ }
1796
+ .header-3 {
1797
+ font-size: 0.9rem;
1798
+ }
1799
+ .header-4,
1800
+ .header-5,
1801
+ .header-6 {
1802
+ font-size: 0.85rem;
1803
+ }
1804
+
1805
+ .list-item {
1806
+ display: flex;
1807
+ gap: 0.25rem;
1808
+ }
1809
+
1810
+ .marker {
1811
+ flex-shrink: 0;
1812
+ min-width: 1rem;
1813
+ }
1814
+ `;
1815
+ ItemText = __decorateClass([
1816
+ customDoclingItemElement("docling-item-text")
1817
+ ], ItemText);
1818
+
1819
+ // src/item/ItemView.ts
1820
+ var ItemView = class extends DoclingItemElement {
1821
+ get itemChildren() {
1822
+ return Array.from(this.childNodes ?? []).filter(
1823
+ (c4) => c4 instanceof DoclingItemElement
1824
+ );
1825
+ }
1826
+ get annotationChildren() {
1827
+ return Array.from(this.childNodes).filter(
1828
+ (c4) => c4 instanceof DoclingAnnotationElement
1829
+ );
1830
+ }
1831
+ get isCustomized() {
1832
+ return this.itemChildren.length > 0 || this.annotationChildren.length > 0;
1833
+ }
1834
+ renderItem(item, page, prov) {
1835
+ const shadowElements = [];
1836
+ const isCustomized = this.isCustomized;
1837
+ if (isCustomized) {
1838
+ this.itemChildren.filter((c4) => c4.canDrawItem(item)).forEach((c4) => shadowElements.push(c4));
1839
+ } else {
1840
+ customDoclingItemElements.filter((el) => el.prototype.canDrawItem(item)).forEach(
1841
+ (el) => shadowElements.push(new el())
1842
+ );
1843
+ }
1844
+ const annotations = [];
1845
+ if (isDoclingDocItem.PictureItem(item)) {
1846
+ const pic = item;
1847
+ const meta = pic.meta;
1848
+ if (meta?.description?.text) {
1849
+ const desc = {
1850
+ kind: "description",
1851
+ text: meta.description.text,
1852
+ provenance: meta.description.created_by ?? ""
1853
+ };
1854
+ annotations.push(desc);
1855
+ }
1856
+ if (meta?.classification?.predictions?.length) {
1857
+ annotations.push({
1858
+ kind: "classification",
1859
+ provenance: "meta",
1860
+ predicted_classes: meta.classification.predictions.map((p3) => ({
1861
+ class_name: p3.class_name,
1862
+ confidence: p3.confidence ?? 1
1863
+ }))
1864
+ });
1865
+ }
1866
+ }
1867
+ for (const ann of annotations) {
1868
+ const annElements = [];
1869
+ if (isCustomized) {
1870
+ this.annotationChildren.filter((c4) => c4.canDrawItem(c4) && c4.canDrawAnnotation(ann)).forEach(
1871
+ (c4) => annElements.push(c4.cloneNode(true))
1872
+ );
1873
+ } else {
1874
+ customDoclingAnnotationElements.filter(
1875
+ (el) => el.prototype.canDrawItem(item) && el.prototype.canDrawAnnotation(ann)
1876
+ ).forEach(
1877
+ (el) => annElements.push(
1878
+ new el()
1879
+ )
1880
+ );
1881
+ }
1882
+ for (const el of annElements) {
1883
+ el.annotation = ann;
1884
+ }
1885
+ shadowElements.push(...annElements);
1886
+ }
1887
+ for (const el of shadowElements) {
1888
+ el.item = item;
1889
+ el.page = page;
1890
+ el.prov = prov;
1891
+ }
1892
+ return x`${shadowElements}`;
1893
+ }
1894
+ canDrawItem(item) {
1895
+ if (isDocling.DocItem(item) && this.isCustomized) {
1896
+ return this.itemChildren.some((c4) => c4.canDrawItem(item)) || this.annotationChildren.some(
1897
+ (c4) => c4.canDrawItem(item) && item.annotations?.some(
1898
+ (a3) => c4.canDrawAnnotation(a3)
1899
+ )
1900
+ );
1901
+ } else {
1902
+ return customDoclingItemElements.some((el) => el.prototype.canDrawItem(item)) || customDoclingAnnotationElements.some(
1903
+ (el) => el.prototype.canDrawItem(item) && item.annotations?.some(
1904
+ (a3) => el.prototype.canDrawAnnotation(a3)
1905
+ )
1906
+ );
1907
+ }
1908
+ }
1909
+ };
1910
+ ItemView = __decorateClass([
1911
+ t("docling-view")
1912
+ ], ItemView);
1913
+ var ItemOverlay = class extends ItemView {
1914
+ constructor() {
1915
+ super(...arguments);
1916
+ this.type = "overlay";
1917
+ }
1918
+ };
1919
+ ItemOverlay = __decorateClass([
1920
+ t("docling-overlay")
1921
+ ], ItemOverlay);
1922
+ var ItemTooltip = class extends ItemView {
1923
+ constructor() {
1924
+ super(...arguments);
1925
+ this.type = "tooltip";
1926
+ }
1927
+ };
1928
+ ItemTooltip = __decorateClass([
1929
+ t("docling-tooltip")
1930
+ ], ItemTooltip);
1931
+
1932
+ // src/item/index.ts
1933
+ function normalBbox(bbox, page) {
1934
+ const { height = 1 } = page.size;
1935
+ return bbox.coord_origin === "TOPLEFT" ? bbox : { ...bbox, t: height - bbox.t, b: height - bbox.b };
1936
+ }
1937
+
1938
+ // src/img/ImgPage.ts
1939
+ var ImgPage = class extends i3 {
1940
+ constructor() {
1941
+ super(...arguments);
1942
+ this.pagenumbers = false;
1943
+ }
1944
+ render() {
1945
+ if (this.page?.image) {
1946
+ const { image, size, page_no } = this.page;
1947
+ const { width = 1, height = 1 } = size;
1948
+ const handleClick = this.onClickItem && this.page ? (e4, item) => this.onClickItem?.(e4, this.page, item) : void 0;
1949
+ return x`
1950
+ <div class="page" @onclick=${(e4) => handleClick?.(e4)}>
1951
+ <svg
1952
+ class="base"
1953
+ width=${image.size.width}
1954
+ viewBox="0 0 ${width} ${height}"
1955
+ >
1956
+ ${this.backdrop ? T`
1957
+ <image
1958
+ class="backdrop"
1959
+ href=${image.uri}
1960
+ width=${width}
1961
+ height=${height}
1962
+ />
1963
+
1964
+ <clippath id="clip-page-${page_no}">
1965
+ ${this.items?.map((item) => {
1966
+ const prov = item.prov?.find((p3) => p3.page_no === page_no);
1967
+ if (prov) {
1968
+ const { l: l3, r: r6, t: t4, b: b3 } = normalBbox(prov.bbox, this.page);
1969
+ return T`<rect
1970
+ x=${l3}
1971
+ y=${t4}
1972
+ width=${r6 - l3}
1973
+ height=${b3 - t4}
1974
+ />`;
1975
+ }
1976
+ })}
1977
+ </clippath>
1978
+ ` : E}
1979
+
1980
+ <image
1981
+ id="image"
1982
+ href=${image.uri}
1983
+ clip-path="url(#clip-page-${page_no})"
1984
+ width=${width}
1985
+ height=${height}
1986
+ />
1987
+
1988
+ ${this.items?.flatMap(
1989
+ (item) => (item.prov ?? []).filter((p3) => p3.page_no === page_no).map((prov) => {
1990
+ const { l: l3, r: r6, t: t4, b: b3 } = normalBbox(prov.bbox, this.page);
1991
+ return T`
1992
+ ${this.layOver(item, prov)}
1993
+
1994
+ <rect
1995
+ part=${"item" + (this.itemPart ? " " + this.itemPart(this.page, item) : "")}
1996
+ style=${this.itemStyle?.(this.page, item)}
1997
+ x=${l3}
1998
+ y=${t4}
1999
+ width=${r6 - l3}
2000
+ height=${b3 - t4}
2001
+ vector-effect="non-scaling-stroke"
2002
+ @click=${(e4) => {
2003
+ e4.stopPropagation();
2004
+ handleClick?.(e4, item);
2005
+ }}
2006
+ @mouseenter=${(e4) => {
2007
+ const bounds = e4.currentTarget.getBoundingClientRect();
2008
+ const areas = [
2009
+ bounds.top * window.innerWidth,
2010
+ (window.innerWidth - bounds.right) * window.innerHeight,
2011
+ (window.innerHeight - bounds.bottom) * window.innerWidth,
2012
+ bounds.left * window.innerHeight
2013
+ ];
2014
+ const maxArea = Math.max(...areas);
2015
+ const quadrant = areas.findIndex((a3) => a3 === maxArea);
2016
+ this.attachTooltip(item, prov, bounds, quadrant);
2017
+ }}
2018
+ @mouseleave=${() => this.removeTooltip()}
2019
+ />
2020
+ `;
2021
+ })
2022
+ )}
2023
+ </svg>
2024
+
2025
+ ${this.renderTrace()}
2026
+ ${this.pagenumbers ? x`<header
2027
+ part="page-number-top"
2028
+ class="page-number-top"
2029
+ title="Page ${page_no}"
2030
+ >
2031
+ ${page_no}
2032
+ </header>
2033
+
2034
+ <header
2035
+ part="page-number-bottom"
2036
+ class="page-number-bottom"
2037
+ title="Page ${page_no}"
2038
+ >
2039
+ ${page_no}
2040
+ </header>` : E}
2041
+ </div>
2042
+ `;
2043
+ } else {
2044
+ return x`Invalid page image.`;
2045
+ }
2046
+ }
2047
+ layOver(item, prov) {
2048
+ if (this.overlay?.canDrawItem(item)) {
2049
+ const clone = this.overlay.cloneNode(true);
2050
+ clone.item = item;
2051
+ clone.page = this.page;
2052
+ clone.prov = prov;
2053
+ const { l: l3, r: r6, t: t4, b: b3 } = normalBbox(prov.bbox, this.page);
2054
+ const overlayClass = isDoclingDocItem.PictureItem(item) ? "softOverlay" : "hardOverlay";
2055
+ return T`<foreignObject part="overlay" class=${overlayClass} x=${l3} y=${t4} width=${r6 - l3} height=${b3 - t4}>${clone}</foreignObject>`;
2056
+ }
2057
+ }
2058
+ attachTooltip(item, prov, bounds, quadrant) {
2059
+ if (this.tooltip?.canDrawItem(item)) {
2060
+ const clone = this.tooltip.cloneNode(true);
2061
+ clone.id = "tooltip";
2062
+ clone.setAttribute("part", "tooltip");
2063
+ clone.className = "tooltip";
2064
+ clone.setAttribute(
2065
+ "style",
2066
+ `
2067
+ ${quadrant === 1 ? `left: ${bounds.right}px` : quadrant === 3 ? `right: ${window.outerWidth - bounds.left}px` : `left: calc(${bounds.left}px - 2rem)`};
2068
+ ${quadrant === 0 ? `bottom: ${window.innerHeight - bounds.top}px` : quadrant === 2 ? `top: ${bounds.bottom}px` : `top: calc(${bounds.top}px - 2rem)`};
2069
+ max-width: ${2 * Math.max(prov.bbox.r - prov.bbox.l, 200)}px;
2070
+ `
2071
+ );
2072
+ clone.item = item;
2073
+ clone.page = this.page;
2074
+ this.renderRoot.appendChild(clone);
2075
+ }
2076
+ }
2077
+ removeTooltip() {
2078
+ this.renderRoot.querySelector("#tooltip")?.remove();
2079
+ }
2080
+ renderTrace() {
2081
+ if (this.trace) {
2082
+ const clone = this.trace.cloneNode(true);
2083
+ clone.page = this.page;
2084
+ clone.items = this.items;
2085
+ return clone;
2086
+ }
2087
+ }
2088
+ };
2089
+ ImgPage.styles = i`
2090
+ .page {
2091
+ position: relative;
2092
+ width: fit-content;
2093
+ color: black;
2094
+ }
2095
+
2096
+ .base {
2097
+ max-width: 100%;
2098
+ }
2099
+
2100
+ svg:not(.base) {
2101
+ position: absolute;
2102
+ inset: 0;
2103
+ }
2104
+
2105
+ .backdrop {
2106
+ opacity: 0.3;
2107
+ }
2108
+
2109
+ .page-number-top,
2110
+ .page-number-bottom {
2111
+ position: absolute;
2112
+ left: 0;
2113
+ width: fit-content;
2114
+ padding: 0 0.25rem;
2115
+
2116
+ font-size: 0.75rem;
2117
+ line-height: 1rem;
2118
+ color: rgb(120, 120, 120);
2119
+ mix-blend-mode: difference;
2120
+ }
2121
+
2122
+ .page-number-top {
2123
+ top: 0;
2124
+ }
2125
+
2126
+ .page-number-bottom {
2127
+ bottom: 0;
2128
+ }
2129
+
2130
+ rect {
2131
+ fill: blue;
2132
+ fill-opacity: 0.0001; /* To activate hover. */
2133
+ stroke: grey;
2134
+ stroke-width: 1px;
2135
+ stroke-dasharray: 1;
2136
+ cursor: pointer;
2137
+ }
2138
+
2139
+ rect:hover {
2140
+ fill-opacity: 0.1;
2141
+ stroke: blue;
2142
+ }
2143
+
2144
+ rect:target {
2145
+ stroke: blue;
2146
+ stroke-width: 3px;
2147
+ stroke-dasharray: none;
2148
+ }
2149
+
2150
+ .hardOverlay,
2151
+ .softOverlay {
2152
+ font-size: 62.5%;
2153
+ background-color: white;
2154
+ }
2155
+
2156
+ .softOverlay {
2157
+ opacity: 0.9;
2158
+ }
2159
+
2160
+ .tooltip {
2161
+ position: fixed;
2162
+ z-index: 100;
2163
+ padding: 1rem;
2164
+ margin: 1rem;
2165
+
2166
+ background: white;
2167
+ border: 1px solid rgb(230, 230, 230);
2168
+ box-shadow: 0 0.5rem 1rem 0 rgba(0, 0, 0, 0.2);
2169
+ }
2170
+ `;
2171
+ __decorateClass([
2172
+ n3({ type: Object })
2173
+ ], ImgPage.prototype, "page", 2);
2174
+ __decorateClass([
2175
+ n3({ type: Array })
2176
+ ], ImgPage.prototype, "items", 2);
2177
+ __decorateClass([
2178
+ n3({ type: Boolean })
2179
+ ], ImgPage.prototype, "pagenumbers", 2);
2180
+ __decorateClass([
2181
+ n3()
2182
+ ], ImgPage.prototype, "itemPart", 2);
2183
+ __decorateClass([
2184
+ n3()
2185
+ ], ImgPage.prototype, "itemStyle", 2);
2186
+ __decorateClass([
2187
+ n3()
2188
+ ], ImgPage.prototype, "onClickItem", 2);
2189
+ __decorateClass([
2190
+ n3({ type: Boolean })
2191
+ ], ImgPage.prototype, "backdrop", 2);
2192
+ __decorateClass([
2193
+ n3({ type: Object })
2194
+ ], ImgPage.prototype, "overlay", 2);
2195
+ __decorateClass([
2196
+ n3({ type: Object })
2197
+ ], ImgPage.prototype, "tooltip", 2);
2198
+ __decorateClass([
2199
+ n3({ type: Object })
2200
+ ], ImgPage.prototype, "trace", 2);
2201
+ ImgPage = __decorateClass([
2202
+ t("docling-img-page")
2203
+ ], ImgPage);
2204
+
2205
+ // node_modules/@lit/task/task.js
2206
+ var i4 = /* @__PURE__ */ Symbol();
2207
+ var h3 = class {
2208
+ get taskComplete() {
2209
+ return this.t || (1 === this.i ? this.t = new Promise(((t4, s5) => {
2210
+ this.o = t4, this.h = s5;
2211
+ })) : 3 === this.i ? this.t = Promise.reject(this.l) : this.t = Promise.resolve(this.u)), this.t;
2212
+ }
2213
+ constructor(t4, s5, i5) {
2214
+ this.p = 0, this.i = 0, (this._ = t4).addController(this);
2215
+ const h4 = "object" == typeof s5 ? s5 : { task: s5, args: i5 };
2216
+ this.v = h4.task, this.j = h4.args, this.m = h4.argsEqual ?? r5, this.k = h4.onComplete, this.A = h4.onError, this.autoRun = h4.autoRun ?? true, "initialValue" in h4 && (this.u = h4.initialValue, this.i = 2, this.O = this.T?.());
2217
+ }
2218
+ hostUpdate() {
2219
+ true === this.autoRun && this.S();
2220
+ }
2221
+ hostUpdated() {
2222
+ "afterUpdate" === this.autoRun && this.S();
2223
+ }
2224
+ T() {
2225
+ if (void 0 === this.j) return;
2226
+ const t4 = this.j();
2227
+ if (!Array.isArray(t4)) throw Error("The args function must return an array");
2228
+ return t4;
2229
+ }
2230
+ async S() {
2231
+ const t4 = this.T(), s5 = this.O;
2232
+ this.O = t4, t4 === s5 || void 0 === t4 || void 0 !== s5 && this.m(s5, t4) || await this.run(t4);
2233
+ }
2234
+ async run(t4) {
2235
+ let s5, h4;
2236
+ t4 ??= this.T(), this.O = t4, 1 === this.i ? this.q?.abort() : (this.t = void 0, this.o = void 0, this.h = void 0), this.i = 1, "afterUpdate" === this.autoRun ? queueMicrotask((() => this._.requestUpdate())) : this._.requestUpdate();
2237
+ const r6 = ++this.p;
2238
+ this.q = new AbortController();
2239
+ let e4 = false;
2240
+ try {
2241
+ s5 = await this.v(t4, { signal: this.q.signal });
2242
+ } catch (t5) {
2243
+ e4 = true, h4 = t5;
2244
+ }
2245
+ if (this.p === r6) {
2246
+ if (s5 === i4) this.i = 0;
2247
+ else {
2248
+ if (false === e4) {
2249
+ try {
2250
+ this.k?.(s5);
2251
+ } catch {
2252
+ }
2253
+ this.i = 2, this.o?.(s5);
2254
+ } else {
2255
+ try {
2256
+ this.A?.(h4);
2257
+ } catch {
2258
+ }
2259
+ this.i = 3, this.h?.(h4);
2260
+ }
2261
+ this.u = s5, this.l = h4;
2262
+ }
2263
+ this._.requestUpdate();
2264
+ }
2265
+ }
2266
+ abort(t4) {
2267
+ 1 === this.i && this.q?.abort(t4);
2268
+ }
2269
+ get value() {
2270
+ return this.u;
2271
+ }
2272
+ get error() {
2273
+ return this.l;
2274
+ }
2275
+ get status() {
2276
+ return this.i;
2277
+ }
2278
+ render(t4) {
2279
+ switch (this.i) {
2280
+ case 0:
2281
+ return t4.initial?.();
2282
+ case 1:
2283
+ return t4.pending?.();
2284
+ case 2:
2285
+ return t4.complete?.(this.value);
2286
+ case 3:
2287
+ return t4.error?.(this.error);
2288
+ default:
2289
+ throw Error("Unexpected status: " + this.i);
2290
+ }
2291
+ }
2292
+ };
2293
+ var r5 = (s5, i5) => s5 === i5 || s5.length === i5.length && s5.every(((s6, h4) => !m(s6, i5[h4])));
2294
+
2295
+ // src/util.ts
2296
+ function pagesOf(doc) {
2297
+ return Object.values(doc?.pages ?? {}).sort(
2298
+ (p1, p22) => p1.page_no - p22.page_no
2299
+ );
2300
+ }
2301
+ async function loadItems(src, filters = {}) {
2302
+ let doc;
2303
+ if (typeof src === "string") {
2304
+ const fetched = await fetch(src);
2305
+ doc = await fetched.json();
2306
+ } else if (typeof src === "object" && isDocling.Document(src)) {
2307
+ doc = src;
2308
+ }
2309
+ const pages = pagesOf(doc);
2310
+ const allItems = Array.from(
2311
+ iterateDocumentItems(doc, { traversePictures: true })
2312
+ ).map(([item, level]) => Object.assign(item, { level }));
2313
+ let retainedItems = allItems;
2314
+ const cutPages = /* @__PURE__ */ new Set();
2315
+ if (typeof filters.items === "string") {
2316
+ const cropPaths = new Set(
2317
+ filters.items.split(",").map((s5) => s5.trim()).filter((s5) => s5.length > 0)
2318
+ );
2319
+ if (cropPaths.size > 0) {
2320
+ retainedItems = [];
2321
+ for (const item of allItems) {
2322
+ const refParts = item.self_ref.split("/");
2323
+ const partialPaths = [];
2324
+ for (let i5 = 2; i5 < refParts.length + 1; i5++) {
2325
+ partialPaths.push(refParts.slice(0, i5).join("/"));
2326
+ }
2327
+ item.prov?.forEach((p3) => partialPaths.push(`#/pages/${p3.page_no}`));
2328
+ if (partialPaths.some((p3) => cropPaths.has(p3))) {
2329
+ retainedItems.push(item);
2330
+ } else {
2331
+ item.prov?.forEach((p3) => cutPages.add(p3.page_no));
2332
+ }
2333
+ }
2334
+ }
2335
+ } else if (Array.isArray(filters.items)) {
2336
+ retainedItems = [];
2337
+ const allowedItems = new Set(filters.items);
2338
+ for (const item of allItems) {
2339
+ if (allowedItems.has(item)) {
2340
+ retainedItems.push(item);
2341
+ } else {
2342
+ item.prov?.forEach((p3) => cutPages.add(p3.page_no));
2343
+ }
2344
+ }
2345
+ }
2346
+ const pageToItems = {};
2347
+ for (const p3 of pages) {
2348
+ pageToItems[p3.page_no] = [];
2349
+ }
2350
+ for (const item of retainedItems) {
2351
+ for (const p3 of item.prov ?? []) {
2352
+ if (pageToItems[p3.page_no].at(-1) !== item) {
2353
+ pageToItems[p3.page_no].push(item);
2354
+ }
2355
+ }
2356
+ }
2357
+ return pages.map((page) => ({
2358
+ page,
2359
+ items: pageToItems[page.page_no],
2360
+ trimmed: cutPages.has(page.page_no)
2361
+ }));
2362
+ }
2363
+
2364
+ // src/img/ImgTrace.ts
2365
+ var ImgTrace = class extends i3 {
2366
+ render() {
2367
+ if (this.page && this.items && this.items.length > 0) {
2368
+ const { page_no, size } = this.page;
2369
+ const { width = 1, height = 1 } = size;
2370
+ const centers = this.items.map((item) => {
2371
+ const bbox = item.prov?.find((p3) => p3.page_no === page_no)?.bbox;
2372
+ const box = normalBbox(bbox ?? { l: 0, t: 0, r: 0, b: 0 }, this.page);
2373
+ return [(box.l + box.r) / 2, (box.t + box.b) / 2];
2374
+ });
2375
+ const d3 = `M${centers[0][0]} 0 ${centers.slice(0).map((c4) => `L${c4[0]} ${c4[1]}`)} L${centers.at(-1)[0]} ${height}`;
2376
+ return x`<svg viewBox="0 0 ${width} ${height}">
2377
+ <marker
2378
+ id="arrow"
2379
+ viewBox="0 0 10 10"
2380
+ refX="0"
2381
+ refY="5"
2382
+ markerWidth="4"
2383
+ markerHeight="4"
2384
+ orient="auto"
2385
+ >
2386
+ <path d="M 0 0 L 10 5 L 0 10" />
2387
+ </marker>
2388
+
2389
+ <path
2390
+ class="halo"
2391
+ vector-effect="non-scaling-stroke"
2392
+ d=${d3}
2393
+ marker-start="url(#arrow)"
2394
+ />
2395
+
2396
+ <path
2397
+ class="trace"
2398
+ vector-effect="non-scaling-stroke"
2399
+ d=${d3}
2400
+ marker-start="url(#arrow)"
2401
+ />
2402
+ </svg>`;
2403
+ }
2404
+ }
2405
+ };
2406
+ ImgTrace.styles = i`
2407
+ svg {
2408
+ position: absolute;
2409
+ inset: 0;
2410
+ pointer-events: none;
2411
+ }
2412
+
2413
+ .halo {
2414
+ fill: none;
2415
+ stroke-width: 5px;
2416
+ stroke: white;
2417
+ stroke-linejoin: round;
2418
+ }
2419
+
2420
+ .trace {
2421
+ fill: none;
2422
+ stroke-width: 3px;
2423
+ stroke: rgba(0, 0, 255);
2424
+ stroke-linejoin: round;
2425
+ }
2426
+
2427
+ marker > path {
2428
+ fill: rgba(0, 0, 255);
2429
+ stroke: none;
2430
+ }
2431
+ `;
2432
+ __decorateClass([
2433
+ n3({ type: Object })
2434
+ ], ImgTrace.prototype, "page", 2);
2435
+ __decorateClass([
2436
+ n3({ type: Array })
2437
+ ], ImgTrace.prototype, "items", 2);
2438
+ ImgTrace = __decorateClass([
2439
+ t("docling-trace")
2440
+ ], ImgTrace);
2441
+
2442
+ // src/img/ImgPages.ts
2443
+ var ImgPages = class extends i3 {
2444
+ constructor() {
2445
+ super(...arguments);
2446
+ this.src = "";
2447
+ this.trim = "pages";
2448
+ this.fetchTask = new h3(this, {
2449
+ task: async ([src, items]) => loadItems(src, { items }),
2450
+ args: () => [this.src, this.items]
2451
+ });
2452
+ }
2453
+ render() {
2454
+ const children = Array.from(this.childNodes);
2455
+ return this.fetchTask.render({
2456
+ pending: () => x`<p>...</p>`,
2457
+ complete: (paged) => x`
2458
+ ${paged.filter((p3) => !this.trim || p3.items.length > 0).map(
2459
+ ({ page, items }) => x`<docling-img-page
2460
+ part="page"
2461
+ .page=${page}
2462
+ .items=${items}
2463
+ .pagenumbers=${this.pagenumbers !== void 0}
2464
+ .itemPart=${this.itemPart}
2465
+ .itemStyle=${this.itemStyle}
2466
+ .onClickItem=${this.onClickItem}
2467
+ .backdrop=${this.backdrop !== void 0}
2468
+ .overlay=${children.find((c4) => c4 instanceof ItemOverlay)}
2469
+ .tooltip=${children.find((c4) => c4 instanceof ItemTooltip)}
2470
+ .trace=${children.find((c4) => c4 instanceof ImgTrace)}
2471
+ />`
2472
+ )}
2473
+ `
2474
+ });
2475
+ }
2476
+ };
2477
+ ImgPages.styles = i`
2478
+ :host {
2479
+ width: fit-content;
2480
+
2481
+ display: flex;
2482
+ flex-direction: column;
2483
+ align-items: center;
2484
+ gap: 2px;
2485
+
2486
+ color: black;
2487
+ }
2488
+ `;
2489
+ __decorateClass([
2490
+ n3()
2491
+ ], ImgPages.prototype, "alt", 2);
2492
+ __decorateClass([
2493
+ n3()
2494
+ ], ImgPages.prototype, "backdrop", 2);
2495
+ __decorateClass([
2496
+ n3()
2497
+ ], ImgPages.prototype, "items", 2);
2498
+ __decorateClass([
2499
+ n3({ type: Boolean })
2500
+ ], ImgPages.prototype, "pagenumbers", 2);
2501
+ __decorateClass([
2502
+ n3()
2503
+ ], ImgPages.prototype, "src", 2);
2504
+ __decorateClass([
2505
+ n3()
2506
+ ], ImgPages.prototype, "trim", 2);
2507
+ __decorateClass([
2508
+ n3()
2509
+ ], ImgPages.prototype, "itemPart", 2);
2510
+ __decorateClass([
2511
+ n3()
2512
+ ], ImgPages.prototype, "itemStyle", 2);
2513
+ __decorateClass([
2514
+ n3()
2515
+ ], ImgPages.prototype, "onClickItem", 2);
2516
+ ImgPages = __decorateClass([
2517
+ t("docling-img")
2518
+ ], ImgPages);
2519
+
2520
+ // src/table/TablePage.ts
2521
+ var TablePage = class extends i3 {
2522
+ constructor() {
2523
+ super(...arguments);
2524
+ this.columns = [];
2525
+ }
2526
+ render() {
2527
+ return x`
2528
+ ${this.pagenumbers ? x`
2529
+ <tr>
2530
+ <td
2531
+ part="page-number-top"
2532
+ class="page-number"
2533
+ title="Page ${this.page?.page_no}"
2534
+ colspan=${this.columns?.length ?? 1}
2535
+ >
2536
+ ${this.page?.page_no}
2537
+ </td>
2538
+ </tr>
2539
+ ` : E}
2540
+ ${this.items?.map((item) => {
2541
+ const level = item.level ?? 0;
2542
+ const itemStyle = this.itemStyle?.(this.page, item);
2543
+ return x`<tr
2544
+ part=${"item" + (this.itemPart ? " " + this.itemPart(this.page, item) : "")}
2545
+ data-level=${level}
2546
+ style="--docling-level: ${level}; ${itemStyle ?? ""}"
2547
+ >
2548
+ ${this.columns.map((col) => {
2549
+ const copy = col.cloneNode(true);
2550
+ copy.item = item;
2551
+ copy.page = this.page;
2552
+ return x`
2553
+ <td
2554
+ @onclick=${(e4) => this.onClickItem?.(e4, this.page, item)}
2555
+ >
2556
+ ${copy}
2557
+ </td>
2558
+ `;
2559
+ })}
2560
+ </tr>`;
2561
+ })}
2562
+ ${this.pagenumbers ? x`<tr>
2563
+ <td
2564
+ part="page-number-bottom"
2565
+ class="page-number"
2566
+ title="Page ${this.page?.page_no}"
2567
+ colspan=${this.columns?.length ?? 1}
2568
+ >
2569
+ ${this.page?.page_no}
2570
+ </td>
2571
+ </tr>` : E}
2572
+ `;
2573
+ }
2574
+ };
2575
+ TablePage.styles = i`
2576
+ :host {
2577
+ display: table-row-group;
2578
+ }
2579
+
2580
+ tbody {
2581
+ border-bottom: 1px solid rgb(220, 220, 220);
2582
+ }
2583
+
2584
+ .page-number {
2585
+ padding: 0.25rem;
2586
+
2587
+ background-color: white;
2588
+ color: rgb(120, 120, 120);
2589
+ font-size: 0.75rem;
2590
+ line-height: 1rem;
2591
+ }
2592
+
2593
+ tr {
2594
+ cursor: pointer;
2595
+ }
2596
+
2597
+ tr:not(:nth-last-child(2)) {
2598
+ border-bottom: 1px dotted rgb(220, 220, 220);
2599
+ }
2600
+
2601
+ td {
2602
+ padding: 1rem;
2603
+ background-color: white;
2604
+ vertical-align: top;
2605
+ }
2606
+
2607
+ td:first-child {
2608
+ border-left: calc(
2609
+ max(var(--docling-level, 0) - 1, 0) * var(--docling-depth-width, 4px)
2610
+ )
2611
+ solid var(--docling-depth-color, rgb(160, 160, 160));
2612
+ }
2613
+
2614
+ tr:hover td {
2615
+ filter: brightness(95%);
2616
+ }
2617
+ `;
2618
+ __decorateClass([
2619
+ n3({ type: Object })
2620
+ ], TablePage.prototype, "page", 2);
2621
+ __decorateClass([
2622
+ n3({ type: Array })
2623
+ ], TablePage.prototype, "items", 2);
2624
+ __decorateClass([
2625
+ n3({ type: Array })
2626
+ ], TablePage.prototype, "columns", 2);
2627
+ __decorateClass([
2628
+ n3({ type: Boolean })
2629
+ ], TablePage.prototype, "pagenumbers", 2);
2630
+ __decorateClass([
2631
+ n3()
2632
+ ], TablePage.prototype, "itemPart", 2);
2633
+ __decorateClass([
2634
+ n3()
2635
+ ], TablePage.prototype, "itemStyle", 2);
2636
+ __decorateClass([
2637
+ n3()
2638
+ ], TablePage.prototype, "onClickItem", 2);
2639
+ TablePage = __decorateClass([
2640
+ t("docling-table-page")
2641
+ ], TablePage);
2642
+
2643
+ // src/table/TableColumn.ts
2644
+ var TableColumn = class extends ItemView {
2645
+ constructor() {
2646
+ super(...arguments);
2647
+ this.type = "column";
2648
+ }
2649
+ };
2650
+ TableColumn = __decorateClass([
2651
+ t("docling-column")
2652
+ ], TableColumn);
2653
+
2654
+ // src/table/TablePages.ts
2655
+ var TablePages = class extends i3 {
2656
+ constructor() {
2657
+ super(...arguments);
2658
+ this.src = "";
2659
+ this.fetchTask = new h3(this, {
2660
+ task: async ([src, items]) => loadItems(src, { items }),
2661
+ args: () => [this.src, this.items]
2662
+ });
2663
+ }
2664
+ render() {
2665
+ const itemChildren = Array.from(this.childNodes).filter(
2666
+ (item) => item.nodeName.toLowerCase().startsWith("docling-column")
2667
+ );
2668
+ const columns = itemChildren.length > 0 ? itemChildren : [new TableColumn(), new TableColumn()];
2669
+ if (itemChildren.length === 0) {
2670
+ columns[1].appendChild(new ItemProvenance());
2671
+ }
2672
+ return this.fetchTask.render({
2673
+ pending: () => x`<p>...</p>`,
2674
+ complete: (paged) => x`
2675
+ <table part="pages">
2676
+ ${paged.filter((p3) => p3.items.length > 0).map(
2677
+ ({ page, items }) => x`<docling-table-page
2678
+ .page=${page}
2679
+ .items=${items}
2680
+ .columns=${columns}
2681
+ .pagenumbers=${this.pagenumbers !== void 0}
2682
+ .itemPart=${this.itemPart}
2683
+ .itemStyle=${this.itemStyle}
2684
+ .onClickItem=${this.onClickItem}
2685
+ />`
2686
+ )}
2687
+ </table>
2688
+ `
2689
+ });
2690
+ }
2691
+ };
2692
+ TablePages.styles = i`
2693
+ table {
2694
+ width: 100%;
2695
+ border-collapse: collapse;
2696
+ table-layout: fixed;
2697
+ background-color: white;
2698
+ }
2699
+ `;
2700
+ __decorateClass([
2701
+ n3()
2702
+ ], TablePages.prototype, "alt", 2);
2703
+ __decorateClass([
2704
+ n3()
2705
+ ], TablePages.prototype, "items", 2);
2706
+ __decorateClass([
2707
+ n3({ type: Boolean })
2708
+ ], TablePages.prototype, "pagenumbers", 2);
2709
+ __decorateClass([
2710
+ n3()
2711
+ ], TablePages.prototype, "src", 2);
2712
+ __decorateClass([
2713
+ n3()
2714
+ ], TablePages.prototype, "itemPart", 2);
2715
+ __decorateClass([
2716
+ n3()
2717
+ ], TablePages.prototype, "itemStyle", 2);
2718
+ __decorateClass([
2719
+ n3()
2720
+ ], TablePages.prototype, "onClickItem", 2);
2721
+ TablePages = __decorateClass([
2722
+ t("docling-table")
2723
+ ], TablePages);
2724
+ export {
2725
+ AnnotationPictureClassification,
2726
+ AnnotationPictureDescription,
2727
+ DoclingAnnotationElement,
2728
+ DoclingItemElement,
2729
+ ImgPage,
2730
+ ImgPages,
2731
+ ImgTrace,
2732
+ ItemCode,
2733
+ ItemKeyValue,
2734
+ ItemOverlay,
2735
+ ItemProvenance,
2736
+ ItemTable,
2737
+ ItemTemplate,
2738
+ ItemText,
2739
+ ItemTooltip,
2740
+ ItemView,
2741
+ TablePage,
2742
+ TablePages,
2743
+ customDoclingAnnotationElement,
2744
+ customDoclingItemElement,
2745
+ normalBbox
2746
+ };
2747
+ /*! Bundled license information:
2748
+
2749
+ @lit/reactive-element/node/decorators/custom-element.js:
2750
+ @lit/reactive-element/node/decorators/property.js:
2751
+ @lit/reactive-element/node/decorators/state.js:
2752
+ @lit/reactive-element/node/decorators/event-options.js:
2753
+ @lit/reactive-element/node/decorators/base.js:
2754
+ @lit/reactive-element/node/decorators/query.js:
2755
+ @lit/reactive-element/node/decorators/query-all.js:
2756
+ @lit/reactive-element/node/decorators/query-async.js:
2757
+ @lit/reactive-element/node/decorators/query-assigned-nodes.js:
2758
+ lit-html/node/lit-html.js:
2759
+ lit-element/lit-element.js:
2760
+ @lit/task/task.js:
2761
+ (**
2762
+ * @license
2763
+ * Copyright 2017 Google LLC
2764
+ * SPDX-License-Identifier: BSD-3-Clause
2765
+ *)
2766
+
2767
+ @lit-labs/ssr-dom-shim/lib/element-internals.js:
2768
+ @lit-labs/ssr-dom-shim/lib/events.js:
2769
+ (**
2770
+ * @license
2771
+ * Copyright 2023 Google LLC
2772
+ * SPDX-License-Identifier: BSD-3-Clause
2773
+ *)
2774
+
2775
+ @lit-labs/ssr-dom-shim/index.js:
2776
+ @lit/reactive-element/node/css-tag.js:
2777
+ (**
2778
+ * @license
2779
+ * Copyright 2019 Google LLC
2780
+ * SPDX-License-Identifier: BSD-3-Clause
2781
+ *)
2782
+
2783
+ @lit/reactive-element/node/decorators/query-assigned-elements.js:
2784
+ (**
2785
+ * @license
2786
+ * Copyright 2021 Google LLC
2787
+ * SPDX-License-Identifier: BSD-3-Clause
2788
+ *)
2789
+
2790
+ lit-html/node/is-server.js:
2791
+ (**
2792
+ * @license
2793
+ * Copyright 2022 Google LLC
2794
+ * SPDX-License-Identifier: BSD-3-Clause
2795
+ *)
2796
+ */