hypothesis 1.963.0 → 1.964.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 f(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 h(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?h(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?075f18","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?31366a","styles/annotator.css":"styles/annotator.css?6e77e6","styles/annotator.css.map":"styles/annotator.css.map?63c804","styles/highlights.css":"styles/highlights.css?c308d0","styles/highlights.css.map":"styles/highlights.css.map?5be890","styles/katex.min.css":"styles/katex.min.css?28919c","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?7205ac","styles/sidebar.css.map":"styles/sidebar.css.map?d95598","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?ee2fe0","styles/ui-playground.css.map":"styles/ui-playground.css.map?e9a64c","styles/ui-playground.css":"styles/ui-playground.css?9af4ea","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?aff69f","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?f5439c","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?938efc"};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.963.0/");if(document.querySelector("hypothesis-app"))!function(t,e){u(t,"fetch",e.apiUrl),u(t,"fetch",e.apiUrl+"links");var s=f(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=f(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/.")}();
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 f(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 h(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?h(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?7f6f35","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?31366a","styles/annotator.css":"styles/annotator.css?6e77e6","styles/highlights.css":"styles/highlights.css?c308d0","styles/highlights.css.map":"styles/highlights.css.map?5be890","styles/annotator.css.map":"styles/annotator.css.map?63c804","styles/katex.min.css.map":"styles/katex.min.css.map?4daef7","styles/katex.min.css":"styles/katex.min.css?28919c","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?7205ac","styles/sidebar.css.map":"styles/sidebar.css.map?d95598","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?ee2fe0","styles/ui-playground.css":"styles/ui-playground.css?9af4ea","styles/ui-playground.css.map":"styles/ui-playground.css.map?e9a64c","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b2de0d","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?145bef","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?938efc"};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.964.0/");if(document.querySelector("hypothesis-app"))!function(t,e){u(t,"fetch",e.apiUrl),u(t,"fetch",e.apiUrl+"links");var s=f(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=f(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/.")}();
@@ -1,20 +1,20 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?075f18",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?7f6f35",
3
3
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?31366a",
4
4
  "styles/annotator.css": "styles/annotator.css?6e77e6",
5
- "styles/annotator.css.map": "styles/annotator.css.map?63c804",
6
5
  "styles/highlights.css": "styles/highlights.css?c308d0",
7
6
  "styles/highlights.css.map": "styles/highlights.css.map?5be890",
8
- "styles/katex.min.css": "styles/katex.min.css?28919c",
7
+ "styles/annotator.css.map": "styles/annotator.css.map?63c804",
9
8
  "styles/katex.min.css.map": "styles/katex.min.css.map?4daef7",
9
+ "styles/katex.min.css": "styles/katex.min.css?28919c",
10
10
  "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?dd8179",
11
11
  "styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?bf5f6c",
12
12
  "styles/sidebar.css": "styles/sidebar.css?7205ac",
13
13
  "styles/sidebar.css.map": "styles/sidebar.css.map?d95598",
14
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?e9a64c",
16
15
  "styles/ui-playground.css": "styles/ui-playground.css?9af4ea",
17
- "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?aff69f",
18
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?f5439c",
16
+ "styles/ui-playground.css.map": "styles/ui-playground.css.map?e9a64c",
17
+ "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?b2de0d",
18
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?145bef",
19
19
  "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?938efc"
20
20
  }
@@ -3,12 +3,12 @@ r(t.target)&&(e||s(t.target))&&a(t.target)}function d(t){r(t.target)&&(t.target.
3
3
  document.removeEventListener("touchmove",m),document.removeEventListener("touchstart",m),document.removeEventListener("touchend",m)}function m(t){t.target.nodeName&&"html"===t.target.nodeName.toLowerCase()||(e=!1,g())}document.addEventListener("keydown",c,!0),document.addEventListener("mousedown",h,!0),document.addEventListener("pointerdown",h,!0),document.addEventListener("touchstart",h,!0),document.addEventListener("visibilitychange",f,!0),p(),t.addEventListener("focus",u,!0),t.addEventListener("blur",d,!0),t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&t.host?t.host.setAttribute("data-js-focus-visible",""):t.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if("undefined"!=typeof window&&"undefined"!=typeof document){var e;window.applyFocusVisiblePolyfill=t;try{e=new CustomEvent("focus-visible-polyfill-ready")}catch(t){
4
4
  (e=document.createEvent("CustomEvent")).initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(e)}"undefined"!=typeof document&&t(document)}();var e,n,o,i,r,s,a={},l=[],c=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(t,e){for(var n in e)t[n]=e[n];return t}function u(t){var e=t.parentNode;e&&e.removeChild(t)}function d(t,e,i,r,s){var a={type:t,props:e,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==s?++o:s};return null==s&&null!=n.vnode&&n.vnode(a),a}function f(t){return t.children}function p(t,e){this.props=t,this.context=e}function g(t,e){if(null==e)return t.__?g(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?g(t):null}function m(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return m(t)}}
5
5
  function _(t){(!t.__d&&(t.__d=!0)&&i.push(t)&&!v.__r++||s!==n.debounceRendering)&&((s=n.debounceRendering)||r)(v)}function v(){for(var t;v.__r=i.length;)t=i.sort((function(t,e){return t.__v.__b-e.__v.__b})),i=[],t.some((function(t){var e,n,o,i,r,s;t.__d&&(r=(i=(e=t).__v).__e,(s=e.__P)&&(n=[],(o=h({},i)).__v=i.__v+1,T(s,i,o,e.__n,void 0!==s.ownerSVGElement,null!=i.__h?[r]:null,n,null==r?g(i):r,i.__h),A(n,i),i.__e!=r&&m(i)))}))}function y(t,e,n,o,i,r,s,c,h,u){var p,m,_,v,y,C,E,S=o&&o.__k||l,x=S.length;for(n.__k=[],p=0;p<e.length;p++)if(null!=(v=n.__k[p]=null==(v=e[p])||"boolean"==typeof v?null:"string"==typeof v||"number"==typeof v||"bigint"==typeof v?d(null,v,null,null,v):Array.isArray(v)?d(f,{children:v},null,null,null):v.__b>0?d(v.type,v.props,v.key,null,v.__v):v)){if(v.__=n,v.__b=n.__b+1,null===(_=S[p])||_&&v.key==_.key&&v.type===_.type)S[p]=void 0;else for(m=0;m<x;m++){if((_=S[m])&&v.key==_.key&&v.type===_.type){S[m]=void 0;break}_=null}T(t,v,_=_||a,i,r,s,c,h,u),y=v.__e,(m=v.ref)&&_.ref!=m&&(E||(E=[]),
6
- _.ref&&E.push(_.ref,null,v),E.push(m,v.__c||y,v)),null!=y?(null==C&&(C=y),"function"==typeof v.type&&v.__k===_.__k?v.__d=h=w(v,h,t):h=b(t,v,_,S,y,h),"function"==typeof n.type&&(n.__d=h)):h&&_.__e==h&&h.parentNode!=t&&(h=g(_))}for(n.__e=C,p=x;p--;)null!=S[p]&&("function"==typeof n.type&&null!=S[p].__e&&S[p].__e==n.__d&&(n.__d=g(o,p+1)),R(S[p],S[p]));if(E)for(p=0;p<E.length;p++)N(E[p],E[++p],E[++p])}function w(t,e,n){for(var o,i=t.__k,r=0;i&&r<i.length;r++)(o=i[r])&&(o.__=t,e="function"==typeof o.type?w(o,e,n):b(n,o,o,i,o.__e,e));return e}function b(t,e,n,o,i,r){var s,a,l;if(void 0!==e.__d)s=e.__d,e.__d=void 0;else if(null==n||i!=r||null==i.parentNode)t:if(null==r||r.parentNode!==t)t.appendChild(i),s=null;else{for(a=r,l=0;(a=a.nextSibling)&&l<o.length;l+=2)if(a==i)break t;t.insertBefore(i,r),s=r}return void 0!==s?s:i.nextSibling}function C(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||c.test(e)?n:n+"px"}function E(t,e,n,o,i){var r
6
+ _.ref&&E.push(_.ref,null,v),E.push(m,v.__c||y,v)),null!=y?(null==C&&(C=y),"function"==typeof v.type&&v.__k===_.__k?v.__d=h=w(v,h,t):h=b(t,v,_,S,y,h),"function"==typeof n.type&&(n.__d=h)):h&&_.__e==h&&h.parentNode!=t&&(h=g(_))}for(n.__e=C,p=x;p--;)null!=S[p]&&("function"==typeof n.type&&null!=S[p].__e&&S[p].__e==n.__d&&(n.__d=g(o,p+1)),N(S[p],S[p]));if(E)for(p=0;p<E.length;p++)R(E[p],E[++p],E[++p])}function w(t,e,n){for(var o,i=t.__k,r=0;i&&r<i.length;r++)(o=i[r])&&(o.__=t,e="function"==typeof o.type?w(o,e,n):b(n,o,o,i,o.__e,e));return e}function b(t,e,n,o,i,r){var s,a,l;if(void 0!==e.__d)s=e.__d,e.__d=void 0;else if(null==n||i!=r||null==i.parentNode)t:if(null==r||r.parentNode!==t)t.appendChild(i),s=null;else{for(a=r,l=0;(a=a.nextSibling)&&l<o.length;l+=2)if(a==i)break t;t.insertBefore(i,r),s=r}return void 0!==s?s:i.nextSibling}function C(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]=null==n?"":"number"!=typeof n||c.test(e)?n:n+"px"}function E(t,e,n,o,i){var r
7
7
  ;t:if("style"===e)if("string"==typeof n)t.style.cssText=n;else{if("string"==typeof o&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||C(t.style,e,"");if(n)for(e in n)o&&n[e]===o[e]||C(t.style,e,n[e])}else if("o"===e[0]&&"n"===e[1])r=e!==(e=e.replace(/Capture$/,"")),e=e.toLowerCase()in t?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+r]=n,n?o||t.addEventListener(e,r?x:S,r):t.removeEventListener(e,r?x:S,r);else if("dangerouslySetInnerHTML"!==e){if(i)e=e.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if("href"!==e&&"list"!==e&&"form"!==e&&"tabIndex"!==e&&"download"!==e&&e in t)try{t[e]=null==n?"":n;break t}catch(t){}"function"==typeof n||(null!=n&&(!1!==n||"a"===e[0]&&"r"===e[1])?t.setAttribute(e,n):t.removeAttribute(e))}}function S(t){this.l[t.type+!1](n.event?n.event(t):t)}function x(t){this.l[t.type+!0](n.event?n.event(t):t)}function T(t,e,o,i,r,s,a,l,c){var u,d,g,m,_,v,w,b,C,E,S,x=e.type;if(void 0!==e.constructor)return null;null!=o.__h&&(c=o.__h,l=e.__e=o.__e,e.__h=null,s=[l]),(u=n.__b)&&u(e)
8
8
  ;try{t:if("function"==typeof x){if(b=e.props,C=(u=x.contextType)&&i[u.__c],E=u?C?C.props.value:u.__:i,o.__c?w=(d=e.__c=o.__c).__=d.__E:("prototype"in x&&x.prototype.render?e.__c=d=new x(b,E):(e.__c=d=new p(b,E),d.constructor=x,d.render=L),C&&C.sub(d),d.props=b,d.state||(d.state={}),d.context=E,d.__n=i,g=d.__d=!0,d.__h=[]),null==d.__s&&(d.__s=d.state),null!=x.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=h({},d.__s)),h(d.__s,x.getDerivedStateFromProps(b,d.__s))),m=d.props,_=d.state,g)null==x.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==x.getDerivedStateFromProps&&b!==m&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(b,E),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(b,d.__s,E)||e.__v===o.__v){d.props=b,d.state=d.__s,e.__v!==o.__v&&(d.__d=!1),d.__v=e,e.__e=o.__e,e.__k=o.__k,e.__k.forEach((function(t){t&&(t.__=e)})),d.__h.length&&a.push(d);break t}
9
9
  null!=d.componentWillUpdate&&d.componentWillUpdate(b,d.__s,E),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(m,_,v)}))}d.context=E,d.props=b,d.state=d.__s,(u=n.__r)&&u(e),d.__d=!1,d.__v=e,d.__P=t,u=d.render(d.props,d.state,d.context),d.state=d.__s,null!=d.getChildContext&&(i=h(h({},i),d.getChildContext())),g||null==d.getSnapshotBeforeUpdate||(v=d.getSnapshotBeforeUpdate(m,_)),S=null!=u&&u.type===f&&null==u.key?u.props.children:u,y(t,Array.isArray(S)?S:[S],e,o,i,r,s,a,l,c),d.base=e.__e,e.__h=null,d.__h.length&&a.push(d),w&&(d.__E=d.__=null),d.__e=!1}else null==s&&e.__v===o.__v?(e.__k=o.__k,e.__e=o.__e):e.__e=k(o.__e,e,o,i,r,s,a,c);(u=n.diffed)&&u(e)}catch(t){e.__v=null,(c||null!=s)&&(e.__e=l,e.__h=!!c,s[s.indexOf(l)]=null),n.__e(t,e,o)}}function A(t,e){n.__c&&n.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){n.__e(t,e.__v)}}))}function k(t,n,o,i,r,s,l,c){var h,d,f,p=o.props,m=n.props,_=n.type,v=0;if("svg"===_&&(r=!0),
10
10
  null!=s)for(;v<s.length;v++)if((h=s[v])&&"setAttribute"in h==!!_&&(_?h.localName===_:3===h.nodeType)){t=h,s[v]=null;break}if(null==t){if(null===_)return document.createTextNode(m);t=r?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,m.is&&m),s=null,c=!1}if(null===_)p===m||c&&t.data===m||(t.data=m);else{if(s=s&&e.call(t.childNodes),d=(p=o.props||a).dangerouslySetInnerHTML,f=m.dangerouslySetInnerHTML,!c){if(null!=s)for(p={},v=0;v<t.attributes.length;v++)p[t.attributes[v].name]=t.attributes[v].value;(f||d)&&(f&&(d&&f.__html==d.__html||f.__html===t.innerHTML)||(t.innerHTML=f&&f.__html||""))}if(function(t,e,n,o,i){var r;for(r in n)"children"===r||"key"===r||r in e||E(t,r,null,n[r],o);for(r in e)i&&"function"!=typeof e[r]||"children"===r||"key"===r||"value"===r||"checked"===r||n[r]===e[r]||E(t,r,e[r],n[r],o)}(t,m,p,r,c),f)n.__k=[];else if(v=n.props.children,y(t,Array.isArray(v)?v:[v],n,o,i,r&&"foreignObject"!==_,s,l,s?s[0]:o.__k&&g(o,0),c),
11
- null!=s)for(v=s.length;v--;)null!=s[v]&&u(s[v]);c||("value"in m&&void 0!==(v=m.value)&&(v!==p.value||v!==t.value||"progress"===_&&!v)&&E(t,"value",v,p.value,!1),"checked"in m&&void 0!==(v=m.checked)&&v!==t.checked&&E(t,"checked",v,p.checked,!1))}return t}function N(t,e,o){try{"function"==typeof t?t(e):t.current=e}catch(t){n.__e(t,o)}}function R(t,e,o){var i,r;if(n.unmount&&n.unmount(t),(i=t.ref)&&(i.current&&i.current!==t.__e||N(i,null,e)),null!=(i=t.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){n.__e(t,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&R(i[r],e,"function"!=typeof t.type);o||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function P(t,o,i){var r,s,l;n.__&&n.__(t,o),s=(r="function"==typeof i)?null:i&&i.__k||o.__k,l=[],T(o,t=(!r&&i||o).__k=function(t,n,o){var i,r,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?r=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?e.call(arguments,2):o),
11
+ null!=s)for(v=s.length;v--;)null!=s[v]&&u(s[v]);c||("value"in m&&void 0!==(v=m.value)&&(v!==p.value||v!==t.value||"progress"===_&&!v)&&E(t,"value",v,p.value,!1),"checked"in m&&void 0!==(v=m.checked)&&v!==t.checked&&E(t,"checked",v,p.checked,!1))}return t}function R(t,e,o){try{"function"==typeof t?t(e):t.current=e}catch(t){n.__e(t,o)}}function N(t,e,o){var i,r;if(n.unmount&&n.unmount(t),(i=t.ref)&&(i.current&&i.current!==t.__e||R(i,null,e)),null!=(i=t.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){n.__e(t,e)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&N(i[r],e,"function"!=typeof t.type);o||null==t.__e||u(t.__e),t.__e=t.__d=void 0}function L(t,e,n){return this.constructor(t,n)}function P(t,o,i){var r,s,l;n.__&&n.__(t,o),s=(r="function"==typeof i)?null:i&&i.__k||o.__k,l=[],T(o,t=(!r&&i||o).__k=function(t,n,o){var i,r,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?r=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?e.call(arguments,2):o),
12
12
  "function"==typeof t&&null!=t.defaultProps)for(s in t.defaultProps)void 0===a[s]&&(a[s]=t.defaultProps[s]);return d(t,a,i,r,null)}(f,null,[t]),s||a,a,void 0!==o.ownerSVGElement,!r&&i?[i]:s?null:o.firstChild?e.call(o.childNodes):null,l,!r&&i?i:s?s.__e:o.firstChild,r),A(l,t)}e=l.slice,n={__e:function(t,e){for(var n,o,i;e=e.__;)if((n=e.__c)&&!n.__)try{if((o=n.constructor)&&null!=o.getDerivedStateFromError&&(n.setState(o.getDerivedStateFromError(t)),i=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(t),i=n.__d),i)return n.__E=n}catch(e){t=e}throw t}},o=0,p.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof t&&(t=t(h({},n),this.props)),t&&h(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),_(this))},p.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),_(this))},p.prototype.render=f,i=[],r="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,v.__r=0,
