hypothesis 1.1136.0 → 1.1138.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";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?ce454e","styles/annotator.css":"styles/annotator.css?7d7b60","styles/annotator.css.map":"styles/annotator.css.map?02fa76","styles/highlights.css":"styles/highlights.css?99b008","styles/highlights.css.map":"styles/highlights.css.map?38cb82","styles/katex.min.css":"styles/katex.min.css?776307","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","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?15b65f","styles/sidebar.css.map":"styles/sidebar.css.map?ced785","styles/ui-playground.css":"styles/ui-playground.css?a18145","styles/ui-playground.css.map":"styles/ui-playground.css.map?5656e5","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b3ac5b","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?98a4ff","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?14e7d4","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?9e7ded","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?acac9d"};if(function(){var s=[function(){return Promise.resolve()},function(){return new Map},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 p=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),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1136.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{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++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?8fe7f6","styles/annotator.css":"styles/annotator.css?7d7b60","styles/annotator.css.map":"styles/annotator.css.map?02fa76","styles/highlights.css":"styles/highlights.css?99b008","styles/highlights.css.map":"styles/highlights.css.map?38cb82","styles/katex.min.css":"styles/katex.min.css?776307","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","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?f8c036","styles/sidebar.css.map":"styles/sidebar.css.map?ced785","styles/ui-playground.css":"styles/ui-playground.css?9516d2","styles/ui-playground.css.map":"styles/ui-playground.css.map?5656e5","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?e8c49c","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?92f5c9","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?14e7d4","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?9e7ded","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?e2eb89"};if(function(){var s=[function(){return Promise.resolve()},function(){return new Map},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 p=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),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1138.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{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++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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,5 +1,5 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?ce454e",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?8fe7f6",
3
3
  "styles/annotator.css": "styles/annotator.css?7d7b60",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?02fa76",
5
5
  "styles/highlights.css": "styles/highlights.css?99b008",
@@ -8,13 +8,13 @@
8
8
  "styles/katex.min.css.map": "styles/katex.min.css.map?42d80c",
9
9
  "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
10
10
  "styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
11
- "styles/sidebar.css": "styles/sidebar.css?15b65f",
11
+ "styles/sidebar.css": "styles/sidebar.css?f8c036",
12
12
  "styles/sidebar.css.map": "styles/sidebar.css.map?ced785",
13
- "styles/ui-playground.css": "styles/ui-playground.css?a18145",
13
+ "styles/ui-playground.css": "styles/ui-playground.css?9516d2",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?5656e5",
15
- "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?b3ac5b",
16
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?98a4ff",
15
+ "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?e8c49c",
16
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?92f5c9",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?14e7d4",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?9e7ded",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?acac9d"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?e2eb89"
20
20
  }
@@ -107,26 +107,26 @@ updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destr
107
107
  ;if(Ki(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&Ki(n)?"content":null}class Ji{constructor(t){wt(this,"_frameObserver",void 0);const e=Ki();if(!e)throw new Error("Book container element not found");const n=new WeakSet,i=e.shadowRoot,o=()=>{const e=i.querySelector("iframe");e&&!n.has(e)&&(n.add(e),Xi(e,((n,i)=>{const o=null==i?void 0:i.body;o&&!o.querySelector("#page-content")&&Gi(e,t)})))};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(i,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function to(){return document.querySelector("img#pbk-page")}class eo extends Rt{constructor(t=document.body,e){var n;super(),wt(this,"_bookElement",void 0),wt(this,"_features",void 0),wt(this,"_htmlIntegration",void 0),wt(this,"_listeners",void 0),wt(this,"_textLayer",void 0),this._features=e.features;const i=null!==(n=e.bookElement)&&void 0!==n?n:Ki(window.parent.document)
108
108
  ;if(!i)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=i,this._features.on("flagsChanged",(()=>{this.emit("uriChanged")}));const o=new on;o.update({html_side_by_side:!0}),this._htmlIntegration=new Jn({container:t,features:o}),this._listeners=new Ct;const r=["mouseup","mousedown","mouseout"];for(const t of r)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const s=window.frameElement;s&&function(t){if("no"!==t.getAttribute("scrolling"))return;const e=document.createElement("style");e.textContent="iframe { height: 100% !important; }",t.insertAdjacentElement("beforebegin",e);const n=()=>t.removeAttribute("scrolling");n(),new MutationObserver(n).observe(t,{attributes:!0})}(s);const a=to(),l=window.innerPageData;if(a&&l){const t=l.glyphs.glyphs.map((t=>{const e=t.l/100,n=t.r/100,i=t.t/100,o=t.b/100;return new DOMRect(e,i,n-e,o-i)}));this._textLayer=new Yi(a,t,l.words),this._textLayer.container.style.zIndex="100"}}canAnnotate(){return!0}
109
109
  destroy(){var t;null===(t=this._textLayer)||void 0===t||t.destroy(),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}async describe(t,e){const n=this._htmlIntegration.describe(t,e);if(!this._bookIsSingleDocument())return n;const i=await this._bookElement.getCurrentPage(),o=[{type:"EPUBContentSelector",cfi:i.cfi,url:i.absoluteURL,title:i.chapterTitle}];return"pbk"===this._bookElement.getBookInfo().format&&o.push({type:"PageSelector",index:i.index,label:i.page}),n.push(...o),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(t){const e=to();if(e&&this._textLayer){const n=e.parentElement,i=this._textLayer,o=window.innerWidth-t.width;return Dn((()=>{t.expanded&&o>480?(n.style.textAlign="left",e.style.width=`${o}px`):(n.style.textAlign="",e.style.width=""),i.updateSync()})),t.expanded}return this._htmlIntegration.fitSideBySide(t)}async getMetadata(){if(this._bookIsSingleDocument()){return{
110
- title:this._bookElement.getBookInfo().title,link:[]}}return{title:document.title,link:[]}}async segmentInfo(){const t=await this._bookElement.getCurrentPage();return{cfi:t.cfi,url:t.absoluteURL}}async uri(){if(this._bookIsSingleDocument()){return`https://bookshelf.vitalsource.com/reader/books/${this._bookElement.getBookInfo().isbn}`}const t=new URL(document.location.href);return t.search="",t.toString()}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}_bookIsSingleDocument(){return this._features.flagEnabled("book_as_single_document")}}function no(t){if("undefined"!=typeof PDFViewerApplication)return new $i(t);return"content"===Qi()?new eo(document.body,{features:t.features}):new Jn({features:t.features})}function io(t){const e=t.getSelection();if(!e||0===e.rangeCount)return null;const n=e.getRangeAt(0);return n.collapsed?null:n}class oo{constructor(t,e=document){let n=!1;this._pendingCallback=null;const i=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(io(e))}),n)},o=t=>{
111
- if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;i(e)};this._document=e,this._listeners=new Ct,this._listeners.add(e,"selectionchange",o),this._listeners.add(e.body,"mousedown",o),this._listeners.add(e.body,"mouseup",o),i(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function ro(){const t=function(t,e){const n=new Set,i=new Set;return Ve(t,(t=>{let o=t;for(;o&&!n.has(o);){n.add(o);const t=e(o);null!=t&&i.add(t),o=o.parentNode}})),[...i]}(window.getSelection().getRangeAt(0),(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function so(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n
112
- }(t).map((t=>t._annotation)).filter((t=>void 0!==t)).map((t=>null==t?void 0:t.$tag));return e}function ao(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function lo(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class co{constructor(t,e={},n=window){var i,o,r,s,a;(wt(this,"element",void 0),wt(this,"selectedRanges",void 0),wt(this,"anchors",void 0),wt(this,"features",void 0),wt(this,"_adder",void 0),wt(this,"_clusterToolbar",void 0),wt(this,"_hostFrame",void 0),wt(this,"_highlightsVisible",void 0),wt(this,"_isAdderVisible",void 0),wt(this,"_informHostOnNextSelectionClear",void 0),wt(this,"_selectionObserver",void 0),wt(this,"_annotations",void 0),wt(this,"_frameIdentifier",void 0),wt(this,"_portFinder",void 0),wt(this,"_integration",void 0),wt(this,"_hostRPC",void 0),wt(this,"_sidebarRPC",void 0),wt(this,"_bucketBarClient",void 0),wt(this,"_sideBySideActive",void 0),wt(this,"_listeners",void 0),wt(this,"_hoveredAnnotations",void 0),this.element=t,
113
- this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._adder=new Re(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:t=>this.selectAnnotations(t,{focusInSidebar:!0})}),this._selectionObserver=new oo((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new Nt({hostFrame:this._hostFrame,source:"guest",sourceId:null!==(i=this._frameIdentifier)&&void 0!==i?i:void 0}),this.features=new on,this._integration=no(this),this._integration.on("uriChanged",(async()=>{const t=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",t)})),e.contentInfoBanner)&&(null===(s=(a=this._integration).showContentInfo)||void 0===s||s.call(a,e.contentInfoBanner))
114
- ;null!==(o=(r=this._integration).canStyleClusteredHighlights)&&void 0!==o&&o.call(r)&&(this._clusterToolbar=new Je(t,{features:this.features})),this._hostRPC=new Vt,this._connectHost(n),this._sidebarRPC=new Vt,this._connectSidebar(),this._bucketBarClient=new Ye({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._sideBySideActive=!1,this._listeners=new Ct,this._setupElementEvents(),this._hoveredAnnotations=new Set}_setupElementEvents(){const t=t=>{this._sideBySideActive||so(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:i}=t,o=so(e);if(o.length&&this._highlightsVisible){const t=n||i;this.selectAnnotations(o,{toggle:t})}})),this._listeners.add(this.element,"mousedown",(({target:e})=>{t(e)})),this._listeners.add(this.element,"touchstart",(({target:e})=>{t(e)})),this._listeners.add(this.element,"mouseover",(({target:t})=>{const e=so(t)
115
- ;e.length&&this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(t=>{this._handleShortcut(t)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){var t,e;const[n,i,o]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),null===(t=(e=this._integration).segmentInfo)||void 0===t?void 0:t.call(e)]);return{uri:xn(n),metadata:i,segmentInfo:o}}_repositionAdder(){var t;if(!1===this._isAdderVisible)return;const e=null===(t=window.getSelection())||void 0===t?void 0:t.getRangeAt(0);e&&this._onSelection(e)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{io(document)&&(this._informHostOnNextSelectionClear=!1,lo())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),
116
- this._hostRPC.on("scrollToClosestOffScreenAnchor",((t,e)=>this._scrollToClosestOffScreenAnchor(t,e))),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e}))),this._hostRPC.on("sidebarLayoutChanged",(e=>{var n,i;((n=window)===(i=t)||n.parent===i&&n.frameElement&&n.frameElement.getBoundingClientRect().width/n.parent.innerWidth>=.8)&&this.fitSideBySide(e)}));const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=ao(e);if(!n)return;const i=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n});this.element.dispatchEvent(i)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),
117
- this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t))))),this._sidebarRPC.on("showContentInfo",(t=>{var e,n;return null===(e=(n=this._integration).showContentInfo)||void 0===e?void 0:e.call(n,t)})),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this.getDocumentInfo().then((t=>this._sidebarRPC.call("documentInfoChanged",t)))}destroy(){var t;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){We(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){const e=t=>{var e;const n=ao(t);if(!n)return;const i=ze(n,c("hypothesis-highlight",null===(e=t.annotation)||void 0===e?void 0:e.$cluster));i.forEach((e=>{e._annotation=t.annotation})),
118
- t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&je(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=Ie.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&We(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){
119
- const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+St(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),lo(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);je(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=Xe(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e)
120
- ;n&&this._integration.scrollToAnchor(n)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=De(e),i=qe(e);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=ro(),this._isAdderVisible=!0,this._adder.show(i,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){
121
- this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Kt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function ho(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function uo(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1136.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}
122
- function fo({config:t,groupId:e}){return ct("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:ho(t.notebookAppUrl,{...uo(t.notebookAppUrl,t),group:e})})}function po({eventBus:t,config:e}){const[n,i]=G(0),[o,r]=G(!0),[s,a]=G(null),l=J(""),h=J(null);K((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),K((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),K((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),h.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ct("div",{className:c("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:ct("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ct("div",{className:"absolute right-0 text-xl m-3",children:ct(mt,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),
123
- null===(t=h.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),ct(fo,{config:e,groupId:s},n)]})})}class mo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ae(this._outerContainer),I(ct(po,{eventBus:e,config:n}),this.shadowRoot)}destroy(){I(null,this.shadowRoot),this._outerContainer.remove()}}var go={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){
124
- 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=e.console&&(e.console.warn||e.console.log);return r&&r.call(e.console,o,i),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===o||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign;var m=p((function(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;)(!n||n&&t[i[r]]===o)&&(t[i[r]]=e[i[r]]),r++;return t}),"extend","Use `assign`."),g=p((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var i,o=e.prototype;(i=t.prototype=Object.create(o)).constructor=t,i._super=o,n&&r(i,n)}function v(t,e){return function(){return t.apply(e,arguments)}}function y(t,e){
125
- return"function"==typeof t?t.apply(e&&e[0]||o,e):t}function b(t,e){return t===o?e:t}function w(t,e,n){f(E(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(E(e),(function(e){t.removeEventListener(e,n,!1)}))}function x(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function E(t){return t.trim().split(/\s+/g)}function k(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}function N(t){return Array.prototype.slice.call(t,0)}function A(t,e,n){for(var i=[],o=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];k(o,s)<0&&i.push(t[r]),o[r]=s,r++}return n&&(i=e?i.sort((function(t,n){return t[e]>n[e]})):i.sort()),i}function T(t,e){for(var n,i,r=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((i=(n=s[a])?n+r:e)in t)return i;a++}return o}var R=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
126
- var P="ontouchstart"in e,M=T(e,"PointerEvent")!==o,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",B="mouse",H=24,D=["x","y"],F=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function q(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=1&e&&i-r==0,a=12&e&&i-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=U(e));r>1&&!n.firstMultiple?n.firstMultiple=U(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,u=e.center=z(i);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(l,u),e.distance=j(l,u),function(t,e){var n=e.center,i=t.offsetDelta||{},o=t.prevDelta||{},r=t.prevInput||{};1!==e.eventType&&4!==r.eventType||(o=t.prevDelta={x:r.deltaX||0,y:r.deltaY||0},
127
- i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=o.x+(n.x-i.x),e.deltaY=o.y+(n.y-i.y)}(n,e),e.offsetDirection=W(e.deltaX,e.deltaY);var d=$(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=i,j(p[0],p[1],F)/j(f[0],f[1],F)):1,e.rotation=a?function(t,e){return X(e[1],e[0],F)+X(t[1],t[0],F)}(a.pointers,i):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,r,s,a=t.lastInterval||e,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===o)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=$(l,h,u);i=d.x,r=d.y,n=c(d.x)>c(d.y)?d.x:d.y,s=W(h,u),t.lastInterval=e}else n=a.velocity,i=a.velocityX,r=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=i,e.velocityY=r,e.direction=s}(n,e);var f,p;var m=t.element;x(e.srcEvent.target,m)&&(m=e.srcEvent.target);e.target=m}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}
128
- function U(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:h(),pointers:e,center:z(e),deltaX:t.deltaX,deltaY:t.deltaY}}function z(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,o=0;o<e;)n+=t[o].clientX,i+=t[o].clientY,o++;return{x:l(n/e),y:l(i/e)}}function $(t,e,n){return{x:e/t||0,y:n/t||0}}function W(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function j(t,e,n){n||(n=D);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return Math.sqrt(i*i+o*o)}function X(t,e,n){n||(n=D);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return 180*Math.atan2(o,i)/Math.PI}V.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),
129
- this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(L(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},Z="mousedown",G="mousemove mouseup";function K(){this.evEl=Z,this.evWin=G,this.pressed=!1,V.apply(this,arguments)}_(K,V,{handler:function(t){var e=Y[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:B,srcEvent:t}))}});var Q={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:I,3:"pen",4:B,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,V.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),_(nt,V,{handler:function(t){
110
+ title:this._bookElement.getBookInfo().title,link:[]}}return{title:document.title,link:[]}}navigateToSegment(t){var e;const n=null===(e=t.target[0].selector)||void 0===e?void 0:e.find((t=>"EPUBContentSelector"===t.type));if(null!=n&&n.cfi)this._bookElement.goToCfi(n.cfi);else{if(null==n||!n.url)throw new Error("No segment information available");this._bookElement.goToURL(n.url)}}async segmentInfo(){const t=await this._bookElement.getCurrentPage();return{cfi:t.cfi,url:t.absoluteURL}}async uri(){if(this._bookIsSingleDocument()){return`https://bookshelf.vitalsource.com/reader/books/${this._bookElement.getBookInfo().isbn}`}const t=new URL(document.location.href);return t.search="",t.toString()}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}_bookIsSingleDocument(){return this._features.flagEnabled("book_as_single_document")}}function no(t){if("undefined"!=typeof PDFViewerApplication)return new $i(t);return"content"===Qi()?new eo(document.body,{features:t.features}):new Jn({
111
+ features:t.features})}function io(t){const e=t.getSelection();if(!e||0===e.rangeCount)return null;const n=e.getRangeAt(0);return n.collapsed?null:n}class oo{constructor(t,e=document){let n=!1;this._pendingCallback=null;const i=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(io(e))}),n)},o=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;i(e)};this._document=e,this._listeners=new Ct,this._listeners.add(e,"selectionchange",o),this._listeners.add(e.body,"mousedown",o),this._listeners.add(e.body,"mouseup",o),i(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function ro(){const t=function(t,e){const n=new Set,i=new Set;return Ve(t,(t=>{let o=t;for(;o&&!n.has(o);){n.add(o);const t=e(o);null!=t&&i.add(t),o=o.parentNode}})),[...i]}(window.getSelection().getRangeAt(0),(t=>{var e
112
+ ;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function so(t){const e=function(t){let e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;const n=[];for(;e;)e.classList.contains("hypothesis-highlight")&&n.push(e),e=e.parentElement;return n}(t).map((t=>t._annotation)).filter((t=>void 0!==t)).map((t=>null==t?void 0:t.$tag));return e}function ao(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function lo(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class co{constructor(t,e={},n=window){var i,o,r,s,a;(wt(this,"element",void 0),wt(this,"selectedRanges",void 0),wt(this,"anchors",void 0),wt(this,"features",void 0),wt(this,"_adder",void 0),wt(this,"_clusterToolbar",void 0),wt(this,"_hostFrame",void 0),wt(this,"_highlightsVisible",void 0),wt(this,"_isAdderVisible",void 0),wt(this,"_informHostOnNextSelectionClear",void 0),wt(this,"_selectionObserver",void 0),wt(this,"_annotations",void 0),wt(this,"_frameIdentifier",void 0),
113
+ wt(this,"_portFinder",void 0),wt(this,"_integration",void 0),wt(this,"_hostRPC",void 0),wt(this,"_sidebarRPC",void 0),wt(this,"_bucketBarClient",void 0),wt(this,"_sideBySideActive",void 0),wt(this,"_listeners",void 0),wt(this,"_hoveredAnnotations",void 0),this.element=t,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._adder=new Re(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:t=>this.selectAnnotations(t,{focusInSidebar:!0})}),this._selectionObserver=new oo((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new Nt({hostFrame:this._hostFrame,source:"guest",sourceId:null!==(i=this._frameIdentifier)&&void 0!==i?i:void 0}),this.features=new on,this._integration=no(this),this._integration.on("uriChanged",(async()=>{
114
+ const t=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",t)})),e.contentInfoBanner)&&(null===(s=(a=this._integration).showContentInfo)||void 0===s||s.call(a,e.contentInfoBanner));null!==(o=(r=this._integration).canStyleClusteredHighlights)&&void 0!==o&&o.call(r)&&(this._clusterToolbar=new Je(t,{features:this.features})),this._hostRPC=new Vt,this._connectHost(n),this._sidebarRPC=new Vt,this._connectSidebar(),this._bucketBarClient=new Ye({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._sideBySideActive=!1,this._listeners=new Ct,this._setupElementEvents(),this._hoveredAnnotations=new Set}_setupElementEvents(){const t=t=>{this._sideBySideActive||so(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:i}=t,o=so(e);if(o.length&&this._highlightsVisible){const t=n||i;this.selectAnnotations(o,{toggle:t})}})),this._listeners.add(this.element,"mousedown",(({target:e})=>{t(e)})),
115
+ this._listeners.add(this.element,"touchstart",(({target:e})=>{t(e)})),this._listeners.add(this.element,"mouseover",(({target:t})=>{const e=so(t);e.length&&this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(t=>{this._handleShortcut(t)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){var t,e;const[n,i,o]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),null===(t=(e=this._integration).segmentInfo)||void 0===t?void 0:t.call(e)]);return{uri:xn(n),metadata:i,segmentInfo:o}}_repositionAdder(){var t;if(!1===this._isAdderVisible)return;const e=null===(t=window.getSelection())||void 0===t?void 0:t.getRangeAt(0);e&&this._onSelection(e)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{io(document)&&(this._informHostOnNextSelectionClear=!1,lo())})),
116
+ this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._hostRPC.on("scrollToClosestOffScreenAnchor",((t,e)=>this._scrollToClosestOffScreenAnchor(t,e))),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e}))),this._hostRPC.on("sidebarLayoutChanged",(e=>{var n,i;((n=window)===(i=t)||n.parent===i&&n.frameElement&&n.frameElement.getBoundingClientRect().width/n.parent.innerWidth>=.8)&&this.fitSideBySide(e)}));const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=ao(e);if(!n)return;const i=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n})
117
+ ;this.element.dispatchEvent(i)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t))))),this._sidebarRPC.on("showContentInfo",(t=>{var e,n;return null===(e=(n=this._integration).showContentInfo)||void 0===e?void 0:e.call(n,t)})),this._sidebarRPC.on("navigateToSegment",(t=>{var e,n;return null===(e=(n=this._integration).navigateToSegment)||void 0===e?void 0:e.call(n,t)})),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this.getDocumentInfo().then((t=>this._sidebarRPC.call("documentInfoChanged",t)))}destroy(){var t;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){
118
+ We(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){const e=t=>{var e;const n=ao(t);if(!n)return;const i=ze(n,c("hypothesis-highlight",null===(e=t.annotation)||void 0===e?void 0:e.$cluster));i.forEach((e=>{e._annotation=t.annotation})),t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&je(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=Ie.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){
119
+ this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&We(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+St(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),lo(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);je(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o
120
+ ;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=Xe(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=De(e),i=qe(e);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=ro(),this._isAdderVisible=!0,this._adder.show(i,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}
121
+ setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Kt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function ho(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function uo(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1138.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0]
122
+ ;t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function fo({config:t,groupId:e}){return ct("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:ho(t.notebookAppUrl,{...uo(t.notebookAppUrl,t),group:e})})}function po({eventBus:t,config:e}){const[n,i]=G(0),[o,r]=G(!0),[s,a]=G(null),l=J(""),h=J(null);K((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),K((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),K((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),h.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ct("div",{className:c("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",
123
+ children:ct("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ct("div",{className:"absolute right-0 text-xl m-3",children:ct(mt,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=h.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),ct(fo,{config:e,groupId:s},n)]})})}class mo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ae(this._outerContainer),I(ct(po,{eventBus:e,config:n}),this.shadowRoot)}destroy(){I(null,this.shadowRoot),this._outerContainer.remove()}}var go={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),
124
+ i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){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=e.console&&(e.console.warn||e.console.log);return r&&r.call(e.console,o,i),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===o||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign;var m=p((function(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;)(!n||n&&t[i[r]]===o)&&(t[i[r]]=e[i[r]]),r++;return t}),"extend","Use `assign`."),g=p((function(t,e){return m(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var i,o=e.prototype;(i=t.prototype=Object.create(o)).constructor=t,
125
+ i._super=o,n&&r(i,n)}function v(t,e){return function(){return t.apply(e,arguments)}}function y(t,e){return"function"==typeof t?t.apply(e&&e[0]||o,e):t}function b(t,e){return t===o?e:t}function w(t,e,n){f(E(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(E(e),(function(e){t.removeEventListener(e,n,!1)}))}function x(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function E(t){return t.trim().split(/\s+/g)}function k(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}function N(t){return Array.prototype.slice.call(t,0)}function A(t,e,n){for(var i=[],o=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];k(o,s)<0&&i.push(t[r]),o[r]=s,r++}return n&&(i=e?i.sort((function(t,n){return t[e]>n[e]})):i.sort()),i}function T(t,e){for(var n,i,r=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((i=(n=s[a])?n+r:e)in t)return i;a++}return o}var R=1;function L(t){var n=t.ownerDocument||t
126
+ ;return n.defaultView||n.parentWindow||e}var P="ontouchstart"in e,M=T(e,"PointerEvent")!==o,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",B="mouse",H=24,D=["x","y"],F=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function q(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=1&e&&i-r==0,a=12&e&&i-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=U(e));r>1&&!n.firstMultiple?n.firstMultiple=U(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,u=e.center=z(i);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(l,u),e.distance=j(l,u),function(t,e){var n=e.center,i=t.offsetDelta||{},o=t.prevDelta||{},r=t.prevInput||{}
127
+ ;1!==e.eventType&&4!==r.eventType||(o=t.prevDelta={x:r.deltaX||0,y:r.deltaY||0},i=t.offsetDelta={x:n.x,y:n.y});e.deltaX=o.x+(n.x-i.x),e.deltaY=o.y+(n.y-i.y)}(n,e),e.offsetDirection=W(e.deltaX,e.deltaY);var d=$(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=i,j(p[0],p[1],F)/j(f[0],f[1],F)):1,e.rotation=a?function(t,e){return X(e[1],e[0],F)+X(t[1],t[0],F)}(a.pointers,i):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,r,s,a=t.lastInterval||e,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===o)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=$(l,h,u);i=d.x,r=d.y,n=c(d.x)>c(d.y)?d.x:d.y,s=W(h,u),t.lastInterval=e}else n=a.velocity,i=a.velocityX,r=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=i,e.velocityY=r,e.direction=s}(n,e);var f,p;var m=t.element;x(e.srcEvent.target,m)&&(m=e.srcEvent.target)
128
+ ;e.target=m}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function U(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:h(),pointers:e,center:z(e),deltaX:t.deltaX,deltaY:t.deltaY}}function z(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,i=0,o=0;o<e;)n+=t[o].clientX,i+=t[o].clientY,o++;return{x:l(n/e),y:l(i/e)}}function $(t,e,n){return{x:e/t||0,y:n/t||0}}function W(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function j(t,e,n){n||(n=D);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return Math.sqrt(i*i+o*o)}function X(t,e,n){n||(n=D);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return 180*Math.atan2(o,i)/Math.PI}V.prototype={handler:function(){},init:function(){this.evEl&&w(this.element,this.evEl,this.domHandler),this.evTarget&&w(this.target,this.evTarget,this.domHandler),this.evWin&&w(L(this.element),this.evWin,this.domHandler)},destroy:function(){
129
+ this.evEl&&C(this.element,this.evEl,this.domHandler),this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(L(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},Z="mousedown",G="mousemove mouseup";function K(){this.evEl=Z,this.evWin=G,this.pressed=!1,V.apply(this,arguments)}_(K,V,{handler:function(t){var e=Y[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:B,srcEvent:t}))}});var Q={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:I,3:"pen",4:B,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,V.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),_(nt,V,{handler:function(t){
130
130
  var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),o=Q[i],r=J[t.pointerType]||t.pointerType,s=r==I,a=k(e,t.pointerId,"pointerId");1&o&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):12&o&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,o,{pointers:e,changedPointers:[t],pointerType:r,srcEvent:t}),n&&e.splice(a,1))}});var it={touchstart:1,touchmove:2,touchend:4,touchcancel:8},ot="touchstart",rt="touchstart touchmove touchend touchcancel";function st(){this.evTarget=ot,this.evWin=rt,this.started=!1,V.apply(this,arguments)}function at(t,e){var n=N(t.touches),i=N(t.changedTouches);return 12&e&&(n=A(n.concat(i),"identifier",!0)),[n,i]}_(st,V,{handler:function(t){var e=it[t.type];if(1===e&&(this.started=!0),this.started){var n=at.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}}});var lt={touchstart:1,touchmove:2,touchend:4,touchcancel:8},ct="touchstart touchmove touchend touchcancel"
131
131
  ;function ht(){this.evTarget=ct,this.targetIds={},V.apply(this,arguments)}function ut(t,e){var n=N(t.touches),i=this.targetIds;if(3&e&&1===n.length)return i[n[0].identifier]=!0,[n,n];var o,r,s=N(t.changedTouches),a=[],l=this.target;if(r=n.filter((function(t){return x(t.target,l)})),1===e)for(o=0;o<r.length;)i[r[o].identifier]=!0,o++;for(o=0;o<s.length;)i[s[o].identifier]&&a.push(s[o]),12&e&&delete i[s[o].identifier],o++;return a.length?[A(r.concat(a),"identifier",!0),a]:void 0}_(ht,V,{handler:function(t){var e=lt[t.type],n=ut.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}});function dt(){V.apply(this,arguments);var t=v(this.handler,this);this.touch=new ht(this.manager,t),this.mouse=new K(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ft(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,pt.call(this,e)):12&t&&pt.call(this,e)}function pt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={
132
132
  x:e.clientX,y:e.clientY};this.lastTouches.push(n);var i=this.lastTouches;setTimeout((function(){var t=i.indexOf(n);t>-1&&i.splice(t,1)}),2500)}}function mt(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var o=this.lastTouches[i],r=Math.abs(e-o.x),s=Math.abs(n-o.y);if(r<=25&&s<=25)return!0}return!1}_(dt,V,{handler:function(t,e,n){var i=n.pointerType==I,o=n.pointerType==B;if(!(o&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)ft.call(this,e,n);else if(o&&mt.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var gt=T(a.style,"touchAction"),_t=gt!==o,vt="compute",yt="auto",bt="manipulation",wt="none",Ct="pan-x",xt="pan-y",St=function(){if(!_t)return!1;var t={},n=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(i){t[i]=!n||e.CSS.supports("touch-action",i)})),t}();function Et(t,e){this.manager=t,this.set(e)}Et.prototype={set:function(t){