hypothesis 1.1163.0 → 1.1164.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?412e0e","styles/annotator.css":"styles/annotator.css?c10c10","styles/annotator.css.map":"styles/annotator.css.map?02fa76","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?776307","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?f2abe4","styles/sidebar.css.map":"styles/sidebar.css.map?7f97de","styles/ui-playground.css":"styles/ui-playground.css?851f65","styles/ui-playground.css.map":"styles/ui-playground.css.map?c066a7","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?709ee3","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?10556f","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?8b6a33","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?e0e9f5","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?55592d"};if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var p=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1163.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{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++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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";function s(s){s.setAttribute("data-hypothesis-asset","")}function t(t,e){var n=t.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,s(n),t.head.appendChild(n)}function e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,a=n.forceReload,i=void 0!==a&&a,l=t.createElement("script");o&&(l.type="module"),i&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,s(l),t.head.appendChild(l)}function n(t,e,n,r){var o=t.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),s(o),t.head.appendChild(o)}function r(t,e,n){var r=t.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),s(r),t.head.appendChild(r)}function o(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=s.match(/(https?):\/\/([^:/]+)/);return t?{protocol:t[1],hostname:t[2]}:null}function i(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=s.currentScript;return t?a(t.src):null}function l(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=i(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)}var c={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?b55880","styles/annotator.css":"styles/annotator.css?c10c10","styles/annotator.css.map":"styles/annotator.css.map?02fa76","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?776307","styles/katex.min.css.map":"styles/katex.min.css.map?42d80c","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?f2abe4","styles/sidebar.css.map":"styles/sidebar.css.map?7f97de","styles/ui-playground.css":"styles/ui-playground.css?851f65","styles/ui-playground.css.map":"styles/ui-playground.css.map?c066a7","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?709ee3","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?bd3634","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?8b6a33","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?e0e9f5","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?dc6ea4"};if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var p=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),u=l(p.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1164.0/");if(document.querySelector("hypothesis-app")){!function(s,n){r(s,"fetch",n.apiUrl),r(s,"fetch",n.apiUrl+"links");for(var a=0,i=["scripts/sidebar.bundle.js"];a<i.length;a++)e(s,o(n,i[a]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,o(n,c[l]))}(document,{assetRoot:u,manifest:c,apiUrl:p.apiUrl})}else{var d=p,h=l(d.notebookAppUrl||"https://hypothes.is/notebook"),y=l(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,a){if(!s.querySelector('link[type="application/annotator+html"]')){n(s,"sidebar","html",a.sidebarAppUrl),n(s,"notebook","html",a.notebookAppUrl),r(s,"style",o(a,"styles/annotator.css")),n(s,"hypothesis-client","javascript",a.assetRoot+"build/boot.js");for(var i=0,l=["scripts/annotator.bundle.js"];i<l.length;i++)e(s,o(a,l[i]),{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++)t(s,o(a,u[p]))}}(document,{assetRoot:u,manifest:c,notebookAppUrl: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?412e0e",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?b55880",
3
3
  "styles/annotator.css": "styles/annotator.css?c10c10",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?02fa76",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -13,8 +13,8 @@
13
13
  "styles/ui-playground.css": "styles/ui-playground.css?851f65",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?c066a7",
15
15
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?709ee3",
16
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?10556f",
16
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?bd3634",
17
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?8b6a33",
18
18
  "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?e0e9f5",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?55592d"
19
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?dc6ea4"
20
20
  }
@@ -121,7 +121,7 @@ this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)}
121
121
  ;const n=po(t);if(!n)return;const i=ze(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)&&Xe(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{const i=await this._integration.anchor(this.element,e.selector),o=Ie.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&&We(e.highlights);this._updateAnchors(n,e)}
122
122
  _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,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+St(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),go(),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);Xe(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_scrollToClosestOffScreenAnchor(t,e){const n=function(t,e){let n=null,i=0;for(let r of t){var o;if(null===(o=r.highlights)||void 0===o||!o.length)continue
123
123
  ;const t=Ye(r.highlights).top;"up"===e&&t>=137||"down"===e&&t<=window.innerHeight-22||(!n||"up"===e&&t>i||"down"===e&&t<i)&&(n=r,i=t)}return n}(this.anchors.filter((({annotation:e})=>t.includes(e.$tag))),e);n&&this._integration.scrollToAnchor(n)}_onSelection(t){if(!this._integration.canAnnotate(t))return void this._onClearSelection();const e=document.getSelection(),n=He(e),i=qe(e);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=uo(),this._isAdderVisible=!0,this._adder.show(i,n)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){
124
- 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._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Kt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function _o(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function vo(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1163.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0]
124
+ 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._sideBySideActive=this._integration.fitSideBySide(t)}get sideBySideActive(){return this._sideBySideActive}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){Kt(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function _o(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function vo(t,e){var n;const i={};for(let[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1164.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0]
125
125
  ;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 yo({config:t,groupId:e}){return ct("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allowFullScreen:!0,src:_o(t.notebookAppUrl,{...vo(t.notebookAppUrl,t),group:e})})}function bo({eventBus:t,config:e}){const[n,i]=G(0),[o,r]=G(!0),[s,a]=G(null),l=J(""),h=J(null);K((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),K((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),K((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),h.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ct("div",{className:c("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",
126
126
  children:ct("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ct("div",{className:"absolute right-0 text-xl m-3",children:ct(gt,{icon:"cancel",title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=h.current)||void 0===t||t.publish("closeNotebook")},variant:"dark"})}),ct(yo,{config:e,groupId:s},n)]})})}class wo{constructor(t,e,n){this._outerContainer=document.createElement("hypothesis-notebook"),t.appendChild(this._outerContainer),this.shadowRoot=Ae(this._outerContainer),I(ct(bo,{eventBus:e,config:n}),this.shadowRoot)}destroy(){I(null,this.shadowRoot),this._outerContainer.remove()}}var Co={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l=Math.round,c=Math.abs,h=Date.now;function u(t,e,n){return setTimeout(v(t,n),e)}function d(t,e,n){return!!Array.isArray(t)&&(f(t,n[e],n),!0)}function f(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(t.length!==o)for(i=0;i<t.length;)e.call(n,t[i],i,t),
127
127
  i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function p(t,n,i){var o="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=e.console&&(e.console.warn||e.console.log);return r&&r.call(e.console,o,i),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(t){if(t===o||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==o&&null!==i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign;var g=p((function(t,e,n){for(var i=Object.keys(e),r=0;r<i.length;)(!n||n&&t[i[r]]===o)&&(t[i[r]]=e[i[r]]),r++;return t}),"extend","Use `assign`."),m=p((function(t,e){return g(t,e,!0)}),"merge","Use `assign`.");function _(t,e,n){var i,o=e.prototype;(i=t.prototype=Object.create(o)).constructor=t,
@@ -596,31 +596,31 @@ title:"Quote"}),Zr(kg,{disabled:e,icon:Kl,onClick:()=>t("link"),shortcutKey:xg.l
596
596
  ;Dr((()=>{var e;o||(null===(e=a.current)||void 0===e||e.focus())}),[o]);const s=e=>{a.current&&(!function(e,t){const n=e=>{const n=e({text:t.value,selectionStart:t.selectionStart,selectionEnd:t.selectionEnd});t.value=n.text,t.selectionStart=n.selectionStart,t.selectionEnd=n.selectionEnd,t.focus()},r=e=>{const t=e.text.slice(0,e.selectionStart);return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?bg(e,"$$","$$","Insert LaTeX"):bg(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>bg(e,"**","**","Bold")));break;case"italic":n((e=>bg(e,"*","*","Italic")));break;case"quote":n((e=>wg(e,"> ")));break;case"link":n((e=>vg(e)));break;case"image":n((e=>vg(e,fg)));break;case"math":n(r);break;case"numlist":n((e=>wg(e,"1. ")));break;case"list":n((e=>wg(e,"* ")));break;default:throw new Error(`Unknown toolbar command "${e}"`)}}(e,a.current),t(a.current.value))};return Zr("div",{className:"leading-none",children:[Zr(Ng,{onCommand:s,isPreviewing:o,onTogglePreview:()=>i(!o)}),o?Zr(cg,{markdown:n,
597
597
  classes:"border bg-grey-1 p-2",style:r}):Zr(Sg,{"aria-label":e,dir:"auto",classes:Vn("w-full min-h-[8em] resize-y","rounded-t-none","text-base touch:text-touch-base"),containerRef:a,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(const[t,n]of Object.entries(xg))n===e.key&&(e.stopPropagation(),e.preventDefault(),s(t))},onInput:e=>t(e.target.value),value:n,style:r})]})}const Eg=e=>e;function Ag({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Eg,onSelectItem:i,open:a=!1}){const s=Hr((()=>r.map(((t,r)=>{const a=n?{id:`${n}${r}`}:{};return Zr("li",{role:"option","aria-selected":(e===r).toString(),className:Vn("flex items-center","border-l-4 py-1 px-3 cursor-pointer hover:bg-grey-2","touch:h-touch-minimum",{"border-brand bg-grey-1":e===r,"border-transparent":e!==r}),onClick:()=>{i(t)},...a,children:o(t,r)},`AutocompleteList-${r}`)}))),[e,n,r,o,i]),l=t?{id:t}:{},c=0===r.length||!a;return Zr("div",{className:"relative",children:Zr("div",{className:Vn({hidden:c
598
598
  },"absolute top-[3px] z-3","min-w-[10em]"),"data-testid":"autocomplete-list-container",children:Zr(Ic,{width:"auto",children:[Zr("ul",{tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s}),Zr(Jc,{direction:"up",classes:"top-[-8px] left-[3px]"})]})})})}let Tg=0;var Mg=Po((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){const i=Pr(),[a,s]=Ir([]),[l,c]=Ir(-1),[u,d]=Ir(!1),[h]=Ir((()=>(++Tg,`TagEditor-${Tg}`))),p=Pr(null);_o(p,u,(()=>{d(!1)}));const m=()=>i.current.value.trim(),f=()=>m()&&m().length>0,g=()=>{i.current.value="",null==n||n("")},v=t=>{e(t)&&(d(!1),c(-1),g(),i.current.focus())},b=e=>{let t=l+e;t<-1?t=a.length-1:t>=a.length&&(t=-1),c(t)},_=l>=0?`${h}-AutocompleteList-item-${l}`:"";return Zr("div",{className:"space-y-4",children:[Zr(ug,{children:r.map((e=>Zr(dg,{onRemoveTag:t,tag:e},e)))}),Zr("div",{id:h,"data-testid":"combobox-container",ref:p,role:"combobox","aria-expanded":u.toString(),"aria-owns":`${h}-AutocompleteList`,"aria-haspopup":"listbox",
599
- children:[Zr(Rc,{onInput:()=>{null==n||n(m()),(()=>{if(f()){const e=o.filter(m());s(((e,t)=>{const n=[];for(const r of e)t.indexOf(r)<0&&n.push(r);return n.sort()})(e,r)),d(e.length>0)}else d(!1);c(-1)})()},onKeyDown:e=>{switch(e.key){case"ArrowUp":b(-1),e.preventDefault();break;case"ArrowDown":b(1),e.preventDefault();break;case"Escape":g(),e.preventDefault();break;case"Enter":case",":v(-1===l?m():a[l]),e.preventDefault();break;case"Tab":if(!f())break;-1!==l?v(a[l]):1===a.length?v(a[0]):v(m()),e.preventDefault()}},onFocus:()=>{f()&&d(!0)},elementRef:i,placeholder:"Add new tags",type:"text",autoComplete:"off","aria-autocomplete":"list","aria-activedescendant":_,"aria-controls":`${h}-AutocompleteList`,dir:"auto"}),Zr(Ag,{id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{const t=m().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Zr("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Zr("span",{children:[Zr("strong",{children:r}),o,Zr("strong",{children:i
600
- })]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Lg(){return Zr("div",{className:"pt-2 border-t text-sm leading-none",children:Zr(Pc,{classes:"flex items-center",color:"text-light",href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",title:"View more information about the Creative Commons Public Domain dedication",children:[Zr(fl,{className:"w-em h-em text-tiny"}),Zr(vl,{className:"w-em h-em ml-px text-tiny"}),Zr("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})}function zg(e){return null!==e.offsetParent}function Rg({className:e,closeMenu:t,children:n,visible:r}){const o=Pr();Dr((()=>{let e;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return Zr("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(zg)
601
- ;let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(e.key){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let Ig=!1;const Og=()=>{};function Dg({align:e="left",arrowClass:t="",children:n,containerPositioned:r=!0,contentClass:o,defaultOpen:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[d,h]=Ir(i);"boolean"==typeof s&&(d=s,h=l||Og);const p=Pr(d);Dr((()=>{"function"==typeof l&&p.current!==d&&(p.current=d,l(d))}),[d,l]);const m=e=>{if("mousedown"===e.type)Ig=!0;else if("click"===e.type&&Ig)return Ig=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=Fr((()=>h(!1)),[h]),g=Pr();_o(g,d,f);const v=e=>e.stopPropagation();return Zr("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:r?"relative":"static"},
602
- onClick:v,onMouseDown:v,children:[Zr("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:Vn("focus-visible-ring","flex items-center justify-center rounded-sm transition-colors",{"text-grey-7 hover:text-grey-9":!d,"text-brand":d}),"data-testid":"menu-toggle-button",onMouseDown:m,onClick:m,"aria-label":u,title:u,children:Zr("span",{className:"flex items-center gap-x-1",children:[a,c&&Zr("span",{className:Vn({"rotate-180 text-color-text":d}),children:Zr(go,{name:"expand-menu",classes:"w-2.5 h-2.5"})})]})}),d&&Zr(Qn,{children:[Zr(Jc,{direction:"up",classes:Vn("right-0 top-[calc(100%-3px)] w-[15px]",t)}),Zr("div",{className:Vn("focus-visible-ring","absolute top-[calc(100%+5px)] z-1 border shadow","bg-white text-lg",{"left-0":"left"===e,"right-0":"right"===e},o),"data-testid":"menu-content",role:"menu",tabIndex:-1,onClick:f,onKeyDown:e=>{const t=e.key;"Enter"!==t&&" "!==t||setTimeout((()=>{f()}))},children:Zr(Rg,{visible:!0,children:n})})]})]})}function Bg({children:e,visible:t}){
603
- const n=Pr(),[r,o]=Ir(t?"auto":0),[i,a]=Ir(t);Dr((()=>{if(t===(0!==r))return;const e=n.current;t?(e.style.display="",a(!0),o(e.scrollHeight)):(e.style.height=`${e.scrollHeight}px`,e.getBoundingClientRect(),o(0))}),[r,t]);return Zr("div",{ontransitionend:Fr((()=>{t?o("auto"):a(!1)}),[o,t]),ref:n,style:{display:i?"":"none",height:r,overflow:"auto"===r?"visible":"hidden",transition:"height 0.15s ease-in"},children:e})}function Pg({title:e,isExpanded:t,onToggleSubmenu:n}){return Zr("div",{"data-testid":"submenu-toggle",role:"none",className:Vn("flex flex-col items-center justify-center w-10 h-10","text-grey-6 bg-grey-1","bg-clip-content border-[8px] border-transparent rounded-xl","group-hover:hover:text-grey-8",{"bg-grey-4":t,"group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Zr(go,{name:t?"collapse-menu":"expand-menu",classes:"w-3 h-3"})})}function Hg({href:e,icon:t,iconAlt:n,isDisabled:r,isExpanded:o,isSelected:i,isSubmenuItem:a,isSubmenuVisible:s,label:l,onClick:c,onToggleSubmenu:u,submenu:d}){
604
- const h=t&&-1!==t.indexOf("/"),p=Pr();let m,f;const g="boolean"==typeof s,v="boolean"==typeof i;Dr((()=>()=>{clearTimeout(m)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}};let _=null;t&&"blank"!==t&&(_=h?Zr("img",{className:"w-4 h-4",alt:n,src:t}):Zr(go,{name:t,classes:"h-3 w-3"}));const y=a?null:_,w=a?_:null,x=w&&a,k=Zr(Qn,{children:[(y||a||"blank"===t)&&Zr("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:y}),Zr("span",{className:"flex items-center grow whitespace-nowrap px-1",children:l}),x&&Zr("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Zr(Pg,{title:`Show actions for ${l}`,isExpanded:s,onToggleSubmenu:u})]}),S=Vn("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","border-b","group",{"min-h-[30px] font-normal":a,"min-h-[40px] font-medium":!a,
605
- "bg-grey-1 hover:bg-grey-3":a||o,"bg-white hover:bg-grey-1":!a&&!o,"pr-1":!g},{"border-l-[4px] border-l-brand":i,"pl-[4px]":!i,"border-b-grey-3":o,"border-b-transparent":!o,"text-color-text-light":r,"text-color-text":!r});return f=e?Zr("a",{ref:p,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:k}):Zr("div",{ref:p,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem","aria-checked":v?i:void 0,"aria-haspopup":g,"aria-expanded":g?s:void 0,children:k}),Zr(Qn,{children:[f,g&&Zr(Bg,{visible:s,children:Zr(Rg,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{p.current.focus()}))},visible:s,className:"border-b",children:d})})]})}var Fg=Po((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=Do(["ctaTextColor","ctaBackgroundColor"],a),l=Zr("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,
606
- children:Zr(go,{name:"expand-menu",classes:"w-4 h-4"})});return Zr("div",{className:"flex flex-row gap-x-3",children:[Zr("div",{className:"flex relative",children:[Zr(ro,{classes:Vn("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"large",variant:"primary",children:["Post to ",n?"Only Me":e.name]}),Zr("div",{className:Vn("flex flex-row rounded-r-sm bg-grey-7 hover:bg-grey-8"),style:s,children:Zr(Dg,{arrowClass:Vn("right-[10px]"),containerPositioned:!1,contentClass:Vn("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Zr(Hg,{icon:"open"===e.type?"public":"groups",label:e.name,isSelected:!n,onClick:()=>i(!1)}),Zr(Hg,{icon:"lock",label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]}),Zr("div",{children:Zr(ro,{classes:"p-2.5",icon:"cancel",onClick:r,size:"large",children:"Cancel"})})]})}),["settings"]);var jg=Po((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){
607
- const[a,s]=Ir(null),l=ls(),c=l.getGroup(e.group),u=!t.isPrivate&&c&&"private"!==c.type,d=t.tags,h=t.text,p=!h&&!d.length,m=Fr((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),f=Fr((e=>{if(!e||d.indexOf(e)>=0)return!1;const t=[...d,e];return o.store(t),m(t),!0}),[m,d,o]),g=Fr((e=>{const t=[...d],n=t.indexOf(e);return n>=0&&(t.splice(n,1),m(t),!0)}),[m,d]),v=Fr((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),b=Fr((n=>{l.createDraft(e,{...t,isPrivate:n}),_i(e)||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,l]),_=async()=>{a&&f(a);const t=`${Mi(e)} ${yi(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch(e){i.error("Saving annotation failed")}},y=Fr((()=>{l.removeDraft(e),yi(e)||l.removeAnnotations([e])}),[e,l]);return Zr("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),_())},children:[Zr(Cg,{textStyle:Do(["annotationFontFamily"],r),
608
- label:"Annotation body",text:h,onEditText:v}),Zr(Mg,{onAddTag:f,onRemoveTag:g,onTagInput:s,tagList:d}),c&&Zr(Fg,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:y,onSave:_,onSetPrivate:b}),u&&Zr(Lg,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Ug({domain:e,link:t,title:n}){return Zr("div",{className:"flex gap-x-1",children:[Zr("div",{className:"text-color-text-light",children:['on "',t?Zr(Pc,{href:t,target:"_blank",children:n}):Zr("span",{children:n}),'"']}),e&&Zr("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function qg({group:e,isPrivate:t}){const n=null==e?void 0:e.links.html;return Zr(Qn,{children:[e&&n&&Zr(vo,{classes:Vn("flex items-baseline gap-x-1","p-muted-link"),href:e.links.html,target:"_blank",children:[Zr(go,{classes:"text-tiny",name:"open"===e.type?"public":"groups"}),Zr("span",{children:e.name})]}),t&&!n&&Zr("div",{className:"text-color-text-light","data-testid":"private-info",children:"Only me"})]})}let $g={};function Gg(e,t){return t-e}
609
- function Vg(e,t,n=window.Intl){const r=JSON.stringify(t);let o=$g[r];return o||(o=$g[r]=new n.DateTimeFormat(void 0,t)),o.format(e)}const Yg=[{test:(e,t)=>Gg(e,t)<3e4,formatter:()=>"Just now",nextUpdate:1e3},{test:(e,t)=>Gg(e,t)<6e4,formatter:function(e,t){return`${Math.floor(Gg(e,t)/1e3)} secs ago`},nextUpdate:1e3},{test:(e,t)=>Gg(e,t)<36e5,formatter:function(e,t){const n=Math.floor(Gg(e,t)/6e4);return`${n} min${n>1?"s":""} ago`},nextUpdate:6e4},{test:(e,t)=>Gg(e,t)<864e5,formatter:function(e,t){const n=Math.floor(Gg(e,t)/36e5);return`${n} hr${n>1?"s":""} ago`},nextUpdate:36e5},{test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:function(e,t,n){return Vg(e,{month:"short",day:"numeric"},n)},nextUpdate:null}],Wg={test:()=>!0,formatter:function(e,t,n){return Vg(e,{day:"numeric",month:"short",year:"numeric"},n)},nextUpdate:null};function Kg(e,t){for(let n of Yg)if(n.test(e,t))return n;return Wg}function Zg(e){return!isNaN(e.valueOf())}function Xg(e,t){let n;const r=new Date(e),o=()=>{const e=function(e,t){
610
- if(!e||!Zg(e)||!Zg(t))return null;let n=Kg(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5e3),n=Math.min(n,20736e5),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function Jg(e,t,n){return e?Kg(e,t).formatter(e,t,n):""}function Qg(e,t){return Vg(e,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"},t)}function ev({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){const[o,i]=Ir((()=>new Date)),a=Hr((()=>new Date(e)),[e]),s=Hr((()=>r&&new Date(t)),[t,r]),l=Hr((()=>({absolute:Qg(a),relative:Jg(a,o)})),[a,o]),c=Hr((()=>s?{absolute:Qg(s),relative:Jg(s,o)}:{}),[s,o]);Dr((()=>Xg(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Zr("div",{children:[r&&Zr("span",{className:"text-color-text-light text-sm italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Zr(Bc,{
611
- classes:"text-color-text-light hover:text-color-text-light hover:underline",target:"_blank",title:l.absolute,href:n,children:l.relative}):Zr("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function tv({authorLink:e,displayName:t}){const n=Zr("h3",{className:"text-color-text font-bold",children:t});return e?Zr(Bc,{href:e,target:"_blank",children:n}):Zr("div",{children:n})}var nv=Po((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){var i;const a=ls(),s=a.defaultAuthority(),l=a.isFeatureEnabled("client_display_names"),c=a.getLink("user",{user:e.user}),u=Hr((()=>qc(e,s,l)),[e,s,l]),d=Hr((()=>function(e,t,n,r){var o;return!Uc(e.user,n)&&r?r:null!==(o=t.usernameUrl&&`${t.usernameUrl}${jc(e.user)}`)&&void 0!==o?o:void 0}(e,o,s,c)),[e,o,s,c]),h=_i(e)&&r,p=(null===(i=e.links)||void 0===i?void 0:i.html)||"",m=Hr((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1
612
- ;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3}(e)&&!h),[e,h]),f=function(e){return{domain:vi(e),titleText:bi(e),titleLink:gi(e)}}(e),g=p&&f.titleLink?f.titleLink:"",v="sidebar"!==a.route()&&f.titleText,b=a.getGroup(e.group);return Zr("header",{children:[Zr("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse",children:[Kc(e.permissions)&&!t&&Zr(tc,{className:"text-tiny w-em h-em",title:"This annotation is visible only to you"}),Zr(tv,{authorLink:d,displayName:u}),n>0&&h&&Zr(Hc,{color:"text-light",onClick:()=>a.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Zr("div",{className:"flex justify-end grow",children:Zr(ev,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:p,withEditedTimestamp:m})})]}),!_i(e)&&Zr("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[b&&Zr(qg,{group:b,
613
- isPrivate:Kc(e.permissions)}),!t&&Ci(e)&&Zr(Gl,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"text-tiny w-em h-em text-color-text-light"}),v&&Zr(Ug,{domain:f.domain,link:g,title:f.titleText})]})]})}),["settings"]);var rv=Po((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Zr(au,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Zr(lg,{classes:Vn({"p-redacted-text":n}),children:Zr("blockquote",{className:Vn("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:Do(["selectionFontFamily"],r),children:e})})})}),["settings"]);function ov({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Zr(oo,{onClick:e,title:r,children:r})}function iv(){return Zr("div",{className:Vn("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Zr("span",{className:"text-xl animate-fade-in-slow",children:Zr(Cc,{size:"sm"})}),Zr("div",{
614
- className:"text-color-text-light font-medium",children:"Saving..."})]})}var av=Po((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ls(),s=zi(e),l=a.getDraft(e),c=a.profile().userid,u=a.isAnnotationHovered(e.$tag),d=a.isSavingAnnotation(e),h=!!l&&!d,p=t&&o,m=!d&&!h&&yi(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=Hr((()=>qc(e,f,g)),[e,f,g]);return Zr("article",{className:"space-y-4","aria-label":`${yi(e)?Mi(e):`New ${Mi(e).toLowerCase()}`} by ${v}`,children:[Zr(nv,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Zr(rv,{quote:s,isHovered:u,isOrphan:Ei(e)}),!p&&!h&&Zr(pg,{annotation:e}),h&&Zr(jg,{annotation:e,draft:l}),!p&&Zr("footer",{className:"flex items-center",children:[n&&Zr(ov,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Zr(iv,{}),m&&Zr(Dc,{classes:"grow",children:Zr(ru,{annotation:e,onReply:()=>{yi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"])
615
- ;function sv({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Zr("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Zr("div",{children:Zr("em",{children:"Message not available."})}),r&&Zr("footer",{className:"flex items-center",children:Zr(ov,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var lv=Po((function({annotation:e,api:t,toastMessenger:n}){const r=ls(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Zr("div",{className:Vn("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!_i(e),"-mr-3":_i(e)}),children:[Zr("div",{className:Vn("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:Zr(go,{name:e.hidden?"hide":"flag"})}),Zr("div",{className:"self-center grow",children:[!e.hidden&&Zr("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Zr("span",{children:"Hidden from users"})]
616
- }),Zr("div",{className:"self-center pr-2",children:Zr(ro,{classes:"py-1 bg-slate-1",onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotationn from non-moderators",variant:"dark",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function cv({threadIsCollapsed:e,onToggleReplies:t}){const n=e?"collapsed":"expand-menu",r=e?"Expand replies":"Collapse replies";return Zr("div",{className:Vn("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Zr("div",{className:Vn("bg-white"),children:Zr(no,{classes:Vn("-mt-1 touch:min-w-[auto] touch:min-h-[auto]"),expanded:!e,icon:n,title:r,onClick:t,size:"medium",variant:"light"})})})}
617
- var uv=Po((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Is(e)>0)),i=ls(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=Fr((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=Hr((()=>t.visible&&Zr(Qn,{children:t.annotation?Zr(Qn,{children:[Zr(lv,{annotation:t.annotation}),Zr(av,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Zr(sv,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Zr("section",{className:"flex","data-testid":"thread-container",children:[r&&Zr(cv,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Zr("div",{className:Vn("grow max-w-full"),"data-testid":"thread-content",children:[d,Rs(t)>0&&Zr("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Zr(nv,{
618
- annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Zr("div",{children:Zr(ro,{onClick:()=>n.forceVisible(t),children:["Show ",Rs(t)," more in conversation"]})})]}),!t.collapsed&&Zr("ul",{className:Vn("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Zr("li",{className:Vn("mt-2","[text-align:start]"),children:Zr(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var dv=Po((function({frameSync:e,thread:t}){var n,r;const o=ls(),i=null!==(n=null===(r=t.annotation)||void 0===r?void 0:r.$tag)&&void 0!==n?n:null,a=i&&o.isAnnotationHovered(i),s=Hr((()=>tl((t=>e.hoverAnnotation(t)),10)),[e]),l=Fr((t=>{e.scrollToAnnotation(t)}),[e]),c=Hr((()=>Zr(uv,{thread:t})),[t]),u=o.annotationFocusRequest(),d=Pr(null);return Dr((()=>{u===t.id&&d.current&&(d.current.focus(),o.clearAnnotationFocusRequest())}),[u,o,t.id]),Zr(so,{classes:Vn("p-3 cursor-pointer focus-visible-ring",{"is-hovered":a}),"data-testid":"thread-card",elementRef:d,tabIndex:-1,onClick:e=>{var n
619
- ;(n=e.target).closest("button")||n.closest("a")||!t.annotation||l(t.annotation)},onMouseEnter:()=>{var e;return s(null!==(e=t.annotation)&&void 0!==e?e:null)},onMouseLeave:()=>s(null),children:c},t.id)}),["frameSync"]);function hv(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function pv(e){return Math.max(e-e%50,0)}function mv(e){var t;const n=e.target[0];if(n)return null===(t=n.selector)||void 0===t?void 0:t.find((e=>"EPUBContentSelector"===e.type))}function fv(e){var t;if(!e.annotation)return null;const n=mv(e.annotation);return null!==(t=null==n?void 0:n.cfi)&&void 0!==t?t:null}function gv({threads:e}){const[t,n]=Ir(0),[r,o]=Ir(0);Br((()=>{const e=new rl,t=hv();n(t.clientHeight),o(pv(t.scrollTop));const r=tl((()=>{n(t.clientHeight),o(pv(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[])
620
- ;const[i,a]=Ir((()=>new Map)),[s,l]=Ir(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=Hr((()=>function(e,t,n,r,o=ol){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),p=ls(),m=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})(),f=Hr((()=>{let t=null;const n=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=mv(n.annotation);null!=e&&e.title&&t.set(e.cfi,e.title)}return t}(e),r=new Map;for(const i of e){const e=fv(i);var o;if(e&&t!==e)t=e,r.set(i,null!==(o=n.get(e))&&void 0!==o?o:"Untitled chapter")}return r}),[e]);return Dr((()=>{m&&(p.setForcedVisible(m,!0),l(m))}),[p,m]),Dr((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null)
621
- ;const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i.get(e.id)||ol.defaultHeight)(t)),0);hv().scrollTop=t}),[s,c,i]),Dr((()=>{a((e=>{const t=new Map;for(const{id:n}of h){const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=il(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Zr("div",{children:[Zr("div",{style:{height:d}}),h.map((e=>Zr("div",{className:Vn("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[f.get(e)&&Zr("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:f.get(e)}),Zr(dv,{thread:e})]},e.id))),Zr("div",{style:{height:u}})]})}function vv({errorType:e,onLoginRequest:t,showClearSelection:n=!1}){const r=ls(),o=r.isLoggedIn();return Zr("div",{className:"mb-4",children:Zr(No,{icon:"restricted",title:"annotation"===e?"Annotation unavailable":"Group unavailable",children:[Zr("p",{
622
- children:o?"group"===e?"The current URL links to a group, but that group cannot be found,\n or you do not have permission to view the annotations in that group.":"The current URL links to an annotation, but that annotation\n cannot be found, or you do not have permission to view it.":`The ${e} associated with the current URL is unavailable.\n You may need to log in to see it.`}),Zr("div",{className:"flex justify-end space-x-2",children:[n&&Zr(ro,{variant:o?"primary":void 0,onClick:()=>r.clearSelection(),children:"Show all annotations"}),!o&&Zr(ro,{variant:"primary",onClick:t,children:"Log in"})]})]})})}var bv=Po((function({loadAnnotationsService:e,onLogin:t}){const n=ls(),r=n.routeParams().id,o=Fs(),i=n.profile().userid,[a,s]=Ir(!1);return Dr((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Zr(Qn,{
623
- children:[a&&Zr(vv,{errorType:"annotation",onLoginRequest:t}),Zr(gv,{threads:o.children})]})}),["loadAnnotationsService"]);function _v({additionalCount:e=0,entitySingular:t="annotation",entityPlural:n="annotations",filterQuery:r,focusDisplayName:o,resultCount:i}){return Zr(Qn,{children:[i>0&&Zr("span",{children:"Showing "}),Zr("span",{className:"whitespace-nowrap font-bold",children:[i>0?i:"No"," ",1===i?t:n]}),r&&Zr("span",{children:[" ","for ",Zr("span",{className:"break-words",children:`'${r}'`})]}),o&&Zr("span",{children:[" ","by"," ",Zr("span",{className:"whitespace-nowrap font-bold",children:o})]}),e>0&&Zr("span",{className:"whitespace-nowrap italic text-color-text-light",children:[" ","(and ",e," more)"]})]})}function yv(){
599
+ children:[Zr(Rc,{onInput:()=>{null==n||n(m()),(()=>{if(f()){const e=o.filter(m());s(((e,t)=>{const n=[];for(const r of e)t.indexOf(r)<0&&n.push(r);return n.sort()})(e,r)),d(e.length>0)}else d(!1);c(-1)})()},onKeyDown:e=>{switch(e.key){case"ArrowUp":b(-1),e.preventDefault();break;case"ArrowDown":b(1),e.preventDefault();break;case"Escape":g(),e.preventDefault();break;case"Enter":case",":v(-1===l?m():a[l]),e.preventDefault();break;case"Tab":if(!f())break;-1!==l?v(a[l]):1===a.length?v(a[0]):v(m()),e.preventDefault()}},onFocus:()=>{f()&&d(!0)},elementRef:i,placeholder:"Add new tags",type:"text",autoComplete:"off","aria-autocomplete":"list","aria-activedescendant":_,"aria-controls":`${h}-AutocompleteList`,"aria-label":"Add tags",dir:"auto"}),Zr(Ag,{id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{const t=m().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Zr("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Zr("span",{children:[Zr("strong",{children:r
600
+ }),o,Zr("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Lg(){return Zr("div",{className:"pt-2 border-t text-sm leading-none",children:Zr(Pc,{classes:"flex items-center",color:"text-light",href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",title:"View more information about the Creative Commons Public Domain dedication",children:[Zr(fl,{className:"w-em h-em text-tiny"}),Zr(vl,{className:"w-em h-em ml-px text-tiny"}),Zr("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})}function zg(e){return null!==e.offsetParent}function Rg({className:e,closeMenu:t,children:n,visible:r}){const o=Pr();Dr((()=>{let e;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return Zr("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{
601
+ const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(zg);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(e.key){case"ArrowLeft":case"Escape":t&&(t(e),i=!0);break;case"ArrowUp":r-=1,r<0&&(r=n.length-1),i=!0;break;case"ArrowDown":r+=1,r===n.length&&(r=0),i=!0;break;case"Home":r=0,i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let Ig=!1;const Og=()=>{};function Dg({align:e="left",arrowClass:t="",children:n,containerPositioned:r=!0,contentClass:o,defaultOpen:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[d,h]=Ir(i);"boolean"==typeof s&&(d=s,h=l||Og);const p=Pr(d);Dr((()=>{"function"==typeof l&&p.current!==d&&(p.current=d,l(d))}),[d,l]);const m=e=>{if("mousedown"===e.type)Ig=!0;else if("click"===e.type&&Ig)return Ig=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=Fr((()=>h(!1)),[h]),g=Pr();_o(g,d,f);const v=e=>e.stopPropagation();return Zr("div",{className:"relative",
602
+ "data-testid":"menu-container",ref:g,style:{position:r?"relative":"static"},onClick:v,onMouseDown:v,children:[Zr("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:Vn("focus-visible-ring","flex items-center justify-center rounded-sm transition-colors",{"text-grey-7 hover:text-grey-9":!d,"text-brand":d}),"data-testid":"menu-toggle-button",onMouseDown:m,onClick:m,"aria-label":u,title:u,children:Zr("span",{className:"flex items-center gap-x-1",children:[a,c&&Zr("span",{className:Vn({"rotate-180 text-color-text":d}),children:Zr(go,{name:"expand-menu",classes:"w-2.5 h-2.5"})})]})}),d&&Zr(Qn,{children:[Zr(Jc,{direction:"up",classes:Vn("right-0 top-[calc(100%-3px)] w-[15px]",t)}),Zr("div",{className:Vn("focus-visible-ring","absolute top-[calc(100%+5px)] z-1 border shadow","bg-white text-lg",{"left-0":"left"===e,"right-0":"right"===e},o),"data-testid":"menu-content",role:"menu",tabIndex:-1,onClick:f,onKeyDown:e=>{const t=e.key;"Enter"!==t&&" "!==t||setTimeout((()=>{f()}))},children:Zr(Rg,{
603
+ visible:!0,children:n})})]})]})}function Bg({children:e,visible:t}){const n=Pr(),[r,o]=Ir(t?"auto":0),[i,a]=Ir(t);Dr((()=>{if(t===(0!==r))return;const e=n.current;t?(e.style.display="",a(!0),o(e.scrollHeight)):(e.style.height=`${e.scrollHeight}px`,e.getBoundingClientRect(),o(0))}),[r,t]);return Zr("div",{ontransitionend:Fr((()=>{t?o("auto"):a(!1)}),[o,t]),ref:n,style:{display:i?"":"none",height:r,overflow:"auto"===r?"visible":"hidden",transition:"height 0.15s ease-in"},children:e})}function Pg({title:e,isExpanded:t,onToggleSubmenu:n}){return Zr("div",{"data-testid":"submenu-toggle",role:"none",className:Vn("flex flex-col items-center justify-center w-10 h-10","text-grey-6 bg-grey-1","bg-clip-content border-[8px] border-transparent rounded-xl","group-hover:hover:text-grey-8",{"bg-grey-4":t,"group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Zr(go,{name:t?"collapse-menu":"expand-menu",classes:"w-3 h-3"})})}
604
+ function Hg({href:e,icon:t,iconAlt:n,isDisabled:r,isExpanded:o,isSelected:i,isSubmenuItem:a,isSubmenuVisible:s,label:l,onClick:c,onToggleSubmenu:u,submenu:d}){const h=t&&-1!==t.indexOf("/"),p=Pr();let m,f;const g="boolean"==typeof s,v="boolean"==typeof i;Dr((()=>()=>{clearTimeout(m)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}};let _=null;t&&"blank"!==t&&(_=h?Zr("img",{className:"w-4 h-4",alt:n,src:t}):Zr(go,{name:t,classes:"h-3 w-3"}));const y=a?null:_,w=a?_:null,x=w&&a,k=Zr(Qn,{children:[(y||a||"blank"===t)&&Zr("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:y}),Zr("span",{className:"flex items-center grow whitespace-nowrap px-1",children:l}),x&&Zr("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Zr(Pg,{title:`Show actions for ${l}`,isExpanded:s,onToggleSubmenu:u})]
605
+ }),S=Vn("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","border-b","group",{"min-h-[30px] font-normal":a,"min-h-[40px] font-medium":!a,"bg-grey-1 hover:bg-grey-3":a||o,"bg-white hover:bg-grey-1":!a&&!o,"pr-1":!g},{"border-l-[4px] border-l-brand":i,"pl-[4px]":!i,"border-b-grey-3":o,"border-b-transparent":!o,"text-color-text-light":r,"text-color-text":!r});return f=e?Zr("a",{ref:p,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:k}):Zr("div",{ref:p,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem","aria-checked":v?i:void 0,"aria-haspopup":g,"aria-expanded":g?s:void 0,children:k}),Zr(Qn,{children:[f,g&&Zr(Bg,{visible:s,children:Zr(Rg,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{p.current.focus()}))},visible:s,className:"border-b",children:d})})]})}
606
+ var Fg=Po((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=Do(["ctaTextColor","ctaBackgroundColor"],a),l=Zr("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Zr(go,{name:"expand-menu",classes:"w-4 h-4"})});return Zr("div",{className:"flex flex-row gap-x-3",children:[Zr("div",{className:"flex relative",children:[Zr(ro,{classes:Vn("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"large",variant:"primary",children:["Post to ",n?"Only Me":e.name]}),Zr("div",{className:Vn("flex flex-row rounded-r-sm bg-grey-7 hover:bg-grey-8"),style:s,children:Zr(Dg,{arrowClass:Vn("right-[10px]"),containerPositioned:!1,contentClass:Vn("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Zr(Hg,{icon:"open"===e.type?"public":"groups",label:e.name,isSelected:!n,onClick:()=>i(!1)}),Zr(Hg,{icon:"lock",label:"Only Me",isSelected:n,
607
+ onClick:()=>i(!0)})]})})]}),Zr("div",{children:Zr(ro,{classes:"p-2.5",icon:"cancel",onClick:r,size:"large",children:"Cancel"})})]})}),["settings"]);var jg=Po((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=Ir(null),l=ls(),c=l.getGroup(e.group),u=!t.isPrivate&&c&&"private"!==c.type,d=t.tags,h=t.text,p=!h&&!d.length,m=Fr((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),f=Fr((e=>{if(!e||d.indexOf(e)>=0)return!1;const t=[...d,e];return o.store(t),m(t),!0}),[m,d,o]),g=Fr((e=>{const t=[...d],n=t.indexOf(e);return n>=0&&(t.splice(n,1),m(t),!0)}),[m,d]),v=Fr((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),b=Fr((n=>{l.createDraft(e,{...t,isPrivate:n}),_i(e)||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,l]),_=async()=>{a&&f(a);const t=`${Mi(e)} ${yi(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch(e){i.error("Saving annotation failed")}},y=Fr((()=>{l.removeDraft(e),yi(e)||l.removeAnnotations([e])
608
+ }),[e,l]);return Zr("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;p||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),_())},children:[Zr(Cg,{textStyle:Do(["annotationFontFamily"],r),label:"Annotation body",text:h,onEditText:v}),Zr(Mg,{onAddTag:f,onRemoveTag:g,onTagInput:s,tagList:d}),c&&Zr(Fg,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:y,onSave:_,onSetPrivate:b}),u&&Zr(Lg,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function Ug({domain:e,link:t,title:n}){return Zr("div",{className:"flex gap-x-1",children:[Zr("div",{className:"text-color-text-light",children:['on "',t?Zr(Pc,{href:t,target:"_blank",children:n}):Zr("span",{children:n}),'"']}),e&&Zr("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function qg({group:e,isPrivate:t}){const n=null==e?void 0:e.links.html;return Zr(Qn,{children:[e&&n&&Zr(vo,{classes:Vn("flex items-baseline gap-x-1","p-muted-link"),href:e.links.html,
609
+ target:"_blank",children:[Zr(go,{classes:"text-tiny",name:"open"===e.type?"public":"groups"}),Zr("span",{children:e.name})]}),t&&!n&&Zr("div",{className:"text-color-text-light","data-testid":"private-info",children:"Only me"})]})}let $g={};function Gg(e,t){return t-e}function Vg(e,t,n=window.Intl){const r=JSON.stringify(t);let o=$g[r];return o||(o=$g[r]=new n.DateTimeFormat(void 0,t)),o.format(e)}const Yg=[{test:(e,t)=>Gg(e,t)<3e4,formatter:()=>"Just now",nextUpdate:1e3},{test:(e,t)=>Gg(e,t)<6e4,formatter:function(e,t){return`${Math.floor(Gg(e,t)/1e3)} secs ago`},nextUpdate:1e3},{test:(e,t)=>Gg(e,t)<36e5,formatter:function(e,t){const n=Math.floor(Gg(e,t)/6e4);return`${n} min${n>1?"s":""} ago`},nextUpdate:6e4},{test:(e,t)=>Gg(e,t)<864e5,formatter:function(e,t){const n=Math.floor(Gg(e,t)/36e5);return`${n} hr${n>1?"s":""} ago`},nextUpdate:36e5},{test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:function(e,t,n){return Vg(e,{month:"short",day:"numeric"},n)},nextUpdate:null}],Wg={test:()=>!0,
610
+ formatter:function(e,t,n){return Vg(e,{day:"numeric",month:"short",year:"numeric"},n)},nextUpdate:null};function Kg(e,t){for(let n of Yg)if(n.test(e,t))return n;return Wg}function Zg(e){return!isNaN(e.valueOf())}function Xg(e,t){let n;const r=new Date(e),o=()=>{const e=function(e,t){if(!e||!Zg(e)||!Zg(t))return null;let n=Kg(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5e3),n=Math.min(n,20736e5),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function Jg(e,t,n){return e?Kg(e,t).formatter(e,t,n):""}function Qg(e,t){return Vg(e,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"},t)}function ev({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){const[o,i]=Ir((()=>new Date)),a=Hr((()=>new Date(e)),[e]),s=Hr((()=>r&&new Date(t)),[t,r]),l=Hr((()=>({absolute:Qg(a),relative:Jg(a,o)})),[a,o]),c=Hr((()=>s?{absolute:Qg(s),relative:Jg(s,o)}:{}),[s,o])
611
+ ;Dr((()=>Xg(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Zr("div",{children:[r&&Zr("span",{className:"text-color-text-light text-sm italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Zr(Bc,{classes:"text-color-text-light hover:text-color-text-light hover:underline",target:"_blank",title:l.absolute,href:n,children:l.relative}):Zr("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function tv({authorLink:e,displayName:t}){const n=Zr("h3",{className:"text-color-text font-bold",children:t});return e?Zr(Bc,{href:e,target:"_blank",children:n}):Zr("div",{children:n})}var nv=Po((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){var i;const a=ls(),s=a.defaultAuthority(),l=a.isFeatureEnabled("client_display_names"),c=a.getLink("user",{user:e.user}),u=Hr((()=>qc(e,s,l)),[e,s,l]),d=Hr((()=>function(e,t,n,r){var o
612
+ ;return!Uc(e.user,n)&&r?r:null!==(o=t.usernameUrl&&`${t.usernameUrl}${jc(e.user)}`)&&void 0!==o?o:void 0}(e,o,s,c)),[e,o,s,c]),h=_i(e)&&r,p=(null===(i=e.links)||void 0===i?void 0:i.html)||"",m=Hr((()=>function(e){if(!e.updated||!e.created||e.updated===e.created)return!1;const t=new Date(e.created).getTime(),n=new Date(e.updated).getTime();return!isNaN(t)&&!isNaN(n)&&n-t>2e3}(e)&&!h),[e,h]),f=function(e){return{domain:vi(e),titleText:bi(e),titleLink:gi(e)}}(e),g=p&&f.titleLink?f.titleLink:"",v="sidebar"!==a.route()&&f.titleText,b=a.getGroup(e.group);return Zr("header",{children:[Zr("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse",children:[Kc(e.permissions)&&!t&&Zr(tc,{className:"text-tiny w-em h-em",title:"This annotation is visible only to you"}),Zr(tv,{authorLink:d,displayName:u}),n>0&&h&&Zr(Hc,{color:"text-light",onClick:()=>a.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Zr("div",{className:"flex justify-end grow",
613
+ children:Zr(ev,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:p,withEditedTimestamp:m})})]}),!_i(e)&&Zr("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[b&&Zr(qg,{group:b,isPrivate:Kc(e.permissions)}),!t&&Ci(e)&&Zr(Gl,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"text-tiny w-em h-em text-color-text-light"}),v&&Zr(Ug,{domain:f.domain,link:g,title:f.titleText})]})]})}),["settings"]);var rv=Po((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Zr(au,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Zr(lg,{classes:Vn({"p-redacted-text":n}),children:Zr("blockquote",{className:Vn("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:Do(["selectionFontFamily"],r),children:e})})})}),["settings"]);function ov({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Zr(oo,{onClick:e,title:r,children:r})}
614
+ function iv(){return Zr("div",{className:Vn("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Zr("span",{className:"text-xl animate-fade-in-slow",children:Zr(Cc,{size:"sm"})}),Zr("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var av=Po((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ls(),s=zi(e),l=a.getDraft(e),c=a.profile().userid,u=a.isAnnotationHovered(e.$tag),d=a.isSavingAnnotation(e),h=!!l&&!d,p=t&&o,m=!d&&!h&&yi(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=Hr((()=>qc(e,f,g)),[e,f,g]);return Zr("article",{className:"space-y-4","aria-label":`${yi(e)?Mi(e):`New ${Mi(e).toLowerCase()}`} by ${v}`,children:[Zr(nv,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Zr(rv,{quote:s,isHovered:u,isOrphan:Ei(e)}),!p&&!h&&Zr(pg,{annotation:e}),h&&Zr(jg,{annotation:e,draft:l}),!p&&Zr("footer",{
615
+ className:"flex items-center",children:[n&&Zr(ov,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Zr(iv,{}),m&&Zr(Dc,{classes:"grow",children:Zr(ru,{annotation:e,onReply:()=>{yi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function sv({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Zr("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Zr("div",{children:Zr("em",{children:"Message not available."})}),r&&Zr("footer",{className:"flex items-center",children:Zr(ov,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var lv=Po((function({annotation:e,api:t,toastMessenger:n}){const r=ls(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Zr("div",{className:Vn("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!_i(e),"-mr-3":_i(e)}),children:[Zr("div",{className:Vn("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),
616
+ children:Zr(go,{name:e.hidden?"hide":"flag"})}),Zr("div",{className:"self-center grow",children:[!e.hidden&&Zr("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Zr("span",{children:"Hidden from users"})]}),Zr("div",{className:"self-center pr-2",children:Zr(ro,{classes:"py-1 bg-slate-1",onClick:e.hidden?()=>{const o=e.id;t.annotation.unhide({id:o}).then((()=>{r.unhideAnnotation(o)})).catch((()=>{n.error("Failed to unhide annotation")}))}:()=>{const o=e.id;t.annotation.hide({id:o}).then((()=>{r.hideAnnotation(o)})).catch((()=>{n.error("Failed to hide annotation")}))},title:e.hidden?"Make this annotation visible to everyone":"Hide this annotationn from non-moderators",variant:"dark",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function cv({threadIsCollapsed:e,onToggleReplies:t}){const n=e?"collapsed":"expand-menu",r=e?"Expand replies":"Collapse replies";return Zr("div",{className:Vn("cursor-auto",{"bg-thread-line":!e}),
617
+ "data-testid":"thread-collapse-channel",children:Zr("div",{className:Vn("bg-white"),children:Zr(no,{classes:Vn("-mt-1 touch:min-w-[auto] touch:min-h-[auto]"),expanded:!e,icon:n,title:r,onClick:t,size:"medium",variant:"light"})})})}var uv=Po((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Is(e)>0)),i=ls(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=Fr((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=Hr((()=>t.visible&&Zr(Qn,{children:t.annotation?Zr(Qn,{children:[Zr(lv,{annotation:t.annotation}),Zr(av,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Zr(sv,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Zr("section",{className:"flex","data-testid":"thread-container",
618
+ children:[r&&Zr(cv,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Zr("div",{className:Vn("grow max-w-full"),"data-testid":"thread-content",children:[d,Rs(t)>0&&Zr("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Zr(nv,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Zr("div",{children:Zr(ro,{onClick:()=>n.forceVisible(t),children:["Show ",Rs(t)," more in conversation"]})})]}),!t.collapsed&&Zr("ul",{className:Vn("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Zr("li",{className:Vn("mt-2","[text-align:start]"),children:Zr(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var dv=Po((function({frameSync:e,thread:t}){var n,r;const o=ls(),i=null!==(n=null===(r=t.annotation)||void 0===r?void 0:r.$tag)&&void 0!==n?n:null,a=i&&o.isAnnotationHovered(i),s=Hr((()=>tl((t=>e.hoverAnnotation(t)),10)),[e]),l=Fr((t=>{e.scrollToAnnotation(t)}),[e]),c=Hr((()=>Zr(uv,{thread:t})),[t]),u=o.annotationFocusRequest(),d=Pr(null)
619
+ ;return Dr((()=>{u===t.id&&d.current&&(d.current.focus(),o.clearAnnotationFocusRequest())}),[u,o,t.id]),Zr(so,{classes:Vn("p-3 cursor-pointer focus-visible-ring",{"is-hovered":a}),"data-testid":"thread-card",elementRef:d,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||l(t.annotation)},onMouseEnter:()=>{var e;return s(null!==(e=t.annotation)&&void 0!==e?e:null)},onMouseLeave:()=>s(null),children:c},t.id)}),["frameSync"]);function hv(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function pv(e){return Math.max(e-e%50,0)}function mv(e){var t;const n=e.target[0];if(n)return null===(t=n.selector)||void 0===t?void 0:t.find((e=>"EPUBContentSelector"===e.type))}function fv(e){var t;if(!e.annotation)return null;const n=mv(e.annotation);return null!==(t=null==n?void 0:n.cfi)&&void 0!==t?t:null}function gv({threads:e}){const[t,n]=Ir(0),[r,o]=Ir(0);Br((()=>{const e=new rl,t=hv();n(t.clientHeight),
620
+ o(pv(t.scrollTop));const r=tl((()=>{n(t.clientHeight),o(pv(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=Ir((()=>new Map)),[s,l]=Ir(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=Hr((()=>function(e,t,n,r,o=ol){const{defaultHeight:i,marginAbove:a,marginBelow:s}=o,l=[];let c=0,u=0,d=0;return e.forEach((e=>{const o=t.get(e.id)||i;c+o<n-a?u+=o:c<n+r+s?l.push(e):d+=o,c+=o})),{visibleThreads:l,offscreenUpperHeight:u,offscreenLowerHeight:d}}(c,i,r,t)),[c,i,r,t]),p=ls(),m=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})(),f=Hr((()=>{let t=null;const n=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=mv(n.annotation);null!=e&&e.title&&t.set(e.cfi,e.title)}return t}(e),r=new Map;for(const i of e){const e=fv(i);var o;if(e&&t!==e)t=e,r.set(i,null!==(o=n.get(e))&&void 0!==o?o:"Untitled chapter")}return r}),[e]);return Dr((()=>{
621
+ m&&(p.setForcedVisible(m,!0),l(m))}),[p,m]),Dr((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null);const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i.get(e.id)||ol.defaultHeight)(t)),0);hv().scrollTop=t}),[s,c,i]),Dr((()=>{a((e=>{const t=new Map;for(const{id:n}of h){const r=document.getElementById(n);if(!r)return console.warn("ThreadList could not measure thread. Element not found."),e;const o=il(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Zr("div",{children:[Zr("div",{style:{height:d}}),h.map((e=>Zr("div",{className:Vn("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[f.get(e)&&Zr("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:f.get(e)}),Zr(dv,{thread:e})]},e.id))),Zr("div",{style:{height:u}})]})}function vv({errorType:e,onLoginRequest:t,showClearSelection:n=!1}){const r=ls(),o=r.isLoggedIn();return Zr("div",{className:"mb-4",children:Zr(No,{icon:"restricted",
622
+ title:"annotation"===e?"Annotation unavailable":"Group unavailable",children:[Zr("p",{children:o?"group"===e?"The current URL links to a group, but that group cannot be found,\n or you do not have permission to view the annotations in that group.":"The current URL links to an annotation, but that annotation\n cannot be found, or you do not have permission to view it.":`The ${e} associated with the current URL is unavailable.\n You may need to log in to see it.`}),Zr("div",{className:"flex justify-end space-x-2",children:[n&&Zr(ro,{variant:o?"primary":void 0,onClick:()=>r.clearSelection(),children:"Show all annotations"}),!o&&Zr(ro,{variant:"primary",onClick:t,children:"Log in"})]})]})})}var bv=Po((function({loadAnnotationsService:e,onLogin:t}){const n=ls(),r=n.routeParams().id,o=Fs(),i=n.profile().userid,[a,s]=Ir(!1);return Dr((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>n.setExpanded(e.id,!0))),
623
+ t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Zr(Qn,{children:[a&&Zr(vv,{errorType:"annotation",onLoginRequest:t}),Zr(gv,{threads:o.children})]})}),["loadAnnotationsService"]);function _v({additionalCount:e=0,entitySingular:t="annotation",entityPlural:n="annotations",filterQuery:r,focusDisplayName:o,resultCount:i}){return Zr(Qn,{children:[i>0&&Zr("span",{children:"Showing "}),Zr("span",{className:"whitespace-nowrap font-bold",children:[i>0?i:"No"," ",1===i?t:n]}),r&&Zr("span",{children:[" ","for ",Zr("span",{className:"break-words",children:`'${r}'`})]}),o&&Zr("span",{children:[" ","by"," ",Zr("span",{className:"whitespace-nowrap font-bold",children:o})]}),e>0&&Zr("span",{className:"whitespace-nowrap italic text-color-text-light",children:[" ","(and ",e," more)"]})]})}function yv(){
624
624
  const e=ls(),t=Fs(),n=e.annotationCount(),r=e.directLinkedAnnotationId(),o=e.filterQuery(),i=e.focusState(),a=e.forcedVisibleThreads().length,s=e.selectedAnnotations().length,l=Hr((()=>s>0?"selection":o?"query":i.configured?"focus":null),[s,o,i]),c=Hr((()=>"selection"===l?s:Is(t)-a),[l,s,t,a]),u=Hr((()=>{if("selection"===l){return(t.children||[]).filter((e=>e.annotation&&e.visible)).length-s}return a}),[l,a,t.children,s]),d=Hr((()=>{if("selection"===l){return!i.configured&&!r?`Show all (${n})`:"Show all"}return"focus"===l?a>0?"Reset filters":i.active?"Show all":`Show only ${i.displayName}`:"Clear search"}),[n,r,i,l,a]);return Zr("div",{className:Vn("mb-3",{"sr-only":!l}),"data-testid":"filter-status-container",children:Zr(Ic,{children:Zr(Oc,{children:e.isLoading()?Zr(Cc,{size:"md"}):Zr("div",{className:"flex items-center justify-center space-x-1",children:[Zr("div",{className:Vn("grow min-w-[0]"),role:"status",children:l&&Zr(_v,{additionalCount:u,entitySingular:"query"===l?"result":"annotation",
625
625
  entityPlural:"query"===l?"results":"annotations",filterQuery:o,focusDisplayName:"selection"!==l&&i.active?i.displayName:"",resultCount:c})}),l&&Zr(Tc,{onClick:"focus"!==l||a?()=>e.clearSelection():()=>e.toggleFocusMode(),size:"sm",title:d,variant:"primary","data-testid":"clear-button",children:["focus"!==l&&Zr(pl,{}),d]})]})})})})}function wv({onLogin:e}){const t=ls();return Zr("div",{className:"flex flex-col items-center m-6 space-y-6",children:[Zr("span",{className:"text-center",children:["This is a public annotation created with Hypothesis. ",Zr("br",{}),"To reply or make your own annotations on this document,"," ",Zr(Pc,{color:"text",href:t.getLink("signup"),target:"_blank",underline:"always",children:"create a free account"})," ","or"," ",Zr(Hc,{inline:!0,color:"text",onClick:e,underline:"always",children:"log in"}),"."]}),Zr("div",{children:Zr(Bc,{href:"https://hypothes.is","aria-label":"Hypothesis homepage",target:"_blank",title:"Hypothesis homepage",children:Zr(rc,{className:"w-16 h-16 text-grey-7"})
626
626
  })})]})}function xv(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function kv(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,p=c&&null!=c.leftOffset?c.leftOffset:0,m=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-=p,o-=m,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-=p,o-=m,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,
@@ -630,7 +630,7 @@ align:n.align,isWindow:n.isWindow||Sv,maxSynchronousAlignments:d,end:u,scrollAnc
630
630
  variant:"primary",onClick:e,children:"Log in"})]})]})}function Lv({children:e,count:t,isWaitingToAnchor:n,isSelected:r,label:o,onSelect:i}){const a=()=>{r||i()},s=t>0?`${o} (${t} available)`:o;return Zr(oo,{classes:Vn("inline bg-transparent min-w-[5.25rem] text-color-text hover:!no-underline",{"font-bold":r}),onClick:a,onMouseDown:a,pressed:!!r,role:"tab",tabIndex:0,title:s,children:Zr(Qn,{children:[e,t>0&&!n&&Zr("span",{className:"relative bottom-[3px] left-[2px] text-tiny",children:t})]})})}var zv=Po((function({annotationsService:e,isLoading:t,settings:n}){const r=ls(),o=r.selectedTab(),i=r.noteCount(),a=r.annotationCount(),s=r.orphanCount(),l=r.isWaitingToAnchorAnnotations(),c=e=>{r.clearSelection(),r.selectTab(e)},u="annotation"===o&&0===a&&!l,d="note"===o&&0===i;return Zr("div",{className:Vn("space-y-3 pb-[9px]"),children:[Zr("div",{className:"flex gap-x-6 theme-clean:ml-[15px]",role:"tablist",children:[Zr(Lv,{count:a,isWaitingToAnchor:l,isSelected:"annotation"===o,label:"Annotations",
631
631
  onSelect:()=>c("annotation"),children:"Annotations"}),Zr(Lv,{count:i,isWaitingToAnchor:l,isSelected:"note"===o,label:"Page notes",onSelect:()=>c("note"),children:"Page Notes"}),s>0&&Zr(Lv,{count:s,isWaitingToAnchor:l,isSelected:"orphan"===o,label:"Orphans",onSelect:()=>c("orphan"),children:"Orphans"})]}),"note"===o&&n.enableExperimentalNewNoteButton&&Zr("div",{className:"flex justify-end",children:Zr(ro,{"data-testid":"new-note-button",icon:"add",onClick:()=>e.createPageNote(),variant:"primary",style:Do(["ctaBackgroundColor"],n),children:"New note"})}),!t&&d&&Zr(ao,{classes:"text-center",children:Zr("span",{"data-testid":"notes-unavailable-message",children:"There are no page notes in this group."})}),!t&&u&&Zr(ao,{classes:"text-center",children:Zr("span",{"data-testid":"annotations-unavailable-message",children:["There are no annotations in this group.",Zr("br",{}),"Create one by selecting some text and clicking the"," ",Zr(go,{classes:"inline m-0.5 -mt-0.5",name:"annotate",title:"Annotate"})," ","button."]
632
632
  })})]})}),["annotationsService","settings"]);var Rv=Po((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=Fs(),a=ls(),s=a.focusedGroupId(),l=a.hasAppliedFilter()||a.hasSelectedAnnotations(),c=a.isLoading(),u=a.isLoggedIn(),d=a.directLinkedAnnotationId(),h=d?a.findAnnotationByID(d):void 0,p=h?Ts(h):"annotation",m=a.searchUris(),f=a.hasSidebarOpened(),g=a.profile().userid,v=!(c||!d)&&!h,b=a.directLinkedGroupFetchFailed(),_=v||b,y=!_,w=!_&&!l,x=d&&!u&&!v&&!c,k=Pr(s);Dr((()=>{if(!k.current||k.current!==s){if(k.current){let e=a.focusState().active;a.clearSelection(),e&&a.toggleFocusMode(!0)}k.current=s}s&&m.length&&r.load({groupId:s,uris:m})}),[a,r,s,g,m]),Dr((()=>{h&&!1===h.$orphan?(e.hoverAnnotation(h),e.scrollToAnnotation(h),a.selectTab(p)):h&&a.selectTab(p)}),[p,e,h,a]);const S=a.hasFetchedProfile();return Dr((()=>{S&&(f||u)&&o.connect({applyUpdatesImmediately:!1})}),[S,u,f,o]),Zr("div",{children:[Zr("h2",{className:"sr-only",children:"Annotations"}),y&&Zr(yv,{}),Zr(Mv,{
633
- onLogin:t,onSignUp:n}),v&&Zr(vv,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Zr(vv,{errorType:"group",onLoginRequest:t}),w&&Zr(zv,{isLoading:c}),Zr(gv,{threads:i.children}),x&&Zr(wv,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Iv=Po((function({api:e,toastMessenger:t}){const n=ls(),r=n.routeParams().q,o=Fr((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...xs(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Dr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Zr(gv,{threads:Fs().children})}),["api","toastMessenger"]);class Ov{constructor(e,t,n=window){var r,o,i,a;const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1163.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||s,
633
+ onLogin:t,onSignUp:n}),v&&Zr(vv,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),b&&Zr(vv,{errorType:"group",onLoginRequest:t}),w&&Zr(zv,{isLoading:c}),Zr(gv,{threads:i.children}),x&&Zr(wv,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Iv=Po((function({api:e,toastMessenger:t}){const n=ls(),r=n.routeParams().q,o=Fr((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...xs(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);return Dr((()=>{n.setSortKey("Newest"),n.clearAnnotations(),o(r).catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]),Zr(gv,{threads:Fs().children})}),["api","toastMessenger"]);class Ov{constructor(e,t,n=window){var r,o,i,a;const s="N/A";let l=s;e.userid&&(l=e.userid,e.displayName&&(l=`${e.displayName} (${l})`)),this.version="1.1164.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||s,
634
634
  this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(i=o.metadata)||void 0===i?void 0:i.documentFingerprint)&&void 0!==r?r:s,this.account=l,this.timestamp=(new Date).toString();const c=null===(a=t[0])||void 0===a?void 0:a.segment;if(c){const e=[];c.cfi&&e.push(["CFI",c.cfi]),c.url&&e.push(["URL",c.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}function Dv(e){const n=t(e);return!(null==n||!n.authority)&&n.authority!==e.authDomain}function Bv({commandName:e,icon:t}){return Zr("span",{className:"whitespace-nowrap","data-testid":"instruction",children:[Zr(t,{className:Vn("w-em h-em","mx-1 -mt-1","text-color-text-light inline")}),Zr("em",{"data-testid":"command-name",children:e})]})}var Pv=Po((function({settings:e}){
635
635
  const t=!Dv(e);return Zr("ol",{className:"list-decimal pl-10 space-y-2",children:[Zr("li",{children:["To create an annotation, select text and then select the"," ",Zr(Bv,{icon:sl,commandName:"Annotate"})," button."]}),Zr("li",{children:["To create a highlight (",Zr(Pc,{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"," ",Zr(Bv,{icon:Gl,commandName:"Highlight"})," button."]}),t&&Zr("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"," ",Zr(Pc,{href:"https://web.hypothes.is/help/how-to-join-a-private-group/",target:"_blank",underline:"always",children:"join link"}),"."]}),Zr("li",{children:["To reply to an annotation, select the"," ",Zr(Bv,{icon:pc,commandName:"Reply"})," button."]})]})}),["settings"]);function Hv({label:e,children:t,classes:n}){return Zr(Qn,{children:[Zr("dt",{
636
636
  className:"col-span-1 sm:text-right font-medium",children:e}),Zr("dd",{className:Vn("col-span-1 sm:col-span-3 text-color-text-light break-words",n),children:t})]})}var Fv=Po((function({toastMessenger:e,versionData:t}){return Zr("div",{className:"space-y-4",children:[Zr("dl",{className:"grid grid-cols-1 sm:grid-cols-4 sm:gap-x-2",children:[Zr(Hv,{label:"Version",children:t.version}),Zr(Hv,{label:"User Agent",children:t.userAgent}),Zr(Hv,{classes:Vn("break-all"),label:"URL",children:t.urls}),Zr(Hv,{label:"Fingerprint",children:t.fingerprint}),t.segment&&Zr(Hv,{label:"Segment",children:t.segment}),Zr(Hv,{label:"Account",children:t.account}),Zr(Hv,{label:"Date",children:t.timestamp})]}),Zr("div",{className:"flex items-center justify-center",children:Zr(Tc,{onClick:()=>{try{Zc(t.asFormattedString()),e.success("Copied version info to clipboard")}catch(t){e.error("Unable to copy version info")}},icon:wl,children:"Copy version details"})})]})}),["toastMessenger"]);function jv({children:e,onClick:t}){return Zr(Hc,{
@@ -661,7 +661,7 @@ children:[Zr(ib,{}),Zr(qv,{}),Zr(rb,{}),l&&Zr("main",{children:["annotation"===l
661
661
  permissions:Yc(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:s,$tag:l,hidden:!1,links:{},document:{title:""}},e);return Ci(c)&&(c.permissions=Gc(i)),c}create(e,t=new Date){const n=this._initialize(e,t);this._store.addAnnotations([n]),this._store.deleteNewAndEmptyDrafts(),Ci(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:!xi(n)}),Ai(n)?this._store.selectTab("note"):Ti(n)&&this._store.selectTab("annotation"),(n.references||[]).forEach((e=>{this._store.setExpanded(e,!0)}))}createPageNote(){const e=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!e)return;const t={target:[],uri:e.uri};this.create(t)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,
662
662
  permissions:xi(e)?Vc(t,e.group):Gc(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;yi(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(let[t,n]of Object.entries(e))if(t.startsWith("$")){o[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([o]),o}}kb.$inject=["annotationActivity","api","store"];class Sb{constructor(e){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:Wc(t.permissions)}}
663
663
  ;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])}}Sb.$inject=["settings"];class Nb extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function Cb(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Nb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new Nb(e,n,"Failed to parse response")}var o;if(!n.ok)throw new Nb(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}function Eb(e){const t={};for(let[n,r]of Object.entries(e))n.startsWith("$")||(t[n]=r);return t}function Ab(e){return"url"in e}function Tb(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,l]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".")
664
- ;for(let[e,t]of r.entries()){const o=n[t];if(!o||Ab(o)){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1163.0"};l&&(u.Authorization="Bearer "+l);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:p}=Ia(c.url,a),m=new URL(h);for(let[e,t]of Object.entries(p)){Array.isArray(t)||(t=[t]);for(let n of t)null!=n&&m.searchParams.append(e,n.toString())}return await Cb(m.toString(),{body:s?JSON.stringify(Eb(s)):null,headers:u,method:c.method})}finally{i()}}}class Mb{constructor(e,t,n){const r=e.routes();this._clientId=null;const o=()=>this._clientId,i=e=>Tb(r,e,{getAccessToken:t.getAccessToken,getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),
664
+ ;for(let[e,t]of r.entries()){const o=n[t];if(!o||Ab(o)){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1164.0"};l&&(u.Authorization="Bearer "+l);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:p}=Ia(c.url,a),m=new URL(h);for(let[e,t]of Object.entries(p)){Array.isArray(t)||(t=[t]);for(let n of t)null!=n&&m.searchParams.append(e,n.toString())}return await Cb(m.toString(),{body:s?JSON.stringify(Eb(s)):null,headers:u,method:c.method})}finally{i()}}}class Mb{constructor(e,t,n){const r=e.routes();this._clientId=null;const o=()=>this._clientId,i=e=>Tb(r,e,{getAccessToken:t.getAccessToken,getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),
665
665
  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}}Mb.$inject=["apiRoutes","auth","store"];var Lb={exports:{}},zb={};function Rb(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 Ib=Rb;Rb.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},Rb.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),
666
666
  this._timeouts=[],this._cachedTimeouts=null},Rb.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},Rb.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()
667
667
  }),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},Rb.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},Rb.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},Rb.prototype.start=Rb.prototype.try,Rb.prototype.errors=function(){return this._errors},Rb.prototype.attempts=function(){return this._attempts},Rb.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=Ib;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})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n]
@@ -696,8 +696,8 @@ const e=Object.values(this._store.pendingUpdates());e.length&&this._store.addAnn
696
696
  }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,Kb(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}h_.$inject=["store","apiRoutes","auth","groups","session"];class p_{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject("hypothesis.user.tags.list")||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${p(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){
697
697
  const t=this._storage.getObject("hypothesis.user.tags.map")||{};e.forEach((e=>{t[e]?(t[e].count+=1,t[e].updated=Date.now()):t[e]={text:e,count:1,updated:Date.now()}})),this._storage.setObject("hypothesis.user.tags.map",t);const n=Object.keys(t).sort(((e,n)=>t[e].count!==t[n].count?t[n].count-t[e].count:e.localeCompare(n)));this._storage.setObject("hypothesis.user.tags.list",n)}}p_.$inject=["localStorage"];class m_{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}m_.$inject=["store"];class f_{constructor(e){this._store=e}dismiss(e){const t=this._store.getToastMessage(e);t&&!t.isDismissed&&(this._store.updateToastMessage({...t,isDismissed:!0}),setTimeout((()=>{this._store.removeToastMessage(e)}),500))}_addMessage(e,t,{autoDismiss:n=!0,moreInfoURL:r="",visuallyHidden:o=!1}={}){if(this._store.hasToastMessage(e,t))return;const i=a(10),s={type:e,id:i,message:t,moreInfoURL:r,visuallyHidden:o};this._store.addToastMessage({
698
698
  isDismissed:!1,...s}),n&&setTimeout((()=>{this.dismiss(i)}),5e3)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}f_.$inject=["store"];class g_{constructor(){this._providers=new Map,this._instances=new Map,this._constructing=new Set}get(e){if(this._instances.has(e))return this._instances.get(e);const t=this._providers.get(e);if(!t)throw new Error(`"${e}" is not registered`);if("value"in t)return this._instances.set(e,t.value),t.value;if(this._constructing.has(e))throw new Error(`Encountered a circular dependency when constructing "${e}"`);this._constructing.add(e);try{const n=[],r="class"in t&&t.class.$inject||"factory"in t&&t.factory.$inject||[];for(const t of r)try{n.push(this.get(t))}catch(n){const r=new Error(`Failed to construct dependency "${t}" of "${e}": ${n.message}`);throw r.cause=n,r}let o;if(t.class)o=new t.class(...n);else{o=(0,t.factory)(...n)}return this._instances.set(e,o),o}finally{this._constructing.delete(e)}}
699
- register(e,t){if("function"==typeof t)t={class:t};else if(!function(e){return"object"==typeof e&&null!==e&&("value"in e||"function"==typeof e.class||"function"==typeof e.factory)}(t))throw new Error(`Invalid provider for "${e}"`);return this._providers.set(e,t),this}run(e){const t="Injector.run";this.register(t,{factory:e});try{return this.get(t)}finally{this._instances.delete(t),this._providers.delete(t)}}}const v_=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),b_=function(t){const{version:n,origin:r}=e(t.location.href);return"1.1163.0"!==n?(console.warn(`The Hypothesis sidebar is using a different version (1.1163.0) than the host page (${n}). It may not work.`),!1):"null"===t.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),
700
- !1):t.origin===r||(console.warn(`The Hypothesis sidebar is running in a different origin (${t.origin}) than expected (${r}). It may not work.`),!1)}(window);function __(e,t){e.setClientId(t.clientId)}function y_(e,t,n){e.load(),t.load(),n.sync()}function w_(e,t,n){e.init(),t.init(),n.init()}function x_(e,t){"sidebar"===t.route()&&e.connect()}v_.sentry&&b_&&function(t){const n=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),r=n?[n]:void 0;In({dsn:t.dsn,environment:t.environment,allowUrls:r,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1163.0",beforeSend:(e,t)=>{if(Bn>=5)return u("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Bn;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{bt("host_config",e(window.location.href))}catch(e){}
699
+ register(e,t){if("function"==typeof t)t={class:t};else if(!function(e){return"object"==typeof e&&null!==e&&("value"in e||"function"==typeof e.class||"function"==typeof e.factory)}(t))throw new Error(`Invalid provider for "${e}"`);return this._providers.set(e,t),this}run(e){const t="Injector.run";this.register(t,{factory:e});try{return this.get(t)}finally{this._instances.delete(t),this._providers.delete(t)}}}const v_=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),b_=function(t){const{version:n,origin:r}=e(t.location.href);return"1.1164.0"!==n?(console.warn(`The Hypothesis sidebar is using a different version (1.1164.0) than the host page (${n}). It may not work.`),!1):"null"===t.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),
700
+ !1):t.origin===r||(console.warn(`The Hypothesis sidebar is running in a different origin (${t.origin}) than expected (${r}). It may not work.`),!1)}(window);function __(e,t){e.setClientId(t.clientId)}function y_(e,t,n){e.load(),t.load(),n.sync()}function w_(e,t,n){e.init(),t.init(),n.init()}function x_(e,t){"sidebar"===t.route()&&e.connect()}v_.sentry&&b_&&function(t){const n=function(){let e=import.meta.url;return e?new URL(e).origin:null}(),r=n?[n]:void 0;In({dsn:t.dsn,environment:t.environment,allowUrls:r,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1164.0",beforeSend:(e,t)=>{if(Bn>=5)return u("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++Bn;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{bt("host_config",e(window.location.href))}catch(e){}
701
701
  bt("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Dn(((e,t)=>{vt(e,{tags:{context:t}})}))}(v_.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;if("A"===t.tagName){const e=t;"_blank"===e.target&&(e.rel="noopener")}}))}(document.body),__.$inject=["api","streamer"],y_.$inject=["groups","session","router"],w_.$inject=["autosaveService","persistedDefaults","serviceURL"],x_.$inject=["frameSync","store"],function(e,{reset:t=!1}={}){t&&Xr.clear();for(let[t,n]of Object.entries(e))Xr.set(t,n)}(Ro);const k_=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",v)}(),async function(i,a=window){const c=function(t){const i=e(t.location.href),a=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],s={openSidebar:n,
702
702
  requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:o(t.origin),ancestorLevel:r(t.ancestorLevel)}}},l={};for(let[e,t]of Object.entries(i))a.includes(e)&&null!==t&&(s[e]?l[e]=s[e](t):l[e]=t);return l}(window),u=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:l(n.ancestorLevel,t),origin:n.origin}}(c,a);let d;if(u){const e=await async function(e,t){return{...await s(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(c,u);d=function(e,t){const n=e.services;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=s(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,u)}else d=c;const h={...i,...d}
703
703
  ;return u&&(h.rpc=u),h.apiUrl=function(e){const n=t(e);if(n){if(n.apiUrl)return n.apiUrl;throw new Error("Service should contain an apiUrl value.")}return e.apiUrl}(h),h}(v_).then((e=>{!function(e,t){const n=new g_;n.register("annotationsService",kb).register("annotationActivity",Sb).register("api",Mb).register("apiRoutes",Pb).register("auth",jb).register("autosaveService",Ub).register("frameSync",Jb).register("groups",t_).register("loadAnnotationsService",n_).register("localStorage",o_).register("persistedDefaults",a_).register("router",s_).register("serviceURL",l_).register("session",c_).register("streamer",h_).register("streamFilter",u_).register("tags",p_).register("threadsService",m_).register("toastMessenger",f_).register("store",{factory:ss}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(w_),n.run(__),n.run(y_),n.run(g),n.run(x_),_r(Zr(Bo.Provider,{value:n,children:Zr(wb,{})}),t)}(e,k_)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),