hypothesis 1.1069.0 → 1.1070.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";function t(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.every((function(e){return"function"==typeof t[e]}))}var n={es2017:function(){return!e(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!e(Promise.prototype,"finally")}};function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=o(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,s=function(){};return{s:s,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){l=!0,a=t},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw a}}}}function s(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var i=["es2017","es2018"];function l(t){t.setAttribute("data-hypothesis-asset","")}function c(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,l(n),t.head.appendChild(n)}function u(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,s=void 0===r||r,o=n.forceReload,a=void 0!==o&&o,i=t.createElement("script");s&&(i.type="module"),a&&(e+="#ts=".concat(Date.now())),i.src=e,i.async=!1,l(i),t.head.appendChild(i)}function p(t,e,n,r){var s=t.createElement("link");s.rel=e,s.href=r,s.type="application/annotator+".concat(n),l(s),t.head.appendChild(s)}function d(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),l(r),t.head.appendChild(r)}function f(t,e){return t.assetRoot+"build/"+t.manifest[e]}function h(t){return function(t){return t.filter((function(t){var e=n[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))}function y(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?y(e.src):null}function b(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var n=m(e);if(!n)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",n.hostname)).replace("{current_scheme}",n.protocol)}var v={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";function t(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function e(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.every((function(e){return"function"==typeof t[e]}))}var n={es2017:function(){return!e(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!e(Promise.prototype,"finally")}};function r(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=o(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,s=function(){};return{s:s,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){l=!0,a=t},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw a}}}}function s(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var i=["es2017","es2018"];function l(t){t.setAttribute("data-hypothesis-asset","")}function c(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,l(n),t.head.appendChild(n)}function u(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,s=void 0===r||r,o=n.forceReload,a=void 0!==o&&o,i=t.createElement("script");s&&(i.type="module"),a&&(e+="#ts=".concat(Date.now())),i.src=e,i.async=!1,l(i),t.head.appendChild(i)}function p(t,e,n,r){var s=t.createElement("link");s.rel=e,s.href=r,s.type="application/annotator+".concat(n),l(s),t.head.appendChild(s)}function d(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),l(r),t.head.appendChild(r)}function f(t,e){return t.assetRoot+"build/"+t.manifest[e]}function h(t){return function(t){return t.filter((function(t){var e=n[t];if(!e)throw new Error('Unknown polyfill set "'.concat(t,'"'));return e()}))}(t).map((function(t){return"scripts/polyfills-".concat(t,".bundle.js")}))}function y(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?y(e.src):null}function b(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var n=m(e);if(!n)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",n.hostname)).replace("{current_scheme}",n.protocol)}var v={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?7fcbce","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?db48c2","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?44387a","styles/annotator.css":"styles/annotator.css?31adb4","styles/annotator.css.map":"styles/annotator.css.map?203fff","styles/highlights.css":"styles/highlights.css?5dd56a","styles/highlights.css.map":"styles/highlights.css.map?34b9c1","styles/katex.min.css":"styles/katex.min.css?d477ff","styles/katex.min.css.map":"styles/katex.min.css.map?010d5b","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?2eeb58","styles/sidebar.css":"styles/sidebar.css?1fa510","styles/sidebar.css.map":"styles/sidebar.css.map?681f45","styles/ui-playground.css":"styles/ui-playground.css?ecff69","styles/ui-playground.css.map":"styles/ui-playground.css.map?aeccb7","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?cb10ed","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?05810d","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?3ad995"};if(function(){var t=[function(){return Promise.resolve()},function(){return new Map},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return t.every((function(t){return t()}))}catch(t){return!1}}()){var g=function(e){for(var n={},r=e.querySelectorAll("script.js-hypothesis-config"),s=0;s<r.length;s++){var o=void 0;try{o=JSON.parse(r[s].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),o={}}t(n,o)}return n}(document),j=b(g.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1070.0/");if(document.querySelector("hypothesis-app")){!function(t,e){d(t,"fetch",e.apiUrl),d(t,"fetch",e.apiUrl+"links");var n,o=h(i),a=r([].concat(s(o),["scripts/sidebar.bundle.js"]));try{for(a.s();!(n=a.n()).done;)u(t,f(e,n.value),{esModule:!0})}catch(t){a.e(t)}finally{a.f()}for(var l=0,p=["styles/katex.min.css","styles/sidebar.css"];l<p.length;l++)c(t,f(e,p[l]))}(document,{assetRoot:j,manifest:v,apiUrl:g.apiUrl})}else{var w=g,A=b(w.notebookAppUrl||"https://hypothes.is/notebook"),k=b(w.sidebarAppUrl||"https://hypothes.is/app.html");!function(t,e){if(!t.querySelector('link[type="application/annotator+html"]')){p(t,"sidebar","html",e.sidebarAppUrl),p(t,"notebook","html",e.notebookAppUrl),d(t,"style",f(e,"styles/annotator.css")),p(t,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");var n,o=h(i),a=r([].concat(s(o),["scripts/annotator.bundle.js"]));try{for(a.s();!(n=a.n()).done;)u(t,f(e,n.value),{esModule:!1})}catch(t){a.e(t)}finally{a.f()}var l=[];void 0!==window.PDFViewerApplication&&l.push("styles/pdfjs-overrides.css"),l.push("styles/highlights.css");for(var y=0,m=l;y<m.length;y++)c(t,f(e,m[y]))}}(document,{assetRoot:j,manifest:v,notebookAppUrl:A,sidebarAppUrl:k})}}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,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?7fcbce",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?db48c2",
|
|
4
|
+
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?44387a",
|
|
4
5
|
"styles/annotator.css": "styles/annotator.css?31adb4",
|
|
6
|
+
"styles/annotator.css.map": "styles/annotator.css.map?203fff",
|
|
5
7
|
"styles/highlights.css": "styles/highlights.css?5dd56a",
|
|
6
8
|
"styles/highlights.css.map": "styles/highlights.css.map?34b9c1",
|
|
7
|
-
"styles/
|
|
9
|
+
"styles/katex.min.css": "styles/katex.min.css?d477ff",
|
|
8
10
|
"styles/katex.min.css.map": "styles/katex.min.css.map?010d5b",
|
|
9
11
|
"styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
|
|
10
|
-
"styles/katex.min.css": "styles/katex.min.css?d477ff",
|
|
11
12
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?2eeb58",
|
|
12
|
-
"styles/sidebar.css.map": "styles/sidebar.css.map?681f45",
|
|
13
13
|
"styles/sidebar.css": "styles/sidebar.css?1fa510",
|
|
14
|
+
"styles/sidebar.css.map": "styles/sidebar.css.map?681f45",
|
|
14
15
|
"styles/ui-playground.css": "styles/ui-playground.css?ecff69",
|
|
15
16
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?aeccb7",
|
|
16
|
-
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?
|
|
17
|
-
"scripts/
|
|
18
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?f61bed"
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?cb10ed",
|
|
18
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?05810d",
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?3ad995"
|
|
20
20
|
}
|
|
@@ -46,74 +46,74 @@ const t="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#w
|
|
|
46
46
|
const e=t.location.href.match(/#annotations:(query|q):(.+)$/i);if(e)try{return decodeURIComponent(e[2])}catch(t){}return null}()},hostPageSetting:o}}function te(t,e){return t.hostPageSetting(e)}const ee={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:te},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:te},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},contentPartner:{allowInBrowserExt:!1,defaultValue:null,getValue:te},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:te},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:te},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:te},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:te},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:te},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:Zt,getValue:te
|
|
47
47
|
},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:te},services:{allowInBrowserExt:!1,defaultValue:null,getValue:te},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:t=>t.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.notebookAppUrl},sidebarAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:te},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:te}};function ne(t,e=window){const n=Qt(e),o={};for(let r of function(t){const e={annotator:["clientUrl","contentPartner","subFrameIdentifier"],sidebar:["appType","annotations","branding","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],
|
|
48
48
|
notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"]};switch(t){case"annotator":return e.annotator;case"sidebar":return e.sidebar;case"notebook":return e.notebook;case"all":return[...e.annotator,...e.sidebar,...e.notebook];default:throw new Error(`Invalid application context used: "${t}"`)}}(t)){const t=ee[r],s=void 0!==t.defaultValue,a=!((i=Kt(e,"sidebar","html")).startsWith("http://")||i.startsWith("https://"));if(!t.allowInBrowserExt&&a){s&&(o[r]=t.defaultValue);continue}const c=t.getValue(n,r);void 0!==c?o[r]=t.coerce?t.coerce(c):c:s&&(o[r]=t.defaultValue)}var i;return o}const oe={alt:1,ctrl:2,meta:4,shift:8};function ie(t,e,{rootElement:n=document.documentElement}={}){const o=n=>{(function(t,e){const n=e.split("+").map((t=>t.toLowerCase()));let o=0,i=null;for(let t of n){const e=oe[t];if(e)o|=e;else{if(null!==i)throw new Error("Multiple non-modifier keys specified");i=t}}if(!i)throw new Error(`Invalid shortcut: ${e}`)
|
|
49
|
-
;return((t.ctrlKey?oe.ctrl:0)|(t.metaKey?oe.meta:0)|(t.altKey?oe.alt:0)|(t.shiftKey?oe.shift:0))===o&&
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
document.body.style.marginRight=""}))}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
children:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
;
|
|
91
|
-
;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
;
|
|
98
|
-
|
|
99
|
-
return this._htmlIntegration.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
;
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.
|
|
49
|
+
;return((t.ctrlKey?oe.ctrl:0)|(t.metaKey?oe.meta:0)|(t.altKey?oe.alt:0)|(t.shiftKey?oe.shift:0))===o&&t.key.toLowerCase()===i})(n,t)&&e(n)};return n.addEventListener("keydown",o),()=>n.removeEventListener("keydown",o)}function re(t,e,{rootElement:n}={}){at((()=>{if(t)return ie(t,e,{rootElement:n})}),[t,e,n])}function se({badgeCount:t}){return _t("span",{className:K("rounded px-1 py-0.5","text-color-text-inverted font-bold bg-grey-7","dim-bg"),children:t})}function ae({arrowDirection:t}){return _t(Tt,{name:"pointer",classes:K("absolute left-1/2 -translate-x-1/2","h-auto w-auto z-2","text-grey-3 fill-white",{"rotate-180":"down"===t,"top-0 -translate-y-full":"up"===t})})}function ce({badgeCount:t,icon:e,label:n,onClick:o,shortcut:i}){re(i,o);const r=i?`${n} (${i})`:n;return _t(St,{className:K("flex flex-col gap-y-1 items-center py-2.5 px-2","text-annotator-sm leading-none text-grey-7","transition-colors duration-200","dim-item"),onClick:o,title:r,children:[e&&_t(Tt,{classes:"text-annotator-lg",name:e,title:r
|
|
50
|
+
}),"number"==typeof t&&_t(se,{badgeCount:t}),_t("span",{className:"font-normal",children:n})]})}function le({arrowDirection:t,isVisible:e,onCommand:n,annotationCount:o=0}){const i=e?"a":null,r=e?"h":null,s=e?"s":null;return re(e?"Escape":null,(()=>n("hide"))),_t("div",{className:K("AdderToolbar","absolute select-none bg-white rounded shadow-adder-toolbar","border border-solid border-grey-3","opacity-5",{"animate-adder-pop-up":"up"===t&&e,"animate-adder-pop-down":"down"===t&&e}),dir:"ltr",style:{visibility:e?"visible":"hidden"},children:[_t("div",{className:"flex dim-items-on-hover",children:[_t(ce,{icon:"annotate",onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),_t(ce,{icon:"highlight",onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),o>0&&_t(f,{children:[_t("div",{className:K("m-1.5 border-r border-grey-4 border-solid")}),_t(ce,{badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),_t(ae,{arrowDirection:t})]})}const he=(t=window)=>t.matchMedia("(pointer: coarse)").matches
|
|
51
|
+
;function ue(t){const e=t.attachShadow({mode:"open"});!function(t){var e;const n=null===(e=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]'))||void 0===e?void 0:e.href;if(!n)return;const o=document.createElement("link");o.rel="stylesheet",o.href=n,t.appendChild(o)}(e);const n=window.applyFocusVisiblePolyfill;var o;return n&&n(e),(o=e).addEventListener("mouseup",(t=>t.stopPropagation())),o.addEventListener("mousedown",(t=>t.stopPropagation())),o.addEventListener("touchstart",(t=>t.stopPropagation()),{passive:!0}),e}function de(t){return t.toString()+"px"}class fe{constructor(t,e){this._outerContainer=document.createElement("hypothesis-adder"),t.appendChild(this._outerContainer),this._shadowRoot=ue(this._outerContainer),Object.assign(this._outerContainer.style,{position:"absolute",top:0,left:0}),this._view=t.ownerDocument.defaultView,this._width=()=>this._shadowRoot.firstChild.getBoundingClientRect().width,
|
|
52
|
+
this._height=()=>this._shadowRoot.firstChild.getBoundingClientRect().height,this._isVisible=!1,this._arrowDirection="up",this._onAnnotate=e.onAnnotate,this._onHighlight=e.onHighlight,this._onShowAnnotations=e.onShowAnnotations,this.annotationsForSelection=[],this._render()}hide(){this._isVisible=!1,this._render(),Object.assign(this._outerContainer.style,{top:0,left:0})}destroy(){M(null,this._shadowRoot),this._outerContainer.remove()}show(t,e){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(t,e);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=2===i?"up":"down",this._render()}_calculateTarget(t,e){let n,o,i;n=e&&!he()?1:2;const r=Math.min(20,t.width),s=this._width(),a=he()?10:0,c=this._height();return i=e?t.left-s/2+r:t.left+t.width-s/2-r,t.top-c<0&&1===n?n=2:t.top+c>this._view.innerHeight&&(n=1),o=2===n?t.top+t.height+10+a:t.top-c-10,i=Math.max(i,0),i=Math.min(i,this._view.innerWidth-s),o=Math.max(o,0),o=Math.min(o,this._view.innerHeight-c),{top:o,left:i,arrowDirection:n}}_findZindex(t,e){
|
|
53
|
+
if(void 0===document.elementsFromPoint)return 32768;const n=this._width(),o=this._height(),i=[...new Set([...document.elementsFromPoint(t,e),...document.elementsFromPoint(t,e+o),...document.elementsFromPoint(t+n/2,e+o/2),...document.elementsFromPoint(t+n,e),...document.elementsFromPoint(t+n,e+o)])].map((t=>+getComputedStyle(t).zIndex)).filter(Number.isInteger);return i.push(0),Math.max(...i)+1}_showAt(t,e){const n=function(t){let e=t.parentElement;for(;e.parentElement&&"static"===getComputedStyle(e).position;)e=e.parentElement;return e}(this._outerContainer).getBoundingClientRect(),o=this._findZindex(t,e);Object.assign(this._outerContainer.style,{left:de(t-n.left),top:de(e-n.top),zIndex:o})}_render(){M(_t(le,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},
|
|
54
|
+
annotationCount:this.annotationsForSelection.length}),this._shadowRoot)}}function pe(t){switch(t.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return t.textContent.length;default:return 0}}function ge(t){let e=t.previousSibling,n=0;for(;e;)n+=pe(e),e=e.previousSibling;return n}function me(t,...e){let n=e.shift();const o=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),i=[];let r,s=o.nextNode(),a=0;for(;void 0!==n&&s;)r=s,a+r.data.length>n?(i.push({node:r,offset:n-a}),n=e.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=e.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}class _e{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element");let e=this.element,n=this.offset;for(;e!==t;)n+=ge(e),e=e.parentElement;return new _e(e,n)}resolve(t={}){try{
|
|
55
|
+
return me(this.element,this.offset)[0]}catch(e){if(0===this.offset&&void 0!==t.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=1===t.direction,i=o?n.nextNode():n.previousNode();if(!i)throw e;return{node:i,offset:o?0:i.data.length}}throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return _e.fromPoint(t,e);case Node.ELEMENT_NODE:return new _e(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const n=ge(t)+e;return new _e(t.parentElement,n)}case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let o=0;o<e;o++)n+=pe(t.childNodes[o]);return new _e(t,n)}default:throw new Error("Point is not in an element or text node")}}}class ve{
|
|
56
|
+
constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new ve(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=me(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:1}),e=this.end.resolve({direction:2}));const n=new Range;return n.setStart(t.node,t.offset),n.setEnd(e.node,e.offset),n}static fromRange(t){const e=_e.fromPoint(t.startContainer,t.startOffset),n=_e.fromPoint(t.endContainer,t.endOffset);return new ve(e,n)}static fromOffsets(t,e,n){return new ve(new _e(t,e),new _e(t,n))}}const ye=".annotator-placeholder";function we(t){return!!t.parentElement&&null!==t.parentElement.closest(ye)}function be(t){if(t.focusNode===t.anchorNode)return t.focusOffset<t.anchorOffset;return t.getRangeAt(0).startContainer===t.focusNode}function Ce(t,e){try{var n,o;const i=null!==(n=null===(o=e.nodeValue)||void 0===o?void 0:o.length)&&void 0!==n?n:e.childNodes.length
|
|
57
|
+
;return t.comparePoint(e,0)<=0&&t.comparePoint(e,i)>=0}catch(t){return!1}}function xe(t,e){const n=t.commonAncestorContainer,o=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let i;for(;i=o.nextNode();)Ce(t,i)&&e(i)}function Se(t){if(t.isCollapsed)return null;const e=function(t){const e=/^\s*$/,n=[];xe(t,(t=>{t.nodeType!==Node.TEXT_NODE||t.textContent.match(e)||n.push(t)}));let o=[];return n.forEach((e=>{const n=e.ownerDocument.createRange();if(n.selectNodeContents(e),e===t.startContainer&&n.setStart(e,t.startOffset),e===t.endContainer&&n.setEnd(e,t.endOffset),n.collapsed)return;const i=Array.from(n.getClientRects());n.detach(),o=o.concat(i)})),o}(t.getRangeAt(0));return 0===e.length?null:be(t)?e[0]:e[e.length-1]}const Ee="http://www.w3.org/2000/svg";function Te(t,e="hypothesis-highlight"){const n=function(t){if(t.collapsed)return[];let e=t.commonAncestorContainer;if(e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentElement),!e)return[]
|
|
58
|
+
;const n=[],o=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT);let i;for(;i=o.nextNode();){if(!Ce(t,i))continue;let e=i;e===t.startContainer&&t.startOffset>0?e.splitText(t.startOffset):(e===t.endContainer&&t.endOffset<e.data.length&&e.splitText(t.endOffset),n.push(e))}return n}(t),o=n.length>0&&we(n[0]);let i=[],r=null,s=null;n.forEach((t=>{r&&r.nextSibling===t?s.push(t):(s=[t],i.push(s)),r=t}));const a=/^\s*$/;i=i.filter((t=>t.some((t=>!a.test(t.data)))));const c=[];return i.forEach((t=>{const n=document.createElement("hypothesis-highlight");n.className=e;t[0].parentNode.replaceChild(n,t[0]),t.forEach((t=>n.appendChild(t))),c.push(n)})),o||function(t){if(0===t.length)return;const e=function(t){const e=t.closest(".page");return e&&e.querySelector(".canvasWrapper > canvas")||null}(t[0]);if(!e||!e.parentElement)return;let n=e.parentElement.querySelector(".hypothesis-highlight-layer");if(!n){n=document.createElementNS(Ee,"svg"),n.setAttribute("class","hypothesis-highlight-layer"),
|
|
59
|
+
e.parentElement.appendChild(n),e.parentElement.style.position="relative";const t=n.style;t.position="absolute",t.left="0",t.top="0",t.width="100%",t.height="100%",t.mixBlendMode="multiply"}const o=e.getBoundingClientRect(),i=t.map((t=>{const e=t.getBoundingClientRect(),n=document.createElementNS(Ee,"rect");return n.setAttribute("x",(e.left-o.left).toString()),n.setAttribute("y",(e.top-o.top).toString()),n.setAttribute("width",e.width.toString()),n.setAttribute("height",e.height.toString()),n.setAttribute("class","hypothesis-svg-highlight"),t.classList.add("is-transparent"),t.svgHighlight=n,n}));n.append(...i)}(c),c}function Ae(t,e){const n=t.parentNode;e.forEach((e=>n.insertBefore(e,t))),t.remove()}function ke(t){for(let e of t){if(e.parentNode){Ae(e,Array.from(e.childNodes))}e.svgHighlight&&e.svgHighlight.remove()}}function Re(t,e){t.forEach((t=>{if(t.svgHighlight){if(t.svgHighlight.classList.toggle("is-focused",e),e){t.svgHighlight.parentNode.append(t.svgHighlight)}
|
|
60
|
+
}else t.classList.toggle("hypothesis-highlight-focused",e)}))}function Le(t){const e=t.map((t=>t.getBoundingClientRect()));return e.reduce(((t,e)=>({top:Math.min(t.top,e.top),left:Math.min(t.left,e.left),bottom:Math.max(t.bottom,e.bottom),right:Math.max(t.right,e.right)})))}class Pe{constructor({contentContainer:t,hostRPC:e}){this._hostRPC=e,this._updatePending=!1,this._anchors=[],this._listeners=new Rt,this._listeners.add(window,"resize",(()=>this.update())),this._listeners.add(window,"scroll",(()=>this.update())),this._listeners.add(t,"scroll",(()=>this.update()))}destroy(){this._listeners.removeAll()}update(t){t&&(this._anchors=t),this._updatePending||(this._updatePending=!0,requestAnimationFrame((()=>{const t=function(t){const e=[];return t.forEach((({annotation:t,highlights:n})=>{if(null==n||!n.length)return;const{top:o,bottom:i}=Le(n);o>=i||e.push({tag:t.$tag,top:o,bottom:i})})),e.sort(((t,e)=>t.top-e.top)),e}(this._anchors);this._hostRPC.call("anchorsChanged",t),this._updatePending=!1})))}}
|
|
61
|
+
let Me=new Set;function Ne(...t){const e=t.join();Me.has(e)||(console.warn(...t),Me.add(e))}Ne.reset=()=>{Me.clear()};const Oe=["html_side_by_side"];class Ie extends Bt{constructor(t=Oe){super(),this._flags=new Map,this._knownFlags=t}update(t){this._flags.clear();for(let[e,n]of Object.entries(t))this._flags.set(e,n);this.emit("flagsChanged")}flagEnabled(t){var e;return this._knownFlags.includes(t)?null!==(e=this._flags.get(t))&&void 0!==e&&e:(Ne("Looked up unknown feature",t),!1)}allFlags(){return Object.fromEntries(this._flags)}}function De(t){return t.split("").reverse().join("")}function Be(t){return(t|-t)>>31&1}function Fe(t,e,n,o){let i=t.P[n],r=t.M[n];const s=o>>>31,a=e[n]|s,c=a|r,l=(a&i)+i^i|a;let h=r|~(l|i),u=i&l;const d=Be(h&t.lastRowMask[n])-Be(u&t.lastRowMask[n]);return h<<=1,u<<=1,u|=s,h|=Be(o)-s,i=u|~(c|h),r=h&c,t.P[n]=i,t.M[n]=r,d}function He(t,e,n){if(0===e.length)return[];n=Math.min(n,e.length);const o=[],i=32,r=Math.ceil(e.length/i)-1,s={P:new Uint32Array(r+1),M:new Uint32Array(r+1),
|
|
62
|
+
lastRowMask:new Uint32Array(r+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[r]=1<<(e.length-1)%i;const a=new Uint32Array(r+1),c=new Map,l=[];for(let t=0;t<256;t++)l.push(a);for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(c.has(n))continue;const o=new Uint32Array(r+1);c.set(n,o),n<l.length&&(l[n]=o);for(let t=0;t<=r;t+=1){o[t]=0;for(let r=0;r<i;r+=1){const s=t*i+r;if(s>=e.length)continue;e.charCodeAt(s)===n&&(o[t]|=1<<r)}}}let h=Math.max(0,Math.ceil(n/i)-1);const u=new Uint32Array(r+1);for(let t=0;t<=h;t+=1)u[t]=(t+1)*i;u[r]=e.length;for(let t=0;t<=h;t+=1)s.P[t]=-1,s.M[t]=0;for(let d=0;d<t.length;d+=1){const f=t.charCodeAt(d);let p;f<l.length?p=l[f]:(p=c.get(f),void 0===p&&(p=a));let g=0;for(let t=0;t<=h;t+=1)g=Fe(s,p,t,g),u[t]+=g;if(u[h]-g<=n&&h<r&&(1&p[h+1]||g<0)){let t;if(h+=1,s.P[h]=-1,s.M[h]=0,h===r){const n=e.length%i;t=0===n?i:n}else t=i;u[h]=u[h-1]+t-g+Fe(s,p,h,g)}else for(;h>0&&u[h]>=n+i;)h-=1;h===r&&u[h]<=n&&(u[h]<n&&o.splice(0,o.length),o.push({start:-1,end:d+1,errors:u[h]}),n=u[h])}return o}
|
|
63
|
+
function Ve(t,e,n){return function(t,e,n){const o=De(e);return n.map((n=>{const i=Math.max(0,n.end-e.length-n.errors);return{start:He(De(t.slice(i,n.end)),o,n.errors).reduce(((t,e)=>n.end-e.end<t?n.end-e.end:t),n.end),end:n.end,errors:n.errors}}))}(t,e,He(t,e,n))}function qe(t,e,n){let o=0,i=[];for(;-1!==o;)o=t.indexOf(e,o),-1!==o&&(i.push({start:o,end:o+e.length,errors:0}),o+=1);return i.length>0?i:Ve(t,e,n)}function Ue(t,e){if(0===e.length||0===t.length)return 0;return 1-qe(t,e,e.length)[0].errors/e.length}function We(t,e,n={}){if(0===e.length)return null;const o=Math.min(256,e.length/2),i=qe(t,e,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/e.length,r=n.prefix?Ue(t.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?Ue(t.slice(o.end,o.end+n.suffix.length),n.suffix):1;let a=1;if("number"==typeof n.hint){a=1-Math.abs(o.start-n.hint)/t.length}return(50*i+20*r+20*s+2*a)/92},s=i.map((t=>({start:t.start,end:t.end,score:r(t)})));return s.sort(((t,e)=>e.score-t.score)),s[0]}
|
|
64
|
+
function ze(t){const e=function(t){const e=t.nodeName.toLowerCase();let n=e;return"#text"===e&&(n="text()"),n}(t),n=function(t){let e=0,n=t;for(;n;)n.nodeName===t.nodeName&&(e+=1),n=n.previousSibling;return e}(t);return`${e}[${n}]`}function $e(t,e){let n="",o=t;for(;o!==e;){if(!o)throw new Error("Node is not a descendant of root");n=ze(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function je(t,e,n){e=e.toUpperCase();let o=-1;for(let i=0;i<t.children.length;i++){const r=t.children[i];if(r.nodeName.toUpperCase()===e&&(++o,o===n))return r}return null}function Xe(t,e=document.body){try{return function(t,e){if(null===t.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=t.split("/");let o=e;n.shift();for(let t of n){let e,n;const i=t.indexOf("[");if(-1!==i){e=t.slice(0,i);const o=t.slice(i+1,t.indexOf("]"));if(n=parseInt(o)-1,n<0)return null}else e=t,n=0;const r=je(o,e,n);if(!r)return null;o=r}return o}(t,e)}catch(n){
|
|
65
|
+
return document.evaluate("."+t,e,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}}class Ye{constructor(t,e){this.root=t,this.range=e}static fromRange(t,e){return new Ye(t,e)}static fromSelector(t,e){const n=Xe(e.startContainer,t);if(!n)throw new Error("Failed to resolve startContainer XPath");const o=Xe(e.endContainer,t);if(!o)throw new Error("Failed to resolve endContainer XPath");const i=_e.fromCharOffset(n,e.startOffset),r=_e.fromCharOffset(o,e.endOffset),s=new ve(i,r).toRange();return new Ye(t,s)}toRange(){return this.range}toSelector(){const t=ve.fromRange(this.range).toRange(),e=ve.fromRange(t),n=$e(e.start.element,this.root),o=$e(e.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:e.start.offset,endContainer:o,endOffset:e.end.offset}}}class Ge{constructor(t,e,n){this.root=t,this.start=e,this.end=n}static fromRange(t,e){const n=ve.fromRange(e).relativeTo(t);return new Ge(t,n.start.offset,n.end.offset)}static fromSelector(t,e){return new Ge(t,e.start,e.end)}
|
|
66
|
+
toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){return ve.fromOffsets(this.root,this.start,this.end).toRange()}}class Ze{constructor(t,e,n={}){this.root=t,this.exact=e,this.context=n}static fromRange(t,e){const n=t.textContent,o=ve.fromRange(e).relativeTo(t),i=o.start.offset,r=o.end.offset;return new Ze(t,n.slice(i,r),{prefix:n.slice(Math.max(0,i-32),i),suffix:n.slice(r,Math.min(n.length,r+32))})}static fromSelector(t,e){const{prefix:n,suffix:o}=e;return new Ze(t,e.exact,{prefix:n,suffix:o})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(t={}){return this.toPositionAnchor(t).toRange()}toPositionAnchor(t={}){const e=We(this.root.textContent,this.exact,{...this.context,hint:t.hint});if(!e)throw new Error("Quote not found");return new Ge(this.root,e.start,e.end)}}async function Ke(t,e={}){return t.toRange(e)}function Je(t,e,n={}){let o=null,i=null,r=null;for(let t of e)switch(t.type){
|
|
67
|
+
case"TextPositionSelector":o=t,n.hint=o.start;break;case"TextQuoteSelector":i=t;break;case"RangeSelector":r=t}const s=t=>{var e;if(null!==(e=i)&&void 0!==e&&e.exact&&t.toString()!==i.exact)throw new Error("quote mismatch");return t};let a=Promise.reject("unable to anchor");if(r){const e=r;a=a.catch((()=>Ke(Ye.fromSelector(t,e),n).then(s)))}if(o){const e=o;a=a.catch((()=>Ke(Ge.fromSelector(t,e),n).then(s)))}if(i){const e=i;a=a.catch((()=>Ke(Ze.fromSelector(t,e),n)))}return a}function Qe(t,e){const n=[Ye,Ge,Ze],o=[];for(let i of n)try{const n=i.fromRange(t,e);o.push(n.toSelector())}catch(t){continue}return o}function tn(t,e=document.baseURI){return new URL(t,e).href.toString().replace(/#.*/,"")}class en{constructor(t={}){this.document=t.document||document}uri(){let t=decodeURIComponent(this._getDocumentHref());const e=this._getLinks();for(let n of e)"canonical"===n.rel&&(t=n.href);return t}getDocumentMetadata(){const t={title:document.title,link:[],dc:this._getMetaTags("name","dc."),
|
|
68
|
+
eprints:this._getMetaTags("name","eprints."),facebook:this._getMetaTags("property","og:"),highwire:this._getMetaTags("name","citation_"),prism:this._getMetaTags("name","prism."),twitter:this._getMetaTags("name","twitter:")},e=this._getFavicon();e&&(t.favicon=e),t.title=this._getTitle(t),t.link=this._getLinks(t);const n=t.link.find((t=>t.href.startsWith("urn:x-dc")));return n&&(t.documentFingerprint=n.href),t}_getMetaTags(t,e){const n={};for(let o of Array.from(this.document.querySelectorAll("meta"))){const i=o.getAttribute(t),{content:r}=o;if(i&&r){const t=i.match(RegExp(`^${e}(.+)$`,"i"));if(t){const e=t[1].toLowerCase();n[e]?n[e].push(r):n[e]=[r]}}}return n}_getTitle(t){return t.highwire.title?t.highwire.title[0]:t.eprints.title?t.eprints.title[0]:t.prism.title?t.prism.title[0]:t.facebook.title?t.facebook.title[0]:t.twitter.title?t.twitter.title[0]:t.dc.title?t.dc.title[0]:this.document.title}_getLinks(t={dc:{},highwire:{}}){const e=[{href:this._getDocumentHref()
|
|
69
|
+
}],n=Array.from(this.document.querySelectorAll("link"));for(let t of n)if(["alternate","canonical","bookmark","shortlink"].includes(t.rel)){if("alternate"===t.rel){if(t.type&&t.type.match(/^application\/(rss|atom)\+xml/))continue;if(t.hreflang)continue}try{const n=this._absoluteUrl(t.href);e.push({href:n,rel:t.rel,type:t.type})}catch(t){}}for(let n of Object.keys(t.highwire)){const o=t.highwire[n];if("pdf_url"===n)for(let t of o)try{e.push({href:this._absoluteUrl(t),type:"application/pdf"})}catch(t){}if("doi"===n)for(let t of o)"doi:"!==t.slice(0,4)&&(t=`doi:${t}`),e.push({href:t})}for(let n of Object.keys(t.dc)){const o=t.dc[n];if("identifier"===n)for(let t of o)"doi:"===t.slice(0,4)&&e.push({href:t})}const o=t.dc["relation.ispartof"],i=t.dc.identifier;if(o&&i){const t=o[o.length-1],n=i[i.length-1],r="urn:x-dc:"+encodeURIComponent(t)+"/"+encodeURIComponent(n);e.push({href:r})}return e}_getFavicon(){let t=null
|
|
70
|
+
;for(let e of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(e.rel))try{t=this._absoluteUrl(e.href)}catch(t){}return t}_absoluteUrl(t){return tn(t,this.document.baseURI)}_getDocumentHref(){const{href:t}=this.document.location,e=["http:","https:","file:"],n=new URL(t).protocol;return e.includes(n)?t:this.document.baseURI&&e.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:t}}function nn(t){return t.width<=0||t.height<=0}function on(t,e,n,o){return Math.max(t,n)<Math.min(e,o)}function rn(t,e){return!nn(t)&&!nn(e)&&(on(t.left,t.right,e.left,e.right)&&on(t.top,t.bottom,e.top,e.bottom))}function sn(t,e){return on(t.top,t.bottom,e.top,e.bottom)}function an(t,e){return on(t.left,t.right,e.left,e.right)}function cn(t,e){if(nn(t))return e;if(nn(e))return t;const n=Math.min(t.left,e.left),o=Math.min(t.top,e.top),i=Math.max(t.right,e.right),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,o,i-n,r-o)}function ln(t){
|
|
71
|
+
return new DOMPoint((t.left+t.right)/2,(t.top+t.bottom)/2)}const hn=["p",".para"];let un;function dn(t,e=0,n=t.data.length){return un||(un=document.createRange()),un.setStart(t,e),un.setEnd(t,n),un.getBoundingClientRect()}function fn(t){const e=t.getBoundingClientRect();return e.x-=t.scrollLeft,e.y-=t.scrollTop,e.height=Math.max(e.height,t.scrollHeight),e.width=Math.max(e.width,t.scrollWidth),e}function*pn(t,e,n=(()=>!0)){let o=t.firstChild;for(;o;){if(o.nodeType===Node.ELEMENT_NODE){const t=o,i=rn(fn(t),e);n(t)&&i&&(yield*pn(t,e,n))}else if(o.nodeType===Node.TEXT_NODE){const t=o;rn(dn(t),e)&&(yield t)}o=o.nextSibling}}function gn(t,e){let n=null;const o=t=>!function(t){switch(getComputedStyle(t).position){case"fixed":case"sticky":return!0;default:return!1}}(t);t:for(let s of pn(t,e,o)){let t=0;for(let o of s.data.split(/\b/)){if(/\S/.test(o)){const a=t,c=t+o.length,l=dn(s,a,c);if(r=l,!nn(i=e)&&!nn(r)&&r.left>=i.left&&r.right<=i.right&&r.top>=i.top&&r.bottom<=i.bottom){n=document.createRange(),
|
|
72
|
+
n.setStart(s,a),n.setEnd(s,c);break t}}t+=o.length}}var i,r;return n}function mn(t,e=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const o=gn(e,n);if(!o)return t(),0;const i=o.getBoundingClientRect().top;t();const r=o.getBoundingClientRect().top-i;return e.scrollTop+=r,r}var _n="complete",vn="canceled";function yn(t,e,n){t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function wn(t){var e=t._scrollSettings;if(e){var n=e.maxSynchronousAlignments,o=function(t,e){var n,o,i,r,s,a,c,l=t.align,h=t.target.getBoundingClientRect(),u=l&&null!=l.left?l.left:.5,d=l&&null!=l.top?l.top:.5,f=l&&null!=l.leftOffset?l.leftOffset:0,p=l&&null!=l.topOffset?l.topOffset:0,g=u,m=d;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),c=Math.min(h.height,e.innerHeight),o=h.left+e.pageXOffset-e.innerWidth*g+a*g,i=h.top+e.pageYOffset-e.innerHeight*m+c*m,o-=f,i-=p,o=t.align.lockX?e.pageXOffset:o,i=t.align.lockY?e.pageYOffset:i,r=o-e.pageXOffset,s=i-e.pageYOffset;else{a=h.width,c=h.height,
|
|
73
|
+
n=e.getBoundingClientRect();var _=h.left-(n.left-e.scrollLeft),v=h.top-(n.top-e.scrollTop);o=_+a*g-e.clientWidth*g,i=v+c*m-e.clientHeight*m,o-=f,i-=p,o=Math.max(Math.min(o,e.scrollWidth-e.clientWidth),0),i=Math.max(Math.min(i,e.scrollHeight-e.clientHeight),0),o=t.align.lockX?e.scrollLeft:o,i=t.align.lockY?e.scrollTop:i,r=o-e.scrollLeft,s=i-e.scrollTop}return{x:o,y:i,differenceX:r,differenceY:s}}(e,t),i=Date.now()-e.startTime,r=Math.min(1/e.time*i,1);if(e.endIterations>=n)return yn(t,o.x,o.y),t._scrollSettings=null,e.end(_n);var s=1-e.ease(r);if(yn(t,o.x-o.differenceX*s,o.y-o.differenceY*s),i>=e.time)return e.endIterations++,e.scrollAncestor&&wn(e.scrollAncestor),void wn(t);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(wn.bind(null,t))}}function bn(t){return t.self===t}function Cn(t){return"pageXOffset"in t||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function xn(){return!0}function Sn(t){
|
|
74
|
+
if(t.assignedSlot)return Sn(t.assignedSlot);if(t.parentElement)return"BODY"===t.parentElement.tagName?t.parentElement.ownerDocument.defaultView||t.parentElement.ownerDocument.ownerWindow:t.parentElement;if(t.getRootNode){var e=t.getRootNode();if(11===e.nodeType)return e.host}}var En=function(t,e,n){if(t){"function"==typeof e&&(n=e,e=null),e||(e={}),e.time=isNaN(e.time)?1e3:e.time,e.ease=e.ease||function(t){return 1-Math.pow(1-t,t/2)},e.align=e.align||{};var o=Sn(t),i=1,r=e.validTarget||xn,s=e.isScrollable;e.debug&&(console.log("About to scroll to",t),o||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var a=[];o;)if(e.debug&&console.log("Scrolling parent node",o),r(o,i)&&(s?s(o,Cn):Cn(o))&&(i++,a.push(o)),!(o=Sn(o))){c(_n);break}return a.reduce(((n,o,i)=>function(t,e,n,o,i){var r,s=!e._scrollSettings,a=e._scrollSettings,c=Date.now(),l={passive:!0};function h(t){e._scrollSettings=null,e.parentElement&&e.parentElement._scrollSettings&&e.parentElement._scrollSettings.end(t),
|
|
75
|
+
n.debug&&console.log("Scrolling ended with type",t,"for",e),i(t),r&&(e.removeEventListener("touchstart",r,l),e.removeEventListener("wheel",r,l))}a&&a.end(vn);var u=n.maxSynchronousAlignments;return null==u&&(u=3),e._scrollSettings={startTime:c,endIterations:0,target:t,time:n.time,ease:n.ease,align:n.align,isWindow:n.isWindow||bn,maxSynchronousAlignments:u,end:h,scrollAncestor:o},"cancellable"in n&&!n.cancellable||(r=h.bind(null,vn),e.addEventListener("touchstart",r,l),e.addEventListener("wheel",r,l)),s&&wn(e),r}(t,o,e,a[i+1],c)),null)}function c(t){--i||n&&n(t)}};function Tn(t,e,n){return t+n*(e-t)}async function An(t,e,{maxDuration:n=500}={}){const o=t.scrollTop,i=e,r=Date.now(),s=Math.min(Math.abs(i-o)/3,n);let a=0;for(;a<1;)await new Promise((t=>{requestAnimationFrame(t)})),a=Math.min(1,(Date.now()-r)/s),t.scrollTop=Tn(o,i,a)}class kn{constructor({features:t,container:e=document.body}){this.features=t,this.container=e,this.anchor=Je,this.describe=Qe,this._htmlMeta=new en,
|
|
76
|
+
this._sideBySideEnabled=this.features.flagEnabled("html_side_by_side"),this._sideBySideActive=!1,this._lastLayout=null,this._flagsChanged=()=>{const e=t.flagEnabled("html_side_by_side");e!==this._sideBySideEnabled&&(this._sideBySideEnabled=e,this._lastLayout&&this.fitSideBySide(this._lastLayout))},this.features.on("flagsChanged",this._flagsChanged)}canAnnotate(){return!0}destroy(){this.features.off("flagsChanged",this._flagsChanged)}contentContainer(){return this.container}fitSideBySide(t){this._lastLayout=t;const e=window.innerWidth-t.width,n=this._sideBySideEnabled&&t.expanded&&e>=480;return n?this._activateSideBySide(t.width):this._sideBySideActive&&this._deactivateSideBySide(),this._sideBySideActive=n,n}_activateSideBySide(t){const e=t+12,n=t=>parseInt(window.getComputedStyle(t).marginLeft,10);mn((()=>{document.body.style.marginLeft="",document.body.style.marginRight="";const t=n(document.body);document.body.style.marginRight=`${e}px`;const o=function(t){
|
|
77
|
+
const e=new Map,n=new Map,o=hn.join(","),i=Array.from(t.querySelectorAll(o)).map((t=>({rect:t.getBoundingClientRect(),textLength:t.textContent.length}))).filter((({rect:t})=>t.width>0&&t.height>0)).sort(((t,e)=>e.textLength-t.textLength)).slice(0,15);if(i.forEach((({rect:t})=>{var o,i;let r=null!==(o=e.get(t.left))&&void 0!==o?o:0;r+=1,e.set(t.left,r);let s=null!==(i=n.get(t.right))&&void 0!==i?i:0;s+=1,n.set(t.right,s)})),0===e.size||0===n.size)return null;const r=[...e.entries()].sort(((t,e)=>e[1]-t[1])),s=[...n.entries()].sort(((t,e)=>e[1]-t[1])),[a]=r[0],[c]=s[0];return{left:a,right:c}}(document.body);if(o){const i=Math.max(0,window.innerWidth-e-o.right);if(i>0){const t=Math.max(0,e-i);document.body.style.marginRight=`${t}px`}n(document.body)>t&&(document.body.style.marginLeft=`${t}px`),o.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){mn((()=>{document.body.style.marginLeft="",
|
|
78
|
+
document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(t){var e;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];n&&await async function(t,{maxDuration:e=500}={}){const n=t.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{value:"BODY",configurable:!0}),await new Promise((n=>En(t,{time:e},n)))}(n)}}var Rn=/^\s+|\s+$/g,Ln=/^[-+]0x[0-9a-f]+$/i,Pn=/^0b[01]+$/i,Mn=/^0o[0-7]+$/i,Nn=parseInt,On="object"==typeof t&&t&&t.Object===Object&&t,In="object"==typeof self&&self&&self.Object===Object&&self,Dn=On||In||Function("return this")(),Bn=Object.prototype.toString,Fn=Math.max,Hn=Math.min,Vn=function(){return Dn.Date.now()};function qn(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Un(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Bn.call(t)}(t))return NaN;if(qn(t)){
|
|
79
|
+
var e="function"==typeof t.valueOf?t.valueOf():t;t=qn(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Rn,"");var n=Pn.test(t);return n||Mn.test(t)?Nn(t.slice(2),n?2:8):Ln.test(t)?NaN:+t}var Wn=function(t,e,n){var o,i,r,s,a,c,l=0,h=!1,u=!1,d=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var n=o,r=i;return o=i=void 0,l=e,s=t.apply(r,n)}function p(t){return l=t,a=setTimeout(m,e),h?f(t):s}function g(t){var n=t-c;return void 0===c||n>=e||n<0||u&&t-l>=r}function m(){var t=Vn();if(g(t))return _(t);a=setTimeout(m,function(t){var n=e-(t-c);return u?Hn(n,r-(t-l)):n}(t))}function _(t){return a=void 0,d&&o?f(t):(o=i=void 0,s)}function v(){var t=Vn(),n=g(t);if(o=arguments,i=this,c=t,n){if(void 0===a)return p(c);if(u)return a=setTimeout(m,e),f(c)}return void 0===a&&(a=setTimeout(m,e)),s}return e=Un(e)||0,qn(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Fn(Un(n.maxWait)||0,e):r,d="trailing"in n?!!n.trailing:d),v.cancel=function(){void 0!==a&&clearTimeout(a),l=0,o=c=i=a=void 0},
|
|
80
|
+
v.flush=function(){return void 0===a?s:_(Vn())},v};function zn(t,e,n,o=0){let i=o;for(;i<t.length&&e>0;)n(t[i])&&--e,++i;return i}function $n(t,e,n,o){let i=0;for(let r=n;r<o;r++)e(t[r])&&++i;return i}function jn(t,e,n,o,i){const r=$n(t,i,0,n),s=$n(t,i,n,o);let a=zn(e,r,i);for(;a<e.length&&!i(e[a]);)++a;return[a,zn(e,s,i,a)]}const Xn=0,Yn=3,Gn=new Map,Zn=new Map;function Kn(t,e){return`${t}:${e}`}function Jn(t){var e;const n="closest"in t?t:t.parentElement;return null!==(e=null==n?void 0:n.closest(".textLayer"))&&void 0!==e?e:null}function Qn(){return PDFViewerApplication.pdfViewer}async function to(t){const e=Qn();let n=e.getPageView(t);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{e.eventBus?e.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(e.getPageView(t))};e.eventBus?e.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function eo(t){const e=Gn.get(t);if(e)return e;const n=(async()=>{const e=await to(t)
|
|
81
|
+
;return(await e.pdfPage.getTextContent({normalizeWhitespace:!0})).items.map((t=>t.str)).join("")})();return Gn.set(t,n),n}async function no(t){const e=Qn();let n=0,o=0,i="";for(let r=0;r<e.pagesCount;r++)if(i=await eo(r),n=o,o+=i.length,o>=t)return{index:r,offset:n,text:i};return{index:e.pagesCount-1,offset:n,text:i}}function oo(t){switch(t){case" ":case"\f":case"\n":case"\r":case"\t":case"\v":case" ":return!0;default:return!1}}const io=t=>!oo(t);async function ro(t,e,n){const[o,i]=await Promise.all([to(t),eo(t)]);if(o.renderingState===Yn&&o.textLayer&&o.textLayer.renderingDone){const t=o.textLayer.textLayerDiv,r=t.textContent,[s,a]=jn(i,r,e,n,io);so(r.slice(s,a))!==so(i.slice(e,n))&&Ne("Text layer text does not match page text. Highlights will be mis-aligned.");const c=new _e(t,s),l=new _e(t,a);return new ve(c,l).toRange()}const r=function(t){let e=t.querySelector(ye);return e||(e=document.createElement("span"),e.classList.add("annotator-placeholder"),e.textContent="Loading annotations...",t.appendChild(e),
|
|
82
|
+
e)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function so(t){let e="";for(let n=0;n<t.length;n++){const o=t[n];oo(o)||(e+=o)}return e}async function ao(t,e){const n=e.find((t=>"TextQuoteSelector"===t.type));if(!n)throw new Error("No quote selector found");const o=e.find((t=>"TextPositionSelector"===t.type));if(o){try{const{index:t,offset:e,text:i}=await no(o.start),r=o.start-e,s=o.end-e,a=i.substring(r,s);if(n.exact!==a)throw new Error("quote mismatch");return await ro(t,r,s)}catch{}try{const t=Kn(n.exact,o.start),e=Zn.get(t);if(e){const{pageIndex:t,anchor:n}=e;return await ro(t,n.start,n.end)}}catch{}}return async function(t,e){const n=Qn().pagesCount,o=Array(n).fill(0).map(((t,e)=>e));let i,r;if(e){const{index:t,offset:n}=await no(e);i=t,r=e-n,o.sort(((e,n)=>Math.abs(e-t)-Math.abs(n-t)))}const s=void 0!==t.prefix?so(t.prefix):void 0,a=void 0!==t.suffix?so(t.suffix):void 0,c=so(t.exact);let l;for(let t of o){const e=await eo(t),n=so(e);let o
|
|
83
|
+
;void 0!==i&&void 0!==r&&(t<i?o=n.length:t===i?[o]=jn(e,n,r,r,io):o=0);const h=We(n,c,{prefix:s,suffix:a,hint:o});if(h&&(!l||h.score>l.match.score)){const[o,i]=jn(n,e,h.start,h.end,io);l={page:t,match:{start:o,end:i,score:h.score}};const r=n.slice(h.start,h.end)===c,u=void 0!==s&&n.slice(Math.max(0,h.start-s.length),h.start)===s,d=void 0!==a&&n.slice(h.end,a.length)===a,f=void 0!==s||void 0!==a;if(r&&(u||d||!f))break}}if(l){const{page:n,match:o}=l;if(e){const i=Kn(t.exact,e);Zn.set(i,{pageIndex:n,anchor:o})}return ro(n,o.start,o.end)}throw new Error("Quote not found")}(n,null==o?void 0:o.start)}function co(t){try{t=ve.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}const e=Jn(t.startContainer),n=Jn(t.endContainer);if(!e||!n)throw new Error("Selection is outside page text");if(e!==n)throw new Error("Selecting across page breaks is not supported");return[t,e]}async function lo(t,e){
|
|
84
|
+
const[n,o]=co(e),i=_e.fromPoint(n.startContainer,n.startOffset).relativeTo(o),r=_e.fromPoint(n.endContainer,n.endOffset).relativeTo(o),s=function(t){let e=0;for(;t.previousSibling;)++e,t=t.previousSibling;return e}(o.parentNode),a=await async function(t){if(t>=Qn().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await eo(n)).length;return e}(s);return[{type:"TextPositionSelector",start:a+i.offset,end:a+r.offset},Ze.fromRange(t,n).toSelector()]}function ho({children:t}){return _t("div",{className:"flex flex-col",children:t})}function uo({provider:t,onClose:e}){return _t("div",{className:"flex items-center border-b gap-x-4 px-2 py-1 bg-white text-annotator-lg",children:["jstor"===t&&_t(f,{children:[_t(At,{href:"https://jstor.org",target:"_blank",children:_t(Tt,{classes:"w-[97px] h-[25px]",name:"jstor",title:"Document hosted by JSTOR"})}),_t("div",{className:"grow",children:["Document hosted by ",_t("b",{children:"JSTOR"})]})]}),_t("div",{className:"text-annotator-base",
|
|
85
|
+
children:_t(St,{onClick:e,"data-testid":"close-button",children:"Close"})})]})}function fo(){return _t("div",{className:"bg-white",children:_t("div",{className:K("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[_t("div",{className:"bg-yellow-notice text-white p-2",children:_t(Tt,{name:"caution",classes:"text-annotator-xl"})}),_t("div",{children:[_t("strong",{children:"This PDF does not contain selectable text:"})," ",_t(At,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})})}class po{constructor(t){this._loaded=function(t){return t.initializedPromise?t.initializedPromise:t.initialized?Promise.resolve():new Promise((e=>{const n=setInterval((()=>{t.initialized&&(clearTimeout(n),e())}),5)}))}(t).then((()=>t.downloadComplete?t:new Promise((e=>{const n=()=>{t.eventBus?(t.eventBus.off("documentload",n),
|
|
86
|
+
t.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),e(t)};t.eventBus?(t.eventBus.on("documentloaded",n),t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))))}getUri(){return this._loaded.then((t=>{let e=_o(t);return e||(e=mo(go(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:o}=await t.pdfDocument.getMetadata(),i=go(t),r=_o(t);let s;s=null!=o&&o.has("dc:title")&&"Untitled"!==o.get("dc:title")?o.get("dc:title"):null!=e&&e.Title?e.Title:n||(r?function(t){const e=new URL(t).pathname.split("/");return e[e.length-1]}(r):"");const a=[{href:mo(i)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:i}}}function go(t){return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function mo(t){return`urn:x-pdf:${t}`}function _o(t){if(!t.url)return null;const e=tn(t.url);return 0!==e.indexOf("file://")?e:null}function vo(t){var e
|
|
87
|
+
;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];return n&&we(n)}function yo(t){return new Promise((e=>setTimeout(e,t)))}class wo{constructor(t,e={}){var n,o,i,r;this.annotator=t;const s=window,a=s.PDFViewerApplication;this.pdfViewer=a.pdfViewer,this.pdfViewer.viewer.classList.add("has-transparent-text-layer"),this.pdfContainer=null!==(n=null===(o=a.appConfig)||void 0===o?void 0:o.appContainer)&&void 0!==n?n:document.body,this.pdfMetadata=new po(a),this.observer=new MutationObserver(Wn((()=>this._update()),100)),this.observer.observe(this.pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=null!==(i=e.reanchoringMaxWait)&&void 0!==i?i:3e3,this._banner=null,this._bannerState={contentPartner:null!==(r=e.contentPartner)&&void 0!==r?r:null,noTextWarning:!1},this._updateBannerState(this._bannerState),this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=s.getSelection()
|
|
88
|
+
;this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Rt,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1}destroy(){var t;this._listeners.removeAll(),this.pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this.observer.disconnect(),null===(t=this._banner)||void 0===t||t.remove(),this._destroyed=!0}uri(){return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}anchor(t,e){return ao(0,e)}canAnnotate(t){return function(t){try{return co(t),!0}catch{return!1}}(t)}describe(t,e){return lo(t,e)}async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=Qn();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await eo(n)).trim().length>0){e=!0;break}return e}();this._updateBannerState({noTextWarning:!t})}catch(t){console.warn("Unable to check for text in PDF:",t)}}_updateBannerState(t){this._bannerState={
|
|
89
|
+
...this._bannerState,...t};const e=document.querySelector("#outerContainer");var n;if(!(this._bannerState.contentPartner||this._bannerState.noTextWarning))return null===(n=this._banner)||void 0===n||n.remove(),this._banner=null,void(e.style.height="");this._banner||(this._banner=document.createElement("hypothesis-banner"),document.body.prepend(this._banner),ue(this._banner)),M(_t(ho,{children:[this._bannerState.contentPartner&&_t(uo,{provider:this._bannerState.contentPartner,onClose:()=>this._updateBannerState({contentPartner:null})}),this._bannerState.noTextWarning&&_t(fo,{})]}),this._banner.shadowRoot);const o=this._banner.getBoundingClientRect().height;e.style.height=`calc(100% - ${o}px)`}_update(){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 Xn:e.textLayer=null;break;case Yn:o=e.div,i=void 0,null===(i=o.querySelector(ye))||void 0===i||i.remove()}}var o,i
|
|
90
|
+
;for(let e of this.annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const o=e.highlights[n];if(!document.body.contains(o)){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,o=n?t.width:t.toolbarWidth;this.pdfContainer.style.width=`calc(100% - ${o}px)`;const i=this.pdfViewer.currentScaleValue;return"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(this.pdfViewer.currentScaleValue=i),this.pdfViewer.update(),n}async scrollToAnchor(t){const e=t.annotation,n=vo(t),o=this._anchorOffset(t);if(null!==o&&(await An(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await An(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n
|
|
91
|
+
;const o=Date.now();let i;do{i=this.annotator.anchors.find((e=>e.annotation===t)),i&&!vo(i)||(i=null,await yo(20))}while(!i&&Date.now()-o<e);return null!==(n=i)&&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())}}class bo{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Wn((()=>{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 Co(t),this._isDisconnected)return;t.contentWindow.addEventListener("unload",(()=>{this._removeFrame(t)})),this._onFrameAdded(t)}catch(e){
|
|
92
|
+
console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${t.src}')`)}}_removeFrame(t){this._annotatableFrames.delete(t),this._onFrameRemoved(t)}_discoverFrames(){const t=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(let e of t)this._annotatableFrames.has(e)||this._addFrame(e);for(let e of this._annotatableFrames)t.has(e)||this._removeFrame(e)}}function Co(t){return new Promise(((e,n)=>{const o=xo(t,((t,i)=>{o(),i?e(i):n(t)}))}))}function xo(t,e,{pollInterval:n=10}={}){let o,i;const r=new WeakSet,s=()=>{clearTimeout(o),o=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 o
|
|
93
|
+
;t.contentDocument&&(null===(o=t.contentWindow)||void 0===o||o.addEventListener("unload",i))}}else e(new Error("Frame is cross-origin"))};let c=!1;i=()=>{s(),c||(o=setInterval(a,n))},t.addEventListener("load",a);const l=setTimeout(a,0);return()=>{c=!0,clearTimeout(l),s(),t.removeEventListener("load",a)}}class So{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length");const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.color="transparent",i.style.textAlign="left",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font="16px sans-serif";const a=(t,e,n="px")=>`calc(var(--${t}-scale) * ${e}${n})`,c=function(t,e){const n=[];let o={text:"",rect:new DOMRect};const i=()=>{o.text.length>0&&(n.push(o),o={text:"",
|
|
94
|
+
rect:new DOMRect})};for(let[n,r]of t.entries()){const t=e[n],s=/\s/.test(t);o.rect=cn(o.rect,r),o.text+=s?" ":t,s&&i()}i();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(let t of n){const e=s.words[s.words.length-1];if(e){const n=ln(e.rect),o=ln(t.rect).x-n.x;(!sn(e.rect,t.rect)||o<0)&&a()}s.words.push(t),s.rect=cn(s.rect,t.rect)}a();const c=[];let l={lines:[],rect:new DOMRect};const h=()=>{l.lines.length>0&&(c.push(l),l={lines:[],rect:new DOMRect})};for(let t of r){const e=l.lines[l.lines.length-1];if(e){const n=ln(e.rect),o=ln(t.rect).y-n.y;(!an(e.rect,t.rect)||sn(e.rect,t.rect)||o<0||o>4*t.rect.height)&&h()}l.lines.push(t),l.rect=cn(l.rect,t.rect)}return h(),c}(e,n);for(let t of c){const e=document.createElement("hypothesis-text-column");e.style.display="block",e.style.position="absolute",e.style.left=a("x",t.rect.left),e.style.top=a("y",t.rect.top);let n=null;for(let o of t.lines){
|
|
95
|
+
const i=document.createElement("hypothesis-text-line");i.style.display="block",i.style.marginLeft=a("x",o.rect.left-t.rect.left),i.style.height=a("y",o.rect.height),n&&(i.style.marginTop=a("y",o.rect.top-n.rect.bottom)),n=o,i.style.whiteSpace="nowrap";let r=null;for(let t of o.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=a("x",t.rect.left-r.rect.right)),r=t,e.style.width=a("x",t.rect.width),e.style.height=a("y",t.rect.height),e.style.whiteSpace="pre";const n=s.measureText(t.text),o=a("x",t.rect.width/n.width,""),c=a("y",t.rect.height/16,"");e.style.transform=`scale(${o}, ${c})`,i.append(e)}e.append(i)}i.append(e)}const l=()=>{const{width:e,height:n}=t.getBoundingClientRect();i.style.width=e+"px",i.style.height=n+"px",i.style.setProperty("--x-scale",`${e}`),i.style.setProperty("--y-scale",`${n}`)};l(),this.container=i,this._updateTextLayerSize=Wn(l,{maxWait:50}),this._listeners=new Rt,
|
|
96
|
+
"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(t)),this._listeners.add(window,"resize",this._updateTextLayerSize)}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()}}class Eo{constructor(t,e){this._config=e,this._frameObserver=new bo(t,(t=>To(t,e)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function To(t,e){if(null!==t.contentDocument.querySelector("script.js-hypothesis-config"))return;await Co(t);const{assetRoot:n,notebookAppUrl:o,sidebarAppUrl:i}=Gt(document),r={...e,assetRoot:n,notebookAppUrl:o,sidebarAppUrl:i,subFrameIdentifier:Pt(10)},s=document.createElement("script");s.className="js-hypothesis-config",s.type="application/json",s.innerText=JSON.stringify(r);const a=document.createElement("script")
|
|
97
|
+
;a.async=!0,a.src=e.clientUrl;const c=t.contentDocument;c.body.appendChild(s),c.body.appendChild(a)}function Ao(t=document){return t.querySelector("mosaic-book")}function ko(t=window){var e;if(Ao(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&Ao(n)?"content":null}class Ro{constructor(t){const e=Ao();if(!e)throw new Error("Book container element not found");const n=new WeakSet,o=e.shadowRoot,i=()=>{const e=o.querySelector("iframe");e&&!n.has(e)&&(n.add(e),xo(e,((n,o)=>{const i=null==o?void 0:o.body;i&&!i.querySelector("#page-content")&&To(e,t)})))};i(),this._frameObserver=new MutationObserver(i),this._frameObserver.observe(o,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function Lo(){return document.querySelector("img#pbk-page")}class Po{constructor(t=document.body){const e=new Ie;e.update({html_side_by_side:!0}),this._htmlIntegration=new kn({container:t,features:e}),this._listeners=new Rt
|
|
98
|
+
;const n=["mouseup","mousedown","mouseout"];for(let t of n)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const o=window.frameElement;o&&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})}(o);const i=Lo(),r=window.innerPageData;if(i&&r){const t=r.glyphs.glyphs.map((t=>{const e=t.l/100,n=t.r/100,o=t.t/100,i=t.b/100;return new DOMRect(e,o,n-e,i-o)}));this._textLayer=new So(i,t,r.words),this._textLayer.container.style.zIndex="100"}}canAnnotate(){return!0}destroy(){var t;null===(t=this._textLayer)||void 0===t||t.destroy(),this._listeners.removeAll(),this._htmlIntegration.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}describe(t,e){return this._htmlIntegration.describe(t,e)}contentContainer(){
|
|
99
|
+
return this._htmlIntegration.contentContainer()}fitSideBySide(t){const e=Lo();if(e&&this._textLayer){const n=e.parentElement,o=this._textLayer,i=window.innerWidth-t.width;return mn((()=>{t.expanded&&i>480?(n.style.textAlign="left",e.style.width=`${i}px`):(n.style.textAlign="",e.style.width=""),o.updateSync()})),t.expanded}return this._htmlIntegration.fitSideBySide(t)}async getMetadata(){return{title:document.title,link:[]}}async uri(){const t=new URL(document.location.href);return t.search="",t.toString()}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function Mo(t,{contentPartner:e}={}){if("undefined"!=typeof PDFViewerApplication)return new wo(t,{contentPartner:e});return"content"===ko()?new Po:new kn({features:t.features})}function No(t){const e=t.getSelection();if(!e||0===e.rangeCount)return null;const n=e.getRangeAt(0);return n.collapsed?null:n}class Oo{constructor(t,e=document){let n=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(No(e))
|
|
100
|
+
}),n)},i=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;o(e)};this._document=e,this._listeners=new Rt,this._listeners.add(e,"selectionchange",i),this._listeners.add(e.body,"mousedown",i),this._listeners.add(e.body,"mouseup",i),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function Io(){const t=function(t,e){const n=new Set,o=new Set;return xe(t,(t=>{let i=t;for(;i&&!n.has(i);){n.add(i);const t=e(i);null!=t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>{var e;return null===(e=t._annotation)||void 0===e?void 0:e.$tag}));return t}function Do(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
|
|
101
|
+
}(t).map((t=>t._annotation)).filter((t=>void 0!==t)).map((t=>null==t?void 0:t.$tag));return e}function Bo(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function Fo(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class Ho{constructor(t,e={},n=window){this.element=t,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._adder=new fe(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0}),onShowAnnotations:t=>this.selectAnnotations(t)}),this._selectionObserver=new Oo((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new Ot({hostFrame:this._hostFrame,source:"guest"}),this.features=new Ie,this._integration=Mo(this,{contentPartner:e.contentPartner}),this._hostRPC=new Xt,this._connectHost(n),this._sidebarRPC=new Xt,
|
|
102
|
+
this._connectSidebar(),this._bucketBarClient=new Pe({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._sideBySideActive=!1,this._listeners=new Rt,this._setupElementEvents(),this._focusedAnnotations=new Set}_setupElementEvents(){const t=t=>{this._sideBySideActive||Do(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:o}=t,i=Do(e);if(i.length&&this._highlightsVisible){const t=n||o;this.selectAnnotations(i,t)}})),this._listeners.add(this.element,"mousedown",(({target:e})=>{t(e)})),this._listeners.add(this.element,"touchstart",(({target:e})=>{t(e)})),this._listeners.add(this.element,"mouseover",(({target:t})=>{const e=Do(t);e.length&&this._highlightsVisible&&this._sidebarRPC.call("focusAnnotations",e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("focusAnnotations",[])})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}
|
|
103
|
+
async getDocumentInfo(){const[t,e]=await Promise.all([this._integration.uri(),this._integration.getMetadata()]);return{uri:tn(t),metadata:e,frameIdentifier:this._frameIdentifier}}_repositionAdder(){var t;if(!1===this._isAdderVisible)return;const e=null===(t=window.getSelection())||void 0===t?void 0:t.getRangeAt(0);e&&this._onSelection(e)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{No(document)&&(this._informHostOnNextSelectionClear=!1,Fo())})),this._hostRPC.on("createAnnotation",(()=>this.createAnnotation())),this._hostRPC.on("focusAnnotations",(t=>this._focusAnnotations(t))),this._hostRPC.on("scrollToClosestOffScreenAnchor",((t,e)=>this._scrollToClosestOffScreenAnchor(t,e))),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,e))),this._hostRPC.on("sidebarLayoutChanged",(e=>{var n,o;((n=window)===(o=t)||n.parent===o&&n.frameElement&&n.frameElement.getBoundingClientRect().width/n.parent.innerWidth>=.8)&&this.fitSideBySide(e)}))
|
|
104
|
+
;const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("focusAnnotations",(t=>this._focusAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=Bo(e);if(!n)return;const o=new CustomEvent("scrolltorange",{bubbles:!0,cancelable:!0,detail:n});this.element.dispatchEvent(o)&&this._integration.scrollToAnchor(e)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t))))),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this.getDocumentInfo().then((t=>this._sidebarRPC.call("documentInfoChanged",t)))}destroy(){this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),
|
|
105
|
+
this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),function(t){ke(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){const e=t=>{const e=Bo(t);if(!e)return;const n=Te(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&Re(n,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const o=await this._integration.anchor(this.element,e.selector),i=ve.fromRange(o);n={annotation:t,target:e,range:i}}catch(o){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(let 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),
|
|
106
|
+
this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(let e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&ke(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(e.map((t=>this._integration.describe(o,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:t,$tag:"a:"+Pt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Fo(),r}_focusAnnotations(t){this._focusedAnnotations.clear(),t.forEach((t=>this._focusedAnnotations.add(t)));for(let e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);Re(e.highlights,n)}this._sidebarRPC.call("focusAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,o=0
|
|
107
|
+
;for(let r of t){var i;if(null===(i=r.highlights)||void 0===i||!i.length)continue;const t=Le(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>o||"down"===e&&t<o)&&(n=r,o=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=be(e),o=Se(e);o?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Io(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,e=!1){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t),this._sidebarRPC.call("openSidebar")}
|
|
108
|
+
setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Vo(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function qo(t,e){var n;const o={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(o[t]=n);o.origin=new URL(t).origin,o.version="1.1070.0";const i=new URL(window.location.href);if(i.hash="",o.hostURL=i.toString(),Array.isArray(o.services)&&(null===(n=o.services)||void 0===n?void 0:n.length)>0){const t=o.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),
|
|
109
|
+
t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return o}function Uo({config:t,groupId:e}){return _t("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:Vo(t.notebookAppUrl,{...qo(t.notebookAppUrl,t),group:e})})}function Wo({eventBus:t,config:e}){const[n,o]=st(0),[i,r]=st(!0),[s,a]=st(null),c=lt(""),l=lt(null);at((()=>(c.current=document.body.style.overflow,()=>{document.body.style.overflow=c.current})),[]),at((()=>{document.body.style.overflow=i?c.current:"hidden"}),[i]),at((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),l.current=e,()=>{e.destroy()}}),[t]);return null===s?null:_t("div",{className:K("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:i}),"data-testid":"notebook-outer",children:_t("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[_t("div",{className:"absolute right-0 text-xl m-3",children:_t(xt,{icon:"cancel",title:"Close the Notebook",
|
|
110
|
+
onClick:()=>{var t;r(!0),null===(t=l.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),_t(Uo,{config:e,groupId:s},n)]})})}class zo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=ue(this._outerContainer),M(_t(Wo,{eventBus:e,config:n}),this.shadowRoot)}destroy(){M(null,this.shadowRoot),this._outerContainer.remove()}}var $o={exports:{}};!function(t){!function(e,n,o,i){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),c=Math.round,l=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var o;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==i)for(o=0;o<t.length;)e.call(n,t[o],o,t),o++;else for(o in t)t.hasOwnProperty(o)&&e.call(n,t[o],o,t)}function p(t,n,o){var i="DEPRECATED METHOD: "+n+"\n"+o+" AT \n";return function(){
|
|
111
|
+
var n=new Error("get-stack-trace"),o=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,i,o),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===i||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var o=arguments[n];if(o!==i&&null!==o)for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])}return e}:Object.assign;var g=p((function(t,e,n){for(var o=Object.keys(e),r=0;r<o.length;)(!n||n&&t[o[r]]===i)&&(t[o[r]]=e[o[r]]),r++;return t}),"extend","Use `assign`."),m=p((function(t,e){return g(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var o,i=e.prototype;(o=t.prototype=Object.create(i)).constructor=t,o._super=i,n&&r(o,n)}function v(t,e){return function(){return t.apply(e,arguments)}}function y(t,e){
|
|
112
|
+
return"function"==typeof t?t.apply(e&&e[0]||i,e):t}function w(t,e){return t===i?e:t}function b(t,e,n){f(E(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(E(e),(function(e){t.removeEventListener(e,n,!1)}))}function x(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function E(t){return t.trim().split(/\s+/g)}function T(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var o=0;o<t.length;){if(n&&t[o][n]==e||!n&&t[o]===e)return o;o++}return-1}function A(t){return Array.prototype.slice.call(t,0)}function k(t,e,n){for(var o=[],i=[],r=0;r<t.length;){var s=e?t[r][e]:t[r];T(i,s)<0&&o.push(t[r]),i[r]=s,r++}return n&&(o=e?o.sort((function(t,n){return t[e]>n[e]})):o.sort()),o}function R(t,e){for(var n,o,r=e[0].toUpperCase()+e.slice(1),a=0;a<s.length;){if((o=(n=s[a])?n+r:e)in t)return o;a++}return i}var L=1;function P(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
|
|
113
|
+
var M="ontouchstart"in e,N=R(e,"PointerEvent")!==i,O=M&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",D="mouse",B=24,F=["x","y"],H=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function q(t,e,n){var o=n.pointers.length,r=n.changedPointers.length,s=1&e&&o-r==0,a=12&e&&o-r==0;n.isFirst=!!s,n.isFinal=!!a,s&&(t.session={}),n.eventType=e,function(t,e){var n=t.session,o=e.pointers,r=o.length;n.firstInput||(n.firstInput=U(e));r>1&&!n.firstMultiple?n.firstMultiple=U(e):1===r&&(n.firstMultiple=!1);var s=n.firstInput,a=n.firstMultiple,c=a?a.center:s.center,u=e.center=W(o);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(c,u),e.distance=j(c,u),function(t,e){var n=e.center,o=t.offsetDelta||{},i=t.prevDelta||{},r=t.prevInput||{};1!==e.eventType&&4!==r.eventType||(i=t.prevDelta={x:r.deltaX||0,y:r.deltaY||0},
|
|
114
|
+
o=t.offsetDelta={x:n.x,y:n.y});e.deltaX=i.x+(n.x-o.x),e.deltaY=i.y+(n.y-o.y)}(n,e),e.offsetDirection=$(e.deltaX,e.deltaY);var d=z(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=l(d.x)>l(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=o,j(p[0],p[1],H)/j(f[0],f[1],H)):1,e.rotation=a?function(t,e){return X(e[1],e[0],H)+X(t[1],t[0],H)}(a.pointers,o):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,o,r,s,a=t.lastInterval||e,c=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(c>25||a.velocity===i)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=z(c,h,u);o=d.x,r=d.y,n=l(d.x)>l(d.y)?d.x:d.y,s=$(h,u),t.lastInterval=e}else n=a.velocity,o=a.velocityX,r=a.velocityY,s=a.direction;e.velocity=n,e.velocityX=o,e.velocityY=r,e.direction=s}(n,e);var f,p;var g=t.element;x(e.srcEvent.target,g)&&(g=e.srcEvent.target);e.target=g}(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}
|
|
115
|
+
function U(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:h(),pointers:e,center:W(e),deltaX:t.deltaX,deltaY:t.deltaY}}function W(t){var e=t.length;if(1===e)return{x:c(t[0].clientX),y:c(t[0].clientY)};for(var n=0,o=0,i=0;i<e;)n+=t[i].clientX,o+=t[i].clientY,i++;return{x:c(n/e),y:c(o/e)}}function z(t,e,n){return{x:e/t||0,y:n/t||0}}function $(t,e){return t===e?1:l(t)>=l(e)?t<0?2:4:e<0?8:16}function j(t,e,n){n||(n=F);var o=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return Math.sqrt(o*o+i*i)}function X(t,e,n){n||(n=F);var o=e[n[0]]-t[n[0]],i=e[n[1]]-t[n[1]];return 180*Math.atan2(i,o)/Math.PI}V.prototype={handler:function(){},init:function(){this.evEl&&b(this.element,this.evEl,this.domHandler),this.evTarget&&b(this.target,this.evTarget,this.domHandler),this.evWin&&b(P(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),
|
|
116
|
+
this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(P(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},G="mousedown",Z="mousemove mouseup";function K(){this.evEl=G,this.evWin=Z,this.pressed=!1,V.apply(this,arguments)}_(K,V,{handler:function(t){var e=Y[t.type];1&e&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=4),this.pressed&&(4&e&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:D,srcEvent:t}))}});var J={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},Q={2:I,3:"pen",4:D,5:"kinect"},tt="pointerdown",et="pointermove pointerup pointercancel";function nt(){this.evEl=tt,this.evWin=et,V.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(tt="MSPointerDown",et="MSPointerMove MSPointerUp MSPointerCancel"),_(nt,V,{handler:function(t){
|
|
117
117
|
var e=this.store,n=!1,o=t.type.toLowerCase().replace("ms",""),i=J[o],r=Q[t.pointerType]||t.pointerType,s=r==I,a=T(e,t.pointerId,"pointerId");1&i&&(0===t.button||s)?a<0&&(e.push(t),a=e.length-1):12&i&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,i,{pointers:e,changedPointers:[t],pointerType:r,srcEvent:t}),n&&e.splice(a,1))}});var ot={touchstart:1,touchmove:2,touchend:4,touchcancel:8},it="touchstart",rt="touchstart touchmove touchend touchcancel";function st(){this.evTarget=it,this.evWin=rt,this.started=!1,V.apply(this,arguments)}function at(t,e){var n=A(t.touches),o=A(t.changedTouches);return 12&e&&(n=k(n.concat(o),"identifier",!0)),[n,o]}_(st,V,{handler:function(t){var e=ot[t.type];if(1===e&&(this.started=!0),this.started){var n=at.call(this,t,e);12&e&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}}});var ct={touchstart:1,touchmove:2,touchend:4,touchcancel:8},lt="touchstart touchmove touchend touchcancel"
|
|
118
118
|
;function ht(){this.evTarget=lt,this.targetIds={},V.apply(this,arguments)}function ut(t,e){var n=A(t.touches),o=this.targetIds;if(3&e&&1===n.length)return o[n[0].identifier]=!0,[n,n];var i,r,s=A(t.changedTouches),a=[],c=this.target;if(r=n.filter((function(t){return x(t.target,c)})),1===e)for(i=0;i<r.length;)o[r[i].identifier]=!0,i++;for(i=0;i<s.length;)o[s[i].identifier]&&a.push(s[i]),12&e&&delete o[s[i].identifier],i++;return a.length?[k(r.concat(a),"identifier",!0),a]:void 0}_(ht,V,{handler:function(t){var e=ct[t.type],n=ut.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}});function dt(){V.apply(this,arguments);var t=v(this.handler,this);this.touch=new ht(this.manager,t),this.mouse=new K(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ft(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,pt.call(this,e)):12&t&&pt.call(this,e)}function pt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={
|
|
119
119
|
x:e.clientX,y:e.clientY};this.lastTouches.push(n);var o=this.lastTouches;setTimeout((function(){var t=o.indexOf(n);t>-1&&o.splice(t,1)}),2500)}}function gt(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,o=0;o<this.lastTouches.length;o++){var i=this.lastTouches[o],r=Math.abs(e-i.x),s=Math.abs(n-i.y);if(r<=25&&s<=25)return!0}return!1}_(dt,V,{handler:function(t,e,n){var o=n.pointerType==I,i=n.pointerType==D;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(o)ft.call(this,e,n);else if(i&>.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var mt=R(a.style,"touchAction"),_t=mt!==i,vt="compute",yt="auto",wt="manipulation",bt="none",Ct="pan-x",xt="pan-y",St=function(){if(!_t)return!1;var t={},n=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(o){t[o]=!n||e.CSS.supports("touch-action",o)})),t}();function Et(t,e){this.manager=t,this.set(e)}Et.prototype={set:function(t){
|