hypothesis 1.951.0 → 1.952.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 s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function e(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),n=1;n<e;n++)s[n-1]=arguments[n];return s.every((function(e){return"function"==typeof t[e]}))}var s={es2017:function(){return!e(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!e(Promise.prototype,"finally")}};function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);"Object"===s&&t.constructor&&(s=t.constructor.name);if("Map"===s||"Set"===s)return Array.from(t);if("Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return r(t,e)}(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 r(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=new Array(e);s<e;s++)n[s]=t[s];return n}var o=["es2017","es2018"];function a(t){t.setAttribute("data-hypothesis-asset","")}function i(t,e){var s=t.createElement("link");s.rel="stylesheet",s.type="text/css",s.href=e,a(s),t.head.appendChild(s)}function c(t,e){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=t.createElement("script");n.type="module",s&&(e+="#ts=".concat(Date.now())),n.src=e,n.async=!1,a(n),t.head.appendChild(n)}function l(t,e,s,n){var r=t.createElement("link");r.rel=e,r.href=n,r.type="application/annotator+".concat(s),a(r),t.head.appendChild(r)}function u(t,e,s){var n=t.createElement("link");n.rel="preload",n.as=e,n.href=s,"fetch"===e&&(n.crossOrigin="anonymous"),a(n),t.head.appendChild(n)}function p(t,e){return t.assetRoot+"build/"+t.manifest[e]}function d(t,e,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=n.forceModuleReload;s.forEach((function(s){var n=p(e,s);n.match(/\.css/)?i(t,n):c(t,n,r)}))}function h(t){return function(t){return t.filter((function(t){var e=s[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 f(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?f(e.src):null}function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var s=y(e);if(!s)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",s.hostname)).replace("{current_scheme}",s.protocol)}var b={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";function t(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function e(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),n=1;n<e;n++)s[n-1]=arguments[n];return s.every((function(e){return"function"==typeof t[e]}))}var s={es2017:function(){return!e(Object,"entries","values")},es2018:function(){return"function"!=typeof Promise||!e(Promise.prototype,"finally")}};function n(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);"Object"===s&&t.constructor&&(s=t.constructor.name);if("Map"===s||"Set"===s)return Array.from(t);if("Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return r(t,e)}(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 r(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=new Array(e);s<e;s++)n[s]=t[s];return n}var o=["es2017","es2018"];function a(t){t.setAttribute("data-hypothesis-asset","")}function i(t,e){var s=t.createElement("link");s.rel="stylesheet",s.type="text/css",s.href=e,a(s),t.head.appendChild(s)}function c(t,e){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=t.createElement("script");n.type="module",s&&(e+="#ts=".concat(Date.now())),n.src=e,n.async=!1,a(n),t.head.appendChild(n)}function l(t,e,s,n){var r=t.createElement("link");r.rel=e,r.href=n,r.type="application/annotator+".concat(s),a(r),t.head.appendChild(r)}function u(t,e,s){var n=t.createElement("link");n.rel="preload",n.as=e,n.href=s,"fetch"===e&&(n.crossOrigin="anonymous"),a(n),t.head.appendChild(n)}function p(t,e){return t.assetRoot+"build/"+t.manifest[e]}function d(t,e,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=n.forceModuleReload;s.forEach((function(s){var n=p(e,s);n.match(/\.css/)?i(t,n):c(t,n,r)}))}function h(t){return function(t){return t.filter((function(t){var e=s[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 f(t){var e=t.match(/(https?):\/\/([^:/]+)/);return e?{protocol:e[1],hostname:e[2]}:null}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=t.currentScript;return e?f(e.src):null}function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===t.indexOf("{"))return t;var s=y(e);if(!s)throw new Error("Could not process URL template because script origin is unknown");return t=(t=t.replace("{current_host}",s.hostname)).replace("{current_scheme}",s.protocol)}var b={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?58e8e2","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?31366a","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?ee2fe0","styles/annotator.css":"styles/annotator.css?c5bbcc","styles/annotator.css.map":"styles/annotator.css.map?26c09c","styles/highlights.css":"styles/highlights.css?c308d0","styles/highlights.css.map":"styles/highlights.css.map?5be890","styles/katex.min.css":"styles/katex.min.css?123be2","styles/katex.min.css.map":"styles/katex.min.css.map?4daef7","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?dd8179","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?bf5f6c","styles/sidebar.css":"styles/sidebar.css?21ecfe","styles/sidebar.css.map":"styles/sidebar.css.map?52d821","styles/ui-playground.css":"styles/ui-playground.css?3fe805","styles/ui-playground.css.map":"styles/ui-playground.css.map?c9b68e","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?cdfade","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?446e90","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?ac7d68"};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 v=function(e){for(var s={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{o=JSON.parse(n[r].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),o={}}t(s,o)}return s}(document),g=m(v.assetRoot||"https://cdn.hypothes.is/hypothesis/1.952.0/");if(document.querySelector("hypothesis-app"))!function(t,e){u(t,"fetch",e.apiUrl),u(t,"fetch",e.apiUrl+"links");var s=h(o);d(t,e,[].concat(n(s),["scripts/sidebar.bundle.js","styles/katex.min.css","styles/sidebar.css"]))}(document,{assetRoot:g,manifest:b,apiUrl:v.apiUrl});else{var j=m(v.notebookAppUrl||"https://hypothes.is/notebook"),w=m(v.sidebarAppUrl||"https://hypothes.is/app.html");!function(t,e){if(!t.querySelector('link[type="application/annotator+html"]')){l(t,"sidebar","html",e.sidebarAppUrl),l(t,"notebook","html",e.notebookAppUrl),u(t,"style",p(e,"styles/annotator.css")),l(t,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");var s=h(o);d(t,e,[].concat(n(s),["scripts/annotator.bundle.js","styles/highlights.css","styles/pdfjs-overrides.css"]),{forceModuleReload:!0})}}(document,{assetRoot:g,manifest:b,notebookAppUrl:j,sidebarAppUrl:w})}}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,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?58e8e2",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?31366a",
|
|
4
|
+
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?ee2fe0",
|
|
4
5
|
"styles/annotator.css": "styles/annotator.css?c5bbcc",
|
|
5
6
|
"styles/annotator.css.map": "styles/annotator.css.map?26c09c",
|
|
6
7
|
"styles/highlights.css": "styles/highlights.css?c308d0",
|
|
@@ -11,10 +12,9 @@
|
|
|
11
12
|
"styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?bf5f6c",
|
|
12
13
|
"styles/sidebar.css": "styles/sidebar.css?21ecfe",
|
|
13
14
|
"styles/sidebar.css.map": "styles/sidebar.css.map?52d821",
|
|
14
|
-
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?ee2fe0",
|
|
15
|
-
"styles/ui-playground.css.map": "styles/ui-playground.css.map?c9b68e",
|
|
16
15
|
"styles/ui-playground.css": "styles/ui-playground.css?3fe805",
|
|
17
|
-
"
|
|
18
|
-
"scripts/
|
|
16
|
+
"styles/ui-playground.css.map": "styles/ui-playground.css.map?c9b68e",
|
|
17
|
+
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?cdfade",
|
|
18
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?446e90",
|
|
19
19
|
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?ac7d68"
|
|
20
20
|
}
|
|
@@ -89,15 +89,15 @@ async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function
|
|
|
89
89
|
this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function Yn(){const t=function(t,e){const n=new Set,o=new Set;return pe(t,(t=>{let i=t;for(;i&&!n.has(i);){n.add(i);const t=e(i);t&&o.add(t),i=i.parentNode}})),[...o]}(window.getSelection().getRangeAt(0),(t=>t._annotation));return t}function Gn(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));return e}function Zn(t){if(!t.range)return null;try{return t.range.toRange()}catch{return null}}function Kn(){var t;null===(t=document.getSelection())||void 0===t||t.removeAllRanges()}class Jn{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 re(this.element,{
|
|
90
90
|
onAnnotate:async()=>{await this.createAnnotation()},onHighlight:async()=>{await this.createAnnotation({highlight:!0})},onShowAnnotations:t=>{this.selectAnnotations(t)}}),this._selectionObserver=new Xn((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new Yt({hostFrame:this._hostFrame,source:"guest"}),this._hostRPC=new Xt,this._connectHostEvents(),this._sidebarRPC=new Xt,this._connectSidebarEvents(),this._hypothesisInjector=new Fe(this.element,e),this._integration=zn(this),this._sideBySideActive=!1,this._listeners=new Ot,this._setupElementEvents(),this._focusedAnnotations=new Set,this._listeners.add(window,"unload",(()=>this._notifyGuestUnload()))}_setupElementEvents(){const t=t=>{this._sideBySideActive||Gn(t).length||this._sidebarRPC.call("closeSidebar")};this._listeners.add(this.element,"mouseup",(t=>{const{target:e,metaKey:n,ctrlKey:o}=t,i=Gn(e);if(i.length&&this._highlightsVisible){const t=n||o
|
|
91
91
|
;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=Gn(t);e.length&&this._highlightsVisible&&this._focusAnnotations(e)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._focusAnnotations([])})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async injectClient(t){return this._hypothesisInjector.injectClient(t)}async getDocumentInfo(){const[t,e]=await Promise.all([this._integration.uri(),this._integration.getMetadata()]);return{uri:un(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 _connectHostEvents(){this._hostRPC.on("clearSelectionExceptIn",(t=>{
|
|
92
|
-
this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),this._hostRPC.on("createAnnotationIn",(t=>{this._frameIdentifier===t&&this.createAnnotation()}));const t=await this._portFinder.discover("host");this._hostRPC.createChannel(t)}async _connectSidebarEvents(){this._sidebarRPC.on("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);ye(e.highlights,n)}})),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=Zn(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("getDocumentInfo",(t=>{
|
|
93
|
-
this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("loadAnnotations",(t=>t.forEach((t=>this.anchor(t)))));const t=await this._portFinder.discover("sidebar");this._sidebarRPC.createChannel(t)}destroy(){this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),function(t){ve(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._sidebarRPC.destroy()}_notifyGuestUnload(){const t={type:"hypothesisGuestUnloaded",frameIdentifier:this._frameIdentifier};this._hostFrame.postMessage(t,"*")}async anchor(t){const e=t=>{const e=Zn(t);if(!e)return;const n=ge(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ye(n,!0)}
|
|
94
|
-
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=he.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),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&&ve(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&null===this._frameIdentifier&&this._hostRPC.call("anchorsChanged")}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
|
|
95
|
-
}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:t,$tag:"a:"+Zt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Kn(),r}_focusAnnotations(t){const e=t.map((t=>t.$tag));this._sidebarRPC.call("focusAnnotations",e)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=de(e),o=me(e);o?(this.selectedRanges=[t],this._hostRPC.call("textSelectedIn",this._frameIdentifier),this._adder.annotationsForSelection=Yn(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselectedIn",this._frameIdentifier),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,e=!1){const n=t.map((t=>t.$tag))
|
|
96
|
-
return this._integration.scrollToAnchor(t)}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}contentContainer(){return this._integration.contentContainer()}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Qn(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function to(t){var e;const n={};for(let[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.version="1.
|
|
97
|
-
t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return n}function eo({config:t,groupId:e}){return gt("iframe",{title:"Hypothesis annotation notebook",className:"NotebookIframe",allowFullScreen:!0,src:Qn(t.notebookAppUrl,{...to(t),group:e})})}function no({eventBus:t,config:e}){const[n,o]=rt(0),[i,r]=rt(!0),[s,a]=rt(null),l=lt(""),c=lt(null);st((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),st((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),st((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:gt("div",{className:Z("NotebookModal__outer",{"is-hidden":i}),children:gt("div",{className:"NotebookModal__inner",children:[gt("div",{
|
|
98
|
-
null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),gt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=oe(this._outerContainer),P(gt(no,{eventBus:e,config:n}),this.shadowRoot)}destroy(){P(null,this.shadowRoot),this._outerContainer.remove()}}var io={exports:{}};!function(t){!function(e,n,o,i){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var 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){
|
|
99
|
-
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 m=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`."),g=p((function(t,e){return m(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)}}
|
|
100
|
-
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(x(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(x(e),(function(e){t.removeEventListener(e,n,!1)}))}function E(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function x(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 N(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 R=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
|
|
92
|
+
this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),this._hostRPC.on("createAnnotationIn",(t=>{this._frameIdentifier===t&&this.createAnnotation()})),this._hostRPC.on("sidebarLayoutChanged",(t=>{null===this._frameIdentifier&&this.fitSideBySide(t)}));const t=await this._portFinder.discover("host");this._hostRPC.createChannel(t)}async _connectSidebarEvents(){this._sidebarRPC.on("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);ye(e.highlights,n)}})),this._sidebarRPC.on("scrollToAnnotation",(t=>{const e=this.anchors.find((e=>e.annotation.$tag===t));if(null==e||!e.highlights)return;const n=Zn(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("getDocumentInfo",(t=>{
|
|
93
|
+
this.getDocumentInfo().then((e=>t(null,e))).catch((e=>t(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)))));const t=await this._portFinder.discover("sidebar");this._sidebarRPC.createChannel(t)}destroy(){this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),function(t){ve(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy(),this._sidebarRPC.destroy()}_notifyGuestUnload(){const t={type:"hypothesisGuestUnloaded",frameIdentifier:this._frameIdentifier};this._hostFrame.postMessage(t,"*")}async anchor(t){const e=t=>{const e=Zn(t);if(!e)return;const n=ge(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ye(n,!0)}
|
|
94
|
+
;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=he.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),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&&ve(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,e&&null===this._frameIdentifier&&this._hostRPC.call("anchorsChanged")}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
|
|
95
|
+
;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:"+Zt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Kn(),r}_focusAnnotations(t){const e=t.map((t=>t.$tag));this._sidebarRPC.call("focusAnnotations",e)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=de(e),o=me(e);o?(this.selectedRanges=[t],this._hostRPC.call("textSelectedIn",this._frameIdentifier),this._adder.annotationsForSelection=Yn(),this._isAdderVisible=!0,this._adder.show(o,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselectedIn",this._frameIdentifier),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,e=!1){const n=t.map((t=>t.$tag))
|
|
96
|
+
;e?this._sidebarRPC.call("toggleAnnotationSelection",n):this._sidebarRPC.call("showAnnotations",n),this._sidebarRPC.call("openSidebar")}scrollToAnchor(t){return this._integration.scrollToAnchor(t)}setHighlightsVisible(t){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t}contentContainer(){return this._integration.contentContainer()}fitSideBySide(t){this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get focusedAnnotationTags(){return this._focusedAnnotations}}function Qn(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function to(t){var e;const n={};for(let[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.version="1.952.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),(null===(e=n.services)||void 0===e?void 0:e.length)>0){const t=n.services[0]
|
|
97
|
+
;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 n}function eo({config:t,groupId:e}){return gt("iframe",{title:"Hypothesis annotation notebook",className:"NotebookIframe",allowFullScreen:!0,src:Qn(t.notebookAppUrl,{...to(t),group:e})})}function no({eventBus:t,config:e}){const[n,o]=rt(0),[i,r]=rt(!0),[s,a]=rt(null),l=lt(""),c=lt(null);st((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),st((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),st((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:gt("div",{className:Z("NotebookModal__outer",{"is-hidden":i}),children:gt("div",{className:"NotebookModal__inner",children:[gt("div",{
|
|
98
|
+
className:"NotebookModal__close-button-container",children:gt(Ct,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),gt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=oe(this._outerContainer),P(gt(no,{eventBus:e,config:n}),this.shadowRoot)}destroy(){P(null,this.shadowRoot),this._outerContainer.remove()}}var io={exports:{}};!function(t){!function(e,n,o,i){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var 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){
|
|
99
|
+
var i="DEPRECATED METHOD: "+n+"\n"+o+" AT \n";return function(){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 m=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`."),g=p((function(t,e){return m(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)}}
|
|
100
|
+
function y(t,e){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(x(e),(function(e){t.addEventListener(e,n,!1)}))}function C(t,e,n){f(x(e),(function(e){t.removeEventListener(e,n,!1)}))}function E(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function S(t,e){return t.indexOf(e)>-1}function x(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 N(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 R=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
|
|
101
101
|
var P="ontouchstart"in e,M=N(e,"PointerEvent")!==i,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",D="mouse",H=24,F=["x","y"],B=["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,l=a?a.center:s.center,u=e.center=W(o);e.timeStamp=h(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=X(l,u),e.distance=z(l,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},
|
|
102
102
|
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=j(e.deltaX,e.deltaY);var d=$(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,e.scale=a?(f=a.pointers,p=o,z(p[0],p[1],B)/z(f[0],f[1],B)):1,e.rotation=a?function(t,e){return X(e[1],e[0],B)+X(t[1],t[0],B)}(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,l=e.timeStamp-a.timeStamp;if(8!=e.eventType&&(l>25||a.velocity===i)){var h=e.deltaX-a.deltaX,u=e.deltaY-a.deltaY,d=$(l,h,u);o=d.x,r=d.y,n=c(d.x)>c(d.y)?d.x:d.y,s=j(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 m=t.element;E(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}
|
|
103
103
|
function U(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:l(t.pointers[n].clientX),clientY:l(t.pointers[n].clientY)},n++;return{timeStamp:h(),pointers:e,center:W(e),deltaX:t.deltaX,deltaY:t.deltaY}}function W(t){var e=t.length;if(1===e)return{x:l(t[0].clientX),y:l(t[0].clientY)};for(var n=0,o=0,i=0;i<e;)n+=t[i].clientX,o+=t[i].clientY,i++;return{x:l(n/e),y:l(o/e)}}function $(t,e,n){return{x:e/t||0,y:n/t||0}}function j(t,e){return t===e?1:c(t)>=c(e)?t<0?2:4:e<0?8:16}function z(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(L(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&C(this.element,this.evEl,this.domHandler),
|
|
@@ -122,12 +122,12 @@ constructor(t,e,{contentContainer:n=document.body}={}){this._contentContainer=n,
|
|
|
122
122
|
className:n,"aria-label":o,"aria-expanded":e,"aria-pressed":s,onClick:r,ref:t,title:o,children:gt(vt,{name:i})})}function go({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:o,showHighlights:i,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return gt("div",{className:"Toolbar",children:[l&&n&>(mo,{className:"Toolbar__sidebar-close",label:"Close annotation sidebar",icon:"cancel",onClick:t}),!l&>(mo,{className:"Toolbar__sidebar-toggle",buttonRef:a,label:"Annotation sidebar",icon:n?"caret-right":"caret-left",expanded:n,onClick:s}),!l&>("div",{className:"Toolbar__buttonbar",children:[gt(mo,{label:"Show highlights",icon:i?"show":"hide",selected:i,onClick:r}),gt(mo,{label:"note"===o?"New page note":"New annotation",icon:"note"===o?"note":"annotate",onClick:e})]})]})}class _o{constructor(t,e){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=e;this._container=t,this._useMinimalControls=!1,this._newAnnotationType="note",
|
|
123
123
|
this._highlightsVisible=!1,this._sidebarOpen=!1,this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>i(!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(){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(){P(gt(go,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,
|
|
124
124
|
isSidebarOpen:this._sidebarOpen,showHighlights:this._highlightsVisible,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}class vo{constructor(t,e,n,o={}){if(this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=new Xt,this._sidebarRPC=new Xt,this.iframe=function(t){const e=Qn(t.sidebarAppUrl,to(t)),n=document.createElement("iframe");return n.setAttribute("allowfullscreen",""),n.src=e,n.title="Hypothesis annotation viewer",n.className="h-sidebar-iframe",n}(o),this.options=o,this.bucketBar=null,o.externalContainerSelector){var i;this.externalFrame=null!==(i=document.querySelector(o.externalContainerSelector))&&void 0!==i?i:t,this.externalFrame.appendChild(this.iframe)}else{this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="annotator-frame",
|
|
125
|
-
"clean"===o.theme?this.iframeContainer.classList.add("annotator-frame--theme-clean"):this.bucketBar=new ho(this.iframeContainer,n,{contentContainer:n.contentContainer()}),this.iframeContainer.appendChild(this.iframe),this.hypothesisSidebar=document.createElement("hypothesis-sidebar");oe(this.hypothesisSidebar).appendChild(this.iframeContainer),t.appendChild(this.hypothesisSidebar)}this.iframe.contentWindow&&Mt(this.iframe.contentWindow),this.
|
|
126
|
-
|
|
125
|
+
"clean"===o.theme?this.iframeContainer.classList.add("annotator-frame--theme-clean"):this.bucketBar=new ho(this.iframeContainer,n,{contentContainer:n.contentContainer()}),this.iframeContainer.appendChild(this.iframe),this.hypothesisSidebar=document.createElement("hypothesis-sidebar");oe(this.hypothesisSidebar).appendChild(this.iframeContainer),t.appendChild(this.hypothesisSidebar)}this.iframe.contentWindow&&Mt(this.iframe.contentWindow),this._listeners=new Ot;const r=document.createElement("div");this.toolbar=new _o(r,{createAnnotation:()=>this._guestRPC.call("createAnnotationIn",this._guestWithSelection),setSidebarOpen:t=>t?this.open():this.close(),setHighlightsVisible:t=>this.setHighlightsVisible(t)}),"clean"===o.theme?this.toolbar.useMinimalControls=!0:this.toolbar.useMinimalControls=!1,this.iframeContainer?(this.iframeContainer.prepend(r),this.toolbarWidth=this.toolbar.getWidth()):this.toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._gestureState={initial:null,final:null},
|
|
126
|
+
this._setupGestures(),this.close();const[s]=o.services||[];s&&(this.onLoginRequest=s.onLoginRequest,this.onLogoutRequest=s.onLogoutRequest,this.onSignupRequest=s.onSignupRequest,this.onProfileRequest=s.onProfileRequest,this.onHelpRequest=s.onHelpRequest),this.onLayoutChange=o.onLayoutChange,this._notifyOfLayoutChange(!1),this._setupSidebarEvents(),this._sidebarRPC.onConnect((()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const t="always"===o.showHighlights;this.setHighlightsVisible(t),(o.openSidebar||o.annotations||o.query||o.group)&&this.open()})),this._setupGuestEvents(),this._listeners.add(window,"message",(t=>{const{data:e}=t;"hypothesisGuestUnloaded"===(null==e?void 0:e.type)&&this._sidebarRPC.call("frameDestroyed",e.frameIdentifier)}))}destroy(){var t,e;this._guestRPC.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(),
|
|
127
127
|
this.hypothesisSidebar?this.hypothesisSidebar.remove():this.iframe.remove(),this._emitter.destroy(),Mt(null)}onFrameConnected(t,e){switch(t){case"guest":this._guestRPC.createChannel(e);break;case"sidebar":this._sidebarRPC.createChannel(e)}}_setupGuestEvents(){this._guestRPC.on("textSelectedIn",(t=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.call("clearSelectionExceptIn",t)})),this._guestRPC.on("textUnselectedIn",(t=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.call("clearSelectionExceptIn",t)})),this._guestRPC.on("anchorsChanged",(()=>{var t;null===(t=this.bucketBar)||void 0===t||t.update()}))}_setupSidebarEvents(){var t;t=document.body,this._sidebarRPC.on("publicAnnotationCountChanged",(function(e){const n=t.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((t=>{t.textContent=e}))})),function(t,e){const n=t.querySelectorAll("[data-hypothesis-trigger]");function o(t){e(),t.stopPropagation()}
|
|
128
128
|
Array.from(n).forEach((t=>{t.addEventListener("click",o)}))}(document.body,(()=>this.open())),po(this._sidebarRPC),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)})),this._emitter.subscribe("closeNotebook",(()=>{this.show()}));[["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 ro.Manager(t).on("panstart panend panleft panright",(t=>this._onPan(t))),this._hammerManager.add(new ro.Pan({direction:ro.DIRECTION_HORIZONTAL})))}
|
|
129
|
-
_updateLayout(){this.renderFrame||(this.renderFrame=requestAnimationFrame((()=>{if(this.renderFrame=null,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=280&&(this.iframeContainer.style.width=`${e}px`),this._notifyOfLayoutChange()}})))}_notifyOfLayoutChange(t){var e;const n=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,i=o.getBoundingClientRect(),r=window.getComputedStyle(o),s=parseInt(r.width),a=parseInt(r.marginLeft);let l=n;"boolean"==typeof t?t&&(l+=s):(a<280?l-=a:l+=s,t=l>n);const c={expanded:t,width:t?l:n,height:i.height,toolbarWidth:n};this.onLayoutChange&&this.onLayoutChange(c),this.
|
|
130
|
-
|
|
131
|
-
this.iframeContainer
|
|
132
|
-
|
|
129
|
+
_updateLayout(){this.renderFrame||(this.renderFrame=requestAnimationFrame((()=>{if(this.renderFrame=null,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){const t=this._gestureState.final,e=-t;this.iframeContainer.style.marginLeft=`${t}px`,e>=280&&(this.iframeContainer.style.width=`${e}px`),this._notifyOfLayoutChange()}})))}_notifyOfLayoutChange(t){var e;const n=this.iframeContainer&&this.toolbar.getWidth()||0,o=null!==(e=this.iframeContainer)&&void 0!==e?e:this.externalFrame,i=o.getBoundingClientRect(),r=window.getComputedStyle(o),s=parseInt(r.width),a=parseInt(r.marginLeft);let l=n;"boolean"==typeof t?t&&(l+=s):(a<280?l-=a:l+=s,t=l>n);const c={expanded:t,width:t?l:n,height:i.height,toolbarWidth:n};this.onLayoutChange&&this.onLayoutChange(c),this._guestRPC.call("sidebarLayoutChanged",c)}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<280?this.close():this.open())}_onPan(t){const e=this.iframeContainer;if(e)switch(t.type){case"panstart":this._resetGestureState(),
|
|
130
|
+
e.classList.add("annotator-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":e.classList.remove("annotator-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("annotator-collapsed")}this.toolbar.sidebarOpen=!0,"whenSidebarOpen"===this.options.showHighlights&&this.setHighlightsVisible(!0),this._notifyOfLayoutChange(!0)}close(){this.iframeContainer&&(this.iframeContainer.style.marginLeft="",
|
|
131
|
+
this.iframeContainer.classList.add("annotator-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this.options.showHighlights&&this.setHighlightsVisible(!1),this._notifyOfLayoutChange(!1)}setHighlightsVisible(t){this.toolbar.highlightsVisible=t,this._sidebarRPC.call("setHighlightsVisible",t)}show(){this.iframeContainer&&this.iframeContainer.classList.remove("is-hidden")}hide(){this.iframeContainer&&this.iframeContainer.classList.add("is-hidden")}}class yo{constructor(t){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,o])=>n!==t||o!==e))}destroy(){for(let[t,e]of this._subscriptions)this._emitter.off(t,e);this._subscriptions=[]}}class wo{constructor(){this._emitter=new Nt}createEmitter(){return new yo(this._emitter)}}!function(t,{reset:e=!1}={}){e&&_t.clear();for(let[e,n]of Object.entries(t))_t.set(e,n)}(Tt)
|
|
132
|
+
;const bo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=jt("annotator"),e=t.subFrameIdentifier?window.parent:window,n=new Jn(document.body,t,e);let o,i,r;if(e===window){const t=jt("sidebar"),e=new URL(t.sidebarAppUrl).origin;r=new Ht(e),r.listen();const s=new wo;o=new vo(document.body,s,n,t),i=new oo(document.body,s,jt("notebook")),r.on("frameConnected",((t,e)=>o.onFrameConnected(t,e)))}bo.addEventListener("destroy",(()=>{var t,e,s;null===(t=r)||void 0===t||t.destroy(),null===(e=o)||void 0===e||e.destroy(),null===(s=i)||void 0===s||s.destroy(),n.destroy();document.querySelectorAll("[data-hypothesis-asset]").forEach((t=>t.remove()))}))}));
|
|
133
133
|
//# sourceMappingURL=annotator.bundle.js.map
|