hypothesis 1.1517.0 → 1.1518.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/build/boot.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?be19cb","styles/annotator.css":"styles/annotator.css?4b6983","styles/annotator.css.map":"styles/annotator.css.map?081c77","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?58e394","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/katex.min.css.map":"styles/katex.min.css.map?1785d7","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css.map":"styles/sidebar.css.map?8cefc2","styles/sidebar.css":"styles/sidebar.css?01eb18","styles/ui-playground.css.map":"styles/ui-playground.css.map?ca871c","styles/ui-playground.css":"styles/ui-playground.css?b3187a","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?dff8eb","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?40f275","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?f8164a","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?ced09b","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?4d5029"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1517.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:d,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
1
+ !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?095bab","styles/annotator.css":"styles/annotator.css?4b6983","styles/annotator.css.map":"styles/annotator.css.map?081c77","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?58e394","styles/katex.min.css.map":"styles/katex.min.css.map?1785d7","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css.map":"styles/sidebar.css.map?8cefc2","styles/ui-playground.css":"styles/ui-playground.css?b3187a","styles/ui-playground.css.map":"styles/ui-playground.css.map?ca871c","styles/sidebar.css":"styles/sidebar.css?01eb18","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?a40fda","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?40f275","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?1fb10d","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?ced09b","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?4d5029"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1518.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:d,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
@@ -1,20 +1,20 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?be19cb",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?095bab",
3
3
  "styles/annotator.css": "styles/annotator.css?4b6983",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?081c77",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
6
6
  "styles/highlights.css.map": "styles/highlights.css.map?241350",
7
7
  "styles/katex.min.css": "styles/katex.min.css?58e394",
8
- "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
9
8
  "styles/katex.min.css.map": "styles/katex.min.css.map?1785d7",
9
+ "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
10
10
  "styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
11
11
  "styles/sidebar.css.map": "styles/sidebar.css.map?8cefc2",
12
- "styles/sidebar.css": "styles/sidebar.css?01eb18",
13
- "styles/ui-playground.css.map": "styles/ui-playground.css.map?ca871c",
14
12
  "styles/ui-playground.css": "styles/ui-playground.css?b3187a",
15
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?dff8eb",
13
+ "styles/ui-playground.css.map": "styles/ui-playground.css.map?ca871c",
14
+ "styles/sidebar.css": "styles/sidebar.css?01eb18",
15
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?a40fda",
16
16
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?40f275",
17
- "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?f8164a",
17
+ "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?1fb10d",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?ced09b",
19
19
  "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?4d5029"
20
20
  }
