hypothesis 1.1435.0 → 1.1436.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?5ce852","styles/annotator.css":"styles/annotator.css?51e5f8","styles/annotator.css.map":"styles/annotator.css.map?dcd4af","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e179ab","styles/katex.min.css.map":"styles/katex.min.css.map?cd8c0e","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css.map":"styles/sidebar.css.map?0d0f70","styles/sidebar.css":"styles/sidebar.css?c78f51","styles/ui-playground.css":"styles/ui-playground.css?4e7479","styles/ui-playground.css.map":"styles/ui-playground.css.map?f88e1a","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b68d18","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?885080","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?2d716b","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?476c34","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?60af2d"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1435.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.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:c,manifest:s,notebookAppUrl:d,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
1
+ !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?eb5ab6","styles/annotator.css":"styles/annotator.css?51e5f8","styles/annotator.css.map":"styles/annotator.css.map?dcd4af","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e179ab","styles/katex.min.css.map":"styles/katex.min.css.map?cd8c0e","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?e8b77f","styles/sidebar.css.map":"styles/sidebar.css.map?7c1ede","styles/ui-playground.css":"styles/ui-playground.css?cd4790","styles/ui-playground.css.map":"styles/ui-playground.css.map?6edf64","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?b68d18","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?885080","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?3c3429","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?476c34","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?61fd19"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1436.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=a(d.notebookAppUrl||"https://hypothes.is/notebook"),h=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)e(s,i(t,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
@@ -1,5 +1,5 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?5ce852",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?eb5ab6",
3
3
  "styles/annotator.css": "styles/annotator.css?51e5f8",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?dcd4af",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -8,13 +8,13 @@
8
8
  "styles/katex.min.css.map": "styles/katex.min.css.map?cd8c0e",
9
9
  "styles/pdfjs-overrides.css": "styles/pdfjs-overrides.css?c95edf",
10
10
  "styles/pdfjs-overrides.css.map": "styles/pdfjs-overrides.css.map?1d8ac6",
11
- "styles/sidebar.css.map": "styles/sidebar.css.map?0d0f70",
12
- "styles/sidebar.css": "styles/sidebar.css?c78f51",
13
- "styles/ui-playground.css": "styles/ui-playground.css?4e7479",
14
- "styles/ui-playground.css.map": "styles/ui-playground.css.map?f88e1a",
11
+ "styles/sidebar.css": "styles/sidebar.css?e8b77f",
12
+ "styles/sidebar.css.map": "styles/sidebar.css.map?7c1ede",
13
+ "styles/ui-playground.css": "styles/ui-playground.css?cd4790",
14
+ "styles/ui-playground.css.map": "styles/ui-playground.css.map?6edf64",
15
15
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?b68d18",
16
16
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?885080",
17
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?2d716b",
17
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?3c3429",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?476c34",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?60af2d"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?61fd19"
20
20
  }
