@docling/docling-components 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,140 +1,487 @@
1
- (function($,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):($=typeof globalThis<"u"?globalThis:$||self,A($.DoclingComponents={}))})(this,function($){"use strict";/**
1
+ (function(a,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(a=typeof globalThis<"u"?globalThis:a||self,_(a.DoclingComponents={}))})(this,function(a){"use strict";/**
2
2
  * @license
3
- * Copyright 2019 Google LLC
3
+ * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */var gt;const A=globalThis,V=A.ShadowRoot&&(A.ShadyCSS===void 0||A.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,G=Symbol(),tt=new WeakMap;let et=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==G)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(V&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=tt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&tt.set(e,t))}return t}toString(){return this.cssText}};const _t=r=>new et(typeof r=="string"?r:r+"",void 0,G),st=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((s,i,o)=>s+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[o+1],r[0]);return new et(e,r,G)},yt=(r,t)=>{if(V)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=A.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},it=V?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return _t(e)})(r):r;/**
5
+ */var Bt;const _=r=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(r,t)}):customElements.define(r,t)};/**
6
6
  * @license
7
- * Copyright 2017 Google LLC
7
+ * Copyright 2019 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:vt,defineProperty:At,getOwnPropertyDescriptor:bt,getOwnPropertyNames:wt,getOwnPropertySymbols:Et,getPrototypeOf:Pt}=Object,b=globalThis,rt=b.trustedTypes,St=rt?rt.emptyScript:"",F=b.reactiveElementPolyfillSupport,O=(r,t)=>r,L={toAttribute(r,t){switch(t){case Boolean:r=r?St:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},q=(r,t)=>!vt(r,t),ot={attribute:!0,type:String,converter:L,reflect:!1,hasChanged:q};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),b.litPropertyMetadata??(b.litPropertyMetadata=new WeakMap);class x extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=ot){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&At(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:o}=bt(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return i==null?void 0:i.call(this)},set(n){const c=i==null?void 0:i.call(this);o.call(this,n),this.requestUpdate(t,c,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ot}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;const t=Pt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){const e=this.properties,s=[...wt(e),...Et(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(it(i))}else t!==void 0&&e.push(it(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return yt(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var o;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const n=(((o=s.converter)==null?void 0:o.toAttribute)!==void 0?s.converter:L).toAttribute(e,s.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){var o;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=s.getPropertyOptions(i),c=typeof n.converter=="function"?{fromAttribute:n.converter}:((o=n.converter)==null?void 0:o.fromAttribute)!==void 0?n.converter:L;this._$Em=i,this[i]=c.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??(s=this.constructor.getPropertyOptions(t)),!(s.hasChanged??q)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,n]of this._$Ep)this[o]=n;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[o,n]of i)n.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.P(o,this[o],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var o;return(o=i.hostUpdate)==null?void 0:o.call(i)}),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[O("elementProperties")]=new Map,x[O("finalized")]=new Map,F==null||F({ReactiveElement:x}),(b.reactiveElementVersions??(b.reactiveElementVersions=[])).push("2.0.4");/**
9
+ */const X=globalThis,at=X.ShadowRoot&&(X.ShadyCSS===void 0||X.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,lt=Symbol(),wt=new WeakMap;let Pt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==lt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(at&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=wt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&wt.set(e,t))}return t}toString(){return this.cssText}};const qt=r=>new Pt(typeof r=="string"?r:r+"",void 0,lt),A=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((s,i,n)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[n+1],r[0]);return new Pt(e,r,lt)},Vt=(r,t)=>{if(at)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=X.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},At=at?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return qt(e)})(r):r;/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const H=globalThis,B=H.trustedTypes,nt=B?B.createPolicy("lit-html",{createHTML:r=>r}):void 0,at="$lit$",w=`lit$${Math.random().toFixed(9).slice(2)}$`,ht="?"+w,Ct=`<${ht}>`,P=document,N=()=>P.createComment(""),R=r=>r===null||typeof r!="object"&&typeof r!="function",J=Array.isArray,xt=r=>J(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",K=`[
14
- \f\r]`,k=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ct=/-->/g,lt=/>/g,S=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),dt=/'/g,pt=/"/g,ut=/^(?:script|style|textarea|title)$/i,It=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),E=It(1),I=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),ft=new WeakMap,C=P.createTreeWalker(P,129);function $t(r,t){if(!J(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return nt!==void 0?nt.createHTML(t):t}const Ut=(r,t)=>{const e=r.length-1,s=[];let i,o=t===2?"<svg>":t===3?"<math>":"",n=k;for(let c=0;c<e;c++){const h=r[c];let d,p,a=-1,l=0;for(;l<h.length&&(n.lastIndex=l,p=n.exec(h),p!==null);)l=n.lastIndex,n===k?p[1]==="!--"?n=ct:p[1]!==void 0?n=lt:p[2]!==void 0?(ut.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=S):p[3]!==void 0&&(n=S):n===S?p[0]===">"?(n=i??k,a=-1):p[1]===void 0?a=-2:(a=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?S:p[3]==='"'?pt:dt):n===pt||n===dt?n=S:n===ct||n===lt?n=k:(n=S,i=void 0);const u=n===S&&r[c+1].startsWith("/>")?" ":"";o+=n===k?h+Ct:a>=0?(s.push(d),h.slice(0,a)+at+h.slice(a)+w+u):h+w+(a===-2?c:u)}return[$t(r,o+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class M{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let o=0,n=0;const c=t.length-1,h=this.parts,[d,p]=Ut(t,e);if(this.el=M.createElement(d,s),C.currentNode=this.el.content,e===2||e===3){const a=this.el.content.firstChild;a.replaceWith(...a.childNodes)}for(;(i=C.nextNode())!==null&&h.length<c;){if(i.nodeType===1){if(i.hasAttributes())for(const a of i.getAttributeNames())if(a.endsWith(at)){const l=p[n++],u=i.getAttribute(a).split(w),m=/([.?@])?(.*)/.exec(l);h.push({type:1,index:o,name:m[2],strings:u,ctor:m[1]==="."?Ot:m[1]==="?"?Ht:m[1]==="@"?Nt:W}),i.removeAttribute(a)}else a.startsWith(w)&&(h.push({type:6,index:o}),i.removeAttribute(a));if(ut.test(i.tagName)){const a=i.textContent.split(w),l=a.length-1;if(l>0){i.textContent=B?B.emptyScript:"";for(let u=0;u<l;u++)i.append(a[u],N()),C.nextNode(),h.push({type:2,index:++o});i.append(a[l],N())}}}else if(i.nodeType===8)if(i.data===ht)h.push({type:2,index:o});else{let a=-1;for(;(a=i.data.indexOf(w,a+1))!==-1;)h.push({type:7,index:o}),a+=w.length-1}o++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function U(r,t,e=r,s){var n,c;if(t===I)return t;let i=s!==void 0?(n=e._$Co)==null?void 0:n[s]:e._$Cl;const o=R(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==o&&((c=i==null?void 0:i._$AO)==null||c.call(i,!1),o===void 0?i=void 0:(i=new o(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=U(r,i._$AS(r,t.values),i,s)),t}class Tt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??P).importNode(e,!0);C.currentNode=i;let o=C.nextNode(),n=0,c=0,h=s[0];for(;h!==void 0;){if(n===h.index){let d;h.type===2?d=new D(o,o.nextSibling,this,t):h.type===1?d=new h.ctor(o,h.name,h.strings,this,t):h.type===6&&(d=new Rt(o,this,t)),this._$AV.push(d),h=s[++c]}n!==(h==null?void 0:h.index)&&(o=C.nextNode(),n++)}return C.currentNode=P,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class D{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=g,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=U(this,t,e),R(t)?t===g||t==null||t===""?(this._$AH!==g&&this._$AR(),this._$AH=g):t!==this._$AH&&t!==I&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):xt(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==g&&R(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var o;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=M.createElement($t(s.h,s.h[0]),this.options)),s);if(((o=this._$AH)==null?void 0:o._$AD)===i)this._$AH.p(e);else{const n=new Tt(i,this),c=n.u(this.options);n.p(e),this.T(c),this._$AH=n}}_$AC(t){let e=ft.get(t.strings);return e===void 0&&ft.set(t.strings,e=new M(t)),e}k(t){J(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const o of t)i===e.length?e.push(s=new D(this.O(N()),this.O(N()),this,this.options)):s=e[i],s._$AI(o),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}}class W{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,o){this.type=1,this._$AH=g,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=g}_$AI(t,e=this,s,i){const o=this.strings;let n=!1;if(o===void 0)t=U(this,t,e,0),n=!R(t)||t!==this._$AH&&t!==I,n&&(this._$AH=t);else{const c=t;let h,d;for(t=o[0],h=0;h<o.length-1;h++)d=U(this,c[s+h],e,h),d===I&&(d=this._$AH[h]),n||(n=!R(d)||d!==this._$AH[h]),d===g?t=g:t!==g&&(t+=(d??"")+o[h+1]),this._$AH[h]=d}n&&!i&&this.j(t)}j(t){t===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ot extends W{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===g?void 0:t}}class Ht extends W{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==g)}}class Nt extends W{constructor(t,e,s,i,o){super(t,e,s,i,o),this.type=5}_$AI(t,e=this){if((t=U(this,t,e,0)??g)===I)return;const s=this._$AH,i=t===g&&s!==g||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==g&&(s===g||i);i&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Rt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){U(this,t)}}const Z=H.litHtmlPolyfillSupport;Z==null||Z(M,D),(H.litHtmlVersions??(H.litHtmlVersions=[])).push("3.2.1");const kt=(r,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const o=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new D(t.insertBefore(N(),o),o,void 0,e??{})}return i._$AI(r),i};/**
13
+ */const{is:Wt,defineProperty:Ft,getOwnPropertyDescriptor:Gt,getOwnPropertyNames:Kt,getOwnPropertySymbols:Jt,getPrototypeOf:Zt}=Object,E=globalThis,It=E.trustedTypes,Xt=It?It.emptyScript:"",ht=E.reactiveElementPolyfillSupport,q=(r,t)=>r,Y={toAttribute(r,t){switch(t){case Boolean:r=r?Xt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Q=(r,t)=>!Wt(r,t),Ct={attribute:!0,type:String,converter:Y,reflect:!1,useDefault:!1,hasChanged:Q};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),E.litPropertyMetadata??(E.litPropertyMetadata=new WeakMap);let R=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Ct){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Ft(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=Gt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){const l=i==null?void 0:i.call(this);n==null||n.call(this,o),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ct}static _$Ei(){if(this.hasOwnProperty(q("elementProperties")))return;const t=Zt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(q("properties"))){const e=this.properties,s=[...Kt(e),...Jt(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(At(i))}else t!==void 0&&e.push(At(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vt(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){var n;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:Y).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var n,o;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const l=s.getPropertyOptions(i),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((n=l.converter)==null?void 0:n.fromAttribute)!==void 0?l.converter:Y;this._$Em=i,this[i]=h.fromAttribute(e,l.type)??((o=this._$Ej)==null?void 0:o.get(i))??null,this._$Em=null}}requestUpdate(t,e,s){var i;if(t!==void 0){const n=this.constructor,o=this[t];if(s??(s=n.getPropertyOptions(t)),!((s.hasChanged??Q)(o,e)||s.useDefault&&s.reflect&&o===((i=this._$Ej)==null?void 0:i.get(t))&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i){const{wrapped:l}=o,h=this[n];l!==!0||this._$AL.has(n)||h===void 0||this.C(n,void 0,o,h)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(e)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};R.elementStyles=[],R.shadowRootOptions={mode:"open"},R[q("elementProperties")]=new Map,R[q("finalized")]=new Map,ht==null||ht({ReactiveElement:R}),(E.reactiveElementVersions??(E.reactiveElementVersions=[])).push("2.1.0");/**
16
14
  * @license
17
15
  * Copyright 2017 Google LLC
18
16
  * SPDX-License-Identifier: BSD-3-Clause
19
- */let j=class extends x{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=kt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return I}};j._$litElement$=!0,j.finalized=!0,(gt=globalThis.litElementHydrateSupport)==null||gt.call(globalThis,{LitElement:j});const Q=globalThis.litElementPolyfillSupport;Q==null||Q({LitElement:j}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
17
+ */const Yt={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:Q},Qt=(r=Yt,t,e)=>{const{kind:s,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),s==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),s==="accessor"){const{name:o}=e;return{set(l){const h=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,h,r)},init(l){return l!==void 0&&this.C(o,void 0,r,l),l}}}if(s==="setter"){const{name:o}=e;return function(l){const h=this[o];t.call(this,l),this.requestUpdate(o,h,r)}}throw Error("Unsupported decorator location: "+s)};function u(r){return(t,e)=>typeof e=="object"?Qt(r,t,e):((s,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}const ct=[];function pt(r){const t=_(r);return function(e,s){return ct.push(e),t(e,s)}}/**
20
18
  * @license
21
19
  * Copyright 2017 Google LLC
22
20
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const Mt=r=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(r,t)}):customElements.define(r,t)};/**
21
+ */const V=globalThis,tt=V.trustedTypes,Ot=tt?tt.createPolicy("lit-html",{createHTML:r=>r}):void 0,Tt="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,Et="?"+S,te=`<${Et}>`,U=document,W=()=>U.createComment(""),F=r=>r===null||typeof r!="object"&&typeof r!="function",dt=Array.isArray,ee=r=>dt(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",ut=`[
22
+ \f\r]`,G=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,St=/-->/g,Dt=/>/g,M=RegExp(`>|${ut}(?:([^\\s"'>=/]+)(${ut}*=${ut}*(?:[^
23
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),jt=/'/g,kt=/"/g,Ut=/^(?:script|style|textarea|title)$/i,Mt=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),g=Mt(1),et=Mt(2),z=Symbol.for("lit-noChange"),$=Symbol.for("lit-nothing"),Nt=new WeakMap,N=U.createTreeWalker(U,129);function Ht(r,t){if(!dt(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ot!==void 0?Ot.createHTML(t):t}const ie=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=G;for(let l=0;l<e;l++){const h=r[l];let p,d,c=-1,m=0;for(;m<h.length&&(o.lastIndex=m,d=o.exec(h),d!==null);)m=o.lastIndex,o===G?d[1]==="!--"?o=St:d[1]!==void 0?o=Dt:d[2]!==void 0?(Ut.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=M):d[3]!==void 0&&(o=M):o===M?d[0]===">"?(o=i??G,c=-1):d[1]===void 0?c=-2:(c=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?M:d[3]==='"'?kt:jt):o===kt||o===jt?o=M:o===St||o===Dt?o=G:(o=M,i=void 0);const f=o===M&&r[l+1].startsWith("/>")?" ":"";n+=o===G?h+te:c>=0?(s.push(p),h.slice(0,c)+Tt+h.slice(c)+S+f):h+S+(c===-2?l:f)}return[Ht(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class K{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const l=t.length-1,h=this.parts,[p,d]=ie(t,e);if(this.el=K.createElement(p,s),N.currentNode=this.el.content,e===2||e===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=N.nextNode())!==null&&h.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const c of i.getAttributeNames())if(c.endsWith(Tt)){const m=d[o++],f=i.getAttribute(c).split(S),b=/([.?@])?(.*)/.exec(m);h.push({type:1,index:n,name:b[2],strings:f,ctor:b[1]==="."?re:b[1]==="?"?ne:b[1]==="@"?oe:it}),i.removeAttribute(c)}else c.startsWith(S)&&(h.push({type:6,index:n}),i.removeAttribute(c));if(Ut.test(i.tagName)){const c=i.textContent.split(S),m=c.length-1;if(m>0){i.textContent=tt?tt.emptyScript:"";for(let f=0;f<m;f++)i.append(c[f],W()),N.nextNode(),h.push({type:2,index:++n});i.append(c[m],W())}}}else if(i.nodeType===8)if(i.data===Et)h.push({type:2,index:n});else{let c=-1;for(;(c=i.data.indexOf(S,c+1))!==-1;)h.push({type:7,index:n}),c+=S.length-1}n++}}static createElement(t,e){const s=U.createElement("template");return s.innerHTML=t,s}}function B(r,t,e=r,s){var o,l;if(t===z)return t;let i=s!==void 0?(o=e._$Co)==null?void 0:o[s]:e._$Cl;const n=F(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((l=i==null?void 0:i._$AO)==null||l.call(i,!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=B(r,i._$AS(r,t.values),i,s)),t}class se{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??U).importNode(e,!0);N.currentNode=i;let n=N.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let p;h.type===2?p=new J(n,n.nextSibling,this,t):h.type===1?p=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(p=new ae(n,this,t)),this._$AV.push(p),h=s[++l]}o!==(h==null?void 0:h.index)&&(n=N.nextNode(),o++)}return N.currentNode=U,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class J{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=$,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=B(this,t,e),F(t)?t===$||t==null||t===""?(this._$AH!==$&&this._$AR(),this._$AH=$):t!==this._$AH&&t!==z&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ee(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==$&&F(this._$AH)?this._$AA.nextSibling.data=t:this.T(U.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=K.createElement(Ht(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(e);else{const o=new se(i,this),l=o.u(this.options);o.p(e),this.T(l),this._$AH=o}}_$AC(t){let e=Nt.get(t.strings);return e===void 0&&Nt.set(t.strings,e=new K(t)),e}k(t){dt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new J(this.O(W()),this.O(W()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}}class it{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=$,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=$}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(n===void 0)t=B(this,t,e,0),o=!F(t)||t!==this._$AH&&t!==z,o&&(this._$AH=t);else{const l=t;let h,p;for(t=n[0],h=0;h<n.length-1;h++)p=B(this,l[s+h],e,h),p===z&&(p=this._$AH[h]),o||(o=!F(p)||p!==this._$AH[h]),p===$?t=$:t!==$&&(t+=(p??"")+n[h+1]),this._$AH[h]=p}o&&!i&&this.j(t)}j(t){t===$?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class re extends it{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$?void 0:t}}class ne extends it{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==$)}}class oe extends it{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=B(this,t,e,0)??$)===z)return;const s=this._$AH,i=t===$&&s!==$||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==$&&(s===$||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class ae{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){B(this,t)}}const mt=V.litHtmlPolyfillSupport;mt==null||mt(K,J),(V.litHtmlVersions??(V.litHtmlVersions=[])).push("3.3.0");const le=(r,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const n=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new J(t.insertBefore(W(),n),n,void 0,e??{})}return i._$AI(r),i};/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */const Dt={attribute:!0,type:String,converter:L,reflect:!1,hasChanged:q},jt=(r=Dt,t,e)=>{const{kind:s,metadata:i}=e;let o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),o.set(e.name,r),s==="accessor"){const{name:n}=e;return{set(c){const h=t.get.call(this);t.set.call(this,c),this.requestUpdate(n,h,r)},init(c){return c!==void 0&&this.P(n,void 0,r),c}}}if(s==="setter"){const{name:n}=e;return function(c){const h=this[n];t.call(this,c),this.requestUpdate(n,h,r)}}throw Error("Unsupported decorator location: "+s)};function y(r){return(t,e)=>typeof e=="object"?jt(r,t,e):((s,i,o)=>{const n=i.hasOwnProperty(o);return i.constructor.createProperty(o,n?{...s,wrapped:!0}:s),n?Object.getOwnPropertyDescriptor(i,o):void 0})(r,t,e)}/**
27
+ */const H=globalThis;let w=class extends R{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=le(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return z}};w._$litElement$=!0,w.finalized=!0,(Bt=H.litElementHydrateSupport)==null||Bt.call(H,{LitElement:w});const gt=H.litElementPolyfillSupport;gt==null||gt({LitElement:w}),(H.litElementVersions??(H.litElementVersions=[])).push("4.2.0");var he=Object.defineProperty,st=(r,t,e,s)=>{for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(t,e,i)||i);return i&&he(t,e,i),i};class D extends w{render(){if(this.annotation&&this.item&&this.page&&this.canDrawAnnotation(this.annotation)&&this.canDrawItem(this.item))return this.renderAnnotation(this.annotation,this.item,this.page,this.prov)}}st([u({attribute:!1})],D.prototype,"annotation"),st([u({attribute:!1})],D.prototype,"item"),st([u({attribute:!1})],D.prototype,"page"),st([u({attribute:!1})],D.prototype,"prov");function L(...r){return function(t){return v.DocItem(t)&&r.includes(t.label)}}var O={CodeItem:L("code"),ListItem:L("list_item"),PictureItem:L("chart","picture"),SectionHeaderItem:L("section_header"),TableItem:L("document_index","table"),TextItem:L("caption","checkbox_selected","checkbox_unselected","footnote","page_footer","page_header","paragraph","reference","text")};function T(...r){return function(t){return r.includes(t.kind)}}var ft={PictureBarChart:T("bar_chart_data"),PictureClassification:T("classification"),PictureDescription:T("description"),PictureMisc:T("misc"),PictureMolecule:T("molecule_data"),PictureLineChart:T("line_chart_data"),PicturePieChart:T("pie_chart_data"),PictureScatterChart:T("scatter_chart_data"),PictureStackedBarChart:T("stacked_bar_chart_data")},v={DocItem(r){return v.NodeItem(r)&&!v.GroupItem(r)},Document(r){return"schema_name"in r&&r.schema_name==="DoclingDocument"},GroupItem(r){return v.NodeItem(r)&&(r.self_ref.startsWith("#/groups/")||r.self_ref==="#/body")},NodeItem(r){return"self_ref"in r},...ft,...O};function*ce(r,t={}){r&&(yield*e(t.root??r.body));function*e(s,i=0){var n;if((!v.GroupItem(s)||t.withGroups)&&(v.DocItem(s)?(t.pageNo===void 0||(n=s.prov)!=null&&n.some(o=>o.page_no===t.pageNo))&&(yield[s,i]):yield[s,i]),!(v.PictureItem(s)&&!t.traversePictures))for(const o of s.children??[]){const l=pe(r,o);v.NodeItem(l)&&(yield*e(l,i+1))}}}function pe(r,t){return t.$ref.split("/").slice(1).reduce((s,i)=>s[i],r)}var de=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,xt=(r,t,e,s)=>{for(var i=s>1?void 0:s?ue(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&de(t,e,i),i};a.AnnotationPictureClassification=class extends D{constructor(){super(...arguments),this.precision=2}renderAnnotation(t,e,s,i){const n=t.predicted_classes??[],o=Math.pow(10,-1*this.precision),l=n.filter(d=>o<d.confidence),h=n.filter(d=>d.confidence<o),p=d=>d.toLocaleString(void 0,{maximumFractionDigits:this.precision});return g`<table>
28
+ <thead>
29
+ <tr>
30
+ <th>Class</th>
31
+ <th>Confidence</th>
32
+ </tr>
33
+ </thead>
34
+ <tbody>
35
+ ${l.map(({class_name:d,confidence:c})=>g`<tr>
36
+ <td>${d}</td>
37
+ <td>${p(c)}</td>
38
+ </tr>`)}
39
+ ${h.length===0?$:g`<tr
40
+ class="more"
41
+ title=${h.map(d=>`${d.class_name} ${d.confidence}`).join(`
42
+ `)}
43
+ >
44
+ <td>${h.length} more</td>
45
+ <td>< ${p(o)}</td>
46
+ </tr>`}
47
+ </tbody>
48
+ </table>`}canDrawAnnotation(t){return ft.PictureClassification(t)}canDrawItem(t){return O.PictureItem(t)}},a.AnnotationPictureClassification.styles=A`
49
+ table {
50
+ margin: 0.5rem;
51
+ font-size: inherit;
52
+ line-height: 1.25;
53
+ }
54
+
55
+ td,
56
+ th {
57
+ padding: 0 1rem 0 0;
58
+ }
59
+
60
+ th {
61
+ font-weight: bold;
62
+ text-align: left;
63
+ }
64
+
65
+ tr.more td {
66
+ padding-top: 0.25rem;
67
+ color: gray;
68
+ }
69
+ `,xt([u()],a.AnnotationPictureClassification.prototype,"precision",2),a.AnnotationPictureClassification=xt([pt("docling-picture-classification")],a.AnnotationPictureClassification);var me=Object.getOwnPropertyDescriptor,ge=(r,t,e,s)=>{for(var i=s>1?void 0:s?me(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.AnnotationPictureDescription=class extends D{renderAnnotation(t,e,s,i){return g`<p><span>Description</span>${t.text}</p>`}canDrawAnnotation(t){return ft.PictureDescription(t)}canDrawItem(t){return O.PictureItem(t)}},a.AnnotationPictureDescription.styles=A`
70
+ p {
71
+ margin: 0.5rem;
72
+ font-size: inherit;
73
+ line-height: 1.25;
74
+ white-space: pre-line;
75
+ }
76
+
77
+ span {
78
+ padding-right: 0.5rem;
79
+ font-weight: bold;
80
+ }
81
+ `,a.AnnotationPictureDescription=ge([pt("docling-picture-description")],a.AnnotationPictureDescription);const $t=[];function _t(r){const t=_(r);return function(e,s){return $t.push(e),t(e,s)}}var fe=Object.defineProperty,yt=(r,t,e,s)=>{for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(t,e,i)||i);return i&&fe(t,e,i),i};class I extends w{render(){if(this.item&&this.page&&this.canDrawItem(this.item))return this.renderItem(this.item,this.page,this.prov)}}yt([u({attribute:!1})],I.prototype,"item"),yt([u({attribute:!1})],I.prototype,"page"),yt([u({attribute:!1})],I.prototype,"prov");var $e=Object.getOwnPropertyDescriptor,_e=(r,t,e,s)=>{for(var i=s>1?void 0:s?$e(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemProvenance=class extends I{renderItem(t,e){var n;const{image:s}=e,i=(n=t.prov)==null?void 0:n.find(o=>{var l;return o.page_no===((l=this.page)==null?void 0:l.page_no)});if(s&&i){const{width:o=1,height:l=1}=this.page.size,{l:h,r:p,t:d,b:c}=x(i.bbox,e);return g`
82
+ <svg
83
+ width=${(p-h)*((s.size.width??1)/o)}
84
+ viewBox="${h} ${d} ${p-h} ${c-d}"
85
+ >
86
+ <image href=${s.uri} width=${o} height=${l} />
87
+ </svg>
88
+ `}else return g`<span>Invalid provenance.</span>`}canDrawItem(t){return v.DocItem(t)}},a.ItemProvenance.styles=A`
89
+ svg {
90
+ max-width: 100%;
91
+ }
92
+ `,a.ItemProvenance=_e([_("docling-item-provenance")],a.ItemProvenance);var ye=Object.getOwnPropertyDescriptor,be=(r,t,e,s)=>{for(var i=s>1?void 0:s?ye(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemTable=class extends I{renderItem(t){const e=new Set;return g`
93
+ <div class="container">
94
+ <table>
95
+ <tbody>
96
+ ${t.data.grid.map(i=>g`<tr>
97
+ ${i.map(n=>{if(!s(n))return g`<td
98
+ class=${n.column_header||n.row_header?"header":""}
99
+ colspan=${n.col_span??1}
100
+ rowspan=${n.row_span??1}
101
+ >
102
+ ${n.text}
103
+ </td>`})}
104
+ </tr>`)}
105
+ </tbody>
106
+ </table>
107
+ </div>
108
+ `;function s(i){const n=e.has([i.start_col_offset_idx,i.start_row_offset_idx].join());if(!n)for(let o=i.start_col_offset_idx;o<i.end_col_offset_idx;o++)for(let l=i.start_row_offset_idx;l<i.end_row_offset_idx;l++)e.add([o,l].join());return n}}canDrawItem(t){return O.TableItem(t)}},a.ItemTable.styles=A`
109
+ .container {
110
+ position: relative;
111
+ min-width: 0;
112
+ max-width: 100%;
113
+ min-height: 0;
114
+ overflow: auto;
115
+ }
116
+
117
+ table {
118
+ border-collapse: collapse;
119
+ font-size: 75%;
120
+ line-height: 1.25;
121
+ }
122
+
123
+ td {
124
+ padding: 0.125rem 0.25rem;
125
+ background-color: var(--cds-layer);
126
+ border: 1px solid rgb(220, 220, 220);
127
+
128
+ color: black;
129
+ text-decoration: none;
130
+ word-break: normal;
131
+ text-align: left;
132
+ }
133
+
134
+ td.header {
135
+ font-weight: bold;
136
+ }
137
+
138
+ td:hover {
139
+ filter: brightness(95%);
140
+ }
141
+
142
+ td:target {
143
+ outline: 3px solid blue;
144
+ }
145
+ `,a.ItemTable=be([_t("docling-item-table")],a.ItemTable);var ve=Object.getOwnPropertyDescriptor,we=(r,t,e,s)=>{for(var i=s>1?void 0:s?ve(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemTemplate=class extends I{constructor(){super(...arguments),this.renderItem=Function("item","page",`"use strict"; return this.html\`${this.innerHTML}\`;`).bind({html:g})}canDrawItem(t){return v.DocItem(t)}},a.ItemTemplate=we([_("docling-item-template")],a.ItemTemplate);var Pe=Object.getOwnPropertyDescriptor,Ae=(r,t,e,s)=>{for(var i=s>1?void 0:s?Pe(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemText=class extends I{renderItem(t,e,s){const i=O.SectionHeaderItem(t)?"header":"";if(s){const{l:n,r:o,t:l,b:h}=x(s.bbox,e),p=Math.sqrt((o-n)*(h-l)/t.text.length),d=Math.min(Math.floor(1.25*p),(h-l)/1.25),[c,m]=s.charspan??[0,t.text.length],f=t.text.substring(c,m);return g`<p
146
+ class=${i}
147
+ style="font-size: ${d}px; line-height: ${1.25*d}px"
148
+ >
149
+ ${f}
150
+ </p>`}else return g`<p class=${i}>${t.text}</p>`}canDrawItem(t){return O.TextItem(t)||O.SectionHeaderItem(t)||O.ListItem(t)}},a.ItemText.styles=A`
151
+ p {
152
+ margin: 0;
153
+ overflow-wrap: anywhere;
154
+ font-size: 1rem;
155
+ line-height: 1.25rem;
156
+ }
157
+
158
+ .header {
159
+ font-weight: bold;
160
+ }
161
+ `,a.ItemText=Ae([_t("docling-item-text")],a.ItemText);var Ie=Object.getOwnPropertyDescriptor,bt=(r,t,e,s)=>{for(var i=s>1?void 0:s?Ie(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemView=class extends I{get itemChildren(){return Array.from(this.childNodes??[]).filter(t=>t instanceof I)}get annotationChildren(){return Array.from(this.childNodes).filter(t=>t instanceof D)}get isCustomized(){return this.itemChildren.length>0||this.annotationChildren.length>0}renderItem(t,e,s){const i=[],n=this.isCustomized;n?this.itemChildren.filter(l=>l.canDrawItem(t)).forEach(l=>i.push(l)):$t.filter(l=>l.prototype.canDrawItem(t)).forEach(l=>i.push(new l));const o=t.annotations??[];for(const l of o){const h=[];n?this.annotationChildren.filter(p=>p.canDrawItem(p)&&p.canDrawAnnotation(l)).forEach(p=>h.push(p.cloneNode(!0))):ct.filter(p=>p.prototype.canDrawItem(t)&&p.prototype.canDrawAnnotation(l)).forEach(p=>h.push(new p));for(const p of h)p.annotation=l;i.push(...h)}for(const l of i)l.item=t,l.page=e,l.prov=s;return g`${i}`}canDrawItem(t){return v.DocItem(t)&&this.isCustomized?this.itemChildren.some(e=>e.canDrawItem(t))||this.annotationChildren.some(e=>{var s;return e.canDrawItem(t)&&((s=t.annotations)==null?void 0:s.some(i=>e.canDrawAnnotation(i)))}):$t.some(e=>e.prototype.canDrawItem(t))||ct.some(e=>{var s;return e.prototype.canDrawItem(t)&&((s=t.annotations)==null?void 0:s.some(i=>e.prototype.canDrawAnnotation(i)))})}},a.ItemView=bt([_("docling-view")],a.ItemView),a.ItemOverlay=class extends a.ItemView{constructor(){super(...arguments),this.type="overlay"}},a.ItemOverlay=bt([_("docling-overlay")],a.ItemOverlay),a.ItemTooltip=class extends a.ItemView{constructor(){super(...arguments),this.type="tooltip"}},a.ItemTooltip=bt([_("docling-tooltip")],a.ItemTooltip);function x(r,t){const{height:e=1}=t.size;return r.coord_origin==="TOPLEFT"?r:{...r,t:e-r.t,b:e-r.b}}var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,P=(r,t,e,s)=>{for(var i=s>1?void 0:s?Oe(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Ce(t,e,i),i};a.ImgPage=class extends w{constructor(){super(...arguments),this.pagenumbers=!1}render(){var t,e,s;if((t=this.page)!=null&&t.image){const{image:i,size:n,page_no:o}=this.page,{width:l=1,height:h=1}=n,p=this.onClickItem&&this.page?(d,c)=>{var m;return(m=this.onClickItem)==null?void 0:m.call(this,d,this.page,c)}:void 0;return g`
162
+ <div class="page" @onclick=${d=>p==null?void 0:p(d)}>
163
+ <svg
164
+ class="base"
165
+ width=${i.size.width}
166
+ viewBox="0 0 ${l} ${h}"
167
+ >
168
+ ${this.backdrop?et`
169
+ <image
170
+ class="backdrop"
171
+ href=${i.uri}
172
+ width=${l}
173
+ height=${h}
174
+ />
175
+
176
+ <clippath id="clip-page-${o}">
177
+ ${(e=this.items)==null?void 0:e.map(d=>{var m;const c=(m=d.prov)==null?void 0:m.find(f=>f.page_no===o);if(c){const{l:f,r:b,t:y,b:nt}=x(c.bbox,this.page);return et`<rect
178
+ x=${f}
179
+ y=${y}
180
+ width=${b-f}
181
+ height=${nt-y}
182
+ />`}})}
183
+ </clippath>
184
+ `:$}
185
+
186
+ <image
187
+ id="image"
188
+ href=${i.uri}
189
+ clip-path="url(#clip-page-${o})"
190
+ width=${l}
191
+ height=${h}
192
+ />
193
+
194
+ ${(s=this.items)==null?void 0:s.flatMap(d=>(d.prov??[]).filter(c=>c.page_no===o).map(c=>{var nt;const{l:m,r:f,t:b,b:y}=x(c.bbox,this.page);return et`
195
+ ${this.layOver(d,c)}
196
+
197
+ <rect
198
+ part=${"item"+(this.itemPart?" "+this.itemPart(this.page,d):"")}
199
+ style=${(nt=this.itemStyle)==null?void 0:nt.call(this,this.page,d)}
200
+ x=${m}
201
+ y=${b}
202
+ width=${f-m}
203
+ height=${y-b}
204
+ vector-effect="non-scaling-stroke"
205
+ @click=${ot=>{ot.stopPropagation(),p==null||p(ot,d)}}
206
+ @mouseenter=${ot=>{const Z=ot.currentTarget.getBoundingClientRect(),Lt=[Z.top*window.innerWidth,(window.innerWidth-Z.right)*window.innerHeight,(window.innerHeight-Z.bottom)*window.innerWidth,Z.left*window.innerHeight],Le=Math.max(...Lt),qe=Lt.findIndex(Ve=>Ve===Le);this.attachTooltip(d,c,Z,qe)}}
207
+ @mouseleave=${()=>this.removeTooltip()}
208
+ />
209
+ `}))}
210
+ </svg>
211
+
212
+ ${this.renderTrace()}
213
+ ${this.pagenumbers?g`<header
214
+ part="page-number-top"
215
+ class="page-number-top"
216
+ title="Page ${o}"
217
+ >
218
+ ${o}
219
+ </header>
220
+
221
+ <header
222
+ part="page-number-bottom"
223
+ class="page-number-bottom"
224
+ title="Page ${o}"
225
+ >
226
+ ${o}
227
+ </header>`:$}
228
+ </div>
229
+ `}else return g`Invalid page image.`}layOver(t,e){var s;if((s=this.overlay)!=null&&s.canDrawItem(t)){const i=this.overlay.cloneNode(!0);i.item=t,i.page=this.page,i.prov=e;const{l:n,r:o,t:l,b:h}=x(e.bbox,this.page),p=O.PictureItem(t)?"softOverlay":"hardOverlay";return et`<foreignObject part="overlay" class=${p} x=${n} y=${l} width=${o-n} height=${h-l}>${i}</foreignObject>`}}attachTooltip(t,e,s,i){var n;if((n=this.tooltip)!=null&&n.canDrawItem(t)){const o=this.tooltip.cloneNode(!0);o.id="tooltip",o.setAttribute("part","tooltip"),o.className="tooltip",o.setAttribute("style",`
230
+ ${i===1?`left: ${s.right}px`:i===3?`right: ${window.outerWidth-s.left}px`:`left: calc(${s.left}px - 2rem)`};
231
+ ${i===0?`bottom: ${window.innerHeight-s.top}px`:i===2?`top: ${s.bottom}px`:`top: calc(${s.top}px - 2rem)`};
232
+ max-width: ${2*Math.max(e.bbox.r-e.bbox.l,200)}px;
233
+ `),o.item=t,o.page=this.page,this.renderRoot.appendChild(o)}}removeTooltip(){var t;(t=this.renderRoot.querySelector("#tooltip"))==null||t.remove()}renderTrace(){if(this.trace){const t=this.trace.cloneNode(!0);return t.page=this.page,t.items=this.items,t}}},a.ImgPage.styles=A`
234
+ .page {
235
+ position: relative;
236
+ width: fit-content;
237
+ color: black;
238
+ }
239
+
240
+ .base {
241
+ max-width: 100%;
242
+ }
243
+
244
+ svg:not(.base) {
245
+ position: absolute;
246
+ inset: 0;
247
+ }
248
+
249
+ .backdrop {
250
+ opacity: 0.3;
251
+ }
252
+
253
+ .page-number-top,
254
+ .page-number-bottom {
255
+ position: absolute;
256
+ left: 0;
257
+ width: fit-content;
258
+ padding: 0 0.25rem;
259
+
260
+ font-size: 0.75rem;
261
+ line-height: 1rem;
262
+ color: rgb(120, 120, 120);
263
+ mix-blend-mode: difference;
264
+ }
265
+
266
+ .page-number-top {
267
+ top: 0;
268
+ }
269
+
270
+ .page-number-bottom {
271
+ bottom: 0;
272
+ }
273
+
274
+ rect {
275
+ fill: blue;
276
+ fill-opacity: 0.0001; /* To activate hover. */
277
+ stroke: grey;
278
+ stroke-width: 1px;
279
+ stroke-dasharray: 1;
280
+ cursor: pointer;
281
+ }
282
+
283
+ rect:hover {
284
+ fill-opacity: 0.1;
285
+ stroke: blue;
286
+ }
287
+
288
+ rect:target {
289
+ stroke: blue;
290
+ stroke-width: 3px;
291
+ stroke-dasharray: none;
292
+ }
293
+
294
+ .hardOverlay,
295
+ .softOverlay {
296
+ font-size: 62.5%;
297
+ background-color: white;
298
+ }
299
+
300
+ .softOverlay {
301
+ opacity: 0.9;
302
+ }
303
+
304
+ .tooltip {
305
+ position: fixed;
306
+ z-index: 100;
307
+ padding: 1rem;
308
+ margin: 1rem;
309
+
310
+ background: white;
311
+ border: 1px solid rgb(230, 230, 230);
312
+ box-shadow: 0 0.5rem 1rem 0 rgba(0, 0, 0, 0.2);
313
+ }
314
+ `,P([u({type:Object})],a.ImgPage.prototype,"page",2),P([u({type:Array})],a.ImgPage.prototype,"items",2),P([u({type:Boolean})],a.ImgPage.prototype,"pagenumbers",2),P([u()],a.ImgPage.prototype,"itemPart",2),P([u()],a.ImgPage.prototype,"itemStyle",2),P([u()],a.ImgPage.prototype,"onClickItem",2),P([u({type:Boolean})],a.ImgPage.prototype,"backdrop",2),P([u({type:Object})],a.ImgPage.prototype,"overlay",2),P([u({type:Object})],a.ImgPage.prototype,"tooltip",2),P([u({type:Object})],a.ImgPage.prototype,"trace",2),a.ImgPage=P([_("docling-img-page")],a.ImgPage);/**
28
315
  * @license
29
316
  * Copyright 2017 Google LLC
30
317
  * SPDX-License-Identifier: BSD-3-Clause
31
- */const zt=Symbol();class Lt{get taskComplete(){return this.t||(this.i===1?this.t=new Promise((t,e)=>{this.o=t,this.h=e}):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,s){var o;this.p=0,this.i=0,(this._=t).addController(this);const i=typeof e=="object"?e:{task:e,args:s};this.v=i.task,this.j=i.args,this.m=i.argsEqual??qt,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=(o=this.T)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;const t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){const t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){var n,c,h,d,p;let e,s;t??(t=this.T()),this.O=t,this.i===1?(n=this.q)==null||n.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this._.requestUpdate()):this._.requestUpdate();const i=++this.p;this.q=new AbortController;let o=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(a){o=!0,s=a}if(this.p===i){if(e===zt)this.i=0;else{if(o===!1){try{(c=this.k)==null||c.call(this,e)}catch{}this.i=2,(h=this.o)==null||h.call(this,e)}else{try{(d=this.A)==null||d.call(this,s)}catch{}this.i=3,(p=this.h)==null||p.call(this,s)}this.u=e,this.l=s}this._.requestUpdate()}}abort(t){var e;this.i===1&&((e=this.q)==null||e.abort(t))}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){var e,s,i,o;switch(this.i){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(s=t.pending)==null?void 0:s.call(t);case 2:return(i=t.complete)==null?void 0:i.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.i)}}}const qt=(r,t)=>r===t||r.length===t.length&&r.every((e,s)=>!q(e,t[s]));function T(...r){return function(t){return v.DocItem(t)&&r.includes(t.label)}}var Bt={CodeItem:T("code"),ListItem:T("list_item"),PictureItem:T("picture"),SectionHeaderItem:T("section_header"),TableItem:T("document_index","table"),TextItem:T("caption","checkbox_selected","checkbox_unselected","footnote","page_footer","page_header","paragraph","reference","text")},v={Document(r){return"schema_name"in r&&r.schema_name==="DoclingDocument"},NodeItem(r){return"self_ref"in r},GroupItem(r){return v.NodeItem(r)&&(r.self_ref.startsWith("#/groups/")||r.self_ref==="#/body")},DocItem(r){return v.NodeItem(r)&&!v.GroupItem(r)},...Bt};function*Wt(r,t={}){r&&(yield*e(t.root??r.body));function*e(s,i=0){var o;if((!v.GroupItem(s)||t.withGroups)&&(v.DocItem(s)?(t.pageNo===void 0||(o=s.prov)!=null&&o.some(n=>n.page_no===t.pageNo))&&(yield[s,i]):yield[s,i]),!(v.PictureItem(s)&&!t.traversePictures))for(const n of s.children??[]){const c=Vt(r,n);v.NodeItem(c)&&(yield*e(c,i+1))}}}function Vt(r,t){return t.$ref.split("/").slice(1).reduce((s,i)=>s[i],r)}function Gt(r){return Object.values((r==null?void 0:r.pages)??{}).sort((t,e)=>t.page_no-e.page_no)}async function Ft(r,t={}){var h,d,p;let e;typeof r=="string"?e=await(await fetch(r)).json():typeof r=="object"&&v.Document(r)&&(e=r);const s=Gt(e),i=Array.from(Wt(e)).map(([a])=>a);let o=i;const n=new Set;if(typeof t.items=="string"){const a=new Set(t.items.split(",").map(l=>l.trim()).filter(l=>l.length>0));if(a.size>0){o=[];for(const l of i){const u=l.self_ref.split("/"),m=[];for(let f=2;f<u.length+1;f++)m.push(u.slice(0,f).join("/"));(h=l.prov)==null||h.forEach(f=>m.push(`#/pages/${f.page_no}`)),m.some(f=>a.has(f))?o.push(l):(d=l.prov)==null||d.forEach(f=>n.add(f.page_no))}}}else if(Array.isArray(t.items)){o=[];const a=new Set(t.items);for(const l of i)a.has(l)?o.push(l):(p=l.prov)==null||p.forEach(u=>n.add(u.page_no))}const c={};for(const a of s)c[a.page_no]=[];for(const a of o)for(const l of a.prov??[])c[l.page_no].push(a);return s.map(a=>({page:a,items:c[a.page_no],trimmed:n.has(a.page_no)}))}function Jt({page:r,items:t=[],pagenumbers:e,backdrop:s,itemPart:i,itemStyle:o,onclickitem:n}){if(r.image){const{size:h}=r,{width:d=1,height:p=1}=h,a=n?(l,u)=>n(l,r,u):void 0;return E`
32
- <div part="page" class="page" @onclick=${l=>a==null?void 0:a(l)} role="tab">
33
- <svg width=${r.image.size.width} viewBox="0 0 ${d} ${p}">
34
- <!-- Suppressed backdrop image. -->
35
- ${s?E`
36
- <image
37
- class="backdrop"
38
- href=${r.image.uri}
39
- width=${d}
40
- height=${p}
41
- />
42
-
43
- <clippath id="clip-page-${r.page_no}">
44
- ${t.map(l=>{var m;const u=(m=l.prov)==null?void 0:m.find(f=>f.page_no===r.page_no);if(u){const{l:f,r:X,t:z,b:Y}=u.bbox;return E`<rect
45
- x=${f}
46
- y=${p-z}
47
- width=${X-f}
48
- height=${z-Y}
49
- />`}})}
50
- </clippath>
51
- `:""}
52
-
53
- <!-- Foreground image. -->
54
- <image
55
- id="image"
56
- href=${r.image.uri}
57
- clip-path="url(#clip-page-${r.page_no})"
58
- width=${d}
59
- height${p}
60
- />
61
-
62
- ${t.map(l=>{var m;const u=(m=l.prov)==null?void 0:m.find(f=>f.page_no===r.page_no);if(u){const{l:f,r:X,t:z,b:Y}=u.bbox;return E`<rect
63
- part=${"item"+(i?" "+i(r,l):"")}
64
- style=${o==null?void 0:o(r,l)}
65
- x=${f}
66
- y=${p-z}
67
- width=${X-f}
68
- height=${z-Y}
69
- vector-effect="non-scaling-stroke"
70
- @onclick=${mt=>{mt.stopPropagation(),a==null||a(mt,l)}}
71
- @onmouseenter={(e: MouseEvent) => {
72
- const bounds = e.currentTarget.getBoundingClientRect();
73
-
74
- // Sizes of surrounding areas: Top, right, bottom, left.
75
- const areas = [
76
- bounds.top * window.innerWidth,
77
- (window.innerWidth - bounds.right) * window.innerHeight,
78
- (window.innerHeight - bounds.bottom) * window.innerWidth,
79
- bounds.left * window.innerHeight,
80
- ];
81
- const maxArea = Math.max(...areas);
82
- const quadrant = areas.findIndex(a => a === maxArea);
83
-
84
- hovered = {
85
- item,
86
- bounds,
87
- quadrant,
88
- };
89
- }}
90
- />`}})}
91
- </svg>
92
-
93
- ${e?E`<header
94
- part="page-number-top"
95
- class="page-number-top"
96
- title="Page ${r.page_no}"
97
- >
98
- ${r.page_no}
99
- </header>
318
+ */const Te=Symbol();class Rt{get taskComplete(){return this.t||(this.i===1?this.t=new Promise((t,e)=>{this.o=t,this.h=e}):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,s){var n;this.p=0,this.i=0,(this._=t).addController(this);const i=typeof e=="object"?e:{task:e,args:s};this.v=i.task,this.j=i.args,this.m=i.argsEqual??Ee,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=(n=this.T)==null?void 0:n.call(this))}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;const t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){const t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){var o,l,h,p,d;let e,s;t??(t=this.T()),this.O=t,this.i===1?(o=this.q)==null||o.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this._.requestUpdate()):this._.requestUpdate();const i=++this.p;this.q=new AbortController;let n=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(c){n=!0,s=c}if(this.p===i){if(e===Te)this.i=0;else{if(n===!1){try{(l=this.k)==null||l.call(this,e)}catch{}this.i=2,(h=this.o)==null||h.call(this,e)}else{try{(p=this.A)==null||p.call(this,s)}catch{}this.i=3,(d=this.h)==null||d.call(this,s)}this.u=e,this.l=s}this._.requestUpdate()}}abort(t){var e;this.i===1&&((e=this.q)==null||e.abort(t))}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){var e,s,i,n;switch(this.i){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(s=t.pending)==null?void 0:s.call(t);case 2:return(i=t.complete)==null?void 0:i.call(t,this.value);case 3:return(n=t.error)==null?void 0:n.call(t,this.error);default:throw Error("Unexpected status: "+this.i)}}}const Ee=(r,t)=>r===t||r.length===t.length&&r.every((e,s)=>!Q(e,t[s]));function Se(r){return Object.values((r==null?void 0:r.pages)??{}).sort((t,e)=>t.page_no-e.page_no)}async function zt(r,t={}){var h,p,d;let e;typeof r=="string"?e=await(await fetch(r)).json():typeof r=="object"&&v.Document(r)&&(e=r);const s=Se(e),i=Array.from(ce(e,{traversePictures:!0})).map(([c])=>c);let n=i;const o=new Set;if(typeof t.items=="string"){const c=new Set(t.items.split(",").map(m=>m.trim()).filter(m=>m.length>0));if(c.size>0){n=[];for(const m of i){const f=m.self_ref.split("/"),b=[];for(let y=2;y<f.length+1;y++)b.push(f.slice(0,y).join("/"));(h=m.prov)==null||h.forEach(y=>b.push(`#/pages/${y.page_no}`)),b.some(y=>c.has(y))?n.push(m):(p=m.prov)==null||p.forEach(y=>o.add(y.page_no))}}}else if(Array.isArray(t.items)){n=[];const c=new Set(t.items);for(const m of i)c.has(m)?n.push(m):(d=m.prov)==null||d.forEach(f=>o.add(f.page_no))}const l={};for(const c of s)l[c.page_no]=[];for(const c of n)for(const m of c.prov??[])l[m.page_no].at(-1)!==c&&l[m.page_no].push(c);return s.map(c=>({page:c,items:l[c.page_no],trimmed:o.has(c.page_no)}))}var De=Object.defineProperty,je=Object.getOwnPropertyDescriptor,vt=(r,t,e,s)=>{for(var i=s>1?void 0:s?je(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&De(t,e,i),i};a.ImgTrace=class extends w{render(){if(this.page&&this.items&&this.items.length>0){const{page_no:t,size:e}=this.page,{width:s=1,height:i=1}=e,n=this.items.map(l=>{var p,d;const h=x((d=(p=l.prov)==null?void 0:p.find(c=>c.page_no===t))==null?void 0:d.bbox,this.page);return[(h.l+h.r)/2,(h.t+h.b)/2]}),o=`M${n[0][0]} 0 ${n.slice(0).map(l=>`L${l[0]} ${l[1]}`)} L${n.at(-1)[0]} ${i}`;return g`<svg viewBox="0 0 ${s} ${i}">
319
+ <marker
320
+ id="arrow"
321
+ viewBox="0 0 10 10"
322
+ refX="0"
323
+ refY="5"
324
+ markerWidth="4"
325
+ markerHeight="4"
326
+ orient="auto"
327
+ >
328
+ <path d="M 0 0 L 10 5 L 0 10" />
329
+ </marker>
330
+
331
+ <path
332
+ class="halo"
333
+ vector-effect="non-scaling-stroke"
334
+ d=${o}
335
+ marker-start="url(#arrow)"
336
+ />
337
+
338
+ <path
339
+ class="trace"
340
+ vector-effect="non-scaling-stroke"
341
+ d=${o}
342
+ marker-start="url(#arrow)"
343
+ />
344
+ </svg>`}}},a.ImgTrace.styles=A`
345
+ svg {
346
+ position: absolute;
347
+ inset: 0;
348
+ pointer-events: none;
349
+ }
350
+
351
+ .halo {
352
+ fill: none;
353
+ stroke-width: 5px;
354
+ stroke: white;
355
+ stroke-linejoin: round;
356
+ }
100
357
 
101
- <header
358
+ .trace {
359
+ fill: none;
360
+ stroke-width: 3px;
361
+ stroke: rgba(0, 0, 255);
362
+ stroke-linejoin: round;
363
+ }
364
+
365
+ marker > path {
366
+ fill: rgba(0, 0, 255);
367
+ stroke: none;
368
+ }
369
+ `,vt([u({type:Object})],a.ImgTrace.prototype,"page",2),vt([u({type:Array})],a.ImgTrace.prototype,"items",2),a.ImgTrace=vt([_("docling-trace")],a.ImgTrace);var ke=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,C=(r,t,e,s)=>{for(var i=s>1?void 0:s?Ue(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&ke(t,e,i),i};a.ImgPages=class extends w{constructor(){super(...arguments),this.src="",this.trim="pages",this.fetchTask=new Rt(this,{task:async([t,e])=>zt(t,{items:e}),args:()=>[this.src,this.items]})}render(){const t=Array.from(this.childNodes);return this.fetchTask.render({pending:()=>g`<p>...</p>`,complete:e=>g`
370
+ ${e.filter(s=>!this.trim||s.items.length>0).map(({page:s,items:i})=>g`<docling-img-page
371
+ part="page"
372
+ .page=${s}
373
+ .items=${i}
374
+ .pagenumbers=${this.pagenumbers!==void 0}
375
+ .itemPart=${this.itemPart}
376
+ .itemStyle=${this.itemStyle}
377
+ .onClickItem=${this.onClickItem}
378
+ .backdrop=${this.backdrop!==void 0}
379
+ .overlay=${t.find(n=>n instanceof a.ItemOverlay)}
380
+ .tooltip=${t.find(n=>n instanceof a.ItemTooltip)}
381
+ .trace=${t.find(n=>n instanceof a.ImgTrace)}
382
+ />`)}
383
+ `})}},a.ImgPages.styles=A`
384
+ :host {
385
+ width: fit-content;
386
+
387
+ display: flex;
388
+ flex-direction: column;
389
+ align-items: center;
390
+ gap: 2px;
391
+
392
+ color: black;
393
+ }
394
+ `,C([u()],a.ImgPages.prototype,"alt",2),C([u()],a.ImgPages.prototype,"backdrop",2),C([u()],a.ImgPages.prototype,"items",2),C([u({type:Boolean})],a.ImgPages.prototype,"pagenumbers",2),C([u()],a.ImgPages.prototype,"src",2),C([u()],a.ImgPages.prototype,"trim",2),C([u()],a.ImgPages.prototype,"itemPart",2),C([u()],a.ImgPages.prototype,"itemStyle",2),C([u()],a.ImgPages.prototype,"onClickItem",2),a.ImgPages=C([_("docling-img")],a.ImgPages);/**
395
+ * @license
396
+ * Copyright 2018 Google LLC
397
+ * SPDX-License-Identifier: BSD-3-Clause
398
+ */const Me=r=>r??$;var Ne=Object.defineProperty,He=Object.getOwnPropertyDescriptor,j=(r,t,e,s)=>{for(var i=s>1?void 0:s?He(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Ne(t,e,i),i};a.TablePage=class extends w{constructor(){super(...arguments),this.columns=[]}render(){var t,e,s,i,n,o,l;return g`
399
+ ${this.pagenumbers?g`
400
+ <tr>
401
+ <td
402
+ part="page-number-top"
403
+ class="page-number"
404
+ title="Page ${(t=this.page)==null?void 0:t.page_no}"
405
+ colspan=${((e=this.columns)==null?void 0:e.length)??1}
406
+ >
407
+ ${(s=this.page)==null?void 0:s.page_no}
408
+ </td>
409
+ </tr>
410
+ `:$}
411
+ ${(i=this.items)==null?void 0:i.map(h=>{var p;return g`<tr
412
+ part=${"item"+(this.itemPart?" "+this.itemPart(this.page,h):"")}
413
+ style=${Me((p=this.itemStyle)==null?void 0:p.call(this,this.page,h))}
414
+ >
415
+ ${this.columns.map(d=>{const c=d.cloneNode(!0);return c.item=h,c.page=this.page,g`
416
+ <td
417
+ @onclick=${m=>{var f;return(f=this.onClickItem)==null?void 0:f.call(this,m,this.page,h)}}
418
+ >
419
+ ${c}
420
+ </td>
421
+ `})}
422
+ </tr>`})}
423
+ ${this.pagenumbers?g`<tr>
424
+ <td
102
425
  part="page-number-bottom"
103
- class="page-number-bottom"
104
- title="Page ${r.page_no}"
426
+ class="page-number"
427
+ title="Page ${(n=this.page)==null?void 0:n.page_no}"
428
+ colspan=${((o=this.columns)==null?void 0:o.length)??1}
105
429
  >
106
- ${r.page_no}
107
- </header>`:""}
108
-
109
- <!-- Tooltip. -->
110
- ${c()}
111
- </div>
112
- `}else return E`Invalid page image.`;function c(){return""}}const Kt=st`
113
- .page {
114
- width: fit-content;
115
- max-width: 100%;
116
-
117
- display: flex;
118
- flex-direction: column;
119
- align-items: center;
120
- gap: 2px;
121
-
122
- color: black;
123
- }
124
- `;var Zt=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,_=(r,t,e,s)=>{for(var i=s>1?void 0:s?Qt(t,e):t,o=r.length-1,n;o>=0;o--)(n=r[o])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&Zt(t,e,i),i};$.ImgPages=class extends j{constructor(){super(...arguments),this.src="",this.trim="pages",this._fetchTask=new Lt(this,{task:async([t,e])=>Ft(t,{items:e}),args:()=>[this.src,this.items]})}render(){return this._fetchTask.render({pending:()=>E`<p>...</p>`,complete:t=>E`
125
- <div part="paged">
126
- ${t.filter(e=>!this.trim||e.items.length>0).map(({page:e,items:s})=>Jt({page:e,items:s,pagenumbers:this.pagenumbers!==void 0,backdrop:this.backdrop!==void 0,itemPart:this.itemPart,itemStyle:this.itemStyle,onclickitem:this.onclickitem}))}
127
- </div>
128
- `})}},$.ImgPages.styles=[st`
129
- div {
130
- width: fit-content;
131
- max-width: 100%;
132
-
133
- display: flex;
134
- flex-direction: column;
135
- align-items: center;
136
- gap: 2px;
137
-
138
- color: black;
139
- }
140
- `,Kt],_([y()],$.ImgPages.prototype,"alt",2),_([y()],$.ImgPages.prototype,"backdrop",2),_([y()],$.ImgPages.prototype,"items",2),_([y()],$.ImgPages.prototype,"pagenumbers",2),_([y()],$.ImgPages.prototype,"src",2),_([y()],$.ImgPages.prototype,"trim",2),_([y()],$.ImgPages.prototype,"itemPart",2),_([y()],$.ImgPages.prototype,"itemStyle",2),_([y()],$.ImgPages.prototype,"onclickitem",2),$.ImgPages=_([Mt("docling-img")],$.ImgPages),Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
430
+ ${(l=this.page)==null?void 0:l.page_no}
431
+ </td>
432
+ </tr>`:$}
433
+ `}},a.TablePage.styles=A`
434
+ :host {
435
+ display: table-row-group;
436
+ }
437
+
438
+ tbody {
439
+ border-bottom: 1px solid rgb(220, 220, 220);
440
+ }
441
+
442
+ .page-number {
443
+ padding: 0.25rem;
444
+
445
+ background-color: white;
446
+ color: rgb(120, 120, 120);
447
+ font-size: 0.75rem;
448
+ line-height: 1rem;
449
+ }
450
+
451
+ tr {
452
+ cursor: pointer;
453
+ }
454
+
455
+ tr:not(:nth-last-child(2)) {
456
+ border-bottom: 1px dotted rgb(220, 220, 220);
457
+ }
458
+
459
+ td {
460
+ padding: 1rem;
461
+ background-color: white;
462
+ vertical-align: top;
463
+ }
464
+
465
+ tr:hover td {
466
+ filter: brightness(95%);
467
+ }
468
+ `,j([u({type:Object})],a.TablePage.prototype,"page",2),j([u({type:Array})],a.TablePage.prototype,"items",2),j([u({type:Array})],a.TablePage.prototype,"columns",2),j([u({type:Boolean})],a.TablePage.prototype,"pagenumbers",2),j([u()],a.TablePage.prototype,"itemPart",2),j([u()],a.TablePage.prototype,"itemStyle",2),j([u()],a.TablePage.prototype,"onClickItem",2),a.TablePage=j([_("docling-table-page")],a.TablePage);var xe=Object.getOwnPropertyDescriptor,Re=(r,t,e,s)=>{for(var i=s>1?void 0:s?xe(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};let rt=class extends a.ItemView{constructor(){super(...arguments),this.type="column"}};rt=Re([_("docling-column")],rt);var ze=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,k=(r,t,e,s)=>{for(var i=s>1?void 0:s?Be(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&ze(t,e,i),i};a.TablePages=class extends w{constructor(){super(...arguments),this.src="",this.fetchTask=new Rt(this,{task:async([t,e])=>zt(t,{items:e}),args:()=>[this.src,this.items]})}render(){const t=Array.from(this.childNodes).filter(s=>s.nodeName.toLowerCase().startsWith("docling-column")),e=t.length>0?t:[new rt,new rt];return t.length===0&&e[1].appendChild(new a.ItemProvenance),this.fetchTask.render({pending:()=>g`<p>...</p>`,complete:s=>g`
469
+ <table part="pages">
470
+ ${s.filter(i=>i.items.length>0).map(({page:i,items:n})=>g`<docling-table-page
471
+ .page=${i}
472
+ .items=${n}
473
+ .columns=${e}
474
+ .pagenumbers=${this.pagenumbers!==void 0}
475
+ .itemPart=${this.itemPart}
476
+ .itemStyle=${this.itemStyle}
477
+ .onClickItem=${this.onClickItem}
478
+ />`)}
479
+ </table>
480
+ `})}},a.TablePages.styles=A`
481
+ table {
482
+ width: 100%;
483
+ border-collapse: collapse;
484
+ table-layout: fixed;
485
+ background-color: white;
486
+ }
487
+ `,k([u()],a.TablePages.prototype,"alt",2),k([u()],a.TablePages.prototype,"items",2),k([u({type:Boolean})],a.TablePages.prototype,"pagenumbers",2),k([u()],a.TablePages.prototype,"src",2),k([u()],a.TablePages.prototype,"itemPart",2),k([u()],a.TablePages.prototype,"itemStyle",2),k([u()],a.TablePages.prototype,"onClickItem",2),a.TablePages=k([_("docling-table")],a.TablePages),a.DoclingAnnotationElement=D,a.DoclingItemElement=I,a.customDoclingAnnotationElement=pt,a.customDoclingItemElement=_t,a.normalBbox=x,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});