hypothesis 1.1277.0 → 1.1279.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?f2bb28","styles/annotator.css":"styles/annotator.css?02ecf3","styles/annotator.css.map":"styles/annotator.css.map?cdb6c3","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?185199","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?c5712d","styles/sidebar.css.map":"styles/sidebar.css.map?3e5b70","styles/ui-playground.css":"styles/ui-playground.css?a6a0f0","styles/ui-playground.css.map":"styles/ui-playground.css.map?1c8e35","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?e66697","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?462a38","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?1de051","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?3357e7","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?a833bd"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function l(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function c(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=l(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var p=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),u=c(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1277.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:u,manifest:s,apiUrl:p.apiUrl})}else{var d=function(){var s,t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return null===(s=e.chrome)||void 0===s||null===(t=s.runtime)||void 0===t?void 0:t.id}();if(d&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(d))throw new Error("Could not start Hypothesis extension as configuration is missing");var h=p,y=c(h.notebookAppUrl||"https://hypothes.is/notebook"),f=c(h.profileAppUrl||"https://hypothes.is/user-profile"),m=c(h.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:u,manifest:s,notebookAppUrl:y,profileAppUrl:f,sidebarAppUrl:m})}}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";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?7b7a5a","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?1de051","styles/annotator.css":"styles/annotator.css?02ecf3","styles/annotator.css.map":"styles/annotator.css.map?cdb6c3","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?185199","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?c5712d","styles/sidebar.css.map":"styles/sidebar.css.map?3e5b70","styles/ui-playground.css":"styles/ui-playground.css?a6a0f0","styles/ui-playground.css.map":"styles/ui-playground.css.map?1c8e35","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?e66697","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?b475c3","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?3357e7","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?28f1e1"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function l(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function c(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=l(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var p=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),u=c(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1279.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:u,manifest:s,apiUrl:p.apiUrl})}else{var d=function(){var s,t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return null===(s=e.chrome)||void 0===s||null===(t=s.runtime)||void 0===t?void 0:t.id}();if(d&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(d))throw new Error("Could not start Hypothesis extension as configuration is missing");var h=p,y=c(h.notebookAppUrl||"https://hypothes.is/notebook"),f=c(h.profileAppUrl||"https://hypothes.is/user-profile"),m=c(h.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:u,manifest:s,notebookAppUrl:y,profileAppUrl:f,sidebarAppUrl:m})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
@@ -1,5 +1,6 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?f2bb28",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?7b7a5a",
3
+ "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?1de051",
3
4
  "styles/annotator.css": "styles/annotator.css?02ecf3",
4
5
  "styles/annotator.css.map": "styles/annotator.css.map?cdb6c3",
5
6
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -13,8 +14,7 @@
13
14
  "styles/ui-playground.css": "styles/ui-playground.css?a6a0f0",
14
15
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?1c8e35",
15
16
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?e66697",
16
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?462a38",
17
- "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?1de051",
17
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?b475c3",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?3357e7",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?a833bd"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?28f1e1"
20
20
  }
