@recogito/text-annotator 3.3.2 → 3.4.0
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/SelectionHandler.d.ts +10 -0
- package/dist/TextAnnotator.d.ts +15 -0
- package/dist/TextAnnotatorOptions.d.ts +34 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/scrollIntoView.d.ts +3 -0
- package/dist/highlight/Highlight.d.ts +5 -0
- package/dist/highlight/HighlightPainter.d.ts +11 -0
- package/dist/highlight/HighlightStyle.d.ts +11 -0
- package/dist/highlight/baseRenderer.d.ts +20 -0
- package/dist/highlight/canvas/canvasRenderer.d.ts +5 -0
- package/dist/highlight/canvas/index.d.ts +1 -0
- package/dist/highlight/highlights/highlightsRenderer.d.ts +6 -0
- package/dist/highlight/highlights/index.d.ts +1 -0
- package/dist/highlight/index.d.ts +6 -0
- package/dist/highlight/span/color.d.ts +2 -0
- package/dist/highlight/span/index.d.ts +1 -0
- package/dist/highlight/span/spansRenderer.d.ts +5 -0
- package/dist/highlight/viewport.d.ts +12 -0
- package/dist/index.d.ts +11 -0
- package/dist/model/core/TextAnnotation.d.ts +15 -0
- package/dist/model/core/index.d.ts +1 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/w3c/W3CTextAnnotation.d.ts +34 -0
- package/dist/model/w3c/W3CTextFormatAdapter.d.ts +12 -0
- package/dist/model/w3c/index.d.ts +2 -0
- package/dist/presence/PresencePainter.d.ts +5 -0
- package/dist/presence/PresencePainterOptions.d.ts +3 -0
- package/dist/presence/index.d.ts +2 -0
- package/dist/src/utils/isWhitespaceOrEmpty.d.ts +1 -2
- package/dist/state/TextAnnotationStore.d.ts +25 -0
- package/dist/state/TextAnnotatorState.d.ts +12 -0
- package/dist/state/index.d.ts +2 -0
- package/dist/state/spatialTree.d.ts +28 -0
- package/dist/text-annotator.es.js +603 -579
- 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/dist/utils/cancelSingleClickEvents.d.ts +6 -0
- package/dist/utils/cloneEvents.d.ts +11 -0
- package/dist/utils/device.d.ts +1 -0
- package/dist/utils/getHighlightClientRects.d.ts +1 -0
- package/dist/utils/getQuoteContext.d.ts +4 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/isNotAnnotatable.d.ts +4 -0
- package/dist/utils/isRevived.d.ts +2 -0
- package/dist/utils/isWhitespaceOrEmpty.d.ts +3 -0
- package/dist/utils/mergeClientRects.d.ts +2 -0
- package/dist/utils/programmaticallyFocusable.d.ts +6 -0
- package/dist/utils/rangeToSelector.d.ts +2 -0
- package/dist/utils/rectsToBounds.d.ts +8 -0
- package/dist/utils/reviveAnnotation.d.ts +2 -0
- package/dist/utils/reviveSelector.d.ts +11 -0
- package/dist/utils/reviveTarget.d.ts +2 -0
- package/dist/utils/splitAnnotatableRanges.d.ts +5 -0
- package/dist/utils/trimRangeToContainer.d.ts +1 -0
- package/package.json +6 -6
|
@@ -1,3 +1,3 @@
|
|
|
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}`,Ye=(e,t)=>{var i;return e.contains(t)?!!(t instanceof HTMLElement?t.closest(xe):(i=t.parentElement)==null?void 0:i.closest(xe)):!0},hn=(e,t)=>{const n=t.commonAncestorContainer;return!Ye(e,n)},gn=e=>e.addEventListener("click",t=>{!t.target.closest(xe)&&!t.target.closest("a")&&t.preventDefault()}),ut=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}),Ke=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});var Ui="2.0.5",kt=500,pn="user-agent",Le="",mn="?",ft="function",be="undefined",ke="object",Mt="string",Q="browser",fe="cpu",ae="device",re="engine",te="os",Me="result",A="name",g="type",E="vendor",S="version",Z="architecture",Fe="major",y="model",We="console",H="mobile",Y="tablet",z="smarttv",le="wearable",ht="xr",ze="embedded",Ie="inapp",It="brands",Oe="formFactors",_t="fullVersionList",_e="platform",Nt="platformVersion",gt="bitness",we="sec-ch-ua",Di=we+"-full-version-list",Hi=we+"-arch",Pi=we+"-"+gt,Vi=we+"-form-factors",Xi=we+"-"+H,Yi=we+"-"+y,bn=we+"-"+_e,Ki=bn+"-version",wn=[It,_t,H,y,_e,Nt,Z,Oe,gt],pt="Amazon",Ne="Apple",yn="ASUS",vn="BlackBerry",Ce="Google",An="Huawei",Bt="Lenovo",En="Honor",mt="LG",Ut="Microsoft",Dt="Motorola",Ht="Nvidia",Sn="OnePlus",Pt="OPPO",$e="Samsung",xn="Sharp",je="Sony",Vt="Xiaomi",Xt="Zebra",On="Chrome",Cn="Chromium",ye="Chromecast",bt="Edge",qe="Firefox",Ge="Opera",Yt="Facebook",Tn="Sogou",Be="Mobile ",Je=" Browser",Kt="Windows",Fi=typeof window!==be,ee=Fi&&window.navigator?window.navigator:void 0,ve=ee&&ee.userAgentData?ee.userAgentData:void 0,Wi=function(e,t){var n={},i=t;if(!yt(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},wt=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},Ft=function(e,t){if(typeof e===ke&&e.length>0){for(var n in e)if(Ae(t)==Ae(e[n]))return!0;return!1}return Ue(e)?Ae(t)==Ae(e):!1},yt=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?yt(e[n]):!1)},Ue=function(e){return typeof e===Mt},Wt=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=vt(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=vt(n[i]);return t}},Ae=function(e){return Ue(e)?e.toLowerCase():e},zt=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},Qe=function(e){return De(/\\?\"/g,e)},vt=function(e,t){if(Ue(e))return e=De(/^\s\s*/,e),typeof t===be?e:e.substring(0,kt)},$t=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]==ft?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===ft&&!(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}},ce=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(Ft(t[n][i],e))return n===mn?void 0:n}else if(Ft(t[n],e))return n===mn?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},Rn={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:""},Ln={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},zi={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"},kn={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[S,[A,Be+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[S,[A,bt+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[S,[A,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[A,S],[/opios[\/ ]+([\w\.]+)/i],[S,[A,Ge+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[S,[A,Ge+" GX"]],[/\bopr\/([\w\.]+)/i],[S,[A,Ge]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[S,[A,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[S,[A,"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],[A,S],[/quark(?:pc)?\/([-\w\.]+)/i],[S,[A,"Quark"]],[/\bddg\/([\w\.]+)/i],[S,[A,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[S,[A,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[S,[A,"WeChat"]],[/konqueror\/([\w\.]+)/i],[S,[A,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[S,[A,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[S,[A,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[S,[A,"Smart "+Bt+Je]],[/(avast|avg)\/([\w\.]+)/i],[[A,/(.+)/,"$1 Secure"+Je],S],[/\bfocus\/([\w\.]+)/i],[S,[A,qe+" Focus"]],[/\bopt\/([\w\.]+)/i],[S,[A,Ge+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[S,[A,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[S,[A,"Dolphin"]],[/coast\/([\w\.]+)/i],[S,[A,Ge+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[S,[A,"MIUI"+Je]],[/fxios\/([\w\.-]+)/i],[S,[A,Be+qe]],[/\bqihoobrowser\/?([\w\.]*)/i],[S,[A,"360"]],[/\b(qq)\/([\w\.]+)/i],[[A,/(.+)/,"$1Browser"],S],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[A,/(.+)/,"$1"+Je],S],[/samsungbrowser\/([\w\.]+)/i],[S,[A,$e+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[S,[A,Tn+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[A,Tn+" Mobile"],S],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[A,S],[/(lbbrowser|rekonq)/i],[A],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[S,A],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[A,Yt],S,[g,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],[A,S,[g,Ie]],[/\bgsa\/([\w\.]+) .*safari\//i],[S,[A,"GSA"],[g,Ie]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[S,[A,"TikTok"],[g,Ie]],[/\[(linkedin)app\]/i],[A,[g,Ie]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[A,/(.+)/,"Zalo"],S,[g,Ie]],[/(chromium)[\/ ]([-\w\.]+)/i],[A,S],[/headlesschrome(?:\/([\w\.]+)| )/i],[S,[A,On+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[S,[A,bt+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[A,On+" WebView"],S],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[S,[A,"Android"+Je]],[/chrome\/([\w\.]+) mobile/i],[S,[A,Be+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[A,S],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[S,[A,Be+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[A,Be+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[S,A],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[A,[S,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[A,S],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[A,Be+qe],S],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[A,"Netscape"],S],[/(wolvic|librewolf)\/([\w\.]+)/i],[A,S],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[S,[A,qe+" 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],[A,[S,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[A,[S,/[^\d\.]+./,Le]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[Z,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[Z,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[Z,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[Z,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[Z,"arm"]],[/ sun4\w[;\)]/i],[[Z,"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],[[Z,/ower/,Le,Ae]],[/winnt.+\[axp/i],[[Z,"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,[E,$e],[g,Y]],[/\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,[E,$e],[g,H]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[y,[E,Ne],[g,H]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[y,[E,Ne],[g,Y]],[/(macintosh);/i],[y,[E,Ne]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[y,[E,xn],[g,H]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[y,[E,En],[g,Y]],[/honor([-\w ]+)[;\)]/i],[y,[E,En],[g,H]],[/\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,[E,An],[g,Y]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[y,[E,An],[g,H]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[y,/_/g," "],[E,Vt],[g,Y]],[/\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," "],[E,Vt],[g,H]],[/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,[E,Sn],[g,H]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[y,[E,Pt],[g,H]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[y,[E,ce,{OnePlus:["203","304","403","404","413","415"],"*":Pt}],[g,Y]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[y,[E,"BLU"],[g,H]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[y,[E,"Vivo"],[g,H]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[y,[E,"Realme"],[g,H]],[/(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,[E,Bt],[g,Y]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[y,[E,Bt],[g,H]],[/\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,[E,Dt],[g,H]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[y,[E,Dt],[g,Y]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[y,[E,mt],[g,Y]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[y,[E,mt],[g,H]],[/(nokia) (t[12][01])/i],[E,y,[g,Y]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*))/i],[[y,/_/g," "],[g,H],[E,"Nokia"]],[/(pixel (c|tablet))\b/i],[y,[E,Ce],[g,Y]],[/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,[E,Ce],[g,H]],[/(google) (pixelbook( go)?)/i],[E,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,[E,je],[g,H]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[y,"Xperia Tablet"],[E,je],[g,Y]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[y,[E,pt],[g,Y]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[y,/(.+)/g,"Fire Phone $1"],[E,pt],[g,H]],[/(playbook);[-\w\),; ]+(rim)/i],[y,E,[g,Y]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[y,[E,vn],[g,H]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[y,[E,yn],[g,Y]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[y,[E,yn],[g,H]],[/(nexus 9)/i],[y,[E,"HTC"],[g,Y]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[E,[y,/_/g," "],[g,H]],[/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,[E,"TCL"],[g,Y]],[/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,[E,"TCL"],[g,H]],[/(itel) ((\w+))/i],[[E,Ae],y,[g,ce,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[y,[E,"Acer"],[g,Y]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[y,[E,"Meizu"],[g,H]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[y,[E,"Ulefone"],[g,H]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[y,[E,"Energizer"],[g,H]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[y,[E,"Cat"],[g,H]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[y,[E,"Smartfren"],[g,H]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[y,[E,"Nothing"],[g,H]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[y,[E,"Archos"],[g,Y]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[y,[E,"Archos"],[g,H]],[/; (n159v)/i],[y,[E,"HMD"],[g,H]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[E,y,[g,Y]],[/(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],[E,y,[g,H]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[E,y,[g,Y]],[/(surface duo)/i],[y,[E,Ut],[g,Y]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[y,[E,"Fairphone"],[g,H]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[y,[E,Ht],[g,Y]],[/(sprint) (\w+)/i],[E,y,[g,H]],[/(kin\.[onetw]{3})/i],[[y,/\./g," "],[E,Ut],[g,H]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[y,[E,Xt],[g,Y]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[y,[E,Xt],[g,H]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[E,[g,z]],[/hbbtv.+maple;(\d+)/i],[[y,/^/,"SmartTV"],[E,$e],[g,z]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[E,y,[g,z]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[E,mt],[g,z]],[/(apple) ?tv/i],[E,[y,Ne+" TV"],[g,z]],[/crkey.*devicetype\/chromecast/i],[[y,ye+" Third Generation"],[E,Ce],[g,z]],[/crkey.*devicetype\/([^/]*)/i],[[y,/^/,"Chromecast "],[E,Ce],[g,z]],[/fuchsia.*crkey/i],[[y,ye+" Nest Hub"],[E,Ce],[g,z]],[/crkey/i],[[y,ye],[E,Ce],[g,z]],[/(portaltv)/i],[y,[E,Yt],[g,z]],[/droid.+aft(\w+)( bui|\))/i],[y,[E,pt],[g,z]],[/(shield \w+ tv)/i],[y,[E,Ht],[g,z]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[y,[E,xn],[g,z]],[/(bravia[\w ]+)( bui|\))/i],[y,[E,je],[g,z]],[/(mi(tv|box)-?\w+) bui/i],[y,[E,Vt],[g,z]],[/Hbbtv.*(technisat) (.*);/i],[E,y,[g,z]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[E,/.+\/(\w+)/,"$1",ce,{LG:"lge"}],[y,vt],[g,z]],[/(playstation \w+)/i],[y,[E,je],[g,We]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[y,[E,Ut],[g,We]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[E,y,[g,We]],[/droid.+; (shield)( bui|\))/i],[y,[E,Ht],[g,We]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[y,[E,$e],[g,le]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[E,y,[g,le]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[y,[E,Pt],[g,le]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[y,[E,Ne],[g,le]],[/(opwwe\d{3})/i],[y,[E,Sn],[g,le]],[/(moto 360)/i],[y,[E,Dt],[g,le]],[/(smartwatch 3)/i],[y,[E,je],[g,le]],[/(g watch r)/i],[y,[E,mt],[g,le]],[/droid.+; (wt63?0{2,3})\)/i],[y,[E,Xt],[g,le]],[/droid.+; (glass) \d/i],[y,[E,Ce],[g,ht]],[/(pico) ([\w ]+) os\d/i],[E,y,[g,ht]],[/(quest( \d| pro)?s?).+vr/i],[y,[E,Yt],[g,ht]],[/mobile vr; rv.+firefox/i],[[g,ht]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[E,[g,ze]],[/(aeobc)\b/i],[y,[E,pt],[g,ze]],[/(homepod).+mac os/i],[y,[E,Ne],[g,ze]],[/windows iot/i],[[g,ze]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[y,[g,z]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[g,z]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+?(mobile|vr|\d) safari/i],[y,[g,ce,{mobile:"Mobile",xr:"VR","*":Y}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[g,Y]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[g,H]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[y,[E,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[S,[A,bt+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[A,S],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[S,[A,"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],[A,S],[/ladybird\//i],[[A,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[S,A]],os:[[/(windows nt) (6\.[23]); arm/i],[[A,/N/,"R"],[S,ce,Rn]],[/(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],[A,S],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[S,/(;|\))/g,"",ce,Rn],[A,Kt]],[/(windows ce)\/?([\d\.]*)/i],[A,S],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[S,/_/g,"."],[A,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[A,"macOS"],[S,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[S,[A,ye+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[S,[A,ye+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[S,[A,ye+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[S,[A,ye+" Linux"]],[/crkey\/([\d\.]+)/i],[S,[A,ye]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[S,A],[/(ubuntu) ([\w\.]+) like android/i],[[A,/(.+)/,"$1 Touch"],S],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[A,S],[/\(bb(10);/i],[S,[A,vn]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[S,[A,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[S,[A,qe+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[S,[A,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[S,ce,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[A,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[S,[A,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[A,"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],[A,S],[/(sunos) ?([\d\.]*)/i],[[A,"Solaris"],S],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[A,S]]},At=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return he.call(e.init,[[Q,[A,S,Fe,g]],[fe,[Z]],[ae,[g,y,E]],[re,[A,S]],[te,[A,S]]]),he.call(e.isIgnore,[[Q,[S,Fe]],[re,[S]],[te,[S]]]),he.call(e.isIgnoreRgx,[[Q,/ ?browser$/i],[te,/ ?os$/i]]),he.call(e.toString,[[Q,[A,S]],[fe,[Z]],[ae,[E,y]],[re,[A,S]],[te,[A,S]]]),e})(),$i=function(e,t){var n=At.init[t],i=At.isIgnore[t]||0,o=At.isIgnoreRgx[t]||0,r=At.toString[t]||0;function s(){he.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return ve?ve.getHighEntropyValues(wn).then(function(a){return e.setCH(new Mn(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)&&!Ft(i,c)&&Ae(o?De(o,this[c]):this[c])==Ae(o?De(o,a):a)){if(l=!0,a!=be)break}else if(a==be&&l){l=!l;break}return l},s.prototype.toString=function(){var a=Le;for(var l in r)typeof this[r[l]]!==be&&(a+=(a?" ":Le)+this[r[l]]);return a||be}),ve||(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 Mn(e,t){if(e=e||{},he.call(this,wn),t)he.call(this,[[It,Wt(e[we])],[_t,Wt(e[Di])],[H,/\?1/.test(e[Xi])],[y,Qe(e[Yi])],[_e,Qe(e[bn])],[Nt,Qe(e[Ki])],[Z,Qe(e[Hi])],[Oe,Wt(e[Vi])],[gt,Qe(e[Pi])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==be&&(this[n]=e[n])}function In(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(ee&&ee.userAgent==this.ua)switch(this.itemType){case Q:ee.brave&&typeof ee.brave.isBrave==ft&&this.set(A,"Brave");break;case ae:!this.get(g)&&ve&&ve[H]&&this.set(g,H),this.get(y)=="Macintosh"&&ee&&typeof ee.standalone!==be&&ee.maxTouchPoints&&ee.maxTouchPoints>2&&this.set(y,"iPad").set(g,Y);break;case te:!this.get(A)&&ve&&ve[_e]&&this.set(A,ve[_e]);break;case Me:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(Q,r(Q)).set(fe,r(fe)).set(ae,r(ae)).set(re,r(re)).set(te,r(te))}return this},this.parseUA=function(){return this.itemType!=Me&&$t.call(this.data,this.ua,this.rgxMap),this.itemType==Q&&this.set(Fe,zt(this.get(S))),this},this.parseCH=function(){var o=this.uaCH,r=this.rgxMap;switch(this.itemType){case Q:case re:var s=o[_t]||o[It],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],u=s[l].version;this.itemType==Q&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=Cn||a==bt&&/WebView2/.test(c))&&(c=ce(c,zi),a=this.get(A),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(A,c).set(S,u).set(Fe,zt(u)),a=c),this.itemType==re&&c==Cn&&this.set(S,u)}break;case fe:var d=o[Z];d&&(d&&o[gt]=="64"&&(d+="64"),$t.call(this.data,d+";",r));break;case ae:if(o[H]&&this.set(g,H),o[y]&&(this.set(y,o[y]),!this.get(g)||!this.get(E))){var v={};$t.call(v,"droid 9; "+o[y]+")",r),!this.get(g)&&v.type&&this.set(g,v.type),!this.get(E)&&v.vendor&&this.set(E,v.vendor)}if(o[Oe]){var m;if(typeof o[Oe]!="string")for(var T=0;!m&&T<o[Oe].length;)m=ce(o[Oe][T++],Ln);else m=ce(o[Oe],Ln);this.set(g,m)}break;case te:var f=o[_e];if(f){var x=o[Nt];f==Kt&&(x=parseInt(zt(x),10)>=13?"11":"10"),this.set(A,f).set(S,x)}this.get(A)==Kt&&o[y]=="Xbox"&&this.set(A,"Xbox").set(S,void 0);break;case Me:var w=this.data,h=function(b){return w[b].getItem().setCH(o).parseCH().get()};this.set(Q,h(Q)).set(fe,h(fe)).set(ae,h(ae)).set(re,h(re)).set(te,h(te))}return this},he.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",$i(this,e)]]),this}function ge(e,t,n){if(typeof e===ke?(yt(e,!0)?(typeof t===ke&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===Mt&&!yt(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===ft){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===Mt?e:n&&n[pn]?n[pn]:ee&&ee.userAgent?ee.userAgent:Le,a=new Mn(n,!0),l=t?Wi(kn,t):kn,c=function(u){return u==Me?function(){return new In(u,s,l,a).set("ua",s).set(Q,this.getBrowser()).set(fe,this.getCPU()).set(ae,this.getDevice()).set(re,this.getEngine()).set(te,this.getOS()).get()}:function(){return new In(u,s,l[u],a).parseUA().get()}};return he.call(this,[["getBrowser",c(Q)],["getCPU",c(fe)],["getDevice",c(ae)],["getEngine",c(re)],["getOS",c(te)],["getResult",c(Me)],["getUA",function(){return s}],["setUA",function(u){return Ue(u)&&(s=u.length>kt?vt(u,kt):u),this}]]).setUA(s),this}ge.VERSION=Ui,ge.BROWSER=wt([A,S,Fe,g]),ge.CPU=wt([Z]),ge.DEVICE=wt([y,E,g,We,H,z,Y,le,ze]),ge.ENGINE=ge.OS=wt([A,S]);const ji=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"}),_n=ge().os.is(ji.MACOS),Nn=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Te=(e,t=10)=>{let n;return((...i)=>{clearTimeout(n),n=setTimeout(()=>e.apply(void 0,i),t)})},jt=/^\s*$/,Bn=e=>jt.test(e.toString()),Un=e=>jt.test(e.textContent||""),Dn=e=>{const t=[],n=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT);let i;for(;i=n.nextNode();)e.intersectsNode(i)&&!Un(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())]}},qi=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(!hn(e,t))return[];const n=[];let i=null;for(const o of qi(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]},Et=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=Et(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=Et(a).textContent;return{prefix:s.substring(s.length-n),suffix:l.substring(0,n)}},de=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),Gi=(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"},Ji=(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)},Vn=(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=Gi(o,a,t,n);if(l==="inline-adjacent"){r=r.map(c=>c===a?Ji(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]},[]),Qi=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Xn=(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=Et(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}},qt=(e,t)=>{var u,d;const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,v=>{var m;return(m=v.parentElement)!=null&&m.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 v=((u=l.textContent)==null?void 0:u.length)||0;if(s+v>n){a.setStart(l,n-s);break}s+=v}l=r.nextNode()}for(;l!==null;){const v=((d=l.textContent)==null?void 0:d.length)||0;if(s+v>=i){a.setEnd(l,i-s);break}s+=v,l=r.nextNode()}return{...e,range:a}},Ze=(e,t)=>de(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:qt(n,t))},St=(e,t)=>de(e.target.selector)?e:{...e,target:Ze(e.target,t)},Yn=(e,t)=>{const n=e.cloneRange();return t.contains(n.startContainer)||n.setStart(t,0),t.contains(n.endContainer)||n.setEnd(t,t.childNodes.length),n},Kn=e=>{if(e===null)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:Kn(e.parentElement)},Fn=(e,t)=>n=>{const i=typeof n=="string"?n:n.id,o=u=>{const d=r.getBoundingClientRect(),v=r.clientHeight,m=r.clientWidth,T=u.selector[0].range.getBoundingClientRect(),{width:f,height:x}=t.getAnnotationBounds(i),w=T.top-d.top,h=T.left-d.left,b=r.parentElement?r.scrollTop:0,R=r.parentElement?r.scrollLeft:0,k=w+b-(v-x)/2,L=h+R-(m-f)/2;r.scroll({top:k,left:L,behavior:"smooth"})},r=Kn(e);if(!r)return console.warn(`The scroll parent is missing for the annotation: ${i}`,{container:e}),!1;const s=t.getAnnotation(i);if(!s)return console.warn(`The annotation is missing in the store: ${i}`),!1;const{range:a}=s.target.selector[0];if(a&&!a.collapsed)return o(s.target),!0;const l=Ze(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?(o(l),!0):!1},ue={fill:"rgb(0, 128, 255)",fillOpacity:.18},et={fill:"rgb(0, 128, 255)",fillOpacity:.45},Wn=(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?et:ue):n:(a=e.state)!=null&&a.selected?et:ue;return i&&i.paint(e,t)||r},Zi=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}},eo=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)}},Gt=(e,t,n,i)=>{const{store:o,selection:r,hover:s}=t;let a,l,c;const u=eo(n),d=Te(U=>{const{x:W,y:_}=e.getBoundingClientRect(),p=o.getAt(U.clientX-W,U.clientY-_,!1,l);p?s.current!==p.id&&(e.classList.add("hovered"),s.set(p.id)):s.current&&(e.classList.remove("hovered"),s.set(null))},10);e.addEventListener("pointermove",d);const v=Te((U=!1)=>requestAnimationFrame(()=>{c&&c.clear();const W=Zi(e),{minX:_,minY:p,maxX:O,maxY:C}=W,M=l?o.getIntersecting(_,p,O,C).filter(({annotation:B})=>l(B)):o.getIntersecting(_,p,O,C),V=r.selected.map(({id:B})=>B),P=M.map(({annotation:B,rects:J})=>{const Ee=V.includes(B.id),Bi=B.id===s.current;return{annotation:B,rects:J,state:{selected:Ee,hovered:Bi}}});i.redraw(P,W,a,c,U),setTimeout(()=>u(M.map(({annotation:B})=>B)),1)}),10),m=U=>{c=U,v()},T=U=>{a=U,v()},f=U=>{l=U,v(!1)},x=()=>v();o.observe(x);const w=r.subscribe(()=>v()),h=s.subscribe(()=>v()),b=()=>v(!0);document.addEventListener("scroll",b,{capture:!0,passive:!0});const R=Te(()=>{o.recalculatePositions(),c&&c.reset(),v()});window.addEventListener("resize",R);const k=new ResizeObserver(R);k.observe(e);const L={attributes:!0,childList:!0,subtree:!0},I=new MutationObserver(Te(U=>{U.every(_=>_.target===e||e.contains(_.target))||v(!0)},150));return I.observe(document.body,L),{destroy:()=>{e.removeEventListener("pointermove",d),i.destroy(),o.unobserve(x),w(),h(),document.removeEventListener("scroll",b),window.removeEventListener("resize",R),k.disconnect(),I.disconnect()},redraw:v,setStyle:T,setFilter:f,setPainter:m,setVisible:i.setVisible}},to=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},no=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},io=e=>{e.classList.add("r6o-annotatable");const t=to(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,u)=>requestAnimationFrame(()=>{const{width:d,height:v}=t;n.clearRect(-.5,-.5,d+1,v+1),u&&u.clear();const{top:m,left:T}=l;[...a].sort((x,w)=>{const{annotation:{target:{created:h}}}=x,{annotation:{target:{created:b}}}=w;return h.getTime()-b.getTime()}).forEach(x=>{var R;const w=c?typeof c=="function"?c(x.annotation,x.state):c:(R=x.state)!=null&&R.selected?et:ue,h=u&&u.paint(x,l)||w,b=x.rects.map(({x:k,y:L,width:I,height:D})=>({x:k+T,y:L+m,width:I,height:D}));if(n.fillStyle=h.fill,n.globalAlpha=h.fillOpacity||1,b.forEach(({x:k,y:L,width:I,height:D})=>n.fillRect(k,L,I,D)),h.underlineColor){n.globalAlpha=1,n.strokeStyle=h.underlineColor,n.lineWidth=h.underlineThickness??1;const k=h.underlineOffset??0;b.forEach(({x:L,y:I,width:D,height:U})=>{n.beginPath(),n.moveTo(L,I+U+k),n.lineTo(L+D,I+U+k),n.stroke()})}})}),o=Te(()=>{no(t)});return window.addEventListener("resize",o),{destroy:()=>{t.remove(),window.removeEventListener("resize",o)},setVisible:a=>{console.log("setVisible not implemented on Canvas renderer")},redraw:i}},zn=(e,t,n)=>Gt(e,t,n,io(e));var oo={grad:.9,turn:360,rad:360/(2*Math.PI)},pe=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},$=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},ne=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},$n=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},jn=function(e){return{r:ne(e.r,0,255),g:ne(e.g,0,255),b:ne(e.b,0,255),a:ne(e.a)}},Jt=function(e){return{r:$(e.r),g:$(e.g),b:$(e.b),a:$(e.a,3)}},ro=/^#([0-9a-f]{3,8})$/i,xt=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},qn=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}},Gn=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}},Jn=function(e){return{h:$n(e.h),s:ne(e.s,0,100),l:ne(e.l,0,100),a:ne(e.a)}},Qn=function(e){return{h:$(e.h),s:$(e.s),l:$(e.l),a:$(e.a,3)}},Zn=function(e){return Gn((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},tt=function(e){return{h:(t=qn(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},so=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ao=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,co=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ei={string:[[function(e){var t=ro.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?$(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?$(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=lo.exec(e)||co.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:jn({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=so.exec(e)||ao.exec(e);if(!t)return null;var n,i,o=Jn({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*(oo[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Zn(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 pe(t)&&pe(n)&&pe(i)?jn({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(!pe(t)||!pe(n)||!pe(i))return null;var s=Jn({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return Zn(s)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,o=e.a,r=o===void 0?1:o;if(!pe(t)||!pe(n)||!pe(i))return null;var s=(function(a){return{h:$n(a.h),s:ne(a.s,0,100),v:ne(a.v,0,100),a:ne(a.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(r)});return Gn(s)},"hsv"]]},ti=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]},uo=function(e){return typeof e=="string"?ti(e.trim(),ei.string):typeof e=="object"&&e!==null?ti(e,ei.object):[null,void 0]},Qt=function(e,t){var n=tt(e);return{h:n.h,s:ne(n.s+100*t,0,100),l:n.l,a:n.a}},Zt=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},ni=function(e,t){var n=tt(e);return{h:n.h,s:n.s,l:ne(n.l+100*t,0,100),a:n.a}},ii=(function(){function e(t){this.parsed=uo(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 $(Zt(this.rgba),2)},e.prototype.isDark=function(){return Zt(this.rgba)<.5},e.prototype.isLight=function(){return Zt(this.rgba)>=.5},e.prototype.toHex=function(){return t=Jt(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?xt($(255*r)):"","#"+xt(n)+xt(i)+xt(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return Jt(this.rgba)},e.prototype.toRgbString=function(){return t=Jt(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 Qn(tt(this.rgba))},e.prototype.toHslString=function(){return t=Qn(tt(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=qn(this.rgba),{h:$(t.h),s:$(t.s),v:$(t.v),a:$(t.a,3)};var t},e.prototype.invert=function(){return ie({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),ie(Qt(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),ie(Qt(this.rgba,-t))},e.prototype.grayscale=function(){return ie(Qt(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),ie(ni(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),ie(ni(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"?ie({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):$(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=tt(this.rgba);return typeof t=="number"?ie({h:t,s:n.s,l:n.l,a:n.a}):$(n.h)},e.prototype.isEqual=function(t){return this.toHex()===ie(t).toHex()},e})(),ie=function(e){return e instanceof ii?e:new ii(e)};const fo=e=>[`background-color:${ie((e==null?void 0:e.fill)||ue.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?ue.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(";"),oi=()=>{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 T;const v=a?typeof a=="function"?a(d.annotation,d.state):a:(T=d.state)!=null&&T.selected?et:ue,m=l&&l.paint(d,s)||v;return`::highlight(_${d.annotation.id}) { ${fo(m)} }`});e.innerHTML=u.join(`
|
|
2
|
-
`),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const v=d.target.selector.map(T=>T.range),m=new Highlight(...v);CSS.highlights.set(`_${d.id}`,m)}),t=c}}},ri=(e,t,n)=>Gt(e,t,n,oi());var si=Object.prototype.hasOwnProperty;function en(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--&&en(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(si.call(e,n)&&++i&&!si.call(t,n)||!(n in t)||!en(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const ho=e=>(e==null?void 0:e.fillOpacity)!==void 0?ie((e==null?void 0:e.fill)||ue.fill).alpha(e.fillOpacity).toHex():e!=null&&e.fill?e.fill:ie(ue.fill).alpha(ue.fillOpacity).toHex(),go=(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))},po=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 v=!(en(n,s)&&u);if(!c&&!v)return;v&&(t.innerHTML=""),[...s].sort((T,f)=>{const{annotation:{target:{created:x}}}=T,{annotation:{target:{created:w}}}=f;return x&&w?x.getTime()-w.getTime():0}).forEach(T=>{T.rects.map(f=>{const x=go(f,s),w=Wn(T,a,l,c,x);if(v){const h=document.createElement("span");h.className="r6o-annotation",h.dataset.annotation=T.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=ho(w),w.underlineStyle&&(h.style.borderStyle=w.underlineStyle),w.underlineColor&&(h.style.borderColor=w.underlineColor),w.underlineThickness&&(h.style.borderBottomWidth=`${w.underlineThickness}px`),w.underlineOffset&&(h.style.paddingBottom=`${w.underlineOffset}px`),t.appendChild(h)}})}),n=s},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},ai=(e,t,n)=>Gt(e,t,n,po(e)),j=[];for(let e=0;e<256;++e)j.push((e+256).toString(16).slice(1));function mo(e,t=0){return(j[e[t+0]]+j[e[t+1]]+j[e[t+2]]+j[e[t+3]]+"-"+j[e[t+4]]+j[e[t+5]]+"-"+j[e[t+6]]+j[e[t+7]]+"-"+j[e[t+8]]+j[e[t+9]]+"-"+j[e[t+10]]+j[e[t+11]]+j[e[t+12]]+j[e[t+13]]+j[e[t+14]]+j[e[t+15]]).toLowerCase()}let tn;const bo=new Uint8Array(16);function wo(){if(!tn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");tn=crypto.getRandomValues.bind(crypto)}return tn(bo)}const li={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function yo(e,t,n){var o;e=e||{};const i=e.random??((o=e.rng)==null?void 0:o.call(e))??wo();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,mo(i)}function ci(e,t,n){return li.randomUUID&&!e?li.randomUUID():yo(e)}var di=Object.prototype.hasOwnProperty;function Re(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--&&Re(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(di.call(e,n)&&++i&&!di.call(t,n)||!(n in t)||!Re(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}function nn(){}function vo(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const He=[];function on(e,t=nn){let n;const i=new Set;function o(a){if(vo(e,a)&&(e=a,n)){const l=!He.length;for(const c of i)c[1](),He.push(c,e);if(l){for(let c=0;c<He.length;c+=2)He[c][0](He[c+1]);He.length=0}}}function r(a){o(a(e))}function s(a,l=nn){const c=[a,l];return i.add(c),i.size===1&&(n=t(o,r)||nn),a(e),()=>{i.delete(c),i.size===0&&n&&(n(),n=null)}}return{set:o,update:r,subscribe:s}}const Ao=e=>{const{subscribe:t,set:n}=on();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 ui=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(ui||{});const Ot={selected:[]},Eo=(e,t,n)=>{const{subscribe:i,set:o}=on(Ot);let r=t,s=Ot;i(f=>s=f);const a=()=>{Re(s,Ot)||o(Ot)},l=()=>{var f;return((f=s.selected)==null?void 0:f.length)===0},c=f=>{if(l())return!1;const x=typeof f=="string"?f:f.id;return s.selected.some(w=>w.id===x)},u=(f,x)=>{let w;if(Array.isArray(f)){if(w=f.map(b=>e.getAnnotation(b)).filter(Boolean),w.length<f.length){console.warn("Invalid selection: "+f.filter(b=>!w.some(R=>R.id===b)));return}}else{const b=e.getAnnotation(f);if(!b){console.warn("Invalid selection: "+f);return}w=[b]}const h=w.reduce((b,R)=>{const k=T(R);return k==="EDIT"?[...b,{id:R.id,editable:!0}]:k==="SELECT"?[...b,{id:R.id}]:b},[]);o({selected:h,event:x})},d=(f,x)=>{const w=Array.isArray(f)?f:[f],h=w.map(b=>e.getAnnotation(b)).filter(b=>!!b);o({selected:h.map(b=>{const R=x===void 0?T(b)==="EDIT":x;return{id:b.id,editable:R}})}),h.length!==w.length&&console.warn("Invalid selection",f)},v=f=>{if(l())return!1;const{selected:x}=s;x.some(({id:w})=>f.includes(w))&&o({selected:x.filter(({id:w})=>!f.includes(w))})},m=f=>{r=f,d(s.selected.map(({id:x})=>x))},T=f=>So(f,r,n);return e.observe(({changes:f})=>v((f.deleted||[]).map(x=>x.id))),{get event(){return s?s.event:null},get selected(){return s?[...s.selected]:null},get userSelectAction(){return r},clear:a,evalSelectAction:T,isEmpty:l,isSelected:c,setSelected:d,setUserSelectAction:m,subscribe:i,userSelect:u}},So=(e,t,n)=>{const i=n?n.serialize(e):e;return typeof t=="function"?t(i):t||"EDIT"},q=[];for(let e=0;e<256;++e)q.push((e+256).toString(16).slice(1));function xo(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 rn;const Oo=new Uint8Array(16);function Co(){if(!rn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");rn=crypto.getRandomValues.bind(crypto)}return rn(Oo)}const To=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),fi={randomUUID:To};function Ro(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??Co();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,xo(o)}function hi(e,t,n){return fi.randomUUID&&!e?fi.randomUUID():Ro(e)}const sn=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)}},Lo=(e,t,n,i)=>({id:hi(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),ko=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},Mo=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},Io=(e,t)=>t.bodies.map(n=>{const i=e.bodies.find(o=>o.id===n.id);return{newBody:n,oldBody:i&&!Re(i,n)?i:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:i})=>({oldBody:n,newBody:i})),_o=(e,t)=>!Re(e.target,t.target),gi=(e,t)=>{const n=ko(e,t),i=Mo(e,t),o=Io(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:_o(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 No=(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},Bo=(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:v})=>v.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:v,newValue:m}=d;if(s.has(m.id)){const T=t.updated.find(f=>f.oldValue.id===m.id).newValue;return gi(v,T)}else return d}),...(t.updated||[]).filter(({oldValue:d})=>!a.has(d.id))];return{created:l,deleted:c,updated:u}},Ct=e=>{const t=e.id===void 0?hi():e.id;return{...e,id:t,bodies:e.bodies===void 0?[]:e.bodies.map(n=>({...n,annotation:t})),target:{...e.target,annotation:t}}},Uo=e=>e.id!==void 0,Do=()=>{const e=new Map,t=new Map,n=[],i=(p,O={})=>{n.push({onChange:p,options:O})},o=p=>{const O=n.findIndex(C=>C.onChange==p);O>-1&&n.splice(O,1)},r=(p,O)=>{const C={origin:p,changes:{created:O.created||[],updated:O.updated||[],deleted:O.deleted||[]},state:[...e.values()]};n.forEach(M=>{No(M,C)&&M.onChange(C)})},s=(p,O=X.LOCAL)=>{if(p.id&&e.get(p.id))throw Error(`Cannot add annotation ${p.id} - exists already`);{const C=Ct(p);e.set(C.id,C),C.bodies.forEach(M=>t.set(M.id,C.id)),r(O,{created:[C]})}},a=(p,O)=>{const C=Ct(typeof p=="string"?O:p),M=typeof p=="string"?p:p.id,V=M&&e.get(M);if(V){const P=gi(V,C);return M===C.id?e.set(M,C):(e.delete(M),e.set(C.id,C)),V.bodies.forEach(B=>t.delete(B.id)),C.bodies.forEach(B=>t.set(B.id,C.id)),P}else console.warn(`Cannot update annotation ${M} - does not exist`)},l=(p,O=X.LOCAL,C=X.LOCAL)=>{const M=Uo(O)?C:O,V=a(p,O);V&&r(M,{updated:[V]})},c=(p,O=X.LOCAL)=>{e.get(p.id)?l(p,O):s(p,O)},u=(p,O=X.LOCAL)=>{const C=p.reduce((M,V)=>{const P=a(V);return P?[...M,P]:M},[]);C.length>0&&r(O,{updated:C})},d=(p,O=X.LOCAL)=>{const C=p.map(Ct),{toAdd:M,toUpdate:V}=C.reduce((B,J)=>e.get(J.id)?{...B,toUpdate:[...B.toUpdate,J]}:{...B,toAdd:[...B.toAdd,J]},{toAdd:[],toUpdate:[]}),P=V.map(B=>a(B,O)).filter(Boolean);M.forEach(B=>{e.set(B.id,B),B.bodies.forEach(J=>t.set(J.id,B.id))}),r(O,{created:M,updated:P})},v=(p,O=X.LOCAL)=>{const C=e.get(p.annotation);if(C){const M={...C,bodies:[...C.bodies,p]};e.set(C.id,M),t.set(p.id,M.id),r(O,{updated:[{oldValue:C,newValue:M,bodiesCreated:[p]}]})}else console.warn(`Attempt to add body to missing annotation: ${p.annotation}`)},m=()=>[...e.values()],T=(p=X.LOCAL)=>{const O=[...e.values()];e.clear(),t.clear(),r(p,{deleted:O})},f=(p,O=!0,C=X.LOCAL)=>{const M=p.map(Ct);if(O){const V=[...e.values()];e.clear(),t.clear(),M.forEach(P=>{e.set(P.id,P),P.bodies.forEach(B=>t.set(B.id,P.id))}),r(C,{created:M,deleted:V})}else{const V=p.reduce((P,B)=>{const J=B.id&&e.get(B.id);return J?[...P,J]:P},[]);if(V.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${V.map(P=>P.id).join(", ")}`);M.forEach(P=>{e.set(P.id,P),P.bodies.forEach(B=>t.set(B.id,P.id))}),r(C,{created:M})}},x=p=>{const O=typeof p=="string"?p:p.id,C=e.get(O);if(C)return e.delete(O),C.bodies.forEach(M=>t.delete(M.id)),C;console.warn(`Attempt to delete missing annotation: ${O}`)},w=(p,O=X.LOCAL)=>{const C=x(p);C&&r(O,{deleted:[C]})},h=(p,O=X.LOCAL)=>{const C=p.reduce((M,V)=>{const P=x(V);return P?[...M,P]:M},[]);C.length>0&&r(O,{deleted:C})},b=p=>{const O=e.get(p.annotation);if(O){const C=O.bodies.find(M=>M.id===p.id);if(C){t.delete(C.id);const M={...O,bodies:O.bodies.filter(V=>V.id!==p.id)};return e.set(O.id,M),{oldValue:O,newValue:M,bodiesDeleted:[C]}}else console.warn(`Attempt to delete missing body ${p.id} from annotation ${p.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${p.annotation}`)},R=(p,O=X.LOCAL)=>{const C=b(p);C&&r(O,{updated:[C]})},k=(p,O=X.LOCAL)=>{const C=p.map(M=>b(M)).filter(Boolean);C.length>0&&r(O,{updated:C})},L=p=>{const O=e.get(p);return O?{...O}:void 0},I=p=>{const O=t.get(p);if(O){const C=L(O).bodies.find(M=>M.id===p);if(C)return C;console.error(`Store integrity error: body ${p} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${p}`)},D=(p,O)=>{if(p.annotation!==O.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const C=e.get(p.annotation);if(C){const M=C.bodies.find(P=>P.id===p.id),V={...C,bodies:C.bodies.map(P=>P.id===M.id?O:P)};return e.set(C.id,V),M.id!==O.id&&(t.delete(M.id),t.set(O.id,V.id)),{oldValue:C,newValue:V,bodiesUpdated:[{oldBody:M,newBody:O}]}}else console.warn(`Attempt to add body to missing annotation ${p.annotation}`)},U=(p,O,C=X.LOCAL)=>{const M=D(p,O);M&&r(C,{updated:[M]})},W=(p,O=X.LOCAL)=>{const C=p.map(M=>D({id:M.id,annotation:M.annotation},M)).filter(Boolean);r(O,{updated:C})},_=p=>{const O=e.get(p.annotation);if(O){const C={...O,target:{...O.target,...p}};return e.set(O.id,C),{oldValue:O,newValue:C,targetUpdated:{oldTarget:O.target,newTarget:p}}}else console.warn(`Attempt to update target on missing annotation: ${p.annotation}`)};return{addAnnotation:s,addBody:v,all:m,bulkAddAnnotations:f,bulkDeleteAnnotations:h,bulkDeleteBodies:k,bulkUpdateAnnotations:u,bulkUpdateBodies:W,bulkUpdateTargets:(p,O=X.LOCAL)=>{const C=p.map(M=>_(M)).filter(Boolean);C.length>0&&r(O,{updated:C})},bulkUpsertAnnotations:d,clear:T,deleteAnnotation:w,deleteBody:R,getAnnotation:L,getBody:I,observe:i,unobserve:o,updateAnnotation:l,updateBody:U,updateTarget:(p,O=X.LOCAL)=>{const C=_(p);C&&r(O,{updated:[C]})},upsertAnnotation:c}};let Ho=()=>({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 Po=250,Vo=(e,t)=>{const n=Ho(),i=[];let o=-1,r=!1,s=0;const a=T=>{if(!r){const{changes:f}=T,x=performance.now();if(x-s>Po)i.splice(o+1),i.push(f),o=i.length-1;else{const w=i.length-1;i[w]=Bo(i[w],f)}s=x}r=!1};e.observe(a,{origin:X.LOCAL});const l=T=>T&&T.length>0&&e.bulkDeleteAnnotations(T),c=T=>T&&T.length>0&&e.bulkAddAnnotations(T,!1),u=T=>T&&T.length>0&&e.bulkUpdateAnnotations(T.map(({oldValue:f})=>f)),d=T=>T&&T.length>0&&e.bulkUpdateAnnotations(T.map(({newValue:f})=>f)),v=T=>T&&T.length>0&&e.bulkAddAnnotations(T,!1),m=T=>T&&T.length>0&&e.bulkDeleteAnnotations(T);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(T,f)=>n.on(T,f),redo:()=>{if(i.length-1>o){r=!0;const{created:T,updated:f,deleted:x}=i[o+1];c(T),d(f),m(x),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:T,updated:f,deleted:x}=i[o];l(T),u(f),v(x),n.emit("undo",i[o]),o-=1}}}},Xo=()=>{const{subscribe:e,set:t}=on([]);return{subscribe:e,set:t}},Yo=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],u;const d=(f,x)=>{l.has(f)?l.get(f).push(x):l.set(f,[x])},v=(f,x)=>{const w=l.get(f);if(w){const h=w.indexOf(x);h!==-1&&w.splice(h,1)}},m=(f,x,w)=>{l.has(f)&&setTimeout(()=>{l.get(f).forEach(h=>{if(n){const b=Array.isArray(x)?x.map(k=>n.serialize(k)):n.serialize(x),R=w?w instanceof PointerEvent?w:n.serialize(w):void 0;h(b,R)}else h(x,w)})},1)};r.subscribe(({selected:f})=>{if(!(c.length===0&&f.length===0)){if(c.length===0&&f.length>0)c=f.map(({id:x})=>s.getAnnotation(x));else if(c.length>0&&f.length===0)c.forEach(x=>{const w=s.getAnnotation(x.id);w&&!Re(w,x)&&m("updateAnnotation",w,x)}),c=[];else{const x=new Set(c.map(h=>h.id)),w=new Set(f.map(({id:h})=>h));c.filter(h=>!w.has(h.id)).forEach(h=>{const b=s.getAnnotation(h.id);b&&!Re(b,h)&&m("updateAnnotation",b,h)}),c=[...c.filter(h=>w.has(h.id)),...f.filter(({id:h})=>!x.has(h)).map(({id:h})=>s.getAnnotation(h))]}m("selectionChanged",c)}}),o.subscribe(f=>{!u&&f?m("mouseEnterAnnotation",s.getAnnotation(f)):u&&!f?m("mouseLeaveAnnotation",s.getAnnotation(u)):u&&f&&(m("mouseLeaveAnnotation",s.getAnnotation(u)),m("mouseEnterAnnotation",s.getAnnotation(f))),u=f}),a==null||a.subscribe(f=>m("viewportIntersect",f.map(x=>s.getAnnotation(x)))),s.observe(f=>{const{created:x,deleted:w}=f.changes;(x||[]).forEach(h=>m("createAnnotation",h)),(w||[]).forEach(h=>m("deleteAnnotation",h)),(f.changes.updated||[]).filter(h=>[...h.bodiesCreated||[],...h.bodiesDeleted||[],...h.bodiesUpdated||[]].length>0).forEach(({oldValue:h,newValue:b})=>{const R=c.find(k=>k.id===h.id)||h;c=c.map(k=>k.id===h.id?b:k),m("updateAnnotation",b,R)})},{origin:X.LOCAL}),s.observe(f=>{if(c){const x=new Set(c.map(h=>h.id)),w=(f.changes.updated||[]).filter(({newValue:h})=>x.has(h.id)).map(({newValue:h})=>h);w.length>0&&(c=c.map(h=>w.find(R=>R.id===h.id)||h))}},{origin:X.REMOTE});const T=f=>x=>{const{updated:w}=x;f?(w||[]).forEach(h=>m("updateAnnotation",h.oldValue,h.newValue)):(w||[]).forEach(h=>m("updateAnnotation",h.newValue,h.oldValue))};return t.on("undo",T(!0)),t.on("redo",T(!1)),{on:d,off:v,emit:m}},Ko=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:[]}),Fo=(e,t,n)=>{const{store:i,selection:o}=e,r=w=>{if(n){const{parsed:h,error:b}=n.parse(w);h?i.addAnnotation(h,X.REMOTE):console.error(b)}else i.addAnnotation(sn(w),X.REMOTE)},s=()=>o.clear(),a=()=>i.clear(),l=w=>{const h=i.getAnnotation(w);return n&&h?n.serialize(h):h},c=()=>n?i.all().map(n.serialize):i.all(),u=()=>{var w;const h=(((w=o.selected)==null?void 0:w.map(b=>b.id))||[]).map(b=>i.getAnnotation(b)).filter(Boolean);return n?h.map(n.serialize):h},d=(w,h=!0)=>fetch(w).then(b=>b.json()).then(b=>(m(b,h),b)),v=w=>{if(typeof w=="string"){const h=i.getAnnotation(w);if(i.deleteAnnotation(w),h)return n?n.serialize(h):h}else{const h=n?n.parse(w).parsed:w;if(h)return i.deleteAnnotation(h),w}},m=(w,h=!0)=>{if(n){const b=n.parseAll||Ko(n),{parsed:R,failed:k}=b(w);k.length>0&&console.warn(`Discarded ${k.length} invalid annotations`,k),i.bulkAddAnnotations(R,h,X.REMOTE)}else i.bulkAddAnnotations(w.map(sn),h,X.REMOTE)},T=(w,h)=>{w?o.setSelected(w,h):o.clear()},f=w=>{o.setUserSelectAction(w)},x=w=>{if(n){const h=n.parse(w).parsed,b=n.serialize(i.getAnnotation(h.id));return i.updateAnnotation(h),b}else{const h=i.getAnnotation(w.id);return i.updateAnnotation(sn(w)),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:v,setAnnotations:m,setSelected:T,setUserSelectAction:f,undo:t.undo,updateAnnotation:x}},Wo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let zo=e=>crypto.getRandomValues(new Uint8Array(e)),$o=(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}}},jo=(e,t=21)=>$o(e,t|0,zo),qo=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Wo[n[e]&63];return t};const Go=()=>({isGuest:!0,id:jo("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Jo=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}`},pi=e=>e?typeof e=="object"?{...e}:e:void 0,Qo=(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-${Jo(n)}`,annotation:t,type:o,purpose:r,value:s,creator:pi(c),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),Zo=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});qo();const er=(e,t)=>({parse:n=>mi(n),serialize:n=>bi(n,e,t)}),tr=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,nr=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:pi(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,v)=>{switch(v.type){case"TextQuoteSelector":d.quote=v.exact;break;case"TextPositionSelector":d.start=v.start,d.end=v.end;break}return d},{});if(tr(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}},mi=e=>{const t=e.id||ci(),{creator:n,created:i,modified:o,body:r,...s}=e,a=Qo(r,t),l=nr(e);return"error"in l?{error:l.error}:{parsed:{...s,id:t,bodies:a,target:l.parsed}}},bi=(e,t,n)=>{const{bodies:i,target:o,...r}=e,{selector:s,creator:a,created:l,updated:c,...u}=o,d=s.map(v=>{const{id:m,quote:T,start:f,end:x,range:w}=v,h={type:"TextQuoteSelector",exact:T};if(n){const{prefix:R,suffix:k}=Pn(w,n);h.prefix=R,h.suffix=k}const b={type:"TextPositionSelector",start:f,end:x};return{...u,id:m,scope:"scope"in v?v.scope:void 0,source:t,selector:[h,b]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:Zo(e.bodies),creator:a,created:l==null?void 0:l.toISOString(),modified:c==null?void 0:c.toISOString(),target:d}};function wi(e,t,n=0,i=e.length-1,o=ir){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),v=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(t-c*d/l+v)),T=Math.min(i,Math.floor(t+(l-c)*d/l+v));wi(e,t,m,T,o)}const r=e[t];let s=n,a=i;for(nt(e,n,t),o(e[i],r)>0&&nt(e,n,i);s<a;){for(nt(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?nt(e,n,a):(a++,nt(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function nt(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function ir(e,t){return e<t?-1:e>t?1:0}class or{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(!Rt(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;Rt(t,l)&&(n.leaf?i.push(a):ln(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!Rt(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(Rt(t,s)){if(n.leaf||ln(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=Ve([]),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=rr(t,i.children,n);if(u!==-1)return i.children.splice(u,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&ln(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=Ve(t.slice(n,i+1)),Pe(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=Ve([]),a.leaf=!1,a.height=o;const l=Math.ceil(r/s),c=l*Math.ceil(Math.sqrt(s));yi(t,n,i,c,this.compareMinX);for(let u=n;u<=i;u+=c){const d=Math.min(u+c-1,i);yi(t,u,d,l,this.compareMinY);for(let v=u;v<=d;v+=l){const m=Math.min(v+l-1,d);a.children.push(this._build(t,v,m,o-1))}}return Pe(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=an(c),d=lr(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),ot(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=Ve(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Pe(i,this.toBBox),Pe(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=Ve([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Pe(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=it(t,0,a,this.toBBox),c=it(t,a,i,this.toBBox),u=cr(l,c),d=an(l)+an(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:sr,r=t.leaf?this.compareMinY:ar,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=it(t,0,n,r),a=it(t,i-n,i,r);let l=Tt(s)+Tt(a);for(let c=n;c<i-n;c++){const u=t.children[c];ot(s,t.leaf?r(u):u),l+=Tt(s)}for(let c=i-n-1;c>=n;c--){const u=t.children[c];ot(a,t.leaf?r(u):u),l+=Tt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)ot(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():Pe(t[n],this.toBBox)}}function rr(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 Pe(e,t){it(e,0,e.children.length,t,e)}function it(e,t,n,i,o){o||(o=Ve(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];ot(o,e.leaf?i(s):s)}return o}function ot(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 sr(e,t){return e.minX-t.minX}function ar(e,t){return e.minY-t.minY}function an(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Tt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function lr(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 cr(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 ln(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Rt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Ve(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function yi(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;wi(e,s,t,n,o),r.push(t,s,s,n)}}const dr=(e,t,n,i)=>{const o=new or,r=new Map,s=(b,R)=>{const k=b.selector.flatMap(I=>{const D=de([I])?I.range:qt(I,t).range;return Dn(D)}),L=Vn(k,n,i).map(({left:I,top:D,right:U,bottom:W})=>new DOMRect(I-R.left,D-R.top,U-I,W-D));return L.map(I=>{const{x:D,y:U,width:W,height:_}=I;return{minX:D,minY:U,maxX:D+W,maxY:U+_,annotation:{id:b.annotation,rects:L}}})},a=()=>[...r.values()],l=()=>{o.clear(),r.clear()},c=b=>{const R=s(b,t.getBoundingClientRect());R.length!==0&&(R.forEach(k=>o.insert(k)),r.set(b.annotation,R))},u=b=>{const R=r.get(b.annotation);R&&(R.forEach(k=>o.remove(k)),r.delete(b.annotation))},d=b=>{u(b),c(b)},v=(b,R=!0)=>{R&&l();const k=t.getBoundingClientRect(),L=b.map(D=>({target:D,rects:s(D,k)}));L.forEach(({target:D,rects:U})=>{U.length>0&&r.set(D.annotation,U)});const I=L.flatMap(({rects:D})=>D);o.load(I)},m=(b,R,k=!1)=>{const L=o.search({minX:b,minY:R,maxX:b,maxY:R}),I=D=>D.annotation.rects.reduce((U,W)=>U+W.width*W.height,0);return L.length>0?(L.sort((D,U)=>I(D)-I(U)),k?L.map(D=>D.annotation.id):[L[0].annotation.id]):[]},T=b=>{const R=f(b);if(R.length===0)return;let k=R[0].left,L=R[0].top,I=R[0].right,D=R[0].bottom;for(let U=1;U<R.length;U++){const W=R[U];k=Math.min(k,W.left),L=Math.min(L,W.top),I=Math.max(I,W.right),D=Math.max(D,W.bottom)}return new DOMRect(k,L,I-k,D-L)},f=b=>{const R=r.get(b);return R?R[0].annotation.rects:[]};return{all:a,clear:l,getAt:m,getAnnotationBounds:T,getAnnotationRects:f,getIntersecting:(b,R,k,L)=>{const I=o.search({minX:b,minY:R,maxX:k,maxY:L}),D=new Set(I.map(U=>U.annotation.id));return Array.from(D).map(U=>({annotation:e.getAnnotation(U),rects:f(U)})).filter(U=>!!U.annotation)},insert:c,recalculate:()=>v(e.all().map(b=>b.target),!0),remove:u,set:v,size:()=>o.all().length,update:d}},vi=(e,t)=>{var w,h;const n=Do(),i=dr(n,e,(w=t.mergeHighlights)==null?void 0:w.horizontalTolerance,(h=t.mergeHighlights)==null?void 0:h.verticalTolerance),o=Eo(n,t.userSelectAction,t.adapter),r=Ao(n),s=Xo(),a=(b,R=X.LOCAL)=>{const k=St(b,e),L=de(k.target.selector);return L&&n.addAnnotation(k,R),L},l=(b,R=!0,k=X.LOCAL)=>{const L=b.map(D=>St(D,e)),I=L.filter(D=>!de(D.target.selector));return n.bulkAddAnnotations(L,R,k),I},c=(b,R=X.LOCAL)=>{const k=b.map(I=>St(I,e)),L=k.filter(I=>!de(I.target.selector));return k.forEach(I=>{n.getAnnotation(I.id)?n.updateAnnotation(I,R):n.addAnnotation(I,R)}),L},u=(b,R=X.LOCAL)=>{const k=Ze(b,e);n.updateTarget(k,R)},d=(b,R=X.LOCAL)=>{const k=b.map(L=>Ze(L,e));n.bulkUpdateTargets(k,R)};function v(b,R,k,L){const I=k||!!L,D=i.getAt(b,R,I).map(W=>n.getAnnotation(W)),U=L?D.filter(L):D;if(U.length!==0)return k?U:U[0]}const m=b=>{if(i.getAnnotationRects(b).length!==0)return i.getAnnotationBounds(b)},T=(b,R,k,L)=>i.getIntersecting(b,R,k,L),f=b=>i.getAnnotationRects(b),x=()=>i.recalculate();return n.observe(({changes:b})=>{const R=(b.deleted||[]).filter(I=>de(I.target.selector)),k=(b.created||[]).filter(I=>de(I.target.selector)),L=(b.updated||[]).filter(I=>de(I.newValue.target.selector));(R==null?void 0:R.length)>0&&R.forEach(I=>i.remove(I.target)),k.length>0&&i.set(k.map(I=>I.target),!1),(L==null?void 0:L.length)>0&&L.forEach(({newValue:I})=>i.update(I.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:d,bulkUpsertAnnotations:c,getAnnotationBounds:m,getAnnotationRects:f,getIntersecting:T,getAt:v,recalculatePositions:x,updateTarget:u},selection:o,hover:r,viewport:s}},ur=()=>{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},Ai=(e,t={})=>{const n=ur(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=u=>Array.from(o.entries()).filter(([d,v])=>v.presenceKey===u.presenceKey).map(([d,v])=>d);return e.on("selectionChange",(u,d)=>{r(u).forEach(m=>o.delete(m)),d&&d.forEach(m=>o.set(m,u))}),{clear:()=>{const{width:u,height:d}=n;i.clearRect(-.5,-.5,u+1,d+1)},destroy:()=>{n.remove()},paint:(u,d,v)=>{t.font&&(i.font=t.font);const m=o.get(u.annotation.id);if(m){const{height:T}=u.rects[0],f=u.rects[0].x+d.left,x=u.rects[0].y+d.top;i.fillStyle=m.appearance.color,i.fillRect(f-2,x-2.5,2,T+5);const w=i.measureText(m.appearance.label),h=w.width+6,b=w.actualBoundingBoxAscent+w.actualBoundingBoxDescent+8,R=w.fontBoundingBoxAscent?8:6.5;return i.fillRect(f-2,x-2.5-b,h,b),i.fillStyle="#fff",i.fillText(m.appearance.label,f+1,x-R),{fill:m.appearance.color,fillOpacity:v?.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)}}},cn=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function dn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function rt(e,t,n,i){e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Ei(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 Si(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 fr(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 st={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,"-":cn?173:189,"=":cn?61:187,";":cn?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},se={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},at={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},G={16:!1,18:!1,17:!1,91:!1},F={};for(let e=1;e<20;e++)st["f".concat(e)]=111+e;let K=[],lt=null,xi="all";const me=new Map,Xe=e=>st[e.toLowerCase()]||se[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),hr=e=>Object.keys(st).find(t=>st[t]===e),gr=e=>Object.keys(se).find(t=>se[t]===e);function Oi(e){xi=e||"all"}function ct(){return xi||"all"}function pr(){return K.slice(0)}function mr(){return K.map(e=>hr(e)||gr(e)||String.fromCharCode(e))}function br(){const e=[];return Object.keys(F).forEach(t=>{F[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=>Xe(a))})})}),e}function wr(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 yr(e){return typeof e=="string"&&(e=Xe(e)),K.indexOf(e)!==-1}function vr(e,t){let n,i;e||(e=ct());for(const o in F)if(Object.prototype.hasOwnProperty.call(F,o))for(n=F[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return un(a)}):i++;ct()===e&&Oi(t||"all")}function Ar(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Xe(e.key));const n=K.indexOf(t);if(n>=0&&K.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&K.splice(0,K.length),(t===93||t===224)&&(t=91),t in G){G[t]=!1;for(const i in se)se[i]===t&&(oe[i]=!1)}}function Ci(e){if(typeof e>"u")Object.keys(F).forEach(o=>{Array.isArray(F[o])&&F[o].forEach(r=>Lt(r)),delete F[o]}),un(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&Lt(o)});else if(typeof e=="object")e.key&&Lt(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=""),Lt({key:e,scope:o,method:r,splitKey:"+"})}}const Lt=e=>{let{key:t,scope:n,method:i,splitKey:o="+"}=e;Si(t).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Xe(c);if(!F[u])return;n||(n=ct());const d=l>1?Ei(se,a):[],v=[];F[u]=F[u].filter(m=>{const f=(i?m.method===i:!0)&&m.scope===n&&fr(m.mods,d);return f&&v.push(m.element),!f}),v.forEach(m=>un(m))})};function Ti(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 G)Object.prototype.hasOwnProperty.call(G,r)&&(!G[r]&&t.mods.indexOf(+r)>-1||G[r]&&t.mods.indexOf(+r)===-1)&&(o=!1);(t.mods.length===0&&!G[16]&&!G[18]&&!G[17]&&!G[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(K),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function Ri(e,t){const n=F["*"];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),K.indexOf(i)===-1&&i!==229&&K.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=at[a];e[a]&&K.indexOf(l)===-1?K.push(l):!e[a]&&K.indexOf(l)>-1?K.splice(K.indexOf(l),1):a==="metaKey"&&e[a]&&(K=K.filter(c=>c in at||c===i))}),i in G){G[i]=!0;for(const a in se)if(Object.prototype.hasOwnProperty.call(se,a)){const l=at[se[a]];oe[a]=e[l]}if(!n)return}for(const a in G)Object.prototype.hasOwnProperty.call(G,a)&&(G[a]=e[at[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(K.indexOf(17)===-1&&K.push(17),K.indexOf(18)===-1&&K.push(18),G[17]=!0,G[18]=!0);const o=ct();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)&&Ti(e,n[a],o,t);if(!(i in F))return;const r=F[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 v=0;v<u.length;v++)d.push(Xe(u[v]));d.sort().join("")===K.sort().join("")&&Ti(e,l,o,t)}}function oe(e,t,n){K=[];const i=Si(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,v=!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&&(v=!0)),typeof t=="string"&&(r=t),v&&Ci(e,r);a<i.length;a++)e=i[a].split(u),o=[],e.length>1&&(o=Ei(se,e)),e=e[e.length-1],e=e==="*"?"*":Xe(e),e in F||(F[e]=[]),F[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(!me.has(s)){const m=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return Ri(f,s)},T=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;Ri(f,s),Ar(f)};me.set(s,{keydownListener:m,keyupListenr:T,capture:d}),dn(s,"keydown",m,d),dn(s,"keyup",T,d)}if(!lt){const m=()=>{K=[]};lt={listener:m,capture:d},dn(window,"focus",m,d)}}}function Er(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(F).forEach(n=>{F[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function un(e){const t=Object.values(F).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=me.get(e)||{};i&&o&&(rt(e,"keyup",o,r),rt(e,"keydown",i,r),me.delete(e))}if((t.length<=0||me.size<=0)&&(Object.keys(me).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=me.get(o)||{};r&&s&&(rt(o,"keyup",s,a),rt(o,"keydown",r,a),me.delete(o))}),me.clear(),Object.keys(F).forEach(o=>delete F[o]),lt)){const{listener:o,capture:r}=lt;rt(window,"focus",o,r),lt=null}}const fn={getPressedKeyString:mr,setScope:Oi,getScope:ct,deleteScope:vr,getPressedKeyCodes:pr,getAllKeyCodes:br,isPressed:yr,filter:wr,trigger:Er,unbind:Ci,keyMap:st,modifier:se,modifierMap:at};for(const e in fn)Object.prototype.hasOwnProperty.call(fn,e)&&(oe[e]=fn[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 Sr(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 Li=300,ki=["up","down","left","right"],Mi=_n?"⌘+a":"ctrl+a",xr=[...ki.map(e=>`shift+${e}`),Mi],Ii=(e,t,n)=>{let i;const{annotatingEnabled:o,offsetReferenceSelector:r,selectionMode:s,dismissOnNotAnnotatable:a="NEVER"}=n,l=_=>i=_;let c;const u=_=>c=_,{store:d,selection:v}=t;let m,T,f;const x=()=>{T!==!1&&(m={annotation:ci(),selector:[],creator:i,created:new Date})},w=Te(_=>{const p=document.getSelection();if(!(p!=null&&p.anchorNode))return;const O=Array.from(Array(p.rangeCount).keys()).map(B=>p.getRangeAt(B));if(!O.some(B=>B.intersectsNode(e))){m=void 0;return}const C=_.timeStamp-((f==null?void 0:f.timeStamp)||_.timeStamp);if((f==null?void 0:f.type)==="pointerdown"&&(C<1e3&&!m||p.isCollapsed&&C<Li)&&x(),m||x(),p.isCollapsed){d.getAnnotation(m.annotation)&&(v.clear(),d.deleteAnnotation(m.annotation));return}const M=O.map(B=>Yn(B,e));if(M.every(B=>Bn(B)))return;const V=M.flatMap(B=>Hn(e,B.cloneRange()));(V.length>0&&!m||V.length!==m.selector.length||V.some((B,J)=>{var Ee;return B.toString()!==((Ee=m.selector[J])==null?void 0:Ee.quote)}))&&(m={...m,selector:V.map(B=>Xn(B,e,r)),updated:new Date},d.getAnnotation(m.annotation)?d.updateTarget(m,X.LOCAL):v.clear())}),h=_=>{f=ut(_),T=f.button===0},b=async _=>{if(!T)return;const p=ut(_),O=()=>{const{x:M,y:V}=e.getBoundingClientRect();if(Ye(e,p.target)){(typeof a=="function"?a(p,e):a==="ALWAYS")&&v.clear();return}const P=p.target instanceof Node&&e.contains(p.target)&&d.getAt(p.clientX-M,p.clientY-V,s==="all",c);if(P){const{selected:B}=v,J=new Set(B.map(dt=>dt.id)),Ee=Array.isArray(P)?P.map(dt=>dt.id):[P.id];(J.size!==Ee.length||!Ee.every(dt=>J.has(dt)))&&v.userSelect(Ee,p)}else v.clear()};if(p.timeStamp-f.timeStamp<Li){await R();const M=document.getSelection(),V=Ye(e,f.target),P=Ye(e,p.target);if(M!=null&&M.isCollapsed||V&&P){m=void 0,O();return}}m&&m.selector.length>0&&(U(),v.userSelect(m.annotation,p))},R=async()=>{const _=document.getSelection();let p=!1,O=_==null?void 0:_.isCollapsed;const C=()=>O||p,M=1;return setTimeout(()=>p=!0,50),Sr(()=>O=_==null?void 0:_.isCollapsed,M,C)},k=_=>{const p=document.getSelection();p!=null&&p.isCollapsed||((!m||m.selector.length===0)&&w(_),m&&(U(),v.userSelect(m.annotation,ut(_))))},L=_=>{_.key==="Shift"&&m&&(document.getSelection().isCollapsed||(U(),v.userSelect(m.annotation,Ke(_))))},I=_=>{const p=()=>setTimeout(()=>{(m==null?void 0:m.selector.length)>0&&(v.clear(),d.addAnnotation({id:m.annotation,bodies:[],target:m}),v.userSelect(m.annotation,Ke(_))),document.removeEventListener("selectionchange",p)},100);document.addEventListener("selectionchange",p),x()};oe(xr.join(","),{element:e,keydown:!0,keyup:!1},_=>{_.repeat||(f=Ke(_))}),oe(Mi,{keydown:!0,keyup:!1},_=>{f=Ke(_),I(_)});const D=_=>{_.repeat||_.target!==e&&_.target!==document.body||(m=void 0,v.clear())};oe(ki.join(","),{keydown:!0,keyup:!1},D);const U=()=>{const _=d.getAnnotation(m.annotation);if(!_){d.addAnnotation({id:m.annotation,bodies:[],target:m});return}const{target:{updated:p}}=_,{updated:O}=m;(!p||!O||p<O)&&d.updateTarget(m)};return document.addEventListener("pointerdown",h),document.addEventListener("pointerup",b),document.addEventListener("contextmenu",k),o&&(e.addEventListener("keyup",L),e.addEventListener("selectstart",x),document.addEventListener("selectionchange",w)),{destroy:()=>{document.removeEventListener("pointerdown",h),document.removeEventListener("pointerup",b),document.removeEventListener("contextmenu",k),e.removeEventListener("keyup",L),e.removeEventListener("selectstart",x),document.removeEventListener("selectionchange",w),oe.unbind()},setFilter:u,setUser:l}},_i=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),Ni="SPANS",Or=(e,t={})=>{gn(e),Nn(e);const n=_i(t,{annotatingEnabled:!0,user:Go()}),i=vi(e,n),{selection:o,viewport:r}=i,s=i.store,a=Vo(s),l=Yo(i,a,n.adapter);let c=n.user;const u=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Ni:n.renderer||Ni,d=u==="SPANS"?ai(e,i,r):u==="CSS_HIGHLIGHTS"?ri(e,i,r):u==="CANVAS"?zn(e,i,r):void 0;if(!d)throw`Unknown renderer implementation: ${u}`;console.debug(`Using ${u} renderer`),n.style&&d.setStyle(n.style);const v=Ii(e,i,n);return v.setUser(c),{...Fo(i,a,n.adapter),destroy:()=>{d.destroy(),v.destroy(),a.destroy()},element:e,getUser:()=>c,setFilter:L=>{d.setFilter(L),v.setFilter(L)},setStyle:L=>d.setStyle(L),setUser:L=>{c=L,v.setUser(L)},setSelected:L=>{L?o.setSelected(L):o.clear()},setPresenceProvider:L=>{L&&(d.setPainter(Ai(L,n.presence)),L.on("selectionChange",()=>d.redraw()))},setVisible:L=>d.setVisible(L),on:l.on,off:l.off,scrollIntoView:Fn(e,s),state:i}};N.DEFAULT_SELECTED_STYLE=et,N.DEFAULT_STYLE=ue,N.NOT_ANNOTATABLE_CLASS=Se,N.NOT_ANNOTATABLE_SELECTOR=xe,N.Origin=X,N.SelectionHandler=Ii,N.UserSelectAction=ui,N.W3CTextFormat=er,N.cancelSingleClickEvents=gn,N.cloneKeyboardEvent=Ke,N.clonePointerEvent=ut,N.createBody=Lo,N.createCanvasRenderer=zn,N.createHighlightsRenderer=ri,N.createPresencePainter=Ai,N.createRenderer=oi,N.createSpansRenderer=ai,N.createTextAnnotator=Or,N.createTextAnnotatorState=vi,N.debounce=Te,N.fillDefaults=_i,N.getHighlightClientRects=Dn,N.getQuoteContext=Pn,N.getRangeAnnotatableContents=Et,N.isMac=_n,N.isNodeWhitespaceOrEmpty=Un,N.isNotAnnotatable=Ye,N.isRangeAnnotatable=hn,N.isRangeWhitespaceOrEmpty=Bn,N.isRevived=de,N.mergeClientRects=Vn,N.paint=Wn,N.parseW3CTextAnnotation=mi,N.programmaticallyFocusable=Nn,N.rangeToSelector=Xn,N.reviveAnnotation=St,N.reviveSelector=qt,N.reviveTarget=Ze,N.scrollIntoView=Fn,N.serializeW3CTextAnnotation=bi,N.splitAnnotatableRanges=Hn,N.toDomRectList=Qi,N.trimRangeToContainer=Yn,N.whitespaceOrEmptyRegex=jt,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(M,Se){typeof exports=="object"&&typeof module<"u"?Se(exports):typeof define=="function"&&define.amd?define(["exports"],Se):(M=typeof globalThis<"u"?globalThis:M||self,Se(M.RecogitoJS={}))})(this,(function(M){"use strict";const Se="not-annotatable",xe=`.${Se}`,Fe=(e,t)=>{var i;return e.contains(t)?!!(t instanceof HTMLElement?t.closest(xe):(i=t.parentElement)==null?void 0:i.closest(xe)):!0},fn=(e,t)=>{const n=t.commonAncestorContainer;return!Fe(e,n)},hn=e=>e.addEventListener("click",t=>{!t.target.closest(xe)&&!t.target.closest("a")&&t.preventDefault()}),ft=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}),Ye=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});var Ui="2.0.6",Di=500,pn="user-agent",Re="",gn="?",K={FUNCTION:"function",OBJECT:"object",STRING:"string",UNDEFINED:"undefined"},te="browser",pe="cpu",ce="device",ae="engine",ie="os",ke="result",E="name",g="type",A="vendor",x="version",ee="architecture",Ke="major",y="model",We="console",B="mobile",X="tablet",j="smarttv",de="wearable",ht="xr",je="embedded",Le="inapp",It="brands",Oe="formFactors",Nt="fullVersionList",Ie="platform",Mt="platformVersion",pt="bitness",ye="sec-ch-ua",Hi=ye+"-full-version-list",Pi=ye+"-arch",Vi=ye+"-"+pt,Xi=ye+"-form-factors",Fi=ye+"-"+B,Yi=ye+"-"+y,mn=ye+"-"+Ie,Ki=mn+"-version",bn=[It,Nt,B,y,Ie,Mt,ee,Oe,pt],gt="Amazon",Ne="Apple",wn="ASUS",yn="BlackBerry",Ce="Google",vn="Huawei",Bt="Lenovo",En="Honor",mt="LG",_t="Microsoft",Ut="Motorola",Dt="Nvidia",An="OnePlus",Ht="OPPO",ze="Samsung",Sn="Sharp",$e="Sony",Pt="Xiaomi",Vt="Zebra",xn="Chrome",On="Chromium",ve="Chromecast",bt="Edge",qe="Firefox",Ge="Opera",Xt="Facebook",Cn="Sogou",Me="Mobile ",Je=" Browser",Ft="Windows",Wi=typeof window!==K.UNDEFINED,ne=Wi&&window.navigator?window.navigator:void 0,Ee=ne&&ne.userAgentData?ne.userAgentData:void 0,ji=function(e,t){var n={},i=t;if(!yt(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},wt=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},Yt=function(e,t){if(typeof e===K.OBJECT&&e.length>0){for(var n in e)if(Ae(t)==Ae(e[n]))return!0;return!1}return Qe(e)?Ae(t)==Ae(e):!1},yt=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?yt(e[n]):!1)},Qe=function(e){return typeof e===K.STRING},Kt=function(e){if(e){for(var t=[],n=Be(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var o=vt(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=vt(n[i]);return t}},Ae=function(e){return Qe(e)?e.toLowerCase():e},Wt=function(e){return Qe(e)?Be(/[^\d\.]/g,e).split(".")[0]:void 0},ge=function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n==K.OBJECT&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Be=function(e,t){return Qe(t)?t.replace(e,Re):t},Ze=function(e){return Be(/\\?\"/g,e)},vt=function(e,t){return e=Be(/^\s\s*/,String(e)),typeof t===K.UNDEFINED?e:e.substring(0,t)},jt=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===K.OBJECT&&s.length>0?s.length===2?typeof s[1]==K.FUNCTION?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===K.FUNCTION&&!(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}},ue=function(e,t){for(var n in t)if(typeof t[n]===K.OBJECT&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(Yt(t[n][i],e))return n===gn?void 0:n}else if(Yt(t[n],e))return n===gn?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},Tn={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:""},Rn={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},zi={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"},kn={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[x,[E,Me+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[x,[E,bt+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[x,[E,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[E,x],[/opios[\/ ]+([\w\.]+)/i],[x,[E,Ge+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[x,[E,Ge+" GX"]],[/\bopr\/([\w\.]+)/i],[x,[E,Ge]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[x,[E,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[x,[E,"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|palemoon)\/([-\w\.]+)/i,/(heytap|ovi|115|surf|qwant)browser\/([\d\.]+)/i,/(qwant)(?:ios|mobile)\/([\d\.]+)/i,/(ecosia|weibo)(?:__| \w+@)([\d\.]+)/i],[E,x],[/quark(?:pc)?\/([-\w\.]+)/i],[x,[E,"Quark"]],[/\bddg\/([\w\.]+)/i],[x,[E,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[x,[E,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[x,[E,"WeChat"]],[/konqueror\/([\w\.]+)/i],[x,[E,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[x,[E,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[x,[E,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[x,[E,"Smart "+Bt+Je]],[/(avast|avg)\/([\w\.]+)/i],[[E,/(.+)/,"$1 Secure"+Je],x],[/\bfocus\/([\w\.]+)/i],[x,[E,qe+" Focus"]],[/\bopt\/([\w\.]+)/i],[x,[E,Ge+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[x,[E,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[x,[E,"Dolphin"]],[/coast\/([\w\.]+)/i],[x,[E,Ge+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[x,[E,"MIUI"+Je]],[/fxios\/([\w\.-]+)/i],[x,[E,Me+qe]],[/\bqihoobrowser\/?([\w\.]*)/i],[x,[E,"360"]],[/\b(qq)\/([\w\.]+)/i],[[E,/(.+)/,"$1Browser"],x],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[E,/(.+)/,"$1"+Je],x],[/samsungbrowser\/([\w\.]+)/i],[x,[E,ze+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[x,[E,Cn+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[E,Cn+" Mobile"],x],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[E,x],[/(lbbrowser|rekonq)/i],[E],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[x,E],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[E,Xt],x,[g,Le]],[/(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,/(bing)(?:web|sapphire)\/([\w\.]+)/i,/(instagram|snapchat|klarna)[\/ ]([-\w\.]+)/i],[E,x,[g,Le]],[/\bgsa\/([\w\.]+) .*safari\//i],[x,[E,"GSA"],[g,Le]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[x,[E,"TikTok"],[g,Le]],[/\[(linkedin)app\]/i],[E,[g,Le]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[E,/(.+)/,"Zalo"],x,[g,Le]],[/(chromium)[\/ ]([-\w\.]+)/i],[E,x],[/headlesschrome(?:\/([\w\.]+)| )/i],[x,[E,xn+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[x,[E,bt+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[E,xn+" WebView"],x],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[x,[E,"Android"+Je]],[/chrome\/([\w\.]+) mobile/i],[x,[E,Me+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[E,x],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[x,[E,Me+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[E,Me+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[x,E],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[E,[x,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[E,x],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[E,Me+qe],x],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[E,"Netscape"],x],[/(wolvic|librewolf)\/([\w\.]+)/i],[E,x],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[x,[E,qe+" 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|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+(?= .+rv\:.+gecko\/\d+)|[0-4][\w\.]+(?!.+compatible))/i,/(amaya|dillo|doris|icab|ladybird|lynx|mosaic|netsurf|obigo|polaris|w3m|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[E,[x,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[E,[x,/[^\d\.]+./,Re]]],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/,Re,Ae]],[/mc680.0/i],[[ee,"68k"]],[/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,ze],[g,X]],[/\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,ze],[g,B]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[y,[A,Ne],[g,B]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[y,[A,Ne],[g,X]],[/(macintosh);/i],[y,[A,Ne]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[y,[A,Sn],[g,B]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[y,[A,En],[g,X]],[/honor([-\w ]+)[;\)]/i],[y,[A,En],[g,B]],[/\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,vn],[g,X]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[y,[A,vn],[g,B]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b(?:xiao)?((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[y,/_/g," "],[A,Pt],[g,X]],[/\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|max|cc)?[_ ]?(?:\d{0,2}\w?)[_ ]?(?:plus|se|lite|pro)?( 5g|lte)?)(?: bui|\))/i,/ ([\w ]+) miui\/v?\d/i],[[y,/_/g," "],[A,Pt],[g,B]],[/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,An],[g,B]],[/; (\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,Ht],[g,B]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[y,[A,ue,{OnePlus:["203","304","403","404","413","415"],"*":Ht}],[g,X]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[y,[A,"BLU"],[g,B]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[y,[A,"Vivo"],[g,B]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[y,[A,"Realme"],[g,B]],[/(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,Bt],[g,X]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[y,[A,Bt],[g,B]],[/\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,Ut],[g,B]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[y,[A,Ut],[g,X]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[y,[A,mt],[g,X]],[/(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,mt],[g,B]],[/(nokia) (t[12][01])/i],[A,y,[g,X]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[y,/_/g," "],[g,B],[A,"Nokia"]],[/(pixel (c|tablet))\b/i],[y,[A,Ce],[g,X]],[/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,Ce],[g,B]],[/(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,$e],[g,B]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[y,"Xperia Tablet"],[A,$e],[g,X]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[y,[A,gt],[g,X]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[y,/(.+)/g,"Fire Phone $1"],[A,gt],[g,B]],[/(playbook);[-\w\),; ]+(rim)/i],[y,A,[g,X]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[y,[A,yn],[g,B]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[y,[A,wn],[g,X]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[y,[A,wn],[g,B]],[/(nexus 9)/i],[y,[A,"HTC"],[g,X]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[A,[y,/_/g," "],[g,B]],[/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"],[g,X]],[/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"],[g,B]],[/(itel) ((\w+))/i],[[A,Ae],y,[g,ue,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[y,[A,"Acer"],[g,X]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[y,[A,"Meizu"],[g,B]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[y,[A,"Ulefone"],[g,B]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[y,[A,"Energizer"],[g,B]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[y,[A,"Cat"],[g,B]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[y,[A,"Smartfren"],[g,B]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[y,[A,"Nothing"],[g,B]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[y,[A,"Archos"],[g,X]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[y,[A,"Archos"],[g,B]],[/; (n159v)/i],[y,[A,"HMD"],[g,B]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[A,y,[g,X]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus(?! zenw)|dell|jolla|meizu|motorola|polytron|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (blu|hmd|imo|infinix|lava|oneplus|tcl|wiko)[_ ]([\w\+ ]+?)(?: bui|\)|; r)/i,/(hp) ([\w ]+\w)/i,/(microsoft); (lumia[\w ]+)/i,/(oppo) ?([\w ]+) bui/i,/(hisense) ([ehv][\w ]+)\)/i,/droid[^;]+; (philips)[_ ]([sv-x][\d]{3,4}[xz]?)/i],[A,y,[g,B]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[A,y,[g,X]],[/(surface duo)/i],[y,[A,_t],[g,X]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[y,[A,"Fairphone"],[g,B]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[y,[A,Dt],[g,X]],[/(sprint) (\w+)/i],[A,y,[g,B]],[/(kin\.[onetw]{3})/i],[[y,/\./g," "],[A,_t],[g,B]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[y,[A,Vt],[g,X]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[y,[A,Vt],[g,B]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[A,[g,j]],[/hbbtv.+maple;(\d+)/i],[[y,/^/,"SmartTV"],[A,ze],[g,j]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[A,y,[g,j]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[A,mt],[g,j]],[/(apple) ?tv/i],[A,[y,Ne+" TV"],[g,j]],[/crkey.*devicetype\/chromecast/i],[[y,ve+" Third Generation"],[A,Ce],[g,j]],[/crkey.*devicetype\/([^/]*)/i],[[y,/^/,"Chromecast "],[A,Ce],[g,j]],[/fuchsia.*crkey/i],[[y,ve+" Nest Hub"],[A,Ce],[g,j]],[/crkey/i],[[y,ve],[A,Ce],[g,j]],[/(portaltv)/i],[y,[A,Xt],[g,j]],[/droid.+aft(\w+)( bui|\))/i],[y,[A,gt],[g,j]],[/(shield \w+ tv)/i],[y,[A,Dt],[g,j]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[y,[A,Sn],[g,j]],[/(bravia[\w ]+)( bui|\))/i],[y,[A,$e],[g,j]],[/(mi(tv|box)-?\w+) bui/i],[y,[A,Pt],[g,j]],[/Hbbtv.*(technisat) (.*);/i],[A,y,[g,j]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[A,/.+\/(\w+)/,"$1",ue,{LG:"lge"}],[y,vt],[g,j]],[/(playstation \w+)/i],[y,[A,$e],[g,We]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[y,[A,_t],[g,We]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[A,y,[g,We]],[/droid.+; (shield)( bui|\))/i],[y,[A,Dt],[g,We]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[y,[A,ze],[g,de]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[A,y,[g,de]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[y,[A,Ht],[g,de]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[y,[A,Ne],[g,de]],[/(opwwe\d{3})/i],[y,[A,An],[g,de]],[/(moto 360)/i],[y,[A,Ut],[g,de]],[/(smartwatch 3)/i],[y,[A,$e],[g,de]],[/(g watch r)/i],[y,[A,mt],[g,de]],[/droid.+; (wt63?0{2,3})\)/i],[y,[A,Vt],[g,de]],[/droid.+; (glass) \d/i],[y,[A,Ce],[g,ht]],[/(pico) ([\w ]+) os\d/i],[A,y,[g,ht]],[/(quest( \d| pro)?s?).+vr/i],[y,[A,Xt],[g,ht]],[/mobile vr; rv.+firefox/i],[[g,ht]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[A,[g,je]],[/(aeobc)\b/i],[y,[A,gt],[g,je]],[/(homepod).+mac os/i],[y,[A,Ne],[g,je]],[/windows iot/i],[[g,je]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[y,[g,j]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[g,j]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[y,[g,ue,{mobile:"Mobile",xr:"VR","*":X}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[g,X]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[g,B]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[y,[A,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[x,[E,bt+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[E,x],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[x,[E,"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],[E,x],[/ladybird\//i],[[E,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[x,E]],os:[[/(windows nt) (6\.[23]); arm/i],[[E,/N/,"R"],[x,ue,Tn]],[/(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],[E,x],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[x,/(;|\))/g,"",ue,Tn],[E,Ft]],[/(windows ce)\/?([\d\.]*)/i],[E,x],[/[adehimnop]{4,7}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv|ios(?=.+ip(?:ad|hone))|ip(?:ad|hone)(?: |.+i(?:pad)?)os)[\/ ]([\w\.]+)/i,/cfnetwork\/.+darwin/i],[[x,/_/g,"."],[E,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[E,"macOS"],[x,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[x,[E,ve+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[x,[E,ve+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[x,[E,ve+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[x,[E,ve+" Linux"]],[/crkey\/([\d\.]+)/i],[x,[E,ve]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[x,E],[/(ubuntu) ([\w\.]+) like android/i],[[E,/(.+)/,"$1 Touch"],x],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[E,x],[/\(bb(10);/i],[x,[E,yn]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[x,[E,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[x,[E,qe+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[x,[E,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[x,ue,{25:"120",24:"108",23:"94",22:"87",6:"79",5:"68",4:"53",3:"38",2:"538",1:"537","*":"TV"}],[E,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[x,[E,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[E,"Chrome OS"],x],[/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],[E,x],[/(sunos) ?([\d\.]*)/i],[[E,"Solaris"],x],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[E,x]]},Et=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return ge.call(e.init,[[te,[E,x,Ke,g]],[pe,[ee]],[ce,[g,y,A]],[ae,[E,x]],[ie,[E,x]]]),ge.call(e.isIgnore,[[te,[x,Ke]],[ae,[x]],[ie,[x]]]),ge.call(e.isIgnoreRgx,[[te,/ ?browser$/i],[ie,/ ?os$/i]]),ge.call(e.toString,[[te,[E,x]],[pe,[ee]],[ce,[A,y]],[ae,[E,x]],[ie,[E,x]]]),e})(),$i=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(){ge.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Ee?Ee.getHighEntropyValues(bn).then(function(a){return e.setCH(new Ln(a,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=ke&&(s.prototype.is=function(a){var l=!1;for(var c in this)if(this.hasOwnProperty(c)&&!Yt(i,c)&&Ae(o?Be(o,this[c]):this[c])==Ae(o?Be(o,a):a)){if(l=!0,a!=K.UNDEFINED)break}else if(a==K.UNDEFINED&&l){l=!l;break}return l},s.prototype.toString=function(){var a=Re;for(var l in r)typeof this[r[l]]!==K.UNDEFINED&&(a+=(a?" ":Re)+this[r[l]]);return a||K.UNDEFINED}),Ee||(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 Ln(e,t){if(e=e||{},ge.call(this,bn),t)ge.call(this,[[It,Kt(e[ye])],[Nt,Kt(e[Hi])],[B,/\?1/.test(e[Fi])],[y,Ze(e[Yi])],[Ie,Ze(e[mn])],[Mt,Ze(e[Ki])],[ee,Ze(e[Pi])],[Oe,Kt(e[Xi])],[pt,Ze(e[Vi])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==K.UNDEFINED&&(this[n]=e[n])}function In(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(ne&&ne.userAgent==this.ua)switch(this.itemType){case te:ne.brave&&typeof ne.brave.isBrave==K.FUNCTION&&this.set(E,"Brave");break;case ce:!this.get(g)&&Ee&&Ee[B]&&this.set(g,B),this.get(y)=="Macintosh"&&ne&&typeof ne.standalone!==K.UNDEFINED&&ne.maxTouchPoints&&ne.maxTouchPoints>2&&this.set(y,"iPad").set(g,X);break;case ie:!this.get(E)&&Ee&&Ee[Ie]&&this.set(E,Ee[Ie]);break;case ke:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(te,r(te)).set(pe,r(pe)).set(ce,r(ce)).set(ae,r(ae)).set(ie,r(ie))}return this},this.parseUA=function(){switch(this.itemType!=ke&&jt.call(this.data,this.ua,this.rgxMap),this.itemType){case te:this.set(Ke,Wt(this.get(x)));break;case ie:if(this.get(E)=="iOS"&&this.get(x)=="18.6"){var o=/\) Version\/([\d\.]+)/.exec(this.ua);o&&parseInt(o[1].substring(0,2),10)>=26&&this.set(x,o[1])}break}return this},this.parseCH=function(){var o=this.uaCH,r=this.rgxMap;switch(this.itemType){case te:case ae:var s=o[Nt]||o[It],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],u=s[l].version;this.itemType==te&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=On||a==bt&&/WebView2/.test(c))&&(c=ue(c,zi),a=this.get(E),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(E,c).set(x,u).set(Ke,Wt(u)),a=c),this.itemType==ae&&c==On&&this.set(x,u)}break;case pe:var d=o[ee];d&&(d&&o[pt]=="64"&&(d+="64"),jt.call(this.data,d+";",r));break;case ce:if(o[B]&&this.set(g,B),o[y]&&(this.set(y,o[y]),!this.get(g)||!this.get(A))){var S={};jt.call(S,"droid 9; "+o[y]+")",r),!this.get(g)&&S.type&&this.set(g,S.type),!this.get(A)&&S.vendor&&this.set(A,S.vendor)}if(o[Oe]){var p;if(typeof o[Oe]!="string")for(var O=0;!p&&O<o[Oe].length;)p=ue(o[Oe][O++],Rn);else p=ue(o[Oe],Rn);this.set(g,p)}break;case ie:var h=o[Ie];if(h){var T=o[Mt];h==Ft&&(T=parseInt(Wt(T),10)>=13?"11":"10"),this.set(E,h).set(x,T)}this.get(E)==Ft&&o[y]=="Xbox"&&this.set(E,"Xbox").set(x,void 0);break;case ke:var v=this.data,f=function(b){return v[b].getItem().setCH(o).parseCH().get()};this.set(te,f(te)).set(pe,f(pe)).set(ce,f(ce)).set(ae,f(ae)).set(ie,f(ie))}return this},ge.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",$i(this,e)]]),this}function me(e,t,n){if(typeof e===K.OBJECT?(yt(e,!0)?(typeof t===K.OBJECT&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===K.STRING&&!yt(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===K.FUNCTION){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 me))return new me(e,t,n).getResult();var s=typeof e===K.STRING?e:n&&n[pn]?n[pn]:ne&&ne.userAgent?ne.userAgent:Re,a=new Ln(n,!0),l=t?ji(kn,t):kn,c=function(u){return u==ke?function(){return new In(u,s,l,a).set("ua",s).set(te,this.getBrowser()).set(pe,this.getCPU()).set(ce,this.getDevice()).set(ae,this.getEngine()).set(ie,this.getOS()).get()}:function(){return new In(u,s,l[u],a).parseUA().get()}};return ge.call(this,[["getBrowser",c(te)],["getCPU",c(pe)],["getDevice",c(ce)],["getEngine",c(ae)],["getOS",c(ie)],["getResult",c(ke)],["getUA",function(){return s}],["setUA",function(u){return Qe(u)&&(s=vt(u,Di)),this}]]).setUA(s),this}me.VERSION=Ui,me.BROWSER=wt([E,x,Ke,g]),me.CPU=wt([ee]),me.DEVICE=wt([y,A,g,We,B,j,X,de,je]),me.ENGINE=me.OS=wt([E,x]);const qi=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"}),Nn=me().os.is(qi.MACOS),Mn=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Bn=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();if(s.selectNode(o),e.startContainer.nodeType===Node.TEXT_NODE)s.setStart(o,e.startOffset);else{const c=e.startContainer.childNodes[e.startOffset];c?s.setStartBefore(c):s.setStartAfter(e.startContainer)}const a=document.createRange();if(a.selectNode(r),e.endContainer.nodeType===Node.TEXT_NODE)a.setEnd(r,e.endOffset);else{const c=e.endContainer.childNodes[e.endOffset];c?a.setEndBefore(c):a.setEndAfter(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())]}},Gi=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)},_n=(e,t)=>{if(!fn(e,t))return[];const n=[];let i=null;for(const o of Gi(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]},At=e=>{const t=e.cloneContents();return t.querySelectorAll(xe).forEach(n=>n.remove()),t},Un=(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=At(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=At(a).textContent;return{prefix:s.substring(s.length-n),suffix:l.substring(0,n)}},fe=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),zt=/^\s*$/,Dn=e=>zt.test(e.toString()),Ji=e=>zt.test(e.textContent||""),Qi=(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"},Zi=(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)},Hn=(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=Qi(o,a,t,n);if(l==="inline-adjacent"){r=r.map(c=>c===a?Zi(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]},[]),eo=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Pn=(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=At(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}},Vn=(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)},to=(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)},$t=(e,t)=>{var u,d;const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,S=>{var p;return(p=S.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 S=((u=l.textContent)==null?void 0:u.length)||0;if(s+S>n){a.setStart(l,n-s);break}s+=S}l=r.nextNode()}for(;l!==null;){const S=((d=l.textContent)==null?void 0:d.length)||0;if(s+S>=i){a.setEnd(l,i-s);break}s+=S,l=r.nextNode()}return{...e,range:a}},et=(e,t)=>fe(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:$t(n,t))},St=(e,t)=>fe(e.target.selector)?e:{...e,target:et(e.target,t)},Xn=(e,t)=>{const n=e.cloneRange();return t.contains(n.startContainer)||n.setStart(t,0),t.contains(n.endContainer)||n.setEnd(t,t.childNodes.length),n},Fn=e=>{if(!e)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:Fn(e.parentElement)},Yn=(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,S=n.parentElement?n.scrollLeft:0,p=c+d-(o-l)/2,O=u+S-(r-a)/2;n.scroll({top:p,left:O,behavior:"smooth"})},Kn=(e,t)=>(n,i)=>{const o=typeof n=="string"?n:n.id,r=i?typeof i=="string"?document.getElementById(i):i:Fn(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 Yn(t,s.target,r),!0;const l=et(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?(Yn(t,l,r),!0):!1},he={fill:"rgb(0, 128, 255)",fillOpacity:.18},tt={fill:"rgb(0, 128, 255)",fillOpacity:.45},Wn=(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?tt:he):n:(a=e.state)!=null&&a.selected?tt:he;return i&&i.paint(e,t)||r};function no(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xt={exports:{}},jn;function io(){if(jn)return xt.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,O=s;return r=void 0,s=void 0,c=t.apply(p,O),c}function d(){const p=Date.now()-l;p<n&&p>=0?a=setTimeout(d,n-p):(a=void 0,o||(c=u()))}const S=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 O=o&&!a;return a||(a=setTimeout(d,n)),O&&(c=u()),c};return Object.defineProperty(S,"isPending",{get(){return a!==void 0}}),S.clear=()=>{a&&(clearTimeout(a),a=void 0)},S.flush=()=>{a&&S.trigger()},S.trigger=()=>{c=u(),S.clear()},S}return xt.exports.debounce=e,xt.exports=e,xt.exports}var oo=io();const _e=no(oo),ro=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}},so=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=so(n),d=_e(_=>{const{x:W,y:Z}=e.getBoundingClientRect(),C=o.getAt(_.clientX-W,_.clientY-Z,!1,l);C?s.current!==C.id&&(e.classList.add("hovered"),s.set(C.id)):s.current&&(e.classList.remove("hovered"),s.set(null))},10);e.addEventListener("pointermove",d);const S=_e((_=!1)=>requestAnimationFrame(()=>{c&&c.clear();const W=ro(e),{minX:Z,minY:C,maxX:m,maxY:w}=W,L=l?o.getIntersecting(Z,C,m,w).filter(({annotation:H})=>l(H)):o.getIntersecting(Z,C,m,w),V=r.selected.map(({id:H})=>H),D=L.map(({annotation:H,rects:$})=>{const q=V.includes(H.id),Ve=H.id===s.current;return{annotation:H,rects:$,state:{selected:q,hovered:Ve}}});i.redraw(D,W,a,c,_),setTimeout(()=>u(L.map(({annotation:H})=>H)),1)}),10),p=_=>{c=_,S()},O=_=>{a=_,S()},h=_=>{l=_,S(!1)},T=()=>S();o.observe(T);const v=r.subscribe(()=>S()),f=s.subscribe(()=>S()),b=()=>S(!0);document.addEventListener("scroll",b,{capture:!0,passive:!0});const k=_e(()=>{o.recalculatePositions(),c==null||c.reset(),S()},10);window.addEventListener("resize",k);const R=new ResizeObserver(k);R.observe(e);const N={attributes:!0,childList:!0,subtree:!0},I=new MutationObserver(_e(_=>{_.every(Z=>Z.target===e||e.contains(Z.target))||S(!0)},150));return I.observe(document.body,N),{destroy:()=>{e.removeEventListener("pointermove",d),i.destroy(),o.unobserve(T),v(),f(),document.removeEventListener("scroll",b),k.clear(),window.removeEventListener("resize",k),R.disconnect(),I.disconnect()},redraw:S,setStyle:O,setFilter:h,setPainter:p,setVisible:i.setVisible}},ao=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},lo=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},co=e=>{e.classList.add("r6o-annotatable");const t=ao(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,u)=>requestAnimationFrame(()=>{const{width:d,height:S}=t;n.clearRect(-.5,-.5,d+1,S+1),u&&u.clear();const{top:p,left:O}=l;[...a].sort((T,v)=>{const{annotation:{target:{created:f}}}=T,{annotation:{target:{created:b}}}=v;return f.getTime()-b.getTime()}).forEach(T=>{var k;const v=c?typeof c=="function"?c(T.annotation,T.state):c:(k=T.state)!=null&&k.selected?tt:he,f=u&&u.paint(T,l)||v,b=T.rects.map(({x:R,y:N,width:I,height:U})=>({x:R+O,y:N+p,width:I,height:U}));if(n.fillStyle=f.fill,n.globalAlpha=f.fillOpacity||1,b.forEach(({x:R,y:N,width:I,height:U})=>n.fillRect(R,N,I,U)),f.underlineColor){n.globalAlpha=1,n.strokeStyle=f.underlineColor,n.lineWidth=f.underlineThickness??1;const R=f.underlineOffset??0;b.forEach(({x:N,y:I,width:U,height:_})=>{n.beginPath(),n.moveTo(N,I+_+R),n.lineTo(N+U,I+_+R),n.stroke()})}})}),o=_e(()=>lo(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}},zn=(e,t,n)=>qt(e,t,n,co(e));var uo={grad:.9,turn:360,rad:360/(2*Math.PI)},be=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},oe=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},$n=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},qn=function(e){return{r:oe(e.r,0,255),g:oe(e.g,0,255),b:oe(e.b,0,255),a:oe(e.a)}},Gt=function(e){return{r:z(e.r),g:z(e.g),b:z(e.b),a:z(e.a,3)}},fo=/^#([0-9a-f]{3,8})$/i,Ot=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Gn=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}},Jn=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}},Qn=function(e){return{h:$n(e.h),s:oe(e.s,0,100),l:oe(e.l,0,100),a:oe(e.a)}},Zn=function(e){return{h:z(e.h),s:z(e.s),l:z(e.l),a:z(e.a,3)}},ei=function(e){return Jn((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},nt=function(e){return{h:(t=Gn(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},ho=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,po=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,go=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,mo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ti={string:[[function(e){var t=fo.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=go.exec(e)||mo.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:qn({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=ho.exec(e)||po.exec(e);if(!t)return null;var n,i,o=Qn({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*(uo[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ei(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 be(t)&&be(n)&&be(i)?qn({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(!be(t)||!be(n)||!be(i))return null;var s=Qn({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return ei(s)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,o=e.a,r=o===void 0?1:o;if(!be(t)||!be(n)||!be(i))return null;var s=(function(a){return{h:$n(a.h),s:oe(a.s,0,100),v:oe(a.v,0,100),a:oe(a.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(r)});return Jn(s)},"hsv"]]},ni=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]},bo=function(e){return typeof e=="string"?ni(e.trim(),ti.string):typeof e=="object"&&e!==null?ni(e,ti.object):[null,void 0]},Jt=function(e,t){var n=nt(e);return{h:n.h,s:oe(n.s+100*t,0,100),l:n.l,a:n.a}},Qt=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},ii=function(e,t){var n=nt(e);return{h:n.h,s:n.s,l:oe(n.l+100*t,0,100),a:n.a}},oi=(function(){function e(t){this.parsed=bo(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(Qt(this.rgba),2)},e.prototype.isDark=function(){return Qt(this.rgba)<.5},e.prototype.isLight=function(){return Qt(this.rgba)>=.5},e.prototype.toHex=function(){return t=Gt(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?Ot(z(255*r)):"","#"+Ot(n)+Ot(i)+Ot(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return Gt(this.rgba)},e.prototype.toRgbString=function(){return t=Gt(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 Zn(nt(this.rgba))},e.prototype.toHslString=function(){return t=Zn(nt(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=Gn(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 re({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),re(Jt(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),re(Jt(this.rgba,-t))},e.prototype.grayscale=function(){return re(Jt(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),re(ii(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),re(ii(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"?re({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=nt(this.rgba);return typeof t=="number"?re({h:t,s:n.s,l:n.l,a:n.a}):z(n.h)},e.prototype.isEqual=function(t){return this.toHex()===re(t).toHex()},e})(),re=function(e){return e instanceof oi?e:new oi(e)};const wo=e=>[`background-color:${re((e==null?void 0:e.fill)||he.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?he.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(";"),ri=()=>{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 O;const S=a?typeof a=="function"?a(d.annotation,d.state):a:(O=d.state)!=null&&O.selected?tt:he,p=l&&l.paint(d,s)||S;return`::highlight(_${d.annotation.id}) { ${wo(p)} }`});e.innerHTML=u.join(`
|
|
2
|
+
`),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const S=d.target.selector.map(O=>O.range),p=new Highlight(...S);CSS.highlights.set(`_${d.id}`,p)}),t=c}}},si=(e,t,n)=>qt(e,t,n,ri());var ai=Object.prototype.hasOwnProperty;function Zt(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--&&Zt(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(ai.call(e,n)&&++i&&!ai.call(t,n)||!(n in t)||!Zt(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const yo=e=>(e==null?void 0:e.fillOpacity)!==void 0?re((e==null?void 0:e.fill)||he.fill).alpha(e.fillOpacity).toHex():e!=null&&e.fill?e.fill:re(he.fill).alpha(he.fillOpacity).toHex(),vo=(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))},Eo=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 S=!(Zt(n,s)&&u);if(!c&&!S)return;S&&(t.innerHTML=""),[...s].sort((O,h)=>{const{annotation:{target:{created:T}}}=O,{annotation:{target:{created:v}}}=h;return T&&v?T.getTime()-v.getTime():0}).forEach(O=>{O.rects.map(h=>{const T=vo(h,s),v=Wn(O,a,l,c,T);if(S){const f=document.createElement("span");f.className="r6o-annotation",f.dataset.annotation=O.annotation.id,f.style.left=`${h.x}px`,f.style.top=`${h.y}px`,f.style.width=`${h.width}px`,f.style.height=`${h.height}px`,f.style.backgroundColor=yo(v),v.underlineStyle&&(f.style.borderStyle=v.underlineStyle),v.underlineColor&&(f.style.borderColor=v.underlineColor),v.underlineThickness&&(f.style.borderBottomWidth=`${v.underlineThickness}px`),v.underlineOffset&&(f.style.paddingBottom=`${v.underlineOffset}px`),t.appendChild(f)}})}),n=s},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},li=(e,t,n)=>qt(e,t,n,Eo(e)),G=[];for(let e=0;e<256;++e)G.push((e+256).toString(16).slice(1));function Ao(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 en;const So=new Uint8Array(16);function xo(){if(!en){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");en=crypto.getRandomValues.bind(crypto)}return en(So)}const ci={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Oo(e,t,n){var o;e=e||{};const i=e.random??((o=e.rng)==null?void 0:o.call(e))??xo();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,Ao(i)}function di(e,t,n){return ci.randomUUID&&!e?ci.randomUUID():Oo(e)}var ui=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(ui.call(e,n)&&++i&&!ui.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 tn(){}function Co(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const Ue=[];function nn(e,t=tn){let n;const i=new Set;function o(a){if(Co(e,a)&&(e=a,n)){const l=!Ue.length;for(const c of i)c[1](),Ue.push(c,e);if(l){for(let c=0;c<Ue.length;c+=2)Ue[c][0](Ue[c+1]);Ue.length=0}}}function r(a){o(a(e))}function s(a,l=tn){const c=[a,l];return i.add(c),i.size===1&&(n=t(o,r)||tn),a(e),()=>{i.delete(c),i.size===0&&n&&(n(),n=null)}}return{set:o,update:r,subscribe:s}}const To=e=>{const{subscribe:t,set:n}=nn();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 fi=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(fi||{});const Ct={selected:[]},Ro=(e,t,n)=>{const{subscribe:i,set:o}=nn(Ct);let r=t,s=Ct;i(h=>s=h);const a=()=>{Te(s,Ct)||o(Ct)},l=()=>{var h;return((h=s.selected)==null?void 0:h.length)===0},c=h=>{if(l())return!1;const T=typeof h=="string"?h:h.id;return s.selected.some(v=>v.id===T)},u=(h,T)=>{let v;if(Array.isArray(h)){if(v=h.map(b=>e.getAnnotation(b)).filter(Boolean),v.length<h.length){console.warn("Invalid selection: "+h.filter(b=>!v.some(k=>k.id===b)));return}}else{const b=e.getAnnotation(h);if(!b){console.warn("Invalid selection: "+h);return}v=[b]}const f=v.reduce((b,k)=>{const R=O(k);return R==="EDIT"?[...b,{id:k.id,editable:!0}]:R==="SELECT"?[...b,{id:k.id}]:b},[]);o({selected:f,event:T})},d=(h,T)=>{const v=Array.isArray(h)?h:[h],f=v.map(b=>e.getAnnotation(b)).filter(b=>!!b);o({selected:f.map(b=>{const k=T===void 0?O(b)==="EDIT":T;return{id:b.id,editable:k}})}),f.length!==v.length&&console.warn("Invalid selection",h)},S=h=>{if(l())return!1;const{selected:T}=s;T.some(({id:v})=>h.includes(v))&&o({selected:T.filter(({id:v})=>!h.includes(v))})},p=h=>{r=h,d(s.selected.map(({id:T})=>T))},O=h=>ko(h,r,n);return e.observe(({changes:h})=>S((h.deleted||[]).map(T=>T.id))),{get event(){return s?s.event:null},get selected(){return s?[...s.selected]:null},get userSelectAction(){return r},clear:a,evalSelectAction:O,isEmpty:l,isSelected:c,setSelected:d,setUserSelectAction:p,subscribe:i,userSelect:u}},ko=(e,t,n)=>{const i=n?n.serialize(e):e;return typeof t=="function"?t(i):t||"EDIT"},J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));function Lo(e,t=0){return(J[e[t+0]]+J[e[t+1]]+J[e[t+2]]+J[e[t+3]]+"-"+J[e[t+4]]+J[e[t+5]]+"-"+J[e[t+6]]+J[e[t+7]]+"-"+J[e[t+8]]+J[e[t+9]]+"-"+J[e[t+10]]+J[e[t+11]]+J[e[t+12]]+J[e[t+13]]+J[e[t+14]]+J[e[t+15]]).toLowerCase()}let on;const Io=new Uint8Array(16);function No(){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(Io)}const Mo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),hi={randomUUID:Mo};function Bo(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??No();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,Lo(o)}function pi(e,t,n){return hi.randomUUID&&!e?hi.randomUUID():Bo(e)}const rn=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)}},_o=(e,t,n,i)=>({id:pi(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),Uo=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},Do=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},Ho=(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})),Po=(e,t)=>!Te(e.target,t.target),gi=(e,t)=>{const n=Uo(e,t),i=Do(e,t),o=Ho(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:Po(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var P=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e.SILENT="SILENT",e))(P||{});const Vo=(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},Xo=(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:S})=>S.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:S,newValue:p}=d;if(s.has(p.id)){const O=t.updated.find(h=>h.oldValue.id===p.id).newValue;return gi(S,O)}else return d}),...(t.updated||[]).filter(({oldValue:d})=>!a.has(d.id))];return{created:l,deleted:c,updated:u}},Tt=e=>{const t=e.id===void 0?pi():e.id;return{...e,id:t,bodies:e.bodies===void 0?[]:e.bodies.map(n=>({...n,annotation:t})),target:{...e.target,annotation:t}}},Fo=e=>e.id!==void 0,Yo=()=>{const e=new Map,t=new Map,n=[],i=(C,m={})=>{n.push({onChange:C,options:m})},o=C=>{const m=n.findIndex(w=>w.onChange==C);m>-1&&n.splice(m,1)},r=(C,m)=>{const w={origin:C,changes:{created:m.created||[],updated:m.updated||[],deleted:m.deleted||[]},state:[...e.values()]};n.forEach(L=>{Vo(L,w)&&L.onChange(w)})},s=(C,m=P.LOCAL)=>{if(C.id&&e.get(C.id))throw Error(`Cannot add annotation ${C.id} - exists already`);{const w=Tt(C);e.set(w.id,w),w.bodies.forEach(L=>t.set(L.id,w.id)),r(m,{created:[w]})}},a=(C,m)=>{const w=Tt(typeof C=="string"?m:C),L=typeof C=="string"?C:C.id,V=L&&e.get(L);if(V){const D=gi(V,w);return L===w.id?e.set(L,w):(e.delete(L),e.set(w.id,w)),V.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=(C,m=P.LOCAL,w=P.LOCAL)=>{const L=Fo(m)?w:m,V=a(C,m);V&&r(L,{updated:[V]})},c=(C,m=P.LOCAL)=>{e.get(C.id)?l(C,m):s(C,m)},u=(C,m=P.LOCAL)=>{const w=C.reduce((L,V)=>{const D=a(V);return D?[...L,D]:L},[]);w.length>0&&r(m,{updated:w})},d=(C,m=P.LOCAL)=>{const w=C.map(Tt),{toAdd:L,toUpdate:V}=w.reduce((H,$)=>e.get($.id)?{...H,toUpdate:[...H.toUpdate,$]}:{...H,toAdd:[...H.toAdd,$]},{toAdd:[],toUpdate:[]}),D=V.map(H=>a(H,m)).filter(Boolean);L.forEach(H=>{e.set(H.id,H),H.bodies.forEach($=>t.set($.id,H.id))}),r(m,{created:L,updated:D})},S=(C,m=P.LOCAL)=>{const w=e.get(C.annotation);if(w){const L={...w,bodies:[...w.bodies,C]};e.set(w.id,L),t.set(C.id,L.id),r(m,{updated:[{oldValue:w,newValue:L,bodiesCreated:[C]}]})}else console.warn(`Attempt to add body to missing annotation: ${C.annotation}`)},p=()=>[...e.values()],O=(C=P.LOCAL)=>{const m=[...e.values()];e.clear(),t.clear(),r(C,{deleted:m})},h=(C,m=!0,w=P.LOCAL)=>{const L=C.map(Tt);if(m){const V=[...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:V})}else{const V=C.reduce((D,H)=>{const $=H.id&&e.get(H.id);return $?[...D,$]:D},[]);if(V.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${V.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})}},T=C=>{const m=typeof C=="string"?C:C.id,w=e.get(m);if(w)return e.delete(m),w.bodies.forEach(L=>t.delete(L.id)),w;console.warn(`Attempt to delete missing annotation: ${m}`)},v=(C,m=P.LOCAL)=>{const w=T(C);w&&r(m,{deleted:[w]})},f=(C,m=P.LOCAL)=>{const w=C.reduce((L,V)=>{const D=T(V);return D?[...L,D]:L},[]);w.length>0&&r(m,{deleted:w})},b=C=>{const m=e.get(C.annotation);if(m){const w=m.bodies.find(L=>L.id===C.id);if(w){t.delete(w.id);const L={...m,bodies:m.bodies.filter(V=>V.id!==C.id)};return e.set(m.id,L),{oldValue:m,newValue:L,bodiesDeleted:[w]}}else console.warn(`Attempt to delete missing body ${C.id} from annotation ${C.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${C.annotation}`)},k=(C,m=P.LOCAL)=>{const w=b(C);w&&r(m,{updated:[w]})},R=(C,m=P.LOCAL)=>{const w=C.map(L=>b(L)).filter(Boolean);w.length>0&&r(m,{updated:w})},N=C=>{const m=e.get(C);return m?{...m}:void 0},I=C=>{const m=t.get(C);if(m){const w=N(m).bodies.find(L=>L.id===C);if(w)return w;console.error(`Store integrity error: body ${C} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${C}`)},U=(C,m)=>{if(C.annotation!==m.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const w=e.get(C.annotation);if(w){const L=w.bodies.find(D=>D.id===C.id),V={...w,bodies:w.bodies.map(D=>D.id===L.id?m:D)};return e.set(w.id,V),L.id!==m.id&&(t.delete(L.id),t.set(m.id,V.id)),{oldValue:w,newValue:V,bodiesUpdated:[{oldBody:L,newBody:m}]}}else console.warn(`Attempt to add body to missing annotation ${C.annotation}`)},_=(C,m,w=P.LOCAL)=>{const L=U(C,m);L&&r(w,{updated:[L]})},W=(C,m=P.LOCAL)=>{const w=C.map(L=>U({id:L.id,annotation:L.annotation},L)).filter(Boolean);r(m,{updated:w})},Z=C=>{const m=e.get(C.annotation);if(m){const w={...m,target:{...m.target,...C}};return e.set(m.id,w),{oldValue:m,newValue:w,targetUpdated:{oldTarget:m.target,newTarget:C}}}else console.warn(`Attempt to update target on missing annotation: ${C.annotation}`)};return{addAnnotation:s,addBody:S,all:p,bulkAddAnnotations:h,bulkDeleteAnnotations:f,bulkDeleteBodies:R,bulkUpdateAnnotations:u,bulkUpdateBodies:W,bulkUpdateTargets:(C,m=P.LOCAL)=>{const w=C.map(L=>Z(L)).filter(Boolean);w.length>0&&r(m,{updated:w})},bulkUpsertAnnotations:d,clear:O,deleteAnnotation:v,deleteBody:k,getAnnotation:N,getBody:I,observe:i,unobserve:o,updateAnnotation:l,updateBody:_,updateTarget:(C,m=P.LOCAL)=>{const w=Z(C);w&&r(m,{updated:[w]})},upsertAnnotation:c}};let Ko=()=>({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 Wo=250,jo=(e,t)=>{const n=Ko(),i=[];let o=-1,r=!1,s=0;const a=O=>{if(!r){const{changes:h}=O,T=performance.now();if(T-s>Wo)i.splice(o+1),i.push(h),o=i.length-1;else{const v=i.length-1;i[v]=Xo(i[v],h)}s=T}r=!1};e.observe(a,{origin:P.LOCAL});const l=O=>O&&O.length>0&&e.bulkDeleteAnnotations(O),c=O=>O&&O.length>0&&e.bulkAddAnnotations(O,!1),u=O=>O&&O.length>0&&e.bulkUpdateAnnotations(O.map(({oldValue:h})=>h)),d=O=>O&&O.length>0&&e.bulkUpdateAnnotations(O.map(({newValue:h})=>h)),S=O=>O&&O.length>0&&e.bulkAddAnnotations(O,!1),p=O=>O&&O.length>0&&e.bulkDeleteAnnotations(O);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(O,h)=>n.on(O,h),redo:()=>{if(i.length-1>o){r=!0;const{created:O,updated:h,deleted:T}=i[o+1];c(O),d(h),p(T),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:O,updated:h,deleted:T}=i[o];l(O),u(h),S(T),n.emit("undo",i[o]),o-=1}}}},zo=()=>{const{subscribe:e,set:t}=nn([]);return{subscribe:e,set:t}},$o=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],u;const d=(h,T)=>{l.has(h)?l.get(h).push(T):l.set(h,[T])},S=(h,T)=>{const v=l.get(h);if(v){const f=v.indexOf(T);f!==-1&&v.splice(f,1)}},p=(h,T,v)=>{l.has(h)&&setTimeout(()=>{l.get(h).forEach(f=>{if(n){const b=Array.isArray(T)?T.map(R=>n.serialize(R)):n.serialize(T),k=v?v instanceof PointerEvent?v:n.serialize(v):void 0;f(b,k)}else f(T,v)})},1)};r.subscribe(({selected:h})=>{if(!(c.length===0&&h.length===0)){if(c.length===0&&h.length>0)c=h.map(({id:T})=>s.getAnnotation(T));else if(c.length>0&&h.length===0)c.forEach(T=>{const v=s.getAnnotation(T.id);v&&!Te(v,T)&&p("updateAnnotation",v,T)}),c=[];else{const T=new Set(c.map(f=>f.id)),v=new Set(h.map(({id:f})=>f));c.filter(f=>!v.has(f.id)).forEach(f=>{const b=s.getAnnotation(f.id);b&&!Te(b,f)&&p("updateAnnotation",b,f)}),c=[...c.filter(f=>v.has(f.id)),...h.filter(({id:f})=>!T.has(f)).map(({id:f})=>s.getAnnotation(f))]}p("selectionChanged",c)}}),o.subscribe(h=>{!u&&h?p("mouseEnterAnnotation",s.getAnnotation(h)):u&&!h?p("mouseLeaveAnnotation",s.getAnnotation(u)):u&&h&&(p("mouseLeaveAnnotation",s.getAnnotation(u)),p("mouseEnterAnnotation",s.getAnnotation(h))),u=h}),a==null||a.subscribe(h=>p("viewportIntersect",h.map(T=>s.getAnnotation(T)))),s.observe(h=>{const{created:T,deleted:v}=h.changes;(T||[]).forEach(f=>p("createAnnotation",f)),(v||[]).forEach(f=>p("deleteAnnotation",f)),(h.changes.updated||[]).filter(f=>[...f.bodiesCreated||[],...f.bodiesDeleted||[],...f.bodiesUpdated||[]].length>0).forEach(({oldValue:f,newValue:b})=>{const k=c.find(R=>R.id===f.id)||f;c=c.map(R=>R.id===f.id?b:R),p("updateAnnotation",b,k)})},{origin:P.LOCAL}),s.observe(h=>{if(c){const T=new Set(c.map(f=>f.id)),v=(h.changes.updated||[]).filter(({newValue:f})=>T.has(f.id)).map(({newValue:f})=>f);v.length>0&&(c=c.map(f=>v.find(k=>k.id===f.id)||f))}},{origin:P.REMOTE});const O=h=>T=>{const{updated:v}=T;h?(v||[]).forEach(f=>p("updateAnnotation",f.oldValue,f.newValue)):(v||[]).forEach(f=>p("updateAnnotation",f.newValue,f.oldValue))};return t.on("undo",O(!0)),t.on("redo",O(!1)),{on:d,off:S,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:[]}),Go=(e,t,n)=>{const{store:i,selection:o}=e,r=v=>{if(n){const{parsed:f,error:b}=n.parse(v);f?i.addAnnotation(f,P.REMOTE):console.error(b)}else i.addAnnotation(rn(v),P.REMOTE)},s=()=>o.clear(),a=()=>i.clear(),l=v=>{const f=i.getAnnotation(v);return n&&f?n.serialize(f):f},c=()=>n?i.all().map(n.serialize):i.all(),u=()=>{var v;const f=(((v=o.selected)==null?void 0:v.map(b=>b.id))||[]).map(b=>i.getAnnotation(b)).filter(Boolean);return n?f.map(n.serialize):f},d=(v,f=!0)=>fetch(v).then(b=>b.json()).then(b=>(p(b,f),b)),S=v=>{if(typeof v=="string"){const f=i.getAnnotation(v);if(i.deleteAnnotation(v),f)return n?n.serialize(f):f}else{const f=n?n.parse(v).parsed:v;if(f)return i.deleteAnnotation(f),v}},p=(v,f=!0)=>{if(n){const b=n.parseAll||qo(n),{parsed:k,failed:R}=b(v);R.length>0&&console.warn(`Discarded ${R.length} invalid annotations`,R),i.bulkAddAnnotations(k,f,P.REMOTE)}else i.bulkAddAnnotations(v.map(rn),f,P.REMOTE)},O=(v,f)=>{v?o.setSelected(v,f):o.clear()},h=v=>{o.setUserSelectAction(v)},T=v=>{if(n){const f=n.parse(v).parsed,b=n.serialize(i.getAnnotation(f.id));return i.updateAnnotation(f),b}else{const f=i.getAnnotation(v.id);return i.updateAnnotation(rn(v)),f}};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:S,setAnnotations:p,setSelected:O,setUserSelectAction:h,undo:t.undo,updateAnnotation:T}},Jo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Qo=e=>crypto.getRandomValues(new Uint8Array(e)),Zo=(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}}},er=(e,t=21)=>Zo(e,t|0,Qo),tr=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Jo[n[e]&63];return t};const nr=()=>({isGuest:!0,id:er("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),ir=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}`},mi=e=>e?typeof e=="object"?{...e}:e:void 0,or=(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-${ir(n)}`,annotation:t,type:o,purpose:r,value:s,creator:mi(c),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),rr=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});tr();const sr=(e,t)=>({parse:n=>bi(n),serialize:n=>wi(n,e,t)}),ar=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,lr=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:mi(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,S)=>{switch(S.type){case"TextQuoteSelector":d.quote=S.exact;break;case"TextPositionSelector":d.start=S.start,d.end=S.end;break}return d},{});if(ar(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}},bi=e=>{const t=e.id||di(),{creator:n,created:i,modified:o,body:r,...s}=e,a=or(r,t),l=lr(e);return"error"in l?{error:l.error}:{parsed:{...s,id:t,bodies:a,target:l.parsed}}},wi=(e,t,n)=>{const{bodies:i,target:o,...r}=e,{selector:s,creator:a,created:l,updated:c,...u}=o,d=s.map(S=>{const{id:p,quote:O,start:h,end:T,range:v}=S,f={type:"TextQuoteSelector",exact:O};if(n){const{prefix:k,suffix:R}=Un(v,n);f.prefix=k,f.suffix=R}const b={type:"TextPositionSelector",start:h,end:T};return{...u,id:p,scope:"scope"in S?S.scope:void 0,source:t,selector:[f,b]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:rr(e.bodies),creator:a,created:l==null?void 0:l.toISOString(),modified:c==null?void 0:c.toISOString(),target:d}};function yi(e,t,n=0,i=e.length-1,o=cr){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),S=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),p=Math.max(n,Math.floor(t-c*d/l+S)),O=Math.min(i,Math.floor(t+(l-c)*d/l+S));yi(e,t,p,O,o)}const r=e[t];let s=n,a=i;for(it(e,n,t),o(e[i],r)>0&&it(e,n,i);s<a;){for(it(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?it(e,n,a):(a++,it(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function it(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function cr(e,t){return e<t?-1:e>t?1:0}class dr{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(!kt(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;kt(t,l)&&(n.leaf?i.push(a):an(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!kt(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(kt(t,s)){if(n.leaf||an(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=He([]),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=ur(t,i.children,n);if(u!==-1)return i.children.splice(u,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&an(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=He(t.slice(n,i+1)),De(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=He([]),a.leaf=!1,a.height=o;const l=Math.ceil(r/s),c=l*Math.ceil(Math.sqrt(s));vi(t,n,i,c,this.compareMinX);for(let u=n;u<=i;u+=c){const d=Math.min(u+c-1,i);vi(t,u,d,l,this.compareMinY);for(let S=u;S<=d;S+=l){const p=Math.min(S+l-1,d);a.children.push(this._build(t,S,p,o-1))}}return De(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=sn(c),d=pr(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),rt(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=He(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,De(i,this.toBBox),De(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=He([t,n]),this.data.height=t.height+1,this.data.leaf=!1,De(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=ot(t,0,a,this.toBBox),c=ot(t,a,i,this.toBBox),u=gr(l,c),d=sn(l)+sn(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:fr,r=t.leaf?this.compareMinY:hr,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=ot(t,0,n,r),a=ot(t,i-n,i,r);let l=Rt(s)+Rt(a);for(let c=n;c<i-n;c++){const u=t.children[c];rt(s,t.leaf?r(u):u),l+=Rt(s)}for(let c=i-n-1;c>=n;c--){const u=t.children[c];rt(a,t.leaf?r(u):u),l+=Rt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)rt(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():De(t[n],this.toBBox)}}function ur(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 De(e,t){ot(e,0,e.children.length,t,e)}function ot(e,t,n,i,o){o||(o=He(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];rt(o,e.leaf?i(s):s)}return o}function rt(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 fr(e,t){return e.minX-t.minX}function hr(e,t){return e.minY-t.minY}function sn(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Rt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function pr(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 gr(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 an(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function kt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function He(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function vi(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;yi(e,s,t,n,o),r.push(t,s,s,n)}}const mr=(e,t,n,i)=>{const o=new dr,r=new Map,s=(b,k)=>{const R=b.selector.flatMap(I=>{const U=fe([I])?I.range:$t(I,t).range;return Bn(U)}),N=Hn(R,n,i).map(I=>Vn(I,k));return N.map(I=>{const{x:U,y:_,width:W,height:Z}=I;return{minX:U,minY:_,maxX:U+W,maxY:_+Z,annotation:{id:b.annotation,rects:N}}})},a=()=>[...r.values()],l=()=>{o.clear(),r.clear()},c=b=>{const k=s(b,t.getBoundingClientRect());k.length!==0&&(k.forEach(R=>o.insert(R)),r.set(b.annotation,k))},u=b=>{const k=r.get(b.annotation);k&&(k.forEach(R=>o.remove(R)),r.delete(b.annotation))},d=b=>{u(b),c(b)},S=(b,k=!0)=>{k&&l();const R=t.getBoundingClientRect(),N=b.map(U=>({target:U,rects:s(U,R)}));N.forEach(({target:U,rects:_})=>{_.length>0&&r.set(U.annotation,_)});const I=N.flatMap(({rects:U})=>U);o.load(I)},p=(b,k,R=!1)=>{const N=o.search({minX:b,minY:k,maxX:b,maxY:k}),I=U=>U.annotation.rects.reduce((_,W)=>_+W.width*W.height,0);return N.length>0?(N.sort((U,_)=>I(U)-I(_)),R?N.map(U=>U.annotation.id):[N[0].annotation.id]):[]},O=b=>{const k=h(b);if(k.length===0)return;let R=k[0].left,N=k[0].top,I=k[0].right,U=k[0].bottom;for(let _=1;_<k.length;_++){const W=k[_];R=Math.min(R,W.left),N=Math.min(N,W.top),I=Math.max(I,W.right),U=Math.max(U,W.bottom)}return new DOMRect(R,N,I-R,U-N)},h=b=>{const k=r.get(b);return k?k[0].annotation.rects:[]};return{all:a,clear:l,getAt:p,getAnnotationBounds:O,getAnnotationRects:h,getIntersecting:(b,k,R,N)=>{const I=o.search({minX:b,minY:k,maxX:R,maxY:N}),U=new Set(I.map(_=>_.annotation.id));return Array.from(U).map(_=>({annotation:e.getAnnotation(_),rects:h(_)})).filter(_=>!!_.annotation)},insert:c,recalculate:()=>S(e.all().map(b=>b.target),!0),remove:u,set:S,size:()=>o.all().length,update:d}},Ei=(e,t)=>{var v,f;const n=Yo(),i=mr(n,e,(v=t.mergeHighlights)==null?void 0:v.horizontalTolerance,(f=t.mergeHighlights)==null?void 0:f.verticalTolerance),o=Ro(n,t.userSelectAction,t.adapter),r=To(n),s=zo(),a=(b,k=P.LOCAL)=>{const R=St(b,e),N=fe(R.target.selector);return N&&n.addAnnotation(R,k),N},l=(b,k=!0,R=P.LOCAL)=>{const N=b.map(U=>St(U,e)),I=N.filter(U=>!fe(U.target.selector));return n.bulkAddAnnotations(N,k,R),I},c=(b,k=P.LOCAL)=>{const R=b.map(I=>St(I,e)),N=R.filter(I=>!fe(I.target.selector));return R.forEach(I=>{n.getAnnotation(I.id)?n.updateAnnotation(I,k):n.addAnnotation(I,k)}),N},u=(b,k=P.LOCAL)=>{const R=et(b,e);n.updateTarget(R,k)},d=(b,k=P.LOCAL)=>{const R=b.map(N=>et(N,e));n.bulkUpdateTargets(R,k)};function S(b,k,R,N){const I=R||!!N,U=i.getAt(b,k,I).map(W=>n.getAnnotation(W)),_=N?U.filter(N):U;if(_.length!==0)return R?_:_[0]}const p=b=>i.getAnnotationRects(b).length>0?i.getAnnotationBounds(b):void 0,O=(b,k,R,N)=>i.getIntersecting(b,k,R,N),h=b=>i.getAnnotationRects(b),T=()=>i.recalculate();return n.observe(({changes:b})=>{const k=(b.deleted||[]).filter(I=>fe(I.target.selector)),R=(b.created||[]).filter(I=>fe(I.target.selector)),N=(b.updated||[]).filter(I=>fe(I.newValue.target.selector));(k==null?void 0:k.length)>0&&k.forEach(I=>i.remove(I.target)),R.length>0&&i.set(R.map(I=>I.target),!1),(N==null?void 0:N.length)>0&&N.forEach(({newValue:I})=>i.update(I.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:d,bulkUpsertAnnotations:c,getAnnotationBounds:p,getAnnotationRects:h,getIntersecting:O,getAt:S,recalculatePositions:T,updateTarget:u},selection:o,hover:r,viewport:s}},br=()=>{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},Ai=(e,t={})=>{const n=br(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=u=>Array.from(o.entries()).filter(([d,S])=>S.presenceKey===u.presenceKey).map(([d,S])=>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,S)=>{t.font&&(i.font=t.font);const p=o.get(u.annotation.id);if(p){const{height:O}=u.rects[0],h=u.rects[0].x+d.left,T=u.rects[0].y+d.top;i.fillStyle=p.appearance.color,i.fillRect(h-2,T-2.5,2,O+5);const v=i.measureText(p.appearance.label),f=v.width+6,b=v.actualBoundingBoxAscent+v.actualBoundingBoxDescent+8,k=v.fontBoundingBoxAscent?8:6.5;return i.fillRect(h-2,T-2.5-b,f,b),i.fillStyle="#fff",i.fillText(p.appearance.label,h+1,T-k),{fill:p.appearance.color,fillOpacity:S?.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)}}},ln=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function cn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function st(e,t,n,i){e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Si(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 xi(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 wr(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 at={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,"-":ln?173:189,"=":ln?61:187,";":ln?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},le={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},lt={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Q={16:!1,18:!1,17:!1,91:!1},Y={};for(let e=1;e<20;e++)at["f".concat(e)]=111+e;let F=[],ct=null,Oi="all";const we=new Map,Pe=e=>at[e.toLowerCase()]||le[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),yr=e=>Object.keys(at).find(t=>at[t]===e),vr=e=>Object.keys(le).find(t=>le[t]===e);function Ci(e){Oi=e||"all"}function dt(){return Oi||"all"}function Er(){return F.slice(0)}function Ar(){return F.map(e=>yr(e)||vr(e)||String.fromCharCode(e))}function Sr(){const e=[];return Object.keys(Y).forEach(t=>{Y[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=>Pe(a))})})}),e}function xr(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 Or(e){return typeof e=="string"&&(e=Pe(e)),F.indexOf(e)!==-1}function Cr(e,t){let n,i;e||(e=dt());for(const o in Y)if(Object.prototype.hasOwnProperty.call(Y,o))for(n=Y[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return dn(a)}):i++;dt()===e&&Ci(t||"all")}function Tr(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Pe(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 Q){Q[t]=!1;for(const i in le)le[i]===t&&(se[i]=!1)}}function Ti(e){if(typeof e>"u")Object.keys(Y).forEach(o=>{Array.isArray(Y[o])&&Y[o].forEach(r=>Lt(r)),delete Y[o]}),dn(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&Lt(o)});else if(typeof e=="object")e.key&&Lt(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=""),Lt({key:e,scope:o,method:r,splitKey:"+"})}}const Lt=e=>{let{key:t,scope:n,method:i,splitKey:o="+"}=e;xi(t).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Pe(c);if(!Y[u])return;n||(n=dt());const d=l>1?Si(le,a):[],S=[];Y[u]=Y[u].filter(p=>{const h=(i?p.method===i:!0)&&p.scope===n&&wr(p.mods,d);return h&&S.push(p.element),!h}),S.forEach(p=>dn(p))})};function Ri(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 Q)Object.prototype.hasOwnProperty.call(Q,r)&&(!Q[r]&&t.mods.indexOf(+r)>-1||Q[r]&&t.mods.indexOf(+r)===-1)&&(o=!1);(t.mods.length===0&&!Q[16]&&!Q[18]&&!Q[17]&&!Q[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 ki(e,t){const n=Y["*"];let i=e.keyCode||e.which||e.charCode;if(e.key&&e.key.toLowerCase()==="capslock"||!se.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=lt[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 lt||c===i))}),i in Q){Q[i]=!0;for(const a in le)if(Object.prototype.hasOwnProperty.call(le,a)){const l=lt[le[a]];se[a]=e[l]}if(!n)return}for(const a in Q)Object.prototype.hasOwnProperty.call(Q,a)&&(Q[a]=e[lt[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(F.indexOf(17)===-1&&F.push(17),F.indexOf(18)===-1&&F.push(18),Q[17]=!0,Q[18]=!0);const o=dt();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)&&Ri(e,n[a],o,t);if(!(i in Y))return;const r=Y[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 S=0;S<u.length;S++)d.push(Pe(u[S]));d.sort().join("")===F.sort().join("")&&Ri(e,l,o,t)}}function se(e,t,n){F=[];const i=xi(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,S=!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&&(S=!0)),typeof t=="string"&&(r=t),S&&Ti(e,r);a<i.length;a++)e=i[a].split(u),o=[],e.length>1&&(o=Si(le,e)),e=e[e.length-1],e=e==="*"?"*":Pe(e),e in Y||(Y[e]=[]),Y[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(!we.has(s)){const p=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return ki(h,s)},O=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;ki(h,s),Tr(h)};we.set(s,{keydownListener:p,keyupListenr:O,capture:d}),cn(s,"keydown",p,d),cn(s,"keyup",O,d)}if(!ct){const p=()=>{F=[]};ct={listener:p,capture:d},cn(window,"focus",p,d)}}}function Rr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(Y).forEach(n=>{Y[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function dn(e){const t=Object.values(Y).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=we.get(e)||{};i&&o&&(st(e,"keyup",o,r),st(e,"keydown",i,r),we.delete(e))}if((t.length<=0||we.size<=0)&&(Object.keys(we).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=we.get(o)||{};r&&s&&(st(o,"keyup",s,a),st(o,"keydown",r,a),we.delete(o))}),we.clear(),Object.keys(Y).forEach(o=>delete Y[o]),ct)){const{listener:o,capture:r}=ct;st(window,"focus",o,r),ct=null}}const un={getPressedKeyString:Ar,setScope:Ci,getScope:dt,deleteScope:Cr,getPressedKeyCodes:Er,getAllKeyCodes:Sr,isPressed:Or,filter:xr,trigger:Rr,unbind:Ti,keyMap:at,modifier:le,modifierMap:lt};for(const e in un)Object.prototype.hasOwnProperty.call(un,e)&&(se[e]=un[e]);if(typeof window<"u"){const e=window.hotkeys;se.noConflict=t=>(t&&window.hotkeys===se&&(window.hotkeys=e),se),window.hotkeys=se}async function kr(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 Li=300,Ii=["up","down","left","right"],Ni=Nn?"⌘+a":"ctrl+a",Lr=[...Ii.map(e=>`shift+${e}`),Ni],Mi=(e,t,n)=>{const{store:i,selection:o}=t;let r;const{annotatingEnabled:s,offsetReferenceSelector:a,selectionMode:l,dismissOnNotAnnotatable:c="NEVER"}=n,u=m=>r=m;let d;const S=m=>d=m;let p,O,h,T=s;const v=m=>{T=m,b.clear(),m||(p=void 0,O=void 0,h=void 0)},f=()=>{T&&O!==!1&&(p={annotation:di(),selector:[],creator:r,created:new Date})},b=_e(m=>{if(!T)return;const w=document.getSelection();if(!(w!=null&&w.anchorNode))return;const L=Array.from(Array(w.rangeCount).keys()).map(q=>w.getRangeAt(q));if(!L.some(q=>q.intersectsNode(e))){p=void 0;return}const V=m.timeStamp-((h==null?void 0:h.timeStamp)||m.timeStamp);if((h==null?void 0:h.type)==="pointerdown"&&(V<1e3&&!p||w.isCollapsed&&V<Li)&&f(),p||f(),w.isCollapsed){i.getAnnotation(p.annotation)&&(o.clear(),i.deleteAnnotation(p.annotation));return}const D=L.map(q=>Xn(q,e));if(D.every(q=>Dn(q)))return;const H=D.flatMap(q=>_n(e,q.cloneRange()));(H.length>0&&!p||H.length!==p.selector.length||H.some((q,Ve)=>{var Xe;return q.toString()!==((Xe=p.selector[Ve])==null?void 0:Xe.quote)}))&&(p={...p,selector:H.map(q=>Pn(q,e,a)),updated:new Date},i.getAnnotation(p.annotation)?i.updateTarget(p,P.LOCAL):o.clear())},10),k=m=>{h=ft(m),O=h.button===0},R=async m=>{if(!O)return;const w=ft(m),L=()=>{const{x:D,y:H}=e.getBoundingClientRect();if(Fe(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,Ve=new Set(q.map(ut=>ut.id)),Xe=Array.isArray($)?$.map(ut=>ut.id):[$.id];(Ve.size!==Xe.length||!Xe.every(ut=>Ve.has(ut)))&&o.userSelect(Xe,w)}else o.clear()};if(w.timeStamp-h.timeStamp<Li){await N();const D=document.getSelection(),H=Fe(e,h.target),$=Fe(e,w.target);if(D!=null&&D.isCollapsed||H&&$){p=void 0,L();return}}p&&p.selector.length>0&&(Z(),o.userSelect(p.annotation,w))},N=async()=>{const m=document.getSelection();let w=!1,L=m==null?void 0:m.isCollapsed;const V=()=>L||w,D=1;return setTimeout(()=>w=!0,50),kr(()=>L=m==null?void 0:m.isCollapsed,D,V)},I=m=>{const w=document.getSelection();w!=null&&w.isCollapsed||((!p||p.selector.length===0)&&b(m),p&&(Z(),o.userSelect(p.annotation,ft(m))))},U=m=>{T&&m.key==="Shift"&&p&&(document.getSelection().isCollapsed||(Z(),o.userSelect(p.annotation,Ye(m))))},_=m=>{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,Ye(m))),document.removeEventListener("selectionchange",w)},100);document.addEventListener("selectionchange",w),f()};se(Lr.join(","),{element:e,keydown:!0,keyup:!1},m=>{m.repeat||(h=Ye(m))}),se(Ni,{keydown:!0,keyup:!1},m=>{h=Ye(m),_(m)});const W=m=>{m.repeat||m.target!==e&&m.target!==document.body||(p=void 0,o.clear())};se(Ii.join(","),{keydown:!0,keyup:!1},W);const Z=()=>{const m=i.getAnnotation(p.annotation);if(!m){i.addAnnotation({id:p.annotation,bodies:[],target:p});return}const{target:{updated:w}}=m,{updated:L}=p;(!w||!L||w<L)&&i.updateTarget(p)};return document.addEventListener("pointerdown",k),document.addEventListener("pointerup",R),document.addEventListener("contextmenu",I),e.addEventListener("keyup",U),e.addEventListener("selectstart",f),document.addEventListener("selectionchange",b),{destroy:()=>{p=void 0,O=void 0,h=void 0,b.clear(),document.removeEventListener("pointerdown",k),document.removeEventListener("pointerup",R),document.removeEventListener("contextmenu",I),e.removeEventListener("keyup",U),e.removeEventListener("selectstart",f),document.removeEventListener("selectionchange",b),se.unbind()},setFilter:S,setUser:u,setAnnotatingEnabled:v}},Bi=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),_i="SPANS",Ir=(e,t={})=>{hn(e),Mn(e);const n=Bi(t,{annotatingEnabled:!0,user:nr()}),i=Ei(e,n),{selection:o,viewport:r}=i,s=i.store,a=jo(s),l=$o(i,a,n.adapter);let c=n.user;const u=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":_i:n.renderer||_i,d=u==="SPANS"?li(e,i,r):u==="CSS_HIGHLIGHTS"?si(e,i,r):u==="CANVAS"?zn(e,i,r):void 0;if(!d)throw`Unknown renderer implementation: ${u}`;console.debug(`Using ${u} renderer`),n.style&&d.setStyle(n.style);const S=Mi(e,i,n);S.setUser(c);const p=Go(i,a,n.adapter),O=()=>c,h=R=>{S.setAnnotatingEnabled(R===void 0?!0:R)},T=R=>{d.setFilter(R),S.setFilter(R)},v=R=>{c=R,S.setUser(R)},f=R=>{R&&(d.setPainter(Ai(R,n.presence)),R.on("selectionChange",()=>d.redraw()))},b=R=>{R?o.setSelected(R):o.clear()};return{...p,destroy:()=>{d.destroy(),S.destroy(),a.destroy()},element:e,getUser:O,setAnnotatingEnabled:h,setFilter:T,setStyle:d.setStyle.bind(d),redraw:d.redraw.bind(d),setUser:v,setSelected:b,setPresenceProvider:f,setVisible:d.setVisible.bind(d),on:l.on,off:l.off,scrollIntoView:Kn(e,s),state:i}};M.DEFAULT_SELECTED_STYLE=tt,M.DEFAULT_STYLE=he,M.NOT_ANNOTATABLE_CLASS=Se,M.NOT_ANNOTATABLE_SELECTOR=xe,M.Origin=P,M.UserSelectAction=fi,M.W3CTextFormat=sr,M.cancelSingleClickEvents=hn,M.cloneKeyboardEvent=Ye,M.clonePointerEvent=ft,M.createBody=_o,M.createCanvasRenderer=zn,M.createHighlightsRenderer=si,M.createPresencePainter=Ai,M.createRenderer=ri,M.createSelectionHandler=Mi,M.createSpansRenderer=li,M.createTextAnnotator=Ir,M.createTextAnnotatorState=Ei,M.fillDefaults=Bi,M.getHighlightClientRects=Bn,M.getQuoteContext=Un,M.getRangeAnnotatableContents=At,M.isMac=Nn,M.isNodeWhitespaceOrEmpty=Ji,M.isNotAnnotatable=Fe,M.isRangeAnnotatable=fn,M.isRangeWhitespaceOrEmpty=Dn,M.isRevived=fe,M.mergeClientRects=Hn,M.paint=Wn,M.parseW3CTextAnnotation=bi,M.programmaticallyFocusable=Mn,M.rangeToSelector=Pn,M.reviveAnnotation=St,M.reviveSelector=$t,M.reviveTarget=et,M.scrollIntoView=Kn,M.serializeW3CTextAnnotation=wi,M.splitAnnotatableRanges=_n,M.toDomRectList=eo,M.toParentBounds=Vn,M.toViewportBounds=to,M.trimRangeToContainer=Xn,M.whitespaceOrEmptyRegex=zt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
|
|
3
3
|
//# sourceMappingURL=text-annotator.umd.js.map
|