13
13
  "undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.6.4",n,{Fragment:f,Component:p});var M={};function O(t){return t.type===f?"Fragment":"function"==typeof t.type?t.type.displayName||t.type.name:"string"==typeof t.type?t.type:"#text"}var I=[],D=[];function H(){return I.length>0?I[I.length-1]:null}var B=!1;function F(t){return"function"==typeof t.type&&t.type!=f}function V(t){for(var e=[t],n=t;null!=n.__o;)e.push(n.__o),n=n.__o;return e.reduce((function(t,e){t+=" in "+O(e);var n=e.__source;return n?t+=" (at "+n.fileName+":"+n.lineNumber+")":B||(B=!0,console.warn("Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons.")),t+"\n"}),"")}var U="function"==typeof WeakMap,q=p.prototype.setState;p.prototype.setState=function(t,e){
14
14
  return null==this.__v?null==this.state&&console.warn('Calling "this.setState" inside the constructor of a component is a no-op and might be a bug in your application. Instead, set "this.state = {}" directly.\n\n'+V(H())):null==this.__P&&console.warn('Can\'t call "this.setState" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+V(this.__v)),q.call(this,t,e)};var W=p.prototype.forceUpdate;function j(t){var e=t.props,n=O(t),o="";for(var i in e)if(e.hasOwnProperty(i)&&"children"!==i){var r=e[i];"function"==typeof r&&(r="function "+(r.displayName||r.name)+"() {}"),r=Object(r)!==r||r.toString?r+"":Object.prototype.toString.call(r),o+=" "+i+"="+JSON.stringify(r)}var s=e.children;return"<"+n+o+(s&&s.length?">..</"+n+">":" />")}p.prototype.forceUpdate=function(t){
@@ -33,8 +33,8 @@ hide:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0
33
33
  highlight:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><g fill-rule="evenodd"><rect fill="none" stroke="none" x="0" y="0" width="16" height="16"></rect><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15H1h11zm-.5-6v2l-1 1v-2l1-1zm.5-7v6h-2V2h2zm0-1h-2 2zm0 8h-2 2z"></path></g></svg>',
34
34
  note:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M14,0 C15.0543618,0 15.9181651,0.815877791 15.9945143,1.85073766 L16,2 L16,9 C16,9.27541264 15.8865388,9.53676152 15.6894833,9.7243131 L15.6,9.8 L7.6,15.8 C7.46152306,15.9038577 7.29908616,15.9695431 7.12886893,15.9916629 L7,16 L2,16 C0.945638205,16 0.0818348781,15.1841222 0.00548573643,14.1492623 L0,14 L0,2 C0,0.945638205 0.815877791,0.0818348781 1.85073766,0.00548573643 L2,0 L14,0 Z M14,2 L2,2 L2,14 L6,14 L6,9 C6,8.48716416 6.38604019,8.06449284 6.88337887,8.00672773 L7,8 L14,8 L14,2 Z M12,10 L8,10 L8,13 L12,10 Z"></path></svg>',pointer:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="8" viewBox="0 0 15 8" aria-hidden="true" focusable="false"><path d="M0 8 L7 0 L15 8" stroke="currentColor" strokeWidth="2" /></svg>\n',
35
35
  show:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" d="M8,2 C12.3599467,2 16,4.6000381 16,8 C16,11.3999619 12.3599467,14 8,14 C3.64005335,14 0,11.3999619 0,8 C0,4.6000381 3.64005335,2 8,2 Z M8,4 C4.62796016,4 2,5.8771144 2,8 C2,10.1228856 4.62796016,12 8,12 C11.3720398,12 14,10.1228856 14,8 C14,5.8771144 11.3720398,4 8,4 Z M8,6 C9.1045695,6 10,6.8954305 10,8 C10,9.1045695 9.1045695,10 8,10 C6.8954305,10 6,9.1045695 6,8 C6,6.8954305 6.8954305,6 8,6 Z"></path></svg>'},At={exports:{}};function kt(){}kt.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var o=this;function i(){o.off(t,i),e.apply(n,arguments)}return i._=e,this.on(t,i,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;o<i;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){
36
- var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,s=o.length;r<s;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},At.exports=kt;var Nt=At.exports.TinyEmitter=kt;let Rt=null;function Lt(t){return t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t),stack:void 0}}function Pt(t,e){if(!Rt)return;const n={type:"hypothesis-error",error:t instanceof Error?t:Lt(t),context:e};try{try{Rt.postMessage(n,"*")}catch(t){if(!(t instanceof DOMException&&"DataCloneError"===t.name))throw t;n.error=Lt(n.error),Rt.postMessage(n,"*")}}catch(t){console.warn("Unable to report Hypothesis error",t)}}function Mt(t){Rt=t}class Ot{constructor(){this._listeners=new Map}add(t,e,n,o){t.addEventListener(e,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:t,eventType:e,listener:n}),i}remove(t){const e=this._listeners.get(t);if(e){const{eventTarget:n,eventType:o,listener:i}=e;n.removeEventListener(o,i),this._listeners.delete(t)}}removeAll(){
37
- this._listeners.forEach((({eventTarget:t,eventType:e,listener:n})=>{t.removeEventListener(e,n)})),this._listeners.clear()}}function It(t){if(null===t||"object"!=typeof t)return!1;for(let e of["frame1","frame2","type"])if("string"!=typeof t[e])return!1;return!0}function Dt(t,e){return!!It(t)&&JSON.stringify(t,Object.keys(e).sort())===JSON.stringify(e,Object.keys(e).sort())}class Ht{constructor(t){this._hypothesisAppsOrigin=t,this._emitter=new Nt,this._sentChannels=new WeakMap,this._sidebarHostChannel=new MessageChannel,this._listeners=new Ot,this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}]}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&Dt(n,t)}on(t,e){this._emitter.on(t,e)}listen(){
36
+ var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,s=o.length;r<s;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},At.exports=kt;var Rt=At.exports.TinyEmitter=kt;let Nt=null;function Lt(t){return t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t),stack:void 0}}function Pt(t,e){if(!Nt)return;const n={type:"hypothesis-error",error:t instanceof Error?t:Lt(t),context:e};try{try{Nt.postMessage(n,"*")}catch(t){if(!(t instanceof DOMException&&"DataCloneError"===t.name))throw t;n.error=Lt(n.error),Nt.postMessage(n,"*")}}catch(t){console.warn("Unable to report Hypothesis error",t)}}function Mt(t){Nt=t}class Ot{constructor(){this._listeners=new Map}add(t,e,n,o){t.addEventListener(e,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:t,eventType:e,listener:n}),i}remove(t){const e=this._listeners.get(t);if(e){const{eventTarget:n,eventType:o,listener:i}=e;n.removeEventListener(o,i),this._listeners.delete(t)}}removeAll(){
37
+ this._listeners.forEach((({eventTarget:t,eventType:e,listener:n})=>{t.removeEventListener(e,n)})),this._listeners.clear()}}function It(t){if(null===t||"object"!=typeof t)return!1;for(let e of["frame1","frame2","type"])if("string"!=typeof t[e])return!1;return!0}function Dt(t,e){return!!It(t)&&JSON.stringify(t,Object.keys(e).sort())===JSON.stringify(e,Object.keys(e).sort())}class Ht{constructor(t){this._hypothesisAppsOrigin=t,this._emitter=new Rt,this._sentChannels=new WeakMap,this._sidebarHostChannel=new MessageChannel,this._listeners=new Ot,this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}]}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&Dt(n,t)}on(t,e){this._emitter.on(t,e)}listen(){
38
38
  const t="Handling port request",e=new Set,n=n=>{e.has(n)||(e.add(n),Pt(new Error(n),t))};var o,i;this._listeners.add(window,"message",(o=t=>{const{data:e,origin:o,source:i}=t;if(!It(e)||"request"!==e.type)return;const{frame1:r,frame2:s}=e,a=`${r}-${s}`;if(!function(t){return!(null===t||t instanceof MessagePort||window.ServiceWorker&&t instanceof ServiceWorker)}(i))return void n(`Ignored port request for channel ${a} from non-Window source`);if(void 0===this._allowedMessages.find((({allowedOrigin:t,...n})=>this._messageMatches({allowedMessage:n,allowedOrigin:t,data:e,origin:o}))))return void n(`Ignored invalid port request for channel ${a} from ${o}`);let l=this._sentChannels.get(i);if(l||(l=new Set,this._sentChannels.set(i,l)),l.has(a))return;l.add(a);const c="sidebar-host"===a?this._sidebarHostChannel:new MessageChannel,h={frame1:r,frame2:s,type:"offer"},u="null"===o?"*":o;i.postMessage(h,u,[c.port1]),
39
39
  "sidebar"===s?this._sidebarHostChannel.port2.postMessage(h,[c.port2]):"host"===s&&this._emitter.emit("frameConnected",r,c.port2)},i=t,(...t)=>{try{return o(...t)}catch(t){throw Pt(t,i),t}}))}destroy(){this._listeners.removeAll()}}function Bt(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Ft(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Bt(e,i)}return e}function Vt(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t);return isNaN(e)?"string"==typeof t:Boolean(e)}function Ut(t,e,n){const o=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return o.href}function qt(t){
40
40
  const e=function(t){if(!t.hasOwnProperty("hypothesisConfig"))return{};if("function"!=typeof t.hypothesisConfig){const t="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+t),{}}return t.hypothesisConfig()}(t);let n;function o(t){return e.hasOwnProperty(t)?e[t]:n.hasOwnProperty(t)?n[t]:void 0}return n=Vt(e.ignoreOtherConfiguration)?{}:Ft(t.document),{get annotations(){return n.annotations||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return Ut(t,"hypothesis-client","javascript")},get group(){return n.group||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return Ut(t,"notebook","html")},get showHighlights(){return function(){let t=o("showHighlights");return void 0===t&&(t="always"),"boolean"==typeof t?t?"always":"never":t}()},get sidebarAppUrl(){
@@ -55,8 +55,8 @@ update(){this._updatePending||(this._updatePending=!0,requestAnimationFrame((()=
55
55
  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:de(t)?e[0]:e[e.length-1]}function me(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[];const n=[],o=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_TEXT);let i;for(;i=o.nextNode();){if(!fe(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&&ue(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.nodeValue)))));const l=[];return i.forEach((t=>{const n=document.createElement("hypothesis-highlight");n.className=e,
56
56
  t[0].parentNode.replaceChild(n,t[0]),t.forEach((t=>n.appendChild(t))),l.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");const o=CSS.supports("mix-blend-mode","multiply");if(!n){n=document.createElementNS("http://www.w3.org/2000/svg","svg"),n.setAttribute("class","hypothesis-highlight-layer"),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%",o?t.mixBlendMode="multiply":t.opacity="0.3"}const i=e.getBoundingClientRect(),r=t.map((t=>{const e=t.getBoundingClientRect(),n=document.createElementNS("http://www.w3.org/2000/svg","rect");return n.setAttribute("x",(e.left-i.left).toString()),n.setAttribute("y",(e.top-i.top).toString()),n.setAttribute("width",e.width.toString()),
57
57
  n.setAttribute("height",e.height.toString()),o?n.setAttribute("class","hypothesis-svg-highlight"):n.setAttribute("class","hypothesis-svg-highlight is-opaque"),t.classList.add("is-transparent"),t.svgHighlight=n,n}));n.append(...r)}(l),l}function _e(t,e){const n=t.parentNode;e.forEach((e=>n.insertBefore(e,t))),t.remove()}function ve(t){for(let e of t){if(e.parentNode){_e(e,Array.from(e.childNodes))}e.svgHighlight&&e.svgHighlight.remove()}}function ye(t,e){t.forEach((t=>{if(t.svgHighlight){if(t.svgHighlight.classList.toggle("is-focused",e),e){t.svgHighlight.parentNode.append(t.svgHighlight)}}else t.classList.toggle("hypothesis-highlight-focused",e)}))}function we(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)})))}
