hypothesis 1.1451.0 → 1.1453.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?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?fc245c","styles/annotator.css":"styles/annotator.css?ec72d0","styles/annotator.css.map":"styles/annotator.css.map?de3818","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e179ab","styles/katex.min.css.map":"styles/katex.min.css.map?cd8c0e","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?13d728","styles/sidebar.css.map":"styles/sidebar.css.map?1984a9","styles/ui-playground.css":"styles/ui-playground.css?db6174","styles/ui-playground.css.map":"styles/ui-playground.css.map?ec0173","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?feaedf","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?3d571c","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?32cfcd","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?d15e01","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?e43938"};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.1453.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 d=l,u=a(d.notebookAppUrl||"https://hypothes.is/notebook"),h=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),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,d=c;p<d.length;p++)e(s,i(t,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,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/.")}();
|
package/build/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?fc245c",
|
|
3
3
|
"styles/annotator.css": "styles/annotator.css?ec72d0",
|
|
4
4
|
"styles/annotator.css.map": "styles/annotator.css.map?de3818",
|
|
5
5
|
"styles/highlights.css": "styles/highlights.css?6b4ebd",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"styles/sidebar.css.map": "styles/sidebar.css.map?1984a9",
|
|
13
13
|
"styles/ui-playground.css": "styles/ui-playground.css?db6174",
|
|
14
14
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?ec0173",
|
|
15
|
-
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?
|
|
15
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?feaedf",
|
|
16
16
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?3d571c",
|
|
17
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
17
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?32cfcd",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?d15e01",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?e43938"
|
|
20
20
|
}
|
|
@@ -115,72 +115,72 @@ showNoTextWarning(t){this._noTextWarning=t,this._update()}destroy(){var t;null==
|
|
|
115
115
|
i(this,"_updateAnnotationLayerVisibility",void 0),i(this,"_sideBySideActive",void 0),this._annotator=t;const a=window,l=a.PDFViewerApplication;this._pdfViewer=l.pdfViewer,this._pdfViewer.viewer.classList.add("has-transparent-text-layer"),this._pdfContainer=null!==(n=null===(r=l.appConfig)||void 0===r?void 0:r.appContainer)&&void 0!==n?n:document.body,this._pdfMetadata=new Uo(l),this._observer=new MutationObserver(vo((()=>this._update()),100)),this._observer.observe(this._pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=null!==(s=e.reanchoringMaxWait)&&void 0!==s?s:3e3,this._banner=new Xo,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const t=a.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new o,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){this.fitSideBySide({
|
|
116
116
|
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(t){this._banner.setContentInfo(t)}anchor(t,e){return Lo(0,e)}getAnnotatableRange(t){try{const e=Fn.trimmedRange(t);if(function(t){try{return Bo(t),!0}catch{return!1}}(e))return e}catch(t){if(!(t instanceof RangeError))throw t}return null}canStyleClusteredHighlights(){return!0}describe(t,e){return Do(t,e)}async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=Ao();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await ko(n)).trim().length>0){e=!0;break}return e}();this._banner.showNoTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_update(){
|
|
117
117
|
const t=[],e=this._pdfViewer.pagesCount;for(let t=0;t<e;t++){var n;const e=this._pdfViewer.getPageView(t);if(null!=e&&null!==(n=e.textLayer)&&void 0!==n&&n.renderingDone)switch(e.renderingState){case xo.INITIAL:e.textLayer=null;break;case xo.FINISHED:i=e.div,o=void 0,null===(o=i.querySelector(Hn))||void 0===o||o.remove()}}var i,o;for(const e of this._annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const i=e.highlights[n];if(!document.body.contains(i)){e.highlights.splice(n,1),delete e.range,t.push(e.annotation);break}}}t.map((t=>this._annotator.anchor(t)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(t){const e=window.innerWidth-t.width,n=t.expanded&&e>=680,i=n?t.width:t.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),this._pdfViewer.update(),
|
|
118
|
-
this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}async scrollToAnchor(t){const e=t.annotation,n=$o(t),i=this._anchorOffset(t);if(null!==i&&(await Ki(this.contentContainer(),i),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await Ki(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const i=Date.now();let o;do{o=this._annotator.anchors.find((e=>e.annotation===t)),o&&!$o(o)||(o=null,await jo(20))}while(!o&&Date.now()-i<e);return null!==(n=o)&&void 0!==n?n:null}_anchorOffset(t){if(!t.highlights)return null;return function(t,e){let n=0;for(;t!==e&&e.contains(t);)n+=t.offsetTop,t=t.offsetParent;return n}(t.highlights[0],this.contentContainer())}}function Go(t){
|
|
119
|
-
}class
|
|
120
|
-
this._onFrameRemoved(t)}_discoverFrames(){const t=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const e of t)this._annotatableFrames.has(e)||this._addFrame(e);for(const e of this._annotatableFrames)t.has(e)||this._removeFrame(e)}}function
|
|
121
|
-
l||(i=setInterval(a,n))},t.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),t.removeEventListener("load",a)}}class
|
|
122
|
-
i(this,"_imageSizeObserver",void 0),i(this,"_listeners",void 0),i(this,"_updateTextLayerSize",void 0),e.length!==n.length)throw new Error("Char boxes length does not match text length");const r=t.parentNode,s=document.createElement("hypothesis-text-layer");r.insertBefore(s,t.nextSibling),r.style.position="relative",s.style.position="absolute",s.style.top="0",s.style.left="0",s.style.color="transparent",s.style.textAlign="left",s.style.mixBlendMode="multiply";const a="sans-serif";s.style.fontSize="16px",s.style.fontFamily=a;const l=document.createElement("canvas").getContext("2d");l.font=`16px ${a}`;const c=(t,e,n="px")=>`calc(var(--${t}-scale) * ${e}${n})`,h=function(t,e){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 t.entries()){const t=e[n],s=/\s/.test(t);i.text.length>0&&!R(i.rect,r)&&o(),i.rect=O(i.rect,r),i.text+=s?" ":t,s&&o()}o();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{
|
|
123
|
-
s={words:[],rect:new DOMRect})};for(const t of n){const e=s.words[s.words.length-1];if(e){const n=M(e.rect),i=M(t.rect).x-n.x;(!R(e.rect,t.rect)||i<0)&&a()}s.words.push(t),s.rect=O(s.rect,t.rect)}a();const l=[];let c={lines:[],rect:new DOMRect};const h=()=>{c.lines.length>0&&(l.push(c),c={lines:[],rect:new DOMRect})};for(const t of r){const e=c.lines[c.lines.length-1];if(e){const n=M(e.rect),i=M(t.rect).y-n.y;(!P(e.rect,t.rect)||R(e.rect,t.rect)||i<0||i>4*t.rect.height)&&h()}c.lines.push(t),c.rect=O(c.rect,t.rect)}return h(),l}(e,n);for(const t of h){const e=document.createElement("hypothesis-text-column");e.style.display="block",e.style.position="absolute",e.style.left=c("x",t.rect.left),e.style.top=c("y",t.rect.top);let n=null;for(const i of t.lines){const o=document.createElement("hypothesis-text-line");o.style.display="block",o.style.marginLeft=c("x",i.rect.left-t.rect.left),o.style.height=c("y",i.rect.height),n&&(o.style.marginTop=c("y",i.rect.top-n.rect.bottom)),n=i,
|
|
124
|
-
;let r=null;for(const t of i.words){const e=document.createElement("hypothesis-text-word");e.style.display="inline-block",e.style.transformOrigin="top left",e.textContent=t.text,r&&(e.style.marginLeft=c("x",t.rect.left-r.rect.right)),r=t,e.style.width=c("x",t.rect.width),e.style.height=c("y",t.rect.height),e.style.whiteSpace="pre";const n=l.measureText(t.text),i=c("x",t.rect.width/n.width,""),s=c("y",t.rect.height/16,"");e.style.transform=`scale(${i}, ${s})`,o.append(e)}e.append(o)}s.append(e)}const u=()=>{const{width:e,height:n}=t.getBoundingClientRect();s.style.width=e+"px",s.style.height=n+"px",s.style.setProperty("--x-scale",`${e}`),s.style.setProperty("--y-scale",`${n}`)};u(),this.container=s,this._updateTextLayerSize=vo(u,{maxWait:50}),this._listeners=new o,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(t)),this._listeners.add(window,"resize",this._updateTextLayerSize)}
|
|
125
|
-
this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){var t;this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),null===(t=this._imageSizeObserver)||void 0===t||t.disconnect()}}function
|
|
126
|
-
constructor(t=document.body,e={}){var n;super(),i(this,"_bookElement",void 0),i(this,"_htmlIntegration",void 0),i(this,"_listeners",void 0),i(this,"_textLayer",void 0),i(this,"_sideBySideActive",void 0);const r=null!==(n=e.bookElement)&&void 0!==n?n:
|
|
127
|
-
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
|
|
128
|
-
;return this._sideBySideActive=!1,q((()=>{t.expanded&&o>480?(n.style.textAlign="left",e.style.width=`${o}px`,this._sideBySideActive=!0):(n.style.textAlign="",e.style.width=""),i.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(t)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}async getMetadata(){return{title:this._bookElement.getBookInfo().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(function(t){const e=new URL(t,document.baseURI);return e.pathname+e.search}(n.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:t=!1,includePageIndex:e=!1}={}){
|
|
129
|
-
const[n,i,o]=await Promise.all([this._bookElement.getCurrentPage(),t?this._bookElement.getTOC():void 0,e?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const t of r)if(!(t in n))throw new Error(`Page metadata field "${t}" is missing`);let s;if(i){var a;s=n.chapterTitle;const t=
|
|
130
|
-
if(void 0!==window.PDFViewerApplication)return new Yo(t);return"content"===
|
|
131
|
-
"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;r(e)};this._document=e,this._listeners=new o,this._listeners.add(e,"selectionchange",s),this._listeners.add(e.body,"mousedown",s),this._listeners.add(e.body,"mouseup",s),r(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function
|
|
132
|
-
;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
|
|
133
|
-
i(this,"_informHostOnNextSelectionClear",void 0),i(this,"_selectionObserver",void 0),i(this,"_annotations",void 0),i(this,"_frameIdentifier",void 0),i(this,"_portFinder",void 0),i(this,"_integration",void 0),i(this,"_hostRPC",void 0),i(this,"_sidebarRPC",void 0),i(this,"_sidebarLayout",void 0),i(this,"_bucketBarClient",void 0),i(this,"_listeners",void 0),i(this,"_hoveredAnnotations",void 0),i(this,"_outsideAssignmentNotice",void 0),this.element=t,this._contentReady=e.contentReady,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._adder=new kn(this.element,{
|
|
134
|
-
this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new c({hostFrame:this._hostFrame,source:"guest",sourceId:null!==(r=this._frameIdentifier)&&void 0!==r?r:void 0}),this.features=new hi,this._featureFlagsReceived=new Promise((t=>{this.features.on("flagsChanged",t)})),this.sideBySide=e.sideBySide,this._integration=
|
|
135
|
-
var t;return"manual"===(null===(t=this.sideBySide)||void 0===t?void 0:t.mode)&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:i}=t,o=
|
|
136
|
-
this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){var t,e,n,i,o;const[r,s,a]=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:Zi(r),metadata:s,segmentInfo:a,persistent:null!==(n=null===(i=(o=this._integration).persistFrame)||void 0===i?void 0:i.call(o))&&void 0!==n&&n}}async _sendDocumentInfo(){var t,e;null!==(t=(e=this._integration).waitForFeatureFlags)&&void 0!==t&&t.call(e)&&await this._featureFlagsReceived;const n=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",n)}_repositionAdder(){if(!this._isAdderVisible)return;const t=qn()
|
|
137
|
-
this._hostRPC.on("scrollToAnnotation",(t=>{this._scrollToAnnotation(t)})),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e}))),this._hostRPC.on("sidebarLayoutChanged",(e=>{
|
|
138
|
-
this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(async t=>{try{await Promise.all(t.map((t=>this.anchor(t))))}catch(t){console.warn("Failed to anchor annotations:",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("setOutsideAssignmentNoticeVisible",(t=>{this._setOutsideAssignmentNoticeVisible(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)})),
|
|
139
|
-
null===(t=this._clusterToolbar)||void 0===t||t.destroy(),null===(e=this._outsideAssignmentNotice)||void 0===e||e.destroy(),function(t){Zn(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{var e;const n=
|
|
140
|
-
;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&&Zn(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
|
|
141
|
-
t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);Qn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Wn(n),o=jn(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=
|
|
142
|
-
}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){re(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(t){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new
|
|
143
|
-
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}function
|
|
144
|
-
className:ge("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:t}),"data-testid":"notebook-outer",children:ve("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:e})});function
|
|
145
|
-
classes:ge("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:ve(Ee,{className:"w-4 h-4"})})}),ve(
|
|
146
|
-
children:ve(Ee,{className:"w-4 h-4"})})}),ve("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class
|
|
147
|
-
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 g=m((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
|
|
148
|
-
function w(t,e){return t===o?e:t}function x(t,e,n){p(E(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){p(E(e),(function(e){t.removeEventListener(e,n,!1)}))}function S(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function N(t,e){return t.indexOf(e)>-1}function E(t){return t.trim().split(/\s+/g)}function A(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 T(t){return Array.prototype.slice.call(t,0)}function k(t,e,n){for(var i=[],o=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];A(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 R(t,e){
|
|
149
|
-
var M="ontouchstart"in e,I=R(e,"PointerEvent")!==o,L=M&&/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,z=4,$=8,j=16,X=W|z,Y=$|j,G=X|Y,K=["x","y"],Z=["clientX","clientY"];function Q(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 J(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=e&H&&i-r==0,a=e&(V|U)&&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=tt(e));r>1&&!n.firstMultiple?n.firstMultiple=tt(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,c=e.center=et(i)
|
|
150
|
-
;e.eventType!==H&&r.eventType!==V||(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=it(e.deltaX,e.deltaY);var d=nt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=h(d.x)>h(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=i,ot(p[0],p[1],Z)/ot(f[0],f[1],Z)):1,e.rotation=a?function(t,e){return rt(e[1],e[0],Z)+rt(t[1],t[0],Z)}(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(e.eventType!=U&&(l>F||a.velocity===o)){var c=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=nt(l,c,u);i=d.x,r=d.y,n=h(d.x)>h(d.y)?d.x:d.y,s=it(c,u),t.lastInterval=e
|
|
151
|
-
;S(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}function tt(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:c(t.pointers[n].clientX),clientY:c(t.pointers[n].clientY)},n++;return{timeStamp:u(),pointers:e,center:et(e),deltaX:t.deltaX,deltaY:t.deltaY}}function et(t){var e=t.length;if(1===e)return{x:c(t[0].clientX),y:c(t[0].clientY)};for(var n=0,i=0,o=0;o<e;)n+=t[o].clientX,i+=t[o].clientY,o++;return{x:c(n/e),y:c(i/e)}}function nt(t,e,n){return{x:e/t||0,y:n/t||0}}function it(t,e){return t===e?q:h(t)>=h(e)?t<0?W:z:e<0?$:j}function ot(t,e,n){n||(n=K);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return Math.sqrt(i*i+o*o)}function rt(t,e,n){n||(n=K);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return 180*Math.atan2(o,i)/Math.PI}Q.prototype={handler:function(){},init:function(){
|
|
152
|
-
this.evWin&&x(O(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(O(this.element),this.evWin,this.domHandler)}};var st={mousedown:H,mousemove:2,mouseup:V},at="mousedown",lt="mousemove mouseup";function ct(){this.evEl=at,this.evWin=lt,this.pressed=!1,Q.apply(this,arguments)}v(ct,Q,{handler:function(t){var e=st[t.type];e&H&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=V),this.pressed&&(e&V&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:D,srcEvent:t}))}});var ht={pointerdown:H,pointermove:2,pointerup:V,pointercancel:U,pointerout:U},ut={2:B,3:"pen",4:D,5:"kinect"},dt="pointerdown",ft="pointermove pointerup pointercancel";function pt(){this.evEl=dt,this.evWin=ft,Q.apply(this,arguments),
|
|
153
|
-
ft="MSPointerMove MSPointerUp MSPointerCancel"),v(pt,Q,{handler:function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),o=ht[i],r=ut[t.pointerType]||t.pointerType,s=r==B,a=A(e,t.pointerId,"pointerId");o&H&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):o&(V|U)&&(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 mt={touchstart:H,touchmove:2,touchend:V,touchcancel:U};function gt(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Q.apply(this,arguments)}function _t(t,e){var n=T(t.touches),i=T(t.changedTouches);return e&(V|U)&&(n=k(n.concat(i),"identifier",!0)),[n,i]}v(gt,Q,{handler:function(t){var e=mt[t.type];if(e===H&&(this.started=!0),this.started){var n=_t.call(this,t,e);e&(V|U)&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{
|
|
154
|
-
touchend:V,touchcancel:U},bt="touchstart touchmove touchend touchcancel";function yt(){this.evTarget=bt,this.targetIds={},Q.apply(this,arguments)}function wt(t,e){var n=T(t.touches),i=this.targetIds;if(e&(2|H)&&1===n.length)return i[n[0].identifier]=!0,[n,n];var o,r,s=T(t.changedTouches),a=[],l=this.target;if(r=n.filter((function(t){return S(t.target,l)})),e===H)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]),e&(V|U)&&delete i[s[o].identifier],o++;return a.length?[k(r.concat(a),"identifier",!0),a]:void 0}v(yt,Q,{handler:function(t){var e=vt[t.type],n=wt.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:B,srcEvent:t})}});var xt=2500;function Ct(){Q.apply(this,arguments);var t=b(this.handler,this);this.touch=new yt(this.manager,t),this.mouse=new ct(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}
|
|
155
|
-
Nt.call(this,e)):t&(V|U)&&Nt.call(this,e)}function Nt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={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)}),xt)}}function Et(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}v(Ct,Q,{handler:function(t,e,n){var i=n.pointerType==B,o=n.pointerType==D;if(!(o&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)St.call(this,e,n);else if(o&&Et.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var At=R(a.style,"touchAction"),Tt=At!==o,kt="compute",Rt="auto",Pt="manipulation",Ot="none",Mt="pan-x",It="pan-y",Lt=function(){if(!Tt)return!1;var t={},n=e.CSS&&e.CSS.supports
|
|
156
|
-
t[i]=!n||e.CSS.supports("touch-action",i)})),t}();function Bt(t,e){this.manager=t,this.set(e)}Bt.prototype={set:function(t){t==kt&&(t=this.compute()),Tt&&this.manager.element.style&&Lt[t]&&(this.manager.element.style[At]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return p(this.manager.recognizers,(function(e){y(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(N(t,Ot))return Ot;var e=N(t,Mt),n=N(t,It);if(e&&n)return Ot;if(e||n)return e?Mt:It;if(N(t,Pt))return Pt;return Rt}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,o=N(i,Ot)&&!Lt[Ot],r=N(i,It)&&!Lt[It],s=N(i,Mt)&&!Lt[Mt];if(o){var a=1===t.pointers.length,l=t.distance<2,c=t.deltaTime<250;if(a&&l&&c)return}
|
|
157
|
-
t.preventDefault()}};var Dt=1,Ft=32;function Ht(t){this.options=r({},this.defaults,t||{}),this.id=P++,this.manager=null,this.options.enable=w(this.options.enable,!0),this.state=Dt,this.simultaneous={},this.requireFail=[]}function Vt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Ut(t){return t==j?"down":t==$?"up":t==W?"left":t==z?"right":""}function qt(t,e){var n=e.manager;return n?n.get(t):t}function Wt(){Ht.apply(this,arguments)}function zt(){Wt.apply(this,arguments),this.pX=null,this.pY=null}function $t(){Wt.apply(this,arguments)}function jt(){Ht.apply(this,arguments),this._timer=null,this._input=null}function Xt(){Wt.apply(this,arguments)}function Yt(){Wt.apply(this,arguments)}function Gt(){Ht.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Kt(t,e){
|
|
158
|
-
this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(f(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=qt(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return f(t,"dropRecognizeWith",this)||(t=qt(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(f(t,"requireFailure",this))return this;var e=this.requireFail;return-1===A(e,t=qt(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(f(t,"dropRequireFailure",this))return this;t=qt(t,this);var e=A(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function i(n){e.manager.emit(n,t)}
|
|
159
|
-
if(this.canEmit())return this.emit(t);this.state=Ft},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(this.requireFail[t].state&(Ft|Dt)))return!1;t++}return!0},recognize:function(t){var e=r({},t);if(!y(this.options.enable,[this,e]))return this.reset(),void(this.state=Ft);56&this.state&&(this.state=Dt),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},v(Wt,Ht,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,i=6&e,o=this.attrTest(t);return i&&(n&U||!o)?16|e:i||o?n&V?8|e:2&e?4|e:2:Ft}}),v(zt,Wt,{defaults:{event:"pan",threshold:10,pointers:1,direction:G},getTouchAction:function(){var t=this.options.direction,e=[];return t&X&&e.push(It),t&Y&&e.push(Mt),e},
|
|
160
|
-
n=r!=this.pX,i=Math.abs(t.deltaX)):(o=0===s?q:s<0?$:j,n=s!=this.pY,i=Math.abs(t.deltaY))),t.direction=o,n&&i>e.threshold&&o&e.direction},attrTest:function(t){return Wt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Ut(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),v($t,Wt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Ot]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),v(jt,Ht,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Rt]},
|
|
161
|
-
|
|
162
|
-
this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&h(e)>this.options.velocity&&t.eventType&V},emit:function(t){var e=Ut(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),v(Gt,Ht,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Pt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,o=t.deltaTime<e.time;if(this.reset(),t.eventType&H&&0===this.count)return this.failTimeout();if(i&&o&&n){if(t.eventType!=V)return this.failTimeout();var r=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||ot(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,s&&r?this.count+=1:this.count=1,this._input=t,
|
|
163
|
-
2):8}return Ft},failTimeout:function(){return this._timer=d((function(){this.state=Ft}),this.options.interval,this),Ft},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Kt.VERSION="2.0.7",Kt.defaults={domEvents:!1,touchAction:kt,enable:!0,inputTarget:null,inputClass:null,preset:[[Xt,{enable:!1}],[$t,{enable:!1},["rotate"]],[Yt,{direction:X}],[zt,{direction:X},["swipe"]],[Gt],[Gt,{event:"doubletap",taps:2},["tap"]],[jt]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Zt(t,e){var n;this.options=r({},Kt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,
|
|
164
|
-
p(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Qt(t,e){var n,i=t.element;i.style&&(p(t.options.cssProps,(function(o,r){n=R(i.style,r),e?(t.oldCssProps[n]=i.style[n],i.style[n]=o):i.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Zt.prototype={set:function(t){return r(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,o=e.curRecognizer;(!o||o&&8&o.state)&&(o=e.curRecognizer=null);for(var r=0;r<i.length;)n=i[r],2===e.stopped||o&&n!=o&&!n.canRecognizeWith(o)?n.reset():n.recognize(t)
|
|
165
|
-
;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(f(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(f(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=A(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==o&&e!==o){var n=this.handlers;return p(E(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==o){var n=this.handlers;return p(E(t),(function(t){e?n[t]&&n[t].splice(A(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var i=n.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){
|
|
166
|
-
this.element&&Qt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(Kt,{INPUT_START:H,INPUT_MOVE:2,INPUT_END:V,INPUT_CANCEL:U,STATE_POSSIBLE:Dt,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Ft,DIRECTION_NONE:q,DIRECTION_LEFT:W,DIRECTION_RIGHT:z,DIRECTION_UP:$,DIRECTION_DOWN:j,DIRECTION_HORIZONTAL:X,DIRECTION_VERTICAL:Y,DIRECTION_ALL:G,Manager:Zt,Input:Q,TouchAction:Bt,TouchInput:yt,MouseInput:ct,PointerEventInput:pt,TouchMouseInput:Ct,SingleTouchInput:gt,Recognizer:Ht,AttrRecognizer:Wt,Tap:Gt,Pan:zt,Swipe:Yt,Pinch:$t,Rotate:Xt,Press:jt,on:x,off:C,each:p,merge:_,extend:g,assign:r,inherit:v,bindFn:b,prefixed:R}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Kt,"function"==typeof o&&o.amd?o((function(){return Kt})):t.exports?t.exports=Kt:e.Hammer=Kt}(window,document)}(
|
|
167
|
-
const s=t.anchors.length>0,a=e.anchors.length>0,l=t=>t.anchors.map((t=>t.tag));return ve("ul",{className:"relative",children:[s&&ve("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:t.position},children:ve(bn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const e=[...t.anchors].sort(((t,e)=>t.bottom-e.bottom)),n=e[e.length-1];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})}),n.map(((t,e)=>ve("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:t.position},children:ve(bn,{direction:"left",onClick:e=>r(l(t),e.metaKey||e.ctrlKey),onBlur:()=>i([]),onFocus:()=>i(l(t)),onMouseEnter:()=>i(l(t)),onMouseOut:()=>i([]),title:`Select nearby annotations (${t.anchors.length})`,children:t.anchors.length})},e))),a&&ve("li",{
|
|
168
|
-
"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const t=[...e.anchors].sort(((t,e)=>t.top-e.top)),n=t[0];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})})]})}class
|
|
169
|
-
const n=[],i=[],o=[];let r=null;function s(t){const{bottom:e,top:n}=t;return{bottom:e,position:n+(e-n)/2,anchors:[t],top:n}}const a=e.getBoundingClientRect(),l=t.map((t=>({tag:t.tag,top:t.top-a.top,bottom:t.bottom-a.top})));for(const t of l){const e=(t.top+t.bottom)/2;if(e<30){n.push(t);continue}if(e>a.height-30){i.push(t);continue}if(!r){r=s(t);continue}const l=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!l)o.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t),r.bottom=e,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 ve(
|
|
170
|
-
const[e,n]=zt([]),i=Gt((t=>n((e=>[...e,t]))),[]),o=Gt((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return $t((()=>(t.subscribe("toastMessageAdded",i),t.subscribe("toastMessageDismissed",o),()=>{t.unsubscribe("toastMessageAdded",i),t.unsubscribe("toastMessageDismissed",o)})),[t,o,i]),ve(hn,{messages:e,onMessageDismiss:o})}function
|
|
171
|
-
classes:ge("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:t,unstyled:!0,children:ve(Ee,{})}),!c&&ve(ht,{children:[ve(tn,{classes:ge("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,"aria-controls":i,onClick:a,unstyled:!0,children:ve(n?Oe:Re,{})}),ve("div",{className:"space-y-px-1.5 mt-px-2",children:[ve(
|
|
118
|
+
this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}async scrollToAnchor(t){const e=t.annotation,n=$o(t),i=this._anchorOffset(t);if(null!==i&&(await Ki(this.contentContainer(),i),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await Ki(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const i=Date.now();let o;do{o=this._annotator.anchors.find((e=>e.annotation===t)),o&&!$o(o)||(o=null,await jo(20))}while(!o&&Date.now()-i<e);return null!==(n=o)&&void 0!==n?n:null}_anchorOffset(t){if(!t.highlights)return null;return function(t,e){let n=0;for(;t!==e&&e.contains(t);)n+=t.offsetTop,t=t.offsetParent;return n}(t.highlights[0],this.contentContainer())}}function Go(t){if(!t.includes("["))return t;let e="",n=!1,i=!1;for(const o of t)n||"^"!==o?(n||"["!==o?!n&&i&&"]"===o?i=!1:i||(e+=o):i=!0,n=!1):n=!0;return e}function Ko(t){const e=Go(t),n=e.indexOf("!")
|
|
119
|
+
;return-1===n?e:e.slice(0,n)}class Zo{constructor(t,e,n){i(this,"_element",void 0),i(this,"_onFrameAdded",void 0),i(this,"_onFrameRemoved",void 0),i(this,"_annotatableFrames",void 0),i(this,"_isDisconnected",void 0),i(this,"_mutationObserver",void 0),this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(vo((()=>{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(t){this._annotatableFrames.add(t);try{if(await Qo(t),this._isDisconnected)return;t.contentWindow.addEventListener("unload",(()=>{this._removeFrame(t)})),this._onFrameAdded(t)}catch(e){console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${t.src}')`)}}_removeFrame(t){
|
|
120
|
+
this._annotatableFrames.delete(t),this._onFrameRemoved(t)}_discoverFrames(){const t=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const e of t)this._annotatableFrames.has(e)||this._addFrame(e);for(const e of this._annotatableFrames)t.has(e)||this._removeFrame(e)}}function Qo(t){return new Promise(((e,n)=>{const i=Jo(t,((t,o)=>{i(),o?e(o):n(t)}))}))}function Jo(t,e,{pollInterval:n=10}={}){let i,o;const r=new WeakSet,s=()=>{clearTimeout(i),i=void 0},a=()=>{const n=t.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),!function(t){var e;return"about:blank"===(null===(e=t.contentDocument)||void 0===e?void 0:e.location.href)&&t.hasAttribute("src")&&"about:blank"!==t.src}(t)){"interactive"===n.readyState||"complete"===n.readyState?e(null,n):n.addEventListener("DOMContentLoaded",(()=>e(null,n)))}var i;t.contentDocument&&(null===(i=t.contentWindow)||void 0===i||i.addEventListener("unload",o))}}else{s();const n=t.isConnected?"Frame is cross-origin":"Frame is disconnected";e(new Error(n))}}
|
|
121
|
+
;let l=!1;o=()=>{s(),l||(i=setInterval(a,n))},t.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),t.removeEventListener("load",a)}}class tr{constructor(t,e){i(this,"_config",void 0),i(this,"_frameObserver",void 0),this._config=e,this._frameObserver=new Zo(t,(t=>er(t,e)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function er(t,e,n){if(null!==t.contentDocument.querySelector("script.js-hypothesis-config"))return;await Qo(t);const{assetRoot:i,notebookAppUrl:o,profileAppUrl:r,sidebarAppUrl:a}=N(document),l={...e,assetRoot:i,notebookAppUrl:o,profileAppUrl:r,sidebarAppUrl:a,subFrameIdentifier:null!=n?n:s(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 h=document.createElement("script");h.async=!0,h.src=e.clientUrl;const u=t.contentDocument;u.body.appendChild(c),u.body.appendChild(h)}class nr{constructor(t,e,n){
|
|
122
|
+
if(i(this,"container",void 0),i(this,"_imageSizeObserver",void 0),i(this,"_listeners",void 0),i(this,"_updateTextLayerSize",void 0),e.length!==n.length)throw new Error("Char boxes length does not match text length");const r=t.parentNode,s=document.createElement("hypothesis-text-layer");r.insertBefore(s,t.nextSibling),r.style.position="relative",s.style.position="absolute",s.style.top="0",s.style.left="0",s.style.color="transparent",s.style.textAlign="left",s.style.mixBlendMode="multiply";const a="sans-serif";s.style.fontSize="16px",s.style.fontFamily=a;const l=document.createElement("canvas").getContext("2d");l.font=`16px ${a}`;const c=(t,e,n="px")=>`calc(var(--${t}-scale) * ${e}${n})`,h=function(t,e){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 t.entries()){const t=e[n],s=/\s/.test(t);i.text.length>0&&!R(i.rect,r)&&o(),i.rect=O(i.rect,r),i.text+=s?" ":t,s&&o()}o();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{
|
|
123
|
+
s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(const t of n){const e=s.words[s.words.length-1];if(e){const n=M(e.rect),i=M(t.rect).x-n.x;(!R(e.rect,t.rect)||i<0)&&a()}s.words.push(t),s.rect=O(s.rect,t.rect)}a();const l=[];let c={lines:[],rect:new DOMRect};const h=()=>{c.lines.length>0&&(l.push(c),c={lines:[],rect:new DOMRect})};for(const t of r){const e=c.lines[c.lines.length-1];if(e){const n=M(e.rect),i=M(t.rect).y-n.y;(!P(e.rect,t.rect)||R(e.rect,t.rect)||i<0||i>4*t.rect.height)&&h()}c.lines.push(t),c.rect=O(c.rect,t.rect)}return h(),l}(e,n);for(const t of h){const e=document.createElement("hypothesis-text-column");e.style.display="block",e.style.position="absolute",e.style.left=c("x",t.rect.left),e.style.top=c("y",t.rect.top);let n=null;for(const i of t.lines){const o=document.createElement("hypothesis-text-line");o.style.display="block",o.style.marginLeft=c("x",i.rect.left-t.rect.left),o.style.height=c("y",i.rect.height),n&&(o.style.marginTop=c("y",i.rect.top-n.rect.bottom)),n=i,
|
|
124
|
+
o.style.whiteSpace="nowrap";let r=null;for(const t of i.words){const e=document.createElement("hypothesis-text-word");e.style.display="inline-block",e.style.transformOrigin="top left",e.textContent=t.text,r&&(e.style.marginLeft=c("x",t.rect.left-r.rect.right)),r=t,e.style.width=c("x",t.rect.width),e.style.height=c("y",t.rect.height),e.style.whiteSpace="pre";const n=l.measureText(t.text),i=c("x",t.rect.width/n.width,""),s=c("y",t.rect.height/16,"");e.style.transform=`scale(${i}, ${s})`,o.append(e)}e.append(o)}s.append(e)}const u=()=>{const{width:e,height:n}=t.getBoundingClientRect();s.style.width=e+"px",s.style.height=n+"px",s.style.setProperty("--x-scale",`${e}`),s.style.setProperty("--y-scale",`${n}`)};u(),this.container=s,this._updateTextLayerSize=vo(u,{maxWait:50}),this._listeners=new o,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(t)),this._listeners.add(window,"resize",this._updateTextLayerSize)}
|
|
125
|
+
updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){var t;this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),null===(t=this._imageSizeObserver)||void 0===t||t.disconnect()}}function ir(t=document){return t.querySelector("mosaic-book")}function or(t=window){var e;if(ir(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&ir(n)?"content":null}class rr{constructor(t){i(this,"_frameObserver",void 0);const e=ir();if(!e)throw new Error("Book container element not found");const n=new WeakSet,o=e.shadowRoot,r=()=>{const e=o.querySelector("iframe");e&&!n.has(e)&&(n.add(e),Jo(e,((n,i)=>{if(n)return;const o=i.body;o&&!o.querySelector("#page-content")&&er(e,t,"vitalsource-content")})))};r(),this._frameObserver=new MutationObserver(r),this._frameObserver.observe(o,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function sr(){return document.querySelector("img#pbk-page")}
|
|
126
|
+
class ar extends d{constructor(t=document.body,e={}){var n;super(),i(this,"_bookElement",void 0),i(this,"_htmlIntegration",void 0),i(this,"_listeners",void 0),i(this,"_textLayer",void 0),i(this,"_sideBySideActive",void 0);const r=null!==(n=e.bookElement)&&void 0!==n?n:ir(window.parent.document);if(!r)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=r;const s=new hi;this._htmlIntegration=new Ji({container:t,features:s}),this._listeners=new o;const a=["mouseup","mousedown","mouseout"];for(const t of a)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const l=window.frameElement;l&&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})}(l);const c=sr(),h=window.innerPageData;if(c&&h){
|
|
127
|
+
const t=h.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 nr(c,t,h.words),this._textLayer.container.style.zIndex="100",this._sideBySideActive=!1}}getAnnotatableRange(t){return this._htmlIntegration.getAnnotatableRange(t)}destroy(){this._textLayer&&(this._textLayer.destroy(),this.fitSideBySide({expanded:!1,height:window.innerHeight,width:0,toolbarWidth:0})),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),{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 t={type:"PageSelector",index:o,label:r};l.push(t)}return n.push(...l),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(t){const e=sr();if(e&&this._textLayer){
|
|
128
|
+
const n=e.parentElement,i=this._textLayer,o=window.innerWidth-t.width;return this._sideBySideActive=!1,q((()=>{t.expanded&&o>480?(n.style.textAlign="left",e.style.width=`${o}px`,this._sideBySideActive=!0):(n.style.textAlign="",e.style.width=""),i.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(t)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}async getMetadata(){return{title:this._bookElement.getBookInfo().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(function(t){const e=new URL(t,document.baseURI);return e.pathname+e.search}(n.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:t=!1,includePageIndex:e=!1}={}){
|
|
129
|
+
const[n,i,o]=await Promise.all([this._bookElement.getCurrentPage(),t?this._bookElement.getTOC():void 0,e?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const t of r)if(!(t in n))throw new Error(`Page metadata field "${t}" is missing`);let s;if(i){var a;s=n.chapterTitle;const t=Ko(n.cfi),e=null===(a=i.data)||void 0===a?void 0:a.find((e=>Ko(e.cfi)===t));e&&(s=e.title)}let l=n.index;if(void 0===l&&o){var c;const t=null===(c=o.data)||void 0===c?void 0:c.findIndex((t=>t.cfi===n.cfi));-1!==t&&(l=t)}return{cfi:n.cfi,index:l,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(t){let e=[];try{const t=await this._bookElement.getPageBreaks();t.ok&&t.data&&(e=t.data)}catch(t){console.error("Failed to get page breaks",t)}const n=Go(t),i=e.filter((t=>t.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:t,url:e}=await this._getPageInfo();return{cfi:t,
|
|
130
|
+
pages:await this._getPageRange(t),url:e}}async uri(){const t=this._bookElement.getBookInfo().isbn;if(!t)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${t}`}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function lr(t){if(void 0!==window.PDFViewerApplication)return new Yo(t);return"content"===or()?new ar(document.body):new Ji({features:t.features,sideBySideOptions:t.sideBySide})}function cr(){return ve(sn,{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."})}class hr{constructor(t){i(this,"_container",void 0),i(this,"_visible",void 0),this._visible=!1,this._container=new En("notice",(()=>this._render())),t.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(t){this._visible=t,this._container.render()}_render(){
|
|
131
|
+
return this._visible?ve(cr,{}):null}}class ur{constructor(t,e=document){i(this,"_pendingCallback",void 0),i(this,"_document",void 0),i(this,"_listeners",void 0);let n=!1;this._pendingCallback=null;const r=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(qn(e.getSelection()))}),n)},s=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;r(e)};this._document=e,this._listeners=new o,this._listeners.add(e,"selectionchange",s),this._listeners.add(e.body,"mousedown",s),this._listeners.add(e.body,"mouseup",s),r(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function dr(t,e){if(t===e)return!0;if(t.parent!==e)return!1;if(!t.frameElement)return!1;return t.frameElement.getBoundingClientRect().width/t.parent.innerWidth>=.8}function fr(){var t;return function(t,e){const n=new Set,i=new Set
|
|
132
|
+
;return $n(t,(t=>{for(;t&&!n.has(t);){n.add(t);const o=e(t);null!=o&&i.add(o),t=t.parentNode}})),[...i]}(null!==(t=qn())&&void 0!==t?t:new Range,(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}))}function pr(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 mr(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function gr(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class _r extends CustomEvent{constructor(t){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:t}),i(this,"_ready",void 0),this._ready=null}get ready(){return this._ready}waitUntil(t){this._ready=t}}class vr extends d{constructor(t,e={},n=window){var r,s,a,l,h;(super(),i(this,"element",void 0),i(this,"selectedRanges",void 0),
|
|
133
|
+
i(this,"anchors",void 0),i(this,"features",void 0),i(this,"sideBySide",void 0),i(this,"_featureFlagsReceived",void 0),i(this,"_contentReady",void 0),i(this,"_adder",void 0),i(this,"_clusterToolbar",void 0),i(this,"_hostFrame",void 0),i(this,"_highlightsVisible",void 0),i(this,"_isAdderVisible",void 0),i(this,"_informHostOnNextSelectionClear",void 0),i(this,"_selectionObserver",void 0),i(this,"_annotations",void 0),i(this,"_frameIdentifier",void 0),i(this,"_portFinder",void 0),i(this,"_integration",void 0),i(this,"_hostRPC",void 0),i(this,"_sidebarRPC",void 0),i(this,"_sidebarLayout",void 0),i(this,"_bucketBarClient",void 0),i(this,"_listeners",void 0),i(this,"_hoveredAnnotations",void 0),i(this,"_outsideAssignmentNotice",void 0),this.element=t,this._contentReady=e.contentReady,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._adder=new kn(this.element,{
|
|
134
|
+
onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:t=>this.selectAnnotations(t,{focusInSidebar:!0})}),this._selectionObserver=new ur((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new c({hostFrame:this._hostFrame,source:"guest",sourceId:null!==(r=this._frameIdentifier)&&void 0!==r?r:void 0}),this.features=new hi,this._featureFlagsReceived=new Promise((t=>{this.features.on("flagsChanged",t)})),this.sideBySide=e.sideBySide,this._integration=lr(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),e.contentInfoBanner)&&(null===(l=(h=this._integration).showContentInfo)||void 0===l||l.call(h,e.contentInfoBanner));null!==(s=(a=this._integration).canStyleClusteredHighlights)&&void 0!==s&&s.call(a)&&(this._clusterToolbar=new mi(this._integration.contentContainer(),{features:this.features})),this._hostRPC=new C,
|
|
135
|
+
this._connectHost(n),this._sidebarRPC=new C,this._sidebarLayout=null,this._connectSidebar(),this._bucketBarClient=new ri({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new o,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){var t;return"manual"===(null===(t=this.sideBySide)||void 0===t?void 0:t.mode)&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:i}=t,o=pr(e);if(o.length&&this._highlightsVisible){const t=n||i;this.selectAnnotations(o,{toggle:t})}})),this._listeners.add(this.element,"pointerdown",(t=>{var e;this._sideBySideActive()||pr(t.target).length||dr(window,this._hostFrame)&&null!==(e=this._sidebarLayout)&&void 0!==e&&e.expanded&&window.innerWidth-t.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),this._listeners.add(this.element,"mouseover",(({target:t})=>{
|
|
136
|
+
const e=pr(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,n,i,o;const[r,s,a]=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:Zi(r),metadata:s,segmentInfo:a,persistent:null!==(n=null===(i=(o=this._integration).persistFrame)||void 0===i?void 0:i.call(o))&&void 0!==n&&n}}async _sendDocumentInfo(){var t,e;null!==(t=(e=this._integration).waitForFeatureFlags)&&void 0!==t&&t.call(e)&&await this._featureFlagsReceived;const n=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",n)}_repositionAdder(){if(!this._isAdderVisible)return;const t=qn()
|
|
137
|
+
;t&&this._onSelection(t)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{qn()&&(this._informHostOnNextSelectionClear=!1,gr())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._hostRPC.on("scrollToAnnotation",(t=>{this._scrollToAnnotation(t)})),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e}))),this._hostRPC.on("sidebarLayoutChanged",(e=>{dr(window,t)&&this.fitSideBySide(e),this.element.dispatchEvent(new si({sidebarLayout:e,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected")));const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}async _scrollToAnchor(t){const e=mr(t);if(!e)return;const n=new _r(e);this.element.dispatchEvent(n)&&(await n.ready,await this._integration.scrollToAnchor(t))}async _scrollToAnnotation(t){const e=this.anchors.find((e=>e.annotation.$tag===t))
|
|
138
|
+
;null!=e&&e.highlights&&await this._scrollToAnchor(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=>{this._scrollToAnnotation(t)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(async t=>{try{await Promise.all(t.map((t=>this.anchor(t))))}catch(t){console.warn("Failed to anchor annotations:",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("setOutsideAssignmentNoticeVisible",(t=>{this._setOutsideAssignmentNoticeVisible(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)})),
|
|
139
|
+
this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this._sendDocumentInfo()}destroy(){var t,e;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(),null===(e=this._outsideAssignmentNotice)||void 0===e||e.destroy(),function(t){Zn(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{var e;const n=mr(t);if(!n)return;const i=Gn(n,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)&&Qn(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=>{
|
|
140
|
+
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=Fn.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&&Zn(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
|
|
141
|
+
;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:"+s(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),gr(),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);Qn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Wn(n),o=jn(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=fr(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],
|
|
142
|
+
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){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){re(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(t){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new hr(this.element)),this._outsideAssignmentNotice.setVisible(t)}}function br(t,e){const n=new URL(t),i=new URLSearchParams
|
|
143
|
+
;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function yr(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1453.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}function wr({config:t,groupId:e}){return ve("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:br(t.notebookAppUrl,{...yr(t.notebookAppUrl,t),group:e})})}const xr=({isHidden:t,children:e,onClose:n})=>{const i=Xt(null);return $t((()=>{var e,n
|
|
144
|
+
;t?null===(e=i.current)||void 0===e||e.close():null===(n=i.current)||void 0===n||n.showModal()}),[t]),$t((()=>{const t=i.current;return null==t||t.addEventListener("cancel",n),()=>{null==t||t.removeEventListener("cancel",n)}}),[n]),ve("dialog",{ref:i,className:"relative w-full h-full backdrop:bg-black/50","data-testid":"notebook-outer",children:e})},Cr=({isHidden:t,children:e})=>ve("div",{className:ge("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:t}),"data-testid":"notebook-outer",children:ve("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:e})});function Sr({eventBus:t,config:e,document_:n=document}){const[i,o]=zt(0),[r,s]=zt(!0),[a,l]=zt(null),c=Xt(""),h=Xt(null),u=Yt((()=>function(t){return"function"==typeof t.createElement("dialog").showModal}(n)?xr:Cr),[n]);$t((()=>(c.current=document.body.style.overflow,()=>{document.body.style.overflow=c.current})),[]),$t((()=>{document.body.style.overflow=r?c.current:"hidden"}),[r]),$t((()=>{
|
|
145
|
+
const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{s(!1),o((t=>t+1)),l(t)})),h.current=e,()=>{e.destroy()}}),[t]);const d=Gt((()=>{var t;s(!0),null===(t=h.current)||void 0===t||t.publish("closeNotebook")}),[]);return null===a?null:ve(u,{isHidden:r,onClose:d,children:[ve("div",{className:"absolute right-0 m-3",children:ve(on,{title:"Close the Notebook",onClick:d,variant:"dark",classes:ge("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:ve(Ee,{className:"w-4 h-4"})})}),ve(wr,{config:e,groupId:a},i)]})}class Nr{constructor(t,e,n){i(this,"_container",void 0),this._container=new En("notebook",(()=>ve(Sr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Er({eventBus:t,config:e}){const[n,i]=zt(!0),o=Xt(null);$t((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:ve("div",{
|
|
146
|
+
className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:ve("div",{className:"relative w-full h-full","data-testid":"profile-inner",children:[ve("div",{className:"absolute right-0 m-3",children:ve(on,{title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:ge("!bg-transparent enabled:hover:!bg-grey-3"),children:ve(Ee,{className:"w-4 h-4"})})}),ve("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class Ar{constructor(t,e,n){i(this,"_container",void 0),this._container=new En("profile",(()=>ve(Er,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}var Tr={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,h=Math.abs,u=Date.now;function d(t,e,n){return setTimeout(b(t,n),e)}
|
|
147
|
+
function f(t,e,n){return!!Array.isArray(t)&&(p(t,n[e],n),!0)}function p(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 m(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 g=m((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
|
|
148
|
+
}),"extend","Use `assign`."),_=m((function(t,e){return g(t,e,!0)}),"merge","Use `assign`.");function v(t,e,n){var i,o=e.prototype;(i=t.prototype=Object.create(o)).constructor=t,i._super=o,n&&r(i,n)}function b(t,e){return function(){return t.apply(e,arguments)}}function y(t,e){return typeof t==l?t.apply(e&&e[0]||o,e):t}function w(t,e){return t===o?e:t}function x(t,e,n){p(E(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){p(E(e),(function(e){t.removeEventListener(e,n,!1)}))}function S(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function N(t,e){return t.indexOf(e)>-1}function E(t){return t.trim().split(/\s+/g)}function A(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 T(t){return Array.prototype.slice.call(t,0)}function k(t,e,n){for(var i=[],o=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];A(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 R(t,e){
|
|
149
|
+
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 P=1;function O(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var M="ontouchstart"in e,I=R(e,"PointerEvent")!==o,L=M&&/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,z=4,$=8,j=16,X=W|z,Y=$|j,G=X|Y,K=["x","y"],Z=["clientX","clientY"];function Q(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 J(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=e&H&&i-r==0,a=e&(V|U)&&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=tt(e));r>1&&!n.firstMultiple?n.firstMultiple=tt(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,l=a?a.center:s.center,c=e.center=et(i)
|
|
150
|
+
;e.timeStamp=u(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=rt(l,c),e.distance=ot(l,c),function(t,e){var n=e.center,i=t.offsetDelta||{},o=t.prevDelta||{},r=t.prevInput||{};e.eventType!==H&&r.eventType!==V||(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=it(e.deltaX,e.deltaY);var d=nt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=h(d.x)>h(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=i,ot(p[0],p[1],Z)/ot(f[0],f[1],Z)):1,e.rotation=a?function(t,e){return rt(e[1],e[0],Z)+rt(t[1],t[0],Z)}(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(e.eventType!=U&&(l>F||a.velocity===o)){var c=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=nt(l,c,u);i=d.x,r=d.y,n=h(d.x)>h(d.y)?d.x:d.y,s=it(c,u),t.lastInterval=e
|
|
151
|
+
}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;S(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}function tt(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:c(t.pointers[n].clientX),clientY:c(t.pointers[n].clientY)},n++;return{timeStamp:u(),pointers:e,center:et(e),deltaX:t.deltaX,deltaY:t.deltaY}}function et(t){var e=t.length;if(1===e)return{x:c(t[0].clientX),y:c(t[0].clientY)};for(var n=0,i=0,o=0;o<e;)n+=t[o].clientX,i+=t[o].clientY,o++;return{x:c(n/e),y:c(i/e)}}function nt(t,e,n){return{x:e/t||0,y:n/t||0}}function it(t,e){return t===e?q:h(t)>=h(e)?t<0?W:z:e<0?$:j}function ot(t,e,n){n||(n=K);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return Math.sqrt(i*i+o*o)}function rt(t,e,n){n||(n=K);var i=e[n[0]]-t[n[0]],o=e[n[1]]-t[n[1]];return 180*Math.atan2(o,i)/Math.PI}Q.prototype={handler:function(){},init:function(){
|
|
152
|
+
this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(O(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(O(this.element),this.evWin,this.domHandler)}};var st={mousedown:H,mousemove:2,mouseup:V},at="mousedown",lt="mousemove mouseup";function ct(){this.evEl=at,this.evWin=lt,this.pressed=!1,Q.apply(this,arguments)}v(ct,Q,{handler:function(t){var e=st[t.type];e&H&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=V),this.pressed&&(e&V&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:D,srcEvent:t}))}});var ht={pointerdown:H,pointermove:2,pointerup:V,pointercancel:U,pointerout:U},ut={2:B,3:"pen",4:D,5:"kinect"},dt="pointerdown",ft="pointermove pointerup pointercancel";function pt(){this.evEl=dt,this.evWin=ft,Q.apply(this,arguments),
|
|
153
|
+
this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(dt="MSPointerDown",ft="MSPointerMove MSPointerUp MSPointerCancel"),v(pt,Q,{handler:function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),o=ht[i],r=ut[t.pointerType]||t.pointerType,s=r==B,a=A(e,t.pointerId,"pointerId");o&H&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):o&(V|U)&&(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 mt={touchstart:H,touchmove:2,touchend:V,touchcancel:U};function gt(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,Q.apply(this,arguments)}function _t(t,e){var n=T(t.touches),i=T(t.changedTouches);return e&(V|U)&&(n=k(n.concat(i),"identifier",!0)),[n,i]}v(gt,Q,{handler:function(t){var e=mt[t.type];if(e===H&&(this.started=!0),this.started){var n=_t.call(this,t,e);e&(V|U)&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{
|
|
154
|
+
pointers:n[0],changedPointers:n[1],pointerType:B,srcEvent:t})}}});var vt={touchstart:H,touchmove:2,touchend:V,touchcancel:U},bt="touchstart touchmove touchend touchcancel";function yt(){this.evTarget=bt,this.targetIds={},Q.apply(this,arguments)}function wt(t,e){var n=T(t.touches),i=this.targetIds;if(e&(2|H)&&1===n.length)return i[n[0].identifier]=!0,[n,n];var o,r,s=T(t.changedTouches),a=[],l=this.target;if(r=n.filter((function(t){return S(t.target,l)})),e===H)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]),e&(V|U)&&delete i[s[o].identifier],o++;return a.length?[k(r.concat(a),"identifier",!0),a]:void 0}v(yt,Q,{handler:function(t){var e=vt[t.type],n=wt.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:B,srcEvent:t})}});var xt=2500;function Ct(){Q.apply(this,arguments);var t=b(this.handler,this);this.touch=new yt(this.manager,t),this.mouse=new ct(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}
|
|
155
|
+
function St(t,e){t&H?(this.primaryTouch=e.changedPointers[0].identifier,Nt.call(this,e)):t&(V|U)&&Nt.call(this,e)}function Nt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={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)}),xt)}}function Et(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}v(Ct,Q,{handler:function(t,e,n){var i=n.pointerType==B,o=n.pointerType==D;if(!(o&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)St.call(this,e,n);else if(o&&Et.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var At=R(a.style,"touchAction"),Tt=At!==o,kt="compute",Rt="auto",Pt="manipulation",Ot="none",Mt="pan-x",It="pan-y",Lt=function(){if(!Tt)return!1;var t={},n=e.CSS&&e.CSS.supports
|
|
156
|
+
;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 Bt(t,e){this.manager=t,this.set(e)}Bt.prototype={set:function(t){t==kt&&(t=this.compute()),Tt&&this.manager.element.style&&Lt[t]&&(this.manager.element.style[At]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return p(this.manager.recognizers,(function(e){y(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(N(t,Ot))return Ot;var e=N(t,Mt),n=N(t,It);if(e&&n)return Ot;if(e||n)return e?Mt:It;if(N(t,Pt))return Pt;return Rt}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,o=N(i,Ot)&&!Lt[Ot],r=N(i,It)&&!Lt[It],s=N(i,Mt)&&!Lt[Mt];if(o){var a=1===t.pointers.length,l=t.distance<2,c=t.deltaTime<250;if(a&&l&&c)return}
|
|
157
|
+
if(!s||!r)return o||r&&n&X||s&&n&Y?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var Dt=1,Ft=32;function Ht(t){this.options=r({},this.defaults,t||{}),this.id=P++,this.manager=null,this.options.enable=w(this.options.enable,!0),this.state=Dt,this.simultaneous={},this.requireFail=[]}function Vt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Ut(t){return t==j?"down":t==$?"up":t==W?"left":t==z?"right":""}function qt(t,e){var n=e.manager;return n?n.get(t):t}function Wt(){Ht.apply(this,arguments)}function zt(){Wt.apply(this,arguments),this.pX=null,this.pY=null}function $t(){Wt.apply(this,arguments)}function jt(){Ht.apply(this,arguments),this._timer=null,this._input=null}function Xt(){Wt.apply(this,arguments)}function Yt(){Wt.apply(this,arguments)}function Gt(){Ht.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Kt(t,e){
|
|
158
|
+
return(e=e||{}).recognizers=w(e.recognizers,Kt.defaults.preset),new Zt(t,e)}Ht.prototype={defaults:{},set:function(t){return r(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(f(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=qt(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return f(t,"dropRecognizeWith",this)||(t=qt(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(f(t,"requireFailure",this))return this;var e=this.requireFail;return-1===A(e,t=qt(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(f(t,"dropRequireFailure",this))return this;t=qt(t,this);var e=A(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function i(n){e.manager.emit(n,t)}
|
|
159
|
+
n<8&&i(e.options.event+Vt(n)),i(e.options.event),t.additionalEvent&&i(t.additionalEvent),n>=8&&i(e.options.event+Vt(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=Ft},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(this.requireFail[t].state&(Ft|Dt)))return!1;t++}return!0},recognize:function(t){var e=r({},t);if(!y(this.options.enable,[this,e]))return this.reset(),void(this.state=Ft);56&this.state&&(this.state=Dt),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},v(Wt,Ht,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,i=6&e,o=this.attrTest(t);return i&&(n&U||!o)?16|e:i||o?n&V?8|e:2&e?4|e:2:Ft}}),v(zt,Wt,{defaults:{event:"pan",threshold:10,pointers:1,direction:G},getTouchAction:function(){var t=this.options.direction,e=[];return t&X&&e.push(It),t&Y&&e.push(Mt),e},
|
|
160
|
+
directionTest:function(t){var e=this.options,n=!0,i=t.distance,o=t.direction,r=t.deltaX,s=t.deltaY;return o&e.direction||(e.direction&X?(o=0===r?q:r<0?W:z,n=r!=this.pX,i=Math.abs(t.deltaX)):(o=0===s?q:s<0?$:j,n=s!=this.pY,i=Math.abs(t.deltaY))),t.direction=o,n&&i>e.threshold&&o&e.direction},attrTest:function(t){return Wt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Ut(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),v($t,Wt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Ot]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),v(jt,Ht,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Rt]},
|
|
161
|
+
process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,o=t.deltaTime>e.time;if(this._input=t,!i||!n||t.eventType&(V|U)&&!o)this.reset();else if(t.eventType&H)this.reset(),this._timer=d((function(){this.state=8,this.tryEmit()}),e.time,this);else if(t.eventType&V)return 8;return Ft},reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&t.eventType&V?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=u(),this.manager.emit(this.options.event,this._input)))}}),v(Xt,Wt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Ot]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),v(Yt,Wt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:X|Y,pointers:1},getTouchAction:function(){return zt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction
|
|
162
|
+
;return n&(X|Y)?e=t.overallVelocity:n&X?e=t.overallVelocityX:n&Y&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&h(e)>this.options.velocity&&t.eventType&V},emit:function(t){var e=Ut(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),v(Gt,Ht,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Pt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,i=t.distance<e.threshold,o=t.deltaTime<e.time;if(this.reset(),t.eventType&H&&0===this.count)return this.failTimeout();if(i&&o&&n){if(t.eventType!=V)return this.failTimeout();var r=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||ot(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,s&&r?this.count+=1:this.count=1,this._input=t,
|
|
163
|
+
0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=d((function(){this.state=8,this.tryEmit()}),e.interval,this),2):8}return Ft},failTimeout:function(){return this._timer=d((function(){this.state=Ft}),this.options.interval,this),Ft},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Kt.VERSION="2.0.7",Kt.defaults={domEvents:!1,touchAction:kt,enable:!0,inputTarget:null,inputClass:null,preset:[[Xt,{enable:!1}],[$t,{enable:!1},["rotate"]],[Yt,{direction:X}],[zt,{direction:X},["swipe"]],[Gt],[Gt,{event:"doubletap",taps:2},["tap"]],[jt]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Zt(t,e){var n;this.options=r({},Kt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,
|
|
164
|
+
this.input=new((n=this).options.inputClass||(I?pt:L?yt:M?Ct:ct))(n,J),this.touchAction=new Bt(this,this.options.touchAction),Qt(this,!0),p(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Qt(t,e){var n,i=t.element;i.style&&(p(t.options.cssProps,(function(o,r){n=R(i.style,r),e?(t.oldCssProps[n]=i.style[n],i.style[n]=o):i.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Zt.prototype={set:function(t){return r(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,o=e.curRecognizer;(!o||o&&8&o.state)&&(o=e.curRecognizer=null);for(var r=0;r<i.length;)n=i[r],2===e.stopped||o&&n!=o&&!n.canRecognizeWith(o)?n.reset():n.recognize(t),
|
|
165
|
+
!o&&14&n.state&&(o=e.curRecognizer=n),r++}},get:function(t){if(t instanceof Ht)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(f(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){if(f(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=A(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==o&&e!==o){var n=this.handlers;return p(E(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==o){var n=this.handlers;return p(E(t),(function(t){e?n[t]&&n[t].splice(A(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var i=n.createEvent("Event");i.initEvent(t,!0,!0),i.gesture=e,e.target.dispatchEvent(i)}(t,e);var i=this.handlers[t]&&this.handlers[t].slice();if(i&&i.length){e.type=t,e.preventDefault=function(){
|
|
166
|
+
e.srcEvent.preventDefault()};for(var o=0;o<i.length;)i[o](e),o++}},destroy:function(){this.element&&Qt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(Kt,{INPUT_START:H,INPUT_MOVE:2,INPUT_END:V,INPUT_CANCEL:U,STATE_POSSIBLE:Dt,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Ft,DIRECTION_NONE:q,DIRECTION_LEFT:W,DIRECTION_RIGHT:z,DIRECTION_UP:$,DIRECTION_DOWN:j,DIRECTION_HORIZONTAL:X,DIRECTION_VERTICAL:Y,DIRECTION_ALL:G,Manager:Zt,Input:Q,TouchAction:Bt,TouchInput:yt,MouseInput:ct,PointerEventInput:pt,TouchMouseInput:Ct,SingleTouchInput:gt,Recognizer:Ht,AttrRecognizer:Wt,Tap:Gt,Pan:zt,Swipe:Yt,Pinch:$t,Rotate:Xt,Press:jt,on:x,off:C,each:p,merge:_,extend:g,assign:r,inherit:v,bindFn:b,prefixed:R}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Kt,"function"==typeof o&&o.amd?o((function(){return Kt})):t.exports?t.exports=Kt:e.Hammer=Kt}(window,document)}(Tr);var kr=Tr.exports
|
|
167
|
+
;function Rr({above:t,below:e,buckets:n,onFocusAnnotations:i,onScrollToAnnotation:o,onSelectAnnotations:r}){const s=t.anchors.length>0,a=e.anchors.length>0,l=t=>t.anchors.map((t=>t.tag));return ve("ul",{className:"relative",children:[s&&ve("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:t.position},children:ve(bn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const e=[...t.anchors].sort(((t,e)=>t.bottom-e.bottom)),n=e[e.length-1];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})}),n.map(((t,e)=>ve("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:t.position},children:ve(bn,{direction:"left",onClick:e=>r(l(t),e.metaKey||e.ctrlKey),onBlur:()=>i([]),onFocus:()=>i(l(t)),onMouseEnter:()=>i(l(t)),onMouseOut:()=>i([]),title:`Select nearby annotations (${t.anchors.length})`,children:t.anchors.length})},e))),a&&ve("li",{
|
|
168
|
+
className:"absolute right-0 pointer-events-auto",style:{top:e.position},children:ve(bn,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const t=[...e.anchors].sort(((t,e)=>t.top-e.top)),n=t[0];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})})]})}class Pr{constructor(t,{onFocusAnnotations:e,onScrollToAnnotation:n,onSelectAnnotations:o}){i(this,"_container",void 0),i(this,"_positions",void 0),i(this,"_onFocusAnnotations",void 0),i(this,"_onScrollToAnnotation",void 0),i(this,"_onSelectAnnotations",void 0),this._positions=[],this._container=new En("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),t.appendChild(this._container.element),this._onFocusAnnotations=e,this._onScrollToAnnotation=n,this._onSelectAnnotations=o,this._container.render()}destroy(){this._container.destroy()}update(t){
|
|
169
|
+
this._positions=t,this._container.render()}_render(){const t=function(t,e){const n=[],i=[],o=[];let r=null;function s(t){const{bottom:e,top:n}=t;return{bottom:e,position:n+(e-n)/2,anchors:[t],top:n}}const a=e.getBoundingClientRect(),l=t.map((t=>({tag:t.tag,top:t.top-a.top,bottom:t.bottom-a.top})));for(const t of l){const e=(t.top+t.bottom)/2;if(e<30){n.push(t);continue}if(e>a.height-30){i.push(t);continue}if(!r){r=s(t);continue}const l=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!l)o.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t),r.bottom=e,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 ve(Rr,{above:t.above,below:t.below,buckets:t.buckets,onFocusAnnotations:t=>this._onFocusAnnotations(t),onScrollToAnnotation:t=>this._onScrollToAnnotation(t),onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e)})}}function Or({emitter:t}){
|
|
170
|
+
const[e,n]=zt([]),i=Gt((t=>n((e=>[...e,t]))),[]),o=Gt((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return $t((()=>(t.subscribe("toastMessageAdded",i),t.subscribe("toastMessageDismissed",o),()=>{t.unsubscribe("toastMessageAdded",i),t.unsubscribe("toastMessageDismissed",o)})),[t,o,i]),ve(hn,{messages:e,onMessageDismiss:o})}function Mr({icon:t,...e}){return ve(tn,{classes:ge("justify-center rounded","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...e,size:"custom",variant:"custom",children:ve(t,{})})}function Ir({highlightsVisible:t}){return ve("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}function Lr({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,sidebarContainerId:i,newAnnotationType:o,showHighlights:r,toggleHighlights:s,toggleSidebar:a,toggleSidebarRef:l,useMinimalControls:c=!1}){return ve("div",{className:ge("absolute left-[-33px] w-[33px] z-2","text-px-base leading-none"),children:[c&&n&&ve(tn,{
|
|
171
|
+
classes:ge("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:t,unstyled:!0,children:ve(Ee,{})}),!c&&ve(ht,{children:[ve(tn,{classes:ge("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,"aria-controls":i,onClick:a,unstyled:!0,children:ve(n?Oe:Re,{})}),ve("div",{className:"space-y-px-1.5 mt-px-2",children:[ve(Mr,{title:"Show highlights",icon:r?Qe:Fe,pressed:r,onClick:s}),ve(Mr,{title:"note"===o?"New page note":"New annotation",icon:"note"===o?je:Se,onClick:e})]}),ve(Ir,{highlightsVisible:r})]})]})}class Br{constructor(t,e){i(this,"_container",void 0),i(this,"_newAnnotationType",void 0),i(this,"_useMinimalControls",void 0),
|
|
172
172
|
i(this,"_highlightsVisible",void 0),i(this,"_sidebarOpen",void 0),i(this,"_sidebarContainerId",void 0),i(this,"_closeSidebar",void 0),i(this,"_toggleSidebar",void 0),i(this,"_toggleHighlights",void 0),i(this,"_createAnnotation",void 0),i(this,"_sidebarToggleButton",void 0);const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:r}=e;this._container=t,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._sidebarContainerId=e.sidebarContainerId,this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>r(!this._highlightsVisible),this._createAnnotation=()=>{n(),o(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(t){this._useMinimalControls=t,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(t){this._sidebarOpen=t,this.render()}get sidebarOpen(){
|
|
173
|
-
return this._sidebarOpen}set newAnnotationType(t){this._newAnnotationType=t,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(t){this._highlightsVisible=t,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){kt(ve(
|
|
174
|
-
i(this,"_messagesElement",void 0),i(this,"_toolbarWidth",void 0),i(this,"_renderFrame",void 0),i(this,"_guestWithSelection",void 0),i(this,"_sidebarRPC",void 0),i(this,"_guestRPC",void 0),i(this,"bucketBar",void 0),i(this,"features",void 0),i(this,"externalFrame",void 0),i(this,"iframeContainer",void 0),i(this,"toolbar",void 0),i(this,"onLoginRequest",void 0),i(this,"onLogoutRequest",void 0),i(this,"onSignupRequest",void 0),i(this,"onProfileRequest",void 0),i(this,"onHelpRequest",void 0),i(this,"onLayoutChange",void 0),i(this,"iframe",void 0),this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new C,this.iframe=function(t){const e=t.sidebarAppUrl,n=
|
|
175
|
-
;this.externalFrame=null!==(s=document.querySelector(n.externalContainerSelector))&&void 0!==s?s:t,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"===n.theme)this.iframeContainer.classList.add("theme-clean");else{let t;n.bucketContainerSelector&&(t=document.querySelector(n.bucketContainerSelector),t||console.warn(`Custom bucket container "${n.bucketContainerSelector}" not found`));const e=document.createElement("div");e.setAttribute("data-testid","sidebar-edge"),e.className=ge("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(e),t||(t=e),this.bucketBar=new
|
|
176
|
-
onScrollToAnnotation:t=>this._guestRPC.forEach((e=>e.call("scrollToAnnotation",t))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const e=Nn(this._hypothesisSidebar);e.appendChild(this.iframeContainer),t.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),e.appendChild(this._messagesElement),kt(ve(
|
|
173
|
+
return this._sidebarOpen}set newAnnotationType(t){this._newAnnotationType=t,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(t){this._highlightsVisible=t,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}render(){kt(ve(Lr,{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 Dr=280;class Fr{constructor(t,e,n){var r;if(i(this,"_emitter",void 0),i(this,"_config",void 0),i(this,"_listeners",void 0),i(this,"_gestureState",void 0),i(this,"_layoutState",void 0),i(this,"_hammerManager",void 0),i(this,"_hypothesisSidebar",void 0),
|
|
174
|
+
i(this,"_messagesElement",void 0),i(this,"_toolbarWidth",void 0),i(this,"_renderFrame",void 0),i(this,"_guestWithSelection",void 0),i(this,"_sidebarRPC",void 0),i(this,"_guestRPC",void 0),i(this,"bucketBar",void 0),i(this,"features",void 0),i(this,"externalFrame",void 0),i(this,"iframeContainer",void 0),i(this,"toolbar",void 0),i(this,"onLoginRequest",void 0),i(this,"onLogoutRequest",void 0),i(this,"onSignupRequest",void 0),i(this,"onProfileRequest",void 0),i(this,"onHelpRequest",void 0),i(this,"onLayoutChange",void 0),i(this,"iframe",void 0),this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new C,this.iframe=function(t){const e=t.sidebarAppUrl,n=br(e,yr(e,t)),i=document.createElement("iframe");return i.src=n,i.title="Hypothesis annotation viewer",i.className="sidebar-frame",i.allow="fullscreen; clipboard-write",Object.defineProperty(i,"allow",{writable:!1})}(n),this._config=n,this.bucketBar=null,this.features=new hi,n.externalContainerSelector){var s
|
|
175
|
+
;this.externalFrame=null!==(s=document.querySelector(n.externalContainerSelector))&&void 0!==s?s:t,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"===n.theme)this.iframeContainer.classList.add("theme-clean");else{let t;n.bucketContainerSelector&&(t=document.querySelector(n.bucketContainerSelector),t||console.warn(`Custom bucket container "${n.bucketContainerSelector}" not found`));const e=document.createElement("div");e.setAttribute("data-testid","sidebar-edge"),e.className=ge("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(e),t||(t=e),this.bucketBar=new Pr(t,{onFocusAnnotations:t=>this._guestRPC.forEach((e=>e.call("hoverAnnotations",t))),
|
|
176
|
+
onScrollToAnnotation:t=>this._guestRPC.forEach((e=>e.call("scrollToAnnotation",t))),onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const e=Nn(this._hypothesisSidebar);e.appendChild(this.iframeContainer),t.appendChild(this._hypothesisSidebar),this._messagesElement=document.createElement("div"),e.appendChild(this._messagesElement),kt(ve(Or,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&g(this.iframe.contentWindow),this._listeners=new o;const a=document.createElement("div");this.toolbar=new Br(a,{sidebarContainerId:null===(r=this.iframeContainer)||void 0===r?void 0:r.id,createAnnotation:()=>{var t;if(0===this._guestRPC.length)return;(null!==(t=this._guestWithSelection)&&void 0!==t?t:this._guestRPC[0]).call("createAnnotation")},setSidebarOpen:t=>t?this.open():this.close(),setHighlightsVisible:t=>this.setHighlightsVisible(t)}),
|
|
177
177
|
"clean"===n.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(a),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[l]=n.services||[];l&&(this.onLoginRequest=l.onLoginRequest,this.onLogoutRequest=l.onLogoutRequest,this.onSignupRequest=l.onSignupRequest,this.onProfileRequest=l.onProfileRequest,this.onHelpRequest=l.onHelpRequest),this.onLayoutChange=n.onLayoutChange,this._layoutState={expanded:!1,width:0,height:0,toolbarWidth:0},this._updateLayoutState(!1),this._setupSidebarEvents()}destroy(){var t,e;this._guestRPC.forEach((t=>t.destroy())),this._sidebarRPC.destroy(),null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),null===(e=this._hammerManager)||void 0===e||e.destroy(),this._hypothesisSidebar?(kt(null,this._messagesElement),
|
|
178
178
|
this._hypothesisSidebar.remove()):this.iframe.remove(),this._emitter.destroy(),g(null)}onFrameConnected(t,e){switch(t){case"guest":this._connectGuest(e);break;case"sidebar":this._sidebarRPC.connect(e)}}_connectGuest(t){const e=new C;e.on("textSelected",(()=>{this._guestWithSelection=e,this.toolbar.newAnnotationType="annotation",this._guestRPC.filter((t=>t!==e)).forEach((t=>t.call("clearSelection")))})),e.on("textUnselected",(()=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.filter((t=>t!==e)).forEach((t=>t.call("clearSelection")))})),e.on("highlightsVisibleChanged",(t=>{this.setHighlightsVisible(t)}));const n=this.bucketBar;n&&e.on("anchorsChanged",(t=>{0===this._guestRPC.indexOf(e)&&n.update(t)})),e.on("close",(()=>{e.destroy(),e===this._guestWithSelection&&(this._guestWithSelection=null),this._guestRPC=this._guestRPC.filter((t=>t!==e))})),e.connect(t),this._guestRPC.push(e),e.call("sidebarLayoutChanged",this._layoutState)}_setupSidebarEvents(){var t;t=document.body,
|
|
179
179
|
this._sidebarRPC.on("publicAnnotationCountChanged",(function(e){const n=t.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((t=>{t.textContent=e.toString()}))})),function(t,e){const n=t.querySelectorAll("[data-hypothesis-trigger]");Array.from(n).forEach((t=>{t.addEventListener("click",(t=>{e(),t.stopPropagation()}))}))}(document.body,(()=>this.open())),this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("connect",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const t="always"===this._config.showHighlights;this.setHighlightsVisible(t),(this._config.openSidebar||this._config.annotations||this._config.query||this._config.group)&&this.open()})),this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(t=>{this.hide(),this._emitter.publish("openNotebook",t)})),
|
|
180
|
-
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",(t=>{this._emitter.publish("toastMessageAdded",t)})),this._sidebarRPC.on("toastMessageDismissed",(t=>{this._emitter.publish("toastMessageDismissed",t)}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([t,e])=>{e&&this._sidebarRPC.on(t,(()=>e()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}_setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new
|
|
181
|
-
this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=
|
|
180
|
+
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",(t=>{this._emitter.publish("toastMessageAdded",t)})),this._sidebarRPC.on("toastMessageDismissed",(t=>{this._emitter.publish("toastMessageDismissed",t)}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([t,e])=>{e&&this._sidebarRPC.on(t,(()=>e()))}))}_resetGestureState(){this._gestureState={initial:null,final:null}}_setupGestures(){const t=this.toolbar.sidebarToggleButton;t&&(this._hammerManager=new kr.Manager(t),this._hammerManager.on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new kr.Pan({direction:kr.DIRECTION_HORIZONTAL})))}_updateLayout(){
|
|
181
|
+
this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=Dr&&(this.iframeContainer.style.width=`${e}px`),this._updateLayoutState()}})))}_updateLayoutState(t){var e,n;const i=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,{height:r}=o.getBoundingClientRect(),s=window.getComputedStyle(o),a=parseInt(s.width),l=parseInt(s.marginLeft);let c=i;"boolean"==typeof t?t&&(c+=a):(l<Dr?c-=l:c+=a,t=c>i);const h={expanded:t,width:t?c:i,height:r,toolbarWidth:i};this._layoutState=h,null===(n=this.onLayoutChange)||void 0===n||n.call(this,h),this._guestRPC.forEach((t=>t.call("sidebarLayoutChanged",h)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<Dr?this.close():this.open())}_onPan(t){const e=this.iframeContainer;if(e)switch(t.type){
|
|
182
182
|
case"panstart":this._resetGestureState(),e.classList.add("sidebar-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":e.classList.remove("sidebar-no-transition"),e.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 e=this._gestureState.initial,n=t.deltaX;this._gestureState.final=Math.min(Math.round(e+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const t=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*t+"px",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"),
|
|
183
|
-
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(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.remove("is-hidden")}hide(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.add("is-hidden")}}class
|
|
184
|
-
i(this,"_emitter",void 0),this._emitter=new d}createEmitter(){return new
|
|
185
|
-
()=>window.removeEventListener("message",e)}();o.push({destroy:t});const e=Y("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new _(n),r=new
|
|
183
|
+
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(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.remove("is-hidden")}hide(){var t;null===(t=this.iframeContainer)||void 0===t||t.classList.add("is-hidden")}}class Hr{constructor(t){i(this,"_emitter",void 0),i(this,"_subscriptions",void 0),this._emitter=t,this._subscriptions=[]}publish(t,...e){this._emitter.emit(t,...e)}subscribe(t,e){this._emitter.on(t,e),this._subscriptions.push([t,e])}unsubscribe(t,e){this._emitter.off(t,e),this._subscriptions=this._subscriptions.filter((([n,i])=>n!==t||i!==e))}destroy(){for(const[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class Vr{constructor(){
|
|
184
|
+
i(this,"_emitter",void 0),this._emitter=new d}createEmitter(){return new Hr(this._emitter)}}const Ur=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=Y("annotator");let e=()=>{};const n=new Promise((t=>{e=t}));Ur.addEventListener("destroy",e);const i=t.subFrameIdentifier?window.parent:window,o=[];if(i===window){if(function(){const t=document.querySelectorAll(["hypothesis-sidebar","hypothesis-notebook","hypothesis-profile"].join(","));return t.forEach((t=>t.remove())),t.length>0}())return void console.warn("Hypothesis did not load because it found an existing instance on the page.");const t=function(t=navigator.userAgent){if(!x(t))return()=>{};const e=t=>{var e;if("hypothesisPortClosed"===(null===(e=t.data)||void 0===e?void 0:e.type)&&t.ports[0]){const e=t.ports[0];w(e,"close"),e.close()}};return window.addEventListener("message",e),
|
|
185
|
+
()=>window.removeEventListener("message",e)}();o.push({destroy:t});const e=Y("sidebar"),n=new URL(e.sidebarAppUrl).origin,i=new _(n),r=new Vr,s=new Fr(document.body,r,e),a=new Nr(document.body,r,Y("notebook")),l=new Ar(document.body,r,Y("profile"));i.on("frameConnected",((t,e)=>s.onFrameConnected(t,e))),o.push(i,s,a,l)}if("container"===or()){const e=new rr(t);o.push(e)}else{const n=new tr(document.body,t),r=new vr(document.body,t,i);r.on("hostDisconnected",e),o.push(n,r)}n.then((()=>{o.forEach((t=>t.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove())),function(t=document){Array.from(t.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((t=>t.remove()))}()}))}))}();
|
|
186
186
|
//# sourceMappingURL=annotator.bundle.js.map
|