hypothesis 1.1447.0 → 1.1448.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/boot.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?df002b","styles/annotator.css":"styles/annotator.css?2b0b58","styles/annotator.css.map":"styles/annotator.css.map?310e26","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e179ab","styles/katex.min.css.map":"styles/katex.min.css.map?cd8c0e","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?13d728","styles/sidebar.css.map":"styles/sidebar.css.map?1984a9","styles/ui-playground.css":"styles/ui-playground.css?db6174","styles/ui-playground.css.map":"styles/ui-playground.css.map?ec0173","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?621536","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?3d571c","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?320d7c","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?d15e01","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?db2898"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1447.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var d=l,u=a(d.notebookAppUrl||"https://hypothes.is/notebook"),h=a(d.profileAppUrl||"https://hypothes.is/user-profile"),y=a(d.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,d=c;p<d.length;p++)e(s,i(t,d[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:u,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
1
+ !function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?7130f5","styles/annotator.css":"styles/annotator.css?2b0b58","styles/annotator.css.map":"styles/annotator.css.map?310e26","styles/highlights.css":"styles/highlights.css?6b4ebd","styles/highlights.css.map":"styles/highlights.css.map?241350","styles/katex.min.css":"styles/katex.min.css?e179ab","styles/katex.min.css.map":"styles/katex.min.css.map?cd8c0e","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?c95edf","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?1d8ac6","styles/sidebar.css":"styles/sidebar.css?13d728","styles/sidebar.css.map":"styles/sidebar.css.map?1984a9","styles/ui-playground.css":"styles/ui-playground.css?db6174","styles/ui-playground.css.map":"styles/ui-playground.css.map?ec0173","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?3bfff8","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?621536","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?3d571c","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?d0a3c6","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?d15e01"};function t(s){s.setAttribute("data-hypothesis-asset","")}function e(s,e){var n=s.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=e,t(n),s.head.appendChild(n)}function n(s,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.esModule,o=void 0===r||r,i=n.forceReload,a=void 0!==i&&i,l=s.createElement("script");o&&(l.type="module"),a&&(e+="#ts=".concat(Date.now())),l.src=e,l.async=!1,t(l),s.head.appendChild(l)}function r(s,e,n,r){var o=s.createElement("link");o.rel=e,o.href=r,o.type="application/annotator+".concat(n),t(o),s.head.appendChild(o)}function o(s,e,n){var r=s.createElement("link");r.rel="preload",r.as=e,r.href=n,"fetch"===e&&(r.crossOrigin="anonymous"),t(r),s.head.appendChild(r)}function i(s,t){return s.assetRoot+"build/"+s.manifest[t]}function a(s){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var e=function(){var s,t,e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return e?(s=e.src,(t=s.match(/(https?):\/\/([^:/]+)/))?{protocol:t[1],hostname:t[2]}:null):null}(t);if(!e)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",e.hostname)).replace("{current_scheme}",e.protocol)}if(function(){var s=[function(){return Object.fromEntries([])},function(){return new URL(document.location.href)},function(){return new Request("https://hypothes.is")},function(){return Element.prototype.attachShadow},function(){return CSS.supports("display: grid")},function(){return document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0}];try{return s.every((function(s){return s()}))}catch(s){return!1}}()){var l=function(s){for(var t={},e=s.querySelectorAll("script.js-hypothesis-config"),n=0;n<e.length;n++){var r=void 0;try{r=JSON.parse(e[n].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),r={}}Object.assign(t,r)}return t}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1448.0/");if(document.querySelector("hypothesis-app")){!function(s,t){o(s,"fetch",t.apiUrl),o(s,"fetch",t.apiUrl+"links");for(var r=0,a=["scripts/sidebar.bundle.js"];r<a.length;r++)n(s,i(t,a[r]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)e(s,i(t,c[l]))}(document,{assetRoot:c,manifest:s,apiUrl:l.apiUrl})}else{var p=function(){var s;return null===(s=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).chrome)||void 0===s||null===(s=s.runtime)||void 0===s?void 0:s.id}();if(p&&!function(s){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:document).querySelector("script.js-hypothesis-config[data-extension-id=".concat(s,"]"))}(p))throw new Error("Could not start Hypothesis extension as configuration is missing");var u=l,d=a(u.notebookAppUrl||"https://hypothes.is/notebook"),h=a(u.profileAppUrl||"https://hypothes.is/user-profile"),y=a(u.sidebarAppUrl||"https://hypothes.is/app.html");!function(s,t){if(!s.querySelector('link[type="application/annotator+html"]')){r(s,"sidebar","html",t.sidebarAppUrl),r(s,"notebook","html",t.notebookAppUrl),r(s,"profile","html",t.profileAppUrl),o(s,"style",i(t,"styles/annotator.css")),r(s,"hypothesis-client","javascript",t.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)n(s,i(t,l[a]),{esModule:!1});var c=[];void 0!==window.PDFViewerApplication&&c.push("styles/pdfjs-overrides.css"),c.push("styles/highlights.css");for(var p=0,u=c;p<u.length;p++)e(s,i(t,u[p]))}}(document,{assetRoot:c,manifest:s,notebookAppUrl:d,profileAppUrl:h,sidebarAppUrl:y})}}else console.warn("The Hypothesis annotation tool is not supported in this browser. See https://web.hypothes.is/help/which-browsers-are-supported-by-hypothesis/.")}();
@@ -1,5 +1,5 @@
1
1
  {
2
- "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?df002b",
2
+ "scripts/annotator.bundle.js": "scripts/annotator.bundle.js?7130f5",
3
3
  "styles/annotator.css": "styles/annotator.css?2b0b58",
4
4
  "styles/annotator.css.map": "styles/annotator.css.map?310e26",
5
5
  "styles/highlights.css": "styles/highlights.css?6b4ebd",
@@ -12,9 +12,9 @@
12
12
  "styles/sidebar.css.map": "styles/sidebar.css.map?1984a9",
13
13
  "styles/ui-playground.css": "styles/ui-playground.css?db6174",
14
14
  "styles/ui-playground.css.map": "styles/ui-playground.css.map?ec0173",
15
+ "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?3bfff8",
15
16
  "scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?621536",
16
17
  "scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?3d571c",
17
- "scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?320d7c",
18
- "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?d15e01",
19
- "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?db2898"
18
+ "scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?d0a3c6",
19
+ "scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?d15e01"
20
20
  }
