hypothesis 1.1541.0 → 1.1543.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?467bfc","styles/annotator.css.map":"styles/annotator.css.map?c421a4","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":"styles/sidebar.css?01a7ca","styles/annotator.css":"styles/annotator.css?40dafc","styles/ui-playground.css":"styles/ui-playground.css?348c39","styles/sidebar.css.map":"styles/sidebar.css.map?72785d","styles/ui-playground.css.map":"styles/ui-playground.css.map?916b82","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?6dfb36","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?da3455","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?260860","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?d9f900","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?54eba4"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var o=s.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=e,t(o),s.head.appendChild(o)}function o(s,e){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=o.esModule,n=void 0===r||r,i=o.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(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,o,r){var n=s.createElement("link");n.rel=e,n.href=r,n.type="application/annotator+".concat(o),t(n),s.head.appendChild(n)}function n(s,e,o){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=o,"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=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),o=0;o<e.length;o++){var r=void 0;try{r=JSON.parse(e[o].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1541.0/");if(document.querySelector("hypothesis-app")){!function(s,t){n(s,"fetch",t.apiUrl),n(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)o(s,i(t,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)e(s,i(t,p[l]))}(document,{assetRoot:p,manifest:s,apiUrl:l.apiUrl})}else{var c=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(c&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(c))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,h=a(d.notebookAppUrl||"https://hypothes.is/notebook"),u=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.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),n(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++)o(s,i(t,l[a]),{esModule:!1});var p=[];void 0!==window.PDFViewerApplication&&p.push("styles/pdfjs-overrides.css"),p.push("styles/highlights.css");for(var c=0,d=p;c<d.length;c++)e(s,i(t,d[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:h,profileAppUrl:u,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?d60eca","styles/annotator.css":"styles/annotator.css?f0ac17","styles/annotator.css.map":"styles/annotator.css.map?c421a4","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":"styles/sidebar.css?d8c723","styles/sidebar.css.map":"styles/sidebar.css.map?868a38","styles/ui-playground.css":"styles/ui-playground.css?249d2a","styles/ui-playground.css.map":"styles/ui-playground.css.map?9f0295","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?83426a","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?6dfb36","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?82aadc","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?d9f900","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?94ff12"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var o=s.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=e,t(o),s.head.appendChild(o)}function o(s,e){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=o.esModule,n=void 0===r||r,i=o.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(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,o,r){var n=s.createElement("link");n.rel=e,n.href=r,n.type="application/annotator+".concat(o),t(n),s.head.appendChild(n)}function n(s,e,o){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=o,"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=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),o=0;o<e.length;o++){var r=void 0;try{r=JSON.parse(e[o].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),p=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1543.0/");if(document.querySelector("hypothesis-app")){!function(s,t){n(s,"fetch",t.apiUrl),n(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)o(s,i(t,a[r]),{esModule:!0});for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)e(s,i(t,p[l]))}(document,{assetRoot:p,manifest:s,apiUrl:l.apiUrl})}else{var c=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(c&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(c))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,h=a(d.notebookAppUrl||"https://hypothes.is/notebook"),u=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.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),n(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++)o(s,i(t,l[a]),{esModule:!1});var p=[];void 0!==window.PDFViewerApplication&&p.push("styles/pdfjs-overrides.css"),p.push("styles/highlights.css");for(var c=0,d=p;c<d.length;c++)e(s,i(t,d[c]))}}(document,{assetRoot:p,manifest:s,notebookAppUrl:h,profileAppUrl:u,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,5 +1,6 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?467bfc",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?d60eca",
3
+ "styles/annotator.css": "styles/annotator.css?f0ac17",
3
4
  "styles/annotator.css.map": "styles/annotator.css.map?c421a4",
4
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
5
6
  "styles/highlights.css.map": "styles/highlights.css.map?241350",
@@ -7,14 +8,13 @@
7
8
  "styles/katex.min.css.map": "styles/katex.min.css.map?1785d7",
8
9
  "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
9
10
  "styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
10
- "styles/sidebar.css": "styles/sidebar.css?01a7ca",
11
- "styles/annotator.css": "styles/annotator.css?40dafc",
12
- "styles/ui-playground.css": "styles/ui-playground.css?348c39",
13
- "styles/sidebar.css.map": "styles/sidebar.css.map?72785d",
14
- "styles/ui-playground.css.map": "styles/ui-playground.css.map?916b82",
11
+ "styles/sidebar.css": "styles/sidebar.css?d8c723",
12
+ "styles/sidebar.css.map": "styles/sidebar.css.map?868a38",
13
+ "styles/ui-playground.css": "styles/ui-playground.css?249d2a",
14
+ "styles/ui-playground.css.map": "styles/ui-playground.css.map?9f0295",
15
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?83426a",
15
16
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?6dfb36",
16
- "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?da3455",
17
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?260860",
17
+ "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?82aadc",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?d9f900",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?54eba4"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?94ff12"
20
20
  }
@@ -108,7 +108,7 @@ describe(e,t){return function(e,t){const n=[si,ei,ti,ni],o=[];for(const i of n)t
108
108
  return this._sideBySideActive}_activateSideBySide(e){const t=e+12,n=e=>parseInt(window.getComputedStyle(e).marginLeft,10);U((()=>{document.body.style.marginLeft="",document.body.style.marginRight="";const e=n(document.body);document.body.style.marginRight=`${t}px`;const o=function(e){const t=new Map,n=new Map,o=I.join(","),i=Array.from(e.querySelectorAll(o)).map((e=>({rect:e.getBoundingClientRect(),textLength:e.textContent.length}))).filter((({rect:e})=>e.width>0&&e.height>0)).sort(((e,t)=>t.textLength-e.textLength)).slice(0,15);if(i.forEach((({rect:e})=>{let o=t.get(e.left)??0;o+=1,t.set(e.left,o);let i=n.get(e.right)??0;i+=1,n.set(e.right,i)})),0===t.size||0===n.size)return null;const r=[...t.entries()].sort(((e,t)=>t[1]-e[1])),s=[...n.entries()].sort(((e,t)=>t[1]-e[1])),[a]=r[0],[l]=s[0];return{left:a,right:l}}(document.body);if(o){const i=Math.max(0,window.innerWidth-t-o.right);if(i>0){const e=Math.max(0,t-i);document.body.style.marginRight=`${e}px`}
109
109
  n(document.body)>e&&(document.body.style.marginLeft=`${e}px`),o.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){U((()=>{document.body.style.marginLeft="",document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(e){const t=e.highlights?.[0];t&&await async function(e,{maxDuration:t=500}={}){const n=e.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{value:"BODY",configurable:!0});const o=e.closest("details");o&&!o.hasAttribute("open")&&(o.open=!0),await new Promise((n=>mi(e,{time:t},n)))}(t)}}var vi,yi;var xi=function(){if(yi)return vi;yi=1
110
110
  ;var t=NaN,n="[object Symbol]",o=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt,l="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,d=l||c||Function("return this")(),h=Object.prototype.toString,u=Math.max,f=Math.min,m=function(){return d.Date.now()};function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function p(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&h.call(e)==n}(e))return t;if(g(e)){var l="function"==typeof e.valueOf?e.valueOf():e;e=g(l)?l+"":l}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var c=r.test(e);return c||s.test(e)?a(e.slice(2),c?2:8):i.test(e)?t:+e}return vi=function(e,t,n){var o,i,r,s,a,l,c=0,d=!1,h=!1,_=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var n=o,r=i;return o=i=void 0,c=t,s=e.apply(r,n)}function w(e){var n=e-l;return void 0===l||n>=t||n<0||h&&e-c>=r}
111
- function v(){var e=m();if(w(e))return y(e);a=setTimeout(v,function(e){var n=t-(e-l);return h?f(n,r-(e-c)):n}(e))}function y(e){return a=void 0,_&&o?b(e):(o=i=void 0,s)}function x(){var e=m(),n=w(e);if(o=arguments,i=this,l=e,n){if(void 0===a)return function(e){return c=e,a=setTimeout(v,t),d?b(e):s}(l);if(h)return a=setTimeout(v,t),b(l)}return void 0===a&&(a=setTimeout(v,t)),s}return t=p(t)||0,g(n)&&(d=!!n.leading,r=(h="maxWait"in n)?u(p(n.maxWait)||0,t):r,_="trailing"in n?!!n.trailing:_),x.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},x.flush=function(){return void 0===a?s:y(m())},x},vi}(),Ni=t(xi);function Ci(e,t,n,o=0){let i=o;for(;i<e.length&&t>0;)n(e[i])&&--t,++i;return i}function Si(e,t,n,o){let i=0;for(let r=n;r<o;r++)t(e[r])&&++i;return i}function Ei(e,t,n,o,i){const r=Si(e,i,0,n),s=Si(e,i,n,o);let a=Ci(t,r,i);for(;a<t.length&&!i(t[a]);)++a;return[a,Ci(t,s,i,a)]}const ki={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Ai=new Map,Ri=new Map;function Ti(e,t){return`${e}:${t}`}function Pi(e){
111
+ function v(){var e=m();if(w(e))return y(e);a=setTimeout(v,function(e){var n=t-(e-l);return h?f(n,r-(e-c)):n}(e))}function y(e){return a=void 0,_&&o?b(e):(o=i=void 0,s)}function x(){var e=m(),n=w(e);if(o=arguments,i=this,l=e,n){if(void 0===a)return function(e){return c=e,a=setTimeout(v,t),d?b(e):s}(l);if(h)return a=setTimeout(v,t),b(l)}return void 0===a&&(a=setTimeout(v,t)),s}return t=p(t)||0,g(n)&&(d=!!n.leading,r=(h="maxWait"in n)?u(p(n.maxWait)||0,t):r,_="trailing"in n?!!n.trailing:_),x.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},x.flush=function(){return void 0===a?s:y(m())},x},vi}(),Ni=t(xi);function Ci(e,t,n,o=0){let i=o;for(;i<e.length&&t>0;)n(e[i])&&--t,++i;return i}function Si(e,t,n,o){let i=0;for(let r=n;r<o;r++)t(e[r])&&++i;return i}function Ei(e,t,n,o,i){const r=Si(e,i,0,n),s=Si(e,i,n,o);let a=Ci(t,r,i);for(;a<t.length&&!i(t[a]);)++a;return[a,Ci(t,s,i,a)]}const ki={INITIAL:0,FINISHED:3},Ai=new Map,Ri=new Map;function Ti(e,t){return`${e}:${t}`}function Pi(e){
112
112
  const t="closest"in e?e:e.parentElement;return t?.closest(".textLayer")??null}function Li(){return PDFViewerApplication.pdfViewer}async function Oi(e){const t=Li();let n=t.getPageView(e);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{t.eventBus?t.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(t.getPageView(e))};t.eventBus?t.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function Mi(e){const t=Ai.get(e);if(t)return t;const n=(async()=>{const t=await Oi(e);return(await t.pdfPage.getTextContent({normalizeWhitespace:!0})).items.map((e=>e.str)).join("")})();return Ai.set(e,n),n}async function Ii(e){const t=Li();let n=0,o=0,i="";for(let r=0;r<t.pagesCount;r++)if(i=await Mi(r),n=o,o+=i.length,o>=e)return{index:r,offset:n,text:i};return{index:t.pagesCount-1,offset:n,text:i}}function Bi(e){switch(e){case" ":case"\f":case"\n":case"\r":case"\t":case"\v":case" ":return!0;default:return!1}}const Fi=e=>!Bi(e);function Di(e){
113
113
  return void 0!==e.renderingDone?e.renderingDone:!!e.div&&null!==e.div.querySelector(".endOfContent")}async function Hi(e,t,n){const[o,i]=await Promise.all([Oi(e),Mi(e)]);if(o.renderingState===ki.FINISHED&&o.textLayer&&Di(o.textLayer)){const e=o.textLayer.textLayerDiv??o.textLayer.div;if(!e)throw new Error("Unable to find PDF.js text layer root");const r=e.textContent,[s,a]=Ei(i,r,t,n,Fi);Vi(r.slice(s,a))!==Vi(i.slice(t,n))&&Mo("Text layer text does not match page text. Highlights will be mis-aligned.");const l=new lo(e,s),c=new lo(e,a);return new co(l,c).toRange()}const r=function(e){let t=e.querySelector(ho);return t||(t=document.createElement("span"),t.classList.add("annotator-placeholder"),t.textContent="Loading annotations...",e.appendChild(t),t)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function Vi(e){let t="";for(let n=0;n<e.length;n++){const o=e[n];Bi(o)||(t+=o)}return t}async function Ui(e,t){const n=t.find((e=>"TextQuoteSelector"===e.type))
114
114
  ;if(!n)throw new Error("No quote selector found");const o=t.find((e=>"TextPositionSelector"===e.type));if(o){try{const{index:e,offset:t,text:i}=await Ii(o.start),r=o.start-t,s=o.end-t,a=i.substring(r,s);if(n.exact!==a)throw new Error("quote mismatch");return await Hi(e,r,s)}catch{}try{const e=Ti(n.exact,o.start),t=Ri.get(e);if(t){const{pageIndex:e,anchor:n}=t;return await Hi(e,n.start,n.end)}}catch{}}return async function(e,t){const n=Li().pagesCount,o=Array(n).fill(0).map(((e,t)=>t));let i,r;if(t){const{index:e,offset:n}=await Ii(t);i=e,r=t-n,o.sort(((t,n)=>Math.abs(t-e)-Math.abs(n-e)))}const s=void 0!==e.prefix?Vi(e.prefix):void 0,a=void 0!==e.suffix?Vi(e.suffix):void 0,l=Vi(e.exact);let c;for(const e of o){const t=await Mi(e),n=Vi(t);let o;void 0!==i&&void 0!==r&&(e<i?o=n.length:e===i?[o]=Ei(t,n,r,r,Fi):o=0);const d=Qo(n,l,{prefix:s,suffix:a,hint:o});if(d&&(!c||d.score>c.match.score)){const[o,i]=Ei(n,t,d.start,d.end,Fi);c={page:e,match:{start:o,end:i,score:d.score}}
@@ -144,7 +144,7 @@ this._sidebarRPC.connect(e)})),this._sendDocumentInfo()}destroy(){var e;this._po
144
144
  const o=await this._integration.anchor(this.element,t.selector),i=co.fromRange(o);n={annotation:e,target:t,range:i}}catch{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&&No(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(),o=this.element,i=(await Promise.all(t.map((e=>this._integration.describe(o,e))))).map((e=>({source:n.uri,selector:e}))),s={uri:n.uri,document:n.metadata,target:i,$highlight:e,
145
145
  $cluster:e?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),xr(),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);Co(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(),o=go(n),i=bo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=wr(),this._isAdderVisible=!0,this._adder.show(i,o)):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}={}){
146
146
  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){lt(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new pr(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Sr(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Er(e,t){const n={}
147
- ;for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1541.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.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 kr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=Qe(null);return Xe((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Xe((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Ct("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Ar({closed:e,children:t,...n}){return Ct("div",{...n,
147
+ ;for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1543.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.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 kr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=Qe(null);return Xe((()=>{e?r.current?.close():r.current?.showModal()}),[e]),Xe((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Ct("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Ar({closed:e,children:t,...n}){return Ct("div",{...n,
148
148
  className:xt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Ct("div",{className:"relative w-full h-full",children:t})})}function Rr({document_:e=document,...t}){return Ct(Ge((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?kr:Ar),[e]),{...t})}function Tr({config:e,groupId:t}){return Ct("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Sr(e.notebookAppUrl,{...Er(e.notebookAppUrl,e),group:t})})}function Pr({eventBus:e,config:t}){const[n,o]=je(0),[i,r]=je(!0),[s,a]=je(null),l=Qe(""),c=Qe(null);Xe((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Xe((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),Xe((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const d=Ye((()=>{r(!0),c.current?.publish("closeNotebook")}),[])
149
149
  ;return null===s?null:Ct(Rr,{closed:i,onClose:d,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Ct("div",{className:"absolute right-0 m-3",children:Ct(vn,{title:"Close notebook",onClick:d,variant:"dark",classes:xt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Ct(Lt,{className:"w-4 h-4"})})}),Ct(Tr,{config:t,groupId:s},n)]})}class Lr{constructor(e,t,n){this._container=new Yn("notebook",(()=>Ct(Pr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Or({eventBus:e,config:t}){const[n,o]=je(!0),i=Qe(null);Xe((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:Ct(Rr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Ct("div",{className:"absolute right-0 m-3",children:Ct(vn,{
150
150
  title:"Close profile dialog",onClick:r,variant:"dark",classes:xt("!bg-transparent enabled:hover:!bg-grey-3"),children:Ct(Lt,{className:"w-4 h-4"})})}),Ct("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Mr{constructor(e,t,n){this._container=new Yn("profile",(()=>Ct(Or,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Ir({above:e,below:t,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return Ct("ul",{className:"relative",children:[s&&Ct("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:Ct(Wn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),