@@ -121,7 +121,7 @@ this._hostRPC.on("close",(()=>this.emit("hostDisconnected")));const e=await this
121
121
  if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{const i=await this._integration.anchor(this.element,e.selector),o=Ye.fromRange(i);n={annotation:t,target:e,range:o}}catch(i){n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.range)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&ln(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[]
122
122
  ;const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),s={uri:n.uri,document:n.metadata,target:o,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+r(8)};return this._sidebarRPC.call("createAnnotation",s),this.anchor(s),Po(),s}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);cn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(const r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue;const t=hn(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){
123
123
  const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Je(n),o=nn(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Ro(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){
124
- this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Vt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Mo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Lo(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1277.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}
124
+ this._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Vt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function Mo(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function Lo(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1279.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}
125
125
  function Io({config:t,groupId:e}){return zt("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:Mo(t.notebookAppUrl,{...Lo(t.notebookAppUrl,t),group:e})})}function Fo({eventBus:t,config:e}){const[n,i]=At(0),[o,r]=At(!0),[s,a]=At(null),l=kt(""),c=kt(null);Rt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),Rt((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),Rt((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:zt("div",{className:be("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:zt("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[zt("div",{className:"absolute right-0 m-3",children:zt(Ae,{title:"Close the Notebook",onClick:()=>{var t;r(!0),
126
126
  null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",classes:be("!bg-transparent enabled:hover:!bg-grey-3"),children:zt(Yt,{className:"w-4 h-4"})})}),zt(Io,{config:e,groupId:s},n)]})})}class Do{constructor(t,e,i){n(this,"_outerContainer",void 0),n(this,"_shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this._shadowRoot=Fe(this._outerContainer),dt(zt(Fo,{eventBus:e,config:i}),this._shadowRoot)}destroy(){dt(null,this._shadowRoot),this._outerContainer.remove()}}function Bo({eventBus:t,config:e}){const[n,i]=At(!0),o=kt(null);Rt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:zt("div",{className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:zt("div",{className:"relative w-full h-full","data-testid":"profile-inner",children:[zt("div",{className:"absolute right-0 m-3",children:zt(Ae,{
127
127
  title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:be("!bg-transparent enabled:hover:!bg-grey-3"),children:zt(Yt,{className:"w-4 h-4"})})}),zt("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class Ho{constructor(t,e,i){n(this,"_outerContainer",void 0),n(this,"shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-profile"),t.appendChild(this._outerContainer),this.shadowRoot=Fe(this._outerContainer),dt(zt(Bo,{eventBus:e,config:i}),this.shadowRoot)}destroy(){dt(null,this.shadowRoot),this._outerContainer.remove()}}var Vo={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i
@@ -534,7 +534,7 @@ function Km(e){return sa([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.cre
534
534
  ;function Qm(e){return function(e){return e.replace(Zm,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class Jm{constructor(e,t){H(this,"term",void 0),H(this,"matcher",void 0),this.term=t.normalize(e),this.matcher=t}matches(e){const t=this.matcher;return t.fieldValues(e).some((e=>t.matches(t.normalize(e),this.term)))}}class ep{constructor(e,t){H(this,"operator",void 0),H(this,"filters",void 0),this.operator=e,this.filters=t}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function tp(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:Qm}}const np={quote:tp((e=>{var t;return[null!==(t=ao(e))&&void 0!==t?t:""]})),since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:tp((e=>e.tags)),text:tp((e=>[e.text])),uri:tp((e=>[e.uri])),user:tp((e=>{var t,n;return[e.user,null!==(t=null===(n=e.user_info)||void 0===n?void 0:n.display_name)&&void 0!==t?t:""]}))};const rp=function(e){
535
535
  if(1!==e.length)throw new Error("Memoize input must be a function of one argument");let t,n;return function(r){return r===t||(t=r,n=e(r)),n}}((function(e){const t=e.selection,n={expanded:t.expanded,forcedVisible:t.forcedVisible,selected:t.selected,sortCompareFn:Xm[t.sortKey]},r=!!t.filterQuery||Object.keys(t.filters).length>0;if(r){const e=function(e,t={}){const n=[],r=[],o=[],i=[],a=[],s=[],l=t.user?[t.user]:[],c=zm(e);for(const e of c){const t=e.slice(0,e.indexOf(":")),c=e.slice(t.length+1);switch(t){case"quote":r.push(c);break;case"since":{const t=86400,n={sec:1,min:60,hour:3600,day:t,week:7*t,month:30*t,year:365*t},r=e.slice(6).toLowerCase().match(/^(\d+)(sec|min|hour|day|week|month|year)?$/);if(r){const e=parseFloat(r[1]),t=r[2]||"sec";o.push(e*n[t])}}break;case"tag":i.push(c);break;case"text":a.push(c);break;case"uri":s.push(c);break;case"user":l.push(c);break;default:n.push(e)}}return{any:{terms:n,operator:"and"},quote:{terms:r,operator:"and"},since:{terms:o,operator:"and"},tag:{terms:i,operator:"and"
536
536
  },text:{terms:a,operator:"and"},uri:{terms:s,operator:"or"},user:{terms:l,operator:"or"}}}(t.filterQuery||"",t.filters);n.filterFn=t=>function(e,t){const n=(e,t)=>new Jm(t,np[e]),r=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{let r;if("any"===e){const e=["quote","text","tag","user"];r=t.terms.map((t=>new ep("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new ep(t.operator,r)})),o=new ep("and",r);return e.filter((e=>e.id&&o.matches(e))).map((e=>e.id))}([t],e).length>0}return!r&&"sidebar"===e.route&&(n.threadFilterFn=e=>{return!!e.annotation&&(n=e.annotation,r=t.selectedTab,!Qr(n)&&Gm(n)===r);var n,r}),$m(e.annotations,n)}));function op(){const e=Pi(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a=de((()=>({annotations:t,route:r,selection:{...o,filterQuery:n,filters:i}})),[t,n,r,o,i]);return rp(a)}var ip=ur((function({loadAnnotationsService:e,onLogin:t}){var n
537
- ;const r=Pi(),o=null!==(n=r.routeParams().id)&&void 0!==n?n:"",i=op(),a=r.profile().userid,[s,l]=ae(!1);return le((()=>{l(!1),r.clearAnnotations(),e.loadThread(o).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&r.setExpanded(e.id,!0))),t.id!==o&&r.highlightAnnotations([o]))})).catch((()=>{l(!0)}))}),[o,a,e,r]),Ee(v,{children:[s&&Ee(Bi,{errorType:"annotation",onLoginRequest:t}),Ee(Mm,{threads:i.children})]})}),["loadAnnotationsService"]);class ap{constructor(e,t,n=window){var r,o,i,a;H(this,"version",void 0),H(this,"userAgent",void 0),H(this,"urls",void 0),H(this,"fingerprint",void 0),H(this,"account",void 0),H(this,"timestamp",void 0),H(this,"segment",void 0);const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1277.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||s,
537
+ ;const r=Pi(),o=null!==(n=r.routeParams().id)&&void 0!==n?n:"",i=op(),a=r.profile().userid,[s,l]=ae(!1);return le((()=>{l(!1),r.clearAnnotations(),e.loadThread(o).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&r.setExpanded(e.id,!0))),t.id!==o&&r.highlightAnnotations([o]))})).catch((()=>{l(!0)}))}),[o,a,e,r]),Ee(v,{children:[s&&Ee(Bi,{errorType:"annotation",onLoginRequest:t}),Ee(Mm,{threads:i.children})]})}),["loadAnnotationsService"]);class ap{constructor(e,t,n=window){var r,o,i,a;H(this,"version",void 0),H(this,"userAgent",void 0),H(this,"urls",void 0),H(this,"fingerprint",void 0),H(this,"account",void 0),H(this,"timestamp",void 0),H(this,"segment",void 0);const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1279.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||s,
538
538
  this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(i=o.metadata)||void 0===i?void 0:i.documentFingerprint)&&void 0!==r?r:s,this.account=l,this.timestamp=(new Date).toString();const c=null===(a=t[0])||void 0===a?void 0:a.segment;if(c){const e=[];c.cfi&&e.push(["CFI",c.cfi]),c.url&&e.push(["URL",c.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}function sp(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function lp(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,r=function(e,t){var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,h=c&&null!=c.top?c.top:.5,m=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,f=d,g=h
539
539
  ;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=m,o-=p,r=e.align.lockX?t.pageXOffset:r,o=e.align.lockY?t.pageYOffset:o,i=r-t.pageXOffset,a=o-t.pageYOffset;else{s=u.width,l=u.height,n=t.getBoundingClientRect();var v=u.left-(n.left-t.scrollLeft),_=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=_+l*g-t.clientHeight*g,r-=m,o-=p,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(t,e),o=Date.now()-t.startTime,i=Math.min(1/t.time*o,1);if(t.endIterations>=n)return sp(e,r.x,r.y),e._scrollSettings=null,t.end("complete");var a=1-t.ease(i);if(sp(e,r.x-r.differenceX*a,r.y-r.differenceY*a),o>=t.time)return t.endIterations++,t.scrollAncestor&&lp(t.scrollAncestor),void lp(e);!function(e){
540
540
  if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(lp.bind(null,e))}}function cp(e){return e.self===e}function up(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function dp(){return!0}function hp(e){if(e.assignedSlot)return hp(e.assignedSlot);if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}var mp=function(e,t,n){if(e){"function"==typeof t&&(n=t,t=null),t||(t={}),t.time=isNaN(t.time)?1e3:t.time,t.ease=t.ease||function(e){return 1-Math.pow(1-e,e/2)},t.align=t.align||{};var r=hp(e),o=1,i=t.validTarget||dp,a=t.isScrollable;t.debug&&(console.log("About to scroll to",e),r||console.error("Target did not have a parent, is it mounted in the DOM?"))
@@ -569,7 +569,7 @@ var af=ur((function({isExpanded:e,group:t,groups:n,onExpand:r,toastMessenger:o})
569
569
  isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await ir({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&Ee("p",{className:X("p-2 pl-9 bg-grey-1 hyphens-none"),"data-testid":"unselectable-group-note",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"]);function sf({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Ee(of,{heading:r,children:n.map((n=>Ee(af,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var lf=ur((function({settings:e}){const t=Pi(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=de((()=>rf(o)),[o]),l=de((()=>rf(r)),[r]),c=de((()=>rf(n)),[n]),u=t.defaultAuthority(),d=a&&!ua(a,u),h=t.getLink("groups.new"),[m,p]=ae(null);let f;if(i){const t=i.organization.logo||function(e){const t=ar(e);return t&&t.icon?t.icon:null}(e)||"",n=tf(i)?tf(i):"";f=Ee("span",{
570
570
  className:X("shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold"),children:[t&&Ee("img",{className:X("relative top-[1px] w-4 h-4"),src:t,alt:n}),i.name]})}else f=Ee("span",{children:"…"});return!!gp(e)&&n.length+r.length+o.length<2?f:Ee(Zh,{align:"left",contentClass:"min-w-[250px]",label:f,onOpenChanged:()=>p(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[c.length>0&&Ee(sf,{expandedGroup:m,onExpandGroup:p,heading:"Currently Viewing",groups:c}),l.length>0&&Ee(sf,{expandedGroup:m,onExpandGroup:p,heading:"Featured Groups",groups:l}),s.length>0&&Ee(sf,{expandedGroup:m,onExpandGroup:p,heading:"My Groups",groups:s}),d&&Ee(Jh,{icon:Wt,href:h,label:"New private group"})]})}),["settings"]);function cf({alwaysExpanded:e,query:t,onSearch:n}){const r=Pi().isLoading(),o=ue(null);!function(e){const t=ue(null),n=he((n=>{var r;!n.metaKey&&!n.ctrlKey&&n.target instanceof HTMLElement&&["INPUT","TEXTAREA"].includes(n.target.tagName)||(t.current=document.activeElement,
571
571
  e.current&&(null===(r=e.current)||void 0===r||r.focus(),n.preventDefault(),n.stopPropagation()))}),[e]),r=he((()=>{var n;document.activeElement===e.current&&(t.current&&(t.current.focus(),t.current=null),null===(n=e.current)||void 0===n||n.blur())}),[e]),o=_a()?"meta":"ctrl";Bp("/",n),Bp(`${o}+k`,n),Bp("escape",r)}(o);const[i,a]=ae(t),[s,l]=ae(t);t!==i&&(l(t),a(t));const c=e||t;return Ee("form",{action:"#",className:X("relative","flex items-center","bg-white/90 hover:bg-white transition-colors"),name:"searchForm",onSubmit:e=>{var t,r,a;(e.preventDefault(),null!==(t=o.current)&&void 0!==t&&t.value||i)&&n(null!==(r=null===(a=o.current)||void 0===a?void 0:a.value)&&void 0!==r?r:"")},children:[Ee(Hn,{"aria-label":"Search",classes:X("order-1","text-base",{"border-0":!c,"focus:border":!0,border:c},{"max-w-0 !p-0":!c,"focus:!p-1.5":!0,"focus:max-w-[150px] focus:ml-[2px]":!0,"max-w-[150px] p-1.5 ml-[2px]":c},"transition-[max-width] duration-300 ease-out"),"data-testid":"search-input",dir:"auto",type:"text",
572
- name:"query",placeholder:r?"Loading…":"Search…",disabled:r,elementRef:o,value:s||"",onInput:e=>l(e.target.value)}),!r&&Ee("div",{className:"order-0",children:Ee(Bn,{icon:cn,onClick:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.focus()},size:"xs",title:"Search annotations"})}),r&&Ee(Nn,{})]})}function uf(){const e=Pi(),t=e.sortKey(),n=e.sortKeys().map((n=>Ee(Jh,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Ee("span",{className:"p-1",children:Ee(vn,{})});return Ee("div",{className:"SortMenu",children:Ee(Zh,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var df=ur((function({router:e}){const t=Pi(),{q:n}=t.routeParams();return Ee(cf,{query:null!=n?n:"",onSearch:t=>{e.navigate("stream",{q:t})},alwaysExpanded:!0})}),["router"]);var hf=ur((function({frameSync:e,onLogout:t,settings:n}){var r,o
572
+ name:"query",placeholder:r?"Loading…":"Search…",disabled:r,elementRef:o,value:s||"",onInput:e=>l(e.target.value)}),!r&&Ee("div",{className:"order-0",children:Ee(Bn,{icon:cn,onClick:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.focus()},size:"xs",title:"Search annotations",disableTouchSizing:!0,classes:"touch:min-w-touch-minimum"})}),r&&Ee(Nn,{})]})}function uf(){const e=Pi(),t=e.sortKey(),n=e.sortKeys().map((n=>Ee(Jh,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Ee("span",{className:"p-1",children:Ee(vn,{})});return Ee("div",{className:"SortMenu",children:Ee(Zh,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var df=ur((function({router:e}){const t=Pi(),{q:n}=t.routeParams();return Ee(cf,{query:null!=n?n:"",onSearch:t=>{e.navigate("stream",{q:t})},alwaysExpanded:!0})}),["router"]);var hf=ur((function({frameSync:e,onLogout:t,settings:n}){var r,o
573
573
  ;const i=Pi(),a=i.defaultAuthority(),s=i.profile(),l=ua(s.userid,a),c=ar(n),u=ca(s.userid),d=null!==(r=null===(o=s.user_info)||void 0===o?void 0:o.display_name)&&void 0!==r?r:u,[h,m]=ae(!1),p=e=>c&&!!c[e],f=!l||p("onProfileRequestProvided"),g=!l||p("onLogoutRequestProvided"),v=i.isFeatureEnabled("client_user_profile"),_=()=>{e.notifyHost("openNotebook",i.focusedGroupId())},b=()=>e.notifyHost("openProfile"),y=f&&!l?i.getLink("user",{user:u}):void 0,w=Ee("span",{className:"p-1",children:Ee(en,{})});return Ee("div",{"data-testid":"user-menu",onKeyDown:e=>{"n"===e.key?(_(),m(!1)):v&&"p"===e.key&&(b(),m(!1))},children:Ee(Zh,{label:w,title:d,align:"right",open:h,onOpenChanged:m,children:[Ee(of,{children:[Ee(Jh,{label:d,isDisabled:!f,href:y,onClick:f?()=>l&&e.notifyHost("profileRequested"):void 0}),!l&&Ee(Jh,{label:"Account settings",href:i.getLink("account.settings")}),v&&Ee(Jh,{label:"Your profile",onClick:()=>b()}),Ee(Jh,{label:"Open notebook",onClick:()=>_()})]}),g&&Ee(of,{children:Ee(Jh,{label:"Log out",
574
574
  onClick:t})})]})})}),["frameSync","settings"]);var mf=ur((function({isSidebar:e,onLogin:t,onLogout:n,onSignUp:r,frameSync:o,settings:i}){const a=!gp(i),s=lr(["accentColor"],i),l=Pi(),c=l.filterQuery(),u=l.isLoggedIn(),d=l.hasFetchedProfile(),h=l.isSidebarPanelOpen("help"),m=l.isSidebarPanelOpen("shareGroupAnnotations");return Ee("div",{className:X("absolute h-10 left-0 top-0 right-0 z-4","text-grey-7 border-b theme-clean:border-b-0 bg-white"),"data-testid":"top-bar",children:Ee("div",{className:X("container flex items-center h-full","text-[16px]"),"data-testid":"top-bar-content",children:[Ee(e?lf:df,{}),Ee("div",{className:"grow flex items-center justify-end",children:[e&&Ee(v,{children:[Ee(Fp,{}),Ee(cf,{query:c||null,onSearch:l.setFilterQuery}),Ee(uf,{}),a&&Ee(Bn,{icon:dn,expanded:m,onClick:()=>{l.toggleSidebarPanel("shareGroupAnnotations")},size:"xs",title:"Share annotations on this page"})]}),Ee(Bn,{icon:Et,expanded:h,onClick:()=>{const e=ar(i)
575
575
  ;e&&e.onHelpRequestProvided?o.notifyHost("helpRequested"):l.toggleSidebarPanel("help")},size:"xs",title:"Help"}),u?Ee(hf,{onLogout:n}):Ee("div",{className:"flex items-center text-md font-medium space-x-1","data-testid":"login-links",children:[!u&&!d&&Ee("span",{children:"⋯"}),!u&&d&&Ee(v,{children:[Ee(rr,{classes:"inline",onClick:r,style:s,children:"Sign up"}),Ee("div",{children:"/"}),Ee(rr,{classes:"inline",onClick:t,style:s,children:"Log in"})]})]})]})]})})}),["frameSync","settings"]);var pf=ur((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=Pi(),a=i.profile(),s=i.route(),l="notebook"===s||"profile"===s,c=de((()=>lr(["appBackgroundColor"],n)),[n]),u="clean"===n.theme,d="sidebar"===s;le((()=>{(function(e,t,n){const r="object"==typeof t.preferences&&!!t.preferences.show_sidebar_tutorial,o=ar(n)||{onHelpRequestProvided:!1};return e&&!o.onHelpRequestProvided&&r})(d,a,n)&&i.openSidebarPanel("help")}),[d,a,n,i]);const h=async()=>{if(ar(n))t.notifyHost("loginRequested");else try{
@@ -581,7 +581,7 @@ if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(
581
581
  n=new Date(t.created).toISOString();break;case"update":n=new Date(t.updated).toISOString();break;default:n=(new Date).toISOString()}const r={date:n,annotation:{id:t.id,isShared:ga(t.permissions)}};this._reportConfig.events.includes(e)&&function(e,t,n,r=[]){const o={jsonrpc:"2.0",method:n,params:r};e.postMessage(o,t)}(this._rpc.targetFrame,this._rpc.origin,this._reportConfig.method,[e,r])}}If.$inject=["settings"];class Rf{constructor(e,t,n){H(this,"_activity",void 0),H(this,"_api",void 0),H(this,"_store",void 0),this._activity=e,this._api=t,this._store=n}_applyDraftChanges(e){const t={},n=this._store.getDraft(e);return n&&(t.tags=n.tags,t.text=n.text,t.permissions=n.isPrivate?ma(e.user):pa(e.user,e.group)),{...e,...t}}_initialize(e,t){const n=this._store.getDefault("annotationPrivacy"),r=this._store.focusedGroupId(),o=this._store.profile();if(!r)throw new Error("Cannot create annotation without a group");const i=o.userid;if(!i)throw new Error("Cannot create annotation when logged out")
582
582
  ;const a=o.user_info,s="s:"+vf(8),l=Object.assign({created:t.toISOString(),group:r,permissions:fa(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return eo(l)&&(l.permissions=ma(i)),l}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),eo(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Xr(n)}),no(n)?this._store.selectTab("note"):ro(n)&&this._store.selectTab("annotation"),(n.references||[]).forEach((e=>{this._store.setExpanded(e,!0)}))}createPageNote(){const e=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!e)return;const t={target:[],uri:e.uri};this.create(t)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),
583
583
  this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,permissions:Xr(e)?pa(t,e.group):ma(t),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e){let t,n;const r=this._applyDraftChanges(e);let o;Wr(e)?(t=this._api.annotation.update({id:e.id},r),n="update"):(t=this._api.annotation.create({},r),n="create"),this._store.annotationSaveStarted(e);try{o=await t,this._activity.reportActivity(n,o)}finally{this._store.annotationSaveFinished(e)}for(const[t,n]of Object.entries(e))if(t.startsWith("$")){o[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([o]),o}}Rf.$inject=["annotationActivity","api","store"];class zf extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function Lf(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new zf(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()
584
- }catch(t){throw new zf(e,n,"Failed to parse response")}var o;if(!n.ok)throw new zf(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Of(e){const t={};for(const[n,r]of Object.entries(e))n.startsWith("$")||(t[n]=r);return t}class Df{constructor(e,t,n){H(this,"_clientId",void 0),H(this,"search",void 0),H(this,"annotation",void 0),H(this,"group",void 0),H(this,"groups",void 0),H(this,"profile",void 0),this._clientId=null;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1277.0"};l&&(u.Authorization="Bearer "+l);const d=r();d&&(u["X-Client-Id"]=d)
584
+ }catch(t){throw new zf(e,n,"Failed to parse response")}var o;if(!n.ok)throw new zf(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Of(e){const t={};for(const[n,r]of Object.entries(e))n.startsWith("$")||(t[n]=r);return t}class Df{constructor(e,t,n){H(this,"_clientId",void 0),H(this,"search",void 0),H(this,"annotation",void 0),H(this,"group",void 0),H(this,"groups",void 0),H(this,"profile",void 0),this._clientId=null;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1279.0"};l&&(u.Authorization="Bearer "+l);const d=r();d&&(u["X-Client-Id"]=d)
585
585
  ;const{url:h,unusedParams:m}=ci(c.url,a),p=new URL(h);for(const[e,t]of Object.entries(m)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&p.searchParams.append(e,t.toString())}return await Lf(p.toString(),{body:s?JSON.stringify(Of(s)):null,headers:u,method:c.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")}}setClientId(e){this._clientId=e}}Df.$inject=["apiRoutes","auth","store"];var Pf={};function Bf(e,t){"boolean"==typeof t&&(t={forever:t}),
586
586
  this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var Ff=Bf;Bf.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},Bf.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},Bf.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1
587
587
  ;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},Bf.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},Bf.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},Bf.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},Bf.prototype.start=Bf.prototype.try,Bf.prototype.errors=function(){return this._errors},Bf.prototype.attempts=function(){
@@ -680,16 +680,16 @@ Tb.prototype.__init.call(this)}static __initStatic(){this.id="HttpContext"}__ini
680
680
  ;if(!Mb(e,t))return!1;if(!Cb(e,t))return!1;return!0}(e,t))return!0;return!1}(e,n._previousEvent))return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&Ug.warn("Event dropped due to being a duplicate of previously captured event."),null}catch(t){return n._previousEvent=e}return n._previousEvent=e}return e};n.id=this.name,e(n)}}function Cb(e,t){let n=Rb(e),r=Rb(t);if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;if(r.length!==n.length)return!1;for(let e=0;e<r.length;e++){const t=r[e],o=n[e];if(t.filename!==o.filename||t.lineno!==o.lineno||t.colno!==o.colno||t.function!==o.function)return!1}return!0}function Mb(e,t){let n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;try{return!(n.join("")!==r.join(""))}catch(e){return!1}}function Ib(e){return e.exception&&e.exception.values&&e.exception.values[0]}function Rb(e){const t=e.exception;if(t)try{return t.values[0].stacktrace.frames}catch(e){return}}Ab.__initStatic();const zb=[new L_,new R_,new yb,new W_,new mb,new Nb,new Ab,new Tb]
681
681
  ;function Lb(e={}){void 0===e.defaultIntegrations&&(e.defaultIntegrations=zb),void 0===e.release&&("string"==typeof __SENTRY_RELEASE__&&(e.release=__SENTRY_RELEASE__),D_.SENTRY_RELEASE&&D_.SENTRY_RELEASE.id&&(e.release=D_.SENTRY_RELEASE.id)),void 0===e.autoSessionTracking&&(e.autoSessionTracking=!0),void 0===e.sendClientReports&&(e.sendClientReports=!0);const t={...e,stackParser:(n=e.stackParser||db,Array.isArray(n)?rv(...n):n),integrations:w_(e),transport:e.transport||(av()?tb:nb)};var n;!function(e,t){!0===t.debug&&("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?Ug.enable():console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle."));const n=h_();n.getScope().update(t.initialScope);const r=new e(t);n.bindClient(r)}(J_,t),e.autoSessionTracking&&function(){if(void 0===D_.document)return void(("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&Ug.warn("Session tracking in non-browser environment with @sentry/browser is not supported."));const e=h_()
682
682
  ;if(!e.captureSession)return;Ob(e),mv("history",(({from:e,to:t})=>{void 0!==e&&e!==t&&Ob(h_())}))}()}function Ob(e){e.startSession({ignoreDuration:!0}),e.captureSession()}let Db=0;function Pb(e){!function(e){h_().setUser(e)}(e)}class Bb{constructor(e,t,n,r,o){var i,a;H(this,"_store",void 0),H(this,"_api",void 0),H(this,"_auth",void 0),H(this,"_toastMessenger",void 0),H(this,"_authority",void 0),H(this,"_lastLoad",void 0),H(this,"_lastLoadTime",void 0),this._api=t,this._auth=n,this._store=e,this._toastMessenger=o,this._authority=null!==(i=null===(a=ar(r))||void 0===a?void 0:a.authority)&&void 0!==i?i:null,this._lastLoad=null,this._lastLoadTime=null,n.on("oauthTokensChanged",(()=>this.reload()))}load(){return(!this._lastLoad||!this._lastLoadTime||Date.now()-this._lastLoadTime>3e5)&&(this._lastLoadTime=Date.now(),this._lastLoad=Uf((()=>{const e=this._authority?{authority:this._authority}:{};return this._api.profile.read(e)})).then((e=>(this.update(e),this._lastLoadTime=Date.now(),e))).catch((e=>{
683
- throw this._lastLoadTime=null,e}))),this._lastLoad}async dismissSidebarTutorial(){const e=await this._api.profile.update({},{preferences:{show_sidebar_tutorial:!1}});this.update(e)}update(e){const t=this._store.profile(),n=e.userid!==t.userid;return this._store.updateProfile(e),this._lastLoad=Promise.resolve(e),this._lastLoadTime=Date.now(),n&&(e.userid?Pb({id:e.userid}):Pb(null)),e}async logout(){try{return await this._auth.logout(),this.reload()}catch(e){throw this._toastMessenger.error("Log out failed"),new Error(e)}}reload(){return this._lastLoad=null,this._lastLoadTime=null,this.load()}}Bb.$inject=["store","api","auth","settings","toastMessenger"];class Fb{constructor(){this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}}}addClause(e,t,n,r=!1){return this._filter.clauses.push({field:e,operator:t,value:n,case_sensitive:r}),this}getFilter(){return this._filter}resetFilter(){return this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,
684
- delete:!0}},this}}class Hb extends Ep{constructor(e){super(),H(this,"_socket",void 0),H(this,"_messageQueue",void 0),this._messageQueue=[],this._socket=new WebSocket(e),this._socket.onopen=e=>{this.sendMessages(),this.emit("open",e)},this._socket.onclose=e=>{if(1e3===e.code||1001===e.code)return void this.emit("close",e);const t=new Error(`WebSocket closed abnormally, code: ${e.code}`);console.warn(t),this.emit("disconnect")},this._socket.onerror=e=>{this.emit("error",e)},this._socket.onmessage=e=>{this.emit("message",e)}}close(){this._socket.close(1e3)}send(e){this._messageQueue.push(e),this.isConnected()&&this.sendMessages()}isConnected(){return this._socket.readyState===WebSocket.OPEN}sendMessages(){for(;this._messageQueue.length>0;){const e=JSON.stringify(this._messageQueue.shift());this._socket.send(e)}}}class Ub{constructor(e,t,n,r,o){this._auth=n,this._groups=r,this._session=o,this._store=e,this._websocketURL=t.links().then((e=>e.websocket)),this.clientId=vf(32),this._socket=null,
685
- this._updateImmediately=!0,this._configMessages={},this._reconnectionAttempts=0,this._reconnectSetUp=!1}applyPendingUpdates(){const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnnotations(e);const t=Object.keys(this._store.pendingDeletions()).map((e=>({id:e})));t.length&&this._store.removeAnnotations(t),this._store.clearPendingUpdates()}_handleSocketError(e,t){Nf("Error connecting to H push notification service:",t);const n=new URL(e).hostname;-1!==["localhost","127.0.0.1"].indexOf(n)&&Nf("Check that your H service is configured to allow WebSocket connections from "+window.location.origin)}_handleSocketMessage(e){const t=JSON.parse(e.data);if(t)if("annotation-notification"===t.type){const e=t.payload;switch(t.options.action){case"create":case"update":case"past":this._store.receiveRealTimeUpdates({updatedAnnotations:e});break;case"delete":this._store.receiveRealTimeUpdates({deletedAnnotations:e})}this._updateImmediately&&this.applyPendingUpdates()
686
- }else if("session-change"===t.type)this._session.update(t.model),this._groups.load();else if("whoyouare"===t.type){const e=this._store.profile().userid;t.userid!==e&&console.warn('WebSocket user ID "%s" does not match logged-in ID "%s"',t.userid,e)}else Nf("Received unsupported notification",t.type)}_sendClientConfig(e){Object.keys(this._configMessages).forEach((t=>{this._configMessages[t]&&e.send(this._configMessages[t])}))}setConfig(e,t){var n;this._configMessages[e]=t,null!==(n=this._socket)&&void 0!==n&&n.isConnected()&&this._socket.send(t)}async _reconnect(){var e;const t=await this._websocketURL;if(!t)return;let n,r;null===(e=this._socket)||void 0===e||e.close();try{n=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(n){const e=new URL(t);e.searchParams.set("access_token",n),r=e.toString()}else r=t;const o=new Hb(r);o.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(o)})),o.on("disconnect",(()=>{
687
- if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),o.on("error",(e=>this._handleSocketError(t,e))),o.on("message",(e=>this._handleSocketMessage(e))),this._socket=o,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,tg(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}Ub.$inject=["store","apiRoutes","auth","groups","session"];class jb{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject("hypothesis.user.tags.list")||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1
688
- ;const o=n.split(/\W+/),i=new RegExp(`^${Ef(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject("hypothesis.user.tags.map")||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject("hypothesis.user.tags.map",t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject("hypothesis.user.tags.list",n)}}jb.$inject=["localStorage"];class qb{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}qb.$inject=["store"];class $b extends Ep{constructor(e,t){super(),H(this,"_store",void 0),H(this,"_window",void 0),H(this,"_delayedMessageQueue",void 0),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{
689
- this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),this.emit("toastMessageDismissed",e),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r="",visuallyHidden:o=!1,delayed:i=!1}={}){if(this._store.hasToastMessage(e,t))return;if(i&&!this._window.document.hasFocus()){const i={autoDismiss:n,moreInfoURL:r,visuallyHidden:o};return void this._delayedMessageQueue.push({type:e,messageText:t,options:i})}const a=vf(10),s={type:e,id:a,message:t,moreInfoURL:r,visuallyHidden:o};this._store.addToastMessage({isDismissed:!1,...s}),this.emit("toastMessageAdded",s),n&&setTimeout((()=>{this.dismiss(a)}),5e3)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}$b.$inject=["store","$window"]
690
- ;const Gb=function(e){for(var t={},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(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),Vb=function(e){const{version:t,origin:n}=bf(e.location.href);return"1.1277.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1277.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function Yb(e,t){e.setClientId(t.clientId)}function Wb(e,t,n){e.load(),t.load(),n.sync()}function Kb(e,t,n){e.init(),t.init(),n.init()}function Xb(e,t){"sidebar"===t.route()&&e.connect()}Gb.sentry&&Vb&&function(e){const t=function(){let e=import.meta.url
691
- ;return e?new URL(e).origin:null}(),n=t?[t]:void 0;Lb({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1277.0",beforeSend:(e,t)=>{if(Db>=5)return Nf("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Db;try{const n=t&&t.originalException;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch(e){}return e}});try{g_("host_config",bf(window.location.href))}catch(e){}g_("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Zf(((e,t)=>{f_(e,{tags:{context:t}})}))}(Gb.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),Yb.$inject=["api","streamer"],Wb.$inject=["groups","session","router"],
692
- Kb.$inject=["autosaveService","persistedDefaults","serviceURL"],Xb.$inject=["frameSync","store"];const Zb=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Mf)}(),async function(e,t=window){const n=function(e){const t=bf(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:yf,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:xf(t.origin),ancestorLevel:wf(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified")
693
- ;return{targetFrame:kf(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await _f(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=_f(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,r)}else o=n;const i={...e,...o};return r&&(i.rpc=r),i.apiUrl=function(e){const t=ar(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(Gb).then((e=>{!function(e,t){const n=new $
694
- ;n.register("annotationsService",Rf).register("annotationActivity",If).register("api",Df).register("apiRoutes",qf).register("auth",Vf).register("autosaveService",Yf).register("frameSync",og).register("groups",sg).register("loadAnnotationsService",lg).register("localStorage",ug).register("persistedDefaults",hg).register("router",mg).register("serviceURL",pg).register("session",Bb).register("streamer",Ub).register("streamFilter",Fb).register("tags",jb).register("threadsService",qb).register("toastMessenger",$b).register("store",{factory:Di}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(Kb),n.run(Yb),n.run(Wb),n.run(Cf),n.run(Xb),B(Ee(cr.Provider,{value:n,children:Ee(pf,{})}),t)}(e,Zb)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),B(Ee(ff,{error:e}),t)}(e,Zb)));
683
+ throw this._lastLoadTime=null,e}))),this._lastLoad}async dismissSidebarTutorial(){const e=await this._api.profile.update({},{preferences:{show_sidebar_tutorial:!1}});this.update(e)}update(e){const t=this._store.profile(),n=e.userid!==t.userid;return this._store.updateProfile(e),this._lastLoad=Promise.resolve(e),this._lastLoadTime=Date.now(),n&&(e.userid?Pb({id:e.userid}):Pb(null)),e}async logout(){try{return await this._auth.logout(),this.reload()}catch(e){throw this._toastMessenger.error("Log out failed"),new Error(e)}}reload(){return this._lastLoad=null,this._lastLoadTime=null,this.load()}}Bb.$inject=["store","api","auth","settings","toastMessenger"];class Fb{constructor(){H(this,"_filter",void 0),this._filter={match_policy:"include_any",clauses:[],actions:{create:!0,update:!0,delete:!0}}}addClause(e,t,n,r=!1){return this._filter.clauses.push({field:e,operator:t,value:n,case_sensitive:r}),this}getFilter(){return this._filter}resetFilter(){return this._filter={match_policy:"include_any",clauses:[],actions:{
684
+ create:!0,update:!0,delete:!0}},this}}class Hb extends Ep{constructor(e){super(),H(this,"_socket",void 0),H(this,"_messageQueue",void 0),this._messageQueue=[],this._socket=new WebSocket(e),this._socket.onopen=e=>{this.sendMessages(),this.emit("open",e)},this._socket.onclose=e=>{if(1e3===e.code||1001===e.code)return void this.emit("close",e);const t=new Error(`WebSocket closed abnormally, code: ${e.code}`);console.warn(t),this.emit("disconnect")},this._socket.onerror=e=>{this.emit("error",e)},this._socket.onmessage=e=>{this.emit("message",e)}}close(){this._socket.close(1e3)}send(e){this._messageQueue.push(e),this.isConnected()&&this.sendMessages()}isConnected(){return this._socket.readyState===WebSocket.OPEN}sendMessages(){for(;this._messageQueue.length>0;){const e=JSON.stringify(this._messageQueue.shift());this._socket.send(e)}}}class Ub{constructor(e,t,n,r,o){H(this,"_auth",void 0),H(this,"_groups",void 0),H(this,"_session",void 0),H(this,"_store",void 0),H(this,"_websocketURL",void 0),
685
+ H(this,"_socket",void 0),H(this,"_reconnectSetUp",void 0),H(this,"_updateImmediately",void 0),H(this,"_configMessages",void 0),H(this,"_reconnectionAttempts",void 0),H(this,"clientId",void 0),this._auth=n,this._groups=r,this._session=o,this._store=e,this._websocketURL=t.links().then((e=>e.websocket)),this.clientId=vf(32),this._socket=null,this._updateImmediately=!0,this._configMessages={},this._reconnectionAttempts=0,this._reconnectSetUp=!1}applyPendingUpdates(){const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnnotations(e);const t=Object.keys(this._store.pendingDeletions()).map((e=>({id:e})));t.length&&this._store.removeAnnotations(t),this._store.clearPendingUpdates()}_handleSocketError(e,t){Nf("Error connecting to H push notification service:",t);const n=new URL(e).hostname;-1!==["localhost","127.0.0.1"].indexOf(n)&&Nf("Check that your H service is configured to allow WebSocket connections from "+window.location.origin)}_handleSocketMessage(e){const t=JSON.parse(e.data)
686
+ ;if(t)if("annotation-notification"===t.type){const e=t.payload;switch(t.options.action){case"create":case"update":case"past":this._store.receiveRealTimeUpdates({updatedAnnotations:e});break;case"delete":this._store.receiveRealTimeUpdates({deletedAnnotations:e})}this._updateImmediately&&this.applyPendingUpdates()}else if("session-change"===t.type)this._session.update(t.model),this._groups.load();else if("whoyouare"===t.type){const e=this._store.profile().userid;t.userid!==e&&console.warn('WebSocket user ID "%s" does not match logged-in ID "%s"',t.userid,e)}else Nf("Received unsupported notification",t.type)}_sendClientConfig(e){Object.keys(this._configMessages).forEach((t=>{this._configMessages[t]&&e.send(this._configMessages[t])}))}setConfig(e,t){var n;this._configMessages[e]=t,null!==(n=this._socket)&&void 0!==n&&n.isConnected()&&this._socket.send(t)}async _reconnect(){var e;const t=await this._websocketURL;if(!t)return;let n,r;null===(e=this._socket)||void 0===e||e.close();try{
687
+ n=await this._auth.getAccessToken()}catch(e){throw console.error("Failed to fetch token for WebSocket authentication",e),e}if(n){const e=new URL(t);e.searchParams.set("access_token",n),r=e.toString()}else r=t;const o=new Hb(r);o.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(o)})),o.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),o.on("error",(e=>this._handleSocketError(t,e))),o.on("message",(e=>this._handleSocketMessage(e))),this._socket=o,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,
688
+ tg(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}Ub.$inject=["store","apiRoutes","auth","groups","session"];class jb{constructor(e){H(this,"_storage",void 0),this._storage=e}filter(e,t=null){const n=this._storage.getObject("hypothesis.user.tags.list")||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${Ef(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject("hypothesis.user.tags.map")||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject("hypothesis.user.tags.map",t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject("hypothesis.user.tags.list",n)}}jb.$inject=["localStorage"];class qb{constructor(e){H(this,"_store",void 0),this._store=e}forceVisible(e){e.children.forEach((e=>{
689
+ this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}qb.$inject=["store"];class $b extends Ep{constructor(e,t){super(),H(this,"_store",void 0),H(this,"_window",void 0),H(this,"_delayedMessageQueue",void 0),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),this.emit("toastMessageDismissed",e),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r="",visuallyHidden:o=!1,delayed:i=!1}={}){if(this._store.hasToastMessage(e,t))return;if(i&&!this._window.document.hasFocus()){const i={autoDismiss:n,moreInfoURL:r,visuallyHidden:o};return void this._delayedMessageQueue.push({type:e,messageText:t,options:i})}const a=vf(10),s={type:e,id:a,message:t,
690
+ moreInfoURL:r,visuallyHidden:o};this._store.addToastMessage({isDismissed:!1,...s}),this.emit("toastMessageAdded",s),n&&setTimeout((()=>{this.dismiss(a)}),5e3)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}$b.$inject=["store","$window"];const Gb=function(e){for(var t={},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(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),Vb=function(e){const{version:t,origin:n}=bf(e.location.href);return"1.1279.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1279.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),
691
+ !1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function Yb(e,t){e.setClientId(t.clientId)}function Wb(e,t,n){e.load(),t.load(),n.sync()}function Kb(e,t,n){e.init(),t.init(),n.init()}function Xb(e,t){"sidebar"===t.route()&&e.connect()}Gb.sentry&&Vb&&function(e){const t=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;Lb({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1279.0",beforeSend:(e,t)=>{if(Db>=5)return Nf("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Db;try{const n=t&&t.originalException;n instanceof Event&&(e.extra||(e.extra={}),Object.assign(e.extra,{type:n.type,detail:n.detail,isTrusted:n.isTrusted}))}catch(e){}return e}});try{g_("host_config",bf(window.location.href))}catch(e){}
692
+ g_("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Zf(((e,t)=>{f_(e,{tags:{context:t}})}))}(Gb.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),Yb.$inject=["api","streamer"],Wb.$inject=["groups","session","router"],Kb.$inject=["autosaveService","persistedDefaults","serviceURL"],Xb.$inject=["frameSync","store"];const Zb=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Mf)}(),async function(e,t=window){const n=function(e){const t=bf(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:yf,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){
693
+ return"object"==typeof e&&null!==e?e:{}}(e);return{origin:xf(t.origin),ancestorLevel:wf(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{targetFrame:kf(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await _f(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=_f(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,r)}else o=n;const i={...e,...o};return r&&(i.rpc=r),i.apiUrl=function(e){const t=ar(e)
694
+ ;if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(Gb).then((e=>{!function(e,t){const n=new $;n.register("annotationsService",Rf).register("annotationActivity",If).register("api",Df).register("apiRoutes",qf).register("auth",Vf).register("autosaveService",Yf).register("frameSync",og).register("groups",sg).register("loadAnnotationsService",lg).register("localStorage",ug).register("persistedDefaults",hg).register("router",mg).register("serviceURL",pg).register("session",Bb).register("streamer",Ub).register("streamFilter",Fb).register("tags",jb).register("threadsService",qb).register("toastMessenger",$b).register("store",{factory:Di}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(Kb),n.run(Yb),n.run(Wb),n.run(Cf),n.run(Xb),B(Ee(cr.Provider,{value:n,children:Ee(pf,{})}),t)}(e,Zb)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),B(Ee(ff,{error:e}),t)}(e,Zb)));
695
695
  //# sourceMappingURL=sidebar.bundle.js.map