58
- var be=/^\s+|\s+$/g,Ce=/^[-+]0x[0-9a-f]+$/i,Ee=/^0b[01]+$/i,Se=/^0o[0-7]+$/i,xe=parseInt,Te="object"==typeof t&&t&&t.Object===Object&&t,Ae="object"==typeof self&&self&&self.Object===Object&&self,ke=Te||Ae||Function("return this")(),Ne=Object.prototype.toString,Re=Math.max,Le=Math.min,Pe=function(){return ke.Date.now()};function Me(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Oe(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Ne.call(t)}(t))return NaN;if(Me(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Me(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(be,"");var n=Ee.test(t);return n||Se.test(t)?xe(t.slice(2),n?2:8):Ce.test(t)?NaN:+t}var Ie=function(t,e,n){var o,i,r,s,a,l,c=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,c=e,s=t.apply(r,n)}function p(t){return c=t,a=setTimeout(m,e),h?f(t):s}
59
- function g(t){var n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=r}function m(){var t=Pe();if(g(t))return _(t);a=setTimeout(m,function(t){var n=e-(t-l);return u?Le(n,r-(t-c)):n}(t))}function _(t){return a=void 0,d&&o?f(t):(o=i=void 0,s)}function v(){var t=Pe(),n=g(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return p(l);if(u)return a=setTimeout(m,e),f(l)}return void 0===a&&(a=setTimeout(m,e)),s}return e=Oe(e)||0,Me(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Re(Oe(n.maxWait)||0,e):r,d="trailing"in n?!!n.trailing:d),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},v.flush=function(){return void 0===a?s:_(Pe())},v};class De{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Ie((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){
58
+ var be=/^\s+|\s+$/g,Ce=/^[-+]0x[0-9a-f]+$/i,Ee=/^0b[01]+$/i,Se=/^0o[0-7]+$/i,xe=parseInt,Te="object"==typeof t&&t&&t.Object===Object&&t,Ae="object"==typeof self&&self&&self.Object===Object&&self,ke=Te||Ae||Function("return this")(),Re=Object.prototype.toString,Ne=Math.max,Le=Math.min,Pe=function(){return ke.Date.now()};function Me(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Oe(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Re.call(t)}(t))return NaN;if(Me(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Me(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(be,"");var n=Ee.test(t);return n||Se.test(t)?xe(t.slice(2),n?2:8):Ce.test(t)?NaN:+t}var Ie=function(t,e,n){var o,i,r,s,a,l,c=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,c=e,s=t.apply(r,n)}function p(t){return c=t,a=setTimeout(m,e),h?f(t):s}
59
+ function g(t){var n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=r}function m(){var t=Pe();if(g(t))return _(t);a=setTimeout(m,function(t){var n=e-(t-l);return u?Le(n,r-(t-c)):n}(t))}function _(t){return a=void 0,d&&o?f(t):(o=i=void 0,s)}function v(){var t=Pe(),n=g(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return p(l);if(u)return a=setTimeout(m,e),f(l)}return void 0===a&&(a=setTimeout(m,e)),s}return e=Oe(e)||0,Me(n)&&(h=!!n.leading,r=(u="maxWait"in n)?Ne(Oe(n.maxWait)||0,e):r,d="trailing"in n?!!n.trailing:d),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},v.flush=function(){return void 0===a?s:_(Pe())},v};class De{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(Ie((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){
60
60
  this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(t){this._annotatableFrames.add(t);try{if(await He(t),this._isDisconnected)return;t.contentWindow.addEventListener("unload",(()=>{this._removeFrame(t)})),this._onFrameAdded(t)}catch(e){console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${t.src}')`)}}_removeFrame(t){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 He(t){return new Promise((e=>{const n=t.contentWindow.document,{readyState:o,location:i}=n;"about:blank"===i.href&&t.hasAttribute("src")&&"about:blank"!==t.src?t.addEventListener("load",(()=>{e()})):"loading"!==o?e():n.addEventListener("DOMContentLoaded",(()=>e()))}))}class Be{constructor(t,e){this._config=e,
61
61
  this._frameObserver=new De(t,(t=>this.injectClient(t)),(()=>{}))}destroy(){this._frameObserver.disconnect()}async injectClient(t){if("__hypothesis"in t.contentWindow)return;await He(t);const{assetRoot:e,notebookAppUrl:n,sidebarAppUrl:o}=Ft(document),i=Gt(10),r={...this._config,assetRoot:e,notebookAppUrl:n,sidebarAppUrl:o,subFrameIdentifier:i},{clientUrl:s}=this._config;!function(t,e,n){const o=document.createElement("script");o.className="js-hypothesis-config",o.type="application/json",o.innerText=JSON.stringify(n);const i=document.createElement("script");i.async=!0,i.src=e;const r=t.contentDocument;r.body.appendChild(o),r.body.appendChild(i)}(t,s,r)}}function Fe(t,e,n){t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function Ve(t){var e=t._scrollSettings;if(e){var n=e.maxSynchronousAlignments,o=function(t,e){
62
62
  var n,o,i,r,s,a,l,c=t.align,h=t.target.getBoundingClientRect(),u=c&&null!=c.left?c.left:.5,d=c&&null!=c.top?c.top:.5,f=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,g=u,m=d;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),l=Math.min(h.height,e.innerHeight),o=h.left+e.pageXOffset-e.innerWidth*g+a*g,i=h.top+e.pageYOffset-e.innerHeight*m+l*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,l=h.height,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+l*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 Fe(t,o.x,o.y),
@@ -74,11 +74,11 @@ type:"application/pdf"})}catch(t){}if("doi"===n)for(let t of o)"doi:"!==t.slice(
74
74
  }destroy(){}contentContainer(){return this.container}fitSideBySide(){return!1}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}scrollToAnchor(t){const e=t.highlights;return new Promise((t=>{$e(e[0],t)}))}}let pn={};function gn(...t){const e=t.join();e in pn||(console.warn(...t),pn[e]=!0)}gn.reset=()=>{pn={}};const mn=0,_n=3,vn=new Map,yn=new Map;function wn(t,e){return`${t}:${e}`}function bn(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 Cn(){return PDFViewerApplication.pdfViewer}async function En(t){const e=Cn();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 Sn(t){const e=vn.get(t);if(e)return e;const n=(async()=>{
75
75
  const e=await En(t);let n=(await e.pdfPage.getTextContent({normalizeWhitespace:!0})).items;return n.length>0&&!("hasEOL"in n[0])&&(n=n.filter((t=>/\S/.test(t.str)))),n.map((t=>t.str)).join("")})();return vn.set(t,n),n}async function xn(t){const e=Cn();let n=0,o=0,i="";for(let r=0;r<e.pagesCount;r++)if(i=await Sn(r),n=o,o+=i.length,o>=t)return{index:r,offset:n,text:i};return{index:e.pagesCount-1,offset:n,text:i}}async function Tn(t,e,n){const[o,i]=await Promise.all([En(t),Sn(t)]);if(o.renderingState===_n&&o.textLayer&&o.textLayer.renderingDone){const t=o.textLayer.textLayerDiv;i!==t.textContent&&gn("PDF text layer content does not match page text. This will cause anchoring misalignment.");const r=new le(t,e),s=new le(t,n);return new ce(r,s).toRange()}const r=function(t){let e=t.querySelector(".annotator-placeholder");return e||(e=document.createElement("span"),e.classList.add("annotator-placeholder"),e.textContent="Loading annotations...",t.appendChild(e),e)}(o.div),s=document.createRange()
76
76
  ;return s.setStartBefore(r),s.setEndAfter(r),s}function An(t){const e=[];let n="";for(let o=0;o<t.length;o++){const i=t[o];" "!==i&&"\t"!==i&&"\n"!==i&&(n+=i,e.push(o))}return[n,e]}async function kn(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 xn(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 Tn(t,r,s)}catch{}try{const t=wn(n.exact,o.start),e=yn.get(t);if(e){const{pageIndex:t,anchor:n}=e;return await Tn(t,n.start,n.end)}}catch{}}return async function(t,e){const n=Cn().pagesCount,o=Array(n).fill(0).map(((t,e)=>e));let i,r;if(e){const{index:t,offset:n}=await xn(e);i=t,r=e-n,o.sort(((e,n)=>Math.abs(e-t)-Math.abs(n-t)))}const[s]=void 0!==t.prefix?An(t.prefix):[],[a]=void 0!==t.suffix?An(t.suffix):[],[l]=An(t.exact);let c;for(let t of o){const e=await Sn(t),[n,o]=An(e);let h
77
- ;if(void 0!==i&&void 0!==r){let n;for(n=t<i?e.length:t===i?r:0,h=0;h<o.length&&o[h]<n;)++h}const u=Qe(n,l,{prefix:s,suffix:a,hint:h});if(u&&(!c||u.score>c.match.score)){c={page:t,match:{start:o[u.start],end:o[u.end-1]+1,score:u.score}};const e=n.slice(u.start,u.end)===l,i=void 0!==s&&n.slice(Math.max(0,u.start-s.length),u.start)===s,r=void 0!==a&&n.slice(u.end,a.length)===a,h=void 0!==s||void 0!==a;if(e&&(i||r||!h))break}}if(c){const{page:n,match:o}=c;if(e){const i=wn(t.exact,e);yn.set(i,{pageIndex:n,anchor:o})}return Tn(n,o.start,o.end)}throw new Error("Quote not found")}(n,null==o?void 0:o.start)}function Nn(t){try{t=ce.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}const e=bn(t.startContainer),n=bn(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 Rn(t,e){
78
- const[n,o]=Nn(e),i=le.fromPoint(n.startContainer,n.startOffset).relativeTo(o),r=le.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>=Cn().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await Sn(n)).length;return e}(s);return[{type:"TextPositionSelector",start:a+i.offset,end:a+r.offset},an.fromRange(t,n).toSelector()]}function Ln(){return mt("div",{className:"WarningBanner WarningBanner--notice",children:[mt("div",{className:"WarningBanner__type",children:mt(vt,{name:"caution",className:"WarningBanner__icon"})}),mt("div",{className:"WarningBanner__message",children:[mt("strong",{children:"This PDF does not contain selectable text:"})," ",mt("a",{target:"_blank",rel:"noreferrer",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})}function Pn(t,e,n){
77
+ ;if(void 0!==i&&void 0!==r){let n;for(n=t<i?e.length:t===i?r:0,h=0;h<o.length&&o[h]<n;)++h}const u=Qe(n,l,{prefix:s,suffix:a,hint:h});if(u&&(!c||u.score>c.match.score)){c={page:t,match:{start:o[u.start],end:o[u.end-1]+1,score:u.score}};const e=n.slice(u.start,u.end)===l,i=void 0!==s&&n.slice(Math.max(0,u.start-s.length),u.start)===s,r=void 0!==a&&n.slice(u.end,a.length)===a,h=void 0!==s||void 0!==a;if(e&&(i||r||!h))break}}if(c){const{page:n,match:o}=c;if(e){const i=wn(t.exact,e);yn.set(i,{pageIndex:n,anchor:o})}return Tn(n,o.start,o.end)}throw new Error("Quote not found")}(n,null==o?void 0:o.start)}function Rn(t){try{t=ce.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}const e=bn(t.startContainer),n=bn(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 Nn(t,e){
78
+ const[n,o]=Rn(e),i=le.fromPoint(n.startContainer,n.startOffset).relativeTo(o),r=le.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>=Cn().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await Sn(n)).length;return e}(s);return[{type:"TextPositionSelector",start:a+i.offset,end:a+r.offset},an.fromRange(t,n).toSelector()]}function Ln(){return mt("div",{className:"WarningBanner WarningBanner--notice",children:[mt("div",{className:"WarningBanner__type",children:mt(vt,{name:"caution",className:"WarningBanner__icon"})}),mt("div",{className:"WarningBanner__message",children:[mt("strong",{children:"This PDF does not contain selectable text:"})," ",mt("a",{target:"_blank",rel:"noreferrer",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})}function Pn(t,e,n){
79
79
  return t+n*(e-t)}async function Mn(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=Pn(o,i,a)}class On{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),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=Hn(t);return e||(e=Dn(In(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:o}=await t.pdfDocument.getMetadata(),i=In(t),r=Hn(t);let s
80
80
  ;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:Dn(i)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:i}}}function In(t){return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function Dn(t){return`urn:x-pdf:${t}`}function Hn(t){if(!t.url)return null;const e=un(t.url);return 0!==e.indexOf("file://")?e:null}function Bn(t){var e;const n=null===(e=t.highlights)||void 0===e?void 0:e[0];return n&&ue(n)}function Fn(t){return new Promise((e=>setTimeout(e,t)))}class Vn{constructor(t,e={}){var n,o,i;this.annotator=t;const r=window,s=r.PDFViewerApplication;this.pdfViewer=s.pdfViewer,this.pdfViewer.viewer.classList.add("has-transparent-text-layer"),this.pdfContainer=null!==(n=null===(o=s.appConfig)||void 0===o?void 0:o.appContainer)&&void 0!==n?n:document.body,this.pdfMetadata=new On(s),
81
- this.observer=new MutationObserver(Ie((()=>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._warningBanner=null,this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=r.getSelection();this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Ot,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._warningBanner)||void 0===t||t.remove(),this._destroyed=!0}uri(){return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}anchor(t,e){return kn(0,e)}canAnnotate(t){return function(t){try{return Nn(t),!0}catch{return!1}}(t)}describe(t,e){return Rn(t,e)}
81
+ this.observer=new MutationObserver(Ie((()=>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._warningBanner=null,this._checkForSelectableText(),this._updateAnnotationLayerVisibility=()=>{const t=r.getSelection();this.pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new Ot,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._warningBanner)||void 0===t||t.remove(),this._destroyed=!0}uri(){return this.pdfMetadata.getUri()}getMetadata(){return this.pdfMetadata.getMetadata()}anchor(t,e){return kn(0,e)}canAnnotate(t){return function(t){try{return Rn(t),!0}catch{return!1}}(t)}describe(t,e){return Nn(t,e)}
82
82
  async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._destroyed)try{const t=await async function(){const t=Cn();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await Sn(n)).trim().length>0){e=!0;break}return e}();this._toggleNoSelectableTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_toggleNoSelectableTextWarning(t){const e=document.querySelector("#outerContainer");var n;if(!t)return null===(n=this._warningBanner)||void 0===n||n.remove(),this._warningBanner=null,void(e.style.height="");this._warningBanner=document.createElement("hypothesis-banner"),document.body.prepend(this._warningBanner);const o=ne(this._warningBanner);P(mt(Ln,{}),o);const i=this._warningBanner.getBoundingClientRect().height;e.style.height=`calc(100% - ${i}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 mn:e.textLayer=null
83
83
  ;break;case _n:o=e.div,i=void 0,null===(i=o.querySelector(".annotator-placeholder"))||void 0===i||i.remove()}}var o,i;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=Bn(t),o=this._anchorOffset(t);if(null!==o&&(await Mn(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return
84
84
  ;const n=this._anchorOffset(t);if(null===n)return;await Mn(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){var n;const o=Date.now();let i;do{i=this.annotator.anchors.find((e=>e.annotation===t)),i&&!Bn(i)||(i=null,await Fn(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())}}function Un(t,e){return t?{left:Math.min(t.left,e.left),right:Math.max(t.right,e.right),top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom)}:e}class qn{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.mixBlendMode="multiply";const r="sans-serif"
@@ -86,48 +86,48 @@ async _checkForSelectableText(){try{await this.uri()}catch(t){return}if(!this._d
86
86
  this._listeners.add(window,"resize",this._updateBoxSizes)}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateBoxSizes.cancel()}}function Wn(t=document){return t.querySelector("mosaic-book")}class jn{constructor(t){const e=Wn();if(!e)throw new Error("Book container element not found");const n=e.shadowRoot,o=()=>{const e=n.querySelector("iframe");e&&t.injectClient(e)};o(),this._frameObserver=new MutationObserver(o),this._frameObserver.observe(n,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}canAnnotate(){return!1}async anchor(){return new Range}describe(){throw new Error("This frame cannot be annotated")}contentContainer(){return document.body}fitSideBySide(){return!1}async getMetadata(){return{title:"",link:[]}}async uri(){return document.location.href}async scrollToAnchor(){}}class $n{constructor(t=document.body){this._htmlIntegration=new fn(t),this._listeners=new Ot;const e=["mousedown","mouseup","mouseout"]
87
87
  ;for(let t of e)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const n=document.querySelector("#pbk-page"),o=window.innerPageData;n&&o&&(this._textLayer=new qn(n,o.glyphs.glyphs.map((t=>({left:t.l/100,right:t.r/100,top:t.t/100,bottom:t.b/100}))),o.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(){return this._htmlIntegration.contentContainer()}fitSideBySide(){return!1}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 zn(t){if("undefined"!=typeof PDFViewerApplication)return new Vn(t);const e=function(t=window){var e
88
88
  ;if(Wn(t.document))return"container";const n=null===(e=t.frameElement)||void 0===e?void 0:e.ownerDocument;return n&&Wn(n)?"content":null}();return"container"===e?new jn(t):"content"===e?new $n:new fn}class Xn{constructor(t,e=document){let n=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(function(t){const e=t.getSelection();if(!e||0===e.rangeCount)return null;const n=e.getRangeAt(0);return n.collapsed?null:n}(e))}),n)};this._eventHandler=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 Ot,this._events=["mousedown","mouseup","selectionchange"];for(let t of this._events)this._listeners.add(e,t,this._eventHandler);o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function Yn(){const t=function(t,e){
89
- 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 ie(this.element,{onAnnotate:async()=>{await this.createAnnotation()},onHighlight:async()=>{await this.createAnnotation({highlight:!0})},onShowAnnotations:t=>{this.selectAnnotations(t)}}),
90
- 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 zt({hostFrame:this._hostFrame,source:"guest"}),this._hostRPC=new Xt,this._connectHostEvents(),this._sidebarRPC=new Xt,this._connectSidebarEvents(),this._hypothesisInjector=new Be(this.element,e),this._integration=zn(this),this._bucketBarClient=null===this._frameIdentifier?new he({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}):null,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;this.selectAnnotations(i,t)
91
- }})),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=>{this._frameIdentifier!==t&&(this._informHostOnNextSelectionClear=!1,Kn())})),
92
- 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.connect(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=>{this.getDocumentInfo().then((e=>t(null,e))).catch((e=>t(e)))})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(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.connect(t)}destroy(){var t;this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),null===(t=this._bucketBarClient)||void 0===t||t.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=me(e);n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ye(n,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[])
94
- ;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=ce.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){var n;(this.anchors=t,e)&&(null===(n=this._bucketBarClient)||void 0===n||n.update())}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:"+Gt(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=ge(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}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,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.963.0";const i=new URL(window.location.href);if(i.hash="",o.hostURL=i.toString(),(null===(n=o.services)||void 0===n?void 0:n.length)>0){const t=o.services[0]
89
+ 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);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 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)).map((t=>null==t?void 0:t.$tag));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 ie(this.element,{onAnnotate:()=>this.createAnnotation(),onHighlight:()=>this.createAnnotation({highlight:!0
90
+ }),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 zt({hostFrame:this._hostFrame,source:"guest"}),this._hostRPC=new Xt,this._connectHostEvents(),this._sidebarRPC=new Xt,this._connectSidebarEvents(),this._hypothesisInjector=new Be(this.element,e),this._integration=zn(this),this._bucketBarClient=null===this._frameIdentifier?new he({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}):null,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)
91
+ ;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=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()})),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,e))),this._hostRPC.on("sidebarLayoutChanged",(t=>{null===this._frameIdentifier&&this.fitSideBySide(t)}));const t=await this._portFinder.discover("host");this._hostRPC.connect(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)})),
93
+ this._sidebarRPC.on("getDocumentInfo",(t=>{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.connect(t)}destroy(){var t;this._portFinder.destroy(),this._notifyGuestUnload(),this._hypothesisInjector.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),null===(t=this._bucketBarClient)||void 0===t||t.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=me(e);n.forEach((e=>{
94
+ e._annotation=t.annotation})),t.highlights=n,this._focusedAnnotations.has(t.annotation.$tag)&&ye(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=ce.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){var n;(this.anchors=t,e)&&(null===(n=this._bucketBarClient)||void 0===n||n.update())}
95
+ 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:"+Gt(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Kn(),r}_focusAnnotations(t){this._sidebarRPC.call("focusAnnotations",t)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=de(e),o=ge(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}
96
+ selectAnnotations(t,e=!1){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t),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}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,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.964.0";const i=new URL(window.location.href);if(i.hash="",o.hostURL=i.toString(),(null===(n=o.services)||void 0===n?void 0:n.length)>0){const t=o.services[0]
97
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 o}function eo({config:t,groupId:e}){return mt("iframe",{title:"Hypothesis annotation notebook",className:"NotebookIframe",allowFullScreen:!0,src:Qn(t.notebookAppUrl,{...to(t.notebookAppUrl,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:mt("div",{className:Z("NotebookModal__outer",{"is-hidden":i}),children:mt("div",{className:"NotebookModal__inner",children:[mt("div",{
98
98
  className:"NotebookModal__close-button-container",children:mt(Ct,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),mt(eo,{config:e,groupId:s},n)]})})}class oo{constructor(t,e,n={}){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=ne(this._outerContainer),P(mt(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
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 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)}}
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
- 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,B=["x","y"],F=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function U(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=q(e));r>1&&!n.firstMultiple?n.firstMultiple=q(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},
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 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 N=1;function L(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}
101
+ var P="ontouchstart"in e,M=R(e,"PointerEvent")!==i,O=P&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),I="touch",D="mouse",H=24,B=["x","y"],F=["clientX","clientY"];function V(t,e){var n=this;this.manager=t,this.callback=e,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(e){y(t.options.enable,[t])&&n.handler(e)},this.init()}function U(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=q(e));r>1&&!n.firstMultiple?n.firstMultiple=q(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=$(e.deltaX,e.deltaY);var d=j(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],F)/z(f[0],f[1],F)):1,e.rotation=a?function(t,e){return X(e[1],e[0],F)+X(t[1],t[0],F)}(a.pointers,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=j(l,h,u);o=d.x,r=d.y,n=c(d.x)>c(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;E(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}
103
103
  function q(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 j(t,e,n){return{x:e/t||0,y:n/t||0}}function $(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=B);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=B);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),
104
104
  this.evTarget&&C(this.target,this.evTarget,this.domHandler),this.evWin&&C(L(this.element),this.evWin,this.domHandler)}};var Y={mousedown:1,mousemove:2,mouseup:4},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){
105
105
  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 lt={touchstart:1,touchmove:2,touchend:4,touchcancel:8},ct="touchstart touchmove touchend touchcancel"
106
106
  ;function ht(){this.evTarget=ct,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=[],l=this.target;if(r=n.filter((function(t){return E(t.target,l)})),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=lt[t.type],n=ut.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:I,srcEvent:t})}});function dt(){V.apply(this,arguments);var t=v(this.handler,this);this.touch=new ht(this.manager,t),this.mouse=new K(this.manager,t),this.primaryTouch=null,this.lastTouches=[]}function ft(t,e){1&t?(this.primaryTouch=e.changedPointers[0].identifier,pt.call(this,e)):12&t&&pt.call(this,e)}function pt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={
107
- 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&&gt.call(this,n))return;this.callback(t,e,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var mt=N(a.style,"touchAction"),_t=mt!==i,vt="compute",yt="auto",wt="manipulation",bt="none",Ct="pan-x",Et="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 xt(t,e){this.manager=t,this.set(e)}xt.prototype={set:function(t){
108
- t==vt&&(t=this.compute()),_t&&this.manager.element.style&&St[t]&&(this.manager.element.style[mt]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return f(this.manager.recognizers,(function(e){y(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(S(t,bt))return bt;var e=S(t,Ct),n=S(t,Et);if(e&&n)return bt;if(e||n)return e?Ct:Et;if(S(t,wt))return wt;return yt}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var o=this.actions,i=S(o,bt)&&!St.none,r=S(o,Et)&&!St["pan-y"],s=S(o,Ct)&&!St["pan-x"];if(i){var a=1===t.pointers.length,l=t.distance<2,c=t.deltaTime<250;if(a&&l&&c)return}if(!s||!r)return i||r&&6&n||s&&n&H?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var Tt=32;function At(t){this.options=r({},this.defaults,t||{}),this.id=R++,this.manager=null,
109
- this.options.enable=w(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function kt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Nt(t){return 16==t?"down":8==t?"up":2==t?"left":4==t?"right":""}function Rt(t,e){var n=e.manager;return n?n.get(t):t}function Lt(){At.apply(this,arguments)}function Pt(){Lt.apply(this,arguments),this.pX=null,this.pY=null}function Mt(){Lt.apply(this,arguments)}function Ot(){At.apply(this,arguments),this._timer=null,this._input=null}function It(){Lt.apply(this,arguments)}function Dt(){Lt.apply(this,arguments)}function Ht(){At.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Bt(t,e){return(e=e||{}).recognizers=w(e.recognizers,Bt.defaults.preset),new Ft(t,e)}At.prototype={defaults:{},set:function(t){return r(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(d(t,"recognizeWith",this))return this;var e=this.simultaneous
110
- ;return e[(t=Rt(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return d(t,"dropRecognizeWith",this)||(t=Rt(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(d(t,"requireFailure",this))return this;var e=this.requireFail;return-1===T(e,t=Rt(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(d(t,"dropRequireFailure",this))return this;t=Rt(t,this);var e=T(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function o(n){e.manager.emit(n,t)}n<8&&o(e.options.event+kt(n)),o(e.options.event),t.additionalEvent&&o(t.additionalEvent),n>=8&&o(e.options.event+kt(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=Tt},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}
107
+ 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&&gt.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",Et="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 xt(t,e){this.manager=t,this.set(e)}xt.prototype={set:function(t){
108
+ t==vt&&(t=this.compute()),_t&&this.manager.element.style&&St[t]&&(this.manager.element.style[mt]=t),this.actions=t.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var t=[];return f(this.manager.recognizers,(function(e){y(e.options.enable,[e])&&(t=t.concat(e.getTouchAction()))})),function(t){if(S(t,bt))return bt;var e=S(t,Ct),n=S(t,Et);if(e&&n)return bt;if(e||n)return e?Ct:Et;if(S(t,wt))return wt;return yt}(t.join(" "))},preventDefaults:function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var o=this.actions,i=S(o,bt)&&!St.none,r=S(o,Et)&&!St["pan-y"],s=S(o,Ct)&&!St["pan-x"];if(i){var a=1===t.pointers.length,l=t.distance<2,c=t.deltaTime<250;if(a&&l&&c)return}if(!s||!r)return i||r&&6&n||s&&n&H?this.preventSrc(e):void 0}},preventSrc:function(t){this.manager.session.prevented=!0,t.preventDefault()}};var Tt=32;function At(t){this.options=r({},this.defaults,t||{}),this.id=N++,this.manager=null,
109
+ this.options.enable=w(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function kt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}function Rt(t){return 16==t?"down":8==t?"up":2==t?"left":4==t?"right":""}function Nt(t,e){var n=e.manager;return n?n.get(t):t}function Lt(){At.apply(this,arguments)}function Pt(){Lt.apply(this,arguments),this.pX=null,this.pY=null}function Mt(){Lt.apply(this,arguments)}function Ot(){At.apply(this,arguments),this._timer=null,this._input=null}function It(){Lt.apply(this,arguments)}function Dt(){Lt.apply(this,arguments)}function Ht(){At.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Bt(t,e){return(e=e||{}).recognizers=w(e.recognizers,Bt.defaults.preset),new Ft(t,e)}At.prototype={defaults:{},set:function(t){return r(this.options,t),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(t){if(d(t,"recognizeWith",this))return this;var e=this.simultaneous
110
+ ;return e[(t=Nt(t,this)).id]||(e[t.id]=t,t.recognizeWith(this)),this},dropRecognizeWith:function(t){return d(t,"dropRecognizeWith",this)||(t=Nt(t,this),delete this.simultaneous[t.id]),this},requireFailure:function(t){if(d(t,"requireFailure",this))return this;var e=this.requireFail;return-1===T(e,t=Nt(t,this))&&(e.push(t),t.requireFailure(this)),this},dropRequireFailure:function(t){if(d(t,"dropRequireFailure",this))return this;t=Nt(t,this);var e=T(this.requireFail,t);return e>-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){var e=this,n=this.state;function o(n){e.manager.emit(n,t)}n<8&&o(e.options.event+kt(n)),o(e.options.event),t.additionalEvent&&o(t.additionalEvent),n>=8&&o(e.options.event+kt(n))},tryEmit:function(t){if(this.canEmit())return this.emit(t);this.state=Tt},canEmit:function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}
111
111
  return!0},recognize:function(t){var e=r({},t);if(!y(this.options.enable,[this,e]))return this.reset(),void(this.state=Tt);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},process:function(t){},getTouchAction:function(){},reset:function(){}},_(Lt,At,{defaults:{pointers:1},attrTest:function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},process:function(t){var e=this.state,n=t.eventType,o=6&e,i=this.attrTest(t);return o&&(8&n||!i)?16|e:o||i?4&n?8|e:2&e?4|e:2:Tt}}),_(Pt,Lt,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var t=this.options.direction,e=[];return 6&t&&e.push(Et),t&H&&e.push(Ct),e},directionTest:function(t){var e=this.options,n=!0,o=t.distance,i=t.direction,r=t.deltaX,s=t.deltaY;return i&e.direction||(6&e.direction?(i=0===r?1:r<0?2:4,n=r!=this.pX,o=Math.abs(t.deltaX)):(i=0===s?1:s<0?8:16,n=s!=this.pY,o=Math.abs(t.deltaY))),t.direction=i,n&&o>e.threshold&&i&e.direction},attrTest:function(t){
112
- return Lt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Nt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),_(Mt,Lt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[bt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),_(Ot,At,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,o=t.distance<e.threshold,i=t.deltaTime>e.time;if(this._input=t,!o||!n||12&t.eventType&&!i)this.reset();else if(1&t.eventType)this.reset(),this._timer=u((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return Tt},
113
- reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=h(),this.manager.emit(this.options.event,this._input)))}}),_(It,Lt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[bt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),_(Dt,Lt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Pt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:n&H&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&c(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=Nt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),
112
+ return Lt.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Rt(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),_(Mt,Lt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[bt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),_(Ot,At,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[yt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,o=t.distance<e.threshold,i=t.deltaTime>e.time;if(this._input=t,!o||!n||12&t.eventType&&!i)this.reset();else if(1&t.eventType)this.reset(),this._timer=u((function(){this.state=8,this.tryEmit()}),e.time,this);else if(4&t.eventType)return 8;return Tt},
113
+ reset:function(){clearTimeout(this._timer)},emit:function(t){8===this.state&&(t&&4&t.eventType?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=h(),this.manager.emit(this.options.event,this._input)))}}),_(It,Lt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[bt]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||2&this.state)}}),_(Dt,Lt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Pt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,n=this.options.direction;return 30&n?e=t.overallVelocity:6&n?e=t.overallVelocityX:n&H&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&n&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&c(e)>this.options.velocity&&4&t.eventType},emit:function(t){var e=Rt(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),
114
114
  this.manager.emit(this.options.event,t)}}),_(Ht,At,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[wt]},process:function(t){var e=this.options,n=t.pointers.length===e.pointers,o=t.distance<e.threshold,i=t.deltaTime<e.time;if(this.reset(),1&t.eventType&&0===this.count)return this.failTimeout();if(o&&i&&n){if(4!=t.eventType)return this.failTimeout();var r=!this.pTime||t.timeStamp-this.pTime<e.interval,s=!this.pCenter||z(this.pCenter,t.center)<e.posThreshold;if(this.pTime=t.timeStamp,this.pCenter=t.center,s&&r?this.count+=1:this.count=1,this._input=t,0===this.count%e.taps)return this.hasRequireFailures()?(this._timer=u((function(){this.state=8,this.tryEmit()}),e.interval,this),2):8}return Tt},failTimeout:function(){return this._timer=u((function(){this.state=Tt}),this.options.interval,this),Tt},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,
115
- this.manager.emit(this.options.event,this._input))}}),Bt.VERSION="2.0.7",Bt.defaults={domEvents:!1,touchAction:vt,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Mt,{enable:!1},["rotate"]],[Dt,{direction:6}],[Pt,{direction:6},["swipe"]],[Ht],[Ht,{event:"doubletap",taps:2},["tap"]],[Ot]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Ft(t,e){var n;this.options=r({},Bt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(M?nt:O?ht:P?dt:K))(n,U),this.touchAction=new xt(this,this.options.touchAction),Vt(this,!0),f(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Vt(t,e){var n,o=t.element;o.style&&(f(t.options.cssProps,(function(i,r){n=N(o.style,r),
115
+ this.manager.emit(this.options.event,this._input))}}),Bt.VERSION="2.0.7",Bt.defaults={domEvents:!1,touchAction:vt,enable:!0,inputTarget:null,inputClass:null,preset:[[It,{enable:!1}],[Mt,{enable:!1},["rotate"]],[Dt,{direction:6}],[Pt,{direction:6},["swipe"]],[Ht],[Ht,{event:"doubletap",taps:2},["tap"]],[Ot]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Ft(t,e){var n;this.options=r({},Bt.defaults,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(M?nt:O?ht:P?dt:K))(n,U),this.touchAction=new xt(this,this.options.touchAction),Vt(this,!0),f(this.options.recognizers,(function(t){var e=this.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])}),this)}function Vt(t,e){var n,o=t.element;o.style&&(f(t.options.cssProps,(function(i,r){n=R(o.style,r),
116
116
  e?(t.oldCssProps[n]=o.style[n],o.style[n]=i):o.style[n]=t.oldCssProps[n]||""})),e||(t.oldCssProps={}))}Ft.prototype={set:function(t){return r(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},stop:function(t){this.session.stopped=t?2:1},recognize:function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var o=this.recognizers,i=e.curRecognizer;(!i||i&&8&i.state)&&(i=e.curRecognizer=null);for(var r=0;r<o.length;)n=o[r],2===e.stopped||i&&n!=i&&!n.canRecognizeWith(i)?n.reset():n.recognize(t),!i&&14&n.state&&(i=e.curRecognizer=n),r++}},get:function(t){if(t instanceof At)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event==t)return e[n];return null},add:function(t){if(d(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),t.manager=this,this.touchAction.update(),t},remove:function(t){
117
117
  if(d(t,"remove",this))return this;if(t=this.get(t)){var e=this.recognizers,n=T(e,t);-1!==n&&(e.splice(n,1),this.touchAction.update())}return this},on:function(t,e){if(t!==i&&e!==i){var n=this.handlers;return f(x(t),(function(t){n[t]=n[t]||[],n[t].push(e)})),this}},off:function(t,e){if(t!==i){var n=this.handlers;return f(x(t),(function(t){e?n[t]&&n[t].splice(T(n[t],e),1):delete n[t]})),this}},emit:function(t,e){this.options.domEvents&&function(t,e){var o=n.createEvent("Event");o.initEvent(t,!0,!0),o.gesture=e,e.target.dispatchEvent(o)}(t,e);var o=this.handlers[t]&&this.handlers[t].slice();if(o&&o.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var i=0;i<o.length;)o[i](e),i++}},destroy:function(){this.element&&Vt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},r(Bt,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Tt,
118
- DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:H,DIRECTION_ALL:30,Manager:Ft,Input:V,TouchAction:xt,TouchInput:ht,MouseInput:K,PointerEventInput:nt,TouchMouseInput:dt,SingleTouchInput:st,Recognizer:At,AttrRecognizer:Lt,Tap:Ht,Pan:Pt,Swipe:Dt,Pinch:Mt,Rotate:It,Press:Ot,on:b,off:C,each:f,merge:m,extend:g,assign:r,inherit:_,bindFn:v,prefixed:N}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Bt,t.exports?t.exports=Bt:e.Hammer=Bt}(window,document)}(io);var ro=io.exports;function so(t){const e=function(t){const e=[];return t.forEach((t=>{var n;if(null===(n=t.highlights)||void 0===n||!n.length)return;const o=we(t.highlights);o.top>=o.bottom||e.push({top:o.top,bottom:o.bottom,anchor:t})})),e.sort(((t,e)=>t.top<e.top?-1:1)),e}(t),n=new Set,o=new Set,i=[];let r=null;function s(t){const e=t.bottom-t.top,n=t.top+e/2;return{anchors:[t.anchor],top:t.top,bottom:t.bottom,position:n}}e.forEach((t=>{
119
- if(t.top<137)return void n.add(t.anchor);if(t.top>window.innerHeight-22)return void o.add(t.anchor);if(!r)return void(r=s(t));const e=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!e)i.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t.anchor),r.bottom=e,r.position=r.top+n/2}})),r&&i.push(r);return{above:{anchors:Array.from(n),position:137},below:{anchors:Array.from(o),position:window.innerHeight-22},buckets:i}}function ao({bucket:t,onSelectAnnotations:e}){const n=t.anchors.map((t=>t.annotation)),o=`Select nearby annotations (${t.anchors.length})`;function i(e){t.anchors.forEach((t=>{ye(t.highlights||[],e)}))}return mt("button",{className:"Buckets__button Buckets__button--left",onClick:t=>function(t){e(n,t.metaKey||t.ctrlKey)}(t),onMouseMove:()=>i(!0),onMouseOut:()=>i(!1),onBlur:()=>i(!1),title:o,"aria-label":o,children:t.anchors.length})}function lo({bucket:t,direction:e,scrollToAnchor:n}){const o=`Go ${e} to next annotations (${t.anchors.length})`
120
- ;return mt("button",{className:Z("Buckets__button",`Buckets__button--${e}`),onClick:function(){const o=function(t,e){let n=null,o=0;for(let r of t){var i;if(null===(i=r.highlights)||void 0===i||!i.length)continue;const t=we(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}(t.anchors,e);o&&n(o)},title:o,"aria-label":o,children:t.anchors.length})}function co({above:t,below:e,buckets:n,onSelectAnnotations:o,scrollToAnchor:i}){const r=t.anchors.length>0,s=e.anchors.length>0;return mt("ul",{className:"Buckets__list",children:[r&&mt("li",{className:"Buckets__bucket",style:{top:t.position},children:mt(lo,{bucket:t,direction:"up",scrollToAnchor:i})}),n.map(((t,e)=>mt("li",{className:"Buckets__bucket",style:{top:t.position},children:mt(ao,{bucket:t,onSelectAnnotations:o})},e))),s&&mt("li",{className:"Buckets__bucket",style:{top:e.position},children:mt(lo,{bucket:e,direction:"down",scrollToAnchor:i})})]})}class ho{constructor(t,e){
121
- this._bucketsContainer=document.createElement("div"),t.appendChild(this._bucketsContainer),this._guest=e,this.update()}destroy(){P(null,this._bucketsContainer),this._bucketsContainer.remove()}update(){const t=so(this._guest.anchors);P(mt(co,{above:t.above,below:t.below,buckets:t.buckets,onSelectAnnotations:(t,e)=>this._guest.selectAnnotations(t,e),scrollToAnchor:t=>this._guest.scrollToAnchor(t)}),this._bucketsContainer)}}let uo={};const fo=t=>{uo=t||{}},po=function(t){t.on("featureFlagsUpdated",fo)};function go({buttonRef:t,expanded:e,className:n="Toolbar__button",label:o,icon:i,onClick:r,selected:s=!1}){return mt("button",{className:n,"aria-label":o,"aria-expanded":e,"aria-pressed":s,onClick:r,ref:t,title:o,children:mt(vt,{name:i})})}function mo({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:o,showHighlights:i,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return mt("div",{className:"Toolbar",children:[l&&n&&mt(go,{className:"Toolbar__sidebar-close",
122
- label:"Close annotation sidebar",icon:"cancel",onClick:t}),!l&&mt(go,{className:"Toolbar__sidebar-toggle",buttonRef:a,label:"Annotation sidebar",icon:n?"caret-right":"caret-left",expanded:n,onClick:s}),!l&&mt("div",{className:"Toolbar__buttonbar",children:[mt(go,{label:"Show highlights",icon:i?"show":"hide",selected:i,onClick:r}),mt(go,{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",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,
123
- 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(mt(mo,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,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=[],this._sidebarRPC=new Xt,this.iframe=function(t){
124
- const e=Qn(t.sidebarAppUrl,to(t.sidebarAppUrl,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","clean"===o.theme?this.iframeContainer.classList.add("annotator-frame--theme-clean"):this.bucketBar=new ho(this.iframeContainer,n),this.iframeContainer.appendChild(this.iframe),this.hypothesisSidebar=document.createElement("hypothesis-sidebar");ne(this.hypothesisSidebar).appendChild(this.iframeContainer),t.appendChild(this.hypothesisSidebar)}this.iframe.contentWindow&&Mt(this.iframe.contentWindow),this._listeners=new Ot
125
- ;const r=document.createElement("div");this.toolbar=new _o(r,{createAnnotation:()=>this._guestRPC.forEach((t=>t.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},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.on("ready",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="")
126
- ;const t="always"===o.showHighlights;this.setHighlightsVisible(t),(o.openSidebar||o.annotations||o.query||o.group)&&this.open()})),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.forEach((t=>t.destroy())),this._sidebarRPC.destroy(),null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),null===(e=this._hammerManager)||void 0===e||e.destroy(),this.hypothesisSidebar?this.hypothesisSidebar.remove():this.iframe.remove(),this._emitter.destroy(),Mt(null)}onFrameConnected(t,e){switch(t){case"guest":this._guestRPC.push(this._connectGuest(e));break;case"sidebar":this._sidebarRPC.connect(e)}}_connectGuest(t){const e=new Xt;return e.on("textSelectedIn",(t=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("textUnselectedIn",(t=>{
127
- this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("anchorsChanged",(()=>{var t;null===(t=this.bucketBar)||void 0===t||t.update()})),e.connect(t),e}_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()}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()}))
128
- ;[["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})))}_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
129
- ;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.forEach((t=>t.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(),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":
130
- 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="",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(){
131
- 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);const bo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),document.addEventListener("readystatechange",(()=>t()))})).then((function(){
132
- const t=$t("annotator"),e=t.subFrameIdentifier?window.parent:window,n=new Jn(document.body,t,e);let o,i,r;if(e===window){const t=$t("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,$t("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()))}))}));
118
+ DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:H,DIRECTION_ALL:30,Manager:Ft,Input:V,TouchAction:xt,TouchInput:ht,MouseInput:K,PointerEventInput:nt,TouchMouseInput:dt,SingleTouchInput:st,Recognizer:At,AttrRecognizer:Lt,Tap:Ht,Pan:Pt,Swipe:Dt,Pinch:Mt,Rotate:It,Press:Ot,on:b,off:C,each:f,merge:m,extend:g,assign:r,inherit:_,bindFn:v,prefixed:R}),(void 0!==e?e:"undefined"!=typeof self?self:{}).Hammer=Bt,t.exports?t.exports=Bt:e.Hammer=Bt}(window,document)}(io);var ro=io.exports;function so(t){const e=function(t){const e=[];return t.forEach((t=>{var n;if(null===(n=t.highlights)||void 0===n||!n.length)return;const o=we(t.highlights);o.top>=o.bottom||e.push({top:o.top,bottom:o.bottom,anchor:t})})),e.sort(((t,e)=>t.top<e.top?-1:1)),e}(t),n=new Set,o=new Set,i=[];let r=null;function s(t){const e=t.bottom-t.top,n=t.top+e/2;return{anchors:[t.anchor],top:t.top,bottom:t.bottom,position:n}}e.forEach((t=>{
119
+ if(t.top<137)return void n.add(t.anchor);if(t.top>window.innerHeight-22)return void o.add(t.anchor);if(!r)return void(r=s(t));const e=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!e)i.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t.anchor),r.bottom=e,r.position=r.top+n/2}})),r&&i.push(r);return{above:{anchors:Array.from(n),position:137},below:{anchors:Array.from(o),position:window.innerHeight-22},buckets:i}}function ao({bucket:t,onSelectAnnotations:e}){const n=`Select nearby annotations (${t.anchors.length})`;function o(e){t.anchors.forEach((t=>{ye(t.highlights||[],e)}))}return mt("button",{className:"Buckets__button Buckets__button--left",onClick:n=>function(n){const o=t.anchors.map((t=>t.annotation.$tag));e(o,n.metaKey||n.ctrlKey)}(n),onMouseMove:()=>o(!0),onMouseOut:()=>o(!1),onBlur:()=>o(!1),title:n,"aria-label":n,children:t.anchors.length})}function lo({bucket:t,direction:e,scrollToAnchor:n}){const o=`Go ${e} to next annotations (${t.anchors.length})`
120
+ ;return mt("button",{className:Z("Buckets__button",`Buckets__button--${e}`),onClick:function(){const o=function(t,e){let n=null,o=0;for(let r of t){var i;if(null===(i=r.highlights)||void 0===i||!i.length)continue;const t=we(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}(t.anchors,e);o&&n(o)},title:o,"aria-label":o,children:t.anchors.length})}function co({above:t,below:e,buckets:n,onSelectAnnotations:o,scrollToAnchor:i}){const r=t.anchors.length>0,s=e.anchors.length>0;return mt("ul",{className:"Buckets__list",children:[r&&mt("li",{className:"Buckets__bucket",style:{top:t.position},children:mt(lo,{bucket:t,direction:"up",scrollToAnchor:i})}),n.map(((t,e)=>mt("li",{className:"Buckets__bucket",style:{top:t.position},children:mt(ao,{bucket:t,onSelectAnnotations:o})},e))),s&&mt("li",{className:"Buckets__bucket",style:{top:e.position},children:mt(lo,{bucket:e,direction:"down",scrollToAnchor:i})})]})}class ho{
121
+ constructor(t,e,{onSelectAnnotations:n}){this._bucketsContainer=document.createElement("div"),t.appendChild(this._bucketsContainer),this._guest=e,this._onSelectAnnotations=n,this.update()}destroy(){P(null,this._bucketsContainer),this._bucketsContainer.remove()}update(){const t=so(this._guest.anchors);P(mt(co,{above:t.above,below:t.below,buckets:t.buckets,onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e),scrollToAnchor:t=>this._guest.scrollToAnchor(t)}),this._bucketsContainer)}}let uo={};const fo=t=>{uo=t||{}},po=function(t){t.on("featureFlagsUpdated",fo)};function go({buttonRef:t,expanded:e,className:n="Toolbar__button",label:o,icon:i,onClick:r,selected:s=!1}){return mt("button",{className:n,"aria-label":o,"aria-expanded":e,"aria-pressed":s,onClick:r,ref:t,title:o,children:mt(vt,{name:i})})}function mo({closeSidebar:t,createAnnotation:e,isSidebarOpen:n,newAnnotationType:o,showHighlights:i,toggleHighlights:r,toggleSidebar:s,toggleSidebarRef:a,useMinimalControls:l=!1}){return mt("div",{
122
+ className:"Toolbar",children:[l&&n&&mt(go,{className:"Toolbar__sidebar-close",label:"Close annotation sidebar",icon:"cancel",onClick:t}),!l&&mt(go,{className:"Toolbar__sidebar-toggle",buttonRef:a,label:"Annotation sidebar",icon:n?"caret-right":"caret-left",expanded:n,onClick:s}),!l&&mt("div",{className:"Toolbar__buttonbar",children:[mt(go,{label:"Show highlights",icon:i?"show":"hide",selected:i,onClick:r}),mt(go,{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",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(){
123
+ 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(mt(mo,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,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={}){
124
+ if(this._emitter=e.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new Xt,this.iframe=function(t){const e=Qn(t.sidebarAppUrl,to(t.sidebarAppUrl,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","clean"===o.theme?this.iframeContainer.classList.add("annotator-frame--theme-clean"):this.bucketBar=new ho(this.iframeContainer,n,{onSelectAnnotations:(t,e)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",t,e)))}),this.iframeContainer.appendChild(this.iframe),
125
+ this.hypothesisSidebar=document.createElement("hypothesis-sidebar");ne(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.forEach((t=>t.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},this._setupGestures(),this.close();const[s]=o.services||[];s&&(this.onLoginRequest=s.onLoginRequest,this.onLogoutRequest=s.onLogoutRequest,this.onSignupRequest=s.onSignupRequest,
126
+ this.onProfileRequest=s.onProfileRequest,this.onHelpRequest=s.onHelpRequest),this.onLayoutChange=o.onLayoutChange,this._notifyOfLayoutChange(!1),this._setupSidebarEvents(),this._sidebarRPC.on("ready",(()=>{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._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.forEach((t=>t.destroy())),this._sidebarRPC.destroy(),null===(t=this.bucketBar)||void 0===t||t.destroy(),this._listeners.removeAll(),null===(e=this._hammerManager)||void 0===e||e.destroy(),this.hypothesisSidebar?this.hypothesisSidebar.remove():this.iframe.remove(),this._emitter.destroy(),Mt(null)}onFrameConnected(t,e){switch(t){case"guest":this._guestRPC.push(this._connectGuest(e));break;case"sidebar":
127
+ this._sidebarRPC.connect(e)}}_connectGuest(t){const e=new Xt;return e.on("textSelectedIn",(t=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("textUnselectedIn",(t=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.forEach((e=>e.call("clearSelectionExceptIn",t)))})),e.on("anchorsChanged",(()=>{var t;null===(t=this.bucketBar)||void 0===t||t.update()})),e.connect(t),e}_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()}Array.from(n).forEach((t=>{t.addEventListener("click",o)}))}(document.body,(()=>this.open())),po(this._sidebarRPC),this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),
128
+ 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})))}_updateLayout(){this.renderFrame||(this.renderFrame=requestAnimationFrame((()=>{if(this.renderFrame=null,this._gestureState.final!==this._gestureState.initial&&this.iframeContainer){
129
+ 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.forEach((t=>t.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(),e.classList.add("annotator-no-transition"),e.style.pointerEvents="none",this._gestureState.initial=parseInt(getComputedStyle(e).marginLeft);break;case"panend":
130
+ 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="",this.iframeContainer.classList.add("annotator-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this.options.showHighlights&&this.setHighlightsVisible(!1),
131
+ 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 Rt}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);const bo=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((t=>{"loading"!==document.readyState&&t(),
132
+ document.addEventListener("readystatechange",(()=>t()))})).then((function(){const t=$t("annotator"),e=t.subFrameIdentifier?window.parent:window,n=new Jn(document.body,t,e);let o,i,r;if(e===window){const t=$t("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,$t("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