@@ -138,7 +138,7 @@ const e=this.anchors.find((e=>e.annotation.$tag===t));null!=e&&e.highlights&&awa
138
138
  this._sendDocumentInfo()}destroy(){var t;this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),null===(t=this._clusterToolbar)||void 0===t||t.destroy(),function(t){Zn(Array.from(t.querySelectorAll("hypothesis-highlight")))}(this.element),this._integration.destroy()}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{var e;const n=dr(t);if(!n)return;const i=Gn(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)&&Qn(i,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type)))return{annotation:t,target:e};let n;try{
139
139
  const i=await this._integration.anchor(this.element,e.selector),o=Fn.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&&Zn(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){var n;this.anchors=t,null===(n=this._clusterToolbar)||void 0===n||n.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),i=this.element,o=(await Promise.all(e.map((t=>this._integration.describe(i,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:o,
140
140
  $highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+s(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),fr(),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);Qn(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),i=Wn(n),o=jn(n);o?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=hr(),this._isAdderVisible=!0,this._adder.show(o,i)):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){
141
- e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){re(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function gr(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function _r(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1447.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),
141
+ e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){!function(t,e){t.classList.toggle("hypothesis-highlights-always-on",e)}(this.element,t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){re(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}}function gr(t,e){const n=new URL(t),i=new URLSearchParams;return i.append("config",JSON.stringify(e)),n.hash=i.toString(),n.toString()}function _r(t,e){var n;const i={};for(const[t,n]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=n&&(i[t]=n);i.origin=new URL(t).origin,i.version="1.1448.0";const o=new URL(window.location.href);if(o.hash="",i.hostURL=o.toString(),
142
142
  Array.isArray(i.services)&&(null===(n=i.services)||void 0===n?void 0:n.length)>0){const t=i.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return i}function vr({config:t,groupId:e}){return ve("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:gr(t.notebookAppUrl,{..._r(t.notebookAppUrl,t),group:e})})}function br({eventBus:t,config:e}){const[n,i]=zt(0),[o,r]=zt(!0),[s,a]=zt(null),l=Xt(""),c=Xt(null);$t((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),$t((()=>{document.body.style.overflow=o?l.current:"hidden"}),[o]),$t((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),i((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);return null===s?null:ve("div",{
143
143
  className:ge("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:o}),"data-testid":"notebook-outer",children:ve("div",{className:"relative w-full h-full","data-testid":"notebook-inner",children:[ve("div",{className:"absolute right-0 m-3",children:ve(on,{title:"Close the Notebook",onClick:()=>{var t;r(!0),null===(t=c.current)||void 0===t||t.publish("closeNotebook")},variant:"dark",classes:ge("!bg-transparent enabled:hover:!bg-grey-3"),children:ve(Ee,{className:"w-4 h-4"})})}),ve(vr,{config:e,groupId:s},n)]})})}class yr{constructor(t,e,n){i(this,"_container",void 0),this._container=new En("notebook",(()=>ve(br,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function wr({eventBus:t,config:e}){const[n,i]=zt(!0),o=Xt(null);$t((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{i(!1)})),o.current=e,()=>{e.destroy()}}),[t]);return n?null:ve("div",{
144
144
  className:"fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50","data-testid":"profile-outer",children:ve("div",{className:"relative w-full h-full","data-testid":"profile-inner",children:[ve("div",{className:"absolute right-0 m-3",children:ve(on,{title:"Close the Profile",onClick:()=>{var t;i(!0),null===(t=o.current)||void 0===t||t.publish("closeProfile")},variant:"dark",classes:ge("!bg-transparent enabled:hover:!bg-grey-3"),children:ve(Ee,{className:"w-4 h-4"})})}),ve("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})})}class xr{constructor(t,e,n){i(this,"_container",void 0),this._container=new En("profile",(()=>ve(wr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}var Cr={exports:{}};!function(t){!function(e,n,i,o){var r,s=["","webkit","Moz","MS","ms","o"],a=n.createElement("div"),l="function",c=Math.round,h=Math.abs,u=Date.now;function d(t,e,n){return setTimeout(b(t,n),e)}
@@ -516,34 +516,35 @@ a.selectionStart=a.selectionEnd-r.length),o===t&&i===n?(a=Pm(a,a.selectionStart-
516
516
  const a=de((()=>us()?"Cmd":"Ctrl"),[]);let s=i;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?Oe(Kn,{classes:"p-1.5 text-grey-7 hover:text-grey-9",...l,size:"custom",variant:"custom",children:n}):Oe(er,{classes:"px-2 py-2.5",...l,children:t&&Oe(t,{className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function qm({classes:e,containerRef:t,...n}){return Oe("textarea",{className:X("border rounded p-2","text-color-text-light bg-grey-0","focus:bg-white focus:outline-none focus:shadow-focus-inner",e),...n,ref:t})}function Gm({isPreviewing:e,onCommand:t,onTogglePreview:n}){const r=ue(null);return Se(r),Oe("div",{className:X("flex flex-wrap w-full items-center","p-1 border-x border-t rounded-t bg-white","touch:h-auto touch:overflow-x-scroll touch:flex-nowrap touch:pb-2.5"),"data-testid":"markdown-toolbar",role:"toolbar","aria-label":"Markdown editor toolbar",ref:r,children:[Oe(Um,{disabled:e,icon:Tt,onClick:()=>t("bold"),shortcutKey:$m.bold,title:"Bold"}),Oe(Um,{
517
517
  disabled:e,icon:Mt,onClick:()=>t("italic"),shortcutKey:$m.italic,title:"Italic"}),Oe(Um,{disabled:e,icon:At,onClick:()=>t("quote"),shortcutKey:$m.quote,title:"Quote"}),Oe(Um,{disabled:e,icon:on,onClick:()=>t("link"),shortcutKey:$m.link,title:"Insert link"}),Oe(Um,{disabled:e,icon:en,onClick:()=>t("image"),shortcutKey:$m.image,title:"Insert image"}),Oe(Um,{disabled:e,icon:Nt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Oe(Um,{disabled:e,icon:sn,onClick:()=>t("numlist"),shortcutKey:$m.numlist,title:"Numbered list"}),Oe(Um,{disabled:e,icon:cn,onClick:()=>t("list"),shortcutKey:$m.list,title:"Bulleted list"}),Oe("div",{className:"grow flex justify-end",children:[Oe(Lr,{classes:"text-grey-7 hover:!text-grey-7",href:"https://web.hypothes.is/help/formatting-annotations-with-markdown/",target:"_blank",title:"Formatting help","aria-label":"Formatting help",underline:"none",variant:"custom",children:Oe("div",{
518
518
  className:X("flex justify-center items-center","touch:h-touch-minimum touch:w-touch-minimum","px-2 py-2.5 touch:p-0"),children:Oe(Yt,{className:"w-2.5 h-2.5"})})}),Oe(Um,{label:e?"Write":"Preview",onClick:n})]})]})}function Vm({label:e,onEditText:t=(()=>{}),text:n,textStyle:r={}}){const[o,i]=ae(!1),a=ue(null);le((()=>{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)?Fm(e,"$$","$$","Insert LaTeX"):Fm(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>Fm(e,"**","**","Bold")));break;case"italic":n((e=>Fm(e,"*","*","Italic")));break;case"quote":n((e=>jm(e,"> ")));break;case"link":n((e=>Dm(e)));break;case"image":n((e=>Dm(e,Rm.IMAGE_LINK)));break;case"math":n(r);break
519
- ;case"numlist":n((e=>jm(e,(e=>`${e+1}. `))));break;case"list":n((e=>jm(e,"* ")))}}(e,a.current),t(a.current.value))};return Oe("div",{className:"leading-none",children:[Oe(Gm,{onCommand:s,isPreviewing:o,onTogglePreview:()=>i(!o)}),o?Oe(Mm,{markdown:n,classes:"border bg-grey-1 p-2",style:r}):Oe(qm,{"aria-label":e,dir:"auto",classes:X("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($m))n===e.key&&(e.stopPropagation(),e.preventDefault(),s(t))},onInput:e=>t(e.target.value),value:n,style:r})]})}const Wm=e=>e;function Ym({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Wm,onSelectItem:i,open:a=!1}){const s=de((()=>r.map(((t,r)=>{const a=n?{id:`${n}${r}`}:{};return Oe("li",{role:"option","aria-selected":e===r,className:X("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,
520
- "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 Oe("div",{className:"relative",children:Oe("div",{className:X({hidden:c},"absolute top-[3px] z-3","min-w-[10em]"),"data-testid":"autocomplete-list-container",children:Oe($e,{width:"auto",classes:"overflow-hidden",children:[Oe("ul",{tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s}),Oe(ms,{direction:"up",classes:"top-[-8px] left-2"})]})})})}let Km=0;var Xm=Kr((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++Km,`TagEditor-${Km}`))),m=ue(null);$r(m,u,(()=>{d(!1)}));const p=()=>i.current.value.trim(),f=()=>p()&&p().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 Oe("div",{className:"space-y-4",
521
- children:[Oe(Im,{children:r.map((e=>Oe(zm,{onRemoveTag:t,tag:e},e)))}),Oe("div",{id:h,"data-testid":"combobox-container",ref:m,children:[Oe(Sr,{onInput:()=>{null==n||n(p()),(()=>{if(f()){const e=o.filter(p());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?p():a[l]),e.preventDefault();break;case"Tab":if(!f())break;-1!==l?v(a[l]):1===a.length?v(a[0]):v(p()),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-expanded":u,"aria-label":"Add tags",dir:"auto",role:"combobox",classes:X("text-base touch:text-touch-base")}),Oe(Ym,{id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{
522
- const t=p().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Oe("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Oe("span",{children:[Oe("strong",{children:r}),o,Oe("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Jm(){return Oe("div",{className:"pt-2 border-t text-xs leading-none",children:Oe(Lr,{href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",title:"View more information about the Creative Commons Public Domain dedication",underline:"none",variant:"text-light",children:Oe("div",{className:"flex items-center",children:[Oe(lt,{className:"w-[10px] h-[10px]"}),Oe(ut,{className:"w-[10px] h-[10px] ml-px"}),Oe("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})})}function Zm(e){return null!==e.offsetParent}function Qm({className:e,closeMenu:t,children:n,visible:r}){const o=ue(null)
523
- ;le((()=>{let e;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return Oe("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Zm);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 ep=!1;const tp=()=>{};function np({align:e="left",children:t,containerPositioned:n=!0,contentClass:r,defaultOpen:o=!1,disabled:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[d,h]=ae(o);"boolean"==typeof s&&(d=s,h=l||tp);const m=ue(d);le((()=>{"function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{
524
- if("mousedown"===e.type)ep=!0;else if("click"===e.type&&ep)return ep=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=he((()=>h(!1)),[h]),g=ue(null);$r(g,d,f);const v=e=>e.stopPropagation();return Oe("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Oe("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:X("focus-visible-ring","flex items-center justify-center rounded transition-colors",{"text-grey-7 hover:text-grey-9":!d,"text-brand":d}),"data-testid":"menu-toggle-button",disabled:i,onMouseDown:p,onClick:p,"aria-label":u,title:u,children:Oe("span",{className:"flex items-center gap-x-1",children:[a,c&&Oe("span",{className:X({"rotate-180 text-color-text":d}),children:Oe(vn,{className:"w-2.5 h-2.5"})})]})}),d&&Oe("div",{className:X("focus-visible-ring","absolute top-[calc(100%+3px)] z-1","border shadow-intense rounded-lg overflow-hidden bg-white text-md",{"left-0":"left"===e,"right-0":"right"===e
525
- },r),"data-testid":"menu-content",role:"menu",tabIndex:-1,onClick:f,onKeyDown:e=>{const t=e.key;"Enter"!==t&&" "!==t||setTimeout((()=>{f()}))},children:Oe(Qm,{visible:!0,children:t})})]})}function rp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?ot:vn;return Oe("div",{"data-testid":"submenu-toggle",role:"none",className:X("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:Oe(r,{className:"w-3 h-3"})})}function op({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d}){const h=ue(null);let m,p;const f="boolean"==typeof a,g="boolean"==typeof o;le((()=>()=>{clearTimeout(m)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},_=t?Oe(t,{
526
- className:"h-3 w-3"}):null,y=i?null:_,w=i?_:null,x=!!w,k=Oe(v,{children:[(l||i||!!y)&&Oe("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:null!=l?l:y}),Oe("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),x&&Oe("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),f&&Oe(rp,{title:`Show actions for ${s}`,isExpanded:a,onToggleSubmenu:u})]}),N=X("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none cursor-pointer",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1 hover:bg-grey-3":i||r,"bg-white hover:bg-grey-1":!i&&!r,"pr-1":!f},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return p=e?Oe("a",{ref:h,className:N,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,
527
- rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:k}):Oe("div",{ref:h,className:N,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:g?"menuitemradio":"menuitem","aria-checked":g?o:void 0,"aria-haspopup":f,"aria-expanded":f?a:void 0,children:k}),Oe(v,{children:[p,f&&Oe(Hr,{direction:a?"in":"out",children:Oe(Qm,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{h.current.focus()}))},visible:a,className:"border-y border-grey-3",children:d})})]})}var ip=Kr((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=Wr(["ctaTextColor","ctaBackgroundColor"],a),l=Oe("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Oe(vn,{className:"w-4 h-4"})});return Oe("div",{className:"flex flex-row gap-x-3",children:[Oe("div",{className:"flex relative",children:[Oe(Kn,{classes:X("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"lg",variant:"primary",
528
- children:["Post to ",n?"Only Me":e.name]}),Oe("div",{className:X("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Oe(np,{containerPositioned:!1,contentClass:X("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Oe(op,{icon:"open"===e.type?qt:Vt,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Oe(op,{icon:dn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]}),Oe("div",{children:Oe(Kn,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Oe(et,{}),"Cancel"]})})]})}),["settings"]);var ap=Kr((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){const[a,s]=ae(null),l=Ea(),c=l.getGroup(e.group),u=!t.isPrivate&&c&&"private"!==c.type,d=t.tags,h=t.text,m=!h&&!d.length,p=he((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),f=he((e=>{if(!e||d.indexOf(e)>=0)return!1;const t=[...d,e];return o.store(t),p(t),!0}),[p,d,o]),g=he((e=>{const t=[...d],n=t.indexOf(e);return n>=0&&(t.splice(n,1),p(t),!0)
529
- }),[p,d]),v=he((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),b=he((n=>{l.createDraft(e,{...t,isPrivate:n}),zo(e)||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,l]),_=async()=>{a&&f(a);const t=`${Uo(e)} ${Lo(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch(e){i.error("Saving annotation failed")}},y=he((()=>{l.removeDraft(e),Lo(e)||l.removeAnnotations([e])}),[e,l]);return Oe("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;m||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),_())},children:[Oe(Vm,{textStyle:Wr(["annotationFontFamily"],r),label:"Annotation body",text:h,onEditText:v}),Oe(Xm,{onAddTag:f,onRemoveTag:g,onTagInput:s,tagList:d}),c&&Oe(ip,{group:c,isDisabled:m,isPrivate:t.isPrivate,onCancel:y,onSave:_,onSetPrivate:b}),u&&Oe(Jm,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function sp({domain:e,link:t,title:n}){return Oe("div",{className:"flex gap-x-1",
530
- children:[Oe("div",{className:"text-color-text-light",children:['on "',t?Oe(Lr,{href:t,target:"_blank",underline:"none",children:n}):Oe("span",{children:n}),'"']}),e&&Oe("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function lp({group:e}){const t=null==e?void 0:e.links.html;return Oe(v,{children:e&&t&&Oe(Lr,{classes:X("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:Oe("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?Oe(qt,{className:"w-2.5 h-2.5"}):Oe(Vt,{className:"w-2.5 h-2.5"}),Oe("span",{children:e.name})]})})})}const cp=1e3,up=60*cp,dp=60*up;let hp={};function mp(e,t){return t-e}function pp(e,t,n=window.Intl){const r=JSON.stringify(t);let o=hp[r];return o||(o=hp[r]=new n.DateTimeFormat(void 0,t)),o.format(e)}const fp=[{test:(e,t)=>mp(e,t)<30*cp,formatter:()=>"Just now",nextUpdate:1*cp},{test:(e,t)=>mp(e,t)<1*up,formatter:(e,t)=>`${Math.floor(mp(e,t)/cp)} secs ago`,
531
- nextUpdate:1*cp},{test:(e,t)=>mp(e,t)<1*dp,formatter:(e,t)=>{const n=Math.floor(mp(e,t)/up);return`${n} min${n>1?"s":""} ago`},nextUpdate:1*up},{test:(e,t)=>mp(e,t)<24*dp,formatter:(e,t)=>{const n=Math.floor(mp(e,t)/dp);return`${n} hr${n>1?"s":""} ago`},nextUpdate:1*dp},{test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:(e,t,n)=>pp(e,{month:"short",day:"numeric"},n),nextUpdate:null}],gp={test:()=>!0,formatter:(e,t,n)=>pp(e,{day:"numeric",month:"short",year:"numeric"},n),nextUpdate:null};function vp(e,t){for(const n of fp)if(n.test(e,t))return n;return gp}function bp(e){return!isNaN(e.valueOf())}function _p(e,t){let n;const r=new Date(e),o=()=>{const e=function(e,t){if(!e||!bp(e)||!bp(t))return null;let n=vp(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5*cp),n=Math.min(n,2073600*cp),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function yp(e,t,n){return e?vp(e,t).formatter(e,t,n):""}function wp(e,t){return pp(e,{year:"numeric",month:"short",
532
- day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"},t)}function xp(e){return`${e.getFullYear()}-${`${e.getMonth()+1}`.padStart(2,"0")}-${`${e.getDate()}`.padStart(2,"0")} ${`${e.getHours()}`.padStart(2,"0")}:${`${e.getMinutes()}`.padStart(2,"0")}`}function kp({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){const[o,i]=ae((()=>new Date)),a=de((()=>new Date(e)),[e]),s=de((()=>r&&new Date(t)),[t,r]),l=de((()=>({absolute:wp(a),relative:yp(a,o)})),[a,o]),c=de((()=>s?{absolute:wp(s),relative:yp(s,o)}:{}),[s,o]);le((()=>_p(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Oe("div",{children:[r&&Oe("span",{className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Oe(Lr,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):Oe("span",{
533
- className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function Np({authorLink:e,displayName:t}){const n=Oe("h3",{className:"text-color-text font-bold",children:t});return e?Oe(Lr,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Oe("div",{children:n})}var Sp=Kr((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){var i;const a=Ea(),s=a.defaultAuthority(),l=a.isFeatureEnabled("client_display_names"),c=a.getLink("user",{user:e.user}),u=de((()=>rs(e,s,l)),[e,s,l]),d=de((()=>function(e,t,n,r){var o;return!ns(e.user,n)&&r?r:null!==(o=t.usernameUrl&&`${t.usernameUrl}${ts(e.user)}`)&&void 0!==o?o:void 0}(e,o,s,c)),[e,o,s,c]),h=zo(e)&&r,m=(null===(i=e.links)||void 0===i?void 0:i.html)||"",p=de((()=>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{
534
- domain:Mo(e),titleText:Io(e),titleLink:Co(e)}}(e),g=m&&f.titleLink?f.titleLink:"",v="sidebar"!==a.route()&&f.titleText;let b;"sidebar"!==a.route()&&(b=a.getGroup(e.group));const _=Wo(e);return Oe("header",{children:[Oe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse",children:[cs(e.permissions)&&!t&&Oe(dn,{className:"w-[10px] h-[10px]",title:"This annotation is visible only to you"}),Oe(Np,{authorLink:d,displayName:u}),n>0&&h&&Oe(Rr,{variant:"text-light",onClick:()=>a.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Oe("div",{className:"flex justify-end grow",children:Oe(kp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:m,withEditedTimestamp:p})})]}),!zo(e)&&Oe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[b&&Oe(lp,{group:b}),!t&&Bo(e)&&Oe(Zt,{title:"This is a highlight. Click 'edit' to add a note or tag.",
535
- className:"w-[10px] h-[10px] text-color-text-light"}),(v||_)&&Oe("span",{className:"flex",children:[v&&Oe(sp,{domain:f.domain,link:g,title:f.titleText}),_&&Oe("span",{className:"text-grey-6","data-testid":"page-number",children:[v&&", ","p. ",_]})]})]})]})}),["settings"]);var Ap=Kr((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Oe(ys,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Oe(Cm,{classes:X({"p-redacted-text":n}),children:Oe("blockquote",{className:X("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:Wr(["selectionFontFamily"],r),children:e})})})}),["settings"]);function Ep({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Oe(Kn,{classes:X("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}function Tp(){return Oe("div",{className:X("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),
536
- "data-testid":"saving-message",children:[Oe("span",{className:"text-[16px] animate-fade-in-slow",children:Oe(pr,{size:"sm"})}),Oe("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var Cp=Kr((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=Ea(),s=Go(e),l=a.getDraft(e),c=a.profile().userid,u=a.isAnnotationHovered(e.$tag),d=a.isSavingAnnotation(e),h=!!l&&!d,m=t&&o,p=!d&&!h&&Lo(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=de((()=>rs(e,f,g)),[e,f,g]);return Oe("article",{className:"space-y-4","aria-label":`${Lo(e)?Uo(e):`New ${Uo(e).toLowerCase()}`} by ${v}`,children:[Oe(Sp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Oe(Ap,{quote:s,isHovered:u,isOrphan:Ho(e)}),!m&&!h&&Oe(Om,{annotation:e}),h&&Oe(ap,{annotation:e,draft:l}),!m&&Oe("footer",{className:"flex items-center",children:[n&&Oe(Ep,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Oe(Tp,{}),p&&Oe(qe,{
537
- classes:"grow",children:Oe(vs,{annotation:e,onReply:()=>{Lo(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function Mp({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Oe("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Oe("div",{children:Oe("em",{children:"Message not available."})}),r&&Oe("footer",{className:"flex items-center",children:Oe(Ep,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var Ip=Kr((function({annotation:e,api:t,toastMessenger:n}){const r=Ea(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Oe("div",{className:X("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!zo(e),"-mr-3":zo(e)}),children:[Oe("div",{className:X("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Oe(Xt,{className:"w-em h-em"}):Oe(Ht,{className:"w-em h-em"})}),Oe("div",{className:"self-center grow",
538
- children:[!e.hidden&&Oe("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Oe("span",{children:"Hidden from users"})]}),Oe("div",{className:"self-center pr-2",children:Oe(Kn,{classes:X("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),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",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function zp({threadIsCollapsed:e,onToggleReplies:t}){const n=e?nt:vn,r=e?"Expand replies":"Collapse replies";return Oe("div",{
539
- className:X("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Oe("div",{className:X("bg-white"),children:Oe(Kn,{classes:X("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Oe(n,{className:"w-em h-em"})})})})}var Lp=Kr((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>Za(e)>0)),i=Ea(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=he((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=de((()=>t.visible&&Oe(v,{children:t.annotation?Oe(v,{children:[Oe(Ip,{annotation:t.annotation}),Oe(Cp,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Oe(Mp,{isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,
540
- threadIsCollapsed:t.collapsed})})),[r,c,u,t.annotation,t.replyCount,t.collapsed,t.visible]);return Oe("section",{className:"flex","data-testid":"thread-container",children:[r&&Oe(zp,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Oe("div",{className:X("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,Ja(t)>0&&Oe("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Oe(Sp,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Oe("div",{children:Oe(Kn,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",Ja(t)," more in conversation"]})})]}),!t.collapsed&&Oe("ul",{className:X("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Oe("li",{className:X("mt-2","[text-align:start]"),children:Oe(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var Op=Kr((function({frameSync:e,thread:t}){var n,r
541
- ;const o=Ea(),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=de((()=>Va((t=>e.hoverAnnotation(t)),10)),[e]),l=he((t=>{e.scrollToAnnotation(t)}),[e]),c=de((()=>Oe(Lp,{thread:t})),[t]),u=o.annotationFocusRequest(),d=ue(null);return le((()=>{u===t.id&&d.current&&(d.current.focus(),o.clearAnnotationFocusRequest())}),[u,o,t.id]),Oe($e,{active:a,classes:"cursor-pointer focus-visible-ring theme-clean:border-none","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:Oe(Ve,{children:c})},t.id)}),["frameSync"]);const Rp=50;function Pp(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function Dp(e){return Math.max(e-e%Rp,0)}function Fp(e){var t;const n=e.target[0]
542
- ;if(n)return null===(t=n.selector)||void 0===t?void 0:t.find((e=>"EPUBContentSelector"===e.type))}function Bp(e){var t;if(!e.annotation)return null;const n=Fp(e.annotation);return null!==(t=null==n?void 0:n.cfi)&&void 0!==t?t:null}function Hp({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new Wa,t=Pp();n(t.clientHeight),o(Dp(t.scrollTop));const r=Va((()=>{n(t.clientHeight),o(Dp(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[]);const[i,a]=ae((()=>new Map)),[s,l]=ae(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=de((()=>function(e,t,n,r,o=Ya){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]),m=Ea(),p=(()=>{const e=m.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})(),f=de((()=>{
543
- let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=Fp(n.annotation);null!=e&&e.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const a of e){var i;const e=Bp(a);if(!e||t===e)continue;t=e;const s=null!==(i=r.get(e))&&void 0!==i?i:"Untitled chapter";n!==s&&(n=s,o.set(a,s))}return o}),[e]);return le((()=>{p&&(m.setForcedVisible(p,!0),l(p))}),[m,p]),le((()=>{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)||Ya.defaultHeight)(t)),0);Pp().scrollTop=t}),[s,c,i]),le((()=>{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=Ka(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Oe("div",{children:[Oe("div",{style:{height:d}}),h.map((e=>Oe("div",{className:X("mb-3"),"data-testid":"thread-card-container",id:e.id,
544
- children:[f.get(e)&&Oe("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:f.get(e)}),Oe(Op,{thread:e})]},e.id))),Oe("div",{style:{height:u}})]})}const jp={collapsed:!1,depth:0,visible:!0,replyCount:0};function $p(e){return e.id||e.$tag}function Up(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||Up(e,t,r.parent))}function qp(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...jp,children:[],id:r},qp(e,r,n.slice(0,-1))),Up(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function Gp(e,t){return Object.assign({},t(e),{children:e.children.map((e=>Gp(e,t)))})}function Vp(e,t,n){const r=e.children.map((e=>Vp(e,n,n))).slice().sort(t);return{...e,children:r}}function Wp(e,t){const n=e.children.map((e=>Wp(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function Yp(e){return e.children.some((e=>e.visible||Yp(e)))}
545
- const Kp=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Xp(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=$p(e);t[n]={...jp,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return qp(t,$p(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...jp,id:"root",children:n}}(e);return n?o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o})):t.threadFilterFn&&(o.children=o.children.filter(t.threadFilterFn)),o.visible=!1,o=Gp(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||Yp(e))),o=Gp(o,(e=>{const n={collapsed:e.collapsed}
546
- ;if(Eo(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&Yp(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=Vp(o,t.sortCompareFn,Kp),o=Wp(o,-1),o}function Jp(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function Zp(e,t){const n=e=>Jp(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}
519
+ ;case"numlist":n((e=>jm(e,(e=>`${e+1}. `))));break;case"list":n((e=>jm(e,"* ")))}}(e,a.current),t(a.current.value))};return Oe("div",{className:"leading-none",children:[Oe(Gm,{onCommand:s,isPreviewing:o,onTogglePreview:()=>i(!o)}),o?Oe(Mm,{markdown:n,classes:"border bg-grey-1 p-2",style:r}):Oe(qm,{"aria-label":e,placeholder:e,dir:"auto",classes:X("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($m))n===e.key&&(e.stopPropagation(),e.preventDefault(),s(t))},onInput:e=>t(e.target.value),value:n,style:r})]})}const Wm=e=>e;function Ym({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Wm,onSelectItem:i,open:a=!1}){const s=de((()=>r.map(((t,r)=>{const a=n?{id:`${n}${r}`}:{};return Oe("li",{role:"option","aria-selected":e===r,className:X("flex items-center","border-l-4 py-1 px-3 cursor-pointer hover:bg-grey-2","touch:h-touch-minimum",{
520
+ "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 Oe("div",{className:"relative",children:Oe("div",{className:X({hidden:c},"absolute top-[3px] z-3","min-w-[10em]"),"data-testid":"autocomplete-list-container",children:Oe($e,{width:"auto",classes:"overflow-hidden",children:[Oe("ul",{tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s}),Oe(ms,{direction:"up",classes:"top-[-8px] left-2"})]})})})}let Km=0;var Xm=Kr((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++Km,`TagEditor-${Km}`))),m=ue(null);$r(m,u,(()=>{d(!1)}));const p=()=>i.current.value.trim(),f=()=>p()&&p().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}`:""
521
+ ;return Oe("div",{className:"space-y-4",children:[Oe(Im,{children:r.map((e=>Oe(zm,{onRemoveTag:t,tag:e},e)))}),Oe("div",{id:h,"data-testid":"combobox-container",ref:m,children:[Oe(Sr,{onInput:()=>{null==n||n(p()),(()=>{if(f()){const e=o.filter(p());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?p():a[l]),e.preventDefault();break;case"Tab":if(!f())break;-1!==l?v(a[l]):1===a.length?v(a[0]):v(p()),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-expanded":u,"aria-label":"Add tags",dir:"auto",role:"combobox",classes:X("text-base touch:text-touch-base")}),Oe(Ym,{
522
+ id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{const t=p().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Oe("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Oe("span",{children:[Oe("strong",{children:r}),o,Oe("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Jm(){return Oe("div",{className:"pt-2 border-t text-xs leading-none",children:Oe(Lr,{href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",title:"View more information about the Creative Commons Public Domain dedication",underline:"none",variant:"text-light",children:Oe("div",{className:"flex items-center",children:[Oe(lt,{className:"w-[10px] h-[10px]"}),Oe(ut,{className:"w-[10px] h-[10px] ml-px"}),Oe("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})})}function Zm(e){return null!==e.offsetParent}
523
+ function Qm({className:e,closeMenu:t,children:n,visible:r}){const o=ue(null);le((()=>{let e;return r&&(e=setTimeout((()=>{const e=o.current.querySelector('[role^="menuitem"]');e&&e.focus()}))),()=>{clearTimeout(e)}}),[r]);return Oe("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Zm);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 ep=!1;const tp=()=>{};function np({align:e="left",children:t,containerPositioned:n=!0,contentClass:r,defaultOpen:o=!1,disabled:i=!1,label:a,open:s,onOpenChanged:l,menuIndicator:c=!0,title:u}){let[d,h]=ae(o);"boolean"==typeof s&&(d=s,h=l||tp);const m=ue(d);le((()=>{
524
+ "function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{if("mousedown"===e.type)ep=!0;else if("click"===e.type&&ep)return ep=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=he((()=>h(!1)),[h]),g=ue(null);$r(g,d,f);const v=e=>e.stopPropagation();return Oe("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Oe("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:X("focus-visible-ring","flex items-center justify-center rounded transition-colors",{"text-grey-7 hover:text-grey-9":!d,"text-brand":d}),"data-testid":"menu-toggle-button",disabled:i,onMouseDown:p,onClick:p,"aria-label":u,title:u,children:Oe("span",{className:"flex items-center gap-x-1",children:[a,c&&Oe("span",{className:X({"rotate-180 text-color-text":d}),children:Oe(vn,{className:"w-2.5 h-2.5"})})]})}),d&&Oe("div",{
525
+ className:X("focus-visible-ring","absolute top-[calc(100%+3px)] z-1","border shadow-intense rounded-lg overflow-hidden bg-white text-md",{"left-0":"left"===e,"right-0":"right"===e},r),"data-testid":"menu-content",role:"menu",tabIndex:-1,onClick:f,onKeyDown:e=>{const t=e.key;"Enter"!==t&&" "!==t||setTimeout((()=>{f()}))},children:Oe(Qm,{visible:!0,children:t})})]})}function rp({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?ot:vn;return Oe("div",{"data-testid":"submenu-toggle",role:"none",className:X("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:Oe(r,{className:"w-3 h-3"})})}function op({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d}){const h=ue(null);let m,p
526
+ ;const f="boolean"==typeof a,g="boolean"==typeof o;le((()=>()=>{clearTimeout(m)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},_=t?Oe(t,{className:"h-3 w-3"}):null,y=i?null:_,w=i?_:null,x=!!w,k=Oe(v,{children:[(l||i||!!y)&&Oe("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:null!=l?l:y}),Oe("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),x&&Oe("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),f&&Oe(rp,{title:`Show actions for ${s}`,isExpanded:a,onToggleSubmenu:u})]}),N=X("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none cursor-pointer",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1 hover:bg-grey-3":i||r,"bg-white hover:bg-grey-1":!i&&!r,"pr-1":!f
527
+ },{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return p=e?Oe("a",{ref:h,className:N,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:k}):Oe("div",{ref:h,className:N,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:g?"menuitemradio":"menuitem","aria-checked":g?o:void 0,"aria-haspopup":f,"aria-expanded":f?a:void 0,children:k}),Oe(v,{children:[p,f&&Oe(Hr,{direction:a?"in":"out",children:Oe(Qm,{closeMenu:e=>{u&&u(e),m=setTimeout((()=>{h.current.focus()}))},visible:a,className:"border-y border-grey-3",children:d})})]})}var ip=Kr((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=Wr(["ctaTextColor","ctaBackgroundColor"],a),l=Oe("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Oe(vn,{className:"w-4 h-4"})});return Oe("div",{
528
+ className:"flex flex-row gap-x-3",children:[Oe("div",{className:"flex relative",children:[Oe(Kn,{classes:X("rounded-r-none"),"data-testid":"publish-control-button",style:s,onClick:o,disabled:t,size:"lg",variant:"primary",children:["Post to ",n?"Only Me":e.name]}),Oe("div",{className:X("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Oe(np,{containerPositioned:!1,contentClass:X("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Oe(op,{icon:"open"===e.type?qt:Vt,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Oe(op,{icon:dn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]}),Oe("div",{children:Oe(Kn,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Oe(et,{}),"Cancel"]})})]})}),["settings"]);var ap=Kr((function({annotation:e,draft:t,annotationsService:n,settings:r,tags:o,toastMessenger:i}){
529
+ const[a,s]=ae(null),l=Ea(),c=l.getGroup(e.group),u=de((()=>zo(e)),[e]),d=!t.isPrivate&&c&&"private"!==c.type,h=t.tags,m=t.text,p=!m&&!h.length,f=he((e=>{l.createDraft(t.annotation,{...t,tags:e})}),[t,l]),g=he((e=>{if(!e||h.indexOf(e)>=0)return!1;const t=[...h,e];return o.store(t),f(t),!0}),[f,h,o]),v=he((e=>{const t=[...h],n=t.indexOf(e);return n>=0&&(t.splice(n,1),f(t),!0)}),[f,h]),b=he((e=>{l.createDraft(t.annotation,{...t,text:e})}),[t,l]),_=he((n=>{l.createDraft(e,{...t,isPrivate:n}),u||l.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,u,l]),y=async()=>{a&&g(a);const t=`${Uo(e)} ${Lo(e)?"updated":"saved"}`;try{await n.save(e),i.success(t,{visuallyHidden:!0})}catch(e){i.error("Saving annotation failed")}},w=he((()=>{l.removeDraft(e),Lo(e)||l.removeAnnotations([e])}),[e,l]);return Oe("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(),y())},children:[Oe(Vm,{
530
+ textStyle:Wr(["annotationFontFamily"],r),label:u?"Enter reply":"Enter comment",text:m,onEditText:b}),Oe(Xm,{onAddTag:g,onRemoveTag:v,onTagInput:s,tagList:h}),c&&Oe(ip,{group:c,isDisabled:p,isPrivate:t.isPrivate,onCancel:w,onSave:y,onSetPrivate:_}),d&&Oe(Jm,{})]})}),["annotationsService","settings","tags","toastMessenger"]);function sp({domain:e,link:t,title:n}){return Oe("div",{className:"flex gap-x-1",children:[Oe("div",{className:"text-color-text-light",children:['on "',t?Oe(Lr,{href:t,target:"_blank",underline:"none",children:n}):Oe("span",{children:n}),'"']}),e&&Oe("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function lp({group:e}){const t=null==e?void 0:e.links.html;return Oe(v,{children:e&&t&&Oe(Lr,{classes:X("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:Oe("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?Oe(qt,{className:"w-2.5 h-2.5"}):Oe(Vt,{className:"w-2.5 h-2.5"
531
+ }),Oe("span",{children:e.name})]})})})}const cp=1e3,up=60*cp,dp=60*up;let hp={};function mp(e,t){return t-e}function pp(e,t,n=window.Intl){const r=JSON.stringify(t);let o=hp[r];return o||(o=hp[r]=new n.DateTimeFormat(void 0,t)),o.format(e)}const fp=[{test:(e,t)=>mp(e,t)<30*cp,formatter:()=>"Just now",nextUpdate:1*cp},{test:(e,t)=>mp(e,t)<1*up,formatter:(e,t)=>`${Math.floor(mp(e,t)/cp)} secs ago`,nextUpdate:1*cp},{test:(e,t)=>mp(e,t)<1*dp,formatter:(e,t)=>{const n=Math.floor(mp(e,t)/up);return`${n} min${n>1?"s":""} ago`},nextUpdate:1*up},{test:(e,t)=>mp(e,t)<24*dp,formatter:(e,t)=>{const n=Math.floor(mp(e,t)/dp);return`${n} hr${n>1?"s":""} ago`},nextUpdate:1*dp},{test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:(e,t,n)=>pp(e,{month:"short",day:"numeric"},n),nextUpdate:null}],gp={test:()=>!0,formatter:(e,t,n)=>pp(e,{day:"numeric",month:"short",year:"numeric"},n),nextUpdate:null};function vp(e,t){for(const n of fp)if(n.test(e,t))return n;return gp}function bp(e){return!isNaN(e.valueOf())}function _p(e,t){
532
+ let n;const r=new Date(e),o=()=>{const e=function(e,t){if(!e||!bp(e)||!bp(t))return null;let n=vp(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5*cp),n=Math.min(n,2073600*cp),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function yp(e,t,n){return e?vp(e,t).formatter(e,t,n):""}function wp(e,t){return pp(e,{year:"numeric",month:"short",day:"2-digit",weekday:"long",hour:"2-digit",minute:"2-digit"},t)}function xp(e){return`${e.getFullYear()}-${`${e.getMonth()+1}`.padStart(2,"0")}-${`${e.getDate()}`.padStart(2,"0")} ${`${e.getHours()}`.padStart(2,"0")}:${`${e.getMinutes()}`.padStart(2,"0")}`}function kp({annotationCreated:e,annotationUpdated:t,annotationURL:n,withEditedTimestamp:r}){const[o,i]=ae((()=>new Date)),a=de((()=>new Date(e)),[e]),s=de((()=>r&&new Date(t)),[t,r]),l=de((()=>({absolute:wp(a),relative:yp(a,o)})),[a,o]),c=de((()=>s?{absolute:wp(s),relative:yp(s,o)}:{}),[s,o]);le((()=>_p(s?t:e,(()=>i(new Date)))),[e,t,a,s,o])
533
+ ;const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Oe("div",{children:[r&&Oe("span",{className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Oe(Lr,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):Oe("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function Np({authorLink:e,displayName:t}){const n=Oe("h3",{className:"text-color-text font-bold",children:t});return e?Oe(Lr,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Oe("div",{children:n})}var Sp=Kr((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){var i;const a=Ea(),s=a.defaultAuthority(),l=a.isFeatureEnabled("client_display_names"),c=a.getLink("user",{user:e.user}),u=de((()=>rs(e,s,l)),[e,s,l]),d=de((()=>function(e,t,n,r){var o
534
+ ;return!ns(e.user,n)&&r?r:null!==(o=t.usernameUrl&&`${t.usernameUrl}${ts(e.user)}`)&&void 0!==o?o:void 0}(e,o,s,c)),[e,o,s,c]),h=zo(e)&&r,m=(null===(i=e.links)||void 0===i?void 0:i.html)||"",p=de((()=>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:Mo(e),titleText:Io(e),titleLink:Co(e)}}(e),g=m&&f.titleLink?f.titleLink:"",v="sidebar"!==a.route()&&f.titleText;let b;"sidebar"!==a.route()&&(b=a.getGroup(e.group));const _=Wo(e);return Oe("header",{children:[Oe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse",children:[cs(e.permissions)&&!t&&Oe(dn,{className:"w-[10px] h-[10px]",title:"This annotation is visible only to you"}),Oe(Np,{authorLink:d,displayName:u}),n>0&&h&&Oe(Rr,{variant:"text-light",onClick:()=>a.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`
535
+ }),!t&&e.created&&Oe("div",{className:"flex justify-end grow",children:Oe(kp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:m,withEditedTimestamp:p})})]}),!zo(e)&&Oe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[b&&Oe(lp,{group:b}),!t&&Bo(e)&&Oe(Zt,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(v||_)&&Oe("span",{className:"flex",children:[v&&Oe(sp,{domain:f.domain,link:g,title:f.titleText}),_&&Oe("span",{className:"text-grey-6","data-testid":"page-number",children:[v&&", ","p. ",_]})]})]})]})}),["settings"]);var Ap=Kr((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Oe(ys,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Oe(Cm,{classes:X({"p-redacted-text":n}),children:Oe("blockquote",{className:X("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:Wr(["selectionFontFamily"],r),children:e})})})}),["settings"])
536
+ ;function Ep({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Oe(Kn,{classes:X("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}function Tp(){return Oe("div",{className:X("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Oe("span",{className:"text-[16px] animate-fade-in-slow",children:Oe(pr,{size:"sm"})}),Oe("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var Cp=Kr((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=Ea(),s=Go(e),l=a.getDraft(e),c=a.profile().userid,u=a.isAnnotationHovered(e.$tag),d=a.isSavingAnnotation(e),h=!!l&&!d,m=t&&o,p=!d&&!h&&Lo(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=de((()=>rs(e,f,g)),[e,f,g]);return Oe("article",{className:"space-y-4",
537
+ "aria-label":`${Lo(e)?Uo(e):`New ${Uo(e).toLowerCase()}`} by ${v}`,children:[Oe(Sp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Oe(Ap,{quote:s,isHovered:u,isOrphan:Ho(e)}),!m&&!h&&Oe(Om,{annotation:e}),h&&Oe(ap,{annotation:e,draft:l}),!m&&Oe("footer",{className:"flex items-center",children:[n&&Oe(Ep,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Oe(Tp,{}),p&&Oe(qe,{classes:"grow",children:Oe(vs,{annotation:e,onReply:()=>{Lo(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function Mp({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Oe("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Oe("div",{children:Oe("em",{children:"Message not available."})}),r&&Oe("footer",{className:"flex items-center",children:Oe(Ep,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var Ip=Kr((function({annotation:e,api:t,toastMessenger:n}){const r=Ea(),o=function(e){
538
+ return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Oe("div",{className:X("flex gap-x-3 bg-grey-1 text-color-text font-semibold","mb-2 ",{"-mt-3 -ml-3 -mr-3":!zo(e),"-mr-3":zo(e)}),children:[Oe("div",{className:X("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Oe(Xt,{className:"w-em h-em"}):Oe(Ht,{className:"w-em h-em"})}),Oe("div",{className:"self-center grow",children:[!e.hidden&&Oe("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Oe("span",{children:"Hidden from users"})]}),Oe("div",{className:"self-center pr-2",children:Oe(Kn,{classes:X("px-1.5 py-1","bg-slate-1 text-grey-7 bg-grey-2","enabled:hover:text-grey-9 enabled:hover:bg-grey-3 disabled:text-grey-5","aria-pressed:bg-grey-3 aria-expanded:bg-grey-3"),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
539
+ }).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",size:"custom",variant:"custom",children:e.hidden?"Unhide":"Hide"})})]}):null}),["api","toastMessenger"]);function zp({threadIsCollapsed:e,onToggleReplies:t}){const n=e?nt:vn,r=e?"Expand replies":"Collapse replies";return Oe("div",{className:X("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Oe("div",{className:X("bg-white"),children:Oe(Kn,{classes:X("-mt-1 touch:min-w-[auto] touch:min-h-[auto] p-[6.5px]","text-grey-5 hover:text-grey-7"),"data-testid":"toggle-button",expanded:!e,title:r,onClick:t,size:"custom",variant:"custom",children:Oe(n,{className:"w-em h-em"})})})})}var Lp=Kr((function e({thread:t,threadsService:n}){
540
+ const r=!!t.parent,o=t.children.filter((e=>Za(e)>0)),i=Ea(),a=i.hasAppliedFilter(),s=t.annotation&&i.isSavingAnnotation(t.annotation),l=t.annotation&&!!i.getDraft(t.annotation)&&!s,c=he((()=>i.setExpanded(t.id,!!t.collapsed)),[i,t.id,t.collapsed]),u=!r&&!l&&!a&&t.replyCount>0,d=de((()=>t.visible&&Oe(v,{children:t.annotation?Oe(v,{children:[Oe(Ip,{annotation:t.annotation}),Oe(Cp,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Oe(Mp,{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 Oe("section",{className:"flex","data-testid":"thread-container",children:[r&&Oe(zp,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Oe("div",{className:X("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,Ja(t)>0&&Oe("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Oe(Sp,{annotation:t.annotation,isEditing:l,
541
+ replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Oe("div",{children:Oe(Kn,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",Ja(t)," more in conversation"]})})]}),!t.collapsed&&Oe("ul",{className:X("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Oe("li",{className:X("mt-2","[text-align:start]"),children:Oe(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var Op=Kr((function({frameSync:e,thread:t}){var n,r;const o=Ea(),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=de((()=>Va((t=>e.hoverAnnotation(t)),10)),[e]),l=he((t=>{e.scrollToAnnotation(t)}),[e]),c=de((()=>Oe(Lp,{thread:t})),[t]),u=o.annotationFocusRequest(),d=ue(null);return le((()=>{u===t.id&&d.current&&(d.current.focus(),o.clearAnnotationFocusRequest())}),[u,o,t.id]),Oe($e,{active:a,classes:"cursor-pointer focus-visible-ring theme-clean:border-none","data-testid":"thread-card",elementRef:d,tabIndex:-1,
542
+ 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:Oe(Ve,{children:c})},t.id)}),["frameSync"]);const Rp=50;function Pp(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function Dp(e){return Math.max(e-e%Rp,0)}function Fp(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 Bp(e){var t;if(!e.annotation)return null;const n=Fp(e.annotation);return null!==(t=null==n?void 0:n.cfi)&&void 0!==t?t:null}function Hp({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new Wa,t=Pp();n(t.clientHeight),o(Dp(t.scrollTop));const r=Va((()=>{n(t.clientHeight),o(Dp(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[])
543
+ ;const[i,a]=ae((()=>new Map)),[s,l]=ae(null),c=e,{offscreenLowerHeight:u,offscreenUpperHeight:d,visibleThreads:h}=de((()=>function(e,t,n,r,o=Ya){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]),m=Ea(),p=(()=>{const e=m.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})(),f=de((()=>{let t=null,n=null;const r=function(e){const t=new Map;for(const n of e){if(!n.annotation)continue;const e=Fp(n.annotation);null!=e&&e.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const a of e){var i;const e=Bp(a);if(!e||t===e)continue;t=e;const s=null!==(i=r.get(e))&&void 0!==i?i:"Untitled chapter";n!==s&&(n=s,o.set(a,s))}return o}),[e]);return le((()=>{p&&(m.setForcedVisible(p,!0),l(p))}),[m,p]),le((()=>{if(!s)return;const e=c.findIndex((e=>e.id===s));if(-1===e)return;l(null)
544
+ ;const t=c.slice(0,e).reduce(((e,t)=>e+(e=>i.get(e.id)||Ya.defaultHeight)(t)),0);Pp().scrollTop=t}),[s,c,i]),le((()=>{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=Ka(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Oe("div",{children:[Oe("div",{style:{height:d}}),h.map((e=>Oe("div",{className:X("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[f.get(e)&&Oe("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:f.get(e)}),Oe(Op,{thread:e})]},e.id))),Oe("div",{style:{height:u}})]})}const jp={collapsed:!1,depth:0,visible:!0,replyCount:0};function $p(e){return e.id||e.$tag}function Up(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||Up(e,t,r.parent))}function qp(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...jp,children:[],id:r},qp(e,r,n.slice(0,-1))),Up(e,t,r)&&(e[t].parent=r,
545
+ e[r].children.push(e[t]))}function Gp(e,t){return Object.assign({},t(e),{children:e.children.map((e=>Gp(e,t)))})}function Vp(e,t,n){const r=e.children.map((e=>Vp(e,n,n))).slice().sort(t);return{...e,children:r}}function Wp(e,t){const n=e.children.map((e=>Wp(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function Yp(e){return e.children.some((e=>e.visible||Yp(e)))}const Kp=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Xp(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=$p(e);t[n]={...jp,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return qp(t,$p(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...jp,id:"root",children:n}}(e);return n?o.children=o.children.filter((e=>{
546
+ const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o})):t.threadFilterFn&&(o.children=o.children.filter(t.threadFilterFn)),o.visible=!1,o=Gp(o,(e=>{if(n)return{...e,visible:!0};let o=e.visible;return t.filterFn&&(o=!(!r||!t.forcedVisible.includes(e.id))||!!e.annotation&&!!t.filterFn(e.annotation)),{...e,visible:o}})),o.children=o.children.filter((e=>e.visible||Yp(e))),o=Gp(o,(e=>{const n={collapsed:e.collapsed};if(Eo(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&Yp(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=Vp(o,t.sortCompareFn,Kp),o=Wp(o,-1),o}function Jp(e){if(!e.includes("["))return e;let t="",n=!1,r=!1;for(const o of e)n||"^"!==o?(n||"["!==o?!n&&r&&"]"===o?r=!1:r||(t+=o):r=!0,n=!1):n=!0;return t}function Zp(e,t){const n=e=>Jp(e).split("/").map((e=>{const t=parseInt(e,10);return Number.isNaN(t)?e:t}));return function(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n]){
547
+ if(typeof e[n]!=typeof t[n])return"number"==typeof e[n]?-1:1;if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length-t.length}(n(e),n(t))}
547
548
  const Qp=/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u08FE\u0900-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D02\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1DC0-\u1DE6\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE26]/g
548
549
  ;function ef(e){return function(e){return e.replace(Qp,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class tf{constructor(e,t){B(this,"term",void 0),B(this,"matcher",void 0),this.term=t.normalize(e),this.matcher=t}matches(e){const t=this.matcher;return t.fieldValues(e).some((e=>t.matches(t.normalize(e),this.term)))}}class nf{constructor(e,t){B(this,"operator",void 0),B(this,"filters",void 0),this.operator=e,this.filters=t}matches(e){return"and"===this.operator?this.filters.every((t=>t.matches(e))):this.filters.some((t=>t.matches(e)))}}function rf(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:ef}}const of={quote:rf((e=>{var t;return[null!==(t=Go(e))&&void 0!==t?t:""]})),cfi:{fieldValues:e=>{var t,n;return[null!==(t=null===(n=Vo(e))||void 0===n?void 0:n.trim())&&void 0!==t?t:""]},matches:(e,t)=>{if(t.includes("-")){const[n,r]=t.split("-");return function(e,t,n){return Zp(e,t)>=0&&Zp(e,n)<0}(e,n,r)}return!1},normalize:e=>Jp(e.trim())},page:{fieldValues:e=>{var t,n
549
550
  ;return[null!==(t=null===(n=Wo(e))||void 0===n?void 0:n.trim())&&void 0!==t?t:""]},matches:(e,t)=>function(e,t){if(!t.includes("-"))return e===t;let[n,r]=t.split("-");n||(n=e),r||(r=e);const[o,i,a]=[parseInt(n),parseInt(r),parseInt(e)];return!!(Number.isInteger(o)&&Number.isInteger(i)&&Number.isInteger(a))&&a>=o&&a<=i}(e,t),normalize:e=>e.trim()},since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:rf((e=>e.tags)),text:rf((e=>[e.text])),uri:rf((e=>[e.uri])),user:rf((e=>{var t,n;return[e.user,null!==(t=null===(n=e.user_info)||void 0===n?void 0:n.display_name)&&void 0!==t?t:""]}))};const af=["cfi","quote","page","since","tag","text","uri","user"],sf=["group","quote","tag","text","uri","user"];function lf(e,t){const n=e.slice(0,e.indexOf(":"));if(!n)return[null,e];if(t.includes(n)){return[n,e.slice(n.length+1)]}return[null,e]}function cf(e){const t=e.slice(0,1),n=e.slice(-1);return'"'!==t&&"'"!==t||t!==n||(e=e.slice(1,e.length-1)),e}function uf(e,t){
@@ -551,7 +552,7 @@ const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(cf).filter((e=>
551
552
  const a=null!==(n=o.position)&&void 0!==n?n:Number.MAX_SAFE_INTEGER,s=null!==(r=i.position)&&void 0!==r?r:Number.MAX_SAFE_INTEGER;return Math.sign(a-s)}};const gf=function(e){if(1!==e.length)throw new Error("Memoize input must be a function of one argument");let t,n;return function(r){return r===t||(t=r,n=e(r)),n}}((function(e){const t=e.selection,n={expanded:t.expanded,forcedVisible:t.forcedVisible,selected:t.selected,sortCompareFn:ff[t.sortKey]};if(!!t.filterQuery||Object.keys(t.filters).length>0){const e=function(e,t={}){const n=e=>{const n=t[e];return"string"==typeof n?[n]:[]},r=n("cfi"),o=n("page"),i=n("quote"),a=n("tag"),s=n("text"),l=n("uri"),c=n("user"),u=[],d=[],h=uf(e,af);for(const e of h){const t=e.slice(0,e.indexOf(":")),n=e.slice(t.length+1);switch(t){case"cfi":r.push(n);break;case"quote":i.push(n);break;case"page":o.push(n);break;case"since":{const t=86400,n={sec:1,min:60,hour:3600,day:t,week:7*t,month:30*t,year:365*t
552
553
  },r=e.slice(6).toLowerCase().match(/^(\d+)(sec|min|hour|day|week|month|year)?$/);if(r){const e=parseFloat(r[1]),t=r[2]||"sec";d.push(e*n[t])}}break;case"tag":a.push(n);break;case"text":s.push(n);break;case"uri":l.push(n);break;case"user":c.push(n);break;default:u.push(e)}}return{any:{terms:u,operator:"and"},cfi:{terms:r,operator:"or"},quote:{terms:i,operator:"and"},page:{terms:o,operator:"or"},since:{terms:d,operator:"and"},tag:{terms:a,operator:"and"},text:{terms:s,operator:"and"},uri:{terms:l,operator:"or"},user:{terms:c,operator:"or"}}}(t.filterQuery||"",t.filters);n.filterFn=t=>function(e,t){const n=(e,t)=>new tf(t,of[e]),r=Object.entries(t).filter((([,e])=>e.terms.length>0)).map((([e,t])=>{let r;if("any"===e){const e=["quote","text","tag","user"];r=t.terms.map((t=>new nf("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new nf(t.operator,r)})),o=new nf("and",r);return e.filter((e=>e.id&&o.matches(e))).map((e=>e.id))}([t],e).length>0}const r=Xp(e.annotations,n),o={annotation:0,note:0,
553
554
  orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(!e.annotation)return!1;if(Do(e.annotation))return!1;const n=hf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function vf(){const e=Ea(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=de((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[t,n,o,i,a]);return gf(s)}var bf=Kr((function({loadAnnotationsService:e,onLogin:t}){var n;const r=Ea(),o=null!==(n=r.routeParams().id)&&void 0!==n?n:"",{rootThread:i}=vf(),a=r.profile().userid,[s,l]=ae(!1);return le((()=>{l(!1),r.clearAnnotations(),e.loadThread(o).then((e=>{const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&r.setExpanded(e.id,!0))),t.id!==o&&r.highlightAnnotations([o]))})).catch((()=>{l(!0)}))}),[o,a,e,r]),Oe(v,{children:[s&&Oe(Ta,{errorType:"annotation",onLoginRequest:t}),Oe(Hp,{threads:i.children})]})
554
- }),["loadAnnotationsService"]);class _f{constructor(e,t,n=window){var r,o,i;B(this,"version",void 0),B(this,"userAgent",void 0),B(this,"urls",void 0),B(this,"fingerprint",void 0),B(this,"account",void 0),B(this,"timestamp",void 0),B(this,"segment",void 0);const a="N/A";let s=a;e.userid&&(s=e.userid,e.displayName&&(s=`${e.displayName} (${s})`)),this.version="1.1447.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(o=o.metadata)||void 0===o?void 0:o.documentFingerprint)&&void 0!==r?r:a,this.account=s,this.timestamp=(new Date).toString();const l=null===(i=t[0])||void 0===i?void 0:i.segment;if(l){const e=[];l.cfi&&e.push(["CFI",l.cfi]),l.url&&e.push(["URL",l.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}
555
+ }),["loadAnnotationsService"]);class _f{constructor(e,t,n=window){var r,o,i;B(this,"version",void 0),B(this,"userAgent",void 0),B(this,"urls",void 0),B(this,"fingerprint",void 0),B(this,"account",void 0),B(this,"timestamp",void 0),B(this,"segment",void 0);const a="N/A";let s=a;e.userid&&(s=e.userid,e.displayName&&(s=`${e.displayName} (${s})`)),this.version="1.1448.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||a,this.fingerprint=null!==(r=null===(o=t[0])||void 0===o||null===(o=o.metadata)||void 0===o?void 0:o.documentFingerprint)&&void 0!==r?r:a,this.account=s,this.timestamp=(new Date).toString();const l=null===(i=t[0])||void 0===i?void 0:i.segment;if(l){const e=[];l.cfi&&e.push(["CFI",l.cfi]),l.url&&e.push(["URL",l.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}
555
556
  asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}var yf="complete",wf="canceled";function xf(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function kf(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,r=function(e,t){var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,h=c&&null!=c.top?c.top:.5,m=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,f=d,g=h;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=m,o-=p,r=e.align.lockX?t.pageXOffset:r,o=e.align.lockY?t.pageYOffset:o,i=r-t.pageXOffset,a=o-t.pageYOffset;else{s=u.width,l=u.height,n=t.getBoundingClientRect();var v=u.left-(n.left-t.scrollLeft),b=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=b+l*g-t.clientHeight*g,r-=m,o-=p,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),
556
557
  o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(t,e),o=Date.now()-t.startTime,i=Math.min(1/t.time*o,1);if(t.endIterations>=n)return xf(e,r.x,r.y),e._scrollSettings=null,t.end(yf);var a=1-t.ease(i);if(xf(e,r.x-r.differenceX*a,r.y-r.differenceY*a),o>=t.time)return t.endIterations++,t.scrollAncestor&&kf(t.scrollAncestor),void kf(e);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(kf.bind(null,e))}}function Nf(e){return e.self===e}function Sf(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function Af(){return!0}function Ef(e){if(e.assignedSlot)return Ef(e.assignedSlot)
557
558
  ;if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}var Tf=function(e,t,n){if(e){"function"==typeof t&&(n=t,t=null),t||(t={}),t.time=isNaN(t.time)?1e3:t.time,t.ease=t.ease||function(e){return 1-Math.pow(1-e,e/2)},t.align=t.align||{};var r=Ef(e),o=1,i=t.validTarget||Af,a=t.isScrollable;t.debug&&(console.log("About to scroll to",e),r||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var s=[];r;)if(t.debug&&console.log("Scrolling parent node",r),i(r,o)&&(a?a(r,Sf):Sf(r))&&(o++,s.push(r)),!(r=Ef(r))){l(yf);break}return s.reduce(((n,r,o)=>function(e,t,n,r,o){var i,a=!t._scrollSettings,s=t._scrollSettings,l=Date.now(),c={passive:!0};function u(e){t._scrollSettings=null,t.parentElement&&t.parentElement._scrollSettings&&t.parentElement._scrollSettings.end(e),
@@ -638,7 +639,7 @@ const n=Wo(e),r=Go(e),o=[`Created at: ${xp(new Date(e.created))}`,`Author: ${c(e
638
639
  }(Oe("html",{lang:"en",children:[Oe("head",{children:[Oe("title",{children:`Annotations on "${a}"`}),Oe("meta",{charSet:"UTF-8"})]}),Oe("body",{children:[Oe("section",{children:[Oe("h1",{children:"Summary"}),Oe("p",{children:Oe("time",{dateTime:o.toISOString(),children:xp(o)})}),Oe("p",{children:Oe("strong",{children:a})}),Oe("p",{children:Oe("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Oe("table",{children:Oe("tbody",{style:{verticalAlign:"top"},children:[Oe("tr",{children:[Oe("td",{children:"Group:"}),Oe("td",{children:t})]}),Oe("tr",{children:[Oe("td",{children:"Total users:"}),Oe("td",{children:s.length})]}),Oe("tr",{children:[Oe("td",{children:"Users:"}),Oe("td",{children:s.join(", ")})]}),Oe("tr",{children:[Oe("td",{children:"Total annotations:"}),Oe("td",{children:e.length})]}),Oe("tr",{children:[Oe("td",{children:"Total replies:"}),Oe("td",{children:l.length})]})]})})]}),Oe("hr",{}),Oe("section",{children:[Oe("h1",{children:"Annotations"}),e.map(((e,t)=>{
639
640
  const n=Wo(e),r=Go(e),o=Tm(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return Oe("article",{children:[Oe("h2",{children:["Annotation ",t+1,":"]}),Oe("table",{children:Oe("tbody",{style:{verticalAlign:"top"},children:[Oe("tr",{children:[Oe("td",{children:"Created at:"}),Oe("td",{children:Oe("time",{dateTime:e.created,children:xp(new Date(e.created))})})]}),Oe("tr",{children:[Oe("td",{children:"Author:"}),Oe("td",{children:c(e)})]}),n&&Oe("tr",{children:[Oe("td",{children:"Page:"}),Oe("td",{children:n})]}),Oe("tr",{children:[Oe("td",{children:"Type:"}),Oe("td",{children:Uo(e)})]}),r&&Oe("tr",{children:[Oe("td",{children:"Quote:"}),Oe("td",{children:Oe("blockquote",{style:{margin:0},children:r})})]}),Oe("tr",{children:[Oe("td",{children:"Comment:"}),Oe("td",{dangerouslySetInnerHTML:{__html:i}})]}),e.tags.length>0&&Oe("tr",{children:[Oe("td",{children:"Tags:"}),Oe("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}
640
641
  _exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>rs(e,n,t),{uri:i,title:a}=To(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>zo(e))),extractUsername:o}}}cb.$inject=[];class ub extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),B(this,"url",void 0),B(this,"response",void 0),B(this,"reason",void 0),this.url=e,this.response=t,this.reason=n}}async function db(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new ub(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch(t){throw new ub(e,n,"Failed to parse response")}var o;if(!n.ok)throw new ub(e,n,null===(o=r)||void 0===o?void 0:o.reason);return r}class hb{constructor(e,t,n){B(this,"_clientId",void 0),B(this,"search",void 0),B(this,"annotation",void 0),B(this,"group",void 0),B(this,"groups",void 0),B(this,"profile",void 0),
641
- this._clientId=null;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,i]=await Promise.all([e,n()]),l=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!l)throw new Error(`Missing API route: ${t}`);const c={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1447.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Qi(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await db(m.toString(),{body:s?JSON.stringify(ib(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished})
642
+ this._clientId=null;const r=e.routes(),o=()=>this._clientId,i=e=>function(e,t,{getAccessToken:n,getClientId:r,onRequestStarted:o,onRequestFinished:i}){return async(a,s)=>{o();try{const[o,i]=await Promise.all([e,n()]),l=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!l)throw new Error(`Missing API route: ${t}`);const c={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1448.0"};i&&(c.Authorization="Bearer "+i);const u=r();u&&(c["X-Client-Id"]=u);const{url:d,unusedParams:h}=Qi(l.url,a),m=new URL(d);for(const[e,t]of Object.entries(h)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await db(m.toString(),{body:s?JSON.stringify(ib(s)):null,headers:c,method:l.method})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished})
642
643
  ;this.search=i("search"),this.annotation={create:i("annotation.create"),delete:i("annotation.delete"),get:i("annotation.read"),update:i("annotation.update"),flag:i("annotation.flag"),hide:i("annotation.hide"),unhide:i("annotation.unhide")},this.group={member:{delete:i("group.member.delete")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},read:i("profile.read"),update:i("profile.update")}}setClientId(e){this._clientId=e}}hb.$inject=["apiRoutes","auth","store"];var mb={};function pb(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var fb=pb;pb.prototype.reset=function(){this._attempts=1,
643
644
  this._timeouts=this._originalTimeouts.slice(0)},pb.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},pb.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n),this._options.unref&&this._timer.unref(),!0},pb.prototype.attempt=function(e,t){this._fn=e,
644
645
  t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},pb.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},pb.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},pb.prototype.start=pb.prototype.try,pb.prototype.errors=function(){return this._errors},pb.prototype.attempts=function(){return this._attempts},pb.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,a=(e[i]||0)+1;e[i]=a,a>=n&&(t=o,n=a)}return t},function(e){var t=fb;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},
@@ -753,8 +754,8 @@ case"update":case"past":this._store.receiveRealTimeUpdates({updatedAnnotations:e
753
754
  const e=new URL(t);e.searchParams.set("access_token",n),r=e.toString()}else r=t;const o=new Ek(r);o.on("open",(()=>{this._reconnectionAttempts=0,this._sendClientConfig(o)})),o.on("disconnect",(()=>{if(++this._reconnectionAttempts,this._reconnectionAttempts<10){const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),o.on("error",(e=>this._handleSocketError(t,e))),o.on("message",(e=>this._handleSocketMessage(e))),this._socket=o,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){var t;this._updateImmediately=null===(t=e.applyUpdatesImmediately)||void 0===t||t,this._reconnectSetUp||(this._reconnectSetUp=!0,Ob(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}Tk.$inject=["store","apiRoutes","auth","groups","session"]
754
755
  ;const Ck="hypothesis.user.tags.list",Mk="hypothesis.user.tags.map";class Ik{constructor(e){B(this,"_storage",void 0),this._storage=e}filter(e,t=null){const n=this._storage.getObject(Ck)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${nv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(Mk)||{};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(Mk,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(Ck,n)}}Ik.$inject=["localStorage"];class zk{constructor(e){B(this,"_store",void 0),this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}zk.$inject=["store"];class Lk extends jf{constructor(e,t){super(),B(this,"_store",void 0),B(this,"_window",void 0),
755
756
  B(this,"_delayedMessageQueue",void 0),this._store=e,this._window=t,this._delayedMessageQueue=[],this._window.addEventListener("focus",(()=>{this._delayedMessageQueue.forEach((({type:e,messageText:t,options:n})=>this._addMessage(e,t,n))),this._delayedMessageQueue=[]}))}dismiss(e){this._store.getToastMessage(e)&&(this._store.removeToastMessage(e),this.emit("toastMessageDismissed",e))}_addMessage(e,t,{autoDismiss:n=!0,visuallyHidden:r=!1,delayed:o=!1}={}){if(this._store.hasToastMessage(e,t))return;if(o&&!this._window.document.hasFocus()){const o={autoDismiss:n,visuallyHidden:r};return void this._delayedMessageQueue.push({type:e,messageText:t,options:o})}const i={type:e,id:Wg(10),message:t,visuallyHidden:r,autoDismiss:n};this._store.addToastMessage(i),this.emit("toastMessageAdded",i)}error(e,t){this._addMessage("error",e,t)}success(e,t){this._addMessage("success",e,t)}notice(e,t){this._addMessage("notice",e,t)}}Lk.$inject=["store","$window"];const Ok=function(e){
756
- 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),Rk=function(e){const{version:t,origin:n}=Kg(e.location.href);return"1.1447.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1447.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function Pk(e,t){e.setClientId(t.clientId)}function Dk(e,t,n){e.load(),t.load(),n.sync()}function Fk(e,t,n){e.init(),t.init(),n.init()}function Bk(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{
757
- autoDismiss:!1})}))}Ok.sentry&&Rk&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;mk({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1447.0",beforeSend:(e,t)=>{if(pk>=5)return tv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++pk;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{pw("host_config",Kg(window.location.href))}catch(e){}pw("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Eb(((e,t)=>{fk(e,t)}))}(Ok.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")}))}(document.body),Pk.$inject=["api","streamer"],
757
+ 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),Rk=function(e){const{version:t,origin:n}=Kg(e.location.href);return"1.1448.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1448.0) than the host page (${t}). It may not work.`),!1):"null"===e.origin?(console.warn("Hypothesis has been loaded in a sandboxed frame. This is not supported."),!1):e.origin===n||(console.warn(`The Hypothesis sidebar is running in a different origin (${e.origin}) than expected (${n}). It may not work.`),!1)}(window);function Pk(e,t){e.setClientId(t.clientId)}function Dk(e,t,n){e.load(),t.load(),n.sync()}function Fk(e,t,n){e.init(),t.init(),n.init()}function Bk(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{
758
+ autoDismiss:!1})}))}Ok.sentry&&Rk&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;mk({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1448.0",beforeSend:(e,t)=>{if(pk>=5)return tv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++pk;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{pw("host_config",Kg(window.location.href))}catch(e){}pw("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Eb(((e,t)=>{fk(e,t)}))}(Ok.sentry),function(e){e.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")}))}(document.body),Pk.$inject=["api","streamer"],
758
759
  Dk.$inject=["groups","session","router"],Fk.$inject=["autosaveService","persistedDefaults","serviceURL"],Bk.$inject=["frameSync","store","toastMessenger"];const Hk=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",sv)}(),async function(e,t=window){const n=function(e){const t=Kg(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Xg,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Zg(t.origin),ancestorLevel:Jg(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null
759
760
  ;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{targetFrame:Qg(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Yg(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=Yg(t.targetFrame,t.origin,"requestGroups",[n],0).catch((()=>{throw new Error("Unable to fetch groups")})))})),e):e}(e,r)}else o=n;const i={...e,...o};return r&&(i.rpc=r),i.apiUrl=function(e){const t=qr(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(Ok).then((e=>{!function(e,t){const n=new U
760
761
  ;n.register("annotationsExporter",cb).register("annotationsService",cv).register("annotationActivity",lv).register("api",hb).register("apiRoutes",_b).register("auth",xb).register("autosaveService",kb).register("frameSync",Db).register("groups",Hb).register("importAnnotationsService",vk).register("loadAnnotationsService",bk).register("localStorage",yk).register("persistedDefaults",xk).register("router",kk).register("serviceURL",Nk).register("session",Sk).register("streamer",Tk).register("streamFilter",Ak).register("tags",Ik).register("threadsService",zk).register("toastMessenger",Lk).register("store",{factory:Aa}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(Fk),n.run(Pk),n.run(Dk),n.run(av),n.run(Bk),P(Oe(Yr.Provider,{value:n,children:Oe(qg,{})}),t)}(e,Hk)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),P(Oe(Gg,{error:e}),t)}(e,Hk)));