@@ -109,44 +109,44 @@ n(document.body)>e&&(document.body.style.marginLeft=`${e}px`),i.left<12&&(docume
109
109
  var xo=NaN,Co="[object Symbol]",No=/^\s+|\s+$/g,So=/^[-+]0x[0-9a-f]+$/i,Eo=/^0b[01]+$/i,Ao=/^0o[0-7]+$/i,ko=parseInt,To="object"==typeof e&&e&&e.Object===Object&&e,Ro="object"==typeof self&&self&&self.Object===Object&&self,Po=To||Ro||Function("return this")(),Oo=Object.prototype.toString,Io=Math.max,Mo=Math.min,Lo=function(){return Po.Date.now()};function Bo(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Do(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Oo.call(e)==Co}(e))return xo;if(Bo(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Bo(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(No,"");var n=Eo.test(e);return n||Ao.test(e)?ko(e.slice(2),n?2:8):So.test(e)?xo:+e}var Fo=function(e,t,n){var i,o,r,s,a,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var n=i,r=o;return i=o=void 0,c=t,s=e.apply(r,n)}function m(e){var n=e-l
110
110
  ;return void 0===l||n>=t||n<0||h&&e-c>=r}function p(){var e=Lo();if(m(e))return g(e);a=setTimeout(p,function(e){var n=t-(e-l);return h?Mo(n,r-(e-c)):n}(e))}function g(e){return a=void 0,d&&i?f(e):(i=o=void 0,s)}function _(){var e=Lo(),n=m(e);if(i=arguments,o=this,l=e,n){if(void 0===a)return function(e){return c=e,a=setTimeout(p,t),u?f(e):s}(l);if(h)return a=setTimeout(p,t),f(l)}return void 0===a&&(a=setTimeout(p,t)),s}return t=Do(t)||0,Bo(n)&&(u=!!n.leading,r=(h="maxWait"in n)?Io(Do(n.maxWait)||0,t):r,d="trailing"in n?!!n.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,i=l=o=a=void 0},_.flush=function(){return void 0===a?s:g(Lo())},_},Ho=t(Fo);function Vo(e,t,n,i=0){let o=i;for(;o<e.length&&t>0;)n(e[o])&&--t,++o;return o}function Uo(e,t,n,i){let o=0;for(let r=n;r<i;r++)t(e[r])&&++o;return o}function qo(e,t,n,i,o){const r=Uo(e,o,0,n),s=Uo(e,o,n,i);let a=Vo(t,r,o);for(;a<t.length&&!o(t[a]);)++a;return[a,Vo(t,s,o,a)]}const Wo={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},$o=new Map,zo=new Map
111
111
  ;function jo(e,t){return`${e}:${t}`}function Xo(e){const t="closest"in e?e:e.parentElement;return t?.closest(".textLayer")??null}function Yo(){return PDFViewerApplication.pdfViewer}async function Go(e){const t=Yo();let n=t.getPageView(e);return n&&n.pdfPage||(n=await new Promise((n=>{const i=()=>{t.eventBus?t.eventBus.off("pagesloaded",i):document.removeEventListener("pagesloaded",i),n(t.getPageView(e))};t.eventBus?t.eventBus.on("pagesloaded",i):document.addEventListener("pagesloaded",i)}))),n}function Ko(e){const t=$o.get(e);if(t)return t;const n=(async()=>{const t=await Go(e);return(await t.pdfPage.getTextContent({normalizeWhitespace:!0})).items.map((e=>e.str)).join("")})();return $o.set(e,n),n}async function Qo(e){const t=Yo();let n=0,i=0,o="";for(let r=0;r<t.pagesCount;r++)if(o=await Ko(r),n=i,i+=o.length,i>=e)return{index:r,offset:n,text:o};return{index:t.pagesCount-1,offset:n,text:o}}function Zo(e){switch(e){case" ":case"\f":case"\n":case"\r":case"\t":case"\v":case" ":return!0;default:return!1}}
112
- const Jo=e=>!Zo(e);async function er(e,t,n){const[i,o]=await Promise.all([Go(e),Ko(e)]);if(i.renderingState===Wo.FINISHED&&i.textLayer&&i.textLayer.renderingDone){const e=i.textLayer.textLayerDiv??i.textLayer.div;if(!e)throw new Error("Unable to find PDF.js text layer root");const r=e.textContent,[s,a]=qo(o,r,t,n,Jo);tr(r.slice(s,a))!==tr(o.slice(t,n))&&Ti("Text layer text does not match page text. Highlights will be mis-aligned.");const l=new oi(e,s),c=new oi(e,a);return new ri(l,c).toRange()}const r=function(e){let t=e.querySelector(si);return t||(t=document.createElement("span"),t.classList.add("annotator-placeholder"),t.textContent="Loading annotations...",e.appendChild(t),t)}(i.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function tr(e){let t="";for(let n=0;n<e.length;n++){const i=e[n];Zo(i)||(t+=i)}return t}async function nr(e,t){const n=t.find((e=>"TextQuoteSelector"===e.type));if(!n)throw new Error("No quote selector found")
113
- ;const i=t.find((e=>"TextPositionSelector"===e.type));if(i){try{const{index:e,offset:t,text:o}=await Qo(i.start),r=i.start-t,s=i.end-t,a=o.substring(r,s);if(n.exact!==a)throw new Error("quote mismatch");return await er(e,r,s)}catch{}try{const e=jo(n.exact,i.start),t=zo.get(e);if(t){const{pageIndex:e,anchor:n}=t;return await er(e,n.start,n.end)}}catch{}}return async function(e,t){const n=Yo().pagesCount,i=Array(n).fill(0).map(((e,t)=>t));let o,r;if(t){const{index:e,offset:n}=await Qo(t);o=e,r=t-n,i.sort(((t,n)=>Math.abs(t-e)-Math.abs(n-e)))}const s=void 0!==e.prefix?tr(e.prefix):void 0,a=void 0!==e.suffix?tr(e.suffix):void 0,l=tr(e.exact);let c;for(const e of i){const t=await Ko(e),n=tr(t);let i;void 0!==o&&void 0!==r&&(e<o?i=n.length:e===o?[i]=qo(t,n,r,r,Jo):i=0);const u=$i(n,l,{prefix:s,suffix:a,hint:i});if(u&&(!c||u.score>c.match.score)){const[i,o]=qo(n,t,u.start,u.end,Jo);c={page:e,match:{start:i,end:o,score:u.score}}
114
- ;const r=n.slice(u.start,u.end)===l,h=void 0!==s&&n.slice(Math.max(0,u.start-s.length),u.start)===s,d=void 0!==a&&n.slice(u.end,a.length)===a;if(r&&(h||d||void 0===s&&void 0===a))break}}if(c){const{page:n,match:i}=c;if(t){const o=jo(e.exact,t);zo.set(o,{pageIndex:n,anchor:i})}return er(n,i.start,i.end)}throw new Error("Quote not found")}(n,i?.start)}function ir(e){try{e=ri.fromRange(e).toRange()}catch{throw new Error("Selection does not contain text")}const t=Xo(e.startContainer),n=Xo(e.endContainer);if(!t||!n)throw new Error("Selection is outside page text");if(t!==n)throw new Error("Selecting across page breaks is not supported");return[e,t]}async function or(e,t){const[n,i]=ir(t),o=oi.fromPoint(n.startContainer,n.startOffset).relativeTo(i),r=oi.fromPoint(n.endContainer,n.endOffset).relativeTo(i),s=function(e){let t=0;for(;e.previousSibling;)++t,e=e.previousSibling;return t}(i.parentNode),a=s+1,l=await async function(e){if(e>=Yo().pagesCount)throw new Error("Invalid page index");let t=0
115
- ;for(let n=0;n<e;n++)t+=(await Ko(n)).length;return t}(s),c=await Go(s);return[{type:"TextPositionSelector",start:l+o.offset,end:l+r.offset},Qi.fromRange(e,n).toSelector(),{type:"PageSelector",index:s,label:c.pageLabel??a.toString()}]}function rr({children:e}){return wt("div",{className:"flex flex-col",children:e})}function sr({info:e}){let t=e.item.title;return e.item.subtitle&&(t+=`: ${e.item.subtitle}`),wt("div",{className:vt("h-10 bg-white px-4 text-slate-7 text-annotator-base border-b","grid items-center","grid-cols-[100px_minmax(0,auto)]","2xl:grid-cols-[100px_minmax(0,auto)_minmax(0,auto)] 2xl:gap-x-3"),children:[wt("div",{"data-testid":"content-logo",children:e.logo&&wt(Fn,{href:e.logo.link,target:"_blank","data-testid":"logo-link",underline:"none",children:wt("img",{alt:e.logo.title,src:e.logo.logo,"data-testid":"logo-image"})})}),wt("div",{className:vt("hidden","2xl:block 2xl:whitespace-nowrap 2xl:overflow-hidden 2xl:text-ellipsis","font-semibold"),"data-testid":"content-container-info",
112
+ const Jo=e=>!Zo(e);function er(e){return void 0!==e.renderingDone?e.renderingDone:!!e.div&&null!==e.div.querySelector(".endOfContent")}async function tr(e,t,n){const[i,o]=await Promise.all([Go(e),Ko(e)]);if(i.renderingState===Wo.FINISHED&&i.textLayer&&er(i.textLayer)){const e=i.textLayer.textLayerDiv??i.textLayer.div;if(!e)throw new Error("Unable to find PDF.js text layer root");const r=e.textContent,[s,a]=qo(o,r,t,n,Jo);nr(r.slice(s,a))!==nr(o.slice(t,n))&&Ti("Text layer text does not match page text. Highlights will be mis-aligned.");const l=new oi(e,s),c=new oi(e,a);return new ri(l,c).toRange()}const r=function(e){let t=e.querySelector(si);return t||(t=document.createElement("span"),t.classList.add("annotator-placeholder"),t.textContent="Loading annotations...",e.appendChild(t),t)}(i.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function nr(e){let t="";for(let n=0;n<e.length;n++){const i=e[n];Zo(i)||(t+=i)}return t}async function ir(e,t){
113
+ const n=t.find((e=>"TextQuoteSelector"===e.type));if(!n)throw new Error("No quote selector found");const i=t.find((e=>"TextPositionSelector"===e.type));if(i){try{const{index:e,offset:t,text:o}=await Qo(i.start),r=i.start-t,s=i.end-t,a=o.substring(r,s);if(n.exact!==a)throw new Error("quote mismatch");return await tr(e,r,s)}catch{}try{const e=jo(n.exact,i.start),t=zo.get(e);if(t){const{pageIndex:e,anchor:n}=t;return await tr(e,n.start,n.end)}}catch{}}return async function(e,t){const n=Yo().pagesCount,i=Array(n).fill(0).map(((e,t)=>t));let o,r;if(t){const{index:e,offset:n}=await Qo(t);o=e,r=t-n,i.sort(((t,n)=>Math.abs(t-e)-Math.abs(n-e)))}const s=void 0!==e.prefix?nr(e.prefix):void 0,a=void 0!==e.suffix?nr(e.suffix):void 0,l=nr(e.exact);let c;for(const e of i){const t=await Ko(e),n=nr(t);let i;void 0!==o&&void 0!==r&&(e<o?i=n.length:e===o?[i]=qo(t,n,r,r,Jo):i=0);const u=$i(n,l,{prefix:s,suffix:a,hint:i});if(u&&(!c||u.score>c.match.score)){const[i,o]=qo(n,t,u.start,u.end,Jo);c={page:e,match:{start:i,end:o,
114
+ score:u.score}};const r=n.slice(u.start,u.end)===l,h=void 0!==s&&n.slice(Math.max(0,u.start-s.length),u.start)===s,d=void 0!==a&&n.slice(u.end,a.length)===a;if(r&&(h||d||void 0===s&&void 0===a))break}}if(c){const{page:n,match:i}=c;if(t){const o=jo(e.exact,t);zo.set(o,{pageIndex:n,anchor:i})}return tr(n,i.start,i.end)}throw new Error("Quote not found")}(n,i?.start)}function or(e){try{e=ri.fromRange(e).toRange()}catch{throw new Error("Selection does not contain text")}const t=Xo(e.startContainer),n=Xo(e.endContainer);if(!t||!n)throw new Error("Selection is outside page text");if(t!==n)throw new Error("Selecting across page breaks is not supported");return[e,t]}async function rr(e,t){const[n,i]=or(t),o=oi.fromPoint(n.startContainer,n.startOffset).relativeTo(i),r=oi.fromPoint(n.endContainer,n.endOffset).relativeTo(i),s=function(e){let t=0;for(;e.previousSibling;)++t,e=e.previousSibling;return t}(i.parentNode),a=s+1,l=await async function(e){if(e>=Yo().pagesCount)throw new Error("Invalid page index");let t=0
115
+ ;for(let n=0;n<e;n++)t+=(await Ko(n)).length;return t}(s),c=await Go(s);return[{type:"TextPositionSelector",start:l+o.offset,end:l+r.offset},Qi.fromRange(e,n).toSelector(),{type:"PageSelector",index:s,label:c.pageLabel??a.toString()}]}function sr({children:e}){return wt("div",{className:"flex flex-col",children:e})}function ar({info:e}){let t=e.item.title;return e.item.subtitle&&(t+=`: ${e.item.subtitle}`),wt("div",{className:vt("h-10 bg-white px-4 text-slate-7 text-annotator-base border-b","grid items-center","grid-cols-[100px_minmax(0,auto)]","2xl:grid-cols-[100px_minmax(0,auto)_minmax(0,auto)] 2xl:gap-x-3"),children:[wt("div",{"data-testid":"content-logo",children:e.logo&&wt(Fn,{href:e.logo.link,target:"_blank","data-testid":"logo-link",underline:"none",children:wt("img",{alt:e.logo.title,src:e.logo.logo,"data-testid":"logo-image"})})}),wt("div",{className:vt("hidden","2xl:block 2xl:whitespace-nowrap 2xl:overflow-hidden 2xl:text-ellipsis","font-semibold"),"data-testid":"content-container-info",
116
116
  title:e.container.title,children:e.container.title}),wt("div",{className:vt("flex justify-center items-center gap-x-2"),"data-testid":"content-item-info",children:[wt("div",{className:vt("hidden","2xl:block 2xl:grow")}),e.links.previousItem&&wt(he,{children:[wt(Fn,{title:"Open previous item",href:e.links.previousItem,underline:"always",target:"_blank","data-testid":"content-previous-link",children:wt("div",{className:"flex gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[wt(It,{className:"w-em h-em"}),wt("span",{children:"Previous"})]})}),wt("div",{className:"text-annotator-sm",children:"|"})]}),wt("div",{className:vt("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis shrink font-medium"),children:wt(Fn,{title:t,href:e.links.currentItem,"data-testid":"content-item-link",target:"_blank",unstyled:!0,children:t})}),e.links.nextItem&&wt(he,{children:[wt("div",{className:"text-annotator-sm",children:"|"}),wt(Fn,{title:"Open next item",href:e.links.nextItem,underline:"always",
117
- target:"_blank","data-testid":"content-next-link",children:wt("div",{className:"flex gap gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[wt("span",{children:"Next"}),wt(Lt,{className:"w-em h-em"})]})})]})]})]})}function ar(){return wt("div",{className:"bg-white",role:"alert",children:wt("div",{className:vt("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[wt("div",{className:"bg-yellow-notice text-white p-2",children:wt(Dt,{className:"text-annotator-xl"})}),wt("div",{children:[wt("strong",{children:"This PDF does not contain selectable text:"})," ",wt(Fn,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",underline:"always",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})})}class lr{constructor(e){this._loaded=function(e){return e.initializedPromise?e.initializedPromise:e.initialized?Promise.resolve():new Promise((t=>{const n=setInterval((()=>{
118
- e.initialized&&(clearTimeout(n),t())}),5)}))}(e).then((async()=>{const t=await async function(e){return void 0!==e.downloadComplete?e.downloadComplete:(await e.pdfDocument.getDownloadInfo(),!0)}(e);return t?e:new Promise((t=>{const n=()=>{e.eventBus?(e.eventBus.off("documentload",n),e.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),t(e)};e.eventBus?(e.eventBus.on("documentloaded",n),e.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))}))}getUri(){return this._loaded.then((e=>{let t=hr(e);return t||(t=ur(cr(e))),t}))}async getMetadata(){const e=await this._loaded,{info:t,contentDispositionFilename:n,metadata:i}=await e.pdfDocument.getMetadata(),o=cr(e),r=hr(e);let s;s=i?.has("dc:title")&&"Untitled"!==i.get("dc:title")?i.get("dc:title"):t?.Title?t.Title:n||(r?function(e){const t=new URL(e),n=t.pathname.split("/");return n[n.length-1]}(r):"");const a=[{href:ur(o)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:o}}}function cr(e){
119
- return Array.isArray(e.pdfDocument.fingerprints)?e.pdfDocument.fingerprints[0]:e.pdfDocument.fingerprint}function ur(e){return`urn:x-pdf:${e}`}function hr(e){if(!e.url)return null;const t=vo(e.url);return 0!==t.indexOf("file://")?t:null}function dr(e){const t=e.highlights?.[0];return t&&ai(t)}function fr(e){return new Promise((t=>setTimeout(t,e)))}class mr{constructor(){this._pdfjsContainer=document.querySelector("#outerContainer"),this._contentInfo=null,this._noTextWarning=!1,this._container=null}setContentInfo(e){this._contentInfo=e,this._update()}showNoTextWarning(e){this._noTextWarning=e,this._update()}destroy(){this._container?.destroy()}_update(){if(!(this._noTextWarning||this._contentInfo))return this._container?.destroy(),this._container=null,void(this._pdfjsContainer.style.height="");this._container||(this._container=new Xn("banner",(()=>this._render())),document.body.prepend(this._container.element)),this._container.render();const e=this._container.element.getBoundingClientRect().height
120
- ;this._pdfjsContainer.style.height=`calc(100% - ${e}px)`}_render(){return wt(rr,{children:[this._contentInfo&&wt(sr,{info:this._contentInfo}),this._noTextWarning&&wt(ar,{})]})}}class pr extends u{constructor(e,t={}){super(),this._annotator=e;const i=window,o=i.PDFViewerApplication;this._pdfViewer=o.pdfViewer,this._pdfViewer.viewer.classList.add("has-transparent-text-layer"),this._pdfContainer=o.appConfig?.appContainer??document.body,this._pdfMetadata=new lr(o),this._observer=new MutationObserver(Ho((()=>this._update()),100)),this._observer.observe(this._pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=t.reanchoringMaxWait??3e3,this._banner=new mr,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const e=i.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!e.isCollapsed)},this._listeners=new n,
121
- this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){this.fitSideBySide({expanded:!1,width:0,toolbarWidth:0,height:window.innerHeight}),this._listeners.removeAll(),this._pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this._observer.disconnect(),this._banner.destroy(),this._destroyed=!0}uri(){return this._pdfMetadata.getUri()}getMetadata(){return this._pdfMetadata.getMetadata()}showContentInfo(e){this._banner.setContentInfo(e)}anchor(e,t){return nr(0,t)}getAnnotatableRange(e){try{const t=ri.trimmedRange(e);if(function(e){try{return ir(e),!0}catch{return!1}}(t))return t}catch(e){if(!(e instanceof RangeError))throw e}return null}canStyleClusteredHighlights(){return!0}describe(e,t){return or(e,t)}async _checkForSelectableText(){try{await this.uri()}catch(e){return}if(!this._destroyed)try{const e=await async function(){const e=Yo();let t=!1;for(let n=0;n<e.pagesCount;n++)if((await Ko(n)).trim().length>0){t=!0;break}return t}()
122
- ;this._banner.showNoTextWarning(!e)}catch(e){console.warn("Unable to check for text in PDF:",e)}}_update(){const e=[],t=this._pdfViewer.pagesCount;for(let e=0;e<t;e++){const t=this._pdfViewer.getPageView(e);if(t?.textLayer?.renderingDone)switch(t.renderingState){case Wo.INITIAL:t.textLayer=null;break;case Wo.FINISHED:n=t.div,n.querySelector(si)?.remove()}}var n;for(const t of this._annotator.anchors)if(t.highlights){if(e.includes(t.annotation))continue;for(let n=0;n<t.highlights.length;n++){const i=t.highlights[n];if(!document.body.contains(i)){t.highlights.splice(n,1),delete t.range,e.push(t.annotation);break}}}e.map((e=>this._annotator.anchor(e)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(e){const t=window.innerWidth-e.width,n=e.expanded&&t>=680,i=n?e.width:e.toolbarWidth;this._pdfContainer.style.width=`calc(100% - ${i}px)`;const o=this._pdfViewer.currentScaleValue;return"auto"!==o&&"page-fit"!==o&&"page-width"!==o||(this._pdfViewer.currentScaleValue=o),
123
- this._pdfViewer.update(),this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}async scrollToAnchor(e){const t=e.annotation,n=dr(e),i=this._anchorOffset(e);if(null!==i&&(await bo(this.contentContainer(),i),n)){const e=await this._waitForAnnotationToBeAnchored(t,this._reanchoringMaxWait);if(!e)return;const n=this._anchorOffset(e);if(null===n)return;await bo(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(e,t){const n=Date.now();let i;do{i=this._annotator.anchors.find((t=>t.annotation===e)),i&&!dr(i)||(i=null,await fr(20))}while(!i&&Date.now()-n<t);return i??null}_anchorOffset(e){if(!e.highlights)return null;return function(e,t){let n=0;for(;e!==t&&t.contains(e);)n+=e.offsetTop,e=e.offsetParent;return n}(e.highlights[0],this.contentContainer())}}function gr(e){if(!e.includes("["))return e;let t="",n=!1,i=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&i&&"]"===o?i=!1:i||(t+=o):i=!0,n=!1):n=!0;return t}function _r(e){const t=gr(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)
124
- }class br{constructor(e,t,n){this._element=e,this._onFrameAdded=t,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Ho((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(e){this._annotatableFrames.add(e);try{if(await vr(e),this._isDisconnected)return;e.contentWindow.addEventListener("unload",(()=>{this._removeFrame(e)})),this._onFrameAdded(e)}catch(t){console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${e.src}')`)}}_removeFrame(e){this._annotatableFrames.delete(e),this._onFrameRemoved(e)}_discoverFrames(){const e=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const t of e)this._annotatableFrames.has(t)||this._addFrame(t)
125
- ;for(const t of this._annotatableFrames)e.has(t)||this._removeFrame(t)}}function vr(e){return new Promise(((t,n)=>{const i=yr(e,((e,o)=>{i(),o?t(o):n(e)}))}))}function yr(e,t,{pollInterval:n=10}={}){let i,o;const r=new WeakSet,s=()=>{clearTimeout(i),i=void 0},a=()=>{const n=e.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),!function(e){return"about:blank"===e.contentDocument?.location.href&&e.hasAttribute("src")&&"about:blank"!==e.src}(e)){"interactive"===n.readyState||"complete"===n.readyState?t(null,n):n.addEventListener("DOMContentLoaded",(()=>t(null,n)))}e.contentDocument&&e.contentWindow?.addEventListener("unload",o)}}else{s();const n=e.isConnected?"Frame is cross-origin":"Frame is disconnected";t(new Error(n))}};let l=!1;o=()=>{s(),l||(i=setInterval(a,n))},e.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),e.removeEventListener("load",a)}}class wr{constructor(e,t){this._config=t,this._frameObserver=new br(e,(e=>xr(e,t)),(()=>{}))}destroy(){
126
- this._frameObserver.disconnect()}}async function xr(e,t,n){if(null!==e.contentDocument.querySelector("script.js-hypothesis-config"))return;await vr(e);const{assetRoot:i,notebookAppUrl:r,profileAppUrl:s,sidebarAppUrl:a}=C(document),l={...t,assetRoot:i,notebookAppUrl:r,profileAppUrl:s,sidebarAppUrl:a,subFrameIdentifier:n??o(10)},c=document.createElement("script");c.className="js-hypothesis-config",c.setAttribute("data-remove-on-unload",""),c.type="application/json",c.innerText=JSON.stringify(l);const u=document.createElement("script");u.async=!0,u.src=t.clientUrl;const h=e.contentDocument;h.body.appendChild(c),h.body.appendChild(u)}class Cr{constructor(e,t,i){if(t.length!==i.length)throw new Error("Char boxes length does not match text length");const o=e.parentNode,r=document.createElement("hypothesis-text-layer");o.insertBefore(r,e.nextSibling),o.style.position="relative",r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.color="transparent",r.style.textAlign="left",
117
+ target:"_blank","data-testid":"content-next-link",children:wt("div",{className:"flex gap gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[wt("span",{children:"Next"}),wt(Lt,{className:"w-em h-em"})]})})]})]})]})}function lr(){return wt("div",{className:"bg-white",role:"alert",children:wt("div",{className:vt("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[wt("div",{className:"bg-yellow-notice text-white p-2",children:wt(Dt,{className:"text-annotator-xl"})}),wt("div",{children:[wt("strong",{children:"This PDF does not contain selectable text:"})," ",wt(Fn,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",underline:"always",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})})}class cr{constructor(e){this._loaded=function(e){return e.initializedPromise?e.initializedPromise:e.initialized?Promise.resolve():new Promise((t=>{const n=setInterval((()=>{
118
+ e.initialized&&(clearTimeout(n),t())}),5)}))}(e).then((async()=>{const t=await async function(e){return void 0!==e.downloadComplete?e.downloadComplete:(await e.pdfDocument.getDownloadInfo(),!0)}(e);return t?e:new Promise((t=>{const n=()=>{e.eventBus?(e.eventBus.off("documentload",n),e.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),t(e)};e.eventBus?(e.eventBus.on("documentloaded",n),e.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))}))}getUri(){return this._loaded.then((e=>{let t=dr(e);return t||(t=hr(ur(e))),t}))}async getMetadata(){const e=await this._loaded,{info:t,contentDispositionFilename:n,metadata:i}=await e.pdfDocument.getMetadata(),o=ur(e),r=dr(e);let s;s=i?.has("dc:title")&&"Untitled"!==i.get("dc:title")?i.get("dc:title"):t?.Title?t.Title:n||(r?function(e){const t=new URL(e),n=t.pathname.split("/");return n[n.length-1]}(r):"");const a=[{href:hr(o)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:o}}}function ur(e){
119
+ return Array.isArray(e.pdfDocument.fingerprints)?e.pdfDocument.fingerprints[0]:e.pdfDocument.fingerprint}function hr(e){return`urn:x-pdf:${e}`}function dr(e){if(!e.url)return null;const t=vo(e.url);return 0!==t.indexOf("file://")?t:null}function fr(e){const t=e.highlights?.[0];return t&&ai(t)}function mr(e){return new Promise((t=>setTimeout(t,e)))}class pr{constructor(){this._pdfjsContainer=document.querySelector("#outerContainer"),this._contentInfo=null,this._noTextWarning=!1,this._container=null}setContentInfo(e){this._contentInfo=e,this._update()}showNoTextWarning(e){this._noTextWarning=e,this._update()}destroy(){this._container?.destroy()}_update(){if(!(this._noTextWarning||this._contentInfo))return this._container?.destroy(),this._container=null,void(this._pdfjsContainer.style.height="");this._container||(this._container=new Xn("banner",(()=>this._render())),document.body.prepend(this._container.element)),this._container.render();const e=this._container.element.getBoundingClientRect().height
120
+ ;this._pdfjsContainer.style.height=`calc(100% - ${e}px)`}_render(){return wt(sr,{children:[this._contentInfo&&wt(ar,{info:this._contentInfo}),this._noTextWarning&&wt(lr,{})]})}}class gr extends u{constructor(e,t={}){super(),this._annotator=e;const i=window,o=i.PDFViewerApplication;this._pdfViewer=o.pdfViewer,this._pdfViewer.viewer.classList.add("has-transparent-text-layer"),this._pdfContainer=o.appConfig?.appContainer??document.body,this._pdfMetadata=new cr(o),this._observer=new MutationObserver(Ho((()=>this._update()),100)),this._observer.observe(this._pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=t.reanchoringMaxWait??3e3,this._banner=new pr,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const e=i.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!e.isCollapsed)},this._listeners=new n,
121
+ this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){this.fitSideBySide({expanded:!1,width:0,toolbarWidth:0,height:window.innerHeight}),this._listeners.removeAll(),this._pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this._observer.disconnect(),this._banner.destroy(),this._destroyed=!0}uri(){return this._pdfMetadata.getUri()}getMetadata(){return this._pdfMetadata.getMetadata()}showContentInfo(e){this._banner.setContentInfo(e)}anchor(e,t){return ir(0,t)}getAnnotatableRange(e){try{const t=ri.trimmedRange(e);if(function(e){try{return or(e),!0}catch{return!1}}(t))return t}catch(e){if(!(e instanceof RangeError))throw e}return null}canStyleClusteredHighlights(){return!0}describe(e,t){return rr(e,t)}async _checkForSelectableText(){try{await this.uri()}catch(e){return}if(!this._destroyed)try{const e=await async function(){const e=Yo();let t=!1;for(let n=0;n<e.pagesCount;n++)if((await Ko(n)).trim().length>0){t=!0;break}return t}()
122
+ ;this._banner.showNoTextWarning(!e)}catch(e){console.warn("Unable to check for text in PDF:",e)}}_update(){const e=[],t=this._pdfViewer.pagesCount;for(let e=0;e<t;e++){const t=this._pdfViewer.getPageView(e);if(t?.textLayer&&er(t.textLayer))switch(t.renderingState){case Wo.INITIAL:t.textLayer=null;break;case Wo.FINISHED:n=t.div,n.querySelector(si)?.remove()}}var n;for(const t of this._annotator.anchors)if(t.highlights){if(e.includes(t.annotation))continue;for(let n=0;n<t.highlights.length;n++){const i=t.highlights[n];if(!document.body.contains(i)){t.highlights.splice(n,1),delete t.range,e.push(t.annotation);break}}}e.map((e=>this._annotator.anchor(e)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(e){const t=window.innerWidth-e.width,n=e.expanded&&t>=680,i=n?e.width:e.toolbarWidth;this._pdfContainer.style.width=`calc(100% - ${i}px)`;const o=this._pdfViewer.currentScaleValue;return"auto"!==o&&"page-fit"!==o&&"page-width"!==o||(this._pdfViewer.currentScaleValue=o),
123
+ this._pdfViewer.update(),this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}async scrollToAnchor(e){const t=e.annotation,n=fr(e),i=this._anchorOffset(e);if(null!==i&&(await bo(this.contentContainer(),i),n)){const e=await this._waitForAnnotationToBeAnchored(t,this._reanchoringMaxWait);if(!e)return;const n=this._anchorOffset(e);if(null===n)return;await bo(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(e,t){const n=Date.now();let i;do{i=this._annotator.anchors.find((t=>t.annotation===e)),i&&!fr(i)||(i=null,await mr(20))}while(!i&&Date.now()-n<t);return i??null}_anchorOffset(e){if(!e.highlights)return null;return function(e,t){let n=0;for(;e!==t&&t.contains(e);)n+=e.offsetTop,e=e.offsetParent;return n}(e.highlights[0],this.contentContainer())}}function _r(e){if(!e.includes("["))return e;let t="",n=!1,i=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&i&&"]"===o?i=!1:i||(t+=o):i=!0,n=!1):n=!0;return t}function br(e){const t=_r(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)
124
+ }class vr{constructor(e,t,n){this._element=e,this._onFrameAdded=t,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Ho((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(e){this._annotatableFrames.add(e);try{if(await yr(e),this._isDisconnected)return;e.contentWindow.addEventListener("unload",(()=>{this._removeFrame(e)})),this._onFrameAdded(e)}catch(t){console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${e.src}')`)}}_removeFrame(e){this._annotatableFrames.delete(e),this._onFrameRemoved(e)}_discoverFrames(){const e=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const t of e)this._annotatableFrames.has(t)||this._addFrame(t)
125
+ ;for(const t of this._annotatableFrames)e.has(t)||this._removeFrame(t)}}function yr(e){return new Promise(((t,n)=>{const i=wr(e,((e,o)=>{i(),o?t(o):n(e)}))}))}function wr(e,t,{pollInterval:n=10}={}){let i,o;const r=new WeakSet,s=()=>{clearTimeout(i),i=void 0},a=()=>{const n=e.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),!function(e){return"about:blank"===e.contentDocument?.location.href&&e.hasAttribute("src")&&"about:blank"!==e.src}(e)){"interactive"===n.readyState||"complete"===n.readyState?t(null,n):n.addEventListener("DOMContentLoaded",(()=>t(null,n)))}e.contentDocument&&e.contentWindow?.addEventListener("unload",o)}}else{s();const n=e.isConnected?"Frame is cross-origin":"Frame is disconnected";t(new Error(n))}};let l=!1;o=()=>{s(),l||(i=setInterval(a,n))},e.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),e.removeEventListener("load",a)}}class xr{constructor(e,t){this._config=t,this._frameObserver=new vr(e,(e=>Cr(e,t)),(()=>{}))}destroy(){
126
+ this._frameObserver.disconnect()}}async function Cr(e,t,n){if(null!==e.contentDocument.querySelector("script.js-hypothesis-config"))return;await yr(e);const{assetRoot:i,notebookAppUrl:r,profileAppUrl:s,sidebarAppUrl:a}=C(document),l={...t,assetRoot:i,notebookAppUrl:r,profileAppUrl:s,sidebarAppUrl:a,subFrameIdentifier:n??o(10)},c=document.createElement("script");c.className="js-hypothesis-config",c.setAttribute("data-remove-on-unload",""),c.type="application/json",c.innerText=JSON.stringify(l);const u=document.createElement("script");u.async=!0,u.src=t.clientUrl;const h=e.contentDocument;h.body.appendChild(c),h.body.appendChild(u)}class Nr{constructor(e,t,i){if(t.length!==i.length)throw new Error("Char boxes length does not match text length");const o=e.parentNode,r=document.createElement("hypothesis-text-layer");o.insertBefore(r,e.nextSibling),o.style.position="relative",r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.color="transparent",r.style.textAlign="left",
127
127
  r.style.mixBlendMode="multiply";const s="sans-serif";r.style.fontSize="16px",r.style.fontFamily=s;const a=document.createElement("canvas").getContext("2d");a.font=`16px ${s}`;const l=(e,t,n="px")=>`calc(var(--${e}-scale) * ${t}${n})`,c=function(e,t){const n=[];let i={text:"",rect:new DOMRect};const o=()=>{i.text.length>0&&(n.push(i),i={text:"",rect:new DOMRect})};for(const[n,r]of e.entries()){const e=t[n],s=/\s/.test(e);i.text.length>0&&!k(i.rect,r)&&o(),i.rect=R(i.rect,r),i.text+=s?" ":e,s&&o()}o();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(const e of n){const t=s.words[s.words.length-1];if(t){const n=P(t.rect),i=P(e.rect).x-n.x;(!k(t.rect,e.rect)||i<0)&&a()}s.words.push(e),s.rect=R(s.rect,e.rect)}a();const l=[];let c={lines:[],rect:new DOMRect};const u=()=>{c.lines.length>0&&(l.push(c),c={lines:[],rect:new DOMRect})};for(const e of r){const t=c.lines[c.lines.length-1];if(t){const n=P(t.rect),i=P(e.rect).y-n.y
128
128
  ;(!T(t.rect,e.rect)||k(t.rect,e.rect)||i<0||i>4*e.rect.height)&&u()}c.lines.push(e),c.rect=R(c.rect,e.rect)}return u(),l}(t,i);for(const e of c){const t=document.createElement("hypothesis-text-column");t.style.display="block",t.style.position="absolute",t.style.left=l("x",e.rect.left),t.style.top=l("y",e.rect.top);let n=null;for(const i of e.lines){const o=document.createElement("hypothesis-text-line");o.style.display="block",o.style.marginLeft=l("x",i.rect.left-e.rect.left),o.style.height=l("y",i.rect.height),n&&(o.style.marginTop=l("y",i.rect.top-n.rect.bottom)),n=i,o.style.whiteSpace="nowrap";let r=null;for(const e of i.words){const t=document.createElement("hypothesis-text-word");t.style.display="inline-block",t.style.transformOrigin="top left",t.textContent=e.text,r&&(t.style.marginLeft=l("x",e.rect.left-r.rect.right)),r=e,t.style.width=l("x",e.rect.width),t.style.height=l("y",e.rect.height),t.style.whiteSpace="pre"
129
- ;const n=a.measureText(e.text),i=l("x",e.rect.width/n.width,""),s=l("y",e.rect.height/16,"");t.style.transform=`scale(${i}, ${s})`,o.append(t)}t.append(o)}r.append(t)}const u=()=>{const{width:t,height:n}=e.getBoundingClientRect();r.style.width=t+"px",r.style.height=n+"px",r.style.setProperty("--x-scale",`${t}`),r.style.setProperty("--y-scale",`${n}`)};u(),this.container=r,this._updateTextLayerSize=Ho(u,{maxWait:50}),this._listeners=new n,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(e)),this._listeners.add(window,"resize",this._updateTextLayerSize)}updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),this._imageSizeObserver?.disconnect()}}function Nr(e=document){return e.querySelector("mosaic-book")}function Sr(e=window){if(Nr(e.document))return"container"
130
- ;const t=e.frameElement?.ownerDocument;return t&&Nr(t)?"content":null}class Er{constructor(e){const t=Nr();if(!t)throw new Error("Book container element not found");const n=new WeakSet,i=t.shadowRoot,o=()=>{const t=i.querySelector("iframe");t&&!n.has(t)&&(n.add(t),yr(t,((n,i)=>{if(n)return;const o=i.body;o&&!o.querySelector("#page-content")&&xr(t,e,"vitalsource-content")})))};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(i,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function Ar(){return document.querySelector("img#pbk-page")}class kr extends u{constructor(e=document.body,t={}){super();const i=t.bookElement??Nr(window.parent.document);if(!i)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=i;const o=new Pi;this._htmlIntegration=new wo({container:e,features:o}),this._listeners=new n;const r=["mouseup","mousedown","mouseout"];for(const e of r)this._listeners.add(document.documentElement,e,(e=>{e.stopPropagation()
131
- }));const s=window.frameElement;s&&function(e){if("no"!==e.getAttribute("scrolling"))return;const t=document.createElement("style");t.textContent="iframe { height: 100% !important; }",e.insertAdjacentElement("beforebegin",t);const n=()=>e.removeAttribute("scrolling");n(),new MutationObserver(n).observe(e,{attributes:!0})}(s);const a=Ar(),l=window.innerPageData;if(a&&l){const e=l.glyphs.glyphs.map((e=>{const t=e.l/100,n=e.r/100,i=e.t/100,o=e.b/100;return new DOMRect(t,i,n-t,o-i)}));this._textLayer=new Cr(a,e,l.words),this._textLayer.container.style.zIndex="100",this._sideBySideActive=!1}}getAnnotatableRange(e){return this._htmlIntegration.getAnnotatableRange(e)}destroy(){this._textLayer&&(this._textLayer.destroy(),this.fitSideBySide({expanded:!1,height:window.innerHeight,width:0,toolbarWidth:0})),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(e,t){return this._htmlIntegration.anchor(e,t)}async describe(e,t){
132
- const n=this._htmlIntegration.describe(e,t),{cfi:i,index:o,page:r,title:s,url:a}=await this._getPageInfo({includeTitle:!0,includePageIndex:!0}),l=[{type:"EPUBContentSelector",cfi:i,url:a,title:s}];if("number"==typeof o){const e={type:"PageSelector",index:o,label:r};l.push(e)}return n.push(...l),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(e){const t=Ar();if(t&&this._textLayer){const n=t.parentElement,i=this._textLayer,o=window.innerWidth-e.width;return this._sideBySideActive=!1,V((()=>{e.expanded&&o>480?(n.style.textAlign="left",t.style.width=`${o}px`,this._sideBySideActive=!0):(n.style.textAlign="",t.style.width=""),i.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(e)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}async getMetadata(){return{title:this._bookElement.getBookInfo().title,link:[]}}navigateToSegment(e){
133
- const t=e.target[0].selector?.find((e=>"EPUBContentSelector"===e.type));if(t?.cfi)this._bookElement.goToCfi(t.cfi);else{if(!t?.url)throw new Error("No segment information available");this._bookElement.goToURL(function(e){const t=new URL(e,document.baseURI);return t.pathname+t.search}(t.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:e=!1,includePageIndex:t=!1}={}){const[n,i,o]=await Promise.all([this._bookElement.getCurrentPage(),e?this._bookElement.getTOC():void 0,t?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const e of r)if(!(e in n))throw new Error(`Page metadata field "${e}" is missing`);let s;if(i){s=n.chapterTitle;const e=_r(n.cfi),t=i.data?.find((t=>_r(t.cfi)===e));t&&(s=t.title)}let a=n.index;if(void 0===a&&o){const e=o.data?.findIndex((e=>e.cfi===n.cfi));-1!==e&&(a=e)}return{cfi:n.cfi,index:a,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(e){let t=[];try{const e=await this._bookElement.getPageBreaks()
134
- ;e.ok&&e.data&&(t=e.data)}catch(e){console.error("Failed to get page breaks",e)}const n=gr(e),i=t.filter((e=>e.cfiWithoutAssertions.split("!")[0]===n));let o;if(i.length>0){o={start:i[0].label,end:i[i.length-1].label}}return o}async segmentInfo(){const{cfi:e,url:t}=await this._getPageInfo();return{cfi:e,pages:await this._getPageRange(e),url:t}}async uri(){const e=this._bookElement.getBookInfo().isbn;if(!e)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${e}`}async scrollToAnchor(e){return this._htmlIntegration.scrollToAnchor(e)}}function Tr(e){if(void 0!==window.PDFViewerApplication)return new pr(e);return"content"===Sr()?new kr(document.body):new wo({features:e.features,sideBySideOptions:e.sideBySide})}function Rr(){return wt(On,{classes:"fixed left-[10px] top-[10px]","data-testid":"outside-assignment-notice",status:"notice",variant:"raised",children:"You are outside the page range for this assignment. Annotations made here may not be counted."
135
- })}class Pr{constructor(e){this._visible=!1,this._container=new Xn("notice",(()=>this._render())),e.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(e){this._visible=e,this._container.render()}_render(){return this._visible?wt(Rr,{}):null}}class Or{constructor(e,t=document){let i=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{e(ci(t.getSelection()))}),n)},r=e=>{if("mousedown"===e.type&&(i=!0),"mouseup"===e.type&&(i=!1),i)return;this._cancelPendingCallback();const t="mouseup"===e.type?10:100;o(t)};this._document=t,this._listeners=new n,this._listeners.add(t,"selectionchange",r),this._listeners.add(t.body,"mousedown",r),this._listeners.add(t.body,"mouseup",r),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function Ir(e,t){if(e===t)return!0;if(e.parent!==t)return!1;if(!e.frameElement)return!1
136
- ;return e.frameElement.getBoundingClientRect().width/e.parent.innerWidth>=.8}function Mr(){return function(e,t){const n=new Set,i=new Set;return di(e,(e=>{for(;e&&!n.has(e);){n.add(e);const o=t(e);null!=o&&i.add(o),e=e.parentNode}})),[...i]}(ci()??new Range,(e=>e._annotation?.$tag))}function Lr(e){const t=function(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;const n=[];for(;t;)t.classList.contains("hypothesis-highlight")&&n.push(t),t=t.parentElement;return n}(e).map((e=>e._annotation)).filter((e=>void 0!==e)).map((e=>e?.$tag));return t}function Br(e){if(!e.range)return null;try{return e.range.toRange()}catch{return null}}function Dr(){document.getSelection()?.removeAllRanges()}class Fr extends CustomEvent{constructor(e){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:e}),this._ready=null}get ready(){return this._ready}waitUntil(e){this._ready=e}}class Hr extends u{constructor(e,t={},i=window){super(),this.element=e,this._contentReady=t.contentReady,this._hostFrame=i,
137
- this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._adder=new Kn(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:e=>this.selectAnnotations(e,{focusInSidebar:!0})}),this._selectionObserver=new Or((e=>{e?this._onSelection(e):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=t.subFrameIdentifier||null,this._portFinder=new a({hostFrame:this._hostFrame,source:"guest",sourceId:this._frameIdentifier??void 0}),this.features=new Pi,this._featureFlagsReceived=new Promise((e=>{this.features.on("flagsChanged",e)})),this.sideBySide=t.sideBySide,this._integration=Tr(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),t.contentInfoBanner&&this._integration.showContentInfo?.(t.contentInfoBanner),
138
- this._integration.canStyleClusteredHighlights?.()&&(this._clusterToolbar=new Bi(this._integration.contentContainer(),{features:this.features})),this._hostRPC=new w,this._connectHost(i),this._sidebarRPC=new w,this._sidebarLayout=null,this._connectSidebar(),this._bucketBarClient=new Ei({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new n,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){return"manual"===this.sideBySide?.mode&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(e=>{const{target:t,metaKey:n,ctrlKey:i}=e,o=Lr(t);if(o.length&&this._highlightsVisible){const e=n||i;this.selectAnnotations(o,{toggle:e})}})),this._listeners.add(this.element,"pointerdown",(e=>{
139
- this._sideBySideActive()||Lr(e.target).length||Ir(window,this._hostFrame)&&this._sidebarLayout?.expanded&&window.innerWidth-e.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),this._listeners.add(this.element,"mouseover",(({target:e})=>{const t=Lr(e);t.length&&this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",t)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(e=>{this._handleShortcut(e)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){const[e,t,n]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),this._integration.segmentInfo?.()]);return{uri:vo(e),metadata:t,segmentInfo:n,persistent:this._integration.persistFrame?.()??!1}}async _sendDocumentInfo(){this._integration.waitForFeatureFlags?.()&&await this._featureFlagsReceived;const e=await this.getDocumentInfo()
140
- ;this._sidebarRPC.call("documentInfoChanged",e)}_repositionAdder(){if(!this._isAdderVisible)return;const e=ci();e&&this._onSelection(e)}async _connectHost(e){this._hostRPC.on("clearSelection",(()=>{ci()&&(this._informHostOnNextSelectionClear=!1,Dr())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._hostRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),this._hostRPC.on("selectAnnotations",((e,t)=>this.selectAnnotations(e,{toggle:t}))),this._hostRPC.on("sidebarLayoutChanged",(t=>{Ir(window,e)&&this.fitSideBySide(t),this.element.dispatchEvent(new Ai({sidebarLayout:t,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected")));const t=await this._portFinder.discover("host");this._hostRPC.connect(t)}async _scrollToAnchor(e){const t=Br(e);if(!t)return;const n=new Fr(t);this.element.dispatchEvent(n)&&(await n.ready,await this._integration.scrollToAnchor(e))}
129
+ ;const n=a.measureText(e.text),i=l("x",e.rect.width/n.width,""),s=l("y",e.rect.height/16,"");t.style.transform=`scale(${i}, ${s})`,o.append(t)}t.append(o)}r.append(t)}const u=()=>{const{width:t,height:n}=e.getBoundingClientRect();r.style.width=t+"px",r.style.height=n+"px",r.style.setProperty("--x-scale",`${t}`),r.style.setProperty("--y-scale",`${n}`)};u(),this.container=r,this._updateTextLayerSize=Ho(u,{maxWait:50}),this._listeners=new n,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(e)),this._listeners.add(window,"resize",this._updateTextLayerSize)}updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),this._imageSizeObserver?.disconnect()}}function Sr(e=document){return e.querySelector("mosaic-book")}function Er(e=window){if(Sr(e.document))return"container"
130
+ ;const t=e.frameElement?.ownerDocument;return t&&Sr(t)?"content":null}class Ar{constructor(e){const t=Sr();if(!t)throw new Error("Book container element not found");const n=new WeakSet,i=t.shadowRoot,o=()=>{const t=i.querySelector("iframe");t&&!n.has(t)&&(n.add(t),wr(t,((n,i)=>{if(n)return;const o=i.body;o&&!o.querySelector("#page-content")&&Cr(t,e,"vitalsource-content")})))};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(i,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function kr(){return document.querySelector("img#pbk-page")}class Tr extends u{constructor(e=document.body,t={}){super();const i=t.bookElement??Sr(window.parent.document);if(!i)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=i;const o=new Pi;this._htmlIntegration=new wo({container:e,features:o}),this._listeners=new n;const r=["mouseup","mousedown","mouseout"];for(const e of r)this._listeners.add(document.documentElement,e,(e=>{e.stopPropagation()
131
+ }));const s=window.frameElement;s&&function(e){if("no"!==e.getAttribute("scrolling"))return;const t=document.createElement("style");t.textContent="iframe { height: 100% !important; }",e.insertAdjacentElement("beforebegin",t);const n=()=>e.removeAttribute("scrolling");n(),new MutationObserver(n).observe(e,{attributes:!0})}(s);const a=kr(),l=window.innerPageData;if(a&&l){const e=l.glyphs.glyphs.map((e=>{const t=e.l/100,n=e.r/100,i=e.t/100,o=e.b/100;return new DOMRect(t,i,n-t,o-i)}));this._textLayer=new Nr(a,e,l.words),this._textLayer.container.style.zIndex="100",this._sideBySideActive=!1}}getAnnotatableRange(e){return this._htmlIntegration.getAnnotatableRange(e)}destroy(){this._textLayer&&(this._textLayer.destroy(),this.fitSideBySide({expanded:!1,height:window.innerHeight,width:0,toolbarWidth:0})),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(e,t){return this._htmlIntegration.anchor(e,t)}async describe(e,t){
132
+ const n=this._htmlIntegration.describe(e,t),{cfi:i,index:o,page:r,title:s,url:a}=await this._getPageInfo({includeTitle:!0,includePageIndex:!0}),l=[{type:"EPUBContentSelector",cfi:i,url:a,title:s}];if("number"==typeof o){const e={type:"PageSelector",index:o,label:r};l.push(e)}return n.push(...l),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(e){const t=kr();if(t&&this._textLayer){const n=t.parentElement,i=this._textLayer,o=window.innerWidth-e.width;return this._sideBySideActive=!1,V((()=>{e.expanded&&o>480?(n.style.textAlign="left",t.style.width=`${o}px`,this._sideBySideActive=!0):(n.style.textAlign="",t.style.width=""),i.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(e)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}async getMetadata(){return{title:this._bookElement.getBookInfo().title,link:[]}}navigateToSegment(e){
133
+ const t=e.target[0].selector?.find((e=>"EPUBContentSelector"===e.type));if(t?.cfi)this._bookElement.goToCfi(t.cfi);else{if(!t?.url)throw new Error("No segment information available");this._bookElement.goToURL(function(e){const t=new URL(e,document.baseURI);return t.pathname+t.search}(t.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:e=!1,includePageIndex:t=!1}={}){const[n,i,o]=await Promise.all([this._bookElement.getCurrentPage(),e?this._bookElement.getTOC():void 0,t?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const e of r)if(!(e in n))throw new Error(`Page metadata field "${e}" is missing`);let s;if(i){s=n.chapterTitle;const e=br(n.cfi),t=i.data?.find((t=>br(t.cfi)===e));t&&(s=t.title)}let a=n.index;if(void 0===a&&o){const e=o.data?.findIndex((e=>e.cfi===n.cfi));-1!==e&&(a=e)}return{cfi:n.cfi,index:a,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(e){let t=[];try{const e=await this._bookElement.getPageBreaks()
134
+ ;e.ok&&e.data&&(t=e.data)}catch(e){console.error("Failed to get page breaks",e)}const n=_r(e),i=t.filter((e=>e.cfiWithoutAssertions.split("!")[0]===n));let o;if(i.length>0){o={start:i[0].label,end:i[i.length-1].label}}return o}async segmentInfo(){const{cfi:e,url:t}=await this._getPageInfo();return{cfi:e,pages:await this._getPageRange(e),url:t}}async uri(){const e=this._bookElement.getBookInfo().isbn;if(!e)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${e}`}async scrollToAnchor(e){return this._htmlIntegration.scrollToAnchor(e)}}function Rr(e){if(void 0!==window.PDFViewerApplication)return new gr(e);return"content"===Er()?new Tr(document.body):new wo({features:e.features,sideBySideOptions:e.sideBySide})}function Pr(){return wt(On,{classes:"fixed left-[10px] top-[10px]","data-testid":"outside-assignment-notice",status:"notice",variant:"raised",children:"You are outside the page range for this assignment. Annotations made here may not be counted."
135
+ })}class Or{constructor(e){this._visible=!1,this._container=new Xn("notice",(()=>this._render())),e.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(e){this._visible=e,this._container.render()}_render(){return this._visible?wt(Pr,{}):null}}class Ir{constructor(e,t=document){let i=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{e(ci(t.getSelection()))}),n)},r=e=>{if("mousedown"===e.type&&(i=!0),"mouseup"===e.type&&(i=!1),i)return;this._cancelPendingCallback();const t="mouseup"===e.type?10:100;o(t)};this._document=t,this._listeners=new n,this._listeners.add(t,"selectionchange",r),this._listeners.add(t.body,"mousedown",r),this._listeners.add(t.body,"mouseup",r),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function Mr(e,t){if(e===t)return!0;if(e.parent!==t)return!1;if(!e.frameElement)return!1
136
+ ;return e.frameElement.getBoundingClientRect().width/e.parent.innerWidth>=.8}function Lr(){return function(e,t){const n=new Set,i=new Set;return di(e,(e=>{for(;e&&!n.has(e);){n.add(e);const o=t(e);null!=o&&i.add(o),e=e.parentNode}})),[...i]}(ci()??new Range,(e=>e._annotation?.$tag))}function Br(e){const t=function(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;const n=[];for(;t;)t.classList.contains("hypothesis-highlight")&&n.push(t),t=t.parentElement;return n}(e).map((e=>e._annotation)).filter((e=>void 0!==e)).map((e=>e?.$tag));return t}function Dr(e){if(!e.range)return null;try{return e.range.toRange()}catch{return null}}function Fr(){document.getSelection()?.removeAllRanges()}class Hr extends CustomEvent{constructor(e){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:e}),this._ready=null}get ready(){return this._ready}waitUntil(e){this._ready=e}}class Vr extends u{constructor(e,t={},i=window){super(),this.element=e,this._contentReady=t.contentReady,this._hostFrame=i,
137
+ this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._adder=new Kn(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:e=>this.selectAnnotations(e,{focusInSidebar:!0})}),this._selectionObserver=new Ir((e=>{e?this._onSelection(e):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=t.subFrameIdentifier||null,this._portFinder=new a({hostFrame:this._hostFrame,source:"guest",sourceId:this._frameIdentifier??void 0}),this.features=new Pi,this._featureFlagsReceived=new Promise((e=>{this.features.on("flagsChanged",e)})),this.sideBySide=t.sideBySide,this._integration=Rr(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),t.contentInfoBanner&&this._integration.showContentInfo?.(t.contentInfoBanner),
138
+ this._integration.canStyleClusteredHighlights?.()&&(this._clusterToolbar=new Bi(this._integration.contentContainer(),{features:this.features})),this._hostRPC=new w,this._connectHost(i),this._sidebarRPC=new w,this._sidebarLayout=null,this._connectSidebar(),this._bucketBarClient=new Ei({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new n,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){return"manual"===this.sideBySide?.mode&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(e=>{const{target:t,metaKey:n,ctrlKey:i}=e,o=Br(t);if(o.length&&this._highlightsVisible){const e=n||i;this.selectAnnotations(o,{toggle:e})}})),this._listeners.add(this.element,"pointerdown",(e=>{
139
+ this._sideBySideActive()||Br(e.target).length||Mr(window,this._hostFrame)&&this._sidebarLayout?.expanded&&window.innerWidth-e.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),this._listeners.add(this.element,"mouseover",(({target:e})=>{const t=Br(e);t.length&&this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",t)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(e=>{this._handleShortcut(e)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){const[e,t,n]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),this._integration.segmentInfo?.()]);return{uri:vo(e),metadata:t,segmentInfo:n,persistent:this._integration.persistFrame?.()??!1}}async _sendDocumentInfo(){this._integration.waitForFeatureFlags?.()&&await this._featureFlagsReceived;const e=await this.getDocumentInfo()
140
+ ;this._sidebarRPC.call("documentInfoChanged",e)}_repositionAdder(){if(!this._isAdderVisible)return;const e=ci();e&&this._onSelection(e)}async _connectHost(e){this._hostRPC.on("clearSelection",(()=>{ci()&&(this._informHostOnNextSelectionClear=!1,Fr())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._hostRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),this._hostRPC.on("selectAnnotations",((e,t)=>this.selectAnnotations(e,{toggle:t}))),this._hostRPC.on("sidebarLayoutChanged",(t=>{Mr(window,e)&&this.fitSideBySide(t),this.element.dispatchEvent(new Ai({sidebarLayout:t,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected")));const t=await this._portFinder.discover("host");this._hostRPC.connect(t)}async _scrollToAnchor(e){const t=Dr(e);if(!t)return;const n=new Hr(t);this.element.dispatchEvent(n)&&(await n.ready,await this._integration.scrollToAnchor(e))}
141
141
  async _scrollToAnnotation(e){const t=this.anchors.find((t=>t.annotation.$tag===e));t?.highlights&&await this._scrollToAnchor(t)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(e=>this.features.update(e))),this._sidebarRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._sidebarRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),this._sidebarRPC.on("setHighlightsVisible",(e=>{this.setHighlightsVisible(e,!1)})),this._sidebarRPC.on("deleteAnnotation",(e=>this.detach(e))),this._sidebarRPC.on("loadAnnotations",(async e=>{try{await Promise.all(e.map((e=>this.anchor(e))))}catch(e){console.warn("Failed to anchor annotations:",e)}})),this._sidebarRPC.on("showContentInfo",(e=>this._integration.showContentInfo?.(e))),this._sidebarRPC.on("setOutsideAssignmentNoticeVisible",(e=>{this._setOutsideAssignmentNoticeVisible(e)})),this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?.(e))),this._portFinder.discover("sidebar").then((e=>{
142
- this._sidebarRPC.connect(e)})),this._sendDocumentInfo()}destroy(){this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),this._clusterToolbar?.destroy(),this._outsideAssignmentNotice?.destroy(),function(e){bi(Array.from(e.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(e){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const t=e=>{const t=Br(e);if(!t)return;const n=gi(t,e.annotation?.$cluster);n.forEach((t=>{t._annotation=e.annotation})),e.highlights=n,this._hoveredAnnotations.has(e.annotation.$tag)&&vi(n,!0)};this.detach(e.$tag,!1),this._annotations.add(e.$tag),e.target||(e.target=[]);const n=await Promise.all(e.target.map((async t=>{if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type)))return{annotation:e,target:t};let n;try{
142
+ this._sidebarRPC.connect(e)})),this._sendDocumentInfo()}destroy(){this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),this._clusterToolbar?.destroy(),this._outsideAssignmentNotice?.destroy(),function(e){bi(Array.from(e.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(e){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const t=e=>{const t=Dr(e);if(!t)return;const n=gi(t,e.annotation?.$cluster);n.forEach((t=>{t._annotation=e.annotation})),e.highlights=n,this._hoveredAnnotations.has(e.annotation.$tag)&&vi(n,!0)};this.detach(e.$tag,!1),this._annotations.add(e.$tag),e.target||(e.target=[]);const n=await Promise.all(e.target.map((async t=>{if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type)))return{annotation:e,target:t};let n;try{
143
143
  const i=await this._integration.anchor(this.element,t.selector),o=ri.fromRange(i);n={annotation:e,target:t,range:o}}catch(i){n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&bi(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,r=(await Promise.all(t.map((e=>this._integration.describe(i,e))))).map((e=>({source:n.uri,selector:e}))),s={uri:n.uri,document:n.metadata,target:r,$highlight:e,
144
- $cluster:e?"user-highlights":"user-annotations",$tag:"a:"+o(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Dr(),s}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);vi(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),i=ui(n),o=fi(n);o?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Mr(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){
145
- t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){at(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Pr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Vr(e,t){const n=new URL(e),i=new URLSearchParams;return i.append("config",JSON.stringify(t)),n.hash=i.toString(),n.toString()}function Ur(e,t){const n={}
146
- ;for(const[e,i]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=i&&(n[e]=i);n.origin=new URL(e).origin,n.version="1.1517.0";const i=new URL(window.location.href);if(i.hash="",n.hostURL=i.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function qr({closed:e,onClose:t,children:n,"data-testid":i,"aria-label":o}){const r=Ye(null);return je((()=>{e?r.current?.close():r.current?.showModal()}),[e]),je((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),wt("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":i,"aria-label":o,children:n})}function Wr({closed:e,children:t,...n}){return wt("div",{...n,
147
- className:vt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:wt("div",{className:"relative w-full h-full",children:t})})}function $r({document_:e=document,...t}){return wt(Ge((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?qr:Wr),[e]),{...t})}function zr({config:e,groupId:t}){return wt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Vr(e.notebookAppUrl,{...Ur(e.notebookAppUrl,e),group:t})})}function jr({eventBus:e,config:t}){const[n,i]=ze(0),[o,r]=ze(!0),[s,a]=ze(null),l=Ye(""),c=Ye(null);je((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),je((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),je((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),i((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const u=Ke((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
148
- ;return null===s?null:wt($r,{closed:o,onClose:u,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[wt("div",{className:"absolute right-0 m-3",children:wt(_n,{title:"Close notebook",onClick:u,variant:"dark",classes:vt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:wt(Tt,{className:"w-4 h-4"})})}),wt(zr,{config:t,groupId:s},n)]})}class Xr{constructor(e,t,n){this._container=new Xn("notebook",(()=>wt(jr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Yr({eventBus:e,config:t}){const[n,i]=ze(!0),o=Ye(null);je((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{i(!1)})),o.current=t,()=>{t.destroy()}}),[e]);const r=()=>{i(!0),o.current?.publish("closeProfile")};return n?null:wt($r,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[wt("div",{className:"absolute right-0 m-3",children:wt(_n,{
149
- title:"Close profile dialog",onClick:r,variant:"dark",classes:vt("!bg-transparent enabled:hover:!bg-grey-3"),children:wt(Tt,{className:"w-4 h-4"})})}),wt("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Gr{constructor(e,t,n){this._container=new Xn("profile",(()=>wt(Yr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}var Kr={exports:{}};!function(e){!function(t,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,u=Math.abs,h=Date.now;function d(e,t,n){return setTimeout(v(e,n),t)}function f(e,t,n){return!!Array.isArray(e)&&(m(e,n[t],n),!0)}function m(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==o)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function p(e,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
144
+ $cluster:e?"user-highlights":"user-annotations",$tag:"a:"+o(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Fr(),s}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);vi(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e);if(!t)return void this._onClearSelection();const n=document.getSelection(),i=ui(n),o=fi(n);o?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Lr(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(e,{toggle:t=!1,focusInSidebar:n=!1}={}){
145
+ t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(e){at(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Or(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Ur(e,t){const n=new URL(e),i=new URLSearchParams;return i.append("config",JSON.stringify(t)),n.hash=i.toString(),n.toString()}function qr(e,t){const n={}
146
+ ;for(const[e,i]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=i&&(n[e]=i);n.origin=new URL(e).origin,n.version="1.1518.0";const i=new URL(window.location.href);if(i.hash="",n.hostURL=i.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}function Wr({closed:e,onClose:t,children:n,"data-testid":i,"aria-label":o}){const r=Ye(null);return je((()=>{e?r.current?.close():r.current?.showModal()}),[e]),je((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),wt("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":i,"aria-label":o,children:n})}function $r({closed:e,children:t,...n}){return wt("div",{...n,
147
+ className:vt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:wt("div",{className:"relative w-full h-full",children:t})})}function zr({document_:e=document,...t}){return wt(Ge((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Wr:$r),[e]),{...t})}function jr({config:e,groupId:t}){return wt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Ur(e.notebookAppUrl,{...qr(e.notebookAppUrl,e),group:t})})}function Xr({eventBus:e,config:t}){const[n,i]=ze(0),[o,r]=ze(!0),[s,a]=ze(null),l=Ye(""),c=Ye(null);je((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),je((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),je((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),i((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const u=Ke((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
148
+ ;return null===s?null:wt(zr,{closed:o,onClose:u,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[wt("div",{className:"absolute right-0 m-3",children:wt(_n,{title:"Close notebook",onClick:u,variant:"dark",classes:vt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:wt(Tt,{className:"w-4 h-4"})})}),wt(jr,{config:t,groupId:s},n)]})}class Yr{constructor(e,t,n){this._container=new Xn("notebook",(()=>wt(Xr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Gr({eventBus:e,config:t}){const[n,i]=ze(!0),o=Ye(null);je((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{i(!1)})),o.current=t,()=>{t.destroy()}}),[e]);const r=()=>{i(!0),o.current?.publish("closeProfile")};return n?null:wt(zr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[wt("div",{className:"absolute right-0 m-3",children:wt(_n,{
149
+ title:"Close profile dialog",onClick:r,variant:"dark",classes:vt("!bg-transparent enabled:hover:!bg-grey-3"),children:wt(Tt,{className:"w-4 h-4"})})}),wt("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Kr{constructor(e,t,n){this._container=new Xn("profile",(()=>wt(Gr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}var Qr={exports:{}};!function(e){!function(t,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,u=Math.abs,h=Date.now;function d(e,t,n){return setTimeout(v(e,n),t)}function f(e,t,n){return!!Array.isArray(e)&&(m(e,n[t],n),!0)}function m(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==o)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function p(e,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
150
150
  var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=t.console&&(t.console.warn||t.console.log);return r&&r.call(t.console,o,i),e.apply(this,arguments)}}r="function"!=typeof Object.assign?function(e){if(e===o||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}return t}:Object.assign;var g=p((function(e,t,n){for(var i=Object.keys(t),r=0;r<i.length;)(!n||n&&e[i[r]]===o)&&(e[i[r]]=t[i[r]]),r++;return e}),"extend","Use `assign`."),_=p((function(e,t){return g(e,t,!0)}),"merge","Use `assign`.");function b(e,t,n){var i,o=t.prototype;(i=e.prototype=Object.create(o)).constructor=e,i._super=o,n&&r(i,n)}function v(e,t){return function(){return e.apply(t,arguments)}}function y(e,t){return typeof e==l?e.apply(t&&t[0]||o,t):e}
151
151
  function w(e,t){return e===o?t:e}function x(e,t,n){m(E(t),(function(t){e.addEventListener(t,n,!1)}))}function C(e,t,n){m(E(t),(function(t){e.removeEventListener(t,n,!1)}))}function N(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function S(e,t){return e.indexOf(t)>-1}function E(e){return e.trim().split(/\s+/g)}function A(e,t,n){if(e.indexOf&&!n)return e.indexOf(t);for(var i=0;i<e.length;){if(n&&e[i][n]==t||!n&&e[i]===t)return i;i++}return-1}function k(e){return Array.prototype.slice.call(e,0)}function T(e,t,n){for(var i=[],o=[],r=0;r<e.length;){var s=e[r][t];A(o,s)<0&&i.push(e[r]),o[r]=s,r++}return i=i.sort((function(e,n){return e[t]>n[t]})),i}function R(e,t){for(var n,i,r=t[0].toUpperCase()+t.slice(1),a=0;a<s.length;){if((i=(n=s[a])?n+r:t)in e)return i;a++}return o}var P=1;function O(e){var n=e.ownerDocument||e;return n.defaultView||n.parentWindow||t}
152
152
  var I="ontouchstart"in t,M=R(t,"PointerEvent")!==o,L=I&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),B="touch",D="mouse",F=25,H=1,V=4,U=8,q=1,W=2,$=4,z=8,j=16,X=W|$,Y=z|j,G=X|Y,K=["x","y"],Q=["clientX","clientY"];function Z(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){y(e.options.enable,[e])&&n.handler(t)},this.init()}function J(e,t,n){var i=n.pointers.length,r=n.changedPointers.length,s=t&H&&i-r==0,a=t&(V|U)&&i-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(e.session={}),n.eventType=t,function(e,t){var n=e.session,i=t.pointers,r=i.length;n.firstInput||(n.firstInput=ee(t));r>1&&!n.firstMultiple?n.firstMultiple=ee(t):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,c=t.center=te(i);t.timeStamp=h(),t.deltaTime=t.timeStamp-s.timeStamp,t.angle=re(l,c),t.distance=oe(l,c),function(e,t){var n=t.center,i=e.offsetDelta||{},o=e.prevDelta||{},r=e.prevInput||{}
@@ -166,22 +166,22 @@ emit:function(e){var t=Ue(e.offsetDirection);t&&this.manager.emit(this.options.e
166
166
  emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Ke.VERSION="2.0.7",Ke.defaults={domEvents:!1,touchAction:Te,enable:!0,inputTarget:null,inputClass:null,preset:[[Xe,{enable:!1}],[ze,{enable:!1},["rotate"]],[Ye,{direction:X}],[$e,{direction:X},["swipe"]],[Ge],[Ge,{event:"doubletap",taps:2},["tap"]],[je]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Qe(e,t){var n;this.options=r({},Ke.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new((n=this).options.inputClass||(M?me:L?ye:I?Ce:ce))(n,J),this.touchAction=new Be(this,this.options.touchAction),Ze(this,!0),m(this.options.recognizers,(function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])}),this)}function Ze(e,t){var n,i=e.element
167
167
  ;i.style&&(m(e.options.cssProps,(function(o,r){n=R(i.style,r),t?(e.oldCssProps[n]=i.style[n],i.style[n]=o):i.style[n]=e.oldCssProps[n]||""})),t||(e.oldCssProps={}))}Qe.prototype={set:function(e){return r(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?2:1},recognize:function(e){var t=this.session;if(!t.stopped){var n;this.touchAction.preventDefaults(e);var i=this.recognizers,o=t.curRecognizer;(!o||o&&8&o.state)&&(o=t.curRecognizer=null);for(var r=0;r<i.length;)n=i[r],2===t.stopped||o&&n!=o&&!n.canRecognizeWith(o)?n.reset():n.recognize(e),!o&&14&n.state&&(o=t.curRecognizer=n),r++}},get:function(e){if(e instanceof He)return e;for(var t=this.recognizers,n=0;n<t.length;n++)if(t[n].options.event==e)return t[n];return null},add:function(e){if(f(e,"add",this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,
168
168
  this.touchAction.update(),e},remove:function(e){if(f(e,"remove",this))return this;if(e=this.get(e)){var t=this.recognizers,n=A(t,e);-1!==n&&(t.splice(n,1),this.touchAction.update())}return this},on:function(e,t){if(e!==o&&t!==o){var n=this.handlers;return m(E(e),(function(e){n[e]=n[e]||[],n[e].push(t)})),this}},off:function(e,t){if(e!==o){var n=this.handlers;return m(E(e),(function(e){t?n[e]&&n[e].splice(A(n[e],t),1):delete n[e]})),this}},emit:function(e,t){this.options.domEvents&&function(e,t){var i=n.createEvent("Event");i.initEvent(e,!0,!0),i.gesture=t,t.target.dispatchEvent(i)}(e,t);var i=this.handlers[e]&&this.handlers[e].slice();if(i&&i.length){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var o=0;o<i.length;)i[o](t),o++}},destroy:function(){this.element&&Ze(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(Ke,{INPUT_START:H,INPUT_MOVE:2,INPUT_END:V,INPUT_CANCEL:U,STATE_POSSIBLE:De,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,
169
- STATE_CANCELLED:16,STATE_FAILED:Fe,DIRECTION_NONE:q,DIRECTION_LEFT:W,DIRECTION_RIGHT:$,DIRECTION_UP:z,DIRECTION_DOWN:j,DIRECTION_HORIZONTAL:X,DIRECTION_VERTICAL:Y,DIRECTION_ALL:G,Manager:Qe,Input:Z,TouchAction:Be,TouchInput:ye,MouseInput:ce,PointerEventInput:me,TouchMouseInput:Ce,SingleTouchInput:ge,Recognizer:He,AttrRecognizer:We,Tap:Ge,Pan:$e,Swipe:Ye,Pinch:ze,Rotate:Xe,Press:je,on:x,off:C,each:m,merge:_,extend:g,assign:r,inherit:b,bindFn:v,prefixed:R}),(void 0!==t?t:"undefined"!=typeof self?self:{}).Hammer=Ke,e.exports?e.exports=Ke:t.Hammer=Ke}(window,document)}(Kr);var Qr=Kr.exports;function Zr({above:e,below:t,buckets:n,onFocusAnnotations:i,onScrollToAnnotation:o,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return wt("ul",{className:"relative",children:[s&&wt("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:wt(Vn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{
170
- const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];o(n.tag)},onBlur:()=>i([]),onFocus:()=>i(l(e)),onMouseEnter:()=>i(l(e)),onMouseOut:()=>i([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})}),n.map(((e,t)=>wt("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:e.position},children:wt(Vn,{direction:"left",onClick:t=>r(l(e),t.metaKey||t.ctrlKey),onBlur:()=>i([]),onFocus:()=>i(l(e)),onMouseEnter:()=>i(l(e)),onMouseOut:()=>i([]),title:`Select nearby annotations (${e.anchors.length})`,children:e.anchors.length})},t))),a&&wt("li",{className:"absolute right-0 pointer-events-auto",style:{top:t.position},children:wt(Vn,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const e=[...t.anchors].sort(((e,t)=>e.top-t.top)),n=e[0];o(n.tag)},onBlur:()=>i([]),onFocus:()=>i(l(t)),onMouseEnter:()=>i(l(t)),onMouseOut:()=>i([]),title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})})]})}class Jr{
169
+ STATE_CANCELLED:16,STATE_FAILED:Fe,DIRECTION_NONE:q,DIRECTION_LEFT:W,DIRECTION_RIGHT:$,DIRECTION_UP:z,DIRECTION_DOWN:j,DIRECTION_HORIZONTAL:X,DIRECTION_VERTICAL:Y,DIRECTION_ALL:G,Manager:Qe,Input:Z,TouchAction:Be,TouchInput:ye,MouseInput:ce,PointerEventInput:me,TouchMouseInput:Ce,SingleTouchInput:ge,Recognizer:He,AttrRecognizer:We,Tap:Ge,Pan:$e,Swipe:Ye,Pinch:ze,Rotate:Xe,Press:je,on:x,off:C,each:m,merge:_,extend:g,assign:r,inherit:b,bindFn:v,prefixed:R}),(void 0!==t?t:"undefined"!=typeof self?self:{}).Hammer=Ke,e.exports?e.exports=Ke:t.Hammer=Ke}(window,document)}(Qr);var Zr=Qr.exports;function Jr({above:e,below:t,buckets:n,onFocusAnnotations:i,onScrollToAnnotation:o,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return wt("ul",{className:"relative",children:[s&&wt("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:wt(Vn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{
170
+ const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];o(n.tag)},onBlur:()=>i([]),onFocus:()=>i(l(e)),onMouseEnter:()=>i(l(e)),onMouseOut:()=>i([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})}),n.map(((e,t)=>wt("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:e.position},children:wt(Vn,{direction:"left",onClick:t=>r(l(e),t.metaKey||t.ctrlKey),onBlur:()=>i([]),onFocus:()=>i(l(e)),onMouseEnter:()=>i(l(e)),onMouseOut:()=>i([]),title:`Select nearby annotations (${e.anchors.length})`,children:e.anchors.length})},t))),a&&wt("li",{className:"absolute right-0 pointer-events-auto",style:{top:t.position},children:wt(Vn,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const e=[...t.anchors].sort(((e,t)=>e.top-t.top)),n=e[0];o(n.tag)},onBlur:()=>i([]),onFocus:()=>i(l(t)),onMouseEnter:()=>i(l(t)),onMouseOut:()=>i([]),title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})})]})}class es{
171
171
  constructor(e,{onFocusAnnotations:t,onScrollToAnnotation:n,onSelectAnnotations:i}){this._positions=[],this._container=new Xn("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),e.appendChild(this._container.element),this._onFocusAnnotations=t,this._onScrollToAnnotation=n,this._onSelectAnnotations=i,this._container.render()}destroy(){this._container.destroy()}update(e){this._positions=e,this._container.render()}_render(){const e=function(e,t){const n=[],i=[],o=[];let r=null;function s(e){const{bottom:t,top:n}=e;return{bottom:t,position:n+(t-n)/2,anchors:[e],top:n}}const a=t.getBoundingClientRect(),l=e.map((e=>({tag:e.tag,top:e.top-a.top,bottom:e.bottom-a.top})));for(const e of l){const t=(e.top+e.bottom)/2;if(t<30){n.push(e);continue}if(t>a.height-30){i.push(e);continue}if(!r){r=s(e);continue}const l=e.top>r.top&&e.bottom<r.bottom;if(e.top-r.bottom>60&&!l)o.push(r),r=s(e);else{const t=e.bottom>r.bottom?e.bottom:r.bottom,n=t-r.top
172
- ;r.anchors.push(e),r.bottom=t,r.position=r.top+n/2}}return r&&o.push(r),{above:{anchors:n,position:30},below:{anchors:i,position:a.height-30},buckets:o}}(this._positions,this._container.element);return wt(Zr,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:e=>this._onFocusAnnotations(e),onScrollToAnnotation:e=>this._onScrollToAnnotation(e),onSelectAnnotations:(e,t)=>this._onSelectAnnotations(e,t)})}}function es({emitter:e}){const[t,n]=ze([]),i=Ke((e=>n((t=>[...t,e]))),[]),o=Ke((e=>n((t=>t.filter((t=>t.id!==e))))),[]);return je((()=>(e.subscribe("toastMessageAdded",i),e.subscribe("toastMessageDismissed",o),()=>{e.unsubscribe("toastMessageAdded",i),e.unsubscribe("toastMessageDismissed",o)})),[e,o,i]),wt(Bn,{messages:t,onMessageDismiss:o})}function ts({icon:e,...t}){return wt(mn,{classes:vt("justify-center rounded","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...t,size:"custom",variant:"custom",children:wt(e,{})})}function ns({highlightsVisible:e}){
173
- return wt("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:e?"Highlights visible":"Highlights hidden"})}function is({closeSidebar:e,createAnnotation:t,isSidebarOpen:n,sidebarContainerId:i,newAnnotationType:o,showHighlights:r,toggleHighlights:s,toggleSidebar:a,toggleSidebarRef:l,useMinimalControls:c=!1}){return wt("div",{className:vt("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[c&&n&&wt(mn,{classes:vt("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-px-1.5","flex items-center justify-center bg-white border","text-grey-6 hover:text-grey-9 transition-colors","border-r-0","shadow-sidebar"),title:"Close annotation sidebar",onClick:e,unstyled:!0,children:wt(Tt,{})}),!c&&wt(he,{children:[wt(mn,{classes:vt("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px] rounded-bl","bg-white text-grey-5 hover:text-grey-9","border-l border-b"),elementRef:l,title:"Annotation sidebar",expanded:n,
174
- "aria-controls":i,onClick:a,unstyled:!0,children:wt(n?Lt:It,{})}),wt("div",{className:"space-y-px-1.5 mt-px-2",children:[wt(ts,{title:"Show highlights",icon:r?dn:Xt,pressed:r,onClick:s}),wt(ts,{title:"note"===o?"New page note":"New annotation",icon:"note"===o?tn:At,onClick:t})]}),wt(ns,{highlightsVisible:r})]})]})}class os{constructor(e,t){const{createAnnotation:n,setSidebarOpen:i,setHighlightsVisible:o}=t;this._container=e,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._sidebarContainerId=t.sidebarContainerId,this._closeSidebar=()=>i(!1),this._toggleSidebar=()=>i(!this._sidebarOpen),this._toggleHighlights=()=>o(!this._highlightsVisible),this._createAnnotation=()=>{n(),i(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(e){this._useMinimalControls=e,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(e){
175
- this._sidebarOpen=e,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(e){this._newAnnotationType=e,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(e){this._highlightsVisible=e,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){Te(wt(is,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,sidebarContainerId:this._sidebarContainerId,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}const rs=280;class ss{constructor(e,t,i){if(this._emitter=t.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new w,this.iframe=function(e){
176
- const t=e.sidebarAppUrl,n=Vr(t,Ur(t,e)),i=document.createElement("iframe");return i.src=n,i.title="Hypothesis annotation viewer",i.className="sidebar-frame",i.allow="fullscreen; clipboard-write",i}(i),this._config=i,this.bucketBar=null,this.features=new Pi,i.externalContainerSelector)this.externalFrame=document.querySelector(i.externalContainerSelector)??e,this.externalFrame.appendChild(this.iframe);else{if(this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="sidebar-container",this.iframeContainer.id="sidebar-container","clean"===i.theme)this.iframeContainer.classList.add("theme-clean");else{let e;i.bucketContainerSelector&&(e=document.querySelector(i.bucketContainerSelector),e||console.warn(`Custom bucket container "${i.bucketContainerSelector}" not found`));const t=document.createElement("div");t.setAttribute("data-testid","sidebar-edge"),
177
- t.className=vt("absolute top-0 bottom-0 w-[23px] left-[-22px]","flex flex-col pt-[110px] pr-[5px]","bg-grey-2 sidebar-collapsed:bg-black/[.08]","pointer-events-none"),this.iframeContainer.append(t),e||(e=t),this.bucketBar=new Jr(e,{onFocusAnnotations:e=>this._guestRPC.forEach((t=>t.call("hoverAnnotations",e))),onScrollToAnnotation:e=>this._guestRPC.forEach((t=>t.call("scrollToAnnotation",e))),onSelectAnnotations:(e,t)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",e,t)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const t=jn(this._hypothesisSidebar);t.appendChild(this.iframeContainer),e.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),t.appendChild(this._messagesElement),Te(wt(es,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&m(this.iframe.contentWindow),this._listeners=new n;const o=document.createElement("div");this.toolbar=new os(o,{
172
+ ;r.anchors.push(e),r.bottom=t,r.position=r.top+n/2}}return r&&o.push(r),{above:{anchors:n,position:30},below:{anchors:i,position:a.height-30},buckets:o}}(this._positions,this._container.element);return wt(Jr,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:e=>this._onFocusAnnotations(e),onScrollToAnnotation:e=>this._onScrollToAnnotation(e),onSelectAnnotations:(e,t)=>this._onSelectAnnotations(e,t)})}}function ts({emitter:e}){const[t,n]=ze([]),i=Ke((e=>n((t=>[...t,e]))),[]),o=Ke((e=>n((t=>t.filter((t=>t.id!==e))))),[]);return je((()=>(e.subscribe("toastMessageAdded",i),e.subscribe("toastMessageDismissed",o),()=>{e.unsubscribe("toastMessageAdded",i),e.unsubscribe("toastMessageDismissed",o)})),[e,o,i]),wt(Bn,{messages:t,onMessageDismiss:o})}function ns({icon:e,...t}){return wt(mn,{classes:vt("justify-center rounded","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...t,size:"custom",variant:"custom",children:wt(e,{})})}function is({highlightsVisible:e}){
173
+ return wt("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:e?"Highlights visible":"Highlights hidden"})}function os({closeSidebar:e,createAnnotation:t,isSidebarOpen:n,sidebarContainerId:i,newAnnotationType:o,showHighlights:r,toggleHighlights:s,toggleSidebar:a,toggleSidebarRef:l,useMinimalControls:c=!1}){return wt("div",{className:vt("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[c&&n&&wt(mn,{classes:vt("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-px-1.5","flex items-center justify-center bg-white border","text-grey-6 hover:text-grey-9 transition-colors","border-r-0","shadow-sidebar"),title:"Close annotation sidebar",onClick:e,unstyled:!0,children:wt(Tt,{})}),!c&&wt(he,{children:[wt(mn,{classes:vt("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px] rounded-bl","bg-white text-grey-5 hover:text-grey-9","border-l border-b"),elementRef:l,title:"Annotation sidebar",expanded:n,
174
+ "aria-controls":i,onClick:a,unstyled:!0,children:wt(n?Lt:It,{})}),wt("div",{className:"space-y-px-1.5 mt-px-2",children:[wt(ns,{title:"Show highlights",icon:r?dn:Xt,pressed:r,onClick:s}),wt(ns,{title:"note"===o?"New page note":"New annotation",icon:"note"===o?tn:At,onClick:t})]}),wt(is,{highlightsVisible:r})]})]})}class rs{constructor(e,t){const{createAnnotation:n,setSidebarOpen:i,setHighlightsVisible:o}=t;this._container=e,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._sidebarContainerId=t.sidebarContainerId,this._closeSidebar=()=>i(!1),this._toggleSidebar=()=>i(!this._sidebarOpen),this._toggleHighlights=()=>o(!this._highlightsVisible),this._createAnnotation=()=>{n(),i(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(e){this._useMinimalControls=e,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(e){
175
+ this._sidebarOpen=e,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(e){this._newAnnotationType=e,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(e){this._highlightsVisible=e,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){Te(wt(os,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,sidebarContainerId:this._sidebarContainerId,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}const ss=280;class as{constructor(e,t,i){if(this._emitter=t.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new w,this.iframe=function(e){
176
+ const t=e.sidebarAppUrl,n=Ur(t,qr(t,e)),i=document.createElement("iframe");return i.src=n,i.title="Hypothesis annotation viewer",i.className="sidebar-frame",i.allow="fullscreen; clipboard-write",i}(i),this._config=i,this.bucketBar=null,this.features=new Pi,i.externalContainerSelector)this.externalFrame=document.querySelector(i.externalContainerSelector)??e,this.externalFrame.appendChild(this.iframe);else{if(this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="sidebar-container",this.iframeContainer.id="sidebar-container","clean"===i.theme)this.iframeContainer.classList.add("theme-clean");else{let e;i.bucketContainerSelector&&(e=document.querySelector(i.bucketContainerSelector),e||console.warn(`Custom bucket container "${i.bucketContainerSelector}" not found`));const t=document.createElement("div");t.setAttribute("data-testid","sidebar-edge"),
177
+ t.className=vt("absolute top-0 bottom-0 w-[23px] left-[-22px]","flex flex-col pt-[110px] pr-[5px]","bg-grey-2 sidebar-collapsed:bg-black/[.08]","pointer-events-none"),this.iframeContainer.append(t),e||(e=t),this.bucketBar=new es(e,{onFocusAnnotations:e=>this._guestRPC.forEach((t=>t.call("hoverAnnotations",e))),onScrollToAnnotation:e=>this._guestRPC.forEach((t=>t.call("scrollToAnnotation",e))),onSelectAnnotations:(e,t)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",e,t)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const t=jn(this._hypothesisSidebar);t.appendChild(this.iframeContainer),e.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),t.appendChild(this._messagesElement),Te(wt(ts,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&m(this.iframe.contentWindow),this._listeners=new n;const o=document.createElement("div");this.toolbar=new rs(o,{
178
178
  sidebarContainerId:this.iframeContainer?.id,createAnnotation:()=>{if(0===this._guestRPC.length)return;(this._guestWithSelection??this._guestRPC[0]).call("createAnnotation")},setSidebarOpen:e=>e?this.open():this.close(),setHighlightsVisible:e=>this.setHighlightsVisible(e)}),"clean"===i.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(o),this._toolbarWidth=this.toolbar.getWidth()):this._toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._gestureState={initial:null,final:null},this._setupGestures(),this.close();const[r]=i.services||[];r&&(this.onLoginRequest=r.onLoginRequest,this.onLogoutRequest=r.onLogoutRequest,this.onSignupRequest=r.onSignupRequest,this.onProfileRequest=r.onProfileRequest,this.onHelpRequest=r.onHelpRequest),this.onLayoutChange=i.onLayoutChange,this._layoutState={expanded:!1,width:0,height:0,toolbarWidth:0},this._updateLayoutState(!1),this._setupSidebarEvents()}destroy(){
179
179
  this._guestRPC.forEach((e=>e.destroy())),this._sidebarRPC.destroy(),this.bucketBar?.destroy(),this._listeners.removeAll(),this._hammerManager?.destroy(),this._hypothesisSidebar?(Te(null,this._messagesElement),this._hypothesisSidebar.remove()):this.iframe.remove(),this._emitter.destroy(),m(null)}onFrameConnected(e,t){switch(e){case"guest":this._connectGuest(t);break;case"sidebar":this._sidebarRPC.connect(t)}}_connectGuest(e){const t=new w;t.on("textSelected",(()=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.filter((e=>e!==t)).forEach((e=>e.call("clearSelection")))})),t.on("textUnselected",(()=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.filter((e=>e!==t)).forEach((e=>e.call("clearSelection")))})),t.on("highlightsVisibleChanged",(e=>{this.setHighlightsVisible(e)}));const n=this.bucketBar;n&&t.on("anchorsChanged",(e=>{0===this._guestRPC.indexOf(t)&&n.update(e)})),t.on("close",(()=>{t.destroy(),
180
180
  t===this._guestWithSelection&&(this._guestWithSelection=null),this._guestRPC=this._guestRPC.filter((e=>e!==t))})),t.connect(e),this._guestRPC.push(t),t.call("sidebarLayoutChanged",this._layoutState)}_setupSidebarEvents(){var e;e=document.body,this._sidebarRPC.on("publicAnnotationCountChanged",(function(t){const n=e.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((e=>{e.textContent=t.toString()}))})),function(e,t){const n=e.querySelectorAll("[data-hypothesis-trigger]");Array.from(n).forEach((e=>{e.addEventListener("click",(e=>{t(),e.stopPropagation()}))}))}(document.body,(()=>this.open())),this._sidebarRPC.on("featureFlagsUpdated",(e=>this.features.update(e))),this._sidebarRPC.on("connect",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const e="always"===this._config.showHighlights;this.setHighlightsVisible(e),(this._config.openSidebar||this._config.annotations||this._config.query||this._config.group)&&this.open()})),
181
181
  this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(e=>{this.hide(),this._emitter.publish("openNotebook",e)})),this._sidebarRPC.on("openProfile",(()=>{this.hide(),this._emitter.publish("openProfile")})),this._emitter.subscribe("closeProfile",(()=>{this.show()})),this._emitter.subscribe("closeNotebook",(()=>{this.show()})),this._sidebarRPC.on("toastMessageAdded",(e=>{this._emitter.publish("toastMessageAdded",e)})),this._sidebarRPC.on("toastMessageDismissed",(e=>{this._emitter.publish("toastMessageDismissed",e)}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([e,t])=>{t&&this._sidebarRPC.on(e,(()=>t()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}
182
- _setupGestures(){const e=this.toolbar.sidebarToggleButton;e&&(this._hammerManager=new Qr.Manager(e),this._hammerManager.on("panstart panend panleft panright",(e=>this._onPan(e))),this._hammerManager.add(new Qr.Pan({direction:Qr.DIRECTION_HORIZONTAL})))}_updateLayout(){this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const e=this._gestureState.final,t=-e;this.iframeContainer.style.marginLeft=`${e}px`,t>=rs&&(this.iframeContainer.style.width=`${t}px`),this._updateLayoutState()}})))}_updateLayoutState(e){const t=this.iframeContainer&&this.toolbar.getWidth()||0,n=this.iframeContainer??this.externalFrame,{height:i}=n.getBoundingClientRect(),o=window.getComputedStyle(n),r=parseInt(o.width),s=parseInt(o.marginLeft);let a=t;"boolean"==typeof e?e&&(a+=r):(s<rs?a-=s:a+=r,e=a>t);const l={expanded:e,width:e?a:t,height:i,toolbarWidth:t};this._layoutState=l,this.onLayoutChange?.(l),
183
- this._guestRPC.forEach((e=>e.call("sidebarLayoutChanged",l)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<rs?this.close():this.open())}_onPan(e){const t=this.iframeContainer;if(t)switch(e.type){case"panstart":this._resetGestureState(),t.classList.add("sidebar-no-transition"),t.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(t).marginLeft);break;case"panend":t.classList.remove("sidebar-no-transition"),t.style.pointerEvents="",null===this._gestureState.final||this._gestureState.final<=-280?this.open():this.close(),this._resetGestureState();break;case"panleft":case"panright":{if("number"!=typeof this._gestureState.initial)return;const t=this._gestureState.initial,n=e.deltaX;this._gestureState.final=Math.min(Math.round(t+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const e=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*e+"px",
184
- this.iframeContainer.classList.remove("sidebar-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!0),this._updateLayoutState(!0)}close(){this._sidebarRPC.call("sidebarClosed"),this.iframeContainer&&(this.iframeContainer.style.marginLeft="",this.iframeContainer.classList.add("sidebar-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!1),this._updateLayoutState(!1)}setHighlightsVisible(e){this.toolbar.highlightsVisible=e,this._sidebarRPC.call("setHighlightsVisible",e)}show(){this.iframeContainer?.classList.remove("is-hidden")}hide(){this.iframeContainer?.classList.add("is-hidden")}}class as{constructor(e){this._emitter=e,this._subscriptions=[]}publish(e,...t){this._emitter.emit(e,...t)}subscribe(e,t){this._emitter.on(e,t),this._subscriptions.push([e,t])}unsubscribe(e,t){this._emitter.off(e,t),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==e||i!==t))}destroy(){
185
- for(const[e,t]of this._subscriptions)this._emitter.off(e,t);this._subscriptions=[]}}class ls{constructor(){this._emitter=new u}createEmitter(){return new as(this._emitter)}}const cs=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((e=>{"loading"!==document.readyState&&e(),document.addEventListener("readystatechange",(()=>e()))})).then((function(){const e=j("annotator");let t=()=>{};const n=new Promise((e=>{t=e}));cs.addEventListener("destroy",t);const i=e.subFrameIdentifier?window.parent:window,o=[];if(i===window){if(function(){const e=document.querySelectorAll(["hypothesis-sidebar","hypothesis-notebook","hypothesis-profile"].join(","));return e.forEach((e=>e.remove())),e.length>0}())return void console.warn("Hypothesis did not load because it found an existing instance on the page.");const e=function(e=navigator.userAgent){if(!y(e))return()=>{};const t=e=>{if("hypothesisPortClosed"===e.data?.type&&e.ports[0]){const t=e.ports[0];v(t,"close"),t.close()}}
186
- ;return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}();o.push({destroy:e});const t=j("sidebar"),n=new URL(t.sidebarAppUrl).origin,i=new p(n),r=new ls,s=new ss(document.body,r,t),a=new Xr(document.body,r,j("notebook")),l=new Gr(document.body,r,j("profile"));i.on("frameConnected",((e,t)=>s.onFrameConnected(e,t))),o.push(i,s,a,l)}if("container"===Sr()){const t=new Er(e);o.push(t)}else{const n=new wr(document.body,e),r=new Hr(document.body,e,i);r.on("hostDisconnected",t),o.push(n,r)}n.then((()=>{o.forEach((e=>e.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((e=>e.remove())),function(e=document){Array.from(e.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((e=>e.remove()))}()}))}))}();
182
+ _setupGestures(){const e=this.toolbar.sidebarToggleButton;e&&(this._hammerManager=new Zr.Manager(e),this._hammerManager.on("panstart panend panleft panright",(e=>this._onPan(e))),this._hammerManager.add(new Zr.Pan({direction:Zr.DIRECTION_HORIZONTAL})))}_updateLayout(){this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const e=this._gestureState.final,t=-e;this.iframeContainer.style.marginLeft=`${e}px`,t>=ss&&(this.iframeContainer.style.width=`${t}px`),this._updateLayoutState()}})))}_updateLayoutState(e){const t=this.iframeContainer&&this.toolbar.getWidth()||0,n=this.iframeContainer??this.externalFrame,{height:i}=n.getBoundingClientRect(),o=window.getComputedStyle(n),r=parseInt(o.width),s=parseInt(o.marginLeft);let a=t;"boolean"==typeof e?e&&(a+=r):(s<ss?a-=s:a+=r,e=a>t);const l={expanded:e,width:e?a:t,height:i,toolbarWidth:t};this._layoutState=l,this.onLayoutChange?.(l),
183
+ this._guestRPC.forEach((e=>e.call("sidebarLayoutChanged",l)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<ss?this.close():this.open())}_onPan(e){const t=this.iframeContainer;if(t)switch(e.type){case"panstart":this._resetGestureState(),t.classList.add("sidebar-no-transition"),t.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(t).marginLeft);break;case"panend":t.classList.remove("sidebar-no-transition"),t.style.pointerEvents="",null===this._gestureState.final||this._gestureState.final<=-280?this.open():this.close(),this._resetGestureState();break;case"panleft":case"panright":{if("number"!=typeof this._gestureState.initial)return;const t=this._gestureState.initial,n=e.deltaX;this._gestureState.final=Math.min(Math.round(t+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const e=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*e+"px",
184
+ this.iframeContainer.classList.remove("sidebar-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!0),this._updateLayoutState(!0)}close(){this._sidebarRPC.call("sidebarClosed"),this.iframeContainer&&(this.iframeContainer.style.marginLeft="",this.iframeContainer.classList.add("sidebar-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!1),this._updateLayoutState(!1)}setHighlightsVisible(e){this.toolbar.highlightsVisible=e,this._sidebarRPC.call("setHighlightsVisible",e)}show(){this.iframeContainer?.classList.remove("is-hidden")}hide(){this.iframeContainer?.classList.add("is-hidden")}}class ls{constructor(e){this._emitter=e,this._subscriptions=[]}publish(e,...t){this._emitter.emit(e,...t)}subscribe(e,t){this._emitter.on(e,t),this._subscriptions.push([e,t])}unsubscribe(e,t){this._emitter.off(e,t),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==e||i!==t))}destroy(){
185
+ for(const[e,t]of this._subscriptions)this._emitter.off(e,t);this._subscriptions=[]}}class cs{constructor(){this._emitter=new u}createEmitter(){return new ls(this._emitter)}}const us=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((e=>{"loading"!==document.readyState&&e(),document.addEventListener("readystatechange",(()=>e()))})).then((function(){const e=j("annotator");let t=()=>{};const n=new Promise((e=>{t=e}));us.addEventListener("destroy",t);const i=e.subFrameIdentifier?window.parent:window,o=[];if(i===window){if(function(){const e=document.querySelectorAll(["hypothesis-sidebar","hypothesis-notebook","hypothesis-profile"].join(","));return e.forEach((e=>e.remove())),e.length>0}())return void console.warn("Hypothesis did not load because it found an existing instance on the page.");const e=function(e=navigator.userAgent){if(!y(e))return()=>{};const t=e=>{if("hypothesisPortClosed"===e.data?.type&&e.ports[0]){const t=e.ports[0];v(t,"close"),t.close()}}
186
+ ;return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}();o.push({destroy:e});const t=j("sidebar"),n=new URL(t.sidebarAppUrl).origin,i=new p(n),r=new cs,s=new as(document.body,r,t),a=new Yr(document.body,r,j("notebook")),l=new Kr(document.body,r,j("profile"));i.on("frameConnected",((e,t)=>s.onFrameConnected(e,t))),o.push(i,s,a,l)}if("container"===Er()){const t=new Ar(e);o.push(t)}else{const n=new xr(document.body,e),r=new Vr(document.body,e,i);r.on("hostDisconnected",t),o.push(n,r)}n.then((()=>{o.forEach((e=>e.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((e=>e.remove())),function(e=document){Array.from(e.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((e=>e.remove()))}()}))}))}();
187
187
  //# sourceMappingURL=annotator.bundle.js.map