@soomo/text-annotator 3.4.0-staging.1 → 3.4.0-staging.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/TextAnnotatorOptions.d.ts +6 -2
- package/dist/src/state/spatialTree.d.ts +1 -1
- package/dist/src/utils/getHighlightClientRects.d.ts +1 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/mergeClientRects.d.ts +1 -1
- package/dist/text-annotator.es.js +666 -642
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +3 -2
- package/dist/src/utils/rangeContains.d.ts +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(p,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("debounce"),require("colord"),require("dequal/lite"),require("uuid"),require("@annotorious/core"),require("rbush"),require("nanoevents"),require("hotkeys-js"),require("poll")):typeof define=="function"&&define.amd?define(["exports","debounce","colord","dequal/lite","uuid","@annotorious/core","rbush","nanoevents","hotkeys-js","poll"],_):(p=typeof globalThis<"u"?globalThis:p||self,_(p.RecogitoJS={},p.debounce,p.Colord,p.DequalLite,p.UUID,p.AnnotoriousCore,p.RBush,p.nanoevents,p.HotkeysJs,p.poll))})(this,(function(p,_,ot,Dt,st,O,_t,Ut,G,Ft){"use strict";const tt="not-annotatable",U=`.${tt}`,V=(t,n)=>{var o;return t.contains(n)?!!(n instanceof HTMLElement?n.closest(U):(o=n.parentElement)==null?void 0:o.closest(U)):!0},rt=(t,n)=>{const e=n.commonAncestorContainer;return!V(t,e)},it=t=>t.addEventListener("click",n=>{!n.target.closest(U)&&!n.target.closest("a")&&n.preventDefault()}),at=typeof navigator<"u"&&/mac/i.test(navigator.userAgentData?navigator.userAgentData.platform:navigator.platform),ct=t=>{!t.hasAttribute("tabindex")&&t.tabIndex<0&&t.setAttribute("tabindex","-1"),t.classList.add("no-focus-outline")},Wt=function*(t){const n=document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,o=>o instanceof HTMLElement&&o.classList.contains(tt)&&!o.parentElement.closest(U)&&t.intersectsNode(o)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let e;for(;e=n.nextNode();)e instanceof HTMLElement&&(yield e)},lt=(t,n)=>{if(!rt(t,n))return[];const e=[];let o=null;for(const s of Wt(n)){let r;o?(r=document.createRange(),r.setStartAfter(o),r.setEndBefore(s)):(r=n.cloneRange(),r.setEndBefore(s)),r.collapsed||e.push(r),o=s}if(o){const s=n.cloneRange();s.setStartAfter(o),s.collapsed||e.push(s)}return e.length>0?e:[n]},Q=t=>{const n=t.cloneContents();return n.querySelectorAll(U).forEach(e=>e.remove()),n},dt=(t,n,e=10,o)=>{const s=o?t.startContainer.parentElement.closest(o):n,r=document.createRange();r.setStart(s,0),r.setEnd(t.startContainer,t.startOffset);const i=Q(r).textContent,a=document.createRange();a.setStart(t.endContainer,t.endOffset),s===document.body?a.setEnd(s,s.childNodes.length):a.setEndAfter(s);const u=Q(a).textContent;return{prefix:i.substring(i.length-e),suffix:u.substring(0,e)}},P=t=>t.every(n=>n.range instanceof Range&&!n.range.collapsed),ut=/^\s*$/,ft=t=>ut.test(t.toString()),Kt=(t,n)=>{const e=r=>Math.round(r*10)/10,o={top:e(t.top),bottom:e(t.bottom),left:e(t.left),right:e(t.right)},s={top:e(n.top),bottom:e(n.bottom),left:e(n.left),right:e(n.right)};if(Math.abs(o.top-s.top)<.5&&Math.abs(o.bottom-s.bottom)<.5){if(Math.abs(o.left-s.right)<.5||Math.abs(o.right-s.left)<.5)return"inline-adjacent";if(o.left>=s.left&&o.right<=s.right)return"inline-is-contained";if(o.left<=s.left&&o.right>=s.right)return"inline-contains"}else if(o.top<=s.top&&o.bottom>=s.bottom){if(o.left<=s.left&&o.right>=s.right)return"block-contains"}else if(o.top>=s.top&&o.bottom<=s.bottom&&o.left>=s.left&&o.right<=s.right)return"block-is-contained"},$t=(t,n)=>{const e=Math.min(t.left,n.left),o=Math.max(t.right,n.right),s=Math.min(t.top,n.top),r=Math.max(t.bottom,n.bottom);return new DOMRect(e,s,o-e,r-s)},gt=t=>t.reduce((n,e)=>{if(e.width===0||e.height===0)return n;let o=[...n],s=!1;for(const r of n){const i=Kt(e,r);if(i==="inline-adjacent"){o=o.map(a=>a===r?$t(e,r):a),s=!0;break}else if(i==="inline-contains"){o=o.map(a=>a===r?e:a),s=!0;break}else if(i==="inline-is-contained"){s=!0;break}else if(i==="block-contains"||i==="block-is-contained"){e.width<r.width&&(o=o.map(a=>a===r?e:a)),s=!0;break}}return s?o:[...o,e]},[]),Vt=t=>({length:t.length,item:n=>t[n],[Symbol.iterator]:function*(){for(let n=0;n<this.length;n++)yield this.item(n)}}),mt=(t,n,e)=>{const o=document.createRange(),s=e?t.startContainer.parentElement.closest(e):n;o.setStart(s,0),o.setEnd(t.startContainer,t.startOffset);const r=Q(o).textContent,i=t.toString(),a=r.length||0,u=a+i.length;return e?{quote:i,start:a,end:u,range:t,offsetReference:s}:{quote:i,start:a,end:u,range:t}},et=(t,n)=>{var b,f;const{start:e,end:o}=t,s=t.offsetReference||n,r=document.createNodeIterator(n,NodeFilter.SHOW_TEXT,h=>{var c;return(c=h.parentElement)!=null&&c.closest(U)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let i=0;const a=document.createRange();let u=r.nextNode();u===null&&console.error("Could not revive annotation target. Content missing.");let C=!s;for(;u!==null;){if(C||(C=typeof(s==null?void 0:s.contains)=="function"?s.contains(u):!1),C){const h=((b=u.textContent)==null?void 0:b.length)||0;if(i+h>e){a.setStart(u,e-i);break}i+=h}u=r.nextNode()}for(;u!==null;){const h=((f=u.textContent)==null?void 0:f.length)||0;if(i+h>=o){a.setEnd(u,o-i);break}i+=h,u=r.nextNode()}return{...t,range:a}},Y=(t,n)=>P(t.selector)?t:{...t,selector:t.selector.map(e=>e.range instanceof Range&&!e.range.collapsed?e:et(e,n))},J=(t,n)=>P(t.target.selector)?t:{...t,target:Y(t.target,n)},ht=(t,n)=>{if(t.isEqualNode(n))return!0;for(let e of t.childNodes)if(ht(e,n))return!0;return!1},pt=(t,n)=>{const e=t.cloneContents();return ht(e,n)},yt=(t,n)=>{const e=t.cloneRange(),o=n.contains(e.startContainer),s=n.contains(e.endContainer);return!o&&!s&&!pt(e,n)?(e.collapse(),e):(o||e.setStart(n,0),s||e.setEnd(n,n.childNodes.length),e)},Z=t=>({...t,type:t.type,x:t.x,y:t.y,clientX:t.clientX,clientY:t.clientY,offsetX:t.offsetX,offsetY:t.offsetY,screenX:t.screenX,screenY:t.screenY,isPrimary:t.isPrimary,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey,button:t.button,buttons:t.buttons,currentTarget:t.currentTarget,target:t.target,defaultPrevented:t.defaultPrevented,detail:t.detail,eventPhase:t.eventPhase,pointerId:t.pointerId,pointerType:t.pointerType,timeStamp:t.timeStamp}),q=t=>({...t,type:t.type,key:t.key,code:t.code,location:t.location,repeat:t.repeat,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey,currentTarget:t.currentTarget,target:t.target,defaultPrevented:t.defaultPrevented,detail:t.detail,timeStamp:t.timeStamp}),bt=(t,n)=>{const{left:e,top:o,right:s,bottom:r}=t;return new DOMRect(e-n.left,o-n.top,s-e,r-o)},Yt=(t,n)=>{const{left:e,top:o,right:s,bottom:r}=t;return new DOMRect(e+n.left,o+n.top,s-e,r-o)},St=t=>{if(!t)return document.scrollingElement;const{overflowY:n}=window.getComputedStyle(t);return n!=="visible"&&n!=="hidden"&&t.scrollHeight>t.clientHeight?t:St(t.parentElement)},Ct=(t,n,e)=>{const o=e.getBoundingClientRect(),s=e.clientHeight,r=e.clientWidth,i=n.selector[0].range.getBoundingClientRect(),{width:a,height:u}=t.getAnnotationBounds(n.annotation),C=i.top-o.top,b=i.left-o.left,f=e.parentElement?e.scrollTop:0,h=e.parentElement?e.scrollLeft:0,c=C+f-(s-u)/2,L=b+h-(r-a)/2;e.scroll({top:c,left:L,behavior:"smooth"})},Et=(t,n)=>(e,o)=>{const s=typeof e=="string"?e:e.id,r=o?typeof o=="string"?document.getElementById(o):o:St(t);if(!r)return console.warn(`The scroll parent is missing for the annotation: ${s}`,{container:t}),!1;const i=n.getAnnotation(s);if(!i)return console.warn(`The annotation is missing in the store: ${s}`),!1;const{range:a}=i.target.selector[0];if(a&&!a.collapsed)return Ct(n,i.target,r),!0;const u=Y(i.target,t),{range:C}=u.selector[0];return C&&!C.collapsed?(Ct(n,u,r),!0):!1},D={fill:"rgb(0, 128, 255)",fillOpacity:.18},z={fill:"rgb(0, 128, 255)",fillOpacity:.45},vt=(t,n,e,o,s)=>{var i,a;const r=e?typeof e=="function"?e(t.annotation,t.state,s)||((i=t.state)!=null&&i.selected?z:D):e:(a=t.state)!=null&&a.selected?z:D;return o&&o.paint(t,n)||r},qt=t=>{const{top:n,left:e}=t.getBoundingClientRect(),{innerWidth:o,innerHeight:s}=window,r=-e,i=-n,a=o-e,u=s-n;return{top:n,left:e,minX:r,minY:i,maxX:a,maxY:u}},zt=t=>{let n=new Set;return o=>{const s=o.map(r=>r.id);(n.size!==s.length||s.some(r=>!n.has(r)))&&t.set(s),n=new Set(s)}},nt=(t,n,e,o)=>{const{store:s,selection:r,hover:i}=n;let a,u,C;const b=zt(e),f=E=>{const{x:N,y:I}=t.getBoundingClientRect(),F=s.getAt(E.clientX-N,E.clientY-I,!1,u);F?i.current!==F.id&&(t.classList.add("hovered"),i.set(F.id)):i.current&&(t.classList.remove("hovered"),i.set(null))};t.addEventListener("pointermove",f);const h=(E=!1)=>{C&&C.clear();const N=qt(t),{minX:I,minY:F,maxX:S,maxY:R}=N,M=u?s.getIntersecting(I,F,S,R).filter(({annotation:k})=>u(k)):s.getIntersecting(I,F,S,R),X=r.selected.map(({id:k})=>k),H=M.map(({annotation:k,rects:W})=>{const B=X.includes(k.id),K=k.id===i.current;return{annotation:k,rects:W,state:{selected:B,hovered:K}}});o.redraw(H,N,a,C,E),setTimeout(()=>b(M.map(({annotation:k})=>k)),1)},c=E=>{C=E,h()},L=E=>{a=E,h()},w=E=>{u=E,h(!1)},x=()=>h();s.observe(x);const v=r.subscribe(()=>h()),m=i.subscribe(()=>h()),l=()=>h(!0);document.addEventListener("scroll",l,{capture:!0,passive:!0});const g=_(()=>{s.recalculatePositions(),C==null||C.reset(),h()},10);window.addEventListener("resize",g);const d=new ResizeObserver(g);d.observe(t);const y={attributes:!0,childList:!0,subtree:!0},A=new MutationObserver(_(E=>{E.every(I=>I.target===t||t.contains(I.target))||h(!0)},150));return A.observe(document.body,y),{destroy:()=>{t.removeEventListener("pointermove",f),o.destroy(),s.unobserve(x),v(),m(),document.removeEventListener("scroll",l),g.clear(),window.removeEventListener("resize",g),d.disconnect(),A.disconnect()},redraw:h,setStyle:L,setFilter:w,setPainter:c,setVisible:o.setVisible}},Xt=()=>{const t=document.createElement("canvas");return t.width=window.innerWidth,t.height=window.innerHeight,t.className="r6o-canvas-highlight-layer bg",t},jt=(t,n)=>{t.width=window.innerWidth,t.height=window.innerHeight},Gt=t=>{t.classList.add("r6o-annotatable");const n=Xt(),e=n.getContext("2d");document.body.appendChild(n);const o=(a,u,C,b)=>requestAnimationFrame(()=>{const{width:f,height:h}=n;e.clearRect(-.5,-.5,f+1,h+1),b&&b.clear();const{top:c,left:L}=u;[...a].sort((x,v)=>{const{annotation:{target:{created:m}}}=x,{annotation:{target:{created:l}}}=v;return m.getTime()-l.getTime()}).forEach(x=>{var g;const v=C?typeof C=="function"?C(x.annotation,x.state):C:(g=x.state)!=null&&g.selected?z:D,m=b&&b.paint(x,u)||v,l=x.rects.map(({x:d,y,width:A,height:T})=>({x:d+L,y:y+c,width:A,height:T}));if(e.fillStyle=m.fill,e.globalAlpha=m.fillOpacity||1,l.forEach(({x:d,y,width:A,height:T})=>e.fillRect(d,y,A,T)),m.underlineColor){e.globalAlpha=1,e.strokeStyle=m.underlineColor,e.lineWidth=m.underlineThickness??1;const d=m.underlineOffset??0;l.forEach(({x:y,y:A,width:T,height:E})=>{e.beginPath(),e.moveTo(y,A+E+d),e.lineTo(y+T,A+E+d),e.stroke()})}})}),s=_(()=>jt(n),10);return window.addEventListener("resize",s),{destroy:()=>{n.remove(),s.clear(),window.removeEventListener("resize",s)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:o}},At=(t,n,e)=>nt(t,n,e,Gt(t)),Qt=t=>[`background-color:${ot.colord((t==null?void 0:t.fill)||D.fill).alpha((t==null?void 0:t.fillOpacity)===void 0?D.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(";"),wt=()=>{const t=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(t);let n=new Set;return{destroy:()=>{CSS.highlights.clear(),t.remove()},setVisible:r=>{console.log("setVisible not implemented on CSS Custom Highlights renderer")},redraw:(r,i,a,u)=>{u&&u.clear();const C=new Set(r.map(f=>f.annotation.id));Array.from(n).filter(f=>!C.has(f));const b=r.map(f=>{var L;const h=a?typeof a=="function"?a(f.annotation,f.state):a:(L=f.state)!=null&&L.selected?z:D,c=u&&u.paint(f,i)||h;return`::highlight(_${f.annotation.id}) { ${Qt(c)} }`});t.innerHTML=b.join(`
|
|
2
|
-
`),CSS.highlights.clear(),r.forEach(({annotation:f})=>{const h=f.target.selector.map(L=>L.range),c=new Highlight(...h);CSS.highlights.set(`_${f.id}`,c)}),n=C}}},Tt=(t,n,e)=>nt(t,n,e,wt()),Jt=(t,n)=>{const e=(r,i)=>r.x<=i.x+i.width&&r.x+r.width>=i.x&&r.y<=i.y+i.height&&r.y+r.height>=i.y,o=r=>r.rects.reduce((i,a)=>i+a.width,0),s=n.filter(({rects:r})=>r.some(i=>e(t,i)));return s.sort((r,i)=>o(i)-o(r)),s.findIndex(r=>r.rects.includes(t))},Zt=t=>{t.classList.add("r6o-annotatable");const n=document.createElement("div");n.className="r6o-span-highlight-layer",t.insertBefore(n,t.firstChild);let e=[];return{destroy:()=>{n.remove()},redraw:(i,a,u,C,b)=>{const h=!(Dt.dequal(e,i)&&b);if(!C&&!h)return;h&&(n.innerHTML=""),[...i].sort((L,w)=>{const{annotation:{target:{created:x}}}=L,{annotation:{target:{created:v}}}=w;return x&&v?x.getTime()-v.getTime():0}).forEach(L=>{L.rects.map(w=>{const x=Jt(w,i),v=vt(L,a,u,C,x);if(h){const m=document.createElement("span");m.className="r6o-annotation",m.dataset.annotation=L.annotation.id,m.style.left=`${w.x}px`,m.style.top=`${w.y}px`,m.style.width=`${w.width}px`,m.style.height=`${w.height}px`,m.style.backgroundColor=ot.colord((v==null?void 0:v.fill)||D.fill).alpha((v==null?void 0:v.fillOpacity)===void 0?D.fillOpacity:v.fillOpacity).toHex(),v.underlineStyle&&(m.style.borderStyle=v.underlineStyle),v.underlineColor&&(m.style.borderColor=v.underlineColor),v.underlineThickness&&(m.style.borderBottomWidth=`${v.underlineThickness}px`),v.underlineOffset&&(m.style.paddingBottom=`${v.underlineOffset}px`),n.appendChild(m)}})}),e=i},setVisible:i=>{i?n.classList.remove("hidden"):n.classList.add("hidden")}}},Rt=(t,n,e)=>nt(t,n,e,Zt(t)),te=(t,n)=>({parse:e=>Lt(e),serialize:e=>xt(e,t,n)}),ee=t=>t.quote!==void 0&&t.start!==void 0&&t.end!==void 0,ne=t=>{const{id:n,creator:e,created:o,modified:s,target:r}=t,i=Array.isArray(r)?r:[r];if(i.length===0)return{error:Error(`No targets found for annotation: ${t.id}`)};const a={creator:O.parseW3CUser(e),created:o?new Date(o):void 0,updated:s?new Date(s):void 0,annotation:n,selector:[],styleClass:"styleClass"in i[0]?i[0].styleClass:void 0};for(const u of i){const b=(Array.isArray(u.selector)?u.selector:[u.selector]).reduce((f,h)=>{switch(h.type){case"TextQuoteSelector":f.quote=h.exact;break;case"TextPositionSelector":f.start=h.start,f.end=h.end;break}return f},{});if(a.outdated||(a.outdated="outdated"in u?u.outdated:void 0),ee(b))a.selector.push({...b,id:u.id,scope:u.scope});else{const f=[b.start?void 0:"TextPositionSelector",b.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${f.join(" and ")} for annotation: ${t.id}`)}}}return{parsed:a}},Lt=t=>{const n=t.id||st.v4(),{creator:e,created:o,modified:s,body:r,...i}=t,a=O.parseW3CBodies(r,n),u=ne(t);return"error"in u?{error:u.error}:{parsed:{...i,id:n,bodies:a,target:u.parsed}}},xt=(t,n,e)=>{const{bodies:o,target:s,...r}=t,{selector:i,creator:a,created:u,updated:C,...b}=s,f=i.map(h=>{const{id:c,quote:L,start:w,end:x,range:v}=h,m={type:"TextQuoteSelector",exact:L};if(e){const{prefix:g,suffix:d}=dt(v,e);m.prefix=g,m.suffix=d}const l={type:"TextPositionSelector",start:w,end:x};return{...b,id:c,scope:"scope"in h?h.scope:void 0,source:n,selector:[m,l]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:t.id,type:"Annotation",body:O.serializeW3CBodies(t.bodies),creator:a,created:u==null?void 0:u.toISOString(),modified:C==null?void 0:C.toISOString(),target:f}},oe=(t,n)=>{const e=new _t,o=new Map,s=Ut.createNanoEvents(),r=(l,g)=>{const d=l.selector.flatMap(A=>{const T=P([A])?A.range:et(A,n).range;return Array.from(T.getClientRects())}),y=gt(d).map(A=>bt(A,g));return y.map(A=>{const{x:T,y:E,width:N,height:I}=A;return{minX:T,minY:E,maxX:T+N,maxY:E+I,annotation:{id:l.annotation,rects:y}}})},i=()=>[...o.values()],a=()=>{e.clear(),o.clear()},u=l=>{const g=r(l,n.getBoundingClientRect());g.length!==0&&(g.forEach(d=>e.insert(d)),o.set(l.annotation,g))},C=l=>{const g=o.get(l.annotation);g&&(g.forEach(d=>e.remove(d)),o.delete(l.annotation))},b=l=>{C(l),u(l)},f=(l,g=!0)=>{g&&a();const d=n.getBoundingClientRect(),y=l.map(T=>({target:T,rects:r(T,d)}));y.forEach(({target:T,rects:E})=>{E.length>0&&o.set(T.annotation,E)});const A=y.flatMap(({rects:T})=>T);e.load(A)},h=(l,g,d=!1)=>{const y=e.search({minX:l,minY:g,maxX:l,maxY:g}),A=T=>T.annotation.rects.reduce((E,N)=>E+N.width*N.height,0);return y.length>0?(y.sort((T,E)=>A(T)-A(E)),d?y.map(T=>T.annotation.id):[y[0].annotation.id]):[]},c=l=>{const g=L(l);if(g.length===0)return;let d=g[0].left,y=g[0].top,A=g[0].right,T=g[0].bottom;for(let E=1;E<g.length;E++){const N=g[E];d=Math.min(d,N.left),y=Math.min(y,N.top),A=Math.max(A,N.right),T=Math.max(T,N.bottom)}return new DOMRect(d,y,A-d,T-y)},L=l=>{const g=o.get(l);return g?g[0].annotation.rects:[]};return{all:i,clear:a,getAt:h,getAnnotationBounds:c,getAnnotationRects:L,getIntersecting:(l,g,d,y)=>{const A=e.search({minX:l,minY:g,maxX:d,maxY:y}),T=new Set(A.map(E=>E.annotation.id));return Array.from(T).map(E=>({annotation:t.getAnnotation(E),rects:L(E)})).filter(E=>!!E.annotation)},insert:u,recalculate:()=>{f(t.all().map(l=>l.target),!0),s.emit("recalculate")},remove:C,set:f,size:()=>e.all().length,update:b,on:(l,g)=>s.on(l,g)}},Ot=(t,n)=>{const e=O.createStore(),o=oe(e,t),s=O.createSelectionState(e,n.userSelectAction,n.adapter),r=O.createHoverState(e),i=O.createViewportState(),a=(m,l=O.Origin.LOCAL)=>{const g=J(m,t),d=P(g.target.selector);return d&&e.addAnnotation(g,l),d},u=(m,l=!0,g=O.Origin.LOCAL)=>{const d=m.map(A=>J(A,t)),y=d.filter(A=>!P(A.target.selector));return e.bulkAddAnnotations(d,l,g),y},C=(m,l=O.Origin.LOCAL)=>{const g=m.map(y=>J(y,t)),d=g.filter(y=>!P(y.target.selector));return g.forEach(y=>{e.getAnnotation(y.id)?e.updateAnnotation(y,l):e.addAnnotation(y,l)}),d},b=(m,l=O.Origin.LOCAL)=>{const g=Y(m,t);e.updateTarget(g,l)},f=(m,l=O.Origin.LOCAL)=>{const g=m.map(d=>Y(d,t));e.bulkUpdateTargets(g,l)};function h(m,l,g,d){const y=g||!!d,A=o.getAt(m,l,y).map(E=>e.getAnnotation(E)),T=d?A.filter(d):A;if(T.length!==0)return g?T:T[0]}const c=m=>o.getAnnotationRects(m).length>0?o.getAnnotationBounds(m):void 0,L=(m,l,g,d)=>o.getIntersecting(m,l,g,d),w=m=>o.getAnnotationRects(m),x=()=>o.recalculate(),v=m=>o.on("recalculate",m);return e.observe(({changes:m})=>{const l=(m.deleted||[]).filter(y=>P(y.target.selector)),g=(m.created||[]).filter(y=>P(y.target.selector)),d=(m.updated||[]).filter(y=>P(y.newValue.target.selector));(l==null?void 0:l.length)>0&&l.forEach(y=>o.remove(y.target)),g.length>0&&o.set(g.map(y=>y.target),!1),(d==null?void 0:d.length)>0&&d.forEach(({newValue:y})=>o.update(y.target))}),{store:{...e,addAnnotation:a,bulkAddAnnotations:u,bulkUpdateTargets:f,bulkUpsertAnnotations:C,getAnnotationBounds:c,getAnnotationRects:w,getIntersecting:L,getAt:h,recalculatePositions:x,onRecalculatePositions:v,updateTarget:b},selection:s,hover:r,viewport:i}},se=()=>{const t=document.createElement("canvas");t.width=2*window.innerWidth,t.height=2*window.innerHeight,t.className="r6o-presence-layer";const n=t.getContext("2d");return n.scale(2,2),n.translate(.5,.5),t},Nt=(t,n={})=>{const e=se(),o=e.getContext("2d");document.body.appendChild(e);const s=new Map,r=b=>Array.from(s.entries()).filter(([f,h])=>h.presenceKey===b.presenceKey).map(([f,h])=>f);return t.on("selectionChange",(b,f)=>{r(b).forEach(c=>s.delete(c)),f&&f.forEach(c=>s.set(c,b))}),{clear:()=>{const{width:b,height:f}=e;o.clearRect(-.5,-.5,b+1,f+1)},destroy:()=>{e.remove()},paint:(b,f,h)=>{n.font&&(o.font=n.font);const c=s.get(b.annotation.id);if(c){const{height:L}=b.rects[0],w=b.rects[0].x+f.left,x=b.rects[0].y+f.top;o.fillStyle=c.appearance.color,o.fillRect(w-2,x-2.5,2,L+5);const v=o.measureText(c.appearance.label),m=v.width+6,l=v.actualBoundingBoxAscent+v.actualBoundingBoxDescent+8,g=v.fontBoundingBoxAscent?8:6.5;return o.fillRect(w-2,x-2.5-l,m,l),o.fillStyle="#fff",o.fillText(c.appearance.label,w+1,x-g),{fill:c.appearance.color,fillOpacity:h?.45:.18}}},reset:()=>{e.width=2*window.innerWidth,e.height=2*window.innerHeight;const b=e.getContext("2d");b.scale(2,2),b.translate(.5,.5)}}},kt=300,Bt=["up","down","left","right"],It=at?"⌘+a":"ctrl+a",re=[...Bt.map(t=>`shift+${t}`),It],Mt=(t,n,e)=>{const{store:o,selection:s}=n;let r;const{annotatingEnabled:i,offsetReferenceSelector:a,selectionMode:u,dismissOnNotAnnotatable:C="NEVER"}=e,b=S=>r=S;let f;const h=S=>f=S;let c,L,w,x=i;const v=S=>{x=S,l.clear(),S||(c=void 0,L=void 0,w=void 0)},m=S=>{x&&L!==!1&&(c=V(t,S.target)?void 0:{annotation:st.v4(),selector:[],creator:r,created:new Date})},l=_(S=>{if(!x)return;const R=document.getSelection();if(!(R!=null&&R.anchorNode))return;if(V(t,R.anchorNode)){c=void 0;return}const M=S.timeStamp-((w==null?void 0:w.timeStamp)||S.timeStamp);if((w==null?void 0:w.type)==="pointerdown"&&(M<1e3&&!c||R.isCollapsed&&M<kt)&&m(w||S),!c)return;if(R.isCollapsed){o.getAnnotation(c.annotation)&&(s.clear(),o.deleteAnnotation(c.annotation));return}const H=Array.from(Array(R.rangeCount).keys()).map(B=>R.getRangeAt(B)).map(B=>yt(B,t));if(H.every(B=>ft(B)))return;const k=H.flatMap(B=>lt(t,B.cloneRange()));(k.length!==c.selector.length||k.some((B,K)=>{var $;return B.toString()!==(($=c.selector[K])==null?void 0:$.quote)}))&&(c={...c,selector:k.map(B=>mt(B,t,a)),updated:new Date},o.getAnnotation(c.annotation)?o.updateTarget(c,O.Origin.LOCAL):s.clear())},10),g=S=>{w=Z(S),L=w.button===0},d=async S=>{if(!L)return;const R=Z(S),M=()=>{const{x:H,y:k}=t.getBoundingClientRect();if(V(t,R.target)){(typeof C=="function"?C(R,t):C==="ALWAYS")&&s.clear();return}const W=R.target instanceof Node&&t.contains(R.target)&&o.getAt(R.clientX-H,R.clientY-k,u==="all",f);if(W){const{selected:B}=s,K=new Set(B.map(j=>j.id)),$=Array.isArray(W)?W.map(j=>j.id):[W.id];(K.size!==$.length||!$.every(j=>K.has(j)))&&s.userSelect($,R)}else s.clear()};if(R.timeStamp-w.timeStamp<kt){await y();const H=document.getSelection();if(H!=null&&H.isCollapsed){c=void 0,M();return}}c&&c.selector.length>0&&(I(),s.userSelect(c.annotation,R))},y=async()=>{const S=document.getSelection();let R=!1,M=S==null?void 0:S.isCollapsed;const X=()=>M||R,H=1;return setTimeout(()=>R=!0,50),Ft.poll(()=>M=S==null?void 0:S.isCollapsed,H,X)},A=S=>{const R=document.getSelection();R!=null&&R.isCollapsed||((!c||c.selector.length===0)&&l(S),c&&(I(),s.userSelect(c.annotation,Z(S))))},T=S=>{x&&S.key==="Shift"&&c&&(document.getSelection().isCollapsed||(I(),s.userSelect(c.annotation,q(S))))},E=S=>{const R=()=>setTimeout(()=>{(c==null?void 0:c.selector.length)>0&&(s.clear(),o.addAnnotation({id:c.annotation,bodies:[],target:c}),s.userSelect(c.annotation,q(S))),document.removeEventListener("selectionchange",R)},100);document.addEventListener("selectionchange",R),m(S)};G(re.join(","),{element:t,keydown:!0,keyup:!1},S=>{S.repeat||(w=q(S))}),G(It,{keydown:!0,keyup:!1},S=>{w=q(S),E(S)});const N=S=>{S.repeat||S.target!==t&&S.target!==document.body||(c=void 0,s.clear())};G(Bt.join(","),{keydown:!0,keyup:!1},N);const I=()=>{const S=o.getAnnotation(c.annotation);if(!S){o.addAnnotation({id:c.annotation,bodies:[],target:c});return}const{target:{updated:R}}=S,{updated:M}=c;(!R||!M||R<M)&&o.updateTarget(c)};return document.addEventListener("pointerdown",g),document.addEventListener("pointerup",d),document.addEventListener("contextmenu",A),t.addEventListener("keyup",T),t.addEventListener("selectstart",m),document.addEventListener("selectionchange",l),{destroy:()=>{c=void 0,L=void 0,w=void 0,l.clear(),document.removeEventListener("pointerdown",g),document.removeEventListener("pointerup",d),document.removeEventListener("contextmenu",A),t.removeEventListener("keyup",T),t.removeEventListener("selectstart",m),document.removeEventListener("selectionchange",l),G.unbind()},setFilter:h,setUser:b,setAnnotatingEnabled:v}},Ht=(t,n)=>({...t,annotatingEnabled:t.annotatingEnabled??n.annotatingEnabled,user:t.user||n.user}),Pt="SPANS",ie=(t,n={})=>{it(t),ct(t);const e=Ht(n,{annotatingEnabled:!0,user:O.createAnonymousGuest()}),o=Ot(t,e),{selection:s,viewport:r}=o,i=o.store,a=O.createUndoStack(i),u=O.createLifecycleObserver(o,a,e.adapter);let C=e.user;const b=e.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Pt:e.renderer||Pt,f=b==="SPANS"?Rt(t,o,r):b==="CSS_HIGHLIGHTS"?Tt(t,o,r):b==="CANVAS"?At(t,o,r):void 0;if(!f)throw`Unknown renderer implementation: ${b}`;console.debug(`Using ${b} renderer`),e.style&&f.setStyle(e.style);const h=Mt(t,o,e);h.setUser(C),h.setAnnotatingEnabled(e.annotatingEnabled);const c=O.createBaseAnnotator(o,a,e.adapter),L=()=>C,w=d=>{h.setAnnotatingEnabled(d===void 0?!0:d)},x=d=>{f.setFilter(d),h.setFilter(d)},v=d=>{C=d,h.setUser(d)},m=d=>{d&&(f.setPainter(Nt(d,e.presence)),d.on("selectionChange",()=>f.redraw()))},l=d=>{d?s.setSelected(d):s.clear()};return{...c,destroy:()=>{f.destroy(),h.destroy(),a.destroy()},element:t,getUser:L,setAnnotatingEnabled:w,setFilter:x,setStyle:f.setStyle.bind(f),redraw:f.redraw.bind(f),setUser:v,setSelected:l,setPresenceProvider:m,setVisible:f.setVisible.bind(f),on:u.on,off:u.off,scrollIntoView:Et(t,i),state:o}};Object.defineProperty(p,"Origin",{enumerable:!0,get:()=>O.Origin}),Object.defineProperty(p,"UserSelectAction",{enumerable:!0,get:()=>O.UserSelectAction}),Object.defineProperty(p,"createBody",{enumerable:!0,get:()=>O.createBody}),p.DEFAULT_SELECTED_STYLE=z,p.DEFAULT_STYLE=D,p.NOT_ANNOTATABLE_CLASS=tt,p.NOT_ANNOTATABLE_SELECTOR=U,p.W3CTextFormat=te,p.cancelSingleClickEvents=it,p.cloneKeyboardEvent=q,p.clonePointerEvent=Z,p.createCanvasRenderer=At,p.createHighlightsRenderer=Tt,p.createPresencePainter=Nt,p.createRenderer=wt,p.createSelectionHandler=Mt,p.createSpansRenderer=Rt,p.createTextAnnotator=ie,p.createTextAnnotatorState=Ot,p.fillDefaults=Ht,p.getQuoteContext=dt,p.getRangeAnnotatableContents=Q,p.isMac=at,p.isNotAnnotatable=V,p.isRangeAnnotatable=rt,p.isRevived=P,p.isWhitespaceOrEmpty=ft,p.mergeClientRects=gt,p.paint=vt,p.parseW3CTextAnnotation=Lt,p.programmaticallyFocusable=ct,p.rangeContains=pt,p.rangeToSelector=mt,p.reviveAnnotation=J,p.reviveSelector=et,p.reviveTarget=Y,p.scrollIntoView=Et,p.serializeW3CTextAnnotation=xt,p.splitAnnotatableRanges=lt,p.toDomRectList=Vt,p.toParentBounds=bt,p.toViewportBounds=Yt,p.trimRangeToContainer=yt,p.whitespaceOrEmptyRegex=ut,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(N,Se){typeof exports=="object"&&typeof module<"u"?Se(exports):typeof define=="function"&&define.amd?define(["exports"],Se):(N=typeof globalThis<"u"?globalThis:N||self,Se(N.RecogitoJS={}))})(this,(function(N){"use strict";const Se="not-annotatable",xe=`.${Se}`,Oe=(e,t)=>{var i;return e.contains(t)?!!(t instanceof HTMLElement?t.closest(xe):(i=t.parentElement)==null?void 0:i.closest(xe)):!0},pn=(e,t)=>{const n=t.commonAncestorContainer;return!Oe(e,n)},mn=e=>e.addEventListener("click",t=>{!t.target.closest(xe)&&!t.target.closest("a")&&t.preventDefault()});var Xi="2.0.5",_t=500,bn="user-agent",Le="",wn="?",ht="function",we="undefined",ke="object",Nt="string",Z="browser",fe="cpu",le="device",re="engine",ne="os",Me="result",v="name",m="type",A="vendor",S="version",ee="architecture",We="major",y="model",je="console",U="mobile",K="tablet",j="smarttv",ce="wearable",gt="xr",ze="embedded",Ie="inapp",Bt="brands",Ce="formFactors",Ut="fullVersionList",_e="platform",Dt="platformVersion",pt="bitness",ye="sec-ch-ua",Yi=ye+"-full-version-list",Ki=ye+"-arch",Fi=ye+"-"+pt,Wi=ye+"-form-factors",ji=ye+"-"+U,zi=ye+"-"+y,yn=ye+"-"+_e,$i=yn+"-version",vn=[Bt,Ut,U,y,_e,Dt,ee,Ce,pt],mt="Amazon",Ne="Apple",An="ASUS",En="BlackBerry",Re="Google",Sn="Huawei",Ht="Lenovo",xn="Honor",bt="LG",Pt="Microsoft",Vt="Motorola",Xt="Nvidia",On="OnePlus",Yt="OPPO",$e="Samsung",Cn="Sharp",qe="Sony",Kt="Xiaomi",Ft="Zebra",Rn="Chrome",Tn="Chromium",ve="Chromecast",wt="Edge",Ge="Firefox",Je="Opera",Wt="Facebook",Ln="Sogou",Be="Mobile ",Qe=" Browser",jt="Windows",qi=typeof window!==we,te=qi&&window.navigator?window.navigator:void 0,Ae=te&&te.userAgentData?te.userAgentData:void 0,Gi=function(e,t){var n={},i=t;if(!vt(t)){i={};for(var o in t)for(var r in t[o])i[r]=t[o][r].concat(i[r]?i[r]:[])}for(var s in e)n[s]=i[s]&&i[s].length%2===0?i[s].concat(e[s]):e[s];return n},yt=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},zt=function(e,t){if(typeof e===ke&&e.length>0){for(var n in e)if(Ee(t)==Ee(e[n]))return!0;return!1}return Ue(e)?Ee(t)==Ee(e):!1},vt=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?vt(e[n]):!1)},Ue=function(e){return typeof e===Nt},$t=function(e){if(e){for(var t=[],n=De(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var o=At(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=At(n[i]);return t}},Ee=function(e){return Ue(e)?e.toLowerCase():e},qt=function(e){return Ue(e)?De(/[^\d\.]/g,e).split(".")[0]:void 0},he=function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n==ke&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},De=function(e,t){return Ue(t)?t.replace(e,Le):t},Ze=function(e){return De(/\\?\"/g,e)},At=function(e,t){if(Ue(e))return e=De(/^\s\s*/,e),typeof t===we?e:e.substring(0,_t)},Gt=function(e,t){if(!(!e||!t))for(var n=0,i,o,r,s,a,l;n<t.length&&!a;){var c=t[n],u=t[n+1];for(i=o=0;i<c.length&&!a&&c[i];)if(a=c[i++].exec(e),a)for(r=0;r<u.length;r++)l=a[++o],s=u[r],typeof s===ke&&s.length>0?s.length===2?typeof s[1]==ht?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===ht&&!(s[1].exec&&s[1].test)?s.length>3?this[s[0]]=l?s[1].apply(this,s.slice(2)):void 0:this[s[0]]=l?s[1].call(this,l,s[2]):void 0:s.length==3?this[s[0]]=l?l.replace(s[1],s[2]):void 0:s.length==4?this[s[0]]=l?s[3].call(this,l.replace(s[1],s[2])):void 0:s.length>4&&(this[s[0]]=l?s[3].apply(this,[l.replace(s[1],s[2])].concat(s.slice(4))):void 0)):this[s]=l||void 0;n+=2}},de=function(e,t){for(var n in t)if(typeof t[n]===ke&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(zt(t[n][i],e))return n===wn?void 0:n}else if(zt(t[n],e))return n===wn?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},kn={ME:"4.90","NT 3.51":"3.51","NT 4.0":"4.0",2e3:["5.0","5.01"],XP:["5.1","5.2"],Vista:"6.0",7:"6.1",8:"6.2","8.1":"6.3",10:["6.4","10.0"],NT:""},Mn={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},Ji={Chrome:"Google Chrome",Edge:"Microsoft Edge","Edge WebView2":"Microsoft Edge WebView2","Chrome WebView":"Android WebView","Chrome Headless":"HeadlessChrome","Huawei Browser":"HuaweiBrowser","MIUI Browser":"Miui Browser","Opera Mobi":"OperaMobile",Yandex:"YaBrowser"},In={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[S,[v,Be+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[S,[v,wt+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[S,[v,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[v,S],[/opios[\/ ]+([\w\.]+)/i],[S,[v,Je+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[S,[v,Je+" GX"]],[/\bopr\/([\w\.]+)/i],[S,[v,Je]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[S,[v,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[S,[v,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon|otter|dooble|(?:lg |qute)browser)\/([-\w\.]+)/i,/(heytap|ovi|115|surf)browser\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[v,S],[/quark(?:pc)?\/([-\w\.]+)/i],[S,[v,"Quark"]],[/\bddg\/([\w\.]+)/i],[S,[v,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[S,[v,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[S,[v,"WeChat"]],[/konqueror\/([\w\.]+)/i],[S,[v,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[S,[v,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[S,[v,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[S,[v,"Smart "+Ht+Qe]],[/(avast|avg)\/([\w\.]+)/i],[[v,/(.+)/,"$1 Secure"+Qe],S],[/\bfocus\/([\w\.]+)/i],[S,[v,Ge+" Focus"]],[/\bopt\/([\w\.]+)/i],[S,[v,Je+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[S,[v,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[S,[v,"Dolphin"]],[/coast\/([\w\.]+)/i],[S,[v,Je+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[S,[v,"MIUI"+Qe]],[/fxios\/([\w\.-]+)/i],[S,[v,Be+Ge]],[/\bqihoobrowser\/?([\w\.]*)/i],[S,[v,"360"]],[/\b(qq)\/([\w\.]+)/i],[[v,/(.+)/,"$1Browser"],S],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[v,/(.+)/,"$1"+Qe],S],[/samsungbrowser\/([\w\.]+)/i],[S,[v,$e+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[S,[v,Ln+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[v,Ln+" Mobile"],S],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[v,S],[/(lbbrowser|rekonq)/i],[v],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[S,v],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[v,Wt],S,[m,Ie]],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/(daum)apps[\/ ]([\w\.]+)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[v,S,[m,Ie]],[/\bgsa\/([\w\.]+) .*safari\//i],[S,[v,"GSA"],[m,Ie]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[S,[v,"TikTok"],[m,Ie]],[/\[(linkedin)app\]/i],[v,[m,Ie]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[v,/(.+)/,"Zalo"],S,[m,Ie]],[/(chromium)[\/ ]([-\w\.]+)/i],[v,S],[/headlesschrome(?:\/([\w\.]+)| )/i],[S,[v,Rn+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[S,[v,wt+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[v,Rn+" WebView"],S],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[S,[v,"Android"+Qe]],[/chrome\/([\w\.]+) mobile/i],[S,[v,Be+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[v,S],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[S,[v,Be+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[v,Be+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[S,v],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[v,[S,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[v,S],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[v,Be+Ge],S],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[v,"Netscape"],S],[/(wolvic|librewolf)\/([\w\.]+)/i],[v,S],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[S,[v,Ge+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[v,[S,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[v,[S,/[^\d\.]+./,Le]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[ee,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[ee,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[ee,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[ee,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[ee,"arm"]],[/ sun4\w[;\)]/i],[[ee,"sparc"]],[/\b(avr32|ia64(?=;)|68k(?=\))|\barm(?=v([1-7]|[5-7]1)l?|;|eabi)|(irix|mips|sparc)(64)?\b|pa-risc)/i,/((ppc|powerpc)(64)?)( mac|;|\))/i,/(?:osf1|[freopnt]{3,4}bsd) (alpha)/i],[[ee,/ower/,Le,Ee]],[/winnt.+\[axp/i],[[ee,"alpha"]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[y,[A,$e],[m,K]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr]|browser)[-\w]+)/i,/sec-(sgh\w+)/i],[y,[A,$e],[m,U]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[y,[A,Ne],[m,U]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[y,[A,Ne],[m,K]],[/(macintosh);/i],[y,[A,Ne]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[y,[A,Cn],[m,U]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[y,[A,xn],[m,K]],[/honor([-\w ]+)[;\)]/i],[y,[A,xn],[m,U]],[/\b((?:ag[rs][2356]?k?|bah[234]?|bg[2o]|bt[kv]|cmr|cpn|db[ry]2?|jdn2|got|kob2?k?|mon|pce|scm|sht?|[tw]gr|vrd)-[ad]?[lw][0125][09]b?|605hw|bg2-u03|(?:gem|fdr|m2|ple|t1)-[7a]0[1-4][lu]|t1-a2[13][lw]|mediapad[\w\. ]*(?= bui|\)))\b(?!.+d\/s)/i],[y,[A,Sn],[m,K]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[y,[A,Sn],[m,U]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[y,/_/g," "],[A,Kt],[m,K]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[y,/_/g," "],[A,Kt],[m,U]],[/droid.+; (cph2[3-6]\d[13579]|((gm|hd)19|(ac|be|in|kb)20|(d[en]|eb|le|mt)21|ne22)[0-2]\d|p[g-k]\w[1m]10)\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[y,[A,On],[m,U]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[y,[A,Yt],[m,U]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[y,[A,de,{OnePlus:["203","304","403","404","413","415"],"*":Yt}],[m,K]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[y,[A,"BLU"],[m,U]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[y,[A,"Vivo"],[m,U]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[y,[A,"Realme"],[m,U]],[/(ideatab[-\w ]+|602lv|d-42a|a101lv|a2109a|a3500-hv|s[56]000|pb-6505[my]|tb-?x?\d{3,4}(?:f[cu]|xu|[av])|yt\d?-[jx]?\d+[lfmx])( bui|;|\)|\/)/i,/lenovo ?(b[68]0[08]0-?[hf]?|tab(?:[\w- ]+?)|tb[\w-]{6,7})( bui|;|\)|\/)/i],[y,[A,Ht],[m,K]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[y,[A,Ht],[m,U]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ]([\w\s]+)(\)| bui)/i,/((?:moto(?! 360)[-\w\(\) ]+|xt\d{3,4}[cgkosw\+]?[-\d]*|nexus 6)(?= bui|\)))/i],[y,[A,Vt],[m,U]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[y,[A,Vt],[m,K]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[y,[A,bt],[m,K]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[y,[A,bt],[m,U]],[/(nokia) (t[12][01])/i],[A,y,[m,K]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[y,/_/g," "],[m,U],[A,"Nokia"]],[/(pixel (c|tablet))\b/i],[y,[A,Re],[m,K]],[/droid.+;(?: google)? (g(01[13]a|020[aem]|025[jn]|1b60|1f8f|2ybb|4s1m|576d|5nz6|8hhn|8vou|a02099|c15s|d1yq|e2ae|ec77|gh2x|kv4x|p4bc|pj41|r83y|tt9q|ur25|wvk6)|pixel[\d ]*a?( pro)?( xl)?( fold)?( \(5g\))?)( bui|\))/i],[y,[A,Re],[m,U]],[/(google) (pixelbook( go)?)/i],[A,y],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-\w\w\d\d)(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[y,[A,qe],[m,U]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[y,"Xperia Tablet"],[A,qe],[m,K]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[y,[A,mt],[m,K]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[y,/(.+)/g,"Fire Phone $1"],[A,mt],[m,U]],[/(playbook);[-\w\),; ]+(rim)/i],[y,A,[m,K]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[y,[A,En],[m,U]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[y,[A,An],[m,K]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[y,[A,An],[m,U]],[/(nexus 9)/i],[y,[A,"HTC"],[m,K]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[A,[y,/_/g," "],[m,U]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[y,[A,"TCL"],[m,K]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[y,[A,"TCL"],[m,U]],[/(itel) ((\w+))/i],[[A,Ee],y,[m,de,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[y,[A,"Acer"],[m,K]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[y,[A,"Meizu"],[m,U]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[y,[A,"Ulefone"],[m,U]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[y,[A,"Energizer"],[m,U]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[y,[A,"Cat"],[m,U]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[y,[A,"Smartfren"],[m,U]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[y,[A,"Nothing"],[m,U]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[y,[A,"Archos"],[m,K]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[y,[A,"Archos"],[m,U]],[/; (n159v)/i],[y,[A,"HMD"],[m,U]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[A,y,[m,K]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|infinix|lava|oneplus|tcl)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i,/droid[^;]+; (philips)[_ ]([sv-x][\d]{3,4}[xz]?)/i],[A,y,[m,U]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[A,y,[m,K]],[/(surface duo)/i],[y,[A,Pt],[m,K]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[y,[A,"Fairphone"],[m,U]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[y,[A,Xt],[m,K]],[/(sprint) (\w+)/i],[A,y,[m,U]],[/(kin\.[onetw]{3})/i],[[y,/\./g," "],[A,Pt],[m,U]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[y,[A,Ft],[m,K]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[y,[A,Ft],[m,U]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[A,[m,j]],[/hbbtv.+maple;(\d+)/i],[[y,/^/,"SmartTV"],[A,$e],[m,j]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[A,y,[m,j]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[A,bt],[m,j]],[/(apple) ?tv/i],[A,[y,Ne+" TV"],[m,j]],[/crkey.*devicetype\/chromecast/i],[[y,ve+" Third Generation"],[A,Re],[m,j]],[/crkey.*devicetype\/([^/]*)/i],[[y,/^/,"Chromecast "],[A,Re],[m,j]],[/fuchsia.*crkey/i],[[y,ve+" Nest Hub"],[A,Re],[m,j]],[/crkey/i],[[y,ve],[A,Re],[m,j]],[/(portaltv)/i],[y,[A,Wt],[m,j]],[/droid.+aft(\w+)( bui|\))/i],[y,[A,mt],[m,j]],[/(shield \w+ tv)/i],[y,[A,Xt],[m,j]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[y,[A,Cn],[m,j]],[/(bravia[\w ]+)( bui|\))/i],[y,[A,qe],[m,j]],[/(mi(tv|box)-?\w+) bui/i],[y,[A,Kt],[m,j]],[/Hbbtv.*(technisat) (.*);/i],[A,y,[m,j]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[A,/.+\/(\w+)/,"$1",de,{LG:"lge"}],[y,At],[m,j]],[/(playstation \w+)/i],[y,[A,qe],[m,je]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[y,[A,Pt],[m,je]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[A,y,[m,je]],[/droid.+; (shield)( bui|\))/i],[y,[A,Xt],[m,je]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[y,[A,$e],[m,ce]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[A,y,[m,ce]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[y,[A,Yt],[m,ce]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[y,[A,Ne],[m,ce]],[/(opwwe\d{3})/i],[y,[A,On],[m,ce]],[/(moto 360)/i],[y,[A,Vt],[m,ce]],[/(smartwatch 3)/i],[y,[A,qe],[m,ce]],[/(g watch r)/i],[y,[A,bt],[m,ce]],[/droid.+; (wt63?0{2,3})\)/i],[y,[A,Ft],[m,ce]],[/droid.+; (glass) \d/i],[y,[A,Re],[m,gt]],[/(pico) ([\w ]+) os\d/i],[A,y,[m,gt]],[/(quest( \d| pro)?s?).+vr/i],[y,[A,Wt],[m,gt]],[/mobile vr; rv.+firefox/i],[[m,gt]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[A,[m,ze]],[/(aeobc)\b/i],[y,[A,mt],[m,ze]],[/(homepod).+mac os/i],[y,[A,Ne],[m,ze]],[/windows iot/i],[[m,ze]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[y,[m,j]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[m,j]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i],[y,[m,de,{mobile:"Mobile",xr:"VR","*":K}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[m,K]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[m,U]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[y,[A,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[S,[v,wt+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[v,S],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[S,[v,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[v,S],[/ladybird\//i],[[v,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[S,v]],os:[[/(windows nt) (6\.[23]); arm/i],[[v,/N/,"R"],[S,de,kn]],[/(windows (?:phone|mobile|iot))(?: os)?[\/ ]?([\d\.]*( se)?)/i,/(windows)[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i],[v,S],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[S,/(;|\))/g,"",de,kn],[v,jt]],[/(windows ce)\/?([\d\.]*)/i],[v,S],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[S,/_/g,"."],[v,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[v,"macOS"],[S,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[S,[v,ve+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[S,[v,ve+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[S,[v,ve+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[S,[v,ve+" Linux"]],[/crkey\/([\d\.]+)/i],[S,[v,ve]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[S,v],[/(ubuntu) ([\w\.]+) like android/i],[[v,/(.+)/,"$1 Touch"],S],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[v,S],[/\(bb(10);/i],[S,[v,En]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[S,[v,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[S,[v,Ge+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[S,[v,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[S,de,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[v,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[S,[v,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[v,"Chrome OS"],S],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/linux.+(mint)[\/\(\) ]?([\w\.]*)/i,/(mageia|vectorlinux|fuchsia|arcaos|arch(?= ?linux))[;l ]([\d\.]*)/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire|knoppix)(?: gnu[\/ ]linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/\b(aix)[; ]([1-9\.]{0,4})/i,/(hurd|linux|morphos)(?: (?:arm|x86|ppc)\w*| ?)([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) ?(r\d)?/i],[v,S],[/(sunos) ?([\d\.]*)/i],[[v,"Solaris"],S],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[v,S]]},Et=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return he.call(e.init,[[Z,[v,S,We,m]],[fe,[ee]],[le,[m,y,A]],[re,[v,S]],[ne,[v,S]]]),he.call(e.isIgnore,[[Z,[S,We]],[re,[S]],[ne,[S]]]),he.call(e.isIgnoreRgx,[[Z,/ ?browser$/i],[ne,/ ?os$/i]]),he.call(e.toString,[[Z,[v,S]],[fe,[ee]],[le,[A,y]],[re,[v,S]],[ne,[v,S]]]),e})(),Qi=function(e,t){var n=Et.init[t],i=Et.isIgnore[t]||0,o=Et.isIgnoreRgx[t]||0,r=Et.toString[t]||0;function s(){he.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Ae?Ae.getHighEntropyValues(vn).then(function(a){return e.setCH(new _n(a,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Me&&(s.prototype.is=function(a){var l=!1;for(var c in this)if(this.hasOwnProperty(c)&&!zt(i,c)&&Ee(o?De(o,this[c]):this[c])==Ee(o?De(o,a):a)){if(l=!0,a!=we)break}else if(a==we&&l){l=!l;break}return l},s.prototype.toString=function(){var a=Le;for(var l in r)typeof this[r[l]]!==we&&(a+=(a?" ":Le)+this[r[l]]);return a||we}),Ae||(s.prototype.then=function(a){var l=this,c=function(){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d])};c.prototype={is:s.prototype.is,toString:s.prototype.toString};var u=new c;return a(u),u}),new s};function _n(e,t){if(e=e||{},he.call(this,vn),t)he.call(this,[[Bt,$t(e[ye])],[Ut,$t(e[Yi])],[U,/\?1/.test(e[ji])],[y,Ze(e[zi])],[_e,Ze(e[yn])],[Dt,Ze(e[$i])],[ee,Ze(e[Ki])],[Ce,$t(e[Wi])],[pt,Ze(e[Fi])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==we&&(this[n]=e[n])}function Nn(e,t,n,i){return this.get=function(o){return o?this.data.hasOwnProperty(o)?this.data[o]:void 0:this.data},this.set=function(o,r){return this.data[o]=r,this},this.setCH=function(o){return this.uaCH=o,this},this.detectFeature=function(){if(te&&te.userAgent==this.ua)switch(this.itemType){case Z:te.brave&&typeof te.brave.isBrave==ht&&this.set(v,"Brave");break;case le:!this.get(m)&&Ae&&Ae[U]&&this.set(m,U),this.get(y)=="Macintosh"&&te&&typeof te.standalone!==we&&te.maxTouchPoints&&te.maxTouchPoints>2&&this.set(y,"iPad").set(m,K);break;case ne:!this.get(v)&&Ae&&Ae[_e]&&this.set(v,Ae[_e]);break;case Me:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(Z,r(Z)).set(fe,r(fe)).set(le,r(le)).set(re,r(re)).set(ne,r(ne))}return this},this.parseUA=function(){return this.itemType!=Me&&Gt.call(this.data,this.ua,this.rgxMap),this.itemType==Z&&this.set(We,qt(this.get(S))),this},this.parseCH=function(){var o=this.uaCH,r=this.rgxMap;switch(this.itemType){case Z:case re:var s=o[Ut]||o[Bt],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],u=s[l].version;this.itemType==Z&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=Tn||a==wt&&/WebView2/.test(c))&&(c=de(c,Ji),a=this.get(v),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(v,c).set(S,u).set(We,qt(u)),a=c),this.itemType==re&&c==Tn&&this.set(S,u)}break;case fe:var d=o[ee];d&&(d&&o[pt]=="64"&&(d+="64"),Gt.call(this.data,d+";",r));break;case le:if(o[U]&&this.set(m,U),o[y]&&(this.set(y,o[y]),!this.get(m)||!this.get(A))){var E={};Gt.call(E,"droid 9; "+o[y]+")",r),!this.get(m)&&E.type&&this.set(m,E.type),!this.get(A)&&E.vendor&&this.set(A,E.vendor)}if(o[Ce]){var p;if(typeof o[Ce]!="string")for(var C=0;!p&&C<o[Ce].length;)p=de(o[Ce][C++],Mn);else p=de(o[Ce],Mn);this.set(m,p)}break;case ne:var f=o[_e];if(f){var R=o[Dt];f==jt&&(R=parseInt(qt(R),10)>=13?"11":"10"),this.set(v,f).set(S,R)}this.get(v)==jt&&o[y]=="Xbox"&&this.set(v,"Xbox").set(S,void 0);break;case Me:var b=this.data,h=function(T){return b[T].getItem().setCH(o).parseCH().get()};this.set(Z,h(Z)).set(fe,h(fe)).set(le,h(le)).set(re,h(re)).set(ne,h(ne))}return this},he.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",Qi(this,e)]]),this}function ge(e,t,n){if(typeof e===ke?(vt(e,!0)?(typeof t===ke&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===Nt&&!vt(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===ht){var i={};n.forEach(function(u,d){i[String(d).toLowerCase()]=u}),n=i}else{var o={};for(var r in n)n.hasOwnProperty(r)&&(o[String(r).toLowerCase()]=n[r]);n=o}if(!(this instanceof ge))return new ge(e,t,n).getResult();var s=typeof e===Nt?e:n&&n[bn]?n[bn]:te&&te.userAgent?te.userAgent:Le,a=new _n(n,!0),l=t?Gi(In,t):In,c=function(u){return u==Me?function(){return new Nn(u,s,l,a).set("ua",s).set(Z,this.getBrowser()).set(fe,this.getCPU()).set(le,this.getDevice()).set(re,this.getEngine()).set(ne,this.getOS()).get()}:function(){return new Nn(u,s,l[u],a).parseUA().get()}};return he.call(this,[["getBrowser",c(Z)],["getCPU",c(fe)],["getDevice",c(le)],["getEngine",c(re)],["getOS",c(ne)],["getResult",c(Me)],["getUA",function(){return s}],["setUA",function(u){return Ue(u)&&(s=u.length>_t?At(u,_t):u),this}]]).setUA(s),this}ge.VERSION=Xi,ge.BROWSER=yt([v,S,We,m]),ge.CPU=yt([ee]),ge.DEVICE=yt([y,A,m,je,U,j,K,ce,ze]),ge.ENGINE=ge.OS=yt([v,S]);const Zi=Object.freeze({AIX:"AIX",AMIGA_OS:"Amiga OS",ANDROID:"Android",ANDROID_X86:"Android-x86",ARCAOS:"ArcaOS",ARCH:"Arch",BADA:"Bada",BEOS:"BeOS",BLACKBERRY:"BlackBerry",CENTOS:"CentOS",CHROME_OS:"Chrome OS",CHROMECAST:"Chromecast",CHROMECAST_ANDROID:"Chromecast Android",CHROMECAST_FUCHSIA:"Chromecast Fuchsia",CHROMECAST_LINUX:"Chromecast Linux",CHROMECAST_SMARTSPEAKER:"Chromecast SmartSpeaker",CONTIKI:"Contiki",DEBIAN:"Debian",DEEPIN:"Deepin",DRAGONFLY:"DragonFly",ELEMENTARY_OS:"elementary OS",FEDORA:"Fedora",FIREFOX_OS:"Firefox OS",FREEBSD:"FreeBSD",FUCHSIA:"Fuchsia",GENTOO:"Gentoo",GHOSTBSD:"GhostBSD",GNU:"GNU",HAIKU:"Haiku",HARMONYOS:"HarmonyOS",HP_UX:"HP-UX",HURD:"Hurd",IOS:"iOS",JOLI:"Joli",KAIOS:"KaiOS",KNOPPIX:"Knoppix",KUBUNTU:"Kubuntu",LINPUS:"Linpus",LINSPIRE:"Linspire",LINUX:"Linux",MACOS:"macOS",MAEMO:"Maemo",MAGEIA:"Mageia",MANDRIVA:"Mandriva",MANJARO:"Manjaro",MEEGO:"MeeGo",MINIX:"Minix",MINT:"Mint",MORPH_OS:"Morph OS",NETBSD:"NetBSD",NETRANGE:"NetRange",NETTV:"NetTV",NINTENDO:"Nintendo",OPENHARMONY:"OpenHarmony",OPENBSD:"OpenBSD",OPENVMS:"OpenVMS",OS2:"OS/2",PALM:"Palm",PC_BSD:"PC-BSD",PCLINUXOS:"PCLinuxOS",PICO:"Pico",PLAN9:"Plan9",PLAYSTATION:"PlayStation",QNX:"QNX",RASPBIAN:"Raspbian",REDHAT:"RedHat",RIM_TABLET_OS:"RIM Tablet OS",RISC_OS:"RISC OS",SABAYON:"Sabayon",SAILFISH:"Sailfish",SERENITYOS:"SerenityOS",SERIES40:"Series40",SLACKWARE:"Slackware",SOLARIS:"Solaris",SUSE:"SUSE",SYMBIAN:"Symbian",TIZEN:"Tizen",UBUNTU:"Ubuntu",UBUNTU_TOUCH:"Ubuntu Touch",UNIX:"Unix",VECTORLINUX:"VectorLinux",WATCHOS:"watchOS",WEBOS:"WebOS",WINDOWS:"Windows",WINDOWS_CE:"Windows CE",WINDOWS_IOT:"Windows IoT",WINDOWS_MOBILE:"Windows Mobile",WINDOWS_PHONE:"Windows Phone",WINDOWS_RT:"Windows RT",XBOX:"Xbox",XUBUNTU:"Xubuntu",ZENWALK:"Zenwalk"}),Bn=ge().os.is(Zi.MACOS),Un=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Dn=e=>{const t=[],n=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT);let i;for(;i=n.nextNode();)e.intersectsNode(i)&&t.push(i);if(t.length<2)return Array.from(e.getClientRects());{const o=t[0],r=t[t.length-1],s=document.createRange();s.selectNode(o),e.startContainer.nodeType===Node.TEXT_NODE?s.setStart(o,e.startOffset):s.setStartAfter(e.startContainer);const a=document.createRange();a.selectNode(r),e.endContainer.nodeType===Node.TEXT_NODE?a.setEnd(r,e.endOffset):a.setEndBefore(e.endContainer);const l=c=>{const u=document.createRange();return u.selectNode(c),Array.from(u.getClientRects())};return[...Array.from(s.getClientRects()),...t.slice(1,-1).flatMap(l),...Array.from(a.getClientRects())]}},eo=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,i=>i instanceof HTMLElement&&i.classList.contains(Se)&&!i.parentElement.closest(xe)&&e.intersectsNode(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Hn=(e,t)=>{if(!pn(e,t))return[];const n=[];let i=null;for(const o of eo(t)){let r;i?(r=document.createRange(),r.setStartAfter(i),r.setEndBefore(o)):(r=t.cloneRange(),r.setEndBefore(o)),r.collapsed||n.push(r),i=o}if(i){const o=t.cloneRange();o.setStartAfter(i),o.collapsed||n.push(o)}return n.length>0?n:[t]},St=e=>{const t=e.cloneContents();return t.querySelectorAll(xe).forEach(n=>n.remove()),t},Pn=(e,t,n=10,i)=>{const o=i?e.startContainer.parentElement.closest(i):t,r=document.createRange();r.setStart(o,0),r.setEnd(e.startContainer,e.startOffset);const s=St(r).textContent,a=document.createRange();a.setStart(e.endContainer,e.endOffset),o===document.body?a.setEnd(o,o.childNodes.length):a.setEndAfter(o);const l=St(a).textContent;return{prefix:s.substring(s.length-n),suffix:l.substring(0,n)}},ue=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),Vn=/^\s*$/,Xn=e=>Vn.test(e.toString()),to=(e,t,n,i)=>{const o=a=>Math.round(a*10)/10,r={top:o(e.top),bottom:o(e.bottom),left:o(e.left),right:o(e.right)},s={top:o(t.top),bottom:o(t.bottom),left:o(t.left),right:o(t.right)};if(Math.abs(r.top-s.top)<i&&Math.abs(r.bottom-s.bottom)<i){if(Math.abs(r.left-s.right)<n||Math.abs(r.right-s.left)<n)return"inline-adjacent";if(r.left>=s.left&&r.right<=s.right)return"inline-is-contained";if(r.left<=s.left&&r.right>=s.right)return"inline-contains"}else if(r.top<=s.top&&r.bottom>=s.bottom){if(r.left<=s.left&&r.right>=s.right)return"block-contains"}else if(r.top>=s.top&&r.bottom<=s.bottom&&r.left>=s.left&&r.right<=s.right)return"block-is-contained"},no=(e,t)=>{const n=Math.min(e.left,t.left),i=Math.max(e.right,t.right),o=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,o,i-n,r-o)},Yn=(e,t=.5,n=.5)=>e.reduce((i,o)=>{if(o.width===0||o.height===0)return i;let r=[...i],s=!1;for(const a of i){const l=to(o,a,t,n);if(l==="inline-adjacent"){r=r.map(c=>c===a?no(o,a):c),s=!0;break}else if(l==="inline-contains"){r=r.map(c=>c===a?o:c),s=!0;break}else if(l==="inline-is-contained"){s=!0;break}else if(l==="block-contains"||l==="block-is-contained"){o.width<a.width&&(r=r.map(c=>c===a?o:c)),o.width===a.width&&o.height<a.width&&(r=r.map(c=>c===a?o:c)),s=!0;break}}return s?r:[...r,o]},[]),io=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Kn=(e,t,n)=>{const i=document.createRange(),o=n?e.startContainer.parentElement.closest(n):t;i.setStart(o,0),i.setEnd(e.startContainer,e.startOffset);const r=St(i).textContent,s=e.toString(),a=r.length||0,l=a+s.length;return n?{quote:s,start:a,end:l,range:e,offsetReference:o}:{quote:s,start:a,end:l,range:e}},Jt=(e,t)=>{var u,d;const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,E=>{var p;return(p=E.parentElement)!=null&&p.closest(xe)?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT});let s=0;const a=document.createRange();let l=r.nextNode();l===null&&console.error("Could not revive annotation target. Content missing.");let c=!o;for(;l!==null;){if(c||(c=typeof(o==null?void 0:o.contains)=="function"?o.contains(l):!1),c){const E=((u=l.textContent)==null?void 0:u.length)||0;if(s+E>n){a.setStart(l,n-s);break}s+=E}l=r.nextNode()}for(;l!==null;){const E=((d=l.textContent)==null?void 0:d.length)||0;if(s+E>=i){a.setEnd(l,i-s);break}s+=E,l=r.nextNode()}return{...e,range:a}},et=(e,t)=>ue(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Jt(n,t))},xt=(e,t)=>ue(e.target.selector)?e:{...e,target:et(e.target,t)},Fn=(e,t)=>{if(e.isEqualNode(t))return!0;for(let n of e.childNodes)if(Fn(n,t))return!0;return!1},oo=(e,t)=>{const n=e.cloneContents();return Fn(n,t)},Wn=(e,t)=>{const n=e.cloneRange(),i=t.contains(n.startContainer),o=t.contains(n.endContainer);return!i&&!o&&!oo(n,t)?(n.collapse(),n):(i||n.setStart(t,0),o||n.setEnd(t,t.childNodes.length),n)},Ot=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}),tt=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}),jn=(e,t)=>{const{left:n,top:i,right:o,bottom:r}=e;return new DOMRect(n-t.left,i-t.top,o-n,r-i)},ro=(e,t)=>{const{left:n,top:i,right:o,bottom:r}=e;return new DOMRect(n+t.left,i+t.top,o-n,r-i)},zn=e=>{if(!e)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:zn(e.parentElement)},$n=(e,t,n)=>{const i=n.getBoundingClientRect(),o=n.clientHeight,r=n.clientWidth,s=t.selector[0].range.getBoundingClientRect(),{width:a,height:l}=e.getAnnotationBounds(t.annotation),c=s.top-i.top,u=s.left-i.left,d=n.parentElement?n.scrollTop:0,E=n.parentElement?n.scrollLeft:0,p=c+d-(o-l)/2,C=u+E-(r-a)/2;n.scroll({top:p,left:C,behavior:"smooth"})},qn=(e,t)=>(n,i)=>{const o=typeof n=="string"?n:n.id,r=i?typeof i=="string"?document.getElementById(i):i:zn(e);if(!r)return console.warn(`The scroll parent is missing for the annotation: ${o}`,{container:e}),!1;const s=t.getAnnotation(o);if(!s)return console.warn(`The annotation is missing in the store: ${o}`),!1;const{range:a}=s.target.selector[0];if(a&&!a.collapsed)return $n(t,s.target,r),!0;const l=et(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?($n(t,l,r),!0):!1},pe={fill:"rgb(0, 128, 255)",fillOpacity:.18},nt={fill:"rgb(0, 128, 255)",fillOpacity:.45},Gn=(e,t,n,i,o)=>{var s,a;const r=n?typeof n=="function"?n(e.annotation,e.state,o)||((s=e.state)!=null&&s.selected?nt:pe):n:(a=e.state)!=null&&a.selected?nt:pe;return i&&i.paint(e,t)||r};function so(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ct={exports:{}},Jn;function ao(){if(Jn)return Ct.exports;Jn=1;function e(t,n=100,i={}){if(typeof t!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(n<0)throw new RangeError("`wait` must not be negative.");const{immediate:o}=typeof i=="boolean"?{immediate:i}:i;let r,s,a,l,c;function u(){const p=r,C=s;return r=void 0,s=void 0,c=t.apply(p,C),c}function d(){const p=Date.now()-l;p<n&&p>=0?a=setTimeout(d,n-p):(a=void 0,o||(c=u()))}const E=function(...p){if(r&&this!==r&&Object.getPrototypeOf(this)===Object.getPrototypeOf(r))throw new Error("Debounced method called with different contexts of the same prototype.");r=this,s=p,l=Date.now();const C=o&&!a;return a||(a=setTimeout(d,n)),C&&(c=u()),c};return Object.defineProperty(E,"isPending",{get(){return a!==void 0}}),E.clear=()=>{a&&(clearTimeout(a),a=void 0)},E.flush=()=>{a&&E.trigger()},E.trigger=()=>{c=u(),E.clear()},E}return Ct.exports.debounce=e,Ct.exports=e,Ct.exports}var lo=ao();const He=so(lo),co=e=>{const{top:t,left:n}=e.getBoundingClientRect(),{innerWidth:i,innerHeight:o}=window,r=-n,s=-t,a=i-n,l=o-t;return{top:t,left:n,minX:r,minY:s,maxX:a,maxY:l}},uo=e=>{let t=new Set;return i=>{const o=i.map(r=>r.id);(t.size!==o.length||o.some(r=>!t.has(r)))&&e.set(o),t=new Set(o)}},Qt=(e,t,n,i)=>{const{store:o,selection:r,hover:s}=t;let a,l,c;const u=uo(n),d=He(B=>{const{x:P,y:V}=e.getBoundingClientRect(),x=o.getAt(B.clientX-P,B.clientY-V,!1,l);x?s.current!==x.id&&(e.classList.add("hovered"),s.set(x.id)):s.current&&(e.classList.remove("hovered"),s.set(null))},10);e.addEventListener("pointermove",d);const E=He((B=!1)=>requestAnimationFrame(()=>{c&&c.clear();const P=co(e),{minX:V,minY:x,maxX:g,maxY:w}=P,L=l?o.getIntersecting(V,x,g,w).filter(({annotation:H})=>l(H)):o.getIntersecting(V,x,g,w),Y=r.selected.map(({id:H})=>H),D=L.map(({annotation:H,rects:$})=>{const Q=Y.includes(H.id),Ke=H.id===s.current;return{annotation:H,rects:$,state:{selected:Q,hovered:Ke}}});i.redraw(D,P,a,c,B),setTimeout(()=>u(L.map(({annotation:H})=>H)),1)}),10),p=B=>{c=B,E()},C=B=>{a=B,E()},f=B=>{l=B,E(!1)},R=()=>E();o.observe(R);const b=r.subscribe(()=>E()),h=s.subscribe(()=>E()),T=()=>E(!0);document.addEventListener("scroll",T,{capture:!0,passive:!0});const M=He(()=>{o.recalculatePositions(),c==null||c.reset(),E()},10);window.addEventListener("resize",M);const O=new ResizeObserver(M);O.observe(e);const k={attributes:!0,childList:!0,subtree:!0},_=new MutationObserver(He(B=>{B.every(V=>V.target===e||e.contains(V.target))||E(!0)},150));return _.observe(document.body,k),{destroy:()=>{e.removeEventListener("pointermove",d),i.destroy(),o.unobserve(R),b(),h(),document.removeEventListener("scroll",T),M.clear(),window.removeEventListener("resize",M),O.disconnect(),_.disconnect()},redraw:E,setStyle:C,setFilter:f,setPainter:p,setVisible:i.setVisible}},fo=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},ho=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},go=e=>{e.classList.add("r6o-annotatable");const t=fo(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,u)=>requestAnimationFrame(()=>{const{width:d,height:E}=t;n.clearRect(-.5,-.5,d+1,E+1),u&&u.clear();const{top:p,left:C}=l;[...a].sort((R,b)=>{const{annotation:{target:{created:h}}}=R,{annotation:{target:{created:T}}}=b;return h.getTime()-T.getTime()}).forEach(R=>{var M;const b=c?typeof c=="function"?c(R.annotation,R.state):c:(M=R.state)!=null&&M.selected?nt:pe,h=u&&u.paint(R,l)||b,T=R.rects.map(({x:O,y:k,width:_,height:I})=>({x:O+C,y:k+p,width:_,height:I}));if(n.fillStyle=h.fill,n.globalAlpha=h.fillOpacity||1,T.forEach(({x:O,y:k,width:_,height:I})=>n.fillRect(O,k,_,I)),h.underlineColor){n.globalAlpha=1,n.strokeStyle=h.underlineColor,n.lineWidth=h.underlineThickness??1;const O=h.underlineOffset??0;T.forEach(({x:k,y:_,width:I,height:B})=>{n.beginPath(),n.moveTo(k,_+B+O),n.lineTo(k+I,_+B+O),n.stroke()})}})}),o=He(()=>ho(t),10);return window.addEventListener("resize",o),{destroy:()=>{t.remove(),o.clear(),window.removeEventListener("resize",o)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:i}},Qn=(e,t,n)=>Qt(e,t,n,go(e));var po={grad:.9,turn:360,rad:360/(2*Math.PI)},me=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},z=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},ie=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Zn=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ei=function(e){return{r:ie(e.r,0,255),g:ie(e.g,0,255),b:ie(e.b,0,255),a:ie(e.a)}},Zt=function(e){return{r:z(e.r),g:z(e.g),b:z(e.b),a:z(e.a,3)}},mo=/^#([0-9a-f]{3,8})$/i,Rt=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},ti=function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=Math.max(t,n,i),s=r-Math.min(t,n,i),a=s?r===t?(n-i)/s:r===n?2+(i-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:o}},ni=function(e){var t=e.h,n=e.s,i=e.v,o=e.a;t=t/360*6,n/=100,i/=100;var r=Math.floor(t),s=i*(1-n),a=i*(1-(t-r)*n),l=i*(1-(1-t+r)*n),c=r%6;return{r:255*[i,a,s,s,l,i][c],g:255*[l,i,i,a,s,s][c],b:255*[s,s,l,i,i,a][c],a:o}},ii=function(e){return{h:Zn(e.h),s:ie(e.s,0,100),l:ie(e.l,0,100),a:ie(e.a)}},oi=function(e){return{h:z(e.h),s:z(e.s),l:z(e.l),a:z(e.a,3)}},ri=function(e){return ni((n=(t=e).s,{h:t.h,s:(n*=((i=t.l)<50?i:100-i)/100)>0?2*n/(i+n)*100:0,v:i+n,a:t.a}));var t,n,i},it=function(e){return{h:(t=ti(e)).h,s:(o=(200-(n=t.s))*(i=t.v)/100)>0&&o<200?n*i/100/(o<=100?o:200-o)*100:0,l:o/2,a:t.a};var t,n,i,o},bo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,si={string:[[function(e){var t=mo.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?z(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?z(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=yo.exec(e)||vo.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ei({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=bo.exec(e)||wo.exec(e);if(!t)return null;var n,i,o=ii({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*(po[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ri(o)},"hsl"]],object:[[function(e){var t=e.r,n=e.g,i=e.b,o=e.a,r=o===void 0?1:o;return me(t)&&me(n)&&me(i)?ei({r:Number(t),g:Number(n),b:Number(i),a:Number(r)}):null},"rgb"],[function(e){var t=e.h,n=e.s,i=e.l,o=e.a,r=o===void 0?1:o;if(!me(t)||!me(n)||!me(i))return null;var s=ii({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return ri(s)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,o=e.a,r=o===void 0?1:o;if(!me(t)||!me(n)||!me(i))return null;var s=(function(a){return{h:Zn(a.h),s:ie(a.s,0,100),v:ie(a.v,0,100),a:ie(a.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(r)});return ni(s)},"hsv"]]},ai=function(e,t){for(var n=0;n<t.length;n++){var i=t[n][0](e);if(i)return[i,t[n][1]]}return[null,void 0]},Ao=function(e){return typeof e=="string"?ai(e.trim(),si.string):typeof e=="object"&&e!==null?ai(e,si.object):[null,void 0]},en=function(e,t){var n=it(e);return{h:n.h,s:ie(n.s+100*t,0,100),l:n.l,a:n.a}},tn=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},li=function(e,t){var n=it(e);return{h:n.h,s:n.s,l:ie(n.l+100*t,0,100),a:n.a}},ci=(function(){function e(t){this.parsed=Ao(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 z(tn(this.rgba),2)},e.prototype.isDark=function(){return tn(this.rgba)<.5},e.prototype.isLight=function(){return tn(this.rgba)>=.5},e.prototype.toHex=function(){return t=Zt(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?Rt(z(255*r)):"","#"+Rt(n)+Rt(i)+Rt(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return Zt(this.rgba)},e.prototype.toRgbString=function(){return t=Zt(this.rgba),n=t.r,i=t.g,o=t.b,(r=t.a)<1?"rgba("+n+", "+i+", "+o+", "+r+")":"rgb("+n+", "+i+", "+o+")";var t,n,i,o,r},e.prototype.toHsl=function(){return oi(it(this.rgba))},e.prototype.toHslString=function(){return t=oi(it(this.rgba)),n=t.h,i=t.s,o=t.l,(r=t.a)<1?"hsla("+n+", "+i+"%, "+o+"%, "+r+")":"hsl("+n+", "+i+"%, "+o+"%)";var t,n,i,o,r},e.prototype.toHsv=function(){return t=ti(this.rgba),{h:z(t.h),s:z(t.s),v:z(t.v),a:z(t.a,3)};var t},e.prototype.invert=function(){return se({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),se(en(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),se(en(this.rgba,-t))},e.prototype.grayscale=function(){return se(en(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),se(li(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),se(li(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"?se({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):z(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=it(this.rgba);return typeof t=="number"?se({h:t,s:n.s,l:n.l,a:n.a}):z(n.h)},e.prototype.isEqual=function(t){return this.toHex()===se(t).toHex()},e})(),se=function(e){return e instanceof ci?e:new ci(e)};const Eo=e=>[`background-color:${se((e==null?void 0:e.fill)||pe.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?pe.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(";"),di=()=>{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,l)=>{l&&l.clear();const c=new Set(r.map(d=>d.annotation.id));Array.from(t).filter(d=>!c.has(d));const u=r.map(d=>{var C;const E=a?typeof a=="function"?a(d.annotation,d.state):a:(C=d.state)!=null&&C.selected?nt:pe,p=l&&l.paint(d,s)||E;return`::highlight(_${d.annotation.id}) { ${Eo(p)} }`});e.innerHTML=u.join(`
|
|
2
|
+
`),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const E=d.target.selector.map(C=>C.range),p=new Highlight(...E);CSS.highlights.set(`_${d.id}`,p)}),t=c}}},ui=(e,t,n)=>Qt(e,t,n,di());var fi=Object.prototype.hasOwnProperty;function nn(e,t){var n,i;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((i=e.length)===t.length)for(;i--&&nn(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(fi.call(e,n)&&++i&&!fi.call(t,n)||!(n in t)||!nn(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const So=(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,i=r=>r.rects.reduce((s,a)=>s+a.width,0),o=t.filter(({rects:r})=>r.some(s=>n(e,s)));return o.sort((r,s)=>i(s)-i(r)),o.findIndex(r=>r.rects.includes(e))},xo=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,l,c,u)=>{const E=!(nn(n,s)&&u);if(!c&&!E)return;E&&(t.innerHTML=""),[...s].sort((C,f)=>{const{annotation:{target:{created:R}}}=C,{annotation:{target:{created:b}}}=f;return R&&b?R.getTime()-b.getTime():0}).forEach(C=>{C.rects.map(f=>{const R=So(f,s),b=Gn(C,a,l,c,R);if(E){const h=document.createElement("span");h.className="r6o-annotation",h.dataset.annotation=C.annotation.id,h.style.left=`${f.x}px`,h.style.top=`${f.y}px`,h.style.width=`${f.width}px`,h.style.height=`${f.height}px`,h.style.backgroundColor=se((b==null?void 0:b.fill)||pe.fill).alpha((b==null?void 0:b.fillOpacity)===void 0?pe.fillOpacity:b.fillOpacity).toHex(),b.underlineStyle&&(h.style.borderStyle=b.underlineStyle),b.underlineColor&&(h.style.borderColor=b.underlineColor),b.underlineThickness&&(h.style.borderBottomWidth=`${b.underlineThickness}px`),b.underlineOffset&&(h.style.paddingBottom=`${b.underlineOffset}px`),t.appendChild(h)}})}),n=s},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},hi=(e,t,n)=>Qt(e,t,n,xo(e)),q=[];for(let e=0;e<256;++e)q.push((e+256).toString(16).slice(1));function Oo(e,t=0){return(q[e[t+0]]+q[e[t+1]]+q[e[t+2]]+q[e[t+3]]+"-"+q[e[t+4]]+q[e[t+5]]+"-"+q[e[t+6]]+q[e[t+7]]+"-"+q[e[t+8]]+q[e[t+9]]+"-"+q[e[t+10]]+q[e[t+11]]+q[e[t+12]]+q[e[t+13]]+q[e[t+14]]+q[e[t+15]]).toLowerCase()}let on;const Co=new Uint8Array(16);function Ro(){if(!on){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");on=crypto.getRandomValues.bind(crypto)}return on(Co)}const gi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function To(e,t,n){var o;e=e||{};const i=e.random??((o=e.rng)==null?void 0:o.call(e))??Ro();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,Oo(i)}function pi(e,t,n){return gi.randomUUID&&!e?gi.randomUUID():To(e)}var mi=Object.prototype.hasOwnProperty;function Te(e,t){var n,i;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((i=e.length)===t.length)for(;i--&&Te(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(mi.call(e,n)&&++i&&!mi.call(t,n)||!(n in t)||!Te(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}function rn(){}function Lo(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const Pe=[];function sn(e,t=rn){let n;const i=new Set;function o(a){if(Lo(e,a)&&(e=a,n)){const l=!Pe.length;for(const c of i)c[1](),Pe.push(c,e);if(l){for(let c=0;c<Pe.length;c+=2)Pe[c][0](Pe[c+1]);Pe.length=0}}}function r(a){o(a(e))}function s(a,l=rn){const c=[a,l];return i.add(c),i.size===1&&(n=t(o,r)||rn),a(e),()=>{i.delete(c),i.size===0&&n&&(n(),n=null)}}return{set:o,update:r,subscribe:s}}const ko=e=>{const{subscribe:t,set:n}=sn();let i;return t(o=>i=o),e.observe(({changes:o})=>{if(i){(o.deleted||[]).some(s=>s.id===i)&&n(void 0);const r=(o.updated||[]).find(({oldValue:s})=>s.id===i);r&&n(r.newValue.id)}}),{get current(){return i},subscribe:t,set:n}};var bi=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(bi||{});const Tt={selected:[]},Mo=(e,t,n)=>{const{subscribe:i,set:o}=sn(Tt);let r=t,s=Tt;i(f=>s=f);const a=()=>{Te(s,Tt)||o(Tt)},l=()=>{var f;return((f=s.selected)==null?void 0:f.length)===0},c=f=>{if(l())return!1;const R=typeof f=="string"?f:f.id;return s.selected.some(b=>b.id===R)},u=(f,R)=>{let b;if(Array.isArray(f)){if(b=f.map(T=>e.getAnnotation(T)).filter(Boolean),b.length<f.length){console.warn("Invalid selection: "+f.filter(T=>!b.some(M=>M.id===T)));return}}else{const T=e.getAnnotation(f);if(!T){console.warn("Invalid selection: "+f);return}b=[T]}const h=b.reduce((T,M)=>{const O=C(M);return O==="EDIT"?[...T,{id:M.id,editable:!0}]:O==="SELECT"?[...T,{id:M.id}]:T},[]);o({selected:h,event:R})},d=(f,R)=>{const b=Array.isArray(f)?f:[f],h=b.map(T=>e.getAnnotation(T)).filter(T=>!!T);o({selected:h.map(T=>{const M=R===void 0?C(T)==="EDIT":R;return{id:T.id,editable:M}})}),h.length!==b.length&&console.warn("Invalid selection",f)},E=f=>{if(l())return!1;const{selected:R}=s;R.some(({id:b})=>f.includes(b))&&o({selected:R.filter(({id:b})=>!f.includes(b))})},p=f=>{r=f,d(s.selected.map(({id:R})=>R))},C=f=>Io(f,r,n);return e.observe(({changes:f})=>E((f.deleted||[]).map(R=>R.id))),{get event(){return s?s.event:null},get selected(){return s?[...s.selected]:null},get userSelectAction(){return r},clear:a,evalSelectAction:C,isEmpty:l,isSelected:c,setSelected:d,setUserSelectAction:p,subscribe:i,userSelect:u}},Io=(e,t,n)=>{const i=n?n.serialize(e):e;return typeof t=="function"?t(i):t||"EDIT"},G=[];for(let e=0;e<256;++e)G.push((e+256).toString(16).slice(1));function _o(e,t=0){return(G[e[t+0]]+G[e[t+1]]+G[e[t+2]]+G[e[t+3]]+"-"+G[e[t+4]]+G[e[t+5]]+"-"+G[e[t+6]]+G[e[t+7]]+"-"+G[e[t+8]]+G[e[t+9]]+"-"+G[e[t+10]]+G[e[t+11]]+G[e[t+12]]+G[e[t+13]]+G[e[t+14]]+G[e[t+15]]).toLowerCase()}let an;const No=new Uint8Array(16);function Bo(){if(!an){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");an=crypto.getRandomValues.bind(crypto)}return an(No)}const Uo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),wi={randomUUID:Uo};function Do(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??Bo();if(o.length<16)throw new Error("Random bytes length must be >= 16");return o[6]=o[6]&15|64,o[8]=o[8]&63|128,_o(o)}function yi(e,t,n){return wi.randomUUID&&!e?wi.randomUUID():Do(e)}const ln=e=>{const t=n=>{const i={...n};return n.created&&typeof n.created=="string"&&(i.created=new Date(n.created)),n.updated&&typeof n.updated=="string"&&(i.updated=new Date(n.updated)),i};return{...e,bodies:(e.bodies||[]).map(t),target:t(e.target)}},Ho=(e,t,n,i)=>({id:yi(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),Po=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},Vo=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},Xo=(e,t)=>t.bodies.map(n=>{const i=e.bodies.find(o=>o.id===n.id);return{newBody:n,oldBody:i&&!Te(i,n)?i:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:i})=>({oldBody:n,newBody:i})),Yo=(e,t)=>!Te(e.target,t.target),vi=(e,t)=>{const n=Po(e,t),i=Vo(e,t),o=Xo(e,t);return{oldValue:e,newValue:t,bodiesCreated:n.length>0?n:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:o.length>0?o:void 0,targetUpdated:Yo(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var X=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e.SILENT="SILENT",e))(X||{});const Ko=(e,t)=>{var n,i;const{changes:o,origin:r}=t;if(!(e.options.origin?e.options.origin===r:r!=="SILENT"))return!1;if(e.options.ignore){const{ignore:s}=e.options,a=l=>l&&l.length>0;if(!(a(o.created)||a(o.deleted))){const l=(n=o.updated)==null?void 0:n.some(u=>a(u.bodiesCreated)||a(u.bodiesDeleted)||a(u.bodiesUpdated)),c=(i=o.updated)==null?void 0:i.some(u=>u.targetUpdated);if(s==="BODY_ONLY"&&l&&!c||s==="TARGET_ONLY"&&c&&!l)return!1}}if(e.options.annotations){const s=new Set([...(o.created||[]).map(a=>a.id),...(o.deleted||[]).map(a=>a.id),...(o.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},Fo=(e,t)=>{const n=new Set((e.created||[]).map(d=>d.id)),i=new Set((e.updated||[]).map(({newValue:d})=>d.id)),o=new Set((t.created||[]).map(d=>d.id)),r=new Set((t.deleted||[]).map(d=>d.id)),s=new Set((t.updated||[]).map(({oldValue:d})=>d.id)),a=new Set((t.updated||[]).filter(({oldValue:d})=>n.has(d.id)||i.has(d.id)).map(({oldValue:d})=>d.id)),l=[...(e.created||[]).filter(d=>!r.has(d.id)).map(d=>s.has(d.id)?t.updated.find(({oldValue:E})=>E.id===d.id).newValue:d),...t.created||[]],c=[...(e.deleted||[]).filter(d=>!o.has(d.id)),...(t.deleted||[]).filter(d=>!n.has(d.id))],u=[...(e.updated||[]).filter(({newValue:d})=>!r.has(d.id)).map(d=>{const{oldValue:E,newValue:p}=d;if(s.has(p.id)){const C=t.updated.find(f=>f.oldValue.id===p.id).newValue;return vi(E,C)}else return d}),...(t.updated||[]).filter(({oldValue:d})=>!a.has(d.id))];return{created:l,deleted:c,updated:u}},Lt=e=>{const t=e.id===void 0?yi():e.id;return{...e,id:t,bodies:e.bodies===void 0?[]:e.bodies.map(n=>({...n,annotation:t})),target:{...e.target,annotation:t}}},Wo=e=>e.id!==void 0,jo=()=>{const e=new Map,t=new Map,n=[],i=(x,g={})=>{n.push({onChange:x,options:g})},o=x=>{const g=n.findIndex(w=>w.onChange==x);g>-1&&n.splice(g,1)},r=(x,g)=>{const w={origin:x,changes:{created:g.created||[],updated:g.updated||[],deleted:g.deleted||[]},state:[...e.values()]};n.forEach(L=>{Ko(L,w)&&L.onChange(w)})},s=(x,g=X.LOCAL)=>{if(x.id&&e.get(x.id))throw Error(`Cannot add annotation ${x.id} - exists already`);{const w=Lt(x);e.set(w.id,w),w.bodies.forEach(L=>t.set(L.id,w.id)),r(g,{created:[w]})}},a=(x,g)=>{const w=Lt(typeof x=="string"?g:x),L=typeof x=="string"?x:x.id,Y=L&&e.get(L);if(Y){const D=vi(Y,w);return L===w.id?e.set(L,w):(e.delete(L),e.set(w.id,w)),Y.bodies.forEach(H=>t.delete(H.id)),w.bodies.forEach(H=>t.set(H.id,w.id)),D}else console.warn(`Cannot update annotation ${L} - does not exist`)},l=(x,g=X.LOCAL,w=X.LOCAL)=>{const L=Wo(g)?w:g,Y=a(x,g);Y&&r(L,{updated:[Y]})},c=(x,g=X.LOCAL)=>{e.get(x.id)?l(x,g):s(x,g)},u=(x,g=X.LOCAL)=>{const w=x.reduce((L,Y)=>{const D=a(Y);return D?[...L,D]:L},[]);w.length>0&&r(g,{updated:w})},d=(x,g=X.LOCAL)=>{const w=x.map(Lt),{toAdd:L,toUpdate:Y}=w.reduce((H,$)=>e.get($.id)?{...H,toUpdate:[...H.toUpdate,$]}:{...H,toAdd:[...H.toAdd,$]},{toAdd:[],toUpdate:[]}),D=Y.map(H=>a(H,g)).filter(Boolean);L.forEach(H=>{e.set(H.id,H),H.bodies.forEach($=>t.set($.id,H.id))}),r(g,{created:L,updated:D})},E=(x,g=X.LOCAL)=>{const w=e.get(x.annotation);if(w){const L={...w,bodies:[...w.bodies,x]};e.set(w.id,L),t.set(x.id,L.id),r(g,{updated:[{oldValue:w,newValue:L,bodiesCreated:[x]}]})}else console.warn(`Attempt to add body to missing annotation: ${x.annotation}`)},p=()=>[...e.values()],C=(x=X.LOCAL)=>{const g=[...e.values()];e.clear(),t.clear(),r(x,{deleted:g})},f=(x,g=!0,w=X.LOCAL)=>{const L=x.map(Lt);if(g){const Y=[...e.values()];e.clear(),t.clear(),L.forEach(D=>{e.set(D.id,D),D.bodies.forEach(H=>t.set(H.id,D.id))}),r(w,{created:L,deleted:Y})}else{const Y=x.reduce((D,H)=>{const $=H.id&&e.get(H.id);return $?[...D,$]:D},[]);if(Y.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${Y.map(D=>D.id).join(", ")}`);L.forEach(D=>{e.set(D.id,D),D.bodies.forEach(H=>t.set(H.id,D.id))}),r(w,{created:L})}},R=x=>{const g=typeof x=="string"?x:x.id,w=e.get(g);if(w)return e.delete(g),w.bodies.forEach(L=>t.delete(L.id)),w;console.warn(`Attempt to delete missing annotation: ${g}`)},b=(x,g=X.LOCAL)=>{const w=R(x);w&&r(g,{deleted:[w]})},h=(x,g=X.LOCAL)=>{const w=x.reduce((L,Y)=>{const D=R(Y);return D?[...L,D]:L},[]);w.length>0&&r(g,{deleted:w})},T=x=>{const g=e.get(x.annotation);if(g){const w=g.bodies.find(L=>L.id===x.id);if(w){t.delete(w.id);const L={...g,bodies:g.bodies.filter(Y=>Y.id!==x.id)};return e.set(g.id,L),{oldValue:g,newValue:L,bodiesDeleted:[w]}}else console.warn(`Attempt to delete missing body ${x.id} from annotation ${x.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${x.annotation}`)},M=(x,g=X.LOCAL)=>{const w=T(x);w&&r(g,{updated:[w]})},O=(x,g=X.LOCAL)=>{const w=x.map(L=>T(L)).filter(Boolean);w.length>0&&r(g,{updated:w})},k=x=>{const g=e.get(x);return g?{...g}:void 0},_=x=>{const g=t.get(x);if(g){const w=k(g).bodies.find(L=>L.id===x);if(w)return w;console.error(`Store integrity error: body ${x} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${x}`)},I=(x,g)=>{if(x.annotation!==g.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const w=e.get(x.annotation);if(w){const L=w.bodies.find(D=>D.id===x.id),Y={...w,bodies:w.bodies.map(D=>D.id===L.id?g:D)};return e.set(w.id,Y),L.id!==g.id&&(t.delete(L.id),t.set(g.id,Y.id)),{oldValue:w,newValue:Y,bodiesUpdated:[{oldBody:L,newBody:g}]}}else console.warn(`Attempt to add body to missing annotation ${x.annotation}`)},B=(x,g,w=X.LOCAL)=>{const L=I(x,g);L&&r(w,{updated:[L]})},P=(x,g=X.LOCAL)=>{const w=x.map(L=>I({id:L.id,annotation:L.annotation},L)).filter(Boolean);r(g,{updated:w})},V=x=>{const g=e.get(x.annotation);if(g){const w={...g,target:{...g.target,...x}};return e.set(g.id,w),{oldValue:g,newValue:w,targetUpdated:{oldTarget:g.target,newTarget:x}}}else console.warn(`Attempt to update target on missing annotation: ${x.annotation}`)};return{addAnnotation:s,addBody:E,all:p,bulkAddAnnotations:f,bulkDeleteAnnotations:h,bulkDeleteBodies:O,bulkUpdateAnnotations:u,bulkUpdateBodies:P,bulkUpdateTargets:(x,g=X.LOCAL)=>{const w=x.map(L=>V(L)).filter(Boolean);w.length>0&&r(g,{updated:w})},bulkUpsertAnnotations:d,clear:C,deleteAnnotation:b,deleteBody:M,getAnnotation:k,getBody:_,observe:i,unobserve:o,updateAnnotation:l,updateBody:B,updateTarget:(x,g=X.LOCAL)=>{const w=V(x);w&&r(g,{updated:[w]})},upsertAnnotation:c}};let zo=()=>({emit(e,...t){for(let n=this.events[e]||[],i=0,o=n.length;i<o;i++)n[i](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var i;this.events[e]=(i=this.events[e])==null?void 0:i.filter(o=>t!==o)}}});const $o=250,qo=(e,t)=>{const n=zo(),i=[];let o=-1,r=!1,s=0;const a=C=>{if(!r){const{changes:f}=C,R=performance.now();if(R-s>$o)i.splice(o+1),i.push(f),o=i.length-1;else{const b=i.length-1;i[b]=Fo(i[b],f)}s=R}r=!1};e.observe(a,{origin:X.LOCAL});const l=C=>C&&C.length>0&&e.bulkDeleteAnnotations(C),c=C=>C&&C.length>0&&e.bulkAddAnnotations(C,!1),u=C=>C&&C.length>0&&e.bulkUpdateAnnotations(C.map(({oldValue:f})=>f)),d=C=>C&&C.length>0&&e.bulkUpdateAnnotations(C.map(({newValue:f})=>f)),E=C=>C&&C.length>0&&e.bulkAddAnnotations(C,!1),p=C=>C&&C.length>0&&e.bulkDeleteAnnotations(C);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(C,f)=>n.on(C,f),redo:()=>{if(i.length-1>o){r=!0;const{created:C,updated:f,deleted:R}=i[o+1];c(C),d(f),p(R),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:C,updated:f,deleted:R}=i[o];l(C),u(f),E(R),n.emit("undo",i[o]),o-=1}}}},Go=()=>{const{subscribe:e,set:t}=sn([]);return{subscribe:e,set:t}},Jo=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],u;const d=(f,R)=>{l.has(f)?l.get(f).push(R):l.set(f,[R])},E=(f,R)=>{const b=l.get(f);if(b){const h=b.indexOf(R);h!==-1&&b.splice(h,1)}},p=(f,R,b)=>{l.has(f)&&setTimeout(()=>{l.get(f).forEach(h=>{if(n){const T=Array.isArray(R)?R.map(O=>n.serialize(O)):n.serialize(R),M=b?b instanceof PointerEvent?b:n.serialize(b):void 0;h(T,M)}else h(R,b)})},1)};r.subscribe(({selected:f})=>{if(!(c.length===0&&f.length===0)){if(c.length===0&&f.length>0)c=f.map(({id:R})=>s.getAnnotation(R));else if(c.length>0&&f.length===0)c.forEach(R=>{const b=s.getAnnotation(R.id);b&&!Te(b,R)&&p("updateAnnotation",b,R)}),c=[];else{const R=new Set(c.map(h=>h.id)),b=new Set(f.map(({id:h})=>h));c.filter(h=>!b.has(h.id)).forEach(h=>{const T=s.getAnnotation(h.id);T&&!Te(T,h)&&p("updateAnnotation",T,h)}),c=[...c.filter(h=>b.has(h.id)),...f.filter(({id:h})=>!R.has(h)).map(({id:h})=>s.getAnnotation(h))]}p("selectionChanged",c)}}),o.subscribe(f=>{!u&&f?p("mouseEnterAnnotation",s.getAnnotation(f)):u&&!f?p("mouseLeaveAnnotation",s.getAnnotation(u)):u&&f&&(p("mouseLeaveAnnotation",s.getAnnotation(u)),p("mouseEnterAnnotation",s.getAnnotation(f))),u=f}),a==null||a.subscribe(f=>p("viewportIntersect",f.map(R=>s.getAnnotation(R)))),s.observe(f=>{const{created:R,deleted:b}=f.changes;(R||[]).forEach(h=>p("createAnnotation",h)),(b||[]).forEach(h=>p("deleteAnnotation",h)),(f.changes.updated||[]).filter(h=>[...h.bodiesCreated||[],...h.bodiesDeleted||[],...h.bodiesUpdated||[]].length>0).forEach(({oldValue:h,newValue:T})=>{const M=c.find(O=>O.id===h.id)||h;c=c.map(O=>O.id===h.id?T:O),p("updateAnnotation",T,M)})},{origin:X.LOCAL}),s.observe(f=>{if(c){const R=new Set(c.map(h=>h.id)),b=(f.changes.updated||[]).filter(({newValue:h})=>R.has(h.id)).map(({newValue:h})=>h);b.length>0&&(c=c.map(h=>b.find(M=>M.id===h.id)||h))}},{origin:X.REMOTE});const C=f=>R=>{const{updated:b}=R;f?(b||[]).forEach(h=>p("updateAnnotation",h.oldValue,h.newValue)):(b||[]).forEach(h=>p("updateAnnotation",h.newValue,h.oldValue))};return t.on("undo",C(!0)),t.on("redo",C(!1)),{on:d,off:E,emit:p}},Qo=e=>t=>t.reduce((n,i)=>{const{parsed:o,error:r}=e.parse(i);return r?{parsed:n.parsed,failed:[...n.failed,i]}:o?{parsed:[...n.parsed,o],failed:n.failed}:{...n}},{parsed:[],failed:[]}),Zo=(e,t,n)=>{const{store:i,selection:o}=e,r=b=>{if(n){const{parsed:h,error:T}=n.parse(b);h?i.addAnnotation(h,X.REMOTE):console.error(T)}else i.addAnnotation(ln(b),X.REMOTE)},s=()=>o.clear(),a=()=>i.clear(),l=b=>{const h=i.getAnnotation(b);return n&&h?n.serialize(h):h},c=()=>n?i.all().map(n.serialize):i.all(),u=()=>{var b;const h=(((b=o.selected)==null?void 0:b.map(T=>T.id))||[]).map(T=>i.getAnnotation(T)).filter(Boolean);return n?h.map(n.serialize):h},d=(b,h=!0)=>fetch(b).then(T=>T.json()).then(T=>(p(T,h),T)),E=b=>{if(typeof b=="string"){const h=i.getAnnotation(b);if(i.deleteAnnotation(b),h)return n?n.serialize(h):h}else{const h=n?n.parse(b).parsed:b;if(h)return i.deleteAnnotation(h),b}},p=(b,h=!0)=>{if(n){const T=n.parseAll||Qo(n),{parsed:M,failed:O}=T(b);O.length>0&&console.warn(`Discarded ${O.length} invalid annotations`,O),i.bulkAddAnnotations(M,h,X.REMOTE)}else i.bulkAddAnnotations(b.map(ln),h,X.REMOTE)},C=(b,h)=>{b?o.setSelected(b,h):o.clear()},f=b=>{o.setUserSelectAction(b)},R=b=>{if(n){const h=n.parse(b).parsed,T=n.serialize(i.getAnnotation(h.id));return i.updateAnnotation(h),T}else{const h=i.getAnnotation(b.id);return i.updateAnnotation(ln(b)),h}};return{addAnnotation:r,cancelSelected:s,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:c,getHistory:t.getHistory,getSelected:u,loadAnnotations:d,redo:t.redo,removeAnnotation:E,setAnnotations:p,setSelected:C,setUserSelectAction:f,undo:t.undo,updateAnnotation:R}},er="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let tr=e=>crypto.getRandomValues(new Uint8Array(e)),nr=(e,t,n)=>{let i=(2<<Math.log2(e.length-1))-1,o=-~(1.6*i*t/e.length);return(r=t)=>{let s="";for(;;){let a=n(o),l=o|0;for(;l--;)if(s+=e[a[l]&i]||"",s.length>=r)return s}}},ir=(e,t=21)=>nr(e,t|0,tr),or=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=er[n[e]&63];return t};const rr=()=>({isGuest:!0,id:ir("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),sr=e=>{const t=JSON.stringify(e);let n=0;for(let i=0,o=t.length;i<o;i++){let r=t.charCodeAt(i);n=(n<<5)-n+r,n|=0}return`${n}`},Ai=e=>e?typeof e=="object"?{...e}:e:void 0,ar=(e,t)=>(Array.isArray(e)?e:[e]).map(n=>{const{id:i,type:o,purpose:r,value:s,created:a,modified:l,creator:c,...u}=n;return{id:i||`temp-${sr(n)}`,annotation:t,type:o,purpose:r,value:s,creator:Ai(c),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),lr=e=>e.map(t=>{var n;const{annotation:i,created:o,updated:r,...s}=t,a={...s,created:o==null?void 0:o.toISOString(),modified:r==null?void 0:r.toISOString()};return(n=a.id)!=null&&n.startsWith("temp-")&&delete a.id,a});or();const cr=(e,t)=>({parse:n=>Ei(n),serialize:n=>Si(n,e,t)}),dr=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,ur=e=>{const{id:t,creator:n,created:i,modified:o,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:Ai(n),created:i?new Date(i):void 0,updated:o?new Date(o):void 0,annotation:t,selector:[],styleClass:"styleClass"in s[0]?s[0].styleClass:void 0};for(const l of s){const u=(Array.isArray(l.selector)?l.selector:[l.selector]).reduce((d,E)=>{switch(E.type){case"TextQuoteSelector":d.quote=E.exact;break;case"TextPositionSelector":d.start=E.start,d.end=E.end;break}return d},{});if(a.outdated||(a.outdated="outdated"in l?l.outdated:void 0),dr(u))a.selector.push({...u,id:l.id,scope:l.scope});else{const d=[u.start?void 0:"TextPositionSelector",u.quote?void 0:"TextQuoteSelector"].filter(Boolean);return{error:Error(`Missing selector types: ${d.join(" and ")} for annotation: ${e.id}`)}}}return{parsed:a}},Ei=e=>{const t=e.id||pi(),{creator:n,created:i,modified:o,body:r,...s}=e,a=ar(r,t),l=ur(e);return"error"in l?{error:l.error}:{parsed:{...s,id:t,bodies:a,target:l.parsed}}},Si=(e,t,n)=>{const{bodies:i,target:o,...r}=e,{selector:s,creator:a,created:l,updated:c,...u}=o,d=s.map(E=>{const{id:p,quote:C,start:f,end:R,range:b}=E,h={type:"TextQuoteSelector",exact:C};if(n){const{prefix:M,suffix:O}=Pn(b,n);h.prefix=M,h.suffix=O}const T={type:"TextPositionSelector",start:f,end:R};return{...u,id:p,scope:"scope"in E?E.scope:void 0,source:t,selector:[h,T]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:lr(e.bodies),creator:a,created:l==null?void 0:l.toISOString(),modified:c==null?void 0:c.toISOString(),target:d}};function xi(e,t,n=0,i=e.length-1,o=fr){for(;i>n;){if(i-n>600){const l=i-n+1,c=t-n+1,u=Math.log(l),d=.5*Math.exp(2*u/3),E=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),p=Math.max(n,Math.floor(t-c*d/l+E)),C=Math.min(i,Math.floor(t+(l-c)*d/l+E));xi(e,t,p,C,o)}const r=e[t];let s=n,a=i;for(ot(e,n,t),o(e[i],r)>0&&ot(e,n,i);s<a;){for(ot(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?ot(e,n,a):(a++,ot(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function ot(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function fr(e,t){return e<t?-1:e>t?1:0}class hr{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 i=[];if(!Mt(t,n))return i;const o=this.toBBox,r=[];for(;n;){for(let s=0;s<n.children.length;s++){const a=n.children[s],l=n.leaf?o(a):a;Mt(t,l)&&(n.leaf?i.push(a):dn(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!Mt(t,n))return!1;const i=[];for(;n;){for(let o=0;o<n.children.length;o++){const r=n.children[o],s=n.leaf?this.toBBox(r):r;if(Mt(t,s)){if(n.leaf||dn(t,s))return!0;i.push(r)}}n=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);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 i=this.data;this.data=n,n=i}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=Xe([]),this}remove(t,n){if(!t)return this;let i=this.data;const o=this.toBBox(t),r=[],s=[];let a,l,c;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=s.pop(),c=!0),i.leaf){const u=gr(t,i.children,n);if(u!==-1)return i.children.splice(u,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&dn(i,o)?(r.push(i),s.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],c=!1):i=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 i=[];for(;t;)t.leaf?n.push(...t.children):i.push(...t.children),t=i.pop();return n}_build(t,n,i,o){const r=i-n+1;let s=this._maxEntries,a;if(r<=s)return a=Xe(t.slice(n,i+1)),Ve(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=Xe([]),a.leaf=!1,a.height=o;const l=Math.ceil(r/s),c=l*Math.ceil(Math.sqrt(s));Oi(t,n,i,c,this.compareMinX);for(let u=n;u<=i;u+=c){const d=Math.min(u+c-1,i);Oi(t,u,d,l,this.compareMinY);for(let E=u;E<=d;E+=l){const p=Math.min(E+l-1,d);a.children.push(this._build(t,E,p,o-1))}}return Ve(a,this.toBBox),a}_chooseSubtree(t,n,i,o){for(;o.push(n),!(n.leaf||o.length-1===i);){let r=1/0,s=1/0,a;for(let l=0;l<n.children.length;l++){const c=n.children[l],u=cn(c),d=br(t,c)-u;d<s?(s=d,r=u<r?u:r,a=c):d===s&&u<r&&(r=u,a=c)}n=a||n.children[0]}return n}_insert(t,n,i){const o=i?t:this.toBBox(t),r=[],s=this._chooseSubtree(o,this.data,n,r);for(s.children.push(t),st(s,o);n>=0&&r[n].children.length>this._maxEntries;)this._split(r,n),n--;this._adjustParentBBoxes(o,r,n)}_split(t,n){const i=t[n],o=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,o);const s=this._chooseSplitIndex(i,r,o),a=Xe(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Ve(i,this.toBBox),Ve(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=Xe([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Ve(this.data,this.toBBox)}_chooseSplitIndex(t,n,i){let o,r=1/0,s=1/0;for(let a=n;a<=i-n;a++){const l=rt(t,0,a,this.toBBox),c=rt(t,a,i,this.toBBox),u=wr(l,c),d=cn(l)+cn(c);u<r?(r=u,o=a,s=d<s?d:s):u===r&&d<s&&(s=d,o=a)}return o||i-n}_chooseSplitAxis(t,n,i){const o=t.leaf?this.compareMinX:pr,r=t.leaf?this.compareMinY:mr,s=this._allDistMargin(t,n,i,o),a=this._allDistMargin(t,n,i,r);s<a&&t.children.sort(o)}_allDistMargin(t,n,i,o){t.children.sort(o);const r=this.toBBox,s=rt(t,0,n,r),a=rt(t,i-n,i,r);let l=kt(s)+kt(a);for(let c=n;c<i-n;c++){const u=t.children[c];st(s,t.leaf?r(u):u),l+=kt(s)}for(let c=i-n-1;c>=n;c--){const u=t.children[c];st(a,t.leaf?r(u):u),l+=kt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)st(n[o],t)}_condense(t){for(let n=t.length-1,i;n>=0;n--)t[n].children.length===0?n>0?(i=t[n-1].children,i.splice(i.indexOf(t[n]),1)):this.clear():Ve(t[n],this.toBBox)}}function gr(e,t,n){if(!n)return t.indexOf(e);for(let i=0;i<t.length;i++)if(n(e,t[i]))return i;return-1}function Ve(e,t){rt(e,0,e.children.length,t,e)}function rt(e,t,n,i,o){o||(o=Xe(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(let r=t;r<n;r++){const s=e.children[r];st(o,e.leaf?i(s):s)}return o}function st(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 pr(e,t){return e.minX-t.minX}function mr(e,t){return e.minY-t.minY}function cn(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function kt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function br(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 wr(e,t){const n=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),o=Math.min(e.maxX,t.maxX),r=Math.min(e.maxY,t.maxY);return Math.max(0,o-n)*Math.max(0,r-i)}function dn(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Mt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Xe(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Oi(e,t,n,i,o){const r=[t,n];for(;r.length;){if(n=r.pop(),t=r.pop(),n-t<=i)continue;const s=t+Math.ceil((n-t)/i/2)*i;xi(e,s,t,n,o),r.push(t,s,s,n)}}let yr=()=>({emit(e,...t){for(let n=this.events[e]||[],i=0,o=n.length;i<o;i++)n[i](...t)},events:{},on(e,t){var n;return((n=this.events)[e]||(n[e]=[])).push(t),()=>{var i;this.events[e]=(i=this.events[e])==null?void 0:i.filter(o=>t!==o)}}});const vr=(e,t,n,i)=>{const o=new hr,r=new Map,s=yr(),a=(O,k)=>{const _=O.selector.flatMap(B=>{const P=ue([B])?B.range:Jt(B,t).range;return Dn(P)}),I=Yn(_,n,i).map(B=>jn(B,k));return I.map(B=>{const{x:P,y:V,width:x,height:g}=B;return{minX:P,minY:V,maxX:P+x,maxY:V+g,annotation:{id:O.annotation,rects:I}}})},l=()=>[...r.values()],c=()=>{o.clear(),r.clear()},u=O=>{const k=a(O,t.getBoundingClientRect());k.length!==0&&(k.forEach(_=>o.insert(_)),r.set(O.annotation,k))},d=O=>{const k=r.get(O.annotation);k&&(k.forEach(_=>o.remove(_)),r.delete(O.annotation))},E=O=>{d(O),u(O)},p=(O,k=!0)=>{k&&c();const _=t.getBoundingClientRect(),I=O.map(P=>({target:P,rects:a(P,_)}));I.forEach(({target:P,rects:V})=>{V.length>0&&r.set(P.annotation,V)});const B=I.flatMap(({rects:P})=>P);o.load(B)},C=(O,k,_=!1)=>{const I=o.search({minX:O,minY:k,maxX:O,maxY:k}),B=P=>P.annotation.rects.reduce((V,x)=>V+x.width*x.height,0);return I.length>0?(I.sort((P,V)=>B(P)-B(V)),_?I.map(P=>P.annotation.id):[I[0].annotation.id]):[]},f=O=>{const k=R(O);if(k.length===0)return;let _=k[0].left,I=k[0].top,B=k[0].right,P=k[0].bottom;for(let V=1;V<k.length;V++){const x=k[V];_=Math.min(_,x.left),I=Math.min(I,x.top),B=Math.max(B,x.right),P=Math.max(P,x.bottom)}return new DOMRect(_,I,B-_,P-I)},R=O=>{const k=r.get(O);return k?k[0].annotation.rects:[]};return{all:l,clear:c,getAt:C,getAnnotationBounds:f,getAnnotationRects:R,getIntersecting:(O,k,_,I)=>{const B=o.search({minX:O,minY:k,maxX:_,maxY:I}),P=new Set(B.map(V=>V.annotation.id));return Array.from(P).map(V=>({annotation:e.getAnnotation(V),rects:R(V)})).filter(V=>!!V.annotation)},insert:u,recalculate:()=>{p(e.all().map(O=>O.target),!0),s.emit("recalculate")},remove:d,set:p,size:()=>o.all().length,update:E,on:(O,k)=>s.on(O,k)}},Ci=(e,t)=>{var h,T;const n=jo(),i=vr(n,e,(h=t.mergeHighlights)==null?void 0:h.horizontalTolerance,(T=t.mergeHighlights)==null?void 0:T.verticalTolerance),o=Mo(n,t.userSelectAction,t.adapter),r=ko(n),s=Go(),a=(M,O=X.LOCAL)=>{const k=xt(M,e),_=ue(k.target.selector);return _&&n.addAnnotation(k,O),_},l=(M,O=!0,k=X.LOCAL)=>{const _=M.map(B=>xt(B,e)),I=_.filter(B=>!ue(B.target.selector));return n.bulkAddAnnotations(_,O,k),I},c=(M,O=X.LOCAL)=>{const k=M.map(I=>xt(I,e)),_=k.filter(I=>!ue(I.target.selector));return k.forEach(I=>{n.getAnnotation(I.id)?n.updateAnnotation(I,O):n.addAnnotation(I,O)}),_},u=(M,O=X.LOCAL)=>{const k=et(M,e);n.updateTarget(k,O)},d=(M,O=X.LOCAL)=>{const k=M.map(_=>et(_,e));n.bulkUpdateTargets(k,O)};function E(M,O,k,_){const I=k||!!_,B=i.getAt(M,O,I).map(V=>n.getAnnotation(V)),P=_?B.filter(_):B;if(P.length!==0)return k?P:P[0]}const p=M=>i.getAnnotationRects(M).length>0?i.getAnnotationBounds(M):void 0,C=(M,O,k,_)=>i.getIntersecting(M,O,k,_),f=M=>i.getAnnotationRects(M),R=()=>i.recalculate(),b=M=>i.on("recalculate",M);return n.observe(({changes:M})=>{const O=(M.deleted||[]).filter(I=>ue(I.target.selector)),k=(M.created||[]).filter(I=>ue(I.target.selector)),_=(M.updated||[]).filter(I=>ue(I.newValue.target.selector));(O==null?void 0:O.length)>0&&O.forEach(I=>i.remove(I.target)),k.length>0&&i.set(k.map(I=>I.target),!1),(_==null?void 0:_.length)>0&&_.forEach(({newValue:I})=>i.update(I.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:d,bulkUpsertAnnotations:c,getAnnotationBounds:p,getAnnotationRects:f,getIntersecting:C,getAt:E,recalculatePositions:R,onRecalculatePositions:b,updateTarget:u},selection:o,hover:r,viewport:s}},Ar=()=>{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},Ri=(e,t={})=>{const n=Ar(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=u=>Array.from(o.entries()).filter(([d,E])=>E.presenceKey===u.presenceKey).map(([d,E])=>d);return e.on("selectionChange",(u,d)=>{r(u).forEach(p=>o.delete(p)),d&&d.forEach(p=>o.set(p,u))}),{clear:()=>{const{width:u,height:d}=n;i.clearRect(-.5,-.5,u+1,d+1)},destroy:()=>{n.remove()},paint:(u,d,E)=>{t.font&&(i.font=t.font);const p=o.get(u.annotation.id);if(p){const{height:C}=u.rects[0],f=u.rects[0].x+d.left,R=u.rects[0].y+d.top;i.fillStyle=p.appearance.color,i.fillRect(f-2,R-2.5,2,C+5);const b=i.measureText(p.appearance.label),h=b.width+6,T=b.actualBoundingBoxAscent+b.actualBoundingBoxDescent+8,M=b.fontBoundingBoxAscent?8:6.5;return i.fillRect(f-2,R-2.5-T,h,T),i.fillStyle="#fff",i.fillText(p.appearance.label,f+1,R-M),{fill:p.appearance.color,fillOpacity:E?.45:.18}}},reset:()=>{n.width=2*window.innerWidth,n.height=2*window.innerHeight;const u=n.getContext("2d");u.scale(2,2),u.translate(.5,.5)}}},un=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function fn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function at(e,t,n,i){e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Ti(e,t){const n=t.slice(0,t.length-1);for(let i=0;i<n.length;i++)n[i]=e[n[i].toLowerCase()];return n}function Li(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 Er(e,t){const n=e.length>=t.length?e:t,i=e.length>=t.length?t:e;let o=!0;for(let r=0;r<n.length;r++)i.indexOf(n[r])===-1&&(o=!1);return o}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,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,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,"-":un?173:189,"=":un?61:187,";":un?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},ae={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},ct={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},J={16:!1,18:!1,17:!1,91:!1},W={};for(let e=1;e<20;e++)lt["f".concat(e)]=111+e;let F=[],dt=null,ki="all";const be=new Map,Ye=e=>lt[e.toLowerCase()]||ae[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Sr=e=>Object.keys(lt).find(t=>lt[t]===e),xr=e=>Object.keys(ae).find(t=>ae[t]===e);function Mi(e){ki=e||"all"}function ut(){return ki||"all"}function Or(){return F.slice(0)}function Cr(){return F.map(e=>Sr(e)||xr(e)||String.fromCharCode(e))}function Rr(){const e=[];return Object.keys(W).forEach(t=>{W[t].forEach(n=>{let{key:i,scope:o,mods:r,shortcut:s}=n;e.push({scope:o,shortcut:s,mods:r,keys:i.split("+").map(a=>Ye(a))})})}),e}function Tr(e){const t=e.target||e.srcElement,{tagName:n}=t;let i=!0;const o=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(o||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(i=!1),i}function Lr(e){return typeof e=="string"&&(e=Ye(e)),F.indexOf(e)!==-1}function kr(e,t){let n,i;e||(e=ut());for(const o in W)if(Object.prototype.hasOwnProperty.call(W,o))for(n=W[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return hn(a)}):i++;ut()===e&&Mi(t||"all")}function Mr(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Ye(e.key));const n=F.indexOf(t);if(n>=0&&F.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&F.splice(0,F.length),(t===93||t===224)&&(t=91),t in J){J[t]=!1;for(const i in ae)ae[i]===t&&(oe[i]=!1)}}function Ii(e){if(typeof e>"u")Object.keys(W).forEach(o=>{Array.isArray(W[o])&&W[o].forEach(r=>It(r)),delete W[o]}),hn(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&It(o)});else if(typeof e=="object")e.key&&It(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];let[o,r]=n;typeof o=="function"&&(r=o,o=""),It({key:e,scope:o,method:r,splitKey:"+"})}}const It=e=>{let{key:t,scope:n,method:i,splitKey:o="+"}=e;Li(t).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Ye(c);if(!W[u])return;n||(n=ut());const d=l>1?Ti(ae,a):[],E=[];W[u]=W[u].filter(p=>{const f=(i?p.method===i:!0)&&p.scope===n&&Er(p.mods,d);return f&&E.push(p.element),!f}),E.forEach(p=>hn(p))})};function _i(e,t,n,i){if(t.element!==i)return;let o;if(t.scope===n||t.scope==="all"){o=t.mods.length>0;for(const r in J)Object.prototype.hasOwnProperty.call(J,r)&&(!J[r]&&t.mods.indexOf(+r)>-1||J[r]&&t.mods.indexOf(+r)===-1)&&(o=!1);(t.mods.length===0&&!J[16]&&!J[18]&&!J[17]&&!J[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(F),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function Ni(e,t){const n=W["*"];let i=e.keyCode||e.which||e.charCode;if(e.key&&e.key.toLowerCase()==="capslock"||!oe.filter.call(this,e))return;if((i===93||i===224)&&(i=91),F.indexOf(i)===-1&&i!==229&&F.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=ct[a];e[a]&&F.indexOf(l)===-1?F.push(l):!e[a]&&F.indexOf(l)>-1?F.splice(F.indexOf(l),1):a==="metaKey"&&e[a]&&(F=F.filter(c=>c in ct||c===i))}),i in J){J[i]=!0;for(const a in ae)if(Object.prototype.hasOwnProperty.call(ae,a)){const l=ct[ae[a]];oe[a]=e[l]}if(!n)return}for(const a in J)Object.prototype.hasOwnProperty.call(J,a)&&(J[a]=e[ct[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(F.indexOf(17)===-1&&F.push(17),F.indexOf(18)===-1&&F.push(18),J[17]=!0,J[18]=!0);const o=ut();if(n)for(let a=0;a<n.length;a++)n[a].scope===o&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&_i(e,n[a],o,t);if(!(i in W))return;const r=W[i],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 l=r[a],{splitKey:c}=l,u=l.key.split(c),d=[];for(let E=0;E<u.length;E++)d.push(Ye(u[E]));d.sort().join("")===F.sort().join("")&&_i(e,l,o,t)}}function oe(e,t,n){F=[];const i=Li(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,E=!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&&(l=t.keyup),t.keydown!==void 0&&(c=t.keydown),t.capture!==void 0&&(d=t.capture),typeof t.splitKey=="string"&&(u=t.splitKey),t.single===!0&&(E=!0)),typeof t=="string"&&(r=t),E&&Ii(e,r);a<i.length;a++)e=i[a].split(u),o=[],e.length>1&&(o=Ti(ae,e)),e=e[e.length-1],e=e==="*"?"*":Ye(e),e in W||(W[e]=[]),W[e].push({keyup:l,keydown:c,scope:r,mods:o,shortcut:i[a],method:n,key:i[a],splitKey:u,element:s});if(typeof s<"u"&&window){if(!be.has(s)){const p=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return Ni(f,s)},C=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;Ni(f,s),Mr(f)};be.set(s,{keydownListener:p,keyupListenr:C,capture:d}),fn(s,"keydown",p,d),fn(s,"keyup",C,d)}if(!dt){const p=()=>{F=[]};dt={listener:p,capture:d},fn(window,"focus",p,d)}}}function Ir(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(W).forEach(n=>{W[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function hn(e){const t=Object.values(W).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=be.get(e)||{};i&&o&&(at(e,"keyup",o,r),at(e,"keydown",i,r),be.delete(e))}if((t.length<=0||be.size<=0)&&(Object.keys(be).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=be.get(o)||{};r&&s&&(at(o,"keyup",s,a),at(o,"keydown",r,a),be.delete(o))}),be.clear(),Object.keys(W).forEach(o=>delete W[o]),dt)){const{listener:o,capture:r}=dt;at(window,"focus",o,r),dt=null}}const gn={getPressedKeyString:Cr,setScope:Mi,getScope:ut,deleteScope:kr,getPressedKeyCodes:Or,getAllKeyCodes:Rr,isPressed:Lr,filter:Tr,trigger:Ir,unbind:Ii,keyMap:lt,modifier:ae,modifierMap:ct};for(const e in gn)Object.prototype.hasOwnProperty.call(gn,e)&&(oe[e]=gn[e]);if(typeof window<"u"){const e=window.hotkeys;oe.noConflict=t=>(t&&window.hotkeys===oe&&(window.hotkeys=e),oe),window.hotkeys=oe}async function _r(e,t,n=(()=>!1)){do{if(await e(),await n())break;const i=t;await new Promise((o=>setTimeout(o,Math.max(0,i))))}while(!await n())}const Bi=300,Ui=["up","down","left","right"],Di=Bn?"⌘+a":"ctrl+a",Nr=[...Ui.map(e=>`shift+${e}`),Di],Hi=(e,t,n)=>{const{store:i,selection:o}=t;let r;const{annotatingEnabled:s,offsetReferenceSelector:a,selectionMode:l,dismissOnNotAnnotatable:c="NEVER"}=n,u=g=>r=g;let d;const E=g=>d=g;let p,C,f,R=s;const b=g=>{R=g,T.clear(),g||(p=void 0,C=void 0,f=void 0)},h=g=>{R&&C!==!1&&(p=Oe(e,g.target)?void 0:{annotation:pi(),selector:[],creator:r,created:new Date})},T=He(g=>{if(!R)return;const w=document.getSelection();if(!(w!=null&&w.anchorNode))return;if(Oe(e,w.anchorNode)){p=void 0;return}const L=g.timeStamp-((f==null?void 0:f.timeStamp)||g.timeStamp);if((f==null?void 0:f.type)==="pointerdown"&&(L<1e3&&!p||w.isCollapsed&&L<Bi)&&h(f||g),!p)return;if(w.isCollapsed){i.getAnnotation(p.annotation)&&(o.clear(),i.deleteAnnotation(p.annotation));return}const D=Array.from(Array(w.rangeCount).keys()).map(Q=>w.getRangeAt(Q)).map(Q=>Wn(Q,e));if(D.every(Q=>Xn(Q)))return;const H=D.flatMap(Q=>Hn(e,Q.cloneRange()));(H.length!==p.selector.length||H.some((Q,Ke)=>{var Fe;return Q.toString()!==((Fe=p.selector[Ke])==null?void 0:Fe.quote)}))&&(p={...p,selector:H.map(Q=>Kn(Q,e,a)),updated:new Date},i.getAnnotation(p.annotation)?i.updateTarget(p,X.LOCAL):o.clear())},10),M=g=>{f=Ot(g),C=f.button===0},O=async g=>{if(!C)return;const w=Ot(g),L=()=>{const{x:D,y:H}=e.getBoundingClientRect();if(Oe(e,w.target)){(typeof c=="function"?c(w,e):c==="ALWAYS")&&o.clear();return}const $=w.target instanceof Node&&e.contains(w.target)&&i.getAt(w.clientX-D,w.clientY-H,l==="all",d);if($){const{selected:Q}=o,Ke=new Set(Q.map(ft=>ft.id)),Fe=Array.isArray($)?$.map(ft=>ft.id):[$.id];(Ke.size!==Fe.length||!Fe.every(ft=>Ke.has(ft)))&&o.userSelect(Fe,w)}else o.clear()};if(w.timeStamp-f.timeStamp<Bi){await k();const D=document.getSelection(),H=Oe(e,f.target),$=Oe(e,w.target);if(D!=null&&D.isCollapsed||H&&$){p=void 0,L();return}}p&&p.selector.length>0&&(V(),o.userSelect(p.annotation,w))},k=async()=>{const g=document.getSelection();let w=!1,L=g==null?void 0:g.isCollapsed;const Y=()=>L||w,D=1;return setTimeout(()=>w=!0,50),_r(()=>L=g==null?void 0:g.isCollapsed,D,Y)},_=g=>{const w=document.getSelection();w!=null&&w.isCollapsed||((!p||p.selector.length===0)&&T(g),p&&(V(),o.userSelect(p.annotation,Ot(g))))},I=g=>{R&&g.key==="Shift"&&p&&(document.getSelection().isCollapsed||(V(),o.userSelect(p.annotation,tt(g))))},B=g=>{const w=()=>setTimeout(()=>{(p==null?void 0:p.selector.length)>0&&(o.clear(),i.addAnnotation({id:p.annotation,bodies:[],target:p}),o.userSelect(p.annotation,tt(g))),document.removeEventListener("selectionchange",w)},100);document.addEventListener("selectionchange",w),h(g)};oe(Nr.join(","),{element:e,keydown:!0,keyup:!1},g=>{g.repeat||(f=tt(g))}),oe(Di,{keydown:!0,keyup:!1},g=>{f=tt(g),B(g)});const P=g=>{g.repeat||g.target!==e&&g.target!==document.body||(p=void 0,o.clear())};oe(Ui.join(","),{keydown:!0,keyup:!1},P);const V=()=>{const g=i.getAnnotation(p.annotation);if(!g){i.addAnnotation({id:p.annotation,bodies:[],target:p});return}const{target:{updated:w}}=g,{updated:L}=p;(!w||!L||w<L)&&i.updateTarget(p)};return document.addEventListener("pointerdown",M),document.addEventListener("pointerup",O),document.addEventListener("contextmenu",_),e.addEventListener("keyup",I),e.addEventListener("selectstart",h),document.addEventListener("selectionchange",T),{destroy:()=>{p=void 0,C=void 0,f=void 0,T.clear(),document.removeEventListener("pointerdown",M),document.removeEventListener("pointerup",O),document.removeEventListener("contextmenu",_),e.removeEventListener("keyup",I),e.removeEventListener("selectstart",h),document.removeEventListener("selectionchange",T),oe.unbind()},setFilter:E,setUser:u,setAnnotatingEnabled:b}},Pi=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),Vi="SPANS",Br=(e,t={})=>{mn(e),Un(e);const n=Pi(t,{annotatingEnabled:!0,user:rr()}),i=Ci(e,n),{selection:o,viewport:r}=i,s=i.store,a=qo(s),l=Jo(i,a,n.adapter);let c=n.user;const u=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Vi:n.renderer||Vi,d=u==="SPANS"?hi(e,i,r):u==="CSS_HIGHLIGHTS"?ui(e,i,r):u==="CANVAS"?Qn(e,i,r):void 0;if(!d)throw`Unknown renderer implementation: ${u}`;console.debug(`Using ${u} renderer`),n.style&&d.setStyle(n.style);const E=Hi(e,i,n);E.setUser(c),E.setAnnotatingEnabled(n.annotatingEnabled);const p=Zo(i,a,n.adapter),C=()=>c,f=O=>{E.setAnnotatingEnabled(O===void 0?!0:O)},R=O=>{d.setFilter(O),E.setFilter(O)},b=O=>{c=O,E.setUser(O)},h=O=>{O&&(d.setPainter(Ri(O,n.presence)),O.on("selectionChange",()=>d.redraw()))},T=O=>{O?o.setSelected(O):o.clear()};return{...p,destroy:()=>{d.destroy(),E.destroy(),a.destroy()},element:e,getUser:C,setAnnotatingEnabled:f,setFilter:R,setStyle:d.setStyle.bind(d),redraw:d.redraw.bind(d),setUser:b,setSelected:T,setPresenceProvider:h,setVisible:d.setVisible.bind(d),on:l.on,off:l.off,scrollIntoView:qn(e,s),state:i}};N.DEFAULT_SELECTED_STYLE=nt,N.DEFAULT_STYLE=pe,N.NOT_ANNOTATABLE_CLASS=Se,N.NOT_ANNOTATABLE_SELECTOR=xe,N.Origin=X,N.UserSelectAction=bi,N.W3CTextFormat=cr,N.cancelSingleClickEvents=mn,N.cloneKeyboardEvent=tt,N.clonePointerEvent=Ot,N.createBody=Ho,N.createCanvasRenderer=Qn,N.createHighlightsRenderer=ui,N.createPresencePainter=Ri,N.createRenderer=di,N.createSelectionHandler=Hi,N.createSpansRenderer=hi,N.createTextAnnotator=Br,N.createTextAnnotatorState=Ci,N.fillDefaults=Pi,N.getHighlightClientRects=Dn,N.getQuoteContext=Pn,N.getRangeAnnotatableContents=St,N.isMac=Bn,N.isNotAnnotatable=Oe,N.isRangeAnnotatable=pn,N.isRevived=ue,N.isWhitespaceOrEmpty=Xn,N.mergeClientRects=Yn,N.paint=Gn,N.parseW3CTextAnnotation=Ei,N.programmaticallyFocusable=Un,N.rangeToSelector=Kn,N.reviveAnnotation=xt,N.reviveSelector=Jt,N.reviveTarget=et,N.scrollIntoView=qn,N.serializeW3CTextAnnotation=Si,N.splitAnnotatableRanges=Hn,N.toDomRectList=io,N.toParentBounds=jn,N.toViewportBounds=ro,N.trimRangeToContainer=Wn,N.whitespaceOrEmptyRegex=Vn,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|
|
3
3
|
//# sourceMappingURL=text-annotator.umd.js.map
|