@@ -138,7 +138,7 @@ const e=this.anchors.find((e=>e.annotation.$tag===t));null!=e&&e.highlights&&awa
138
138
  this._sendDocumentInfo()}destroy(){var t;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){Gn(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{var e;const n=cr(t);if(!n)return;const i=Xn(n,null===(e=t.annotation)||void 0===e?void 0:e.$cluster);i.forEach((e=>{e._annotation=t.annotation})),t.highlights=i,this._hoveredAnnotations.has(t.annotation.$tag)&&Kn(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{
139
139
  const i=await this._integration.anchor(this.element,e.selector),o=Bn.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&&Gn(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=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,
140
140
  $highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+s(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),hr(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);Kn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Un(n),o=zn(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=ar(),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}={}){
141
- e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){oe(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function fr(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function pr(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.1435.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),
141
+ e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){oe(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function fr(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function pr(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.1436.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),
142
142
  Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function mr({config:t,groupId:e}){return _e("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:fr(t.notebookAppUrl,{...pr(t.notebookAppUrl,t),group:e})})}function gr({eventBus:t,config:e}){const[n,i]=Wt(0),[o,r]=Wt(!0),[s,a]=Wt(null),l=jt(""),c=jt(null);zt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),zt((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),zt((()=>{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:_e("div",{
143
143
  className:me("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:_e("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[_e("div",{className:"absolute right-0 m-3",children:_e(nn,{title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",classes:me("!bg-transparent enabled:hover:!bg-grey-3"),children:_e(Ne,{className:"w-4 h-4"})})}),_e(mr,{config:e,groupId:s},n)]})})}class _r{constructor(t,e,n){i(this,"_outerContainer",void 0),i(this,"_shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this._shadowRoot=Sn(this._outerContainer),Tt(_e(gr,{eventBus:e,config:n}),this._shadowRoot)}destroy(){Tt(null,this._shadowRoot),this._outerContainer.remove()}}function vr({eventBus:t,config:e}){const[n,i]=Wt(!0),o=jt(null);zt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{
144
144
  i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:_e("div",{className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:_e("div",{className:"relative w-full h-full","data-testid":"profile-inner",children:[_e("div",{className:"absolute right-0 m-3",children:_e(nn,{title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:me("!bg-transparent enabled:hover:!bg-grey-3"),children:_e(Ne,{className:"w-4 h-4"})})}),_e("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class br{constructor(t,e,n){i(this,"_outerContainer",void 0),i(this,"shadowRoot",void 0),this._outerContainer=document.createElement("hypothesis-profile"),t.appendChild(this._outerContainer),this.shadowRoot=Sn(this._outerContainer),Tt(_e(vr,{eventBus:e,config:n}),this.shadowRoot)}destroy(){Tt(null,this.shadowRoot),this._outerContainer.remove()}}var yr={exports:{}}
@@ -552,14 +552,14 @@ const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(cf).filter((e=>
552
552
  const a=null!==(n=o.position)&&void 0!==n?n:Number.MAX_SAFE_INTEGER,s=null!==(r=i.position)&&void 0!==r?r:Number.MAX_SAFE_INTEGER;return Math.sign(a-s)}};const gf=function(e){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:ff[t.sortKey]};if(!!t.filterQuery||Object.keys(t.filters).length>0){const e=function(e,t={}){const n=e=>{const n=t[e];return"string"==typeof n?[n]:[]},r=n("cfi"),o=n("page"),i=n("quote"),a=n("tag"),s=n("text"),l=n("uri"),c=n("user"),u=[],d=[],h=uf(e,af);for(const e of h){const t=e.slice(0,e.indexOf(":")),n=e.slice(t.length+1);switch(t){case"cfi":r.push(n);break;case"quote":i.push(n);break;case"page":o.push(n);break;case"since":{const t=86400,n={sec:1,min:60,hour:3600,day:t,week:7*t,month:30*t,year:365*t
553
553
  },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";d.push(e*n[t])}}break;case"tag":a.push(n);break;case"text":s.push(n);break;case"uri":l.push(n);break;case"user":c.push(n);break;default:u.push(e)}}return{any:{terms:u,operator:"and"},cfi:{terms:r,operator:"or"},quote:{terms:i,operator:"and"},page:{terms:o,operator:"or"},since:{terms:d,operator:"and"},tag:{terms:a,operator:"and"},text:{terms:s,operator:"and"},uri:{terms:l,operator:"or"},user:{terms:c,operator:"or"}}}(t.filterQuery||"",t.filters);n.filterFn=t=>function(e,t){const n=(e,t)=>new tf(t,of[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 nf("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new nf(t.operator,r)})),o=new nf("and",r);return e.filter((e=>e.id&&o.matches(e))).map((e=>e.id))}([t],e).length>0}const r=Xp(e.annotations,n),o={annotation:0,note:0,
554
554
  orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(!e.annotation)return!1;if(Do(e.annotation))return!1;const n=hf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function vf(){const e=Ea(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=de((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return gf(s)}var bf=Kr((function({loadAnnotationsService:e,onLogin:t}){var n;const r=Ea(),o=null!==(n=r.routeParams().id)&&void 0!==n?n:"",{rootThread:i}=vf(),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]),Oe(v,{children:[s&&Oe(Ta,{errorType:"annotation",onLoginRequest:t}),Oe(Hp,{threads:i.children})]})
555
- }),["loadAnnotationsService"]);class _f{constructor(e,t,n=window){var r,o,i;B(this,"version",void 0),B(this,"userAgent",void 0),B(this,"urls",void 0),B(this,"fingerprint",void 0),B(this,"account",void 0),B(this,"timestamp",void 0),B(this,"segment",void 0);const a="N/A";let s=a;e.userid&&(s=e.userid,e.displayName&&(s=`${e.displayName} (${s})`)),this.version="1.1435.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(o=o.metadata)||void 0===o?void 0:o.documentFingerprint)&&void 0!==r?r:a,this.account=s,this.timestamp=(new Date).toString();const l=null===(i=t[0])||void 0===i?void 0:i.segment;if(l){const e=[];l.cfi&&e.push(["CFI",l.cfi]),l.url&&e.push(["URL",l.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`}
555
+ }),["loadAnnotationsService"]);class _f{constructor(e,t,n=window){var r,o,i;B(this,"version",void 0),B(this,"userAgent",void 0),B(this,"urls",void 0),B(this,"fingerprint",void 0),B(this,"account",void 0),B(this,"timestamp",void 0),B(this,"segment",void 0);const a="N/A";let s=a;e.userid&&(s=e.userid,e.displayName&&(s=`${e.displayName} (${s})`)),this.version="1.1436.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(o=o.metadata)||void 0===o?void 0:o.documentFingerprint)&&void 0!==r?r:a,this.account=s,this.timestamp=(new Date).toString();const l=null===(i=t[0])||void 0===i?void 0:i.segment;if(l){const e=[];l.cfi&&e.push(["CFI",l.cfi]),l.url&&e.push(["URL",l.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`}
556
556
  asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}var yf="complete",wf="canceled";function xf(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function kf(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;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),b=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=b+l*g-t.clientHeight*g,r-=m,o-=p,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),
557
557
  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 xf(e,r.x,r.y),e._scrollSettings=null,t.end(yf);var a=1-t.ease(i);if(xf(e,r.x-r.differenceX*a,r.y-r.differenceY*a),o>=t.time)return t.endIterations++,t.scrollAncestor&&kf(t.scrollAncestor),void kf(e);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(kf.bind(null,e))}}function Nf(e){return e.self===e}function Sf(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function Af(){return!0}function Ef(e){if(e.assignedSlot)return Ef(e.assignedSlot)
558
558
  ;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 Tf=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=Ef(e),o=1,i=t.validTarget||Af,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?"));for(var s=[];r;)if(t.debug&&console.log("Scrolling parent node",r),i(r,o)&&(a?a(r,Sf):Sf(r))&&(o++,s.push(r)),!(r=Ef(r))){l(yf);break}return s.reduce(((n,r,o)=>function(e,t,n,r,o){var i,a=!t._scrollSettings,s=t._scrollSettings,l=Date.now(),c={passive:!0};function u(e){t._scrollSettings=null,t.parentElement&&t.parentElement._scrollSettings&&t.parentElement._scrollSettings.end(e),
559
559
  n.debug&&console.log("Scrolling ended with type",e,"for",t),o(e),i&&(t.removeEventListener("touchstart",i,c),t.removeEventListener("wheel",i,c))}s&&s.end(wf);var d=n.maxSynchronousAlignments;return null==d&&(d=3),t._scrollSettings={startTime:l,endIterations:0,target:e,time:n.time,ease:n.ease,align:n.align,isWindow:n.isWindow||Nf,maxSynchronousAlignments:d,end:u,scrollAncestor:r},"cancellable"in n&&!n.cancellable||(i=u.bind(null,wf),t.addEventListener("touchstart",i,c),t.addEventListener("wheel",i,c)),a&&kf(t),i}(e,r,t,s[o+1],l)),null)}function l(e){--o||n&&n(e)}},Cf=t(Tf);function Mf({children:e,icon:t,panelName:n,title:r,variant:o="panel",onActiveChanged:i,initialFocus:a}){const s=Ea(),l=s.isSidebarPanelOpen(n),c=ue(null),u=ue(l);le((()=>{u.current!==l&&(u.current=l,l&&c.current&&Cf(c.current),null==i||i(l))}),[l,i]);const d=he((()=>{s.toggleSidebarPanel(n,!1)}),[s,n]);return Oe(v,{children:l&&Oe(ur,{initialFocus:a,restoreFocus:!0,ref:c,classes:"mb-4",title:r,icon:t,onClose:d,transitionComponent:Hr,
560
560
  variant:o,scrollable:!1,children:e})})}function If({commandName:e,icon:t}){return Oe("span",{className:"whitespace-nowrap","data-testid":"instruction",children:[Oe(t,{className:X("w-em h-em","mx-1 -mt-1","text-color-text-light inline")}),Oe("em",{"data-testid":"command-name",children:e})]})}var zf=Kr((function({settings:e}){const t=!Gr(e);return Oe("ol",{className:"list-decimal pl-10 space-y-2",children:[Oe("li",{children:["To create an annotation, select text and then select the"," ",Oe(If,{icon:Ye,commandName:"Annotate"})," button."]}),Oe("li",{children:["To create a highlight (",Oe(Lr,{href:"https://web.hypothes.is/help/why-are-highlights-private-by-default/",target:"_blank",underline:"always",children:"visible only to you"}),"), select text and then select the"," ",Oe(If,{icon:Zt,commandName:"Highlight"})," button."]}),t&&Oe("li",{children:["To annotate in a private group, select the group from the groups dropdown. Don't see your group? Ask the group creator to send a"," ",Oe(Lr,{
561
561
  href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",underline:"always",children:"join link"}),"."]}),Oe("li",{children:["To reply to an annotation, select the"," ",Oe(If,{icon:In,commandName:"Reply"})," button."]})]})}),["settings"]);function Lf({label:e,children:t,classes:n}){return Oe(v,{children:[Oe("dt",{className:"col-span-1 sm:text-right font-medium",children:e}),Oe("dd",{className:X("col-span-1 sm:col-span-3 text-color-text-light break-words",n),children:t})]})}var Of=Kr((function({toastMessenger:e,versionData:t}){return Oe("div",{className:"space-y-4",children:[Oe("dl",{className:"grid grid-cols-1 sm:grid-cols-4 sm:gap-x-2",children:[Oe(Lf,{label:"Version",children:t.version}),Oe(Lf,{label:"User Agent",children:t.userAgent}),Oe(Lf,{classes:X("break-all"),label:"URL",children:t.urls}),Oe(Lf,{label:"Fingerprint",children:t.fingerprint}),t.segment&&Oe(Lf,{label:"Segment",children:t.segment}),Oe(Lf,{label:"Account",children:t.account}),Oe(Lf,{label:"Date",children:t.timestamp
562
- })]}),Oe("div",{className:"flex items-center justify-center",children:Oe(Kn,{onClick:()=>{try{hs(t.asFormattedString()),e.success("Copied version info to clipboard")}catch(t){e.error("Unable to copy version info")}},icon:yt,children:"Copy version details"})})]})}),["toastMessenger"]);function Rf({children:e}){return Oe("div",{"data-testid":"tab-header",className:"flex items-center",children:[Oe(nr,{classes:X("order-last","text-[16px]","text-grey-6 hover:text-grey-7 hover:bg-grey-3/50"),title:"Close",variant:"custom",size:"sm"}),Oe(Br,{classes:"grow gap-x-1 -mb-[1px] z-2",children:e})]})}function Pf({children:e,active:t,title:n,...r}){return Oe("div",{role:"tabpanel",...r,className:X("p-3 focus-visible-ring ring-inset",{hidden:!t}),hidden:!t,children:[n&&Oe(or,{children:n}),Oe("div",{className:"space-y-3 pt-2",children:e})]})}function Df({linkText:e,url:t}){return Oe("div",{className:"flex-1 flex items-center justify-center border-r last-of-type:border-r-0 text-md font-medium",children:Oe(Lr,{
562
+ })]}),Oe("div",{className:"flex items-center justify-center",children:Oe(Kn,{onClick:()=>{try{hs(t.asFormattedString()),e.success("Copied version info to clipboard")}catch(t){e.error("Unable to copy version info")}},icon:yt,children:"Copy version details"})})]})}),["toastMessenger"]);function Rf({children:e}){return Oe("div",{"data-testid":"tab-header",className:"flex items-center",children:[Oe(nr,{classes:X("order-last","text-[16px]","text-grey-6 hover:text-grey-7 hover:bg-grey-3/50","touch:!min-h-0"),title:"Close",variant:"custom",size:"sm"}),Oe(Br,{classes:"grow gap-x-1 -mb-[1px] z-2",children:e})]})}function Pf({children:e,active:t,title:n,...r}){return Oe("div",{role:"tabpanel",...r,className:X("p-3 focus-visible-ring ring-inset",{hidden:!t}),hidden:!t,children:[n&&Oe(or,{children:n}),Oe("div",{className:"space-y-3 pt-2",children:e})]})}function Df({linkText:e,url:t}){return Oe("div",{className:"flex-1 flex items-center justify-center border-r last-of-type:border-r-0 text-md font-medium",children:Oe(Lr,{
563
563
  variant:"text-light",href:t,target:"_blank",underline:"none",children:Oe("div",{className:"flex items-center gap-x-2",children:[Oe("span",{children:e})," ",Oe(Pt,{className:"w-3 h-3"})]})})})}var Ff=Kr((function({session:e}){var t,n;const r=Ea(),o=r.frames(),i=r.mainFrame(),a=r.profile(),s=null!==(t=null===(n=a.user_info)||void 0===n?void 0:n.display_name)&&void 0!==t?t:ts(a.userid),l=pe(),c=pe(),u=pe(),d=pe(),h=!!r.profile().preferences.show_sidebar_tutorial,[m,p]=ae("tutorial"),f=de((()=>{const e=[...o].sort(((e,t)=>e===i?-1:t===i?1:0));return new _f({userid:a.userid,displayName:s},e)}),[a,s,o,i]),g=`https://web.hypothes.is/get-help/?sys_info=${f.asEncodedURLString()}`;return Oe(Mf,{title:"Help",panelName:"help",onActiveChanged:he((t=>{!t&&h&&e.dismissSidebarTutorial()}),[e,h]),variant:"custom",children:[Oe(Rf,{children:[Oe(Dr,{id:l,"aria-controls":c,variant:"tab",textContent:"Help",selected:"tutorial"===m,onClick:()=>p("tutorial"),"data-testid":"tutorial-tab",children:"Help"}),Oe(Dr,{id:u,
564
564
  "aria-controls":d,variant:"tab",textContent:"Version",selected:"versionInfo"===m,onClick:()=>p("versionInfo"),"data-testid":"version-info-tab",children:"Version"})]}),Oe($e,{classes:X({"rounded-tl-none":"tutorial"===m}),children:[Oe("div",{className:"border-b",children:[Oe(Pf,{id:c,"aria-labelledby":l,active:"tutorial"===m,title:"Getting started",children:Oe(zf,{})}),Oe(Pf,{id:d,"aria-labelledby":u,active:"versionInfo"===m,title:"Version details",children:Oe(Of,{versionData:f})})]}),Oe("div",{className:"flex items-center p-3",children:[Oe(Df,{linkText:"Help topics",url:"https://web.hypothes.is/help/"}),Oe(Df,{linkText:"New support ticket",url:g})]})]})]})}),["session"]),Bf={exports:{}};function Hf(){}Hf.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function o(){r.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){
565
565
  for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),r=n[e],o=[];if(r&&t)for(var i=0,a=r.length;i<a;i++)r[i].fn!==t&&r[i].fn._!==t&&o.push(r[i]);return o.length?n[e]=o:delete n[e],this}},Bf.exports=Hf;var jf=Bf.exports.TinyEmitter=Hf;class $f extends Error{constructor(e){super(`Results size exceeds ${e}`)}}function Uf(e){return 0===e?50:200}class qf extends jf{constructor(e,{getPageSize:t=Uf,separateReplies:n=!0,incremental:r=!0,maxResults:o=null,sortBy:i="created",sortOrder:a="asc"}={}){super(),B(this,"_canceled",void 0),B(this,"_getPageSize",void 0),B(this,"_incremental",void 0),B(this,"_maxResults",void 0),B(this,"_expectedCount",void 0),B(this,"_fetchedCount",void 0),B(this,"_results",void 0),B(this,"_searchFn",void 0),B(this,"_separateReplies",void 0),B(this,"_sortBy",void 0),B(this,"_sortOrder",void 0),this._searchFn=e,this._getPageSize=t,this._separateReplies=n,
@@ -589,28 +589,28 @@ classes:X({"rounded-tl-none":s}),children:[Oe(Pf,{id:"share-panel",active:"share
589
589
  target:"_blank",title:"Hypothesis homepage",underline:"none",variant:"custom",children:Oe(mn,{className:"w-16 h-16 text-grey-7"})})})]})}function bg({onLogin:e,onSignUp:t}){return Ea().isLoggedIn()?null:Oe(Mf,{icon:Ln,title:"Login needed",panelName:"loginPrompt",children:[Oe("p",{children:"Please log in to create annotations or highlights."}),Oe(qe,{children:[Oe(Kn,{title:"Sign up",onClick:t,children:"Sign up"}),Oe(Kn,{title:"Log in",variant:"primary",onClick:e,children:"Log in"})]})]})}function _g({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i}){const a=()=>{r||i()},s=t>0?`${o} (${t} available)`:o;return Oe(Rr,{classes:X("bg-transparent min-w-[5.25rem]",{"font-bold":r}),variant:"text",onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,underline:"none",children:Oe(v,{children:[e,t>0&&!n&&Oe("span",{className:"relative bottom-[3px] left-[2px] text-[10px]",children:t})]})})}var yg=Kr((function({annotationsService:e,isLoading:t,settings:n,tabCounts:r}){
590
590
  const o=Ea(),i=o.selectedTab(),a=r.note,s=r.annotation,l=r.orphan,c=o.isWaitingToAnchorAnnotations(),u=e=>{o.selectTab(e)},d="annotation"===i&&0===s&&!c,h="note"===i&&0===a,m=(e,t,n)=>1===e?t:n,p=[];if(s>0){const e=m(s,"annotation","annotations");p.push(`${s} ${e}`)}if(a>0){const e=m(a,"note","notes");p.push(`${a} ${e}`)}if(l>0){const e=m(a,"orphan","orphans");p.push(`${l} ${e}`)}return Oe(v,{children:[Oe("div",{"aria-live":"polite",role:"status",className:"sr-only",children:p.join(", ")}),Oe("div",{className:X("space-y-3 pb-[9px]"),children:[Oe("div",{className:"flex gap-x-6 theme-clean:ml-[15px]",role:"tablist",children:[Oe(_g,{count:s,isWaitingToAnchor:c,isSelected:"annotation"===i,label:"Annotations",onSelect:()=>u("annotation"),children:"Annotations"}),Oe(_g,{count:a,isWaitingToAnchor:c,isSelected:"note"===i,label:"Page notes",onSelect:()=>u("note"),children:"Page Notes"}),l>0&&Oe(_g,{count:l,isWaitingToAnchor:c,isSelected:"orphan"===i,label:"Orphans",onSelect:()=>u("orphan"),children:"Orphans"})]
591
591
  }),"note"===i&&n.enableExperimentalNewNoteButton&&Oe("div",{className:"flex justify-end",children:Oe(Kn,{"data-testid":"new-note-button",onClick:()=>e.createPageNote(),variant:"primary",style:Wr(["ctaBackgroundColor"],n),children:[Oe(wn,{}),"New note"]})}),!t&&h&&Oe($e,{"data-testid":"notes-unavailable-message",variant:"flat",children:Oe(Ve,{classes:"text-center",children:"There are no page notes in this group."})}),!t&&d&&Oe($e,{"data-testid":"annotations-unavailable-message",variant:"flat",children:Oe(Ve,{classes:"text-center !space-y-1",children:[Oe("p",{children:"There are no annotations in this group."}),Oe("p",{children:["Create one by selecting some text and clicking the"," ",Oe(Ye,{className:"w-em h-em inline m-0.5 -mt-0.5",title:"Annotate"})," ","button."]})]})})]})]})}),["annotationsService","settings"]);function wg({label:e,icon:t,description:n,active:r,disabled:o=!1,setActive:i,testId:a}){return Oe(Kn,{"data-testid":a,classes:X({"font-medium rounded-lg py-1":!0,"text-grey-7 bg-grey-2":!r,
592
- "text-grey-1 bg-grey-7":r,"opacity-50":o}),disabled:o,onClick:()=>i(!r),pressed:r,variant:"custom",title:n,children:[t&&Oe(t,{className:"w-em h-em"}),e,Oe("div",{className:X({"h-[2em] w-[1.5px] -mt-1 -mb-1":!0,"bg-grey-3":!r,"bg-grey-5":r})}),Oe(r?_n:wn,{className:"w-em h-em"})]})}function xg({children:e}){return Oe("div",{className:"mb-3",children:Oe($e,{children:Oe(Ve,{children:e})})})}function kg({withCardContainer:e=!1}){const t=Ea(),n=t.selectedAnnotations().length,r=n>0,o=t.getFocusActive(),i=t.getFocusFilters(),a=Object.keys(i).length>0;if(!(r||a))return null;return Oe(e?xg:v,{children:Oe("div",{className:"flex flex-row gap-x-2 items-center","data-testid":"filter-controls",children:[Oe("b",{children:"Filters"}),r&&Oe(wg,{label:`${n} selected`,description:`Show ${n} selected annotations`,active:!0,setActive:()=>t.clearSelection(),testId:"selection-toggle"}),i.user&&Oe(wg,{icon:En,label:`By ${i.user.display}`,description:`Show annotations by ${i.user.display}`,active:o.has("user"),disabled:r,
593
- setActive:()=>t.toggleFocusMode({key:"user"}),testId:"user-focus-toggle"}),i.page&&Oe(wg,{icon:Ft,label:`Pages ${i.page.display}`,description:`Show annotations on pages ${i.page.display}`,active:o.has("page"),disabled:r,setActive:()=>t.toggleFocusMode({key:"page"}),testId:"page-focus-toggle"}),i.cfi&&Oe(wg,{icon:Ft,label:"Selected chapter",description:"Show annotations on selected book chapter(s)",active:o.has("cfi"),disabled:r,setActive:()=>t.toggleFocusMode({key:"cfi"}),testId:"cfi-focus-toggle"})]})})}var Ng=Kr((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const{rootThread:i,tabCounts:a}=vf(),s=Ea(),l=s.focusedGroupId(),c=s.isLoading(),u=s.isLoggedIn(),d=s.directLinkedAnnotationId(),h=d?s.findAnnotationByID(d):void 0,m=h?hf(h):"annotation",p=s.searchUris(),f=s.hasSidebarOpened(),g=s.profile().userid,v=!(c||!d)&&!h,b=s.directLinkedGroupFetchFailed(),_=v||b,y=!_,w=s.isSidebarPanelOpen("searchAnnotations"),x=!_&&!w,k=d&&!u&&!v&&!c,N=ue(l);le((()=>{
594
- if(!N.current||N.current!==l){if(N.current){const e=s.focusState().active;s.clearSelection(),e&&s.toggleFocusMode({active:!0})}N.current=l}l&&p.length&&r.load({groupId:l,uris:p})}),[s,r,l,g,p]),le((()=>{h&&!1===h.$orphan?(e.hoverAnnotation(h),e.scrollToAnnotation(h),s.selectTab(m)):h&&s.selectTab(m)}),[m,e,h,s]);const S=s.hasFetchedProfile();return le((()=>{S&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[S,u,f,o]),Oe("div",{children:[Oe("h2",{className:"sr-only",children:"Annotations"}),x&&Oe(kg,{withCardContainer:!0}),Oe(bg,{onLogin:t,onSignUp:n}),v&&Oe(Ta,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Oe(Ta,{errorType:"group",onLoginRequest:t}),y&&Oe(yg,{isLoading:c,tabCounts:a}),Oe(Hp,{threads:i.children}),k&&Oe(vg,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Sg=Kr((function({api:e,toastMessenger:t}){const n=Ea(),r=n.routeParams().q,o=he((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...df(t)};try{n.annotationFetchStarted()
595
- ;const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);le((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(null!=r?r:"").catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]);const{rootThread:i}=vf();return Oe(Hp,{threads:i.children})}),["api","toastMessenger"]);var Ag=Kr((function({toastMessenger:e}){const t=Ea().getToastMessages();return Oe("div",{className:X("z-10","absolute left-0 w-full"),children:Oe(yr,{messages:t,onMessageDismiss:t=>e.dismiss(t),transitionClasses:{transitionIn:"motion-safe:animate-slide-in-from-right lg:animate-fade-in motion-reduce:animate-fade-in"}})})}),["toastMessenger"]);function Eg(e){return e.organization&&e.organization.name}const Tg="__default__";function Cg(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;const n=(r=e.organization).id===Tg?Tg:`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]={...e.organization,groups:[]}),function(e,t){
596
- const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function Mg(e){const t=Cg(e),n=[],r=[];return Object.keys(t).sort().forEach((e=>{e===Tg?n.push(...t[e].groups):r.push(...t[e].groups)})),n.length&&r.push(...n),r}function Ig({heading:e,children:t}){return Oe(v,{children:[e&&Oe("h2",{className:"text-color-text-light p-3 leading-none uppercase",children:e}),Oe("ul",{className:"border-b",children:S(t).map((e=>Oe("li",{children:e},e.key)))})]})}var zg=Kr((function({isExpanded:e,group:t,groups:n,onExpand:r,toastMessenger:o}){const i=t.links.html,a=i||t.canLeave,s=t.scopes&&!t.scopes.enforced||t.isScopedToUri,l=Ea(),c=l.focusedGroupId(),u=t.id===c,d=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},h="private"===t.type?"Copy invite link":"Copy activity link",m=t.logo?Oe("img",{className:"w-4 h-4",alt:Eg(t),src:t.logo}):Oe("span",{className:"sr-only",children:Eg(t)});return Oe(op,{isDisabled:!s,isExpanded:!!a&&e,isSelected:u,
597
- isSubmenuVisible:a?e:void 0,label:t.name,leftChannelContent:m,onClick:s?()=>{l.clearDirectLinkedGroupFetchFailed(),l.clearDirectLinkedIds(),n.focus(t.id)}:d,onToggleSubmenu:d,submenu:Oe(v,{children:[Oe("ul",{children:[i&&Oe("li",{children:Oe(op,{href:i,icon:Pt,isSubmenuItem:!0,label:"View group activity"})}),i&&Oe("li",{children:Oe(op,{onClick:()=>(e=>{try{hs(e),o.success(`Copied link for "${t.name}"`)}catch(e){o.error("Unable to copy link")}})(i),icon:yt,isSubmenuItem:!0,label:h})}),t.canLeave&&Oe("li",{children:Oe(op,{icon:nn,isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await Ur({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&Oe("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 Lg({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Oe(Ig,{heading:r,
598
- children:n.map((n=>Oe(zg,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var Og=Kr((function({settings:e}){const t=Ea(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=t.importsPending()>0,l=de((()=>Mg(o)),[o]),c=de((()=>Mg(r)),[r]),u=de((()=>Mg(n)),[n]),d=t.defaultAuthority(),h=a&&!ns(a,d),m=t.getLink("groups.new"),[p,f]=ae(null);let g;if(i){const t=i.organization.logo||function(e){const t=qr(e);return t&&t.icon?t.icon:null}(e)||"",n=Eg(i)?Eg(i):"";g=Oe("span",{className:X("py-1"),children:Oe("span",{className:X("shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold"),children:[t&&Oe("img",{className:X("relative top-[1px] w-4 h-4"),src:t,alt:n}),i.name]})})}else g=Oe("span",{children:"…"});return!!Gr(e)&&n.length+r.length+o.length<2?g:Oe(np,{align:"left",contentClass:"min-w-[250px]",disabled:s,label:g,onOpenChanged:()=>f(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",
599
- children:[u.length>0&&Oe(Lg,{expandedGroup:p,onExpandGroup:f,heading:"Currently Viewing",groups:u}),c.length>0&&Oe(Lg,{expandedGroup:p,onExpandGroup:f,heading:"Featured Groups",groups:c}),l.length>0&&Oe(Lg,{expandedGroup:p,onExpandGroup:f,heading:"My Groups",groups:l}),h&&Oe(op,{icon:wn,href:m,label:"New private group"})]})}),["settings"]);function Rg({classes:e,...t}){return Oe(er,{...t,classes:X(e,"border border-transparent","aria-pressed:border-grey-3 aria-pressed:bg-grey-1")})}function Pg(){const e=Ea(),t=e.sortKey(),n=e.sortKeys().map((n=>Oe(op,{label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Oe("span",{className:"p-1",children:Oe(Un,{})});return Oe("div",{"data-component":"SortMenu",children:Oe(np,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var Dg=Kr((function({frameSync:e,onLogout:t,settings:n}){var r,o
600
- ;const i=Ea(),a=i.defaultAuthority(),s=i.profile(),l=ns(s.userid,a),c=qr(n),u=ts(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.importsPending()>0,b=i.isFeatureEnabled("client_user_profile"),_=()=>{e.notifyHost("openNotebook",i.focusedGroupId())},y=()=>e.notifyHost("openProfile"),w=f&&!l?i.getLink("user",{user:u}):void 0,x=Oe("span",{className:"p-1",children:Oe(En,{})});return Oe("div",{"data-testid":"user-menu",onKeyDown:e=>{"n"===e.key?(_(),m(!1)):b&&"p"===e.key&&(y(),m(!1))},children:Oe(np,{label:x,title:d,align:"right",open:h,onOpenChanged:m,children:[Oe(Ig,{children:[Oe(op,{label:d,isDisabled:!f,href:w,onClick:f?()=>l&&e.notifyHost("profileRequested"):void 0}),!l&&Oe(op,{label:"Account settings",href:i.getLink("account.settings")}),b&&Oe(op,{label:"Your profile",onClick:()=>y()}),Oe(op,{label:"Open notebook",onClick:()=>_()})]}),g&&Oe(Ig,{children:Oe(op,{
601
- isDisabled:v,label:"Log out",onClick:t})})]})})}),["frameSync","settings"]);function Fg(){const e=Ea(),t=e.isLoading(),n=e.isSidebarPanelOpen("searchAnnotations"),r=he((()=>{e.toggleSidebarPanel("searchAnnotations")}),[e]);return function(e){const t=ue(null),n=he((n=>{!n.metaKey&&!n.ctrlKey&&n.target instanceof HTMLElement&&["INPUT","TEXTAREA"].includes(n.target.tagName)||(t.current=document.activeElement,e.isSidebarPanelOpen("searchAnnotations")||(e.openSidebarPanel("searchAnnotations"),n.preventDefault(),n.stopPropagation()))}),[e]),r=us()?"meta":"ctrl";Qf("/",n),Qf(`${r}+k`,n)}(e),Oe(v,{children:[t&&Oe(pr,{}),!t&&Oe(jg,{icon:Rn,expanded:n,pressed:n,onClick:r,title:"Search annotations"})]})}function Bg({classes:e,disabled:t=!1,inputRef:n,onClearSearch:r,onKeyDown:o,onSearch:i,query:a}){const s=Ea().isLoading(),l=Ie(n),[c,u]=ae(a),[d,h]=ae(a);Qf("/",(e=>{var t;document.activeElement!==l.current&&(e.preventDefault(),null===(t=l.current)||void 0===t||t.focus())}));return a!==c&&(h(a),u(a)),Oe("form",{
602
- name:"searchForm",onSubmit:e=>{var t,n,r;(e.preventDefault(),null!==(t=l.current)&&void 0!==t&&t.value||c)&&i(null!==(n=null===(r=l.current)||void 0===r?void 0:r.value)&&void 0!==n?n:"")},className:X("space-y-3",e),children:Oe("div",{className:"relative",children:[Oe(er,{classes:"absolute left-0 text-[16px] top-[50%] translate-y-[-50%]",icon:Rn,size:"lg",title:"Search",type:"submit",disabled:t}),Oe(Sr,{"aria-label":"Search annotations",classes:X("pl-8 pr-8","disabled:text-grey-6","text-base touch:text-touch-base"),"data-testid":"search-input",dir:"auto",name:"query",placeholder:s?"Loading…":"Search annotations…",disabled:t||s,elementRef:l,value:d||"",onInput:e=>h(e.target.value),onKeyDown:o}),d&&Oe(er,{classes:"absolute right-0 text-[16px] top-[50%] translate-y-[-50%]",size:"lg",icon:et,"data-testid":"clear-button",title:"Clear search",onClick:r,disabled:t})]})})}var Hg=Kr((function({router:e}){const t=Ea(),{q:n}=t.routeParams(),r=t=>{e.navigate("stream",{q:t})};return Oe(Bg,{query:null!=n?n:"",onSearch:r,
603
- onClearSearch:()=>r("")})}),["router"]);function jg(e){return Oe(Rg,{size:"custom",classes:"touch:min-w-touch-minimum p-1",...e})}var $g=Kr((function({isSidebar:e,onLogin:t,onLogout:n,onSignUp:r,frameSync:o,settings:i}){const a=Wr(["accentColor"],i),s=Ea(),l=s.isLoggedIn(),c=s.hasFetchedProfile(),u=s.isSidebarPanelOpen("help"),d=s.isSidebarPanelOpen("shareGroupAnnotations");return Oe("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:Oe("div",{className:X("container flex items-center h-full","text-[16px]"),"data-testid":"top-bar-content",children:[Oe(e?Og:Hg,{}),Oe("div",{className:"grow flex items-center justify-end",children:[e&&Oe(v,{children:[Oe(eg,{}),Oe(Fg,{}),Oe(Pg,{}),Oe(jg,{icon:Dn,expanded:d,pressed:d,onClick:()=>{s.toggleSidebarPanel("shareGroupAnnotations")},title:"Share annotations on this page","data-testid":"share-icon-button"})]}),Oe(jg,{icon:Yt,expanded:u,pressed:u,onClick:()=>{const e=qr(i)
604
- ;e&&e.onHelpRequestProvided?o.notifyHost("helpRequested"):s.toggleSidebarPanel("help")},title:"Help","data-testid":"help-icon-button"}),l?Oe(Dg,{onLogout:n}):Oe("div",{className:"flex items-center text-md font-medium space-x-1 pl-1","data-testid":"login-links",children:[!l&&!c&&Oe("span",{children:"⋯"}),!l&&c&&Oe(v,{children:[Oe(Rr,{classes:"inline",onClick:r,style:a,underline:"none",children:"Sign up"}),Oe("div",{children:"/"}),Oe(Rr,{classes:"inline",onClick:t,style:a,underline:"none",children:"Log in"})]})]})]})]})})}),["frameSync","settings"]);function Ug(){const e=Ea(),t=e.filterQuery(),n=ue(null),r=e.hasSelectedAnnotations(),o=()=>{e.closeSidebarPanel("searchAnnotations")};return Oe(Mf,{panelName:"searchAnnotations",variant:"custom",title:"Search annotations",initialFocus:n,onActiveChanged:t=>{t||e.setFilterQuery(null)},children:Oe($e,{children:Oe(Ve,{children:[Oe("div",{className:"flex gap-x-3",children:Oe(Bg,{inputRef:n,classes:"grow",disabled:r,query:t||null,onClearSearch:o,onSearch:e.setFilterQuery,
605
- onKeyDown:e=>{"Escape"===e.key&&o()}})}),Oe(kg,{})]})})})}var qg=Kr((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=Ea(),a=i.profile(),s=i.route(),l="notebook"===s||"profile"===s,c=de((()=>Wr(["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=qr(n)||{onHelpRequestProvided:!1};return e&&!o.onHelpRequestProvided&&r})(d,a,n)&&i.openSidebarPanel("help")}),[d,a,n,i]);const h=Gr(n),m=async()=>{if(qr(n))t.notifyHost("loginRequested");else try{await e.login(),i.closeSidebarPanel("loginPrompt"),i.clearGroups(),r.reload()}catch(e){o.error(e.message)}},p=()=>{qr(n)?t.notifyHost("signupRequested"):window.open(i.getLink("signup"))};return Oe("div",{className:X("h-full min-h-full overflow-auto","lg:pb-16 bg-grey-2","js-thread-list-scroll-root",{"theme-clean":u,"pt-[49px]":!l,"p-4 lg:p-12":l}),"data-testid":"hypothesis-app",style:c,children:[!l&&Oe($g,{onLogin:m,onSignUp:p,
606
- onLogout:async()=>{await(async()=>{const e=i.countDrafts();if(0===e)return!0;let t="";return 1===e?t="You have an unsaved annotation.\nDo you really want to discard this draft?":e>1&&(t="You have "+e+" unsaved annotations.\nDo you really want to discard these drafts?"),Ur({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),qr(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),Oe("div",{className:"container",children:[Oe(Ag,{}),Oe(Ff,{}),Oe(Ug,{}),Oe(gg,{shareTab:!h}),s&&Oe("main",{children:["annotation"===s&&Oe(bf,{onLogin:m}),"notebook"===s&&Oe(tg,{}),"profile"===s&&Oe(rg,{}),"stream"===s&&Oe(Sg,{}),"sidebar"===s&&Oe(Ng,{onLogin:m,onSignUp:p})]})]})]})}),["auth","frameSync","session","settings","toastMessenger"]);function Gg({error:e}){return Oe("div",{className:X("m-2 mt-12"),children:Oe(lr,{title:"Unable to start Hypothesis",children:e.message})})}function Vg(e){const t=e.toString(16)
607
- ;return 1===t.length?"0"+t:t}function Wg(e){const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t).map(Vg).join("")}function Yg(e,t,n,r=[],o=2e3,i=window){const a=Wg(10),s={jsonrpc:"2.0",method:n,params:r,id:a};try{e.postMessage(s,t)}catch(e){return Promise.reject(e)}let l;const c=new Promise(((e,n)=>{l=r=>{if(r.origin!==t)return;if(!(r.data instanceof Object)||"2.0"!==r.data.jsonrpc||r.data.id!==a)return;const{error:o,result:i}=r.data;void 0!==o?n(o):void 0!==i?e(i):n(new Error("RPC reply had no result or error"))},i.addEventListener("message",l)})),u=[c];var d,h;return o&&u.push((d=o,h=`Request to ${t} timed out`,new Promise(((e,t)=>{setTimeout((()=>t(new Error(h))),d)})))),Promise.race(u).then((e=>(i.removeEventListener("message",l),e))).catch((e=>{throw i.removeEventListener("message",l),e}))}function Kg(e){const t=new URL(e).hash.slice(1),n=new URLSearchParams(t).get("config");return JSON.parse(n||"{}")}function Xg(e){
608
- if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function Jg(e){return parseInt(e)}function Zg(e){return e&&"function"==typeof e.toString?e.toString():""}function Qg(e,t=window){let n=t;for(let t=0;t<e;t++){if(n===n.top)throw new Error("The target parent frame has exceeded the ancestor tree. Try reducing the `requestConfigFromFrame.ancestorLevel` value in the `hypothesisConfig`");n=n.parent}return n}const ev=new Set;function tv(...e){const t=e.join();ev.has(t)||(console.warn(...e),ev.add(t))}tv.reset=()=>{ev.clear()};var nv=t((e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}));function rv(e,t,n,r){const o=t.find((e=>"__world__"===e.id));o&&e.unshift(o);const i=e.map((e=>e.id));t=t.filter((e=>!i.includes(e.id))),t.forEach((e=>e.isMember=!1)),e.forEach((e=>e.isMember=!0));const a=e.concat(t);return a.forEach((e=>{e.canLeave=!!function(e){
609
- const t=qr(e);return!t||!!t.allowLeavingGroups}(r)&&"private"===e.type})),a.forEach((e=>e.isScopedToUri=function(e,t){if(e.scopes&&e.scopes.uri_patterns.length>0&&t)return function(e,t){return t.some((t=>e.match(t.split("*").map(nv).join(".*"))))}(t,e.scopes.uri_patterns);return!0}(e,n))),a}let ov=[];const iv=e=>({changeFocusModeUser:t=>{var n;e.changeFocusModeUser(t);const r=null!==(n=null==t?void 0:t.groups)&&void 0!==n?n:[],o=function(e,t){return function(e,t){return t.filter((t=>e.includes(t.id)||t.groupid&&e.includes(t.groupid)))}(e,t).map((e=>e.id))}(r,e.allGroups());r.length&&!o.length&&console.error("No matching groups found in list of filtered group IDs"),e.filterGroups(o)},showContentInfo:t=>{e.setContentInfo(t)}});function av(e,t,n){const r=iv(e);function o(e){const n=t.rpcAllowedOrigins||[];if(null==(o=e.data)||"object"!=typeof o||"2.0"!==o.jsonrpc)return;var o;if(!n.includes(e.origin))return void tv(`Ignoring JSON-RPC request from non-whitelisted origin ${e.origin}`);const i=e.data
610
- ;e.source.postMessage(function(e){const t=r[e.method];if(void 0===t)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",result:"ok",id:e.id}}(i),e.origin)}ov.forEach((e=>{o(e)})),ov=[],window.removeEventListener("message",sv),n.addEventListener("message",o)}function sv(e){ov.push(e)}av.$inject=["store","settings","$window"];class lv{constructor(e){B(this,"_rpc",void 0),B(this,"_reportConfig",void 0),this._rpc=e.rpc,this._reportConfig=e.reportActivity}reportActivity(e,t){if(!this._rpc||!this._reportConfig)return;let n;switch(e){case"create":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:ls(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])}}
611
- lv.$inject=["settings"];class cv{constructor(e,t,n,r){B(this,"_activity",void 0),B(this,"_api",void 0),B(this,"_settings",void 0),B(this,"_store",void 0),this._activity=e,this._api=t,this._settings=n,this._store=r}_applyDraftChanges(e){const t={},n=this._store.getDraft(e);return n&&(t.tags=n.tags,t.text=n.text,t.permissions=n.isPrivate?is(e.user):as(e.user,e.group)),{...e,...t}}annotationFromData(e,t=new Date){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");const a=o.user_info,s=`s:${Wg(8)}`,l=Object.assign({created:t.toISOString(),group:r,permissions:ss(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Bo(l)&&(l.permissions=is(i)),this._settings.annotationMetadata&&(l.metadata={...this._settings.annotationMetadata}),l}
612
- create(e,t=new Date){const n=this.annotationFromData(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Bo(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Ro(n)}),jo(n)?this._store.selectTab("note"):$o(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:[{source:e.uri}],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),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,permissions:Ro(e)?as(t,e.group):is(t),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e){
613
- let t,n;const r=this._applyDraftChanges(e);let o;Lo(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}}if(cv.$inject=["annotationActivity","api","settings","store"],"function"!=typeof Symbol){var uv=0;Symbol=function(e){return"@@"+e+ ++uv},Symbol.for=function(e){return"@@"+e}}
592
+ "text-grey-1 bg-grey-7":r,"opacity-50":o}),disabled:o,onClick:()=>i(!r),pressed:r,variant:"custom",title:n,children:[t&&Oe(t,{className:"w-em h-em"}),Oe("span",{className:"max-w-36 truncate",children:e}),Oe("div",{className:X({"h-[2em] w-[1.5px] -mt-1 -mb-1":!0,"bg-grey-3":!r,"bg-grey-5":r})}),Oe(r?_n:wn,{className:"w-em h-em"})]})}function xg({children:e}){return Oe("div",{className:"mb-3",children:Oe($e,{children:Oe(Ve,{children:e})})})}function kg({withCardContainer:e=!1}){const t=Ea(),n=t.selectedAnnotations().length,r=n>0,o=t.getFocusActive(),i=t.getFocusFilters(),a=Object.keys(i).length>0;if(!(r||a))return null;return Oe(e?xg:v,{children:Oe("div",{className:"flex flex-row flex-wrap gap-2 items-center","data-testid":"filter-controls",children:[Oe("b",{children:"Filters"}),r&&Oe(wg,{label:`${n} selected`,description:`Show ${n} selected annotations`,active:!0,setActive:()=>t.clearSelection(),testId:"selection-toggle"}),i.user&&Oe(wg,{icon:En,label:`By ${i.user.display}`,
593
+ description:`Show annotations by ${i.user.display}`,active:o.has("user"),disabled:r,setActive:()=>t.toggleFocusMode({key:"user"}),testId:"user-focus-toggle"}),i.page&&Oe(wg,{icon:Ft,label:`Pages ${i.page.display}`,description:`Show annotations on pages ${i.page.display}`,active:o.has("page"),disabled:r,setActive:()=>t.toggleFocusMode({key:"page"}),testId:"page-focus-toggle"}),i.cfi&&Oe(wg,{icon:Ft,label:"Selected chapter",description:"Show annotations on selected book chapter(s)",active:o.has("cfi"),disabled:r,setActive:()=>t.toggleFocusMode({key:"cfi"}),testId:"cfi-focus-toggle"})]})})}var Ng=Kr((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){
594
+ const{rootThread:i,tabCounts:a}=vf(),s=Ea(),l=s.focusedGroupId(),c=s.isLoading(),u=s.isLoggedIn(),d=s.directLinkedAnnotationId(),h=d?s.findAnnotationByID(d):void 0,m=h?hf(h):"annotation",p=s.searchUris(),f=s.hasSidebarOpened(),g=s.profile().userid,v=!(c||!d)&&!h,b=s.directLinkedGroupFetchFailed(),_=v||b,y=!_,w=s.isSidebarPanelOpen("searchAnnotations"),x=!_&&!w,k=d&&!u&&!v&&!c,N=ue(l);le((()=>{if(!N.current||N.current!==l){if(N.current){const e=s.focusState().active;s.clearSelection(),e&&s.toggleFocusMode({active:!0})}N.current=l}l&&p.length&&r.load({groupId:l,uris:p})}),[s,r,l,g,p]),le((()=>{h&&!1===h.$orphan?(e.hoverAnnotation(h),e.scrollToAnnotation(h),s.selectTab(m)):h&&s.selectTab(m)}),[m,e,h,s]);const S=s.hasFetchedProfile();return le((()=>{S&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[S,u,f,o]),Oe("div",{children:[Oe("h2",{className:"sr-only",children:"Annotations"}),x&&Oe(kg,{withCardContainer:!0}),Oe(bg,{onLogin:t,onSignUp:n}),v&&Oe(Ta,{errorType:"annotation",onLoginRequest:t,
595
+ showClearSelection:!0}),b&&Oe(Ta,{errorType:"group",onLoginRequest:t}),y&&Oe(yg,{isLoading:c,tabCounts:a}),Oe(Hp,{threads:i.children}),k&&Oe(vg,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Sg=Kr((function({api:e,toastMessenger:t}){const n=Ea(),r=n.routeParams().q,o=he((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...df(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);le((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(null!=r?r:"").catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]);const{rootThread:i}=vf();return Oe(Hp,{threads:i.children})}),["api","toastMessenger"]);var Ag=Kr((function({toastMessenger:e}){const t=Ea().getToastMessages();return Oe("div",{className:X("z-10","absolute left-0 w-full"),children:Oe(yr,{messages:t,onMessageDismiss:t=>e.dismiss(t),transitionClasses:{
596
+ transitionIn:"motion-safe:animate-slide-in-from-right lg:animate-fade-in motion-reduce:animate-fade-in"}})})}),["toastMessenger"]);function Eg(e){return e.organization&&e.organization.name}const Tg="__default__";function Cg(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;const n=(r=e.organization).id===Tg?Tg:`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]={...e.organization,groups:[]}),function(e,t){const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function Mg(e){const t=Cg(e),n=[],r=[];return Object.keys(t).sort().forEach((e=>{e===Tg?n.push(...t[e].groups):r.push(...t[e].groups)})),n.length&&r.push(...n),r}function Ig({heading:e,children:t}){return Oe(v,{children:[e&&Oe("h2",{className:"text-color-text-light p-3 leading-none uppercase",children:e}),Oe("ul",{className:"border-b",children:S(t).map((e=>Oe("li",{children:e},e.key)))})]})}
597
+ var zg=Kr((function({isExpanded:e,group:t,groups:n,onExpand:r,toastMessenger:o}){const i=t.links.html,a=i||t.canLeave,s=t.scopes&&!t.scopes.enforced||t.isScopedToUri,l=Ea(),c=l.focusedGroupId(),u=t.id===c,d=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},h="private"===t.type?"Copy invite link":"Copy activity link",m=t.logo?Oe("img",{className:"w-4 h-4",alt:Eg(t),src:t.logo}):Oe("span",{className:"sr-only",children:Eg(t)});return Oe(op,{isDisabled:!s,isExpanded:!!a&&e,isSelected:u,isSubmenuVisible:a?e:void 0,label:t.name,leftChannelContent:m,onClick:s?()=>{l.clearDirectLinkedGroupFetchFailed(),l.clearDirectLinkedIds(),n.focus(t.id)}:d,onToggleSubmenu:d,submenu:Oe(v,{children:[Oe("ul",{children:[i&&Oe("li",{children:Oe(op,{href:i,icon:Pt,isSubmenuItem:!0,label:"View group activity"})}),i&&Oe("li",{children:Oe(op,{onClick:()=>(e=>{try{hs(e),o.success(`Copied link for "${t.name}"`)}catch(e){o.error("Unable to copy link")}})(i),icon:yt,isSubmenuItem:!0,label:h})}),t.canLeave&&Oe("li",{children:Oe(op,{icon:nn,
598
+ isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await Ur({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]}),!s&&Oe("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 Lg({expandedGroup:e,onExpandGroup:t,groups:n,heading:r}){return Oe(Ig,{heading:r,children:n.map((n=>Oe(zg,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n},n.id)))})}var Og=Kr((function({settings:e}){const t=Ea(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=t.importsPending()>0,l=de((()=>Mg(o)),[o]),c=de((()=>Mg(r)),[r]),u=de((()=>Mg(n)),[n]),d=t.defaultAuthority(),h=a&&!ns(a,d),m=t.getLink("groups.new"),[p,f]=ae(null);let g;if(i){const t=i.organization.logo||function(e){const t=qr(e);return t&&t.icon?t.icon:null}(e)||"",n=Eg(i)?Eg(i):""
599
+ ;g=Oe("span",{className:X("py-1"),children:Oe("span",{className:X("shrink-0 flex items-center gap-x-1 text-md text-color-text font-bold"),children:[t&&Oe("img",{className:X("relative top-[1px] w-4 h-4"),src:t,alt:n}),i.name]})})}else g=Oe("span",{children:"…"});return!!Gr(e)&&n.length+r.length+o.length<2?g:Oe(np,{align:"left",contentClass:"min-w-[250px]",disabled:s,label:g,onOpenChanged:()=>f(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[u.length>0&&Oe(Lg,{expandedGroup:p,onExpandGroup:f,heading:"Currently Viewing",groups:u}),c.length>0&&Oe(Lg,{expandedGroup:p,onExpandGroup:f,heading:"Featured Groups",groups:c}),l.length>0&&Oe(Lg,{expandedGroup:p,onExpandGroup:f,heading:"My Groups",groups:l}),h&&Oe(op,{icon:wn,href:m,label:"New private group"})]})}),["settings"]);function Rg({classes:e,...t}){return Oe(er,{...t,classes:X(e,"border border-transparent","aria-pressed:border-grey-3 aria-pressed:bg-grey-1")})}function Pg(){const e=Ea(),t=e.sortKey(),n=e.sortKeys().map((n=>Oe(op,{
600
+ label:n,onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Oe("span",{className:"p-1",children:Oe(Un,{})});return Oe("div",{"data-component":"SortMenu",children:Oe(np,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}var Dg=Kr((function({frameSync:e,onLogout:t,settings:n}){var r,o;const i=Ea(),a=i.defaultAuthority(),s=i.profile(),l=ns(s.userid,a),c=qr(n),u=ts(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.importsPending()>0,b=i.isFeatureEnabled("client_user_profile"),_=()=>{e.notifyHost("openNotebook",i.focusedGroupId())},y=()=>e.notifyHost("openProfile"),w=f&&!l?i.getLink("user",{user:u}):void 0,x=Oe("span",{className:"p-1",children:Oe(En,{})});return Oe("div",{"data-testid":"user-menu",onKeyDown:e=>{"n"===e.key?(_(),m(!1)):b&&"p"===e.key&&(y(),m(!1))},children:Oe(np,{label:x,title:d,align:"right",open:h,onOpenChanged:m,
601
+ children:[Oe(Ig,{children:[Oe(op,{label:d,isDisabled:!f,href:w,onClick:f?()=>l&&e.notifyHost("profileRequested"):void 0}),!l&&Oe(op,{label:"Account settings",href:i.getLink("account.settings")}),b&&Oe(op,{label:"Your profile",onClick:()=>y()}),Oe(op,{label:"Open notebook",onClick:()=>_()})]}),g&&Oe(Ig,{children:Oe(op,{isDisabled:v,label:"Log out",onClick:t})})]})})}),["frameSync","settings"]);function Fg(){const e=Ea(),t=e.isLoading(),n=e.isSidebarPanelOpen("searchAnnotations"),r=he((()=>{e.toggleSidebarPanel("searchAnnotations")}),[e]);return function(e){const t=ue(null),n=he((n=>{!n.metaKey&&!n.ctrlKey&&n.target instanceof HTMLElement&&["INPUT","TEXTAREA"].includes(n.target.tagName)||(t.current=document.activeElement,e.isSidebarPanelOpen("searchAnnotations")||(e.openSidebarPanel("searchAnnotations"),n.preventDefault(),n.stopPropagation()))}),[e]),r=us()?"meta":"ctrl";Qf("/",n),Qf(`${r}+k`,n)}(e),Oe(v,{children:[t&&Oe(pr,{}),!t&&Oe(jg,{icon:Rn,expanded:n,pressed:n,onClick:r,title:"Search annotations"})]})}
602
+ function Bg({classes:e,disabled:t=!1,inputRef:n,onClearSearch:r,onKeyDown:o,onSearch:i,query:a}){const s=Ea().isLoading(),l=Ie(n),[c,u]=ae(a),[d,h]=ae(a);Qf("/",(e=>{var t;document.activeElement!==l.current&&(e.preventDefault(),null===(t=l.current)||void 0===t||t.focus())}));return a!==c&&(h(a),u(a)),Oe("form",{name:"searchForm",onSubmit:e=>{var t,n,r;(e.preventDefault(),null!==(t=l.current)&&void 0!==t&&t.value||c)&&i(null!==(n=null===(r=l.current)||void 0===r?void 0:r.value)&&void 0!==n?n:"")},className:X("space-y-3",e),children:Oe("div",{className:"relative",children:[Oe(er,{classes:"absolute left-0 text-[16px] top-[50%] translate-y-[-50%]",icon:Rn,size:"lg",title:"Search",type:"submit",disabled:t}),Oe(Sr,{"aria-label":"Search annotations",classes:X("pl-8 pr-8","disabled:text-grey-6","text-base touch:text-touch-base"),"data-testid":"search-input",dir:"auto",name:"query",placeholder:s?"Loading…":"Search annotations…",disabled:t||s,elementRef:l,value:d||"",onInput:e=>h(e.target.value),onKeyDown:o
603
+ }),d&&Oe(er,{classes:"absolute right-0 text-[16px] top-[50%] translate-y-[-50%]",size:"lg",icon:et,"data-testid":"clear-button",title:"Clear search",onClick:r,disabled:t})]})})}var Hg=Kr((function({router:e}){const t=Ea(),{q:n}=t.routeParams(),r=t=>{e.navigate("stream",{q:t})};return Oe(Bg,{query:null!=n?n:"",onSearch:r,onClearSearch:()=>r("")})}),["router"]);function jg(e){return Oe(Rg,{size:"custom",classes:"touch:min-w-touch-minimum p-1",...e})}var $g=Kr((function({isSidebar:e,onLogin:t,onLogout:n,onSignUp:r,frameSync:o,settings:i}){const a=Wr(["accentColor"],i),s=Ea(),l=s.isLoggedIn(),c=s.hasFetchedProfile(),u=s.isSidebarPanelOpen("help"),d=s.isSidebarPanelOpen("shareGroupAnnotations");return Oe("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:Oe("div",{className:X("container flex items-center h-full","text-[16px]"),"data-testid":"top-bar-content",children:[Oe(e?Og:Hg,{}),Oe("div",{
604
+ className:"grow flex items-center justify-end",children:[e&&Oe(v,{children:[Oe(eg,{}),Oe(Fg,{}),Oe(Pg,{}),Oe(jg,{icon:Dn,expanded:d,pressed:d,onClick:()=>{s.toggleSidebarPanel("shareGroupAnnotations")},title:"Share annotations on this page","data-testid":"share-icon-button"})]}),Oe(jg,{icon:Yt,expanded:u,pressed:u,onClick:()=>{const e=qr(i);e&&e.onHelpRequestProvided?o.notifyHost("helpRequested"):s.toggleSidebarPanel("help")},title:"Help","data-testid":"help-icon-button"}),l?Oe(Dg,{onLogout:n}):Oe("div",{className:"flex items-center text-md font-medium space-x-1 pl-1","data-testid":"login-links",children:[!l&&!c&&Oe("span",{children:"⋯"}),!l&&c&&Oe(v,{children:[Oe(Rr,{classes:"inline",onClick:r,style:a,underline:"none",children:"Sign up"}),Oe("div",{children:"/"}),Oe(Rr,{classes:"inline",onClick:t,style:a,underline:"none",children:"Log in"})]})]})]})]})})}),["frameSync","settings"]);function Ug(){const e=Ea(),t=e.filterQuery(),n=ue(null),r=e.hasSelectedAnnotations(),o=()=>{
605
+ e.closeSidebarPanel("searchAnnotations")};return Oe(Mf,{panelName:"searchAnnotations",variant:"custom",title:"Search annotations",initialFocus:n,onActiveChanged:t=>{t||e.setFilterQuery(null)},children:Oe($e,{children:Oe(Ve,{children:[Oe("div",{className:"flex gap-x-3",children:Oe(Bg,{inputRef:n,classes:"grow",disabled:r,query:t||null,onClearSearch:o,onSearch:e.setFilterQuery,onKeyDown:e=>{"Escape"===e.key&&o()}})}),Oe(kg,{})]})})})}var qg=Kr((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=Ea(),a=i.profile(),s=i.route(),l="notebook"===s||"profile"===s,c=de((()=>Wr(["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=qr(n)||{onHelpRequestProvided:!1};return e&&!o.onHelpRequestProvided&&r})(d,a,n)&&i.openSidebarPanel("help")}),[d,a,n,i]);const h=Gr(n),m=async()=>{if(qr(n))t.notifyHost("loginRequested");else try{await e.login(),i.closeSidebarPanel("loginPrompt"),
606
+ i.clearGroups(),r.reload()}catch(e){o.error(e.message)}},p=()=>{qr(n)?t.notifyHost("signupRequested"):window.open(i.getLink("signup"))};return Oe("div",{className:X("h-full min-h-full overflow-auto","lg:pb-16 bg-grey-2","js-thread-list-scroll-root",{"theme-clean":u,"pt-[49px]":!l,"p-4 lg:p-12":l}),"data-testid":"hypothesis-app",style:c,children:[!l&&Oe($g,{onLogin:m,onSignUp:p,onLogout:async()=>{await(async()=>{const e=i.countDrafts();if(0===e)return!0;let t="";return 1===e?t="You have an unsaved annotation.\nDo you really want to discard this draft?":e>1&&(t="You have "+e+" unsaved annotations.\nDo you really want to discard these drafts?"),Ur({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),qr(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),Oe("div",{className:"container",children:[Oe(Ag,{}),Oe(Ff,{}),Oe(Ug,{}),Oe(gg,{shareTab:!h}),s&&Oe("main",{children:["annotation"===s&&Oe(bf,{onLogin:m
607
+ }),"notebook"===s&&Oe(tg,{}),"profile"===s&&Oe(rg,{}),"stream"===s&&Oe(Sg,{}),"sidebar"===s&&Oe(Ng,{onLogin:m,onSignUp:p})]})]})]})}),["auth","frameSync","session","settings","toastMessenger"]);function Gg({error:e}){return Oe("div",{className:X("m-2 mt-12"),children:Oe(lr,{title:"Unable to start Hypothesis",children:e.message})})}function Vg(e){const t=e.toString(16);return 1===t.length?"0"+t:t}function Wg(e){const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t).map(Vg).join("")}function Yg(e,t,n,r=[],o=2e3,i=window){const a=Wg(10),s={jsonrpc:"2.0",method:n,params:r,id:a};try{e.postMessage(s,t)}catch(e){return Promise.reject(e)}let l;const c=new Promise(((e,n)=>{l=r=>{if(r.origin!==t)return;if(!(r.data instanceof Object)||"2.0"!==r.data.jsonrpc||r.data.id!==a)return;const{error:o,result:i}=r.data;void 0!==o?n(o):void 0!==i?e(i):n(new Error("RPC reply had no result or error"))},i.addEventListener("message",l)})),u=[c];var d,h;return o&&u.push((d=o,h=`Request to ${t} timed out`,
608
+ new Promise(((e,t)=>{setTimeout((()=>t(new Error(h))),d)})))),Promise.race(u).then((e=>(i.removeEventListener("message",l),e))).catch((e=>{throw i.removeEventListener("message",l),e}))}function Kg(e){const t=new URL(e).hash.slice(1),n=new URLSearchParams(t).get("config");return JSON.parse(n||"{}")}function Xg(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function Jg(e){return parseInt(e)}function Zg(e){return e&&"function"==typeof e.toString?e.toString():""}function Qg(e,t=window){let n=t;for(let t=0;t<e;t++){if(n===n.top)throw new Error("The target parent frame has exceeded the ancestor tree. Try reducing the `requestConfigFromFrame.ancestorLevel` value in the `hypothesisConfig`");n=n.parent}return n}const ev=new Set;function tv(...e){const t=e.join();ev.has(t)||(console.warn(...e),ev.add(t))}tv.reset=()=>{ev.clear()};var nv=t((e=>{if("string"!=typeof e)throw new TypeError("Expected a string")
609
+ ;return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}));function rv(e,t,n,r){const o=t.find((e=>"__world__"===e.id));o&&e.unshift(o);const i=e.map((e=>e.id));t=t.filter((e=>!i.includes(e.id))),t.forEach((e=>e.isMember=!1)),e.forEach((e=>e.isMember=!0));const a=e.concat(t);return a.forEach((e=>{e.canLeave=!!function(e){const t=qr(e);return!t||!!t.allowLeavingGroups}(r)&&"private"===e.type})),a.forEach((e=>e.isScopedToUri=function(e,t){if(e.scopes&&e.scopes.uri_patterns.length>0&&t)return function(e,t){return t.some((t=>e.match(t.split("*").map(nv).join(".*"))))}(t,e.scopes.uri_patterns);return!0}(e,n))),a}let ov=[];const iv=e=>({changeFocusModeUser:t=>{var n;e.changeFocusModeUser(t);const r=null!==(n=null==t?void 0:t.groups)&&void 0!==n?n:[],o=function(e,t){return function(e,t){return t.filter((t=>e.includes(t.id)||t.groupid&&e.includes(t.groupid)))}(e,t).map((e=>e.id))}(r,e.allGroups());r.length&&!o.length&&console.error("No matching groups found in list of filtered group IDs"),
610
+ e.filterGroups(o)},showContentInfo:t=>{e.setContentInfo(t)}});function av(e,t,n){const r=iv(e);function o(e){const n=t.rpcAllowedOrigins||[];if(null==(o=e.data)||"object"!=typeof o||"2.0"!==o.jsonrpc)return;var o;if(!n.includes(e.origin))return void tv(`Ignoring JSON-RPC request from non-whitelisted origin ${e.origin}`);const i=e.data;e.source.postMessage(function(e){const t=r[e.method];if(void 0===t)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",result:"ok",id:e.id}}(i),e.origin)}ov.forEach((e=>{o(e)})),ov=[],window.removeEventListener("message",sv),n.addEventListener("message",o)}function sv(e){ov.push(e)}av.$inject=["store","settings","$window"];class lv{constructor(e){B(this,"_rpc",void 0),B(this,"_reportConfig",void 0),this._rpc=e.rpc,this._reportConfig=e.reportActivity}reportActivity(e,t){if(!this._rpc||!this._reportConfig)return;let n;switch(e){case"create":n=new Date(t.created).toISOString();break;case"update":
611
+ n=new Date(t.updated).toISOString();break;default:n=(new Date).toISOString()}const r={date:n,annotation:{id:t.id,isShared:ls(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])}}lv.$inject=["settings"];class cv{constructor(e,t,n,r){B(this,"_activity",void 0),B(this,"_api",void 0),B(this,"_settings",void 0),B(this,"_store",void 0),this._activity=e,this._api=t,this._settings=n,this._store=r}_applyDraftChanges(e){const t={},n=this._store.getDraft(e);return n&&(t.tags=n.tags,t.text=n.text,t.permissions=n.isPrivate?is(e.user):as(e.user,e.group)),{...e,...t}}annotationFromData(e,t=new Date){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")
612
+ ;const a=o.user_info,s=`s:${Wg(8)}`,l=Object.assign({created:t.toISOString(),group:r,permissions:ss(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Bo(l)&&(l.permissions=is(i)),this._settings.annotationMetadata&&(l.metadata={...this._settings.annotationMetadata}),l}create(e,t=new Date){const n=this.annotationFromData(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Bo(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!Ro(n)}),jo(n)?this._store.selectTab("note"):$o(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:[{source:e.uri}],uri:e.uri};this.create(t)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),
613
+ this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,permissions:Ro(e)?as(t,e.group):is(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;Lo(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}}if(cv.$inject=["annotationActivity","api","settings","store"],"function"!=typeof Symbol){var uv=0;Symbol=function(e){return"@@"+e+ ++uv},Symbol.for=function(e){return"@@"+e}}
614
614
  var dv=/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,hv=/[\s\n\\/='"\0<>]/,mv=/^(xlink|xmlns|xml)([A-Z])/,pv=/^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/,fv=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/,gv=/["&<]/;function vv(e){if(0===e.length||!1===gv.test(e))return e;for(var t=0,n=0,r="",o="";n<e.length;n++){switch(e.charCodeAt(n)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}n!==t&&(r+=e.slice(t,n)),r+=o,t=n+1}return n!==t&&(r+=e.slice(t,n)),r}var bv=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},_v=function(e,t,n){
615
615
  return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},yv={},wv=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),xv=/[A-Z]/g;function kv(e){var t="";for(var n in e){var r=e[n];if(null!=r&&""!==r){var o="-"==n[0]?n:yv[n]||(yv[n]=n.replace(xv,"-$&").toLowerCase()),i=";";"number"!=typeof r||o.startsWith("--")||wv.has(o)||(i="px;"),t=t+o+":"+r+i}}return t||void 0}function Nv(e,t){return Array.isArray(t)?t.reduce(Nv,e):null!=t&&!1!==t&&e.push(t),e}function Sv(){this.__d=!0}function Av(e,t){return{__v:e,context:t,
616
616
  props:e.props,setState:Sv,forceUpdate:Sv,__d:!0,__h:[]}}var Ev=[],Tv=[];function Cv(e,t,n,o){var i=r.__s;r.__s=!0;try{return Mv(e,t||{},n,o)}finally{r.__c&&r.__c(e,Tv),r.__s=i,Tv.length=0}}function Mv(e,t,n,o,i,a){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return"function"==typeof e?"":vv(e+"");var s=n.pretty,l=s&&"string"==typeof s?s:"\t";if(Array.isArray(e)){for(var c="",u=0;u<e.length;u++)s&&u>0&&(c+="\n"),c+=Mv(e[u],t,n,o,i,a);return c}if(void 0!==e.constructor)return"";r.__b&&r.__b(e);var d,h=e.type,m=e.props,p=!1;if("function"==typeof h){if(p=!0,!n.shallow||!o&&!1!==n.renderRootComponent){if(h===v){var f=[];return Nv(f,e.props.children),Mv(f,t,n,!1!==n.shallowHighOrder,i,a)}var g,b=e.__c=Av(e,t),_=r.__r,y=t,w=h.contextType;if(null!=w){var x=t[w.__c];y=x?x.props.value:w.__}if(h.prototype&&"function"==typeof h.prototype.render)(b=e.__c=new h(m,y)).__v=e,b._dirty=b.__d=!0,b.props=m,null==b.state&&(b.state={}),null==b._nextState&&null==b.__s&&(b._nextState=b.__s=b.state),b.context=y,
@@ -639,7 +639,7 @@ const n=Wo(e),r=Go(e),o=[`Created at: ${xp(new Date(e.created))}`,`Author: ${c(e
639
639
  }(Oe("html",{lang:"en",children:[Oe("head",{children:[Oe("title",{children:`Annotations on "${a}"`}),Oe("meta",{charSet:"UTF-8"})]}),Oe("body",{children:[Oe("section",{children:[Oe("h1",{children:"Summary"}),Oe("p",{children:Oe("time",{dateTime:o.toISOString(),children:xp(o)})}),Oe("p",{children:Oe("strong",{children:a})}),Oe("p",{children:Oe("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Oe("table",{children:Oe("tbody",{style:{verticalAlign:"top"},children:[Oe("tr",{children:[Oe("td",{children:"Group:"}),Oe("td",{children:t})]}),Oe("tr",{children:[Oe("td",{children:"Total users:"}),Oe("td",{children:s.length})]}),Oe("tr",{children:[Oe("td",{children:"Users:"}),Oe("td",{children:s.join(", ")})]}),Oe("tr",{children:[Oe("td",{children:"Total annotations:"}),Oe("td",{children:e.length})]}),Oe("tr",{children:[Oe("td",{children:"Total replies:"}),Oe("td",{children:l.length})]})]})})]}),Oe("hr",{}),Oe("section",{children:[Oe("h1",{children:"Annotations"}),e.map(((e,t)=>{
640
640
  const n=Wo(e),r=Go(e),o=Tm(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return Oe("article",{children:[Oe("h2",{children:["Annotation ",t+1,":"]}),Oe("table",{children:Oe("tbody",{style:{verticalAlign:"top"},children:[Oe("tr",{children:[Oe("td",{children:"Created at:"}),Oe("td",{children:Oe("time",{dateTime:e.created,children:xp(new Date(e.created))})})]}),Oe("tr",{children:[Oe("td",{children:"Author:"}),Oe("td",{children:c(e)})]}),n&&Oe("tr",{children:[Oe("td",{children:"Page:"}),Oe("td",{children:n})]}),Oe("tr",{children:[Oe("td",{children:"Type:"}),Oe("td",{children:Uo(e)})]}),r&&Oe("tr",{children:[Oe("td",{children:"Quote:"}),Oe("td",{children:Oe("blockquote",{style:{margin:0},children:r})})]}),Oe("tr",{children:[Oe("td",{children:"Comment:"}),Oe("td",{dangerouslySetInnerHTML:{__html:i}})]}),e.tags.length>0&&Oe("tr",{children:[Oe("td",{children:"Tags:"}),Oe("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}
641
641
  _exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>rs(e,n,t),{uri:i,title:a}=To(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>zo(e))),extractUsername:o}}}cb.$inject=[];class ub extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),B(this,"url",void 0),B(this,"response",void 0),B(this,"reason",void 0),this.url=e,this.response=t,this.reason=n}}async function db(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new ub(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new ub(e,n,"Failed to parse response")}var o;if(!n.ok)throw new ub(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}class hb{constructor(e,t,n){B(this,"_clientId",void 0),B(this,"search",void 0),B(this,"annotation",void 0),B(this,"group",void 0),B(this,"groups",void 0),B(this,"profile",void 0),
642
- 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,i]=await Promise.all([e,n()]),l=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(!l)throw new Error(`Missing API route: ${t}`);const c={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1435.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Qi(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await db(m.toString(),{body:s?JSON.stringify(ib(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished})
642
+ 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,i]=await Promise.all([e,n()]),l=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(!l)throw new Error(`Missing API route: ${t}`);const c={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1436.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Qi(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await db(m.toString(),{body:s?JSON.stringify(ib(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished})
643
643
  ;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}}hb.$inject=["apiRoutes","auth","store"];var mb={};function pb(e,t){"boolean"==typeof t&&(t={forever:t}),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 fb=pb;pb.prototype.reset=function(){this._attempts=1,
644
644
  this._timeouts=this._originalTimeouts.slice(0)},pb.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},pb.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;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},pb.prototype.attempt=function(e,t){this._fn=e,
645
645
  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)},pb.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},pb.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},pb.prototype.start=pb.prototype.try,pb.prototype.errors=function(){return this._errors},pb.prototype.attempts=function(){return this._attempts},pb.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},function(e){var t=fb;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},
@@ -754,7 +754,7 @@ this._updateImmediately=!0,this._configMessages={},this._reconnectionAttempts=0,
754
754
  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,Lb(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}Sk.$inject=["store","apiRoutes","auth","groups","session"];const Ak="hypothesis.user.tags.list",Ek="hypothesis.user.tags.map";class Tk{constructor(e){B(this,"_storage",void 0),this._storage=e}filter(e,t=null){const n=this._storage.getObject(Ak)||[];let r=0;return n.filter((n=>{
755
755
  if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${nv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(Ek)||{};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(Ek,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(Ak,n)}}Tk.$inject=["localStorage"];class Ck{constructor(e){B(this,"_store",void 0),this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}Ck.$inject=["store"];class Mk extends jf{constructor(e,t){super(),B(this,"_store",void 0),B(this,"_window",void 0),B(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))),
756
756
  this._delayedMessageQueue=[]}))}dismiss(e){this._store.getToastMessage(e)&&(this._store.removeToastMessage(e),this.emit("toastMessageDismissed",e))}_addMessage(e,t,{autoDismiss:n=!0,visuallyHidden:r=!1,delayed:o=!1}={}){if(this._store.hasToastMessage(e,t))return;if(o&&!this._window.document.hasFocus()){const o={autoDismiss:n,visuallyHidden:r};return void this._delayedMessageQueue.push({type:e,messageText:t,options:o})}const i={type:e,id:Wg(10),message:t,visuallyHidden:r,autoDismiss:n};this._store.addToastMessage(i),this.emit("toastMessageAdded",i)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}Mk.$inject=["store","$window"];const Ik=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),zk=function(e){
757
- const{version:t,origin:n}=Kg(e.location.href);return"1.1435.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1435.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 Lk(e,t){e.setClientId(t.clientId)}function Ok(e,t,n){e.load(),t.load(),n.sync()}function Rk(e,t,n){e.init(),t.init(),n.init()}function Pk(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}Ik.sentry&&zk&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;uk({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1435.0",
757
+ const{version:t,origin:n}=Kg(e.location.href);return"1.1436.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1436.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 Lk(e,t){e.setClientId(t.clientId)}function Ok(e,t,n){e.load(),t.load(),n.sync()}function Rk(e,t,n){e.init(),t.init(),n.init()}function Pk(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}Ik.sentry&&zk&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;uk({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1436.0",
758
758
  beforeSend:(e,t)=>{if(dk>=5)return tv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++dk;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{mw("host_config",Kg(window.location.href))}catch(e){}mw("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Eb(((e,t)=>{hk(e,t)}))}(Ik.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")}))}(document.body),Lk.$inject=["api","streamer"],Ok.$inject=["groups","session","router"],Rk.$inject=["autosaveService","persistedDefaults","serviceURL"],Pk.$inject=["frameSync","store","toastMessenger"];const Dk=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",sv)}(),async function(e,t=window){const n=function(e){
759
759
  const t=Kg(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Xg,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Zg(t.origin),ancestorLevel:Jg(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:Qg(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Yg(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services
760
760
  ;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=Yg(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=qr(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(Ik).then((e=>{!function(e,t){const n=new U