@soomo/text-annotator 3.0.0-staging.30 → 3.0.0-staging.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(R,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(R=typeof globalThis<"u"?globalThis:R||self,_(R.RecogitoJS={}))})(this,function(R){"use strict";const _={fill:"rgb(0, 128, 255)",fillOpacity:.18},G={fill:"rgb(0, 128, 255)",fillOpacity:.45},Et=(t,e,n,o,i)=>{var s,a;const r=n?typeof n=="function"?n(t.annotation,t.state,i)||((s=t.state)!=null&&s.selected?G:_):n:(a=t.state)!=null&&a.selected?G:_;return o&&o.paint(t,e)||r},lt="not-annotatable",Y=`.${lt}`,ue=t=>{var n;const e=t.commonAncestorContainer;return e instanceof HTMLElement?!e.closest(Y):!((n=e.parentElement)!=null&&n.closest(Y))},he=function*(t){const e=document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(lt)&&!o.parentElement.closest(Y)&&t.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=e.nextNode();)n instanceof HTMLElement&&(yield n)},St=t=>{if(!ue(t))return[];const e=[];let n=null;for(const o of he(t)){let i;n?(i=document.createRange(),i.setStartAfter(n),i.setEndBefore(o)):(i=t.cloneRange(),i.setEndBefore(o)),i.collapsed||e.push(i),n=o}if(n){const o=t.cloneRange();o.setStartAfter(n),o.collapsed||e.push(o)}return e.length>0?e:[t]},et=t=>{const e=t.cloneContents();return e.querySelectorAll(Y).forEach(n=>n.remove()),e},Ct=t=>{t.addEventListener("click",e=>{!e.target.closest(Y)&&!e.target.closest("a")&&e.preventDefault()})},nt=(t,e=10)=>{let n;return(...o)=>{clearTimeout(n),n=setTimeout(()=>t.apply(void 0,o),e)}},fe=t=>{const e=t.cloneContents();return e.querySelectorAll(Y).forEach(n=>n.remove()),e},Tt=(t,e)=>{const n=document.createNodeIterator(e);let o=0,i=n.nextNode();for(;i!==null;){if(i===t)return o;o+=1,i=n.nextNode()}},Lt=(t,e)=>{const n=document.createNodeIterator(e);let o=null;for(let i=0;i<t+1;i++)o=n.nextNode();return o},ge=t=>{const{commonAncestorContainer:e,startContainer:n,startOffset:o,endContainer:i,endOffset:r}=t,s=Array.from(e.childNodes).map(l=>{const p=l.cloneNode(!0);return l.nodeName==="CANVAS"?l:p}),a=Tt(n,e),u=Tt(i,e),h=()=>{const l=e;l.replaceChildren(...s);const p=Lt(a,l),g=Lt(u,l);return t.setStart(p,o),t.setEnd(g,r),t},m=l=>{const p=document.createElement("SPAN");return l.surroundContents(p),p};if(n===i)throw"Not implemented";{const l=document.createRange();l.selectNodeContents(n),l.setStart(n,o);const p=m(l),g=document.createRange();g.selectNode(i),g.setEnd(i,r);const w=m(g),f=pe(t).reverse().map(d=>{var v;const c=document.createElement("SPAN");return(v=d.parentNode)==null||v.insertBefore(c,d),c.appendChild(d),c});return{unwrap:h,nodes:[p,...f,w]}}},pe=t=>{const{commonAncestorContainer:e,startContainer:n,endContainer:o}=t,i=document.createNodeIterator(e,NodeFilter.SHOW_TEXT);let r=i.nextNode(),s=!1;const a=[];for(;r!=null;)r===o&&(s=!1),s&&a.push(r),r===n&&(s=!0),r=i.nextNode();return a},me=t=>{const{startContainer:e,endContainer:n}=t;if(e===n)return Array.from(t.getClientRects());{const{unwrap:o,nodes:i}=ge(t),r=i.reduce((s,a)=>[...s,...a.getClientRects()],[]);return o(),r}},Rt=(t,e,n=10,o)=>{const i=o?t.startContainer.parentElement.closest(o):e,r=document.createRange();r.setStart(i,0),r.setEnd(t.startContainer,t.startOffset);const s=et(r).textContent,a=document.createRange();a.setStart(t.endContainer,t.endOffset),i===document.body?a.setEnd(i,i.childNodes.length):a.setEndAfter(i);const u=et(a).textContent;return{prefix:s.substring(s.length-n),suffix:u.substring(0,n)}},Bt=/^\s*$/,Nt=t=>Bt.test(t.toString()),$=t=>t.every(e=>e.range instanceof Range&&!e.range.collapsed),be=(t,e)=>{const n=r=>Math.round(r*10)/10,o={top:n(t.top),bottom:n(t.bottom),left:n(t.left),right:n(t.right)},i={top:n(e.top),bottom:n(e.bottom),left:n(e.left),right:n(e.right)};if(Math.abs(o.top-i.top)<.5&&Math.abs(o.bottom-i.bottom)<.5){if(Math.abs(o.left-i.right)<.5||Math.abs(o.right-i.left)<.5)return"inline-adjacent";if(o.left>=i.left&&o.right<=i.right)return"inline-is-contained";if(o.left<=i.left&&o.right>=i.right)return"inline-contains"}else if(o.top<=i.top&&o.bottom>=i.bottom){if(o.left<=i.left&&o.right>=i.right)return"block-contains"}else if(o.top>=i.top&&o.bottom<=i.bottom&&o.left>=i.left&&o.right<=i.right)return"block-is-contained"},ve=(t,e)=>{const n=Math.min(t.left,e.left),o=Math.max(t.right,e.right),i=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,i,o-n,r-i)},Ot=t=>t.reduce((e,n)=>{if(n.width===0||n.height===0)return e;let o=[...e],i=!1;for(const r of e){const s=be(n,r);if(s==="inline-adjacent"){o=o.map(a=>a===r?ve(n,r):a),i=!0;break}else if(s==="inline-contains"){o=o.map(a=>a===r?n:a),i=!0;break}else if(s==="inline-is-contained"){i=!0;break}else if(s==="block-contains"||s==="block-is-contained"){n.width<r.width&&(o=o.map(a=>a===r?n:a)),i=!0;break}}return i?o:[...o,n]},[]),Mt=(t,e,n)=>{const o=document.createRange(),i=n?t.startContainer.parentElement.closest(n):e;o.setStart(i,0),o.setEnd(t.startContainer,t.startOffset);const r=et(o).textContent,s=t.toString(),a=r.length||0,u=a+s.length;return n?{quote:s,start:a,end:u,range:t,offsetReference:i}:{quote:s,start:a,end:u,range:t}},dt=(t,e)=>{var m,l;const{start:n,end:o}=t,i=t.offsetReference||e,r=document.createNodeIterator(e,NodeFilter.SHOW_TEXT,p=>{var g;return(g=p.parentElement)!=null&&g.closest(Y)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let s=0;const a=document.createRange();let u=r.nextNode();u===null&&console.error("Could not revive annotation target. Content missing.");let h=!i;for(;u!==null;){if(h||(h=i==null?void 0:i.contains(u)),h){const p=((m=u.textContent)==null?void 0:m.length)||0;if(s+p>n){a.setStart(u,n-s);break}s+=p}u=r.nextNode()}for(;u!==null;){const p=((l=u.textContent)==null?void 0:l.length)||0;if(s+p>=o){a.setEnd(u,o-s);break}s+=p,u=r.nextNode()}return{...t,range:a}},Q=(t,e)=>$(t.selector)?t:{...t,selector:t.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:dt(n,e))},ot=(t,e)=>$(t.target.selector)?t:{...t,target:Q(t.target,e)},ye=t=>{const{top:e,left:n}=t.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,r=-n,s=-e,a=o-n,u=i-e;return{top:e,left:n,minX:r,minY:s,maxX:a,maxY:u}},we=t=>{let e=new Set;return o=>{const i=o.map(r=>r.id);(e.size!==i.length||i.some(r=>!e.has(r)))&&t.set(i),e=new Set(i)}},ut=(t,e,n,o)=>{const{store:i,selection:r,hover:s}=e;let a,u,h;const m=we(n),l=L=>{const{x:M,y:b}=t.getBoundingClientRect(),A=i.getAt(L.clientX-M,L.clientY-b,u);A?s.current!==A.id&&(t.classList.add("hovered"),s.set(A.id)):s.current&&(t.classList.remove("hovered"),s.set(null))};t.addEventListener("pointermove",l);const p=(L=!1)=>{h&&h.clear();const M=ye(t),{minX:b,minY:A,maxX:x,maxY:S}=M,N=u?i.getIntersecting(b,A,x,S).filter(({annotation:P})=>u(P)):i.getIntersecting(b,A,x,S),I=r.selected.map(({id:P})=>P),F=N.map(({annotation:P,rects:Vn})=>{const kn=I.includes(P.id),_n=P.id===s.current;return{annotation:P,rects:Vn,state:{selected:kn,hover:_n}}});o.redraw(F,M,a,h,L),setTimeout(()=>m(N.map(({annotation:P})=>P)),1)},g=L=>{h=L,p()},w=L=>{a=L,p()},y=L=>{u=L,p(!1)},f=()=>p();i.observe(f);const d=r.subscribe(()=>p()),c=()=>p(!0);document.addEventListener("scroll",c,{capture:!0,passive:!0});const v=nt(()=>{i.recalculatePositions(),h&&h.reset(),p()});window.addEventListener("resize",v);const E=new ResizeObserver(v);E.observe(t);const T={attributes:!0,childList:!0,subtree:!0},C=new MutationObserver(L=>{L.every(b=>b.target===t||t.contains(b.target))||p(!0)});return C.observe(document.body,T),{destroy:()=>{t.removeEventListener("pointermove",l),o.destroy(),i.unobserve(f),d(),document.removeEventListener("scroll",c),window.removeEventListener("resize",v),E.disconnect(),C.disconnect()},redraw:p,setStyle:w,setFilter:y,setPainter:g,setVisible:o.setVisible}},Ae=()=>{const t=document.createElement("canvas");return t.width=window.innerWidth,t.height=window.innerHeight,t.className="r6o-canvas-highlight-layer bg",t},xe=(t,e)=>{t.width=window.innerWidth,t.height=window.innerHeight},Ee=t=>{t.classList.add("r6o-annotatable");const e=Ae(),n=e.getContext("2d");document.body.appendChild(e);const o=(a,u,h,m)=>requestAnimationFrame(()=>{const{width:l,height:p}=e;n.clearRect(-.5,-.5,l+1,p+1),m&&m.clear();const{top:g,left:w}=u;[...a].sort((f,d)=>{const{annotation:{target:{created:c}}}=f,{annotation:{target:{created:v}}}=d;return c.getTime()-v.getTime()}).forEach(f=>{var E;const d=h?typeof h=="function"?h(f.annotation,f.state):h:(E=f.state)!=null&&E.selected?G:_,c=m&&m.paint(f,u)||d,v=f.rects.map(({x:T,y:C,width:B,height:L})=>({x:T+w,y:C+g,width:B,height:L}));if(n.fillStyle=c.fill,n.globalAlpha=c.fillOpacity||1,v.forEach(({x:T,y:C,width:B,height:L})=>n.fillRect(T,C,B,L)),c.underlineColor){n.globalAlpha=1,n.strokeStyle=c.underlineColor,n.lineWidth=c.underlineThickness??1;const T=c.underlineOffset??0;v.forEach(({x:C,y:B,width:L,height:M})=>{n.beginPath(),n.moveTo(C,B+M+T),n.lineTo(C+L,B+M+T),n.stroke()})}})}),i=nt(()=>{xe(e)});return window.addEventListener("resize",i),{destroy:()=>{e.remove(),window.removeEventListener("resize",i)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},It=(t,e,n)=>ut(t,e,n,Ee(t));var Se={grad:.9,turn:360,rad:360/(2*Math.PI)},H=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},U=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},D=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},Ut=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Vt=function(t){return{r:D(t.r,0,255),g:D(t.g,0,255),b:D(t.b,0,255),a:D(t.a)}},ht=function(t){return{r:U(t.r),g:U(t.g),b:U(t.b),a:U(t.a,3)}},Ce=/^#([0-9a-f]{3,8})$/i,it=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},kt=function(t){var e=t.r,n=t.g,o=t.b,i=t.a,r=Math.max(e,n,o),s=r-Math.min(e,n,o),a=s?r===e?(n-o)/s:r===n?2+(o-e)/s:4+(e-n)/s:0;return{h:60*(a<0?a+6:a),s:r?s/r*100:0,v:r/255*100,a:i}},_t=function(t){var e=t.h,n=t.s,o=t.v,i=t.a;e=e/360*6,n/=100,o/=100;var r=Math.floor(e),s=o*(1-n),a=o*(1-(e-r)*n),u=o*(1-(1-e+r)*n),h=r%6;return{r:255*[o,a,s,s,u,o][h],g:255*[u,o,o,a,s,s][h],b:255*[s,s,u,o,o,a][h],a:i}},Dt=function(t){return{h:Ut(t.h),s:D(t.s,0,100),l:D(t.l,0,100),a:D(t.a)}},Yt=function(t){return{h:U(t.h),s:U(t.s),l:U(t.l),a:U(t.a,3)}},Xt=function(t){return _t((n=(e=t).s,{h:e.h,s:(n*=((o=e.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:e.a}));var e,n,o},J=function(t){return{h:(e=kt(t)).h,s:(i=(200-(n=e.s))*(o=e.v)/100)>0&&i<200?n*o/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,o,i},Te=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Le=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Re=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Be=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$t={string:[[function(t){var e=Ce.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?U(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?U(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Re.exec(t)||Be.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Vt({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=Te.exec(t)||Le.exec(t);if(!e)return null;var n,o,i=Dt({h:(n=e[1],o=e[2],o===void 0&&(o="deg"),Number(n)*(Se[o]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Xt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,o=t.b,i=t.a,r=i===void 0?1:i;return H(e)&&H(n)&&H(o)?Vt({r:Number(e),g:Number(n),b:Number(o),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,n=t.s,o=t.l,i=t.a,r=i===void 0?1:i;if(!H(e)||!H(n)||!H(o))return null;var s=Dt({h:Number(e),s:Number(n),l:Number(o),a:Number(r)});return Xt(s)},"hsl"],[function(t){var e=t.h,n=t.s,o=t.v,i=t.a,r=i===void 0?1:i;if(!H(e)||!H(n)||!H(o))return null;var s=function(a){return{h:Ut(a.h),s:D(a.s,0,100),v:D(a.v,0,100),a:D(a.a)}}({h:Number(e),s:Number(n),v:Number(o),a:Number(r)});return _t(s)},"hsv"]]},Ht=function(t,e){for(var n=0;n<e.length;n++){var o=e[n][0](t);if(o)return[o,e[n][1]]}return[null,void 0]},Ne=function(t){return typeof t=="string"?Ht(t.trim(),$t.string):typeof t=="object"&&t!==null?Ht(t,$t.object):[null,void 0]},ft=function(t,e){var n=J(t);return{h:n.h,s:D(n.s+100*e,0,100),l:n.l,a:n.a}},gt=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},Pt=function(t,e){var n=J(t);return{h:n.h,s:n.s,l:D(n.l+100*e,0,100),a:n.a}},Ft=function(){function t(e){this.parsed=Ne(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return U(gt(this.rgba),2)},t.prototype.isDark=function(){return gt(this.rgba)<.5},t.prototype.isLight=function(){return gt(this.rgba)>=.5},t.prototype.toHex=function(){return e=ht(this.rgba),n=e.r,o=e.g,i=e.b,s=(r=e.a)<1?it(U(255*r)):"","#"+it(n)+it(o)+it(i)+s;var e,n,o,i,r,s},t.prototype.toRgb=function(){return ht(this.rgba)},t.prototype.toRgbString=function(){return e=ht(this.rgba),n=e.r,o=e.g,i=e.b,(r=e.a)<1?"rgba("+n+", "+o+", "+i+", "+r+")":"rgb("+n+", "+o+", "+i+")";var e,n,o,i,r},t.prototype.toHsl=function(){return Yt(J(this.rgba))},t.prototype.toHslString=function(){return e=Yt(J(this.rgba)),n=e.h,o=e.s,i=e.l,(r=e.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+r+")":"hsl("+n+", "+o+"%, "+i+"%)";var e,n,o,i,r},t.prototype.toHsv=function(){return e=kt(this.rgba),{h:U(e.h),s:U(e.s),v:U(e.v),a:U(e.a,3)};var e},t.prototype.invert=function(){return X({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),X(ft(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),X(ft(this.rgba,-e))},t.prototype.grayscale=function(){return X(ft(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),X(Pt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),X(Pt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?X({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):U(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=J(this.rgba);return typeof e=="number"?X({h:e,s:n.s,l:n.l,a:n.a}):U(n.h)},t.prototype.isEqual=function(e){return this.toHex()===X(e).toHex()},t}(),X=function(t){return t instanceof Ft?t:new Ft(t)};const Oe=t=>[`background-color:${X((t==null?void 0:t.fill)||_.fill).alpha((t==null?void 0:t.fillOpacity)===void 0?_.fillOpacity:t.fillOpacity).toHex()}`,t!=null&&t.underlineThickness?"text-decoration:underline":void 0,t!=null&&t.underlineColor?`text-decoration-color:${t.underlineColor}`:void 0,t!=null&&t.underlineOffset?`text-underline-offset:${t.underlineOffset}px`:void 0,t!=null&&t.underlineThickness?`text-decoration-thickness:${t.underlineThickness}px`:void 0].filter(Boolean).join(";"),zt=()=>{const t=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(t);let e=new Set;return{destroy:()=>{CSS.highlights.clear(),t.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,s,a,u)=>{u&&u.clear();const h=new Set(r.map(l=>l.annotation.id));Array.from(e).filter(l=>!h.has(l));const m=r.map(l=>{var w;const p=a?typeof a=="function"?a(l.annotation,l.state):a:(w=l.state)!=null&&w.selected?G:_,g=u&&u.paint(l,s)||p;return`::highlight(_${l.annotation.id}) { ${Oe(g)} }`});t.innerHTML=m.join(`
2
- `),CSS.highlights.clear(),r.forEach(({annotation:l})=>{const p=l.target.selector.map(w=>w.range),g=new Highlight(...p);CSS.highlights.set(`_${l.id}`,g)}),e=h}}},Wt=(t,e,n)=>ut(t,e,n,zt());var jt=Object.prototype.hasOwnProperty;function pt(t,e){var n,o;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((o=t.length)===e.length)for(;o--&&pt(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(jt.call(t,n)&&++o&&!jt.call(e,n)||!(n in e)||!pt(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}const Me=(t,e)=>{const n=(r,s)=>r.x<=s.x+s.width&&r.x+r.width>=s.x&&r.y<=s.y+s.height&&r.y+r.height>=s.y,o=r=>r.rects.reduce((s,a)=>s+a.width,0),i=e.filter(({rects:r})=>r.some(s=>n(t,s)));return i.sort((r,s)=>o(s)-o(r)),i.findIndex(r=>r.rects.includes(t))},Ie=t=>{t.classList.add("r6o-annotatable");const e=document.createElement("div");e.className="r6o-span-highlight-layer",t.insertBefore(e,t.firstChild);let n=[];return{destroy:()=>{e.remove()},redraw:(s,a,u,h,m)=>{const p=!(pt(n,s)&&m);!h&&!p||(p&&(e.innerHTML=""),s.forEach(g=>{g.rects.map(w=>{const y=Me(w,s),f=Et(g,a,u,h,y);if(p){const d=document.createElement("span");d.className="r6o-annotation",d.dataset.annotation=g.annotation.id,d.style.left=`${w.x}px`,d.style.top=`${w.y}px`,d.style.width=`${w.width}px`,d.style.height=`${w.height}px`,d.style.backgroundColor=X((f==null?void 0:f.fill)||_.fill).alpha((f==null?void 0:f.fillOpacity)===void 0?_.fillOpacity:f.fillOpacity).toHex(),f.underlineStyle&&(d.style.borderStyle=f.underlineStyle),f.underlineColor&&(d.style.borderColor=f.underlineColor),f.underlineThickness&&(d.style.borderBottomWidth=`${f.underlineThickness}px`),f.underlineOffset&&(d.style.paddingBottom=`${f.underlineOffset}px`),e.appendChild(d)}})}),n=s)},setVisible:s=>{s?e.classList.remove("hidden"):e.classList.add("hidden")}}},qt=(t,e,n)=>ut(t,e,n,Ie(t));for(var V=[],mt=0;mt<256;++mt)V.push((mt+256).toString(16).slice(1));function Ue(t,e=0){return(V[t[e+0]]+V[t[e+1]]+V[t[e+2]]+V[t[e+3]]+"-"+V[t[e+4]]+V[t[e+5]]+"-"+V[t[e+6]]+V[t[e+7]]+"-"+V[t[e+8]]+V[t[e+9]]+"-"+V[t[e+10]]+V[t[e+11]]+V[t[e+12]]+V[t[e+13]]+V[t[e+14]]+V[t[e+15]]).toLowerCase()}var rt,Ve=new Uint8Array(16);function ke(){if(!rt&&(rt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!rt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return rt(Ve)}var _e=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Gt={randomUUID:_e};function Qt(t,e,n){if(Gt.randomUUID&&!e&&!t)return Gt.randomUUID();t=t||{};var o=t.random||(t.rng||ke)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,Ue(o)}var Jt=Object.prototype.hasOwnProperty;function z(t,e){var n,o;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((o=t.length)===e.length)for(;o--&&z(t[o],e[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Jt.call(t,n)&&++o&&!Jt.call(e,n)||!(n in e)||!z(t[n],e[n]))return!1;return Object.keys(e).length===o}}return t!==t&&e!==e}function bt(){}function De(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}const W=[];function vt(t,e=bt){let n;const o=new Set;function i(a){if(De(t,a)&&(t=a,n)){const u=!W.length;for(const h of o)h[1](),W.push(h,t);if(u){for(let h=0;h<W.length;h+=2)W[h][0](W[h+1]);W.length=0}}}function r(a){i(a(t))}function s(a,u=bt){const h=[a,u];return o.add(h),o.size===1&&(n=e(i,r)||bt),a(t),()=>{o.delete(h),o.size===0&&n&&(n(),n=null)}}return{set:i,update:r,subscribe:s}}const Ye=t=>{const{subscribe:e,set:n}=vt();let o;return e(i=>o=i),t.observe(({changes:i})=>{if(o){(i.deleted||[]).some(s=>s.id===o)&&n(void 0);const r=(i.updated||[]).find(({oldValue:s})=>s.id===o);r&&n(r.newValue.id)}}),{get current(){return o},subscribe:e,set:n}};var Kt=(t=>(t.EDIT="EDIT",t.SELECT="SELECT",t.NONE="NONE",t))(Kt||{});const yt={selected:[]},Xe=(t,e="EDIT")=>{const{subscribe:n,set:o}=vt(yt);let i=yt;n(l=>i=l);const r=()=>o(yt),s=()=>{var l;return((l=i.selected)==null?void 0:l.length)===0},a=l=>{if(i.selected.length===0)return!1;const p=typeof l=="string"?l:l.id;return i.selected.some(g=>g.id===p)},u=(l,p)=>{const g=t.getAnnotation(l);if(g){const w=Zt(g,e);o(w==="EDIT"?{selected:[{id:l,editable:!0}],pointerEvent:p}:w==="SELECT"?{selected:[{id:l}],pointerEvent:p}:{selected:[],pointerEvent:p})}else console.warn("Invalid selection: "+l)},h=(l,p)=>{const g=Array.isArray(l)?l:[l],w=g.map(y=>t.getAnnotation(y)).filter(Boolean);o({selected:w.map(y=>{const f=p===void 0?Zt(y,e)==="EDIT":p;return{id:y.id,editable:f}})}),w.length!==g.length&&console.warn("Invalid selection",l)},m=l=>{if(i.selected.length===0)return!1;const{selected:p}=i;p.filter(({id:g})=>l.includes(g)).length>0&&o({selected:p.filter(({id:g})=>!l.includes(g))})};return t.observe(({changes:l})=>m((l.deleted||[]).map(p=>p.id))),{clear:r,clickSelect:u,get selected(){return i?[...i.selected]:null},get pointerEvent(){return i?i.pointerEvent:null},isEmpty:s,isSelected:a,setSelected:h,subscribe:n}},Zt=(t,e)=>typeof e=="function"?e(t)||"EDIT":e||"EDIT";for(var k=[],wt=0;wt<256;++wt)k.push((wt+256).toString(16).slice(1));function $e(t,e=0){return(k[t[e+0]]+k[t[e+1]]+k[t[e+2]]+k[t[e+3]]+"-"+k[t[e+4]]+k[t[e+5]]+"-"+k[t[e+6]]+k[t[e+7]]+"-"+k[t[e+8]]+k[t[e+9]]+"-"+k[t[e+10]]+k[t[e+11]]+k[t[e+12]]+k[t[e+13]]+k[t[e+14]]+k[t[e+15]]).toLowerCase()}var st,He=new Uint8Array(16);function Pe(){if(!st&&(st=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!st))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return st(He)}var Fe=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const te={randomUUID:Fe};function ze(t,e,n){if(te.randomUUID&&!e&&!t)return te.randomUUID();t=t||{};var o=t.random||(t.rng||Pe)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,$e(o)}const We=(t,e,n,o)=>({id:ze(),annotation:t.id,created:n||new Date,creator:o,...e}),je=(t,e)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},qe=(t,e)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},Ge=(t,e)=>e.bodies.map(n=>{const o=t.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!z(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),Qe=(t,e)=>!z(t.target,e.target),ee=(t,e)=>{const n=je(t,e),o=qe(t,e),i=Ge(t,e);return{oldValue:t,newValue:e,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:o.length>0?o:void 0,bodiesUpdated:i.length>0?i:void 0,targetUpdated:Qe(t,e)?{oldTarget:t.target,newTarget:e.target}:void 0}};var O=(t=>(t.LOCAL="LOCAL",t.REMOTE="REMOTE",t))(O||{});const Je=(t,e)=>{var n,o;const{changes:i,origin:r}=e;if(!(!t.options.origin||t.options.origin===r))return!1;if(t.options.ignore){const{ignore:s}=t.options,a=u=>u&&u.length>0;if(!(a(i.created)||a(i.deleted))){const u=(n=i.updated)==null?void 0:n.some(m=>a(m.bodiesCreated)||a(m.bodiesDeleted)||a(m.bodiesUpdated)),h=(o=i.updated)==null?void 0:o.some(m=>m.targetUpdated);if(s==="BODY_ONLY"&&u&&!h||s==="TARGET_ONLY"&&h&&!u)return!1}}if(t.options.annotations){const s=new Set([...(i.created||[]).map(a=>a.id),...(i.deleted||[]).map(a=>a.id),...(i.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(t.options.annotations)?t.options.annotations:[t.options.annotations]).find(a=>s.has(a))}else return!0},Ke=(t,e)=>{const n=new Set((t.created||[]).map(l=>l.id)),o=new Set((t.updated||[]).map(({newValue:l})=>l.id)),i=new Set((e.created||[]).map(l=>l.id)),r=new Set((e.deleted||[]).map(l=>l.id)),s=new Set((e.updated||[]).map(({oldValue:l})=>l.id)),a=new Set((e.updated||[]).filter(({oldValue:l})=>n.has(l.id)||o.has(l.id)).map(({oldValue:l})=>l.id)),u=[...(t.created||[]).filter(l=>!r.has(l.id)).map(l=>s.has(l.id)?e.updated.find(({oldValue:p})=>p.id===l.id).newValue:l),...e.created||[]],h=[...(t.deleted||[]).filter(l=>!i.has(l.id)),...(e.deleted||[]).filter(l=>!n.has(l.id))],m=[...(t.updated||[]).filter(({newValue:l})=>!r.has(l.id)).map(l=>{const{oldValue:p,newValue:g}=l;if(s.has(g.id)){const w=e.updated.find(y=>y.oldValue.id===g.id).newValue;return ee(p,w)}else return l}),...(e.updated||[]).filter(({oldValue:l})=>!a.has(l.id))];return{created:u,deleted:h,updated:m}},Ze=t=>t.id!==void 0,tn=()=>{const t=new Map,e=new Map,n=[],o=(b,A={})=>n.push({onChange:b,options:A}),i=b=>{const A=n.findIndex(x=>x.onChange==b);A>-1&&n.splice(A,1)},r=(b,A)=>{const x={origin:b,changes:{created:A.created||[],updated:A.updated||[],deleted:A.deleted||[]},state:[...t.values()]};n.forEach(S=>{Je(S,x)&&S.onChange(x)})},s=(b,A=O.LOCAL)=>{if(t.get(b.id))throw Error(`Cannot add annotation ${b.id} - exists already`);t.set(b.id,b),b.bodies.forEach(x=>e.set(x.id,b.id)),r(A,{created:[b]})},a=(b,A)=>{const x=typeof b=="string"?A:b,S=typeof b=="string"?b:b.id,N=t.get(S);if(N){const I=ee(N,x);return S===x.id?t.set(S,x):(t.delete(S),t.set(x.id,x)),N.bodies.forEach(F=>e.delete(F.id)),x.bodies.forEach(F=>e.set(F.id,x.id)),I}else console.warn(`Cannot update annotation ${S} - does not exist`)},u=(b,A=O.LOCAL,x=O.LOCAL)=>{const S=Ze(A)?x:A,N=a(b,A);N&&r(S,{updated:[N]})},h=(b,A=O.LOCAL)=>{const x=b.reduce((S,N)=>{const I=a(N);return I?[...S,I]:S},[]);x.length>0&&r(A,{updated:x})},m=(b,A=O.LOCAL)=>{const x=t.get(b.annotation);if(x){const S={...x,bodies:[...x.bodies,b]};t.set(x.id,S),e.set(b.id,S.id),r(A,{updated:[{oldValue:x,newValue:S,bodiesCreated:[b]}]})}else console.warn(`Attempt to add body to missing annotation: ${b.annotation}`)},l=()=>[...t.values()],p=(b=O.LOCAL)=>{const A=[...t.values()];t.clear(),e.clear(),r(b,{deleted:A})},g=(b,A=!0,x=O.LOCAL)=>{if(A){const S=[...t.values()];t.clear(),e.clear(),b.forEach(N=>{t.set(N.id,N),N.bodies.forEach(I=>e.set(I.id,N.id))}),r(x,{created:b,deleted:S})}else{const S=b.reduce((N,I)=>{const F=t.get(I.id);return F?[...N,F]:N},[]);if(S.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${S.map(N=>N.id).join(", ")}`);b.forEach(N=>{t.set(N.id,N),N.bodies.forEach(I=>e.set(I.id,N.id))}),r(x,{created:b})}},w=b=>{const A=typeof b=="string"?b:b.id,x=t.get(A);if(x)return t.delete(A),x.bodies.forEach(S=>e.delete(S.id)),x;console.warn(`Attempt to delete missing annotation: ${A}`)},y=(b,A=O.LOCAL)=>{const x=w(b);x&&r(A,{deleted:[x]})},f=(b,A=O.LOCAL)=>{const x=b.reduce((S,N)=>{const I=w(N);return I?[...S,I]:S},[]);x.length>0&&r(A,{deleted:x})},d=b=>{const A=t.get(b.annotation);if(A){const x=A.bodies.find(S=>S.id===b.id);if(x){e.delete(x.id);const S={...A,bodies:A.bodies.filter(N=>N.id!==b.id)};return t.set(A.id,S),{oldValue:A,newValue:S,bodiesDeleted:[x]}}else console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${b.annotation}`)},c=(b,A=O.LOCAL)=>{const x=d(b);x&&r(A,{updated:[x]})},v=(b,A=O.LOCAL)=>{const x=b.map(S=>d(S)).filter(Boolean);x.length>0&&r(A,{updated:x})},E=b=>{const A=t.get(b);return A?{...A}:void 0},T=b=>{const A=e.get(b);if(A){const x=E(A).bodies.find(S=>S.id===b);if(x)return x;console.error(`Store integrity error: body ${b} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${b}`)},C=(b,A)=>{if(b.annotation!==A.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const x=t.get(b.annotation);if(x){const S=x.bodies.find(I=>I.id===b.id),N={...x,bodies:x.bodies.map(I=>I.id===S.id?A:I)};return t.set(x.id,N),S.id!==A.id&&(e.delete(S.id),e.set(A.id,N.id)),{oldValue:x,newValue:N,bodiesUpdated:[{oldBody:S,newBody:A}]}}else console.warn(`Attempt to add body to missing annotation ${b.annotation}`)},B=(b,A,x=O.LOCAL)=>{const S=C(b,A);S&&r(x,{updated:[S]})},L=(b,A=O.LOCAL)=>{const x=b.map(S=>C({id:S.id,annotation:S.annotation},S)).filter(Boolean);r(A,{updated:x})},M=b=>{const A=t.get(b.annotation);if(A){const x={...A,target:{...A.target,...b}};return t.set(A.id,x),{oldValue:A,newValue:x,targetUpdated:{oldTarget:A.target,newTarget:b}}}else console.warn(`Attempt to update target on missing annotation: ${b.annotation}`)};return{addAnnotation:s,addBody:m,all:l,bulkAddAnnotation:g,bulkDeleteAnnotation:f,bulkDeleteBodies:v,bulkUpdateAnnotation:h,bulkUpdateBodies:L,bulkUpdateTargets:(b,A=O.LOCAL)=>{const x=b.map(S=>M(S)).filter(Boolean);x.length>0&&r(A,{updated:x})},clear:p,deleteAnnotation:y,deleteBody:c,getAnnotation:E,getBody:T,observe:o,unobserve:i,updateAnnotation:u,updateBody:B,updateTarget:(b,A=O.LOCAL)=>{const x=M(b);x&&r(A,{updated:[x]})}}};let en=()=>({emit(t,...e){for(let n=0,o=this.events[t]||[],i=o.length;n<i;n++)o[n](...e)},events:{},on(t,e){var n;return((n=this.events)[t]||(n[t]=[])).push(e),()=>{var o;this.events[t]=(o=this.events[t])==null?void 0:o.filter(i=>e!==i)}}});const nn=250,on=t=>{const e=en(),n=[];let o=-1,i=!1,r=0;const s=g=>{if(!i){const{changes:w}=g,y=performance.now();if(y-r>nn)n.splice(o+1),n.push(w),o=n.length-1;else{const f=n.length-1;n[f]=Ke(n[f],w)}r=y}i=!1};t.observe(s,{origin:O.LOCAL});const a=g=>g&&g.length>0&&t.bulkDeleteAnnotation(g),u=g=>g&&g.length>0&&t.bulkAddAnnotation(g,!1),h=g=>g&&g.length>0&&t.bulkUpdateAnnotation(g.map(({oldValue:w})=>w)),m=g=>g&&g.length>0&&t.bulkUpdateAnnotation(g.map(({newValue:w})=>w)),l=g=>g&&g.length>0&&t.bulkAddAnnotation(g,!1),p=g=>g&&g.length>0&&t.bulkDeleteAnnotation(g);return{canRedo:()=>n.length-1>o,canUndo:()=>o>-1,destroy:()=>t.unobserve(s),on:(g,w)=>e.on(g,w),redo:()=>{if(n.length-1>o){i=!0;const{created:g,updated:w,deleted:y}=n[o+1];u(g),m(w),p(y),e.emit("redo",n[o+1]),o+=1}},undo:()=>{if(o>-1){i=!0;const{created:g,updated:w,deleted:y}=n[o];a(g),h(w),l(y),e.emit("undo",n[o]),o-=1}}}},rn=()=>{const{subscribe:t,set:e}=vt([]);return{subscribe:t,set:e}},sn=(t,e,n,o)=>{const{store:i,selection:r,hover:s,viewport:a}=t,u=new Map;let h=[],m;const l=(y,f)=>{u.has(y)?u.get(y).push(f):u.set(y,[f])},p=(y,f)=>{const d=u.get(y);if(d){const c=d.indexOf(f);c!==-1&&d.splice(c,1)}},g=(y,f,d)=>{u.has(y)&&setTimeout(()=>{u.get(y).forEach(c=>{if(n){const v=Array.isArray(f)?f.map(T=>n.serialize(T)):n.serialize(f),E=d?d instanceof PointerEvent?d:n.serialize(d):void 0;c(v,E)}else c(f,d)})},1)};r.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:f})=>i.getAnnotation(f));else if(h.length>0&&y.length===0)h.forEach(f=>{const d=i.getAnnotation(f.id);d&&!z(d,f)&&g("updateAnnotation",d,f)}),h=[];else{const f=new Set(h.map(c=>c.id)),d=new Set(y.map(({id:c})=>c));h.filter(c=>!d.has(c.id)).forEach(c=>{const v=i.getAnnotation(c.id);v&&!z(v,c)&&g("updateAnnotation",v,c)}),h=[...h.filter(c=>d.has(c.id)),...y.filter(({id:c})=>!f.has(c)).map(({id:c})=>i.getAnnotation(c))]}g("selectionChanged",h)}}),s.subscribe(y=>{!m&&y?g("mouseEnterAnnotation",i.getAnnotation(y)):m&&!y?g("mouseLeaveAnnotation",i.getAnnotation(m)):m&&y&&(g("mouseLeaveAnnotation",i.getAnnotation(m)),g("mouseEnterAnnotation",i.getAnnotation(y))),m=y}),a==null||a.subscribe(y=>g("viewportIntersect",y.map(f=>i.getAnnotation(f)))),i.observe(y=>{const{created:f,deleted:d}=y.changes;(f||[]).forEach(c=>g("createAnnotation",c)),(d||[]).forEach(c=>g("deleteAnnotation",c)),(y.changes.updated||[]).filter(c=>[...c.bodiesCreated||[],...c.bodiesDeleted||[],...c.bodiesUpdated||[]].length>0).forEach(({oldValue:c,newValue:v})=>{const E=h.find(T=>T.id===c.id)||c;h=h.map(T=>T.id===c.id?v:T),g("updateAnnotation",v,E)})},{origin:O.LOCAL}),i.observe(y=>{if(h){const f=new Set(h.map(c=>c.id)),d=(y.changes.updated||[]).filter(({newValue:c})=>f.has(c.id)).map(({newValue:c})=>c);d.length>0&&(h=h.map(c=>d.find(E=>E.id===c.id)||c))}},{origin:O.REMOTE});const w=y=>f=>{const{updated:d}=f;y?(d||[]).forEach(c=>g("updateAnnotation",c.oldValue,c.newValue)):(d||[]).forEach(c=>g("updateAnnotation",c.newValue,c.oldValue))};return e.on("undo",w(!0)),e.on("redo",w(!1)),{on:l,off:p,emit:g}},an=t=>e=>e.reduce((n,o)=>{const{parsed:i,error:r}=t.parse(o);return r?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),cn=(t,e,n)=>{const{store:o,selection:i}=t,r=f=>{if(n){const{parsed:d,error:c}=n.parse(f);d?o.addAnnotation(d,O.REMOTE):console.error(c)}else o.addAnnotation(f,O.REMOTE)},s=()=>i.clear(),a=()=>o.clear(),u=f=>{const d=o.getAnnotation(f);return n&&d?n.serialize(d):d},h=()=>n?o.all().map(n.serialize):o.all(),m=()=>{var f;const d=(((f=i.selected)==null?void 0:f.map(c=>c.id))||[]).map(c=>o.getAnnotation(c)).filter(Boolean);return n?d.map(n.serialize):d},l=(f,d=!0)=>fetch(f).then(c=>c.json()).then(c=>(g(c,d),c)),p=f=>{if(typeof f=="string"){const d=o.getAnnotation(f);if(o.deleteAnnotation(f),d)return n?n.serialize(d):d}else{const d=n?n.parse(f).parsed:f;if(d)return o.deleteAnnotation(d),f}},g=(f,d=!0)=>{if(n){const{parsed:c,failed:v}=an(n)(f);v.length>0&&console.warn(`Discarded ${v.length} invalid annotations`,v),o.bulkAddAnnotation(c,d,O.REMOTE)}else o.bulkAddAnnotation(f,d,O.REMOTE)},w=(f,d)=>{f?i.setSelected(f,d):i.clear()},y=f=>{if(n){const d=n.parse(f).parsed,c=n.serialize(o.getAnnotation(d.id));return o.updateAnnotation(d),c}else{const d=o.getAnnotation(f.id);return o.updateAnnotation(f),d}};return{addAnnotation:r,cancelSelected:s,canRedo:e.canRedo,canUndo:e.canUndo,clearAnnotations:a,getAnnotationById:u,getAnnotations:h,getSelected:m,loadAnnotations:l,redo:e.redo,removeAnnotation:p,setAnnotations:g,setSelected:w,undo:e.undo,updateAnnotation:y}},ln="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let dn=t=>crypto.getRandomValues(new Uint8Array(t)),un=(t,e,n)=>{let o=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*o*e/t.length);return(r=e)=>{let s="";for(;;){let a=n(i),u=i;for(;u--;)if(s+=t[a[u]&o]||"",s.length===r)return s}}},hn=(t,e=21)=>un(t,e,dn),fn=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=ln[n[t]&63];return e};const gn=()=>({isGuest:!0,id:hn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),pn=t=>{const e=JSON.stringify(t);let n=0;for(let o=0,i=e.length;o<i;o++){let r=e.charCodeAt(o);n=(n<<5)-n+r,n|=0}return`${n}`},ne=t=>t?typeof t=="object"?{...t}:t:void 0,mn=(t,e)=>(Array.isArray(t)?t:[t]).map(n=>{const{id:o,type:i,purpose:r,value:s,created:a,modified:u,creator:h,...m}=n;return{id:o||`temp-${pn(n)}`,annotation:e,type:i,purpose:r,value:s,creator:ne(h),created:a?new Date(a):void 0,updated:u?new Date(u):void 0,...m}}),bn=t=>t.map(e=>{var n;const{annotation:o,created:i,updated:r,...s}=e,a={...s,created:i==null?void 0:i.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});fn();const vn=(t,e)=>({parse:n=>oe(n),serialize:n=>ie(n,t,e)}),yn=t=>t.quote!==void 0&&t.start!==void 0&&t.end!==void 0,wn=t=>{const{id:e,creator:n,created:o,modified:i,target:r}=t,s=Array.isArray(r)?r:[r];if(s.length===0)return{error:Error(`No targets found for annotation: ${t.id}`)};const a={creator:ne(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:e,selector:[],styleClass:s[0].styleClass};for(const u of s){const m=(Array.isArray(u.selector)?u.selector:[u.selector]).reduce((l,p)=>{switch(p.type){case"TextQuoteSelector":l.quote=p.exact;break;case"TextPositionSelector":l.start=p.start,l.end=p.end;break}return l},{});if(yn(m))a.selector.push({id:u.id,...m});else{const l=[m.start?void 0:"TextPositionSelector",m.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`)}}}return{parsed:a}},oe=t=>{const e=t.id||Qt(),{creator:n,created:o,modified:i,body:r,...s}=t,a=mn(r,e),u=wn(t);return"error"in u?{error:u.error}:{parsed:{...s,id:e,bodies:a,target:u.parsed}}},ie=(t,e,n)=>{const{bodies:o,target:i,...r}=t,{selector:s,creator:a,created:u,updated:h,...m}=i,l=s.map(p=>{const{quote:g,start:w,end:y,range:f}=p,{prefix:d,suffix:c}=Rt(f,n),v=[{type:"TextQuoteSelector",exact:g,prefix:d,suffix:c},{type:"TextPositionSelector",start:w,end:y}];return{...m,id:p.id,source:e,selector:v}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:t.id,type:"Annotation",body:bn(t.bodies),creator:a,created:u==null?void 0:u.toISOString(),modified:h==null?void 0:h.toISOString(),target:l}};function An(t,e,n,o,i){re(t,e,n||0,o||t.length-1,i||xn)}function re(t,e,n,o,i){for(;o>n;){if(o-n>600){var r=o-n+1,s=e-n+1,a=Math.log(r),u=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*u*(r-u)/r)*(s-r/2<0?-1:1),m=Math.max(n,Math.floor(e-s*u/r+h)),l=Math.min(o,Math.floor(e+(r-s)*u/r+h));re(t,e,m,l,i)}var p=t[e],g=n,w=o;for(K(t,n,e),i(t[o],p)>0&&K(t,n,o);g<w;){for(K(t,g,w),g++,w--;i(t[g],p)<0;)g++;for(;i(t[w],p)>0;)w--}i(t[n],p)===0?K(t,n,w):(w++,K(t,w,o)),w<=e&&(n=w+1),e<=w&&(o=w-1)}}function K(t,e,n){var o=t[e];t[e]=t[n],t[n]=o}function xn(t,e){return t<e?-1:t>e?1:0}class En{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let n=this.data;const o=[];if(!ct(e,n))return o;const i=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],u=n.leaf?i(a):a;ct(e,u)&&(n.leaf?o.push(a):xt(e,u)?this._all(a,o):r.push(a))}n=r.pop()}return o}collides(e){let n=this.data;if(!ct(e,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const r=n.children[i],s=n.leaf?this.toBBox(r):r;if(ct(e,s)){if(n.leaf||xt(e,s))return!0;o.push(r)}}n=o.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let o=0;o<e.length;o++)this.insert(e[o]);return this}let n=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const o=this.data;this.data=n,n=o}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=q([]),this}remove(e,n){if(!e)return this;let o=this.data;const i=this.toBBox(e),r=[],s=[];let a,u,h;for(;o||r.length;){if(o||(o=r.pop(),u=r[r.length-1],a=s.pop(),h=!0),o.leaf){const m=Sn(e,o.children,n);if(m!==-1)return o.children.splice(m,1),r.push(o),this._condense(r),this}!h&&!o.leaf&&xt(o,i)?(r.push(o),s.push(a),a=0,u=o,o=o.children[0]):u?(a++,o=u.children[a],h=!1):o=null}return this}toBBox(e){return e}compareMinX(e,n){return e.minX-n.minX}compareMinY(e,n){return e.minY-n.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,n){const o=[];for(;e;)e.leaf?n.push(...e.children):o.push(...e.children),e=o.pop();return n}_build(e,n,o,i){const r=o-n+1;let s=this._maxEntries,a;if(r<=s)return a=q(e.slice(n,o+1)),j(a,this.toBBox),a;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),a=q([]),a.leaf=!1,a.height=i;const u=Math.ceil(r/s),h=u*Math.ceil(Math.sqrt(s));se(e,n,o,h,this.compareMinX);for(let m=n;m<=o;m+=h){const l=Math.min(m+h-1,o);se(e,m,l,u,this.compareMinY);for(let p=m;p<=l;p+=u){const g=Math.min(p+u-1,l);a.children.push(this._build(e,p,g,i-1))}}return j(a,this.toBBox),a}_chooseSubtree(e,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let r=1/0,s=1/0,a;for(let u=0;u<n.children.length;u++){const h=n.children[u],m=At(h),l=Ln(e,h)-m;l<s?(s=l,r=m<r?m:r,a=h):l===s&&m<r&&(r=m,a=h)}n=a||n.children[0]}return n}_insert(e,n,o){const i=o?e:this.toBBox(e),r=[],s=this._chooseSubtree(i,this.data,n,r);for(s.children.push(e),tt(s,i);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(i,r,n)}_split(e,n){const o=e[n],i=o.children.length,r=this._minEntries;this._chooseSplitAxis(o,r,i);const s=this._chooseSplitIndex(o,r,i),a=q(o.children.splice(s,o.children.length-s));a.height=o.height,a.leaf=o.leaf,j(o,this.toBBox),j(a,this.toBBox),n?e[n-1].children.push(a):this._splitRoot(o,a)}_splitRoot(e,n){this.data=q([e,n]),this.data.height=e.height+1,this.data.leaf=!1,j(this.data,this.toBBox)}_chooseSplitIndex(e,n,o){let i,r=1/0,s=1/0;for(let a=n;a<=o-n;a++){const u=Z(e,0,a,this.toBBox),h=Z(e,a,o,this.toBBox),m=Rn(u,h),l=At(u)+At(h);m<r?(r=m,i=a,s=l<s?l:s):m===r&&l<s&&(s=l,i=a)}return i||o-n}_chooseSplitAxis(e,n,o){const i=e.leaf?this.compareMinX:Cn,r=e.leaf?this.compareMinY:Tn,s=this._allDistMargin(e,n,o,i),a=this._allDistMargin(e,n,o,r);s<a&&e.children.sort(i)}_allDistMargin(e,n,o,i){e.children.sort(i);const r=this.toBBox,s=Z(e,0,n,r),a=Z(e,o-n,o,r);let u=at(s)+at(a);for(let h=n;h<o-n;h++){const m=e.children[h];tt(s,e.leaf?r(m):m),u+=at(s)}for(let h=o-n-1;h>=n;h--){const m=e.children[h];tt(a,e.leaf?r(m):m),u+=at(a)}return u}_adjustParentBBoxes(e,n,o){for(let i=o;i>=0;i--)tt(n[i],e)}_condense(e){for(let n=e.length-1,o;n>=0;n--)e[n].children.length===0?n>0?(o=e[n-1].children,o.splice(o.indexOf(e[n]),1)):this.clear():j(e[n],this.toBBox)}}function Sn(t,e,n){if(!n)return e.indexOf(t);for(let o=0;o<e.length;o++)if(n(t,e[o]))return o;return-1}function j(t,e){Z(t,0,t.children.length,e,t)}function Z(t,e,n,o,i){i||(i=q(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=e;r<n;r++){const s=t.children[r];tt(i,t.leaf?o(s):s)}return i}function tt(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Cn(t,e){return t.minX-e.minX}function Tn(t,e){return t.minY-e.minY}function At(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function at(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ln(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Rn(t,e){const n=Math.max(t.minX,e.minX),o=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),r=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,r-o)}function xt(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function ct(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function q(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function se(t,e,n,o,i){const r=[e,n];for(;r.length;){if(n=r.pop(),e=r.pop(),n-e<=o)continue;const s=e+Math.ceil((n-e)/o/2)*o;An(t,s,e,n,i),r.push(e,s,s,n)}}const Bn=(t,e)=>{const n=new En,o=new Map,i=(d,c)=>{const v=d.selector.flatMap(T=>{const C=$([T])?T.range:dt(T,e).range;return Array.from(C.getClientRects())}),E=Ot(v).map(({left:T,top:C,right:B,bottom:L})=>new DOMRect(T-c.left,C-c.top,B-T,L-C));return E.map(T=>{const{x:C,y:B,width:L,height:M}=T;return{minX:C,minY:B,maxX:C+L,maxY:B+M,annotation:{id:d.annotation,rects:E}}})},r=()=>[...o.values()],s=()=>{n.clear(),o.clear()},a=d=>{const c=i(d,e.getBoundingClientRect());c.forEach(v=>n.insert(v)),o.set(d.annotation,c)},u=d=>{const c=o.get(d.annotation);c&&(c.forEach(v=>n.remove(v)),o.delete(d.annotation))},h=d=>{u(d),a(d)},m=(d,c=!0)=>{c&&s();const v=e.getBoundingClientRect(),E=d.map(C=>({target:C,rects:i(C,v)}));E.forEach(({target:C,rects:B})=>o.set(C.annotation,B));const T=E.flatMap(({rects:C})=>C);n.load(T)},l=(d,c,v=!1)=>{const E=n.search({minX:d,minY:c,maxX:d,maxY:c}),T=C=>C.annotation.rects.reduce((B,L)=>B+L.width*L.height,0);return E.length>0?(E.sort((C,B)=>T(C)-T(B)),v?E.map(C=>C.annotation.id):[E[0].annotation.id]):[]},p=d=>{const c=g(d);if(c.length===0)return;let v=c[0].left,E=c[0].top,T=c[0].right,C=c[0].bottom;for(let B=1;B<c.length;B++){const L=c[B];v=Math.min(v,L.left),E=Math.min(E,L.top),T=Math.max(T,L.right),C=Math.max(C,L.bottom)}return new DOMRect(v,E,T-v,C-E)},g=d=>{const c=o.get(d);return c?c[0].annotation.rects:[]};return{all:r,clear:s,getAt:l,getAnnotationBounds:p,getAnnotationRects:g,getIntersecting:(d,c,v,E)=>{const T=n.search({minX:d,minY:c,maxX:v,maxY:E}),C=new Set(T.map(B=>B.annotation.id));return Array.from(C).map(B=>({annotation:t.getAnnotation(B),rects:g(B)})).filter(B=>!!B.annotation)},insert:a,recalculate:()=>m(t.all().map(d=>d.target),!0),remove:u,set:m,size:()=>n.all().length,update:h}},ae=(t,e)=>{const n=tn(),o=Bn(n,t),i=Xe(n,e),r=Ye(n),s=rn(),a=(y,f=O.LOCAL)=>{const d=ot(y,t),c=$(d.target.selector);return c&&n.addAnnotation(d,f),c},u=(y,f=!0,d=O.LOCAL)=>{const c=y.map(E=>ot(E,t)),v=c.filter(E=>!$(E.target.selector));return v.length>0?(console.warn("Could not revive all targets for these annotations:",v),n.bulkAddAnnotation(c,f,d),v):(n.bulkAddAnnotation(c,f,d),[])},h=(y,f=O.LOCAL)=>{const d=y.map(v=>ot(v,t)),c=d.filter(v=>!$(v.target.selector));return c.length>0&&console.warn("Could not revive all targets for these annotations:",c),d.forEach(v=>{n.getAnnotation(v.id)?n.updateAnnotation(v,f):n.addAnnotation(v,f)}),c},m=(y,f=O.LOCAL)=>{const d=Q(y,t);n.updateTarget(d,f)},l=(y,f=O.LOCAL)=>{const d=y.map(c=>Q(c,t));n.bulkUpdateTargets(d,f)},p=(y,f,d)=>{const c=o.getAt(y,f,!!d).map(E=>n.getAnnotation(E)),v=d?c.filter(d):c;return v.length>0?v[0]:void 0},g=(y,f,d,c=5)=>{const v=o.getAnnotationRects(y);if(v.length!==0){if(f&&d){const E=v.find(({top:T,right:C,bottom:B,left:L})=>f>=L-c&&f<=C+c&&d>=T-c&&d<=B+c);if(E)return E}return o.getAnnotationBounds(y)}},w=()=>o.recalculate();return n.observe(({changes:y})=>{const f=(y.deleted||[]).filter(v=>$(v.target.selector)),d=(y.created||[]).filter(v=>$(v.target.selector)),c=(y.updated||[]).filter(v=>$(v.newValue.target.selector));(f==null?void 0:f.length)>0&&f.forEach(v=>o.remove(v.target)),d.length>0&&o.set(d.map(v=>v.target),!1),(c==null?void 0:c.length)>0&&c.forEach(({newValue:v})=>o.update(v.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotation:u,bulkUpdateTargets:l,bulkUpsertAnnotations:h,getAnnotationBounds:g,getAt:p,getIntersecting:o.getIntersecting,recalculatePositions:w,updateTarget:m},selection:i,hover:r,viewport:s}},Nn=()=>{const t=document.createElement("canvas");t.width=2*window.innerWidth,t.height=2*window.innerHeight,t.className="r6o-presence-layer";const e=t.getContext("2d");return e.scale(2,2),e.translate(.5,.5),t},On=(t,e,n={})=>{const o=Nn(),i=o.getContext("2d");document.body.appendChild(o);const r=new Map,s=l=>Array.from(r.entries()).filter(([p,g])=>g.presenceKey===l.presenceKey).map(([p,g])=>p);return e.on("selectionChange",(l,p)=>{s(l).forEach(w=>r.delete(w)),p&&p.forEach(w=>r.set(w,l))}),{clear:()=>{const{width:l,height:p}=o;i.clearRect(-.5,-.5,l+1,p+1)},destroy:()=>{o.remove()},paint:(l,p,g)=>{n.font&&(i.font=n.font);const w=r.get(l.annotation.id);if(w){const{height:y}=l.rects[0],f=l.rects[0].x+p.left,d=l.rects[0].y+p.top;i.fillStyle=w.appearance.color,i.fillRect(f-2,d-2.5,2,y+5);const c=i.measureText(w.appearance.label),v=c.width+6,E=c.actualBoundingBoxAscent+c.actualBoundingBoxDescent+8,T=c.fontBoundingBoxAscent?8:6.5;return i.fillRect(f-2,d-2.5-E,v,E),i.fillStyle="#fff",i.fillText(w.appearance.label,f+1,d-T),{fill:w.appearance.color,fillOpacity:g?.45:.18}}},reset:()=>{o.width=2*window.innerWidth,o.height=2*window.innerHeight;const l=o.getContext("2d");l.scale(2,2),l.translate(.5,.5)}}},ce=t=>{if(t===null)return document.scrollingElement;const{overflowY:e}=window.getComputedStyle(t);return e!=="visible"&&e!=="hidden"&&t.scrollHeight>t.clientHeight?t:ce(t.parentElement)},Mn=(t,e)=>n=>{const o=typeof n=="string"?n:n.id,i=s=>{const a=r.getBoundingClientRect(),u=r.clientHeight,h=r.clientWidth,m=s.selector[0].range.getBoundingClientRect(),{width:l,height:p}=e.getAnnotationBounds(o),g=m.top-a.top,w=m.left-a.left,y=r.parentElement?r.scrollTop:0,f=r.parentElement?r.scrollLeft:0,d=g+y-(u-p)/2,c=w+f-(h-l)/2;r.scroll({top:d,left:c,behavior:"smooth"})},r=ce(t);if(r){const s=e.getAnnotation(o),{range:a}=s.target.selector[0];if(a&&!a.collapsed)return i(s.target),!0;{const u=Q(s.target,t),{range:h}=u.selector[0];if(h&&!h.collapsed)return i(u),!0}}return!1},le=(t,e)=>({...t,annotationEnabled:t.annotationEnabled??e.annotationEnabled,user:t.user||e.user}),In=(t,e,n,o)=>{let i;const r=c=>i=c;let s;const a=c=>s=c,{store:u,selection:h}=e;let m,l=!1,p;const g=c=>{var E;if(!l)return;!((E=c.target.parentElement)!=null&&E.closest(Y))?m={annotation:Qt(),selector:[],creator:i,created:new Date}:m=void 0};n&&t.addEventListener("selectstart",g);const w=nt(c=>{var L,M;const v=document.getSelection();if(!!((M=(L=v.anchorNode)==null?void 0:L.parentElement)!=null&&M.closest(Y))){m=void 0;return}if(c.timeStamp-((p==null?void 0:p.timeStamp)||c.timeStamp)<1e3&&!m&&g(p),v.isCollapsed||!l||!m)return;const T=v.getRangeAt(0);if(Nt(T))return;const C=St(T.cloneRange());(C.length!==m.selector.length||C.some((b,A)=>{var x;return b.toString()!==((x=m.selector[A])==null?void 0:x.quote)}))&&(m={...m,selector:C.map(b=>Mt(b,t,o)),updated:new Date},u.getAnnotation(m.annotation)?u.updateTarget(m,O.LOCAL):(h.clear(),u.addAnnotation({id:m.annotation,bodies:[],target:m},O.LOCAL),h.clickSelect(m.annotation,p)))});n&&document.addEventListener("selectionchange",w);const y=c=>{const{target:v,timeStamp:E,offsetX:T,offsetY:C,type:B}=c;p={...c,target:v,timeStamp:E,offsetX:T,offsetY:C,type:B},l=c.button===0};t.addEventListener("pointerdown",y);const f=c=>{var C;if(!!((C=c.target.parentElement)!=null&&C.closest(Y))||!l)return;const E=()=>{const{x:B,y:L}=t.getBoundingClientRect(),M=u.getAt(c.clientX-B,c.clientY-L,s);if(M){const{selected:b}=h;(b.length!==1||b[0].id!==M.id)&&h.clickSelect(M.id,c)}else h.isEmpty()||h.clear()},T=c.timeStamp-p.timeStamp;document.getSelection().isCollapsed&&T<300?(m=void 0,E()):m&&h.clickSelect(m.annotation,c)};return document.addEventListener("pointerup",f),{destroy:()=>{t.removeEventListener("selectstart",g),document.removeEventListener("selectionchange",w),t.removeEventListener("pointerdown",y),document.removeEventListener("pointerup",f)},setFilter:a,setUser:r}},de="SPANS",Un=(t,e={})=>{Ct(t);const n=le(e,{annotationEnabled:!0,user:gn()}),o=ae(t,n.pointerAction),{selection:i,viewport:r}=o,s=o.store,a=on(s),u=sn(o,a,n.adapter);let h=n.user;const m=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":de:n.renderer||de,l=m==="SPANS"?qt(t,o,r):m==="CSS_HIGHLIGHTS"?Wt(t,o,r):m==="CANVAS"?It(t,o,r):void 0;if(!l)throw`Unknown renderer implementation: ${m}`;console.debug(`Using ${m} renderer`),n.style&&l.setStyle(n.style);const p=In(t,o,n.annotationEnabled,n.offsetReferenceSelector);p.setUser(h);const g=cn(o,a,n.adapter),w=()=>h,y=E=>{l.setFilter(E),p.setFilter(E)},f=E=>{h=E,p.setUser(E)},d=E=>{E&&(l.setPainter(On(t,E,n.presence)),E.on("selectionChange",()=>l.redraw()))},c=E=>{E?i.setSelected(E):i.clear()};return{...g,destroy:()=>{l.destroy(),p.destroy(),a.destroy()},element:t,getUser:w,setFilter:y,setStyle:l.setStyle.bind(l),redraw:l.redraw.bind(l),setUser:f,setSelected:c,setPresenceProvider:d,setVisible:l.setVisible.bind(l),on:u.on,off:u.off,scrollIntoView:Mn(t,s),state:o}};R.DEFAULT_SELECTED_STYLE=G,R.DEFAULT_STYLE=_,R.NOT_ANNOTATABLE_CLASS=lt,R.NOT_ANNOTATABLE_SELECTOR=Y,R.Origin=O,R.PointerSelectAction=Kt,R.W3CTextFormat=vn,R.cancelSingleClickEvents=Ct,R.createBody=We,R.createCanvasRenderer=It,R.createHighlightsRenderer=Wt,R.createRenderer=zt,R.createSpansRenderer=qt,R.createTextAnnotator=Un,R.createTextAnnotatorState=ae,R.debounce=nt,R.fillDefaults=le,R.getAnnotatableFragment=fe,R.getClientRectsPonyfill=me,R.getQuoteContext=Rt,R.getRangeAnnotatableContents=et,R.isRevived=$,R.isWhitespaceOrEmpty=Nt,R.mergeClientRects=Ot,R.paint=Et,R.parseW3CTextAnnotation=oe,R.rangeToSelector=Mt,R.reviveAnnotation=ot,R.reviveSelector=dt,R.reviveTarget=Q,R.serializeW3CTextAnnotation=ie,R.splitAnnotatableRanges=St,R.whitespaceOrEmptyRegex=Bt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
1
+ (function(x,H){typeof exports=="object"&&typeof module<"u"?H(exports):typeof define=="function"&&define.amd?define(["exports"],H):(x=typeof globalThis<"u"?globalThis:x||self,H(x.RecogitoJS={}))})(this,function(x){"use strict";const H={fill:"rgb(0, 128, 255)",fillOpacity:.18},et={fill:"rgb(0, 128, 255)",fillOpacity:.45},_t=(e,t,n,o,i)=>{var s,a;const r=n?typeof n=="function"?n(e.annotation,e.state,i)||((s=e.state)!=null&&s.selected?et:H):n:(a=e.state)!=null&&a.selected?et:H;return o&&o.paint(e,t)||r},St="not-annotatable",X=`.${St}`,_e=e=>{var n;const t=e.commonAncestorContainer;return t instanceof HTMLElement?!t.closest(X):!((n=t.parentElement)!=null&&n.closest(X))},He=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(St)&&!o.parentElement.closest(X)&&e.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Ht=e=>{if(!_e(e))return[];const t=[];let n=null;for(const o of He(e)){let i;n?(i=document.createRange(),i.setStartAfter(n),i.setEndBefore(o)):(i=e.cloneRange(),i.setEndBefore(o)),i.collapsed||t.push(i),n=o}if(n){const o=e.cloneRange();o.setStartAfter(n),o.collapsed||t.push(o)}return t.length>0?t:[e]},ft=e=>{const t=e.cloneContents();return t.querySelectorAll(X).forEach(n=>n.remove()),t},Yt=e=>e.addEventListener("click",t=>{!t.target.closest(X)&&!t.target.closest("a")&&t.preventDefault()}),Xt=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},pt=(e,t=10)=>{let n;return(...o)=>{clearTimeout(n),n=setTimeout(()=>e.apply(void 0,o),t)}},Ye=e=>{const t=e.cloneContents();return t.querySelectorAll(X).forEach(n=>n.remove()),t},$t=(e,t)=>{const n=document.createNodeIterator(t);let o=0,i=n.nextNode();for(;i!==null;){if(i===e)return o;o+=1,i=n.nextNode()}},jt=(e,t)=>{const n=document.createNodeIterator(t);let o=null;for(let i=0;i<e+1;i++)o=n.nextNode();return o},Xe=e=>{const{commonAncestorContainer:t,startContainer:n,startOffset:o,endContainer:i,endOffset:r}=e,s=Array.from(t.childNodes).map(c=>{const m=c.cloneNode(!0);return c.nodeName==="CANVAS"?c:m}),a=$t(n,t),u=$t(i,t),p=()=>{const c=t;c.replaceChildren(...s);const m=jt(a,c),f=jt(u,c);return e.setStart(m,o),e.setEnd(f,r),e},h=c=>{const m=document.createElement("SPAN");return c.surroundContents(m),m};if(n===i)throw"Not implemented";{const c=document.createRange();c.selectNodeContents(n),c.setStart(n,o);const m=h(c),f=document.createRange();f.selectNode(i),f.setEnd(i,r);const v=h(f),w=$e(e).reverse().map(d=>{var g;const l=document.createElement("SPAN");return(g=d.parentNode)==null||g.insertBefore(l,d),l.appendChild(d),l});return{unwrap:p,nodes:[m,...w,v]}}},$e=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o}=e,i=document.createNodeIterator(t,NodeFilter.SHOW_TEXT);let r=i.nextNode(),s=!1;const a=[];for(;r!=null;)r===o&&(s=!1),s&&a.push(r),r===n&&(s=!0),r=i.nextNode();return a},je=e=>{const{startContainer:t,endContainer:n}=e;if(t===n)return Array.from(e.getClientRects());{const{unwrap:o,nodes:i}=Xe(e),r=i.reduce((s,a)=>[...s,...a.getClientRects()],[]);return o(),r}},Wt=(e,t,n=10,o)=>{const i=o?e.startContainer.parentElement.closest(o):t,r=document.createRange();r.setStart(i,0),r.setEnd(e.startContainer,e.startOffset);const s=ft(r).textContent,a=document.createRange();a.setStart(e.endContainer,e.endOffset),i===document.body?a.setEnd(i,i.childNodes.length):a.setEndAfter(i);const u=ft(a).textContent;return{prefix:s.substring(s.length-n),suffix:u.substring(0,n)}},Gt=/^\s*$/,zt=e=>Gt.test(e.toString()),j=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),We=(e,t)=>{const n=r=>Math.round(r*10)/10,o={top:n(e.top),bottom:n(e.bottom),left:n(e.left),right:n(e.right)},i={top:n(t.top),bottom:n(t.bottom),left:n(t.left),right:n(t.right)};if(Math.abs(o.top-i.top)<.5&&Math.abs(o.bottom-i.bottom)<.5){if(Math.abs(o.left-i.right)<.5||Math.abs(o.right-i.left)<.5)return"inline-adjacent";if(o.left>=i.left&&o.right<=i.right)return"inline-is-contained";if(o.left<=i.left&&o.right>=i.right)return"inline-contains"}else if(o.top<=i.top&&o.bottom>=i.bottom){if(o.left<=i.left&&o.right>=i.right)return"block-contains"}else if(o.top>=i.top&&o.bottom<=i.bottom&&o.left>=i.left&&o.right<=i.right)return"block-is-contained"},Ge=(e,t)=>{const n=Math.min(e.left,t.left),o=Math.max(e.right,t.right),i=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,i,o-n,r-i)},qt=e=>e.reduce((t,n)=>{if(n.width===0||n.height===0)return t;let o=[...t],i=!1;for(const r of t){const s=We(n,r);if(s==="inline-adjacent"){o=o.map(a=>a===r?Ge(n,r):a),i=!0;break}else if(s==="inline-contains"){o=o.map(a=>a===r?n:a),i=!0;break}else if(s==="inline-is-contained"){i=!0;break}else if(s==="block-contains"||s==="block-is-contained"){n.width<r.width&&(o=o.map(a=>a===r?n:a)),i=!0;break}}return i?o:[...o,n]},[]),ze=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Zt=(e,t,n)=>{const o=document.createRange(),i=n?e.startContainer.parentElement.closest(n):t;o.setStart(i,0),o.setEnd(e.startContainer,e.startOffset);const r=ft(o).textContent,s=e.toString(),a=r.length||0,u=a+s.length;return n?{quote:s,start:a,end:u,range:e,offsetReference:i}:{quote:s,start:a,end:u,range:e}},Ct=(e,t)=>{var h,c;const{start:n,end:o}=e,i=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,m=>{var f;return(f=m.parentElement)!=null&&f.closest(X)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let s=0;const a=document.createRange();let u=r.nextNode();u===null&&console.error("Could not revive annotation target. Content missing.");let p=!i;for(;u!==null;){if(p||(p=i==null?void 0:i.contains(u)),p){const m=((h=u.textContent)==null?void 0:h.length)||0;if(s+m>n){a.setStart(u,n-s);break}s+=m}u=r.nextNode()}for(;u!==null;){const m=((c=u.textContent)==null?void 0:c.length)||0;if(s+m>=o){a.setEnd(u,o-s);break}s+=m,u=r.nextNode()}return{...e,range:a}},nt=(e,t)=>j(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Ct(n,t))},ht=(e,t)=>j(e.target.selector)?e:{...e,target:nt(e.target,t)},Jt=(e,t)=>{const{left:n,top:o,right:i,bottom:r}=e;return new DOMRect(n-t.left,o-t.top,i-n,r-o)},qe=(e,t)=>{const{left:n,top:o,right:i,bottom:r}=e;return new DOMRect(n+t.left,o+t.top,i-n,r-o)},Qt=e=>({...e,type:e.type,x:e.x,y:e.y,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,screenX:e.screenX,screenY:e.screenY,isPrimary:e.isPrimary,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,button:e.button,buttons:e.buttons,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,eventPhase:e.eventPhase,pointerId:e.pointerId,pointerType:e.pointerType,timeStamp:e.timeStamp}),Kt=e=>({...e,type:e.type,key:e.key,code:e.code,location:e.location,repeat:e.repeat,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,currentTarget:e.currentTarget,target:e.target,defaultPrevented:e.defaultPrevented,detail:e.detail,timeStamp:e.timeStamp}),Ze=e=>{const{top:t,left:n}=e.getBoundingClientRect(),{innerWidth:o,innerHeight:i}=window,r=-n,s=-t,a=o-n,u=i-t;return{top:t,left:n,minX:r,minY:s,maxX:a,maxY:u}},Je=e=>{let t=new Set;return o=>{const i=o.map(r=>r.id);(t.size!==i.length||i.some(r=>!t.has(r)))&&e.set(i),t=new Set(i)}},Tt=(e,t,n,o)=>{const{store:i,selection:r,hover:s}=t;let a,u,p;const h=Je(n),c=R=>{const{x:P,y:A}=e.getBoundingClientRect(),S=i.getAt(R.clientX-P,R.clientY-A,u);S?s.current!==S.id&&(e.classList.add("hovered"),s.set(S.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",c);const m=(R=!1)=>{p&&p.clear();const P=Ze(e),{minX:A,minY:S,maxX:C,maxY:L}=P,k=u?i.getIntersecting(A,S,C,L).filter(({annotation:q})=>u(q)):i.getIntersecting(A,S,C,L),F=r.selected.map(({id:q})=>q),Z=k.map(({annotation:q,rects:Lo})=>{const Eo=F.includes(q.id),xo=q.id===s.current;return{annotation:q,rects:Lo,state:{selected:Eo,hover:xo}}});o.redraw(Z,P,a,p,R),setTimeout(()=>h(k.map(({annotation:q})=>q)),1)},f=R=>{p=R,m()},v=R=>{a=R,m()},b=R=>{u=R,m(!1)},w=()=>m();i.observe(w);const d=r.subscribe(()=>m()),l=()=>m(!0);document.addEventListener("scroll",l,{capture:!0,passive:!0});const g=pt(()=>{i.recalculatePositions(),p&&p.reset(),m()});window.addEventListener("resize",g);const T=new ResizeObserver(g);T.observe(e);const E={attributes:!0,childList:!0,subtree:!0},M=new MutationObserver(R=>{R.every(A=>A.target===e||e.contains(A.target))||m(!0)});return M.observe(document.body,E),{destroy:()=>{e.removeEventListener("pointermove",c),o.destroy(),i.unobserve(w),d(),document.removeEventListener("scroll",l),window.removeEventListener("resize",g),T.disconnect(),M.disconnect()},redraw:m,setStyle:v,setFilter:b,setPainter:f,setVisible:o.setVisible}},Qe=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},Ke=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},tn=e=>{e.classList.add("r6o-annotatable");const t=Qe(),n=t.getContext("2d");document.body.appendChild(t);const o=(a,u,p,h)=>requestAnimationFrame(()=>{const{width:c,height:m}=t;n.clearRect(-.5,-.5,c+1,m+1),h&&h.clear();const{top:f,left:v}=u;[...a].sort((w,d)=>{const{annotation:{target:{created:l}}}=w,{annotation:{target:{created:g}}}=d;return l.getTime()-g.getTime()}).forEach(w=>{var T;const d=p?typeof p=="function"?p(w.annotation,w.state):p:(T=w.state)!=null&&T.selected?et:H,l=h&&h.paint(w,u)||d,g=w.rects.map(({x:E,y:M,width:B,height:R})=>({x:E+v,y:M+f,width:B,height:R}));if(n.fillStyle=l.fill,n.globalAlpha=l.fillOpacity||1,g.forEach(({x:E,y:M,width:B,height:R})=>n.fillRect(E,M,B,R)),l.underlineColor){n.globalAlpha=1,n.strokeStyle=l.underlineColor,n.lineWidth=l.underlineThickness??1;const E=l.underlineOffset??0;g.forEach(({x:M,y:B,width:R,height:P})=>{n.beginPath(),n.moveTo(M,B+P+E),n.lineTo(M+R,B+P+E),n.stroke()})}})}),i=pt(()=>{Ke(t)});return window.addEventListener("resize",i),{destroy:()=>{t.remove(),window.removeEventListener("resize",i)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},te=(e,t,n)=>Tt(e,t,n,tn(e));var en={grad:.9,turn:360,rad:360/(2*Math.PI)},G=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},I=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},Y=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},ee=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ne=function(e){return{r:Y(e.r,0,255),g:Y(e.g,0,255),b:Y(e.b,0,255),a:Y(e.a)}},Lt=function(e){return{r:I(e.r),g:I(e.g),b:I(e.b),a:I(e.a,3)}},nn=/^#([0-9a-f]{3,8})$/i,gt=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},oe=function(e){var t=e.r,n=e.g,o=e.b,i=e.a,r=Math.max(t,n,o),s=r-Math.min(t,n,o),a=s?r===t?(n-o)/s:r===n?2+(o-t)/s:4+(t-n)/s:0;return{h:60*(a<0?a+6:a),s:r?s/r*100:0,v:r/255*100,a:i}},ie=function(e){var t=e.h,n=e.s,o=e.v,i=e.a;t=t/360*6,n/=100,o/=100;var r=Math.floor(t),s=o*(1-n),a=o*(1-(t-r)*n),u=o*(1-(1-t+r)*n),p=r%6;return{r:255*[o,a,s,s,u,o][p],g:255*[u,o,o,a,s,s][p],b:255*[s,s,u,o,o,a][p],a:i}},re=function(e){return{h:ee(e.h),s:Y(e.s,0,100),l:Y(e.l,0,100),a:Y(e.a)}},ae=function(e){return{h:I(e.h),s:I(e.s),l:I(e.l),a:I(e.a,3)}},se=function(e){return ie((n=(t=e).s,{h:t.h,s:(n*=((o=t.l)<50?o:100-o)/100)>0?2*n/(o+n)*100:0,v:o+n,a:t.a}));var t,n,o},ot=function(e){return{h:(t=oe(e)).h,s:(i=(200-(n=t.s))*(o=t.v)/100)>0&&i<200?n*o/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,o,i},on=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,sn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,le={string:[[function(e){var t=nn.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?I(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?I(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=an.exec(e)||sn.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ne({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=on.exec(e)||rn.exec(e);if(!t)return null;var n,o,i=re({h:(n=t[1],o=t[2],o===void 0&&(o="deg"),Number(n)*(en[o]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return se(i)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,o=e.b,i=e.a,r=i===void 0?1:i;return G(t)&&G(n)&&G(o)?ne({r:Number(t),g:Number(n),b:Number(o),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,o=e.l,i=e.a,r=i===void 0?1:i;if(!G(t)||!G(n)||!G(o))return null;var s=re({h:Number(t),s:Number(n),l:Number(o),a:Number(r)});return se(s)},"hsl"],[function(e){var t=e.h,n=e.s,o=e.v,i=e.a,r=i===void 0?1:i;if(!G(t)||!G(n)||!G(o))return null;var s=function(a){return{h:ee(a.h),s:Y(a.s,0,100),v:Y(a.v,0,100),a:Y(a.a)}}({h:Number(t),s:Number(n),v:Number(o),a:Number(r)});return ie(s)},"hsv"]]},ce=function(e,t){for(var n=0;n<t.length;n++){var o=t[n][0](e);if(o)return[o,t[n][1]]}return[null,void 0]},ln=function(e){return typeof e=="string"?ce(e.trim(),le.string):typeof e=="object"&&e!==null?ce(e,le.object):[null,void 0]},Et=function(e,t){var n=ot(e);return{h:n.h,s:Y(n.s+100*t,0,100),l:n.l,a:n.a}},xt=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},de=function(e,t){var n=ot(e);return{h:n.h,s:n.s,l:Y(n.l+100*t,0,100),a:n.a}},ue=function(){function e(t){this.parsed=ln(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return I(xt(this.rgba),2)},e.prototype.isDark=function(){return xt(this.rgba)<.5},e.prototype.isLight=function(){return xt(this.rgba)>=.5},e.prototype.toHex=function(){return t=Lt(this.rgba),n=t.r,o=t.g,i=t.b,s=(r=t.a)<1?gt(I(255*r)):"","#"+gt(n)+gt(o)+gt(i)+s;var t,n,o,i,r,s},e.prototype.toRgb=function(){return Lt(this.rgba)},e.prototype.toRgbString=function(){return t=Lt(this.rgba),n=t.r,o=t.g,i=t.b,(r=t.a)<1?"rgba("+n+", "+o+", "+i+", "+r+")":"rgb("+n+", "+o+", "+i+")";var t,n,o,i,r},e.prototype.toHsl=function(){return ae(ot(this.rgba))},e.prototype.toHslString=function(){return t=ae(ot(this.rgba)),n=t.h,o=t.s,i=t.l,(r=t.a)<1?"hsla("+n+", "+o+"%, "+i+"%, "+r+")":"hsl("+n+", "+o+"%, "+i+"%)";var t,n,o,i,r},e.prototype.toHsv=function(){return t=oe(this.rgba),{h:I(t.h),s:I(t.s),v:I(t.v),a:I(t.a,3)};var t},e.prototype.invert=function(){return $({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),$(Et(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),$(Et(this.rgba,-t))},e.prototype.grayscale=function(){return $(Et(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),$(de(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),$(de(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?$({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):I(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=ot(this.rgba);return typeof t=="number"?$({h:t,s:n.s,l:n.l,a:n.a}):I(n.h)},e.prototype.isEqual=function(t){return this.toHex()===$(t).toHex()},e}(),$=function(e){return e instanceof ue?e:new ue(e)};const cn=e=>[`background-color:${$((e==null?void 0:e.fill)||H.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?H.fillOpacity:e.fillOpacity).toHex()}`,e!=null&&e.underlineThickness?"text-decoration:underline":void 0,e!=null&&e.underlineColor?`text-decoration-color:${e.underlineColor}`:void 0,e!=null&&e.underlineOffset?`text-underline-offset:${e.underlineOffset}px`:void 0,e!=null&&e.underlineThickness?`text-decoration-thickness:${e.underlineThickness}px`:void 0].filter(Boolean).join(";"),fe=()=>{const e=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(e);let t=new Set;return{destroy:()=>{CSS.highlights.clear(),e.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,s,a,u)=>{u&&u.clear();const p=new Set(r.map(c=>c.annotation.id));Array.from(t).filter(c=>!p.has(c));const h=r.map(c=>{var v;const m=a?typeof a=="function"?a(c.annotation,c.state):a:(v=c.state)!=null&&v.selected?et:H,f=u&&u.paint(c,s)||m;return`::highlight(_${c.annotation.id}) { ${cn(f)} }`});e.innerHTML=h.join(`
2
+ `),CSS.highlights.clear(),r.forEach(({annotation:c})=>{const m=c.target.selector.map(v=>v.range),f=new Highlight(...m);CSS.highlights.set(`_${c.id}`,f)}),t=p}}},pe=(e,t,n)=>Tt(e,t,n,fe());var he=Object.prototype.hasOwnProperty;function Mt(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&Mt(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(he.call(e,n)&&++o&&!he.call(t,n)||!(n in t)||!Mt(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}const dn=(e,t)=>{const n=(r,s)=>r.x<=s.x+s.width&&r.x+r.width>=s.x&&r.y<=s.y+s.height&&r.y+r.height>=s.y,o=r=>r.rects.reduce((s,a)=>s+a.width,0),i=t.filter(({rects:r})=>r.some(s=>n(e,s)));return i.sort((r,s)=>o(s)-o(r)),i.findIndex(r=>r.rects.includes(e))},un=e=>{e.classList.add("r6o-annotatable");const t=document.createElement("div");t.className="r6o-span-highlight-layer",e.insertBefore(t,e.firstChild);let n=[];return{destroy:()=>{t.remove()},redraw:(s,a,u,p,h)=>{const m=!(Mt(n,s)&&h);!p&&!m||(m&&(t.innerHTML=""),s.forEach(f=>{f.rects.map(v=>{const b=dn(v,s),w=_t(f,a,u,p,b);if(m){const d=document.createElement("span");d.className="r6o-annotation",d.dataset.annotation=f.annotation.id,d.style.left=`${v.x}px`,d.style.top=`${v.y}px`,d.style.width=`${v.width}px`,d.style.height=`${v.height}px`,d.style.backgroundColor=$((w==null?void 0:w.fill)||H.fill).alpha((w==null?void 0:w.fillOpacity)===void 0?H.fillOpacity:w.fillOpacity).toHex(),w.underlineStyle&&(d.style.borderStyle=w.underlineStyle),w.underlineColor&&(d.style.borderColor=w.underlineColor),w.underlineThickness&&(d.style.borderBottomWidth=`${w.underlineThickness}px`),w.underlineOffset&&(d.style.paddingBottom=`${w.underlineOffset}px`),t.appendChild(d)}})}),n=s)},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},ge=(e,t,n)=>Tt(e,t,n,un(e));for(var y=[],Bt=0;Bt<256;++Bt)y.push((Bt+256).toString(16).slice(1));function fn(e,t=0){return(y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var mt,pn=new Uint8Array(16);function hn(){if(!mt&&(mt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!mt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return mt(pn)}var gn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const me={randomUUID:gn};function be(e,t,n){if(me.randomUUID&&!t&&!e)return me.randomUUID();e=e||{};var o=e.random||(e.rng||hn)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,fn(o)}var we=Object.prototype.hasOwnProperty;function J(e,t){var n,o;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((o=e.length)===t.length)for(;o--&&J(e[o],t[o]););return o===-1}if(!n||typeof e=="object"){o=0;for(n in e)if(we.call(e,n)&&++o&&!we.call(t,n)||!(n in t)||!J(e[n],t[n]))return!1;return Object.keys(t).length===o}}return e!==e&&t!==t}function Rt(){}function mn(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const Q=[];function kt(e,t=Rt){let n;const o=new Set;function i(a){if(mn(e,a)&&(e=a,n)){const u=!Q.length;for(const p of o)p[1](),Q.push(p,e);if(u){for(let p=0;p<Q.length;p+=2)Q[p][0](Q[p+1]);Q.length=0}}}function r(a){i(a(e))}function s(a,u=Rt){const p=[a,u];return o.add(p),o.size===1&&(n=t(i,r)||Rt),a(e),()=>{o.delete(p),o.size===0&&n&&(n(),n=null)}}return{set:i,update:r,subscribe:s}}const bn=e=>{const{subscribe:t,set:n}=kt();let o;return t(i=>o=i),e.observe(({changes:i})=>{if(o){(i.deleted||[]).some(s=>s.id===o)&&n(void 0);const r=(i.updated||[]).find(({oldValue:s})=>s.id===o);r&&n(r.newValue.id)}}),{get current(){return o},subscribe:t,set:n}};var Ae=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(Ae||{});const Ot={selected:[]},wn=(e,t="EDIT")=>{const{subscribe:n,set:o}=kt(Ot);let i=t,r=Ot;n(f=>r=f);const s=()=>o(Ot),a=()=>{var f;return((f=r.selected)==null?void 0:f.length)===0},u=f=>{if(a())return!1;const v=typeof f=="string"?f:f.id;return r.selected.some(b=>b.id===v)},p=(f,v)=>{const b=e.getAnnotation(f);if(!b){console.warn("Invalid selection: "+f);return}switch(ve(b,i)){case"EDIT":o({selected:[{id:f,editable:!0}],event:v});break;case"SELECT":o({selected:[{id:f}],event:v});break;default:o({selected:[],event:v})}},h=(f,v)=>{const b=Array.isArray(f)?f:[f],w=b.map(d=>e.getAnnotation(d)).filter(d=>!!d);o({selected:w.map(d=>{const l=v===void 0?ve(d,i)==="EDIT":v;return{id:d.id,editable:l}})}),w.length!==b.length&&console.warn("Invalid selection",f)},c=f=>{if(a())return!1;const{selected:v}=r;v.some(({id:b})=>f.includes(b))&&o({selected:v.filter(({id:b})=>!f.includes(b))})},m=f=>i=f;return e.observe(({changes:f})=>c((f.deleted||[]).map(v=>v.id))),{get event(){return r?r.event:null},get selected(){return r?[...r.selected]:null},clear:s,isEmpty:a,isSelected:u,setSelected:h,setUserSelectAction:m,subscribe:n,userSelect:p}},ve=(e,t)=>typeof t=="function"?t(e):t||"EDIT";for(var D=[],Vt=0;Vt<256;++Vt)D.push((Vt+256).toString(16).slice(1));function An(e,t=0){return(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase()}var bt,vn=new Uint8Array(16);function Sn(){if(!bt&&(bt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!bt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return bt(vn)}var Cn=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Se={randomUUID:Cn};function Tn(e,t,n){if(Se.randomUUID&&!t&&!e)return Se.randomUUID();e=e||{};var o=e.random||(e.rng||Sn)();return o[6]=o[6]&15|64,o[8]=o[8]&63|128,An(o)}const Ln=(e,t,n,o)=>({id:Tn(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:o,...t}),En=(e,t)=>{const n=new Set(e.bodies.map(o=>o.id));return t.bodies.filter(o=>!n.has(o.id))},xn=(e,t)=>{const n=new Set(t.bodies.map(o=>o.id));return e.bodies.filter(o=>!n.has(o.id))},Mn=(e,t)=>t.bodies.map(n=>{const o=e.bodies.find(i=>i.id===n.id);return{newBody:n,oldBody:o&&!J(o,n)?o:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:o})=>({oldBody:n,newBody:o})),Bn=(e,t)=>!J(e.target,t.target),Ce=(e,t)=>{const n=En(e,t),o=xn(e,t),i=Mn(e,t);return{oldValue:e,newValue:t,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:o.length>0?o:void 0,bodiesUpdated:i.length>0?i:void 0,targetUpdated:Bn(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var O=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e))(O||{});const Rn=(e,t)=>{var n,o;const{changes:i,origin:r}=t;if(!(!e.options.origin||e.options.origin===r))return!1;if(e.options.ignore){const{ignore:s}=e.options,a=u=>u&&u.length>0;if(!(a(i.created)||a(i.deleted))){const u=(n=i.updated)==null?void 0:n.some(h=>a(h.bodiesCreated)||a(h.bodiesDeleted)||a(h.bodiesUpdated)),p=(o=i.updated)==null?void 0:o.some(h=>h.targetUpdated);if(s==="BODY_ONLY"&&u&&!p||s==="TARGET_ONLY"&&p&&!u)return!1}}if(e.options.annotations){const s=new Set([...(i.created||[]).map(a=>a.id),...(i.deleted||[]).map(a=>a.id),...(i.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(e.options.annotations)?e.options.annotations:[e.options.annotations]).find(a=>s.has(a))}else return!0},kn=(e,t)=>{const n=new Set((e.created||[]).map(c=>c.id)),o=new Set((e.updated||[]).map(({newValue:c})=>c.id)),i=new Set((t.created||[]).map(c=>c.id)),r=new Set((t.deleted||[]).map(c=>c.id)),s=new Set((t.updated||[]).map(({oldValue:c})=>c.id)),a=new Set((t.updated||[]).filter(({oldValue:c})=>n.has(c.id)||o.has(c.id)).map(({oldValue:c})=>c.id)),u=[...(e.created||[]).filter(c=>!r.has(c.id)).map(c=>s.has(c.id)?t.updated.find(({oldValue:m})=>m.id===c.id).newValue:c),...t.created||[]],p=[...(e.deleted||[]).filter(c=>!i.has(c.id)),...(t.deleted||[]).filter(c=>!n.has(c.id))],h=[...(e.updated||[]).filter(({newValue:c})=>!r.has(c.id)).map(c=>{const{oldValue:m,newValue:f}=c;if(s.has(f.id)){const v=t.updated.find(b=>b.oldValue.id===f.id).newValue;return Ce(m,v)}else return c}),...(t.updated||[]).filter(({oldValue:c})=>!a.has(c.id))];return{created:u,deleted:p,updated:h}},On=e=>e.id!==void 0,Vn=()=>{const e=new Map,t=new Map,n=[],o=(A,S={})=>n.push({onChange:A,options:S}),i=A=>{const S=n.findIndex(C=>C.onChange==A);S>-1&&n.splice(S,1)},r=(A,S)=>{const C={origin:A,changes:{created:S.created||[],updated:S.updated||[],deleted:S.deleted||[]},state:[...e.values()]};n.forEach(L=>{Rn(L,C)&&L.onChange(C)})},s=(A,S=O.LOCAL)=>{if(e.get(A.id))throw Error(`Cannot add annotation ${A.id} - exists already`);e.set(A.id,A),A.bodies.forEach(C=>t.set(C.id,A.id)),r(S,{created:[A]})},a=(A,S)=>{const C=typeof A=="string"?S:A,L=typeof A=="string"?A:A.id,k=e.get(L);if(k){const F=Ce(k,C);return L===C.id?e.set(L,C):(e.delete(L),e.set(C.id,C)),k.bodies.forEach(Z=>t.delete(Z.id)),C.bodies.forEach(Z=>t.set(Z.id,C.id)),F}else console.warn(`Cannot update annotation ${L} - does not exist`)},u=(A,S=O.LOCAL,C=O.LOCAL)=>{const L=On(S)?C:S,k=a(A,S);k&&r(L,{updated:[k]})},p=(A,S=O.LOCAL)=>{const C=A.reduce((L,k)=>{const F=a(k);return F?[...L,F]:L},[]);C.length>0&&r(S,{updated:C})},h=(A,S=O.LOCAL)=>{const C=e.get(A.annotation);if(C){const L={...C,bodies:[...C.bodies,A]};e.set(C.id,L),t.set(A.id,L.id),r(S,{updated:[{oldValue:C,newValue:L,bodiesCreated:[A]}]})}else console.warn(`Attempt to add body to missing annotation: ${A.annotation}`)},c=()=>[...e.values()],m=(A=O.LOCAL)=>{const S=[...e.values()];e.clear(),t.clear(),r(A,{deleted:S})},f=(A,S=!0,C=O.LOCAL)=>{if(S){const L=[...e.values()];e.clear(),t.clear(),A.forEach(k=>{e.set(k.id,k),k.bodies.forEach(F=>t.set(F.id,k.id))}),r(C,{created:A,deleted:L})}else{const L=A.reduce((k,F)=>{const Z=e.get(F.id);return Z?[...k,Z]:k},[]);if(L.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${L.map(k=>k.id).join(", ")}`);A.forEach(k=>{e.set(k.id,k),k.bodies.forEach(F=>t.set(F.id,k.id))}),r(C,{created:A})}},v=A=>{const S=typeof A=="string"?A:A.id,C=e.get(S);if(C)return e.delete(S),C.bodies.forEach(L=>t.delete(L.id)),C;console.warn(`Attempt to delete missing annotation: ${S}`)},b=(A,S=O.LOCAL)=>{const C=v(A);C&&r(S,{deleted:[C]})},w=(A,S=O.LOCAL)=>{const C=A.reduce((L,k)=>{const F=v(k);return F?[...L,F]:L},[]);C.length>0&&r(S,{deleted:C})},d=A=>{const S=e.get(A.annotation);if(S){const C=S.bodies.find(L=>L.id===A.id);if(C){t.delete(C.id);const L={...S,bodies:S.bodies.filter(k=>k.id!==A.id)};return e.set(S.id,L),{oldValue:S,newValue:L,bodiesDeleted:[C]}}else console.warn(`Attempt to delete missing body ${A.id} from annotation ${A.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${A.annotation}`)},l=(A,S=O.LOCAL)=>{const C=d(A);C&&r(S,{updated:[C]})},g=(A,S=O.LOCAL)=>{const C=A.map(L=>d(L)).filter(Boolean);C.length>0&&r(S,{updated:C})},T=A=>{const S=e.get(A);return S?{...S}:void 0},E=A=>{const S=t.get(A);if(S){const C=T(S).bodies.find(L=>L.id===A);if(C)return C;console.error(`Store integrity error: body ${A} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${A}`)},M=(A,S)=>{if(A.annotation!==S.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const C=e.get(A.annotation);if(C){const L=C.bodies.find(F=>F.id===A.id),k={...C,bodies:C.bodies.map(F=>F.id===L.id?S:F)};return e.set(C.id,k),L.id!==S.id&&(t.delete(L.id),t.set(S.id,k.id)),{oldValue:C,newValue:k,bodiesUpdated:[{oldBody:L,newBody:S}]}}else console.warn(`Attempt to add body to missing annotation ${A.annotation}`)},B=(A,S,C=O.LOCAL)=>{const L=M(A,S);L&&r(C,{updated:[L]})},R=(A,S=O.LOCAL)=>{const C=A.map(L=>M({id:L.id,annotation:L.annotation},L)).filter(Boolean);r(S,{updated:C})},P=A=>{const S=e.get(A.annotation);if(S){const C={...S,target:{...S.target,...A}};return e.set(S.id,C),{oldValue:S,newValue:C,targetUpdated:{oldTarget:S.target,newTarget:A}}}else console.warn(`Attempt to update target on missing annotation: ${A.annotation}`)};return{addAnnotation:s,addBody:h,all:c,bulkAddAnnotation:f,bulkDeleteAnnotation:w,bulkDeleteBodies:g,bulkUpdateAnnotation:p,bulkUpdateBodies:R,bulkUpdateTargets:(A,S=O.LOCAL)=>{const C=A.map(L=>P(L)).filter(Boolean);C.length>0&&r(S,{updated:C})},clear:m,deleteAnnotation:b,deleteBody:l,getAnnotation:T,getBody:E,observe:o,unobserve:i,updateAnnotation:u,updateBody:B,updateTarget:(A,S=O.LOCAL)=>{const C=P(A);C&&r(S,{updated:[C]})}}};let Nn=()=>({emit(e,...t){for(let n=0,o=this.events[e]||[],i=o.length;n<i;n++)o[n](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var o;this.events[e]=(o=this.events[e])==null?void 0:o.filter(i=>t!==i)}}});const Fn=250,In=e=>{const t=Nn(),n=[];let o=-1,i=!1,r=0;const s=f=>{if(!i){const{changes:v}=f,b=performance.now();if(b-r>Fn)n.splice(o+1),n.push(v),o=n.length-1;else{const w=n.length-1;n[w]=kn(n[w],v)}r=b}i=!1};e.observe(s,{origin:O.LOCAL});const a=f=>f&&f.length>0&&e.bulkDeleteAnnotation(f),u=f=>f&&f.length>0&&e.bulkAddAnnotation(f,!1),p=f=>f&&f.length>0&&e.bulkUpdateAnnotation(f.map(({oldValue:v})=>v)),h=f=>f&&f.length>0&&e.bulkUpdateAnnotation(f.map(({newValue:v})=>v)),c=f=>f&&f.length>0&&e.bulkAddAnnotation(f,!1),m=f=>f&&f.length>0&&e.bulkDeleteAnnotation(f);return{canRedo:()=>n.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(s),on:(f,v)=>t.on(f,v),redo:()=>{if(n.length-1>o){i=!0;const{created:f,updated:v,deleted:b}=n[o+1];u(f),h(v),m(b),t.emit("redo",n[o+1]),o+=1}},undo:()=>{if(o>-1){i=!0;const{created:f,updated:v,deleted:b}=n[o];a(f),p(v),c(b),t.emit("undo",n[o]),o-=1}}}},Pn=()=>{const{subscribe:e,set:t}=kt([]);return{subscribe:e,set:t}},yn=(e,t,n,o)=>{const{store:i,selection:r,hover:s,viewport:a}=e,u=new Map;let p=[],h;const c=(b,w)=>{u.has(b)?u.get(b).push(w):u.set(b,[w])},m=(b,w)=>{const d=u.get(b);if(d){const l=d.indexOf(w);l!==-1&&d.splice(l,1)}},f=(b,w,d)=>{u.has(b)&&setTimeout(()=>{u.get(b).forEach(l=>{if(n){const g=Array.isArray(w)?w.map(E=>n.serialize(E)):n.serialize(w),T=d?d instanceof PointerEvent?d:n.serialize(d):void 0;l(g,T)}else l(w,d)})},1)};r.subscribe(({selected:b})=>{if(!(p.length===0&&b.length===0)){if(p.length===0&&b.length>0)p=b.map(({id:w})=>i.getAnnotation(w));else if(p.length>0&&b.length===0)p.forEach(w=>{const d=i.getAnnotation(w.id);d&&!J(d,w)&&f("updateAnnotation",d,w)}),p=[];else{const w=new Set(p.map(l=>l.id)),d=new Set(b.map(({id:l})=>l));p.filter(l=>!d.has(l.id)).forEach(l=>{const g=i.getAnnotation(l.id);g&&!J(g,l)&&f("updateAnnotation",g,l)}),p=[...p.filter(l=>d.has(l.id)),...b.filter(({id:l})=>!w.has(l)).map(({id:l})=>i.getAnnotation(l))]}f("selectionChanged",p)}}),s.subscribe(b=>{!h&&b?f("mouseEnterAnnotation",i.getAnnotation(b)):h&&!b?f("mouseLeaveAnnotation",i.getAnnotation(h)):h&&b&&(f("mouseLeaveAnnotation",i.getAnnotation(h)),f("mouseEnterAnnotation",i.getAnnotation(b))),h=b}),a==null||a.subscribe(b=>f("viewportIntersect",b.map(w=>i.getAnnotation(w)))),i.observe(b=>{const{created:w,deleted:d}=b.changes;(w||[]).forEach(l=>f("createAnnotation",l)),(d||[]).forEach(l=>f("deleteAnnotation",l)),(b.changes.updated||[]).filter(l=>[...l.bodiesCreated||[],...l.bodiesDeleted||[],...l.bodiesUpdated||[]].length>0).forEach(({oldValue:l,newValue:g})=>{const T=p.find(E=>E.id===l.id)||l;p=p.map(E=>E.id===l.id?g:E),f("updateAnnotation",g,T)})},{origin:O.LOCAL}),i.observe(b=>{if(p){const w=new Set(p.map(l=>l.id)),d=(b.changes.updated||[]).filter(({newValue:l})=>w.has(l.id)).map(({newValue:l})=>l);d.length>0&&(p=p.map(l=>d.find(T=>T.id===l.id)||l))}},{origin:O.REMOTE});const v=b=>w=>{const{updated:d}=w;b?(d||[]).forEach(l=>f("updateAnnotation",l.oldValue,l.newValue)):(d||[]).forEach(l=>f("updateAnnotation",l.newValue,l.oldValue))};return t.on("undo",v(!0)),t.on("redo",v(!1)),{on:c,off:m,emit:f}},Dn=e=>t=>t.reduce((n,o)=>{const{parsed:i,error:r}=e.parse(o);return r?{parsed:n.parsed,failed:[...n.failed,o]}:i?{parsed:[...n.parsed,i],failed:n.failed}:{...n}},{parsed:[],failed:[]}),Un=(e,t,n)=>{const{store:o,selection:i}=e,r=d=>{if(n){const{parsed:l,error:g}=n.parse(d);l?o.addAnnotation(l,O.REMOTE):console.error(g)}else o.addAnnotation(d,O.REMOTE)},s=()=>i.clear(),a=()=>o.clear(),u=d=>{const l=o.getAnnotation(d);return n&&l?n.serialize(l):l},p=()=>n?o.all().map(n.serialize):o.all(),h=()=>{var d;const l=(((d=i.selected)==null?void 0:d.map(g=>g.id))||[]).map(g=>o.getAnnotation(g)).filter(Boolean);return n?l.map(n.serialize):l},c=(d,l=!0)=>fetch(d).then(g=>g.json()).then(g=>(f(g,l),g)),m=d=>{if(typeof d=="string"){const l=o.getAnnotation(d);if(o.deleteAnnotation(d),l)return n?n.serialize(l):l}else{const l=n?n.parse(d).parsed:d;if(l)return o.deleteAnnotation(l),d}},f=(d,l=!0)=>{if(n){const{parsed:g,failed:T}=Dn(n)(d);T.length>0&&console.warn(`Discarded ${T.length} invalid annotations`,T),o.bulkAddAnnotation(g,l,O.REMOTE)}else o.bulkAddAnnotation(d,l,O.REMOTE)},v=(d,l)=>{d?i.setSelected(d,l):i.clear()},b=d=>{i.clear(),i.setUserSelectAction(d)},w=d=>{if(n){const l=n.parse(d).parsed,g=n.serialize(o.getAnnotation(l.id));return o.updateAnnotation(l),g}else{const l=o.getAnnotation(d.id);return o.updateAnnotation(d),l}};return{addAnnotation:r,cancelSelected:s,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:u,getAnnotations:p,getSelected:h,loadAnnotations:c,redo:t.redo,removeAnnotation:m,setAnnotations:f,setSelected:v,setUserSelectAction:b,undo:t.undo,updateAnnotation:w}},_n="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Hn=e=>crypto.getRandomValues(new Uint8Array(e)),Yn=(e,t,n)=>{let o=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*o*t/e.length);return(r=t)=>{let s="";for(;;){let a=n(i),u=i;for(;u--;)if(s+=e[a[u]&o]||"",s.length===r)return s}}},Xn=(e,t=21)=>Yn(e,t,Hn),$n=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=_n[n[e]&63];return t};const jn=()=>({isGuest:!0,id:Xn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Wn=e=>{const t=JSON.stringify(e);let n=0;for(let o=0,i=t.length;o<i;o++){let r=t.charCodeAt(o);n=(n<<5)-n+r,n|=0}return`${n}`},Te=e=>e?typeof e=="object"?{...e}:e:void 0,Gn=(e,t)=>(Array.isArray(e)?e:[e]).map(n=>{const{id:o,type:i,purpose:r,value:s,created:a,modified:u,creator:p,...h}=n;return{id:o||`temp-${Wn(n)}`,annotation:t,type:i,purpose:r,value:s,creator:Te(p),created:a?new Date(a):void 0,updated:u?new Date(u):void 0,...h}}),zn=e=>e.map(t=>{var n;const{annotation:o,created:i,updated:r,...s}=t,a={...s,created:i==null?void 0:i.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});$n();const qn=(e,t)=>({parse:n=>Le(n),serialize:n=>Ee(n,e,t)}),Zn=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,Jn=e=>{const{id:t,creator:n,created:o,modified:i,target:r}=e,s=Array.isArray(r)?r:[r];if(s.length===0)return{error:Error(`No targets found for annotation: ${e.id}`)};const a={creator:Te(n),created:o?new Date(o):void 0,updated:i?new Date(i):void 0,annotation:t,selector:[],styleClass:s[0].styleClass};for(const u of s){const h=(Array.isArray(u.selector)?u.selector:[u.selector]).reduce((c,m)=>{switch(m.type){case"TextQuoteSelector":c.quote=m.exact;break;case"TextPositionSelector":c.start=m.start,c.end=m.end;break}return c},{});if(Zn(h))a.selector.push({id:u.id,...h});else{const c=[h.start?void 0:"TextPositionSelector",h.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${c.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:a}},Le=e=>{const t=e.id||be(),{creator:n,created:o,modified:i,body:r,...s}=e,a=Gn(r,t),u=Jn(e);return"error"in u?{error:u.error}:{parsed:{...s,id:t,bodies:a,target:u.parsed}}},Ee=(e,t,n)=>{const{bodies:o,target:i,...r}=e,{selector:s,creator:a,created:u,updated:p,...h}=i,c=s.map(m=>{const{quote:f,start:v,end:b,range:w}=m,{prefix:d,suffix:l}=Wt(w,n),g=[{type:"TextQuoteSelector",exact:f,prefix:d,suffix:l},{type:"TextPositionSelector",start:v,end:b}];return{...h,id:m.id,source:t,selector:g}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:zn(e.bodies),creator:a,created:u==null?void 0:u.toISOString(),modified:p==null?void 0:p.toISOString(),target:c}};function Qn(e,t,n,o,i){xe(e,t,n||0,o||e.length-1,i||Kn)}function xe(e,t,n,o,i){for(;o>n;){if(o-n>600){var r=o-n+1,s=t-n+1,a=Math.log(r),u=.5*Math.exp(2*a/3),p=.5*Math.sqrt(a*u*(r-u)/r)*(s-r/2<0?-1:1),h=Math.max(n,Math.floor(t-s*u/r+p)),c=Math.min(o,Math.floor(t+(r-s)*u/r+p));xe(e,t,h,c,i)}var m=e[t],f=n,v=o;for(it(e,n,t),i(e[o],m)>0&&it(e,n,o);f<v;){for(it(e,f,v),f++,v--;i(e[f],m)<0;)f++;for(;i(e[v],m)>0;)v--}i(e[n],m)===0?it(e,n,v):(v++,it(e,v,o)),v<=t&&(n=v+1),t<=v&&(o=v-1)}}function it(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function Kn(e,t){return e<t?-1:e>t?1:0}class to{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const o=[];if(!At(t,n))return o;const i=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],u=n.leaf?i(a):a;At(t,u)&&(n.leaf?o.push(a):Ft(t,u)?this._all(a,o):r.push(a))}n=r.pop()}return o}collides(t){let n=this.data;if(!At(t,n))return!1;const o=[];for(;n;){for(let i=0;i<n.children.length;i++){const r=n.children[i],s=n.leaf?this.toBBox(r):r;if(At(t,s)){if(n.leaf||Ft(t,s))return!0;o.push(r)}}n=o.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let o=0;o<t.length;o++)this.insert(t[o]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const o=this.data;this.data=n,n=o}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=tt([]),this}remove(t,n){if(!t)return this;let o=this.data;const i=this.toBBox(t),r=[],s=[];let a,u,p;for(;o||r.length;){if(o||(o=r.pop(),u=r[r.length-1],a=s.pop(),p=!0),o.leaf){const h=eo(t,o.children,n);if(h!==-1)return o.children.splice(h,1),r.push(o),this._condense(r),this}!p&&!o.leaf&&Ft(o,i)?(r.push(o),s.push(a),a=0,u=o,o=o.children[0]):u?(a++,o=u.children[a],p=!1):o=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const o=[];for(;t;)t.leaf?n.push(...t.children):o.push(...t.children),t=o.pop();return n}_build(t,n,o,i){const r=o-n+1;let s=this._maxEntries,a;if(r<=s)return a=tt(t.slice(n,o+1)),K(a,this.toBBox),a;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),a=tt([]),a.leaf=!1,a.height=i;const u=Math.ceil(r/s),p=u*Math.ceil(Math.sqrt(s));Me(t,n,o,p,this.compareMinX);for(let h=n;h<=o;h+=p){const c=Math.min(h+p-1,o);Me(t,h,c,u,this.compareMinY);for(let m=h;m<=c;m+=u){const f=Math.min(m+u-1,c);a.children.push(this._build(t,m,f,i-1))}}return K(a,this.toBBox),a}_chooseSubtree(t,n,o,i){for(;i.push(n),!(n.leaf||i.length-1===o);){let r=1/0,s=1/0,a;for(let u=0;u<n.children.length;u++){const p=n.children[u],h=Nt(p),c=io(t,p)-h;c<s?(s=c,r=h<r?h:r,a=p):c===s&&h<r&&(r=h,a=p)}n=a||n.children[0]}return n}_insert(t,n,o){const i=o?t:this.toBBox(t),r=[],s=this._chooseSubtree(i,this.data,n,r);for(s.children.push(t),at(s,i);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(i,r,n)}_split(t,n){const o=t[n],i=o.children.length,r=this._minEntries;this._chooseSplitAxis(o,r,i);const s=this._chooseSplitIndex(o,r,i),a=tt(o.children.splice(s,o.children.length-s));a.height=o.height,a.leaf=o.leaf,K(o,this.toBBox),K(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(o,a)}_splitRoot(t,n){this.data=tt([t,n]),this.data.height=t.height+1,this.data.leaf=!1,K(this.data,this.toBBox)}_chooseSplitIndex(t,n,o){let i,r=1/0,s=1/0;for(let a=n;a<=o-n;a++){const u=rt(t,0,a,this.toBBox),p=rt(t,a,o,this.toBBox),h=ro(u,p),c=Nt(u)+Nt(p);h<r?(r=h,i=a,s=c<s?c:s):h===r&&c<s&&(s=c,i=a)}return i||o-n}_chooseSplitAxis(t,n,o){const i=t.leaf?this.compareMinX:no,r=t.leaf?this.compareMinY:oo,s=this._allDistMargin(t,n,o,i),a=this._allDistMargin(t,n,o,r);s<a&&t.children.sort(i)}_allDistMargin(t,n,o,i){t.children.sort(i);const r=this.toBBox,s=rt(t,0,n,r),a=rt(t,o-n,o,r);let u=wt(s)+wt(a);for(let p=n;p<o-n;p++){const h=t.children[p];at(s,t.leaf?r(h):h),u+=wt(s)}for(let p=o-n-1;p>=n;p--){const h=t.children[p];at(a,t.leaf?r(h):h),u+=wt(a)}return u}_adjustParentBBoxes(t,n,o){for(let i=o;i>=0;i--)at(n[i],t)}_condense(t){for(let n=t.length-1,o;n>=0;n--)t[n].children.length===0?n>0?(o=t[n-1].children,o.splice(o.indexOf(t[n]),1)):this.clear():K(t[n],this.toBBox)}}function eo(e,t,n){if(!n)return t.indexOf(e);for(let o=0;o<t.length;o++)if(n(e,t[o]))return o;return-1}function K(e,t){rt(e,0,e.children.length,t,e)}function rt(e,t,n,o,i){i||(i=tt(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=t;r<n;r++){const s=e.children[r];at(i,e.leaf?o(s):s)}return i}function at(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function no(e,t){return e.minX-t.minX}function oo(e,t){return e.minY-t.minY}function Nt(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function wt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function io(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function ro(e,t){const n=Math.max(e.minX,t.minX),o=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,r-o)}function Ft(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function At(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function tt(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Me(e,t,n,o,i){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=o)continue;const s=t+Math.ceil((n-t)/o/2)*o;Qn(e,s,t,n,i),r.push(t,s,s,n)}}const ao=(e,t)=>{const n=new to,o=new Map,i=(d,l)=>{const g=d.selector.flatMap(E=>{const M=j([E])?E.range:Ct(E,t).range;return Array.from(M.getClientRects())}),T=qt(g).map(E=>Jt(E,l));return T.map(E=>{const{x:M,y:B,width:R,height:P}=E;return{minX:M,minY:B,maxX:M+R,maxY:B+P,annotation:{id:d.annotation,rects:T}}})},r=()=>[...o.values()],s=()=>{n.clear(),o.clear()},a=d=>{const l=i(d,t.getBoundingClientRect());l.forEach(g=>n.insert(g)),o.set(d.annotation,l)},u=d=>{const l=o.get(d.annotation);l&&(l.forEach(g=>n.remove(g)),o.delete(d.annotation))},p=d=>{u(d),a(d)},h=(d,l=!0)=>{l&&s();const g=t.getBoundingClientRect(),T=d.map(M=>({target:M,rects:i(M,g)}));T.forEach(({target:M,rects:B})=>o.set(M.annotation,B));const E=T.flatMap(({rects:M})=>M);n.load(E)},c=(d,l,g=!1)=>{const T=n.search({minX:d,minY:l,maxX:d,maxY:l}),E=M=>M.annotation.rects.reduce((B,R)=>B+R.width*R.height,0);return T.length>0?(T.sort((M,B)=>E(M)-E(B)),g?T.map(M=>M.annotation.id):[T[0].annotation.id]):[]},m=d=>{const l=f(d);if(l.length===0)return;let g=l[0].left,T=l[0].top,E=l[0].right,M=l[0].bottom;for(let B=1;B<l.length;B++){const R=l[B];g=Math.min(g,R.left),T=Math.min(T,R.top),E=Math.max(E,R.right),M=Math.max(M,R.bottom)}return new DOMRect(g,T,E-g,M-T)},f=d=>{const l=o.get(d);return l?l[0].annotation.rects:[]};return{all:r,clear:s,getAt:c,getAnnotationBounds:m,getAnnotationRects:f,getIntersecting:(d,l,g,T)=>{const E=n.search({minX:d,minY:l,maxX:g,maxY:T}),M=new Set(E.map(B=>B.annotation.id));return Array.from(M).map(B=>({annotation:e.getAnnotation(B),rects:f(B)})).filter(B=>!!B.annotation)},insert:a,recalculate:()=>h(e.all().map(d=>d.target),!0),remove:u,set:h,size:()=>n.all().length,update:p}},Be=(e,t)=>{const n=Vn(),o=ao(n,e),i=wn(n,t),r=bn(n),s=Pn(),a=(b,w=O.LOCAL)=>{const d=ht(b,e),l=j(d.target.selector);return l&&n.addAnnotation(d,w),l},u=(b,w=!0,d=O.LOCAL)=>{const l=b.map(T=>ht(T,e)),g=l.filter(T=>!j(T.target.selector));return g.length>0?(console.warn("Could not revive all targets for these annotations:",g),n.bulkAddAnnotation(l,w,d),g):(n.bulkAddAnnotation(l,w,d),[])},p=(b,w=O.LOCAL)=>{const d=b.map(g=>ht(g,e)),l=d.filter(g=>!j(g.target.selector));return l.length>0&&console.warn("Could not revive all targets for these annotations:",l),d.forEach(g=>{n.getAnnotation(g.id)?n.updateAnnotation(g,w):n.addAnnotation(g,w)}),l},h=(b,w=O.LOCAL)=>{const d=nt(b,e);n.updateTarget(d,w)},c=(b,w=O.LOCAL)=>{const d=b.map(l=>nt(l,e));n.bulkUpdateTargets(d,w)},m=(b,w,d)=>{const l=o.getAt(b,w,!!d).map(T=>n.getAnnotation(T)),g=d?l.filter(d):l;return g.length>0?g[0]:void 0},f=(b,w,d,l=5)=>{const g=o.getAnnotationRects(b);if(g.length!==0){if(w&&d){const T=g.find(({top:E,right:M,bottom:B,left:R})=>w>=R-l&&w<=M+l&&d>=E-l&&d<=B+l);if(T)return T}return o.getAnnotationBounds(b)}},v=()=>o.recalculate();return n.observe(({changes:b})=>{const w=(b.deleted||[]).filter(g=>j(g.target.selector)),d=(b.created||[]).filter(g=>j(g.target.selector)),l=(b.updated||[]).filter(g=>j(g.newValue.target.selector));(w==null?void 0:w.length)>0&&w.forEach(g=>o.remove(g.target)),d.length>0&&o.set(d.map(g=>g.target),!1),(l==null?void 0:l.length)>0&&l.forEach(({newValue:g})=>o.update(g.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotation:u,bulkUpdateTargets:c,bulkUpsertAnnotations:p,getAnnotationBounds:f,getAt:m,getIntersecting:o.getIntersecting.bind(o),getAnnotationRects:o.getAnnotationRects.bind(o),recalculatePositions:v,updateTarget:h},selection:i,hover:r,viewport:s}},so=()=>{const e=document.createElement("canvas");e.width=2*window.innerWidth,e.height=2*window.innerHeight,e.className="r6o-presence-layer";const t=e.getContext("2d");return t.scale(2,2),t.translate(.5,.5),e},lo=(e,t,n={})=>{const o=so(),i=o.getContext("2d");document.body.appendChild(o);const r=new Map,s=c=>Array.from(r.entries()).filter(([m,f])=>f.presenceKey===c.presenceKey).map(([m,f])=>m);return t.on("selectionChange",(c,m)=>{s(c).forEach(v=>r.delete(v)),m&&m.forEach(v=>r.set(v,c))}),{clear:()=>{const{width:c,height:m}=o;i.clearRect(-.5,-.5,c+1,m+1)},destroy:()=>{o.remove()},paint:(c,m,f)=>{n.font&&(i.font=n.font);const v=r.get(c.annotation.id);if(v){const{height:b}=c.rects[0],w=c.rects[0].x+m.left,d=c.rects[0].y+m.top;i.fillStyle=v.appearance.color,i.fillRect(w-2,d-2.5,2,b+5);const l=i.measureText(v.appearance.label),g=l.width+6,T=l.actualBoundingBoxAscent+l.actualBoundingBoxDescent+8,E=l.fontBoundingBoxAscent?8:6.5;return i.fillRect(w-2,d-2.5-T,g,T),i.fillStyle="#fff",i.fillText(v.appearance.label,w+1,d-E),{fill:v.appearance.color,fillOpacity:f?.45:.18}}},reset:()=>{o.width=2*window.innerWidth,o.height=2*window.innerHeight;const c=o.getContext("2d");c.scale(2,2),c.translate(.5,.5)}}},Re=e=>{if(e===null)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:Re(e.parentElement)},co=(e,t)=>n=>{const o=typeof n=="string"?n:n.id,i=s=>{const a=r.getBoundingClientRect(),u=r.clientHeight,p=r.clientWidth,h=s.selector[0].range.getBoundingClientRect(),{width:c,height:m}=t.getAnnotationBounds(o),f=h.top-a.top,v=h.left-a.left,b=r.parentElement?r.scrollTop:0,w=r.parentElement?r.scrollLeft:0,d=f+b-(u-m)/2,l=v+w-(p-c)/2;r.scroll({top:d,left:l,behavior:"smooth"})},r=Re(e);if(r){const s=t.getAnnotation(o),{range:a}=s.target.selector[0];if(a&&!a.collapsed)return i(s.target),!0;{const u=nt(s.target,e),{range:p}=u.selector[0];if(p&&!p.collapsed)return i(u),!0}}return!1},ke=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),It=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Pt(e,t,n,o){e.addEventListener?e.addEventListener(t,n,o):e.attachEvent&&e.attachEvent("on".concat(t),n)}function st(e,t,n,o){e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Oe(e,t){const n=t.slice(0,t.length-1);for(let o=0;o<n.length;o++)n[o]=e[n[o].toLowerCase()];return n}function Ve(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function uo(e,t){const n=e.length>=t.length?e:t,o=e.length>=t.length?t:e;let i=!0;for(let r=0;r<n.length;r++)o.indexOf(n[r])===-1&&(i=!1);return i}const lt={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":It?173:189,"=":It?61:187,";":It?59:186,"'":222,"[":219,"]":221,"\\":220},W={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},yt={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},U={16:!1,18:!1,17:!1,91:!1},N={};for(let e=1;e<20;e++)lt["f".concat(e)]=111+e;let V=[],ct=null,Ne="all";const z=new Map,dt=e=>lt[e.toLowerCase()]||W[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),fo=e=>Object.keys(lt).find(t=>lt[t]===e),po=e=>Object.keys(W).find(t=>W[t]===e);function Fe(e){Ne=e||"all"}function ut(){return Ne||"all"}function ho(){return V.slice(0)}function go(){return V.map(e=>fo(e)||po(e)||String.fromCharCode(e))}function mo(){const e=[];return Object.keys(N).forEach(t=>{N[t].forEach(n=>{let{key:o,scope:i,mods:r,shortcut:s}=n;e.push({scope:i,shortcut:s,mods:r,keys:o.split("+").map(a=>dt(a))})})}),e}function bo(e){const t=e.target||e.srcElement,{tagName:n}=t;let o=!0;const i=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(i||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(o=!1),o}function wo(e){return typeof e=="string"&&(e=dt(e)),V.indexOf(e)!==-1}function Ao(e,t){let n,o;e||(e=ut());for(const i in N)if(Object.prototype.hasOwnProperty.call(N,i))for(n=N[i],o=0;o<n.length;)n[o].scope===e?n.splice(o,1).forEach(s=>{let{element:a}=s;return Dt(a)}):o++;ut()===e&&Fe(t||"all")}function vo(e){let t=e.keyCode||e.which||e.charCode;const n=V.indexOf(t);if(n>=0&&V.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&V.splice(0,V.length),(t===93||t===224)&&(t=91),t in U){U[t]=!1;for(const o in W)W[o]===t&&(_[o]=!1)}}function Ie(e){if(typeof e>"u")Object.keys(N).forEach(i=>{Array.isArray(N[i])&&N[i].forEach(r=>vt(r)),delete N[i]}),Dt(null);else if(Array.isArray(e))e.forEach(i=>{i.key&&vt(i)});else if(typeof e=="object")e.key&&vt(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];let[i,r]=n;typeof i=="function"&&(r=i,i=""),vt({key:e,scope:i,method:r,splitKey:"+"})}}const vt=e=>{let{key:t,scope:n,method:o,splitKey:i="+"}=e;Ve(t).forEach(s=>{const a=s.split(i),u=a.length,p=a[u-1],h=p==="*"?"*":dt(p);if(!N[h])return;n||(n=ut());const c=u>1?Oe(W,a):[],m=[];N[h]=N[h].filter(f=>{const b=(o?f.method===o:!0)&&f.scope===n&&uo(f.mods,c);return b&&m.push(f.element),!b}),m.forEach(f=>Dt(f))})};function Pe(e,t,n,o){if(t.element!==o)return;let i;if(t.scope===n||t.scope==="all"){i=t.mods.length>0;for(const r in U)Object.prototype.hasOwnProperty.call(U,r)&&(!U[r]&&t.mods.indexOf(+r)>-1||U[r]&&t.mods.indexOf(+r)===-1)&&(i=!1);(t.mods.length===0&&!U[16]&&!U[18]&&!U[17]&&!U[91]||i||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(V),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function ye(e,t){const n=N["*"];let o=e.keyCode||e.which||e.charCode;if(!_.filter.call(this,e))return;if((o===93||o===224)&&(o=91),V.indexOf(o)===-1&&o!==229&&V.push(o),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const u=yt[a];e[a]&&V.indexOf(u)===-1?V.push(u):!e[a]&&V.indexOf(u)>-1?V.splice(V.indexOf(u),1):a==="metaKey"&&e[a]&&V.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(V=V.slice(V.indexOf(u))))}),o in U){U[o]=!0;for(const a in W)W[a]===o&&(_[a]=!0);if(!n)return}for(const a in U)Object.prototype.hasOwnProperty.call(U,a)&&(U[a]=e[yt[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(V.indexOf(17)===-1&&V.push(17),V.indexOf(18)===-1&&V.push(18),U[17]=!0,U[18]=!0);const i=ut();if(n)for(let a=0;a<n.length;a++)n[a].scope===i&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&Pe(e,n[a],i,t);if(!(o in N))return;const r=N[o],s=r.length;for(let a=0;a<s;a++)if((e.type==="keydown"&&r[a].keydown||e.type==="keyup"&&r[a].keyup)&&r[a].key){const u=r[a],{splitKey:p}=u,h=u.key.split(p),c=[];for(let m=0;m<h.length;m++)c.push(dt(h[m]));c.sort().join("")===V.sort().join("")&&Pe(e,u,i,t)}}function _(e,t,n){V=[];const o=Ve(e);let i=[],r="all",s=document,a=0,u=!1,p=!0,h="+",c=!1,m=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(r=t.scope),t.element&&(s=t.element),t.keyup&&(u=t.keyup),t.keydown!==void 0&&(p=t.keydown),t.capture!==void 0&&(c=t.capture),typeof t.splitKey=="string"&&(h=t.splitKey),t.single===!0&&(m=!0)),typeof t=="string"&&(r=t),m&&Ie(e,r);a<o.length;a++)e=o[a].split(h),i=[],e.length>1&&(i=Oe(W,e)),e=e[e.length-1],e=e==="*"?"*":dt(e),e in N||(N[e]=[]),N[e].push({keyup:u,keydown:p,scope:r,mods:i,shortcut:o[a],method:n,key:o[a],splitKey:h,element:s});if(typeof s<"u"&&window){if(!z.has(s)){const f=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return ye(b,s)},v=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;ye(b,s),vo(b)};z.set(s,{keydownListener:f,keyupListenr:v,capture:c}),Pt(s,"keydown",f,c),Pt(s,"keyup",v,c)}if(!ct){const f=()=>{V=[]};ct={listener:f,capture:c},Pt(window,"focus",f,c)}}}function So(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(N).forEach(n=>{N[n].filter(i=>i.scope===t&&i.shortcut===e).forEach(i=>{i&&i.method&&i.method()})})}function Dt(e){const t=Object.values(N).flat();if(t.findIndex(o=>{let{element:i}=o;return i===e})<0){const{keydownListener:o,keyupListenr:i,capture:r}=z.get(e)||{};o&&i&&(st(e,"keyup",i,r),st(e,"keydown",o,r),z.delete(e))}if((t.length<=0||z.size<=0)&&(Object.keys(z).forEach(i=>{const{keydownListener:r,keyupListenr:s,capture:a}=z.get(i)||{};r&&s&&(st(i,"keyup",s,a),st(i,"keydown",r,a),z.delete(i))}),z.clear(),Object.keys(N).forEach(i=>delete N[i]),ct)){const{listener:i,capture:r}=ct;st(window,"focus",i,r),ct=null}}const Ut={getPressedKeyString:go,setScope:Fe,getScope:ut,deleteScope:Ao,getPressedKeyCodes:ho,getAllKeyCodes:mo,isPressed:wo,filter:bo,trigger:So,unbind:Ie,keyMap:lt,modifier:W,modifierMap:yt};for(const e in Ut)Object.prototype.hasOwnProperty.call(Ut,e)&&(_[e]=Ut[e]);if(typeof window<"u"){const e=window.hotkeys;_.noConflict=t=>(t&&window.hotkeys===_&&(window.hotkeys=e),_),window.hotkeys=_}var De={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.Unidentified="Unidentified",t.Alt="Alt",t.AltGraph="AltGraph",t.CapsLock="CapsLock",t.Control="Control",t.Fn="Fn",t.FnLock="FnLock",t.Hyper="Hyper",t.Meta="Meta",t.NumLock="NumLock",t.ScrollLock="ScrollLock",t.Shift="Shift",t.Super="Super",t.Symbol="Symbol",t.SymbolLock="SymbolLock",t.Enter="Enter",t.Tab="Tab",t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.ArrowUp="ArrowUp",t.End="End",t.Home="Home",t.PageDown="PageDown",t.PageUp="PageUp",t.Backspace="Backspace",t.Clear="Clear",t.Copy="Copy",t.CrSel="CrSel",t.Cut="Cut",t.Delete="Delete",t.EraseEof="EraseEof",t.ExSel="ExSel",t.Insert="Insert",t.Paste="Paste",t.Redo="Redo",t.Undo="Undo",t.Accept="Accept",t.Again="Again",t.Attn="Attn",t.Cancel="Cancel",t.ContextMenu="ContextMenu",t.Escape="Escape",t.Execute="Execute",t.Find="Find",t.Finish="Finish",t.Help="Help",t.Pause="Pause",t.Play="Play",t.Props="Props",t.Select="Select",t.ZoomIn="ZoomIn",t.ZoomOut="ZoomOut",t.BrightnessDown="BrightnessDown",t.BrightnessUp="BrightnessUp",t.Eject="Eject",t.LogOff="LogOff",t.Power="Power",t.PowerOff="PowerOff",t.PrintScreen="PrintScreen",t.Hibernate="Hibernate",t.Standby="Standby",t.WakeUp="WakeUp",t.AllCandidates="AllCandidates",t.Alphanumeric="Alphanumeric",t.CodeInput="CodeInput",t.Compose="Compose",t.Convert="Convert",t.Dead="Dead",t.FinalMode="FinalMode",t.GroupFirst="GroupFirst",t.GroupLast="GroupLast",t.GroupNext="GroupNext",t.GroupPrevious="GroupPrevious",t.ModeChange="ModeChange",t.NextCandidate="NextCandidate",t.NonConvert="NonConvert",t.PreviousCandidate="PreviousCandidate",t.Process="Process",t.SingleCandidate="SingleCandidate",t.HangulMode="HangulMode",t.HanjaMode="HanjaMode",t.JunjaMode="JunjaMode",t.Eisu="Eisu",t.Hankaku="Hankaku",t.Hiragana="Hiragana",t.HiraganaKatakana="HiraganaKatakana",t.KanaMode="KanaMode",t.KanjiMode="KanjiMode",t.Katakana="Katakana",t.Romaji="Romaji",t.Zenkaku="Zenkaku",t.ZenkakuHanaku="ZenkakuHanaku",t.F1="F1",t.F2="F2",t.F3="F3",t.F4="F4",t.F5="F5",t.F6="F6",t.F7="F7",t.F8="F8",t.F9="F9",t.F10="F10",t.F11="F11",t.F12="F12",t.F13="F13",t.F14="F14",t.F15="F15",t.F16="F16",t.F17="F17",t.F18="F18",t.F19="F19",t.F20="F20",t.Soft1="Soft1",t.Soft2="Soft2",t.Soft3="Soft3",t.Soft4="Soft4",t.AppSwitch="AppSwitch",t.Call="Call",t.Camera="Camera",t.CameraFocus="CameraFocus",t.EndCall="EndCall",t.GoBack="GoBack",t.GoHome="GoHome",t.HeadsetHook="HeadsetHook",t.LastNumberRedial="LastNumberRedial",t.Notification="Notification",t.MannerMode="MannerMode",t.VoiceDial="VoiceDial",t.ChannelDown="ChannelDown",t.ChannelUp="ChannelUp",t.MediaFastForward="MediaFastForward",t.MediaPause="MediaPause",t.MediaPlay="MediaPlay",t.MediaPlayPause="MediaPlayPause",t.MediaRecord="MediaRecord",t.MediaRewind="MediaRewind",t.MediaStop="MediaStop",t.MediaTrackNext="MediaTrackNext",t.MediaTrackPrevious="MediaTrackPrevious",t.AudioBalanceLeft="AudioBalanceLeft",t.AudioBalanceRight="AudioBalanceRight",t.AudioBassDown="AudioBassDown",t.AudioBassBoostDown="AudioBassBoostDown",t.AudioBassBoostToggle="AudioBassBoostToggle",t.AudioBassBoostUp="AudioBassBoostUp",t.AudioBassUp="AudioBassUp",t.AudioFaderFront="AudioFaderFront",t.AudioFaderRear="AudioFaderRear",t.AudioSurroundModeNext="AudioSurroundModeNext",t.AudioTrebleDown="AudioTrebleDown",t.AudioTrebleUp="AudioTrebleUp",t.AudioVolumeDown="AudioVolumeDown",t.AudioVolumeMute="AudioVolumeMute",t.AudioVolumeUp="AudioVolumeUp",t.MicrophoneToggle="MicrophoneToggle",t.MicrophoneVolumeDown="MicrophoneVolumeDown",t.MicrophoneVolumeMute="MicrophoneVolumeMute",t.MicrophoneVolumeUp="MicrophoneVolumeUp",t.TV="TV",t.TV3DMode="TV3DMode",t.TVAntennaCable="TVAntennaCable",t.TVAudioDescription="TVAudioDescription",t.TVAudioDescriptionMixDown="TVAudioDescriptionMixDown",t.TVAudioDescriptionMixUp="TVAudioDescriptionMixUp",t.TVContentsMenu="TVContentsMenu",t.TVDataService="TVDataService",t.TVInput="TVInput",t.TVInputComponent1="TVInputComponent1",t.TVInputComponent2="TVInputComponent2",t.TVInputComposite1="TVInputComposite1",t.TVInputComposite2="TVInputComposite2",t.TVInputHDMI1="TVInputHDMI1",t.TVInputHDMI2="TVInputHDMI2",t.TVInputHDMI3="TVInputHDMI3",t.TVInputHDMI4="TVInputHDMI4",t.TVInputVGA1="TVInputVGA1",t.TVMediaContext="TVMediaContext",t.TVNetwork="TVNetwork",t.TVNumberEntry="TVNumberEntry",t.TVPower="TVPower",t.TVRadioService="TVRadioService",t.TVSatellite="TVSatellite",t.TVSatelliteBS="TVSatelliteBS",t.TVSatelliteCS="TVSatelliteCS",t.TVSatelliteToggle="TVSatelliteToggle",t.TVTerrestrialAnalog="TVTerrestrialAnalog",t.TVTerrestrialDigital="TVTerrestrialDigital",t.TVTimer="TVTimer",t.AVRInput="AVRInput",t.AVRPower="AVRPower",t.ColorF0Red="ColorF0Red",t.ColorF1Green="ColorF1Green",t.ColorF2Yellow="ColorF2Yellow",t.ColorF3Blue="ColorF3Blue",t.ColorF4Grey="ColorF4Grey",t.ColorF5Brown="ColorF5Brown",t.ClosedCaptionToggle="ClosedCaptionToggle",t.Dimmer="Dimmer",t.DisplaySwap="DisplaySwap",t.DVR="DVR",t.Exit="Exit",t.FavoriteClear0="FavoriteClear0",t.FavoriteClear1="FavoriteClear1",t.FavoriteClear2="FavoriteClear2",t.FavoriteClear3="FavoriteClear3",t.FavoriteRecall0="FavoriteRecall0",t.FavoriteRecall1="FavoriteRecall1",t.FavoriteRecall2="FavoriteRecall2",t.FavoriteRecall3="FavoriteRecall3",t.FavoriteStore0="FavoriteStore0",t.FavoriteStore1="FavoriteStore1",t.FavoriteStore2="FavoriteStore2",t.FavoriteStore3="FavoriteStore3",t.Guide="Guide",t.GuideNextDay="GuideNextDay",t.GuidePreviousDay="GuidePreviousDay",t.Info="Info",t.InstantReplay="InstantReplay",t.Link="Link",t.ListProgram="ListProgram",t.LiveContent="LiveContent",t.Lock="Lock",t.MediaApps="MediaApps",t.MediaAudioTrack="MediaAudioTrack",t.MediaLast="MediaLast",t.MediaSkipBackward="MediaSkipBackward",t.MediaSkipForward="MediaSkipForward",t.MediaStepBackward="MediaStepBackward",t.MediaStepForward="MediaStepForward",t.MediaTopMenu="MediaTopMenu",t.NavigateIn="NavigateIn",t.NavigateNext="NavigateNext",t.NavigateOut="NavigateOut",t.NavigatePrevious="NavigatePrevious",t.NextFavoriteChannel="NextFavoriteChannel",t.NextUserProfile="NextUserProfile",t.OnDemand="OnDemand",t.Pairing="Pairing",t.PinPDown="PinPDown",t.PinPMove="PinPMove",t.PinPToggle="PinPToggle",t.PinPUp="PinPUp",t.PlaySpeedDown="PlaySpeedDown",t.PlaySpeedReset="PlaySpeedReset",t.PlaySpeedUp="PlaySpeedUp",t.RandomToggle="RandomToggle",t.RcLowBattery="RcLowBattery",t.RecordSpeedNext="RecordSpeedNext",t.RfBypass="RfBypass",t.ScanChannelsToggle="ScanChannelsToggle",t.ScreenModeNext="ScreenModeNext",t.Settings="Settings",t.SplitScreenToggle="SplitScreenToggle",t.STBInput="STBInput",t.STBPower="STBPower",t.Subtitle="Subtitle",t.Teletext="Teletext",t.VideoModeNext="VideoModeNext",t.Wink="Wink",t.ZoomToggle="ZoomToggle",t.SpeechCorrectionList="SpeechCorrectionList",t.SpeechInputToggle="SpeechInputToggle",t.Close="Close",t.New="New",t.Open="Open",t.Print="Print",t.Save="Save",t.SpellCheck="SpellCheck",t.MailForward="MailForward",t.MailReply="MailReply",t.MailSend="MailSend",t.LaunchCalculator="LaunchCalculator",t.LaunchCalendar="LaunchCalendar",t.LaunchContacts="LaunchContacts",t.LaunchMail="LaunchMail",t.LaunchMediaPlayer="LaunchMediaPlayer",t.LaunchMusicPlayer="LaunchMusicPlayer",t.LaunchMyComputer="LaunchMyComputer",t.LaunchPhone="LaunchPhone",t.LaunchScreenSaver="LaunchScreenSaver",t.LaunchSpreadsheet="LaunchSpreadsheet",t.LaunchWebBrowser="LaunchWebBrowser",t.LaunchWebCam="LaunchWebCam",t.LaunchWordProcessor="LaunchWordProcessor",t.LaunchApplication1="LaunchApplication1",t.LaunchApplication2="LaunchApplication2",t.LaunchApplication3="LaunchApplication3",t.LaunchApplication4="LaunchApplication4",t.LaunchApplication5="LaunchApplication5",t.LaunchApplication6="LaunchApplication6",t.LaunchApplication7="LaunchApplication7",t.LaunchApplication8="LaunchApplication8",t.LaunchApplication9="LaunchApplication9",t.LaunchApplication10="LaunchApplication10",t.LaunchApplication11="LaunchApplication11",t.LaunchApplication12="LaunchApplication12",t.LaunchApplication13="LaunchApplication13",t.LaunchApplication14="LaunchApplication14",t.LaunchApplication15="LaunchApplication15",t.LaunchApplication16="LaunchApplication16",t.BrowserBack="BrowserBack",t.BrowserFavorites="BrowserFavorites",t.BrowserForward="BrowserForward",t.BrowserHome="BrowserHome",t.BrowserRefresh="BrowserRefresh",t.BrowserSearch="BrowserSearch",t.BrowserStop="BrowserStop",t.Decimal="Decimal",t.Key11="Key11",t.Key12="Key12",t.Multiply="Multiply",t.Add="Add",t.Divide="Divide",t.Subtract="Subtract",t.Separator="Separator"}(e.Key||(e.Key={}))})(De);const Co=(e,t,n,o)=>{let i;const r=g=>i=g;let s;const a=g=>s=g,{store:u,selection:p}=t;let h,c,m;const f=g=>{var E;if(c===!1)return;h=!((E=g.target.parentElement)!=null&&E.closest(X))?{annotation:be(),selector:[],creator:i,created:new Date}:void 0};n&&e.addEventListener("selectstart",f);const v=pt(g=>{var P,A;const T=document.getSelection();if(!!((A=(P=T.anchorNode)==null?void 0:P.parentElement)!=null&&A.closest(X))){h=void 0;return}if(g.timeStamp-((m==null?void 0:m.timeStamp)||g.timeStamp)<1e3&&!h&&f(m||g),T.isCollapsed||!h||c===!1)return;const M=T.getRangeAt(0);if(zt(M))return;const B=Ht(M.cloneRange());(B.length!==h.selector.length||B.some((S,C)=>{var L;return S.toString()!==((L=h.selector[C])==null?void 0:L.quote)}))&&(h={...h,selector:B.map(S=>Zt(S,e,o)),updated:new Date},u.getAnnotation(h.annotation)?u.updateTarget(h,O.LOCAL):(p.clear(),u.addAnnotation({id:h.annotation,bodies:[],target:h},O.LOCAL),p.userSelect(h.annotation,m)))});n&&document.addEventListener("selectionchange",v);const b=g=>{m=Qt(g),c=m.button===0};e.addEventListener("pointerdown",b);const w=g=>{var B;if(!!((B=g.target.parentElement)!=null&&B.closest(X))||!c)return;const E=()=>{const{x:R,y:P}=e.getBoundingClientRect(),A=u.getAt(g.clientX-R,g.clientY-P,s);if(A){const{selected:S}=p;(S.length!==1||S[0].id!==A.id)&&p.userSelect(A.id,g)}else p.isEmpty()||p.clear()},M=g.timeStamp-m.timeStamp;document.getSelection().isCollapsed&&M<300?(h=void 0,E()):h&&p.userSelect(h.annotation,g)};document.addEventListener("pointerup",w),_("*",{element:e,keyup:!1,keydown:!0},(g,T)=>{g.repeat||(m=Kt(g))}),_("*",{keyup:!0,keydown:!1},g=>{_.shift&&g.key===De.Key.Shift&&!g.repeat&&h&&p.userSelect(h.annotation,g)});let d=!1;return _("ctrl+a, ⌘+a",{keyup:!1,keydown:!0},()=>{d=!0}),_("*",{keyup:!0,keydown:!1},g=>{d&&!g.repeat&&h&&p.userSelect(h.annotation,g),d=!1}),{destroy:()=>{e.removeEventListener("selectstart",f),document.removeEventListener("selectionchange",v),e.removeEventListener("pointerdown",b),document.removeEventListener("pointerup",w),_.unbind()},setFilter:a,setUser:r}},Ue="SPANS",To=(e,t={})=>{Yt(e),Xt(e);const n=ke(t,{annotatingEnabled:!0,user:jn()}),o=Be(e,n.userAction),{selection:i,viewport:r}=o,s=o.store,a=In(s),u=yn(o,a,n.adapter);let p=n.user;const h=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Ue:n.renderer||Ue,c=h==="SPANS"?ge(e,o,r):h==="CSS_HIGHLIGHTS"?pe(e,o,r):h==="CANVAS"?te(e,o,r):void 0;if(!c)throw`Unknown renderer implementation: ${h}`;console.debug(`Using ${h} renderer`),n.style&&c.setStyle(n.style);const m=Co(e,o,n.annotatingEnabled,n.offsetReferenceSelector);m.setUser(p);const f=Un(o,a,n.adapter),v=()=>p,b=T=>{c.setFilter(T),m.setFilter(T)},w=T=>{p=T,m.setUser(T)},d=T=>{T&&(c.setPainter(lo(e,T,n.presence)),T.on("selectionChange",()=>c.redraw()))},l=T=>{T?i.setSelected(T):i.clear()};return{...f,destroy:()=>{c.destroy(),m.destroy(),a.destroy()},element:e,getUser:v,setFilter:b,setStyle:c.setStyle.bind(c),redraw:c.redraw.bind(c),setUser:w,setSelected:l,setPresenceProvider:d,setVisible:c.setVisible.bind(c),on:u.on,off:u.off,scrollIntoView:co(e,s),state:o}};x.DEFAULT_SELECTED_STYLE=et,x.DEFAULT_STYLE=H,x.NOT_ANNOTATABLE_CLASS=St,x.NOT_ANNOTATABLE_SELECTOR=X,x.Origin=O,x.UserSelectAction=Ae,x.W3CTextFormat=qn,x.cancelSingleClickEvents=Yt,x.cloneKeyboardEvent=Kt,x.clonePointerEvent=Qt,x.createBody=Ln,x.createCanvasRenderer=te,x.createHighlightsRenderer=pe,x.createRenderer=fe,x.createSpansRenderer=ge,x.createTextAnnotator=To,x.createTextAnnotatorState=Be,x.debounce=pt,x.denormalizeRectWithOffset=qe,x.fillDefaults=ke,x.getAnnotatableFragment=Ye,x.getClientRectsPonyfill=je,x.getQuoteContext=Wt,x.getRangeAnnotatableContents=ft,x.isRevived=j,x.isWhitespaceOrEmpty=zt,x.mergeClientRects=qt,x.normalizeRectWithOffset=Jt,x.paint=_t,x.parseW3CTextAnnotation=Le,x.programmaticallyFocusable=Xt,x.rangeToSelector=Zt,x.reviveAnnotation=ht,x.reviveSelector=Ct,x.reviveTarget=nt,x.serializeW3CTextAnnotation=Ee,x.splitAnnotatableRanges=Ht,x.toDomRectList=ze,x.whitespaceOrEmptyRegex=Gt,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
3
3
  //# sourceMappingURL=text-annotator.umd.js.map