hypothesis 1.1740.0 → 1.1741.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-template.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?b1e53f","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?bf10cf","styles/annotator.css":"styles/annotator.css?728e30","styles/annotator.css.map":"styles/annotator.css.map?11ce1b","styles/highlights.css":"styles/highlights.css?ef86d1","styles/highlights.css.map":"styles/highlights.css.map?6ce8dd","styles/katex.min.css":"styles/katex.min.css?027dee","styles/katex.min.css.map":"styles/katex.min.css.map?f4f041","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?d58df4","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?5a12c5","styles/sidebar.css":"styles/sidebar.css?556d6b","styles/sidebar.css.map":"styles/sidebar.css.map?f7c41c","styles/ui-playground.css":"styles/ui-playground.css?f10b88","styles/ui-playground.css.map":"styles/ui-playground.css.map?e5bb19","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?8fff8b","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?5f80ee","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?659eb2","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?33cd45"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.esModule,n=void 0===o||o,i=r.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function o(s,t,r,o){var n=s.createElement("link");n.rel=t,n.href=o,n.type="application/annotator+".concat(r),e(n),s.head.appendChild(n)}function n(s,t,r){var o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).crossOrigin,n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,(o||"fetch"===t)&&(n.crossOrigin="anonymous",n.removeAttribute=()=>{}),e(n),s.head.appendChild(n)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),r=0;r<t.length;r++){var o=void 0;try{o=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),o={}}Object.assign(e,o)}return e}(document),c=a(l.assetRoot||"__ASSET_ROOT__");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var o=0,a=["scripts/sidebar.bundle.js"];o<a.length;o++)r(s,i(e,a[o]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,i(e,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||"__NOTEBOOK_APP_URL__"),h=a(d.profileAppUrl||"__PROFILE_APP_URL__"),y=a(d.sidebarAppUrl||"__SIDEBAR_APP_URL__");!function(s,e){if(!s.querySelector('link[type="application/annotator+html"]')){o(s,"sidebar","html",e.sidebarAppUrl),o(s,"notebook","html",e.notebookAppUrl),o(s,"profile","html",e.profileAppUrl),n(s,"style",i(e,"styles/annotator.css"),{crossOrigin:!0}),o(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)r(s,i(e,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++)t(s,i(e,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/.")}();
|
package/build/boot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?
|
|
1
|
+
!function(){"use strict";var s={"scripts/annotator.bundle.js":"scripts/annotator.bundle.js?b1e53f","scripts/ui-playground.bundle.js":"scripts/ui-playground.bundle.js?bf10cf","styles/annotator.css":"styles/annotator.css?728e30","styles/annotator.css.map":"styles/annotator.css.map?11ce1b","styles/highlights.css":"styles/highlights.css?ef86d1","styles/highlights.css.map":"styles/highlights.css.map?6ce8dd","styles/katex.min.css":"styles/katex.min.css?027dee","styles/katex.min.css.map":"styles/katex.min.css.map?f4f041","styles/pdfjs-overrides.css":"styles/pdfjs-overrides.css?d58df4","styles/pdfjs-overrides.css.map":"styles/pdfjs-overrides.css.map?5a12c5","styles/sidebar.css":"styles/sidebar.css?556d6b","styles/sidebar.css.map":"styles/sidebar.css.map?f7c41c","styles/ui-playground.css":"styles/ui-playground.css?f10b88","styles/ui-playground.css.map":"styles/ui-playground.css.map?e5bb19","scripts/annotator.bundle.js.map":"scripts/annotator.bundle.js.map?8fff8b","scripts/sidebar.bundle.js":"scripts/sidebar.bundle.js?5f80ee","scripts/ui-playground.bundle.js.map":"scripts/ui-playground.bundle.js.map?659eb2","scripts/sidebar.bundle.js.map":"scripts/sidebar.bundle.js.map?33cd45"};function e(s){s.setAttribute("data-hypothesis-asset","")}function t(s,t){var r=s.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t,e(r),s.head.appendChild(r)}function r(s,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.esModule,n=void 0===o||o,i=r.forceReload,a=void 0!==i&&i,l=s.createElement("script");n&&(l.type="module"),a&&(t+="#ts=".concat(Date.now())),l.src=t,l.async=!1,e(l),s.head.appendChild(l)}function o(s,t,r,o){var n=s.createElement("link");n.rel=t,n.href=o,n.type="application/annotator+".concat(r),e(n),s.head.appendChild(n)}function n(s,t,r){var o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).crossOrigin,n=s.createElement("link");n.rel="preload",n.as=t,n.href=r,(o||"fetch"===t)&&(n.crossOrigin="anonymous",n.removeAttribute=()=>{}),e(n),s.head.appendChild(n)}function i(s,e){return s.assetRoot+"build/"+s.manifest[e]}function a(s){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(-1===s.indexOf("{"))return s;var t=function(){var s,e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:document).currentScript;return t?(s=t.src,(e=s.match(/(https?):\/\/([^:/]+)/))?{protocol:e[1],hostname:e[2]}:null):null}(e);if(!t)throw new Error("Could not process URL template because script origin is unknown");return s=(s=s.replace("{current_host}",t.hostname)).replace("{current_scheme}",t.protocol)}if(function(){var s=[()=>Object.fromEntries([]),()=>new URL(document.location.href),()=>new Request("https://hypothes.is"),()=>Element.prototype.attachShadow,()=>CSS.supports("display: grid"),()=>(document.evaluate("/html/body",document,null,XPathResult.ANY_TYPE,null),!0)];try{return s.every((s=>s()))}catch(s){return!1}}()){var l=function(s){for(var e={},t=s.querySelectorAll("script.js-hypothesis-config"),r=0;r<t.length;r++){var o=void 0;try{o=JSON.parse(t[r].textContent||"")}catch(s){console.warn("Could not parse settings from js-hypothesis-config tags",s),o={}}Object.assign(e,o)}return e}(document),c=a(l.assetRoot||"https://cdn.hypothes.is/hypothesis/1.1741.0/");if(document.querySelector("hypothesis-app")){!function(s,e){n(s,"fetch",e.apiUrl),n(s,"fetch",e.apiUrl+"links");for(var o=0,a=["scripts/sidebar.bundle.js"];o<a.length;o++)r(s,i(e,a[o]),{esModule:!0});for(var l=0,c=["styles/katex.min.css","styles/sidebar.css"];l<c.length;l++)t(s,i(e,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,e){if(!s.querySelector('link[type="application/annotator+html"]')){o(s,"sidebar","html",e.sidebarAppUrl),o(s,"notebook","html",e.notebookAppUrl),o(s,"profile","html",e.profileAppUrl),n(s,"style",i(e,"styles/annotator.css"),{crossOrigin:!0}),o(s,"hypothesis-client","javascript",e.assetRoot+"build/boot.js");for(var a=0,l=["scripts/annotator.bundle.js"];a<l.length;a++)r(s,i(e,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++)t(s,i(e,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/.")}();
|
package/build/manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?
|
|
2
|
+
"scripts/annotator.bundle.js": "scripts/annotator.bundle.js?b1e53f",
|
|
3
3
|
"scripts/ui-playground.bundle.js": "scripts/ui-playground.bundle.js?bf10cf",
|
|
4
4
|
"styles/annotator.css": "styles/annotator.css?728e30",
|
|
5
5
|
"styles/annotator.css.map": "styles/annotator.css.map?11ce1b",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"styles/ui-playground.css": "styles/ui-playground.css?f10b88",
|
|
15
15
|
"styles/ui-playground.css.map": "styles/ui-playground.css.map?e5bb19",
|
|
16
16
|
"scripts/annotator.bundle.js.map": "scripts/annotator.bundle.js.map?8fff8b",
|
|
17
|
-
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?
|
|
17
|
+
"scripts/sidebar.bundle.js": "scripts/sidebar.bundle.js?5f80ee",
|
|
18
18
|
"scripts/ui-playground.bundle.js.map": "scripts/ui-playground.bundle.js.map?659eb2",
|
|
19
|
-
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?
|
|
19
|
+
"scripts/sidebar.bundle.js.map": "scripts/sidebar.bundle.js.map?33cd45"
|
|
20
20
|
}
|
|
@@ -150,7 +150,7 @@ this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),th
|
|
|
150
150
|
if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type||"ShapeSelector"===t.type)))return{annotation:t,target:e};let n;try{const o=await this._integration.anchor(this.element,e.selector);if(o instanceof Range){const i=On.fromRange(o);n={annotation:t,target:e,region:i}}else n={annotation:t,target:e,region:o}}catch{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.region)),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&&this._highlighter.removeHighlights(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,this._clusterToolbar?.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation(t){if("selection"===t)return this.createAnnotationFromSelection()
|
|
151
151
|
;if(!["rect","point"].includes(t))throw new Error("Unsupported annotation tool");{let e=!1;try{this._hostRPC.call("activeToolChanged",t);const e=await this._drawTool.draw(t),n=await this.getDocumentInfo(),o=[{source:n.uri,selector:await this._integration.describe(this.element,e)}],i={uri:n.uri,document:n.metadata,target:o,$tag:"a:"+Ce(8)};return this._sidebarRPC.call("createAnnotation",i),this.anchor(i),i}catch(t){if(t instanceof oo&&["canceled","restarted"].includes(t.kind))return e="restarted"===t.kind,null;throw t}finally{e||this._hostRPC.call("activeToolChanged",null)}}}async createAnnotationFromSelection({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(e.map((t=>this._integration.describe(o,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+Ce(8)};return this._sidebarRPC.call("createAnnotation",r),
|
|
152
152
|
this.anchor(r),ir(),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);this._highlighter.setHighlightsFocused(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(),o=Hn(n),i=Un(n);i?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._commentsMode||(this._adder.annotationsForSelection=er(),this._isAdderVisible=!0,this._adder.show(i,o))):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),
|
|
153
|
-
this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){this._highlighter.setHighlightsVisible(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){dn(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible&&!this._commentsMode)}_setOutsideAssignmentNoticeVisible(t){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Ji(this.element)),this._outsideAssignmentNotice.setVisible(t)}}function ar(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function lr(t,e){const n={};for(const[t,o]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=o&&(n[t]=o);n.origin=new URL(t).origin,n.version="1.
|
|
153
|
+
this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){this._highlighter.setHighlightsVisible(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){dn(t,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible&&!this._commentsMode)}_setOutsideAssignmentNoticeVisible(t){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Ji(this.element)),this._outsideAssignmentNotice.setVisible(t)}}function ar(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function lr(t,e){const n={};for(const[t,o]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=o&&(n[t]=o);n.origin=new URL(t).origin,n.version="1.1741.0";const o=new URL(window.location.href);if(o.hash="",
|
|
154
154
|
n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const t=n.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 n}function cr({closed:t,onClose:e,children:n,"data-testid":o,"aria-label":i}){const r=it(null);return nt((()=>{t?r.current?.close():r.current?.showModal()}),[t]),nt((()=>{const t=r.current;return t?.addEventListener("cancel",e),()=>{t?.removeEventListener("cancel",e)}}),[e]),St("dialog",{ref:r,className:"relative m-5 w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function hr({closed:t,children:e,...n}){return St("div",{...n,className:Tt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:t}),children:St("div",{className:"relative w-full h-full",children:e})})}function dr({document_:t=document,...e}){
|
|
155
155
|
return St(rt((()=>function(t){return"function"==typeof t.createElement("dialog").showModal}(t)?cr:hr),[t]),{...e})}function ur({config:t,groupId:e}){return St("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:ar(t.notebookAppUrl,{...lr(t.notebookAppUrl,t),group:e})})}function fr({eventBus:t,config:e}){const[n,o]=et(0),[i,r]=et(!0),[s,a]=et(null),l=it(""),c=it(null);nt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),nt((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),nt((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);const h=st((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:St(dr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[St("div",{className:"absolute right-0 m-3",children:St(oe,{title:"Close notebook",onClick:h,
|
|
156
156
|
variant:"dark",classes:Tt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:St(Lt,{className:"w-4 h-4"})})}),St(ur,{config:e,groupId:s},n)]})}class pr{constructor(t,e,n){this._container=new vn("notebook",(()=>St(fr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function gr({eventBus:t,config:e}){const[n,o]=et(!0),i=it(null);nt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{o(!1)})),i.current=e,()=>{e.destroy()}}),[t]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:St(dr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[St("div",{className:"absolute right-0 m-3",children:St(oe,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Tt("!bg-transparent enabled:hover:!bg-grey-3"),children:St(Lt,{className:"w-4 h-4"})})}),St("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",
|
|
@@ -581,7 +581,7 @@ className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(t)}),Ve(zm,{t
|
|
|
581
581
|
return e.annotation||t.annotation?e.annotation?1:-1:0}(e,t);const n=Gr(e.annotation),r=Gr(t.annotation);if(n.cfi||r.cfi){const e="/0",t=Qm(n.cfi??e,r.cfi??e);if(0!==t)return Math.sign(t)}const o=_f(n.pageIndex,r.pageIndex);if(0!==o)return o;const i=_f(n.top,r.top);if(0!==i)return i;const a=_f(n.charOffset,r.charOffset);if(0!==a)return a;return wf(e.annotation.created,t.annotation.created)}(e,t);default:return 0}}const kf=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:(e,n)=>xf(e,n,{sortBy: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=ff(e,df);for(const e of h){
|
|
582
582
|
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},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",filterReplies:!0},cfi:{terms:r,operator:"or",filterReplies:!1},quote:{terms:i,operator:"and",filterReplies:!1},page:{terms:o,operator:"or",filterReplies:!1},since:{terms:d,operator:"and",filterReplies:!0},tag:{terms:a,operator:"and",filterReplies:!0},text:{terms:s,operator:"and",filterReplies:!0},uri:{terms:l,operator:"or",filterReplies:!1},user:{terms:c,operator:"or",filterReplies:!0}}}(t.filterQuery||"",t.filters),r={},o={}
|
|
583
583
|
;for(const[t,n]of Object.entries(e))n.filterReplies?r[t]=n:o[t]=n;n.filterFn=e=>uf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&uf([e.annotation],o).length>0)}const r=Ym(e.annotations,n),o={annotation:0,note:0,orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(e.annotation&&Hr(e.annotation))return!1;const n=e.annotation?vf(e.annotation):"orphan";return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function Sf(){const e=Hi(),t=e.allAnnotations(),n=e.filterQuery(),r=e.route(),o=e.selectionState(),i=e.getFilterValues(),a="sidebar"===r,s=ue((()=>{const e={...o,filterQuery:n,filters:i};return{annotations:t,selection:e,showTabs:a}}),[o,n,i,t,a]);return kf(s)}var Af,Tf,Ef=Jn((function({loadAnnotationsService:e,onLogin:t}){const n=Hi(),r=n.routeParams().id??"",{rootThread:o}=Sf(),i=n.profile().userid,[a,s]=ie(!1);return se((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{
|
|
584
|
-
const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Ve(y,{children:[a&&Ve(Bi,{errorType:"annotation",onLoginRequest:t}),Ve(Hm,{threads:o.children})]})}),["loadAnnotationsService"]);class Cf{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.
|
|
584
|
+
const t=e.filter((e=>0===(e.references||[]).length))[0];t&&(e.forEach((e=>e.id&&n.setExpanded(e.id,!0))),t.id!==r&&n.highlightAnnotations([r]))})).catch((()=>{s(!0)}))}),[r,i,e,n]),Ve(y,{children:[a&&Ve(Bi,{errorType:"annotation",onLoginRequest:t}),Ve(Hm,{threads:o.children})]})}),["loadAnnotationsService"]);class Cf{constructor(e,t,n=window){const r="N/A";let o=r;e.userid&&(o=e.userid,e.displayName&&(o=`${e.displayName} (${o})`)),this.version="1.1741.0",this.userAgent=n.navigator.userAgent,this.urls=t.map((e=>e.uri)).join(", ")||r,this.fingerprint=t[0]?.metadata?.documentFingerprint??r,this.account=o,this.timestamp=(new Date).toString();const i=t[0]?.segment;if(i){const e=[];if(i.cfi&&e.push(["CFI",i.cfi]),i.pages){const t=`${i.pages.start}-${i.pages.end}`;e.push(["Pages",t])}i.url&&e.push(["URL",i.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){
|
|
585
585
|
return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}var Mf=function(){if(Tf)return Af;Tf=1;var e="complete",t="canceled";function n(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function r(t){var o=t._scrollSettings;if(o){var i=o.maxSynchronousAlignments,a=function(e,t){var n,r,o,i,a,s,l,c=e.align,u=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,h=c&&null!=c.top?c.top:.5,p=c&&null!=c.leftOffset?c.leftOffset:0,m=c&&null!=c.topOffset?c.topOffset:0,f=d,g=h;if(e.isWindow(t))s=Math.min(u.width,t.innerWidth),l=Math.min(u.height,t.innerHeight),r=u.left+t.pageXOffset-t.innerWidth*f+s*f,o=u.top+t.pageYOffset-t.innerHeight*g+l*g,r-=p,o-=m,r=e.align.lockX?t.pageXOffset:r,o=e.align.lockY?t.pageYOffset:o,i=r-t.pageXOffset,a=o-t.pageYOffset;else{s=u.width,l=u.height,n=t.getBoundingClientRect()
|
|
586
586
|
;var v=u.left-(n.left-t.scrollLeft),b=u.top-(n.top-t.scrollTop);r=v+s*f-t.clientWidth*f,o=b+l*g-t.clientHeight*g,r-=p,o-=m,r=Math.max(Math.min(r,t.scrollWidth-t.clientWidth),0),o=Math.max(Math.min(o,t.scrollHeight-t.clientHeight),0),r=e.align.lockX?t.scrollLeft:r,o=e.align.lockY?t.scrollTop:o,i=r-t.scrollLeft,a=o-t.scrollTop}return{x:r,y:o,differenceX:i,differenceY:a}}(o,t),s=Date.now()-o.startTime,l=Math.min(1/o.time*s,1);if(o.endIterations>=i)return n(t,a.x,a.y),t._scrollSettings=null,o.end(e);var c=1-o.ease(l);if(n(t,a.x-a.differenceX*c,a.y-a.differenceY*c),s>=o.time)return o.endIterations++,o.scrollAncestor&&r(o.scrollAncestor),void r(t);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(r.bind(null,t))}}function o(e){return e.self===e}function i(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function a(){return!0}function s(e){
|
|
587
587
|
if(e.assignedSlot)return s(e.assignedSlot);if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t.host}}return Af=function(n,l,c){if(n){"function"==typeof l&&(c=l,l=null),l||(l={}),l.time=isNaN(l.time)?1e3:l.time,l.ease=l.ease||function(e){return 1-Math.pow(1-e,e/2)},l.align=l.align||{};var u=s(n),d=1,h=l.validTarget||a,p=l.isScrollable;l.debug&&(console.log("About to scroll to",n),u||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var m=[];u;)if(l.debug&&console.log("Scrolling parent node",u),h(u,d)&&(p?p(u,i):i(u))&&(d++,m.push(u)),!(u=s(u))){f(e);break}return m.reduce(((e,i,a)=>function(e,n,i,a,s){var l,c=!n._scrollSettings,u=n._scrollSettings,d=Date.now(),h={passive:!0};function p(e){n._scrollSettings=null,
|
|
@@ -618,30 +618,30 @@ title:"Hypothesis homepage",underline:"none",variant:"custom",children:Ve(Vt,{cl
|
|
|
618
618
|
id:wg(a),"aria-controls":xg(a),tabIndex:0,title:l,underline:"none",children:Ve(y,{children:[e,t>0&&!n&&Ve("span",{className:"relative bottom-[3px] left-[2px] text-[10px]",children:t})]})})}var Sg=Jn((function({annotationsService:e,isLoading:t,settings:n}){const{rootThread:r,tabCounts:o}=Sf(),i=Hi(),a=i.selectedTab(),s=o.note,l=o.annotation,c=o.orphan,u=i.isWaitingToAnchorAnnotations(),d=e=>{i.selectTab(e)},h="annotation"===a&&0===l&&!u,p="note"===a&&0===s,m=[];if(l>0){const e=Yf(l,"annotation","annotations");m.push(`${l} ${e}`)}if(s>0){const e=Yf(s,"note","notes");m.push(`${s} ${e}`)}if(c>0){const e=Yf(s,"unanchored","unanchored");m.push(`${c} ${e}`)}const f=m.join(", "),g=de((async()=>{e.createPageNote()}),[e]);return Ve(y,{children:[Ve("div",{"aria-live":"polite",role:"status",className:"sr-only",children:f}),Ve("div",{className:Je("space-y-3 pb-[9px]"),children:[Ve("div",{className:"flex gap-x-6 theme-clean:ml-[15px] mt-1",role:"tablist",children:[!n.commentsMode&&Ve(kg,{count:l,isWaitingToAnchor:u,
|
|
619
619
|
isSelected:"annotation"===a,label:"Annotations",name:"annotation",onSelect:()=>d("annotation"),children:"Annotations"}),Ve(kg,{count:s,isWaitingToAnchor:u,isSelected:"note"===a,label:n.commentsMode?"Comments":"Page notes",name:"note",onSelect:()=>d("note"),children:n.commentsMode?"Comments":"Page Notes"}),c>0&&Ve(kg,{count:c,isWaitingToAnchor:u,isSelected:"orphan"===a,label:"Unanchored",name:"orphan",onSelect:()=>d("orphan"),children:"Unanchored"})]}),Ve("div",{className:"space-y-3",role:"tabpanel",id:xg(a),"aria-labelledby":wg(a),children:["note"===a&&n.enableExperimentalNewNoteButton&&Ve("div",{className:"flex justify-end",children:Ve(dn,{"data-testid":"new-note-button",onClick:g,variant:"primary",style:Zn(["ctaBackgroundColor"],n),children:[Ve(Zt,{}),n.commentsMode?"Add comment":"New note"]})}),!t&&p&&Ve(it,{"data-testid":"notes-unavailable-message",variant:"flat",children:Ve(st,{classes:"text-center",children:["There are no ",n.commentsMode?"comments":"page notes"," ","in this group."]})}),!t&&h&&Ve(it,{
|
|
620
620
|
"data-testid":"annotations-unavailable-message",variant:"flat",children:Ve(st,{classes:"text-center !space-y-1",children:[Ve("p",{children:"There are no annotations in this group."}),Ve("p",{children:["Create one by selecting some text and clicking the"," ",Ve(lt,{className:"w-em h-em inline m-0.5 -mt-0.5",title:"Annotate"})," ","button."]})]})}),Ve(Hm,{threads:r.children})]})]})]})}),["annotationsService","frameSync","settings"]);function Ag({label:e,icon:t,description:n,active:r,disabled:o=!1,setActive:i,testId:a}){return Ve(dn,{"data-testid":a,classes:Je({"font-medium rounded-lg py-1":!0,"text-grey-7 bg-grey-2":!r,"text-grey-1 bg-grey-7":r,"opacity-50":o}),disabled:o,onClick:()=>i(!r),variant:"custom",title:n,children:[t&&Ve(t,{className:"w-em h-em"}),Ve("span",{className:"max-w-56 truncate",children:e}),Ve("div",{className:Je({"h-[2em] w-[1.5px] -mt-1 -mb-1":!0,"bg-grey-3":!r,"bg-grey-5":r})}),Ve(r?Xt:Zt,{className:"w-em h-em"})]})}function Tg({children:e}){return Ve("div",{className:"mb-3",
|
|
621
|
-
children:Ve(it,{children:Ve(st,{children:e})})})}function Eg({withCardContainer:e=!1}){const t=Hi(),n=t.selectedAnnotations().length,r=n>0,o=t.getFocusActive(),i=t.getFocusFilters(),a=Object.keys(i).length>0;if(!(r||a))return null;return Ve(e?Tg:y,{children:Ve("div",{className:"flex flex-row flex-wrap gap-2 items-center","data-testid":"filter-controls",children:[Ve("b",{children:"Filters"}),r&&Ve(Ag,{label:`Remove ${n} selected annotation filter`,description:`Show ${n} selected annotations
|
|
622
|
-
label:"Selected chapter",description:"Show annotations on selected book chapter(s)",active:o.has("cfi"),disabled:r,setActive:()=>t.toggleFocusMode({key:"cfi"}),testId:"cfi-focus-toggle"})]})})}var Cg=Jn((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=Hi(),a=i.focusedGroupId(),s=i.isLoading(),l=i.isLoggedIn(),c=i.directLinkedAnnotationId(),u=c?i.findAnnotationByID(c):void 0,d=u?vf(u):"annotation",h=i.searchUris(),p=i.hasSidebarOpened(),m=i.profile().userid,f=!(s||!c)&&!u,g=i.directLinkedGroupFetchFailed(),v=f||g,b=i.isSidebarPanelOpen("searchAnnotations"),y=!v&&!b,_=c&&!l&&!f&&!s,w=ce(a);se((()=>{if(!w.current||w.current!==a){if(w.current){const e=i.focusState().active;i.clearSelection(),e&&i.toggleFocusMode({active:!0})}w.current=a}a&&h.length&&r.load({groupId:a,uris:h})}),[i,r,a,m,h]),se((()=>{
|
|
623
|
-
x&&(p||l)&&o.connect({applyUpdatesImmediately:!1})}),[x,l,p,o]),Ve("div",{className:"relative",children:[Ve("h2",{className:"sr-only",children:"Annotations"}),Ve("div",{className:Je("fixed z-10","right-[9px] top-12"),children:Ve(tg,{})}),y&&Ve(Eg,{withCardContainer:!0}),Ve(_g,{onLogin:t,onSignUp:n}),f&&Ve(Bi,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),g&&Ve(Bi,{errorType:"group",onLoginRequest:t}),!v&&Ve(Sg,{isLoading:s}),_&&Ve(yg,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Mg=Jn((function({api:e,toastMessenger:t}){const n=Hi(),r=n.routeParams().q,o=de((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...gf(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);se((()=>{n.setSortKey("newest"),
|
|
624
|
-
})}),["api","toastMessenger"]);var Ng=Jn((function({toastMessenger:e}){const t=Hi().getToastMessages();return Ve("div",{className:Je("z-10","absolute left-0 w-full"),children:Ve(Fn,{messages:t,onMessageDismiss:t=>e.dismiss(t),transitionClasses:{transitionIn:"motion-safe:animate-slide-in-from-right lg:animate-fade-in motion-reduce:animate-fade-in"}})})}),["toastMessenger"]);function Ig(e){return e.organization.name}const Og="__default__";function zg(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;const n=(r=e.organization).id===Og?Og:`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]={...e.organization,groups:[]}),function(e,t){const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function Lg(e){const t=zg(e),n=[],r=[]
|
|
625
|
-
children:[e&&Ve("h2",{className:"text-color-text-light p-3 leading-none uppercase",children:e}),Ve("ul",{className:"border-b",children:E(t).map((e=>Ve("li",{children:e},e.key)))})]})}function Rg({type:e}){return Ve("div",{className:"text-color-text-light",title:"open"===e?"Public group":"restricted"===e?"Restricted group":"Private group","data-testid":"group-icon",children:["open"===e&&Ve(zt,{}),"restricted"===e&&Ve(Lt,{}),"private"===e&&Ve(Gt,{})]})}var Dg=Jn((function({isExpanded:e,group:t,groups:n,onExpand:r,showIcon:o=!0,toastMessenger:i}){const a=t.links.html,s=a||t.canLeave,l=t.scopes&&!t.scopes.enforced||t.isScopedToUri,c=Hi(),u=c.focusedGroupId(),d=t.id===u,h=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},p="private"===t.type?"Copy invite link":"Copy activity link",m=t.logo?Ve("img",{className:"w-4 h-4",alt:Ig(t),src:t.logo
|
|
626
|
-
className:"grow flex items-center justify-between gap-x-2",children:[t.name,o&&Ve(Rg,{type:t.type})]}),leftChannelContent:m,onClick:l?()=>{c.clearDirectLinkedGroupFetchFailed(),c.clearDirectLinkedIds(),n.focus(t.id)}:h,onToggleSubmenu:h,submenuToggleTitle:`Show actions for ${t.name}`,submenu:Ve(y,{children:[Ve("ul",{children:[a&&Ve("li",{children:Ve(bm,{href:a,icon:Ct,isSubmenuItem:!0,label:"View group activity"})}),a&&Ve("li",{children:Ve(bm,{onClick:()=>(async e=>{try{await Lf(e),i.success(`Copied link for "${t.name}"`)}catch{i.error("Unable to copy link")}})(a),icon:_t,isSubmenuItem:!0,label:p})}),t.canLeave&&Ve("li",{children:Ve(bm,{icon:$t,isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await wn({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]
|
|
627
|
-
}),["groups","toastMessenger"]);function jg({expandedGroup:e,onExpandGroup:t,groups:n,heading:r,showIcons:o}){return Ve(Pg,{heading:r,children:n.map((n=>Ve(Dg,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n,showIcon:o},n.id)))})}function Hg({group:e,settings:t}){const n=e.organization.logo||function(e){const t=Kn(e);return t&&t.icon?t.icon:null}(t)||"",r=Ig(e);return Ve(y,{children:[n&&Ve("img",{className:Je("relative top-[1px] w-4 h-4","max-[350px]:hidden"),src:n,alt:r}),Ve("span",{className:Je("text-md text-color-text font-bold truncate","py-1"),children:e.name})]})}var Fg=Jn((function({settings:e}){
|
|
628
|
-
;return!!v&&n.length+r.length+o.length<2?g:Ve(gm,{align:"left",contentClass:"min-w-[250px]",disabled:s,label:g,onOpenChanged:()=>f(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[u.length>0&&Ve(jg,{expandedGroup:m,onExpandGroup:f,heading:"Currently Viewing",groups:u,showIcons:b}),c.length>0&&Ve(jg,{expandedGroup:m,onExpandGroup:f,heading:"Featured Groups",groups:c,showIcons:b}),l.length>0&&Ve(jg,{expandedGroup:m,onExpandGroup:f,heading:"My Groups",groups:l,showIcons:b}),h&&Ve(bm,{icon:Zt,href:p,label:"Create new group"})]})}),["settings"]);const $g={newest:"Newest",oldest:"Oldest",location:"Location"}
|
|
629
|
-
classes:Je(e,"border border-transparent","aria-pressed:border-grey-3 aria-pressed:bg-grey-1")})}function Ug(e){return Ve(qg,{size:"custom",classes:"touch:min-w-touch-minimum p-1",...e})}var Gg=Jn((function({dashboard:e,isMenuOpen:t,toastMessenger:n}){const[r,o]=ie(),i=!r,a=de((()=>{"string"!=typeof r?r&&n.error("Can't open dashboard: You must reload the page.",{autoDismiss:!1}):e.open(r)}),[r,e,n]);return se((()=>(t&&e.getAuthToken().then(o).catch((e=>{console.warn("An error occurred while getting auth token",e),o(e)})),()=>o(void 0))),[e,t]),Ve(bm,{label:"Open dashboard",isDisabled:i,onClick:a})}),["dashboard","toastMessenger"])
|
|
630
|
-
;t&&e.notifyHost("openNotebook",t)},b=()=>e.notifyHost("openProfile"),y=p&&!a?r.getLink("user",{user:l}):void 0,_=Ve("span",{className:"p-1",children:Ve(en,{})});return Ve("div",{"data-testid":"user-menu",onKeyDown:e=>{"n"===e.key?(v(),d(!1)):g&&"p"===e.key&&(b(),d(!1))},children:Ve(gm,{label:_,title:c,align:"right",open:u,onOpenChanged:d,children:[Ve(Pg,{children:[Ve(bm,{label:c,isDisabled:!p,href:y,onClick:p?()=>a&&e.notifyHost("profileRequested"):void 0}),!a&&Ve(bm,{label:"Account settings",href:r.getLink("account.settings")}),g&&Ve(bm,{label:"Your profile",onClick:()=>b()}),Ve(bm,{label:"Open notebook",onClick:()=>v()})]
|
|
631
|
-
!n.metaKey&&!n.ctrlKey&&n.target instanceof HTMLElement&&["INPUT","TEXTAREA"].includes(n.target.tagName)||(t.current=document.activeElement,e.isSidebarPanelOpen("searchAnnotations")||(e.openSidebarPanel("searchAnnotations"),n.preventDefault(),n.stopPropagation()))}),[e]),r=zp()?"meta":"ctrl";Qf("/",n),Qf(`${r}+k`,n)}(e),Ve(y,{children:[t&&Ve(Rn,{}),!t&&Ve(Ug,{icon:an,expanded:n,pressed:n,onClick:r,title:"Show search panel"})]})}function Kg({classes:e,disabled:t=!1,inputRef:n,onClearSearch:r,onKeyDown:o,onSearch:i,query:a}){const s=Hi().isLoading(),l=Ie(n),[c,u]=ie(a),[d,h]=ie(a);Qf("/",(e=>{document.activeElement!==l.current&&(e.preventDefault(),
|
|
632
|
-
}),Ve(An,{"aria-label":"Search",classes:Je("pl-8 pr-8","disabled:text-grey-6","text-base touch:text-touch-base"),"data-testid":"search-input",dir:"auto",name:"query",placeholder:s?"Loading…":"Search…",disabled:t||s,elementRef:l,value:d||"",onInput:e=>h(e.target.value),onKeyDown:o}),d&&Ve(mn,{classes:"absolute right-0 text-[16px] top-[50%] translate-y-[-50%]",size:"lg",icon:dt,"data-testid":"clear-button",title:"Clear search",onClick:r,disabled:t})]})})}var Yg=Jn((function({router:e}){const t=Hi(),{q:n}=t.routeParams(),r=t=>{e.navigate("stream",{q:t})};return Ve(Kg,{query:n??"",onSearch:r,onClearSearch:()=>r("")})}),["router"]);function Xg(e,t){
|
|
633
|
-
const a=Zn(["accentColor"],i),s=Hi(),l=s.isLoggedIn(),c=s.hasFetchedProfile(),u=s.isSidebarPanelOpen("help"),d=s.isSidebarPanelOpen("shareGroupAnnotations");return Ve("div",{className:Je("absolute h-10 left-0 top-0 right-0 z-4","text-grey-7 border-b theme-clean:border-b-0 bg-white"),"data-testid":"top-bar",children:Ve("div",{className:Je("container flex items-center h-full","text-[16px]"),"data-testid":"top-bar-content",children:[Ve(e?Fg:Yg,{}),Ve("div",{className:"grow flex items-center justify-end",children:[e&&Ve(y,{children:[Ve(Wg,{}),Ve(Bg,{}),Xg(i,"share")&&Ve(Ug,{icon:sn,expanded:d,pressed:d,onClick:()=>{s.toggleSidebarPanel("shareGroupAnnotations")},title:"Show share panel","data-testid":"share-icon-button"})]
|
|
634
|
-
className:"flex items-center text-md font-medium space-x-1 pl-1","data-testid":"login-links",children:[!l&&!c&&Ve("span",{children:"⋯"}),!l&&c&&Ve(y,{children:[Ve(Bn,{classes:"inline",onClick:r,style:a,underline:"none",children:"Sign up"}),Ve("div",{children:"/"}),Ve(Bn,{classes:"inline",onClick:t,style:a,underline:"none",children:"Log in"})]})]})]})]})})}),["frameSync","settings"]);function Qg(){const e=Hi(),t=e.filterQuery(),n=ce(null),r=e.hasSelectedAnnotations(),o=()=>{e.closeSidebarPanel("searchAnnotations")};return Ve(If,{panelName:"searchAnnotations",label:"Search panel",initialFocus:n,onActiveChanged:t=>{t||e.setFilterQuery(null)},children:Ve(it,{children:Ve(st,{children:[Ve("div",{className:"flex gap-x-3",children:Ve(Kg,{
|
|
635
|
-
const i=Hi(),a=i.profile(),s=i.route(),l="notebook"===s||"profile"===s,c=ue((()=>Zn(["appBackgroundColor"],n)),[n]),u="clean"===n.theme,d="sidebar"===s;se((()=>{(function(e,t,n){if(!e)return!1;if("object"!=typeof t.preferences||!t.preferences.show_sidebar_tutorial)return!1;const r=Kn(n);return!r?.onHelpRequestProvided&&!1!==r?.enableHelpPanel})(d,a,n)&&i.openSidebarPanel("help")}),[d,a,n,i]);const h=Yn(n),p=async t=>{try{await e.login({action:t}),i.closeSidebarPanel("loginPrompt"),i.clearGroups(),r.reload()}catch(e){o.error(e.message)}},m=async()=>{Kn(n)?t.notifyHost("loginRequested"):await p("login")},f=async()=>{Kn(n)?t.notifyHost("signupRequested"):await p("signup")};return Ve("div",{
|
|
636
|
-
;return 1===e?t="You have an unsaved annotation.\nDo you really want to discard this draft?":e>1&&(t="You have "+e+" unsaved annotations.\nDo you really want to discard these drafts?"),wn({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),Kn(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),Ve("div",{className:"container",children:[Ve(Ng,{}),Ve(Ff,{}),Ve(Qg,{}),Ve(bg,{shareTab:!h}),s&&Ve("main",{children:["annotation"===s&&Ve(Ef,{onLogin:m}),"notebook"===s&&Ve(ng,{}),"profile"===s&&Ve(og,{}),"stream"===s&&Ve(Mg,{}),"sidebar"===s&&Ve(Cg,{onLogin:m,onSignUp:f})]})]})]})
|
|
637
|
-
;return window.crypto.getRandomValues(t),Array.from(t).map(tv).join("")}function rv(e,t,n,r=[],o=2e3,i=window){const a=nv(10),s={jsonrpc:"2.0",method:n,params:r,id:a};try{e.postMessage(s,t)}catch(e){return Promise.reject(e)}let l;const c=new Promise(((e,n)=>{l=r=>{if(r.origin!==t)return;if(!(r.data instanceof Object)||"2.0"!==r.data.jsonrpc||r.data.id!==a)return;const{error:o,result:i}=r.data;void 0!==o?n(o):void 0!==i?e(i):n(new Error("RPC reply had no result or error"))},i.addEventListener("message",l)})),u=[c];var d,h;return o&&u.push((d=o,h=`Request to ${t} timed out`,new Promise(((e,t)=>{setTimeout((()=>t(new Error(h))),d)})))),Promise.race(u).then((e=>(i.removeEventListener("message",l),
|
|
638
|
-
;return isNaN(t)?"string"==typeof e:Boolean(t)}function av(e){return parseInt(e)}function sv(e){return e&&"function"==typeof e.toString?e.toString():""}function lv(e,t=window){let n=t;for(let t=0;t<e;t++){if(n===n.top)throw new Error("The target parent frame has exceeded the ancestor tree. Try reducing the `requestConfigFromFrame.ancestorLevel` value in the `hypothesisConfig`");n=n.parent}return n}const cv=new Set;function uv(...e){const t=e.join();cv.has(t)||(console.warn(...e),cv.add(t))}var dv,hv;uv.reset=()=>{cv.clear()};var pv=Ke(hv?dv:(hv=1,dv=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}));function mv(e){const t=Kn(e)
|
|
639
|
-
;for(const e of a)e.canLeave=mv(r)&&e.isMember&&e.id!==fv;return a.forEach((e=>e.isScopedToUri=function(e,t){if(e.scopes&&e.scopes.uri_patterns.length>0&&t)return function(e,t){return t.some((t=>e.match(t.split("*").map(pv).join(".*"))))}(t,e.scopes.uri_patterns);return!0}(e,n))),a}let vv=[];const bv=e=>({changeFocusModeUser:t=>{e.changeFocusModeUser(t);const n=t?.groups??[],r=function(e,t){return function(e,t){return t.filter((t=>e.includes(t.id)||t.groupid&&e.includes(t.groupid)))}(e,t).map((e=>e.id))}(n,e.allGroups());n.length&&!r.length&&console.error("No matching groups found in list of filtered group IDs"),e.filterGroups(r)},showContentInfo:t=>{e.setContentInfo(t)}});function yv(e,t,n){const r=bv(e);function o(e){const n=t.rpcAllowedOrigins||[]
|
|
640
|
-
;if(void 0===t)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",result:"ok",id:e.id}}(i),e.origin)}vv.forEach((e=>{o(e)})),vv=[],window.removeEventListener("message",_v),n.addEventListener("message",o)}function _v(e){vv.push(e)}yv.$inject=["store","settings","$window"];class wv{constructor(e){this._api=e}trackEvent(e){this._api.analytics.events.create({},{event:e}).catch((t=>console.warn(`Could not track event "${e}"`,t)))}}wv.$inject=["api"];class xv{constructor(e){this._rpc=e.rpc,this._reportConfig=e.reportActivity}reportActivity(e,t){if(!this._rpc||!this._reportConfig)return;let n;switch(e){case"create":n=new Date(t.created).toISOString();break;case"update":
|
|
641
|
-
this.notify("reportUnsavedChanges",[{unsaved:e}])}notify(e,t){this._rpc&&function(e,t,n,r=[]){const o={jsonrpc:"2.0",method:n,params:r};e.postMessage(o,t)}(this._rpc.targetFrame,this._rpc.origin,e,t)}}xv.$inject=["settings"];class kv{constructor(e,t,n,r){this._activity=e,this._api=t,this._settings=n,this._store=r}_applyDraftChanges(e,t){const n={},r=this._store.getDraft(e),o=Or(this._store.profile().userid)?.provider??this._store.defaultAuthority(),i=this._store.isFeatureEnabled("at_mentions");if(!r)return{...e};i?"username"===t.mentionMode?n.text=function(e,t){return e.replace(Pp,((e,n,r)=>`${n}${jp(function(e,t){return`acct:${e}@${t}`}(r,t),`@${r}`)}`))}(r.text,o):n.text=function(e,t){return e.replace(Dp,((e,n)=>{const r=t.get(n)
|
|
642
|
-
...e,...n}}annotationFromData(e,t=new Date){const n=this._store.getDefault("annotationPrivacy"),r=this._store.focusedGroupId(),o=this._store.profile();if(!r)throw new Error("Cannot create annotation without a group");const i=o.userid;if(!i)throw new Error("Cannot create annotation when logged out");const a=o.user_info,s=`s:${nv(8)}`,l=Object.assign({created:t.toISOString(),group:r,permissions:Sp(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Fr(l)&&(l.permissions=xp(i)),this._settings.annotationMetadata&&(l.metadata={...this._settings.annotationMetadata}),l}create(e,t=new Date){const n=this.annotationFromData(e,t);this._store.addAnnotations([n]),
|
|
643
|
-
this._store.setExpanded(e,!0)}))}createPageNote(e){const t=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!t)return;const n={target:[{source:t.uri}],uri:t.uri,document:e};this.create(n)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,permissions:Tp(e.permissions)?xp(t):kp(t,e.group),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e,t={
|
|
644
|
-
this._store.annotationSaveFinished(e)}for(const[t,n]of Object.entries(e))if(t.startsWith("$")){i[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([i]),i}async moderate(e,t){const n=await this._api.annotation.moderate({id:e.id},{moderation_status:t,current_moderation_status:e.moderation_status,annotation_updated:e.updated});return this._store.addAnnotations([n]),n}async loadAnnotation(e){const t=await this._api.annotation.read({id:e});return this._store.addAnnotations([t]),t}}if(kv.$inject=["annotationActivity","api","settings","store"],"function"!=typeof Symbol){var Sv=0;Symbol=function(e){return"@@"+e+ ++Sv},Symbol.for=function(e){return"@@"+e}}
|
|
621
|
+
children:Ve(it,{children:Ve(st,{children:e})})})}function Eg({withCardContainer:e=!1}){const t=Hi(),n=t.selectedAnnotations().length,r=n>0,o=t.getFocusActive(),i=t.getFocusFilters(),a=Object.keys(i).length>0;if(!(r||a))return null;return Ve(e?Tg:y,{children:Ve("div",{className:"flex flex-row flex-wrap gap-2 items-center","data-testid":"filter-controls",children:[Ve("b",{children:"Filters"}),r&&Ve(Ag,{label:`Remove ${n} selected annotation filter`,description:`Show only the ${n} selected annotations. Press to clear this filter and show all annotations.`,active:!0,setActive:()=>t.clearSelection(),testId:"selection-toggle"}),i.user&&Ve(Ag,{icon:en,label:`By ${i.user.display}`,description:`Show annotations by ${i.user.display}. Press to clear this filter.`,active:o.has("user"),disabled:r,setActive:()=>t.toggleFocusMode({key:"user"}),testId:"user-focus-toggle"}),i.page&&Ve(Ag,{icon:Mt,label:`Pages ${i.page.display}`,description:`Show annotations on pages ${i.page.display}. Press to clear this filter.`,
|
|
622
|
+
active:o.has("page"),disabled:r,setActive:()=>t.toggleFocusMode({key:"page"}),testId:"page-focus-toggle"}),i.cfi&&Ve(Ag,{icon:Mt,label:"Selected chapter",description:"Show annotations on selected book chapter(s). Press to clear this filter.",active:o.has("cfi"),disabled:r,setActive:()=>t.toggleFocusMode({key:"cfi"}),testId:"cfi-focus-toggle"})]})})}var Cg=Jn((function({frameSync:e,onLogin:t,onSignUp:n,loadAnnotationsService:r,streamer:o}){const i=Hi(),a=i.focusedGroupId(),s=i.isLoading(),l=i.isLoggedIn(),c=i.directLinkedAnnotationId(),u=c?i.findAnnotationByID(c):void 0,d=u?vf(u):"annotation",h=i.searchUris(),p=i.hasSidebarOpened(),m=i.profile().userid,f=!(s||!c)&&!u,g=i.directLinkedGroupFetchFailed(),v=f||g,b=i.isSidebarPanelOpen("searchAnnotations"),y=!v&&!b,_=c&&!l&&!f&&!s,w=ce(a);se((()=>{if(!w.current||w.current!==a){if(w.current){const e=i.focusState().active;i.clearSelection(),e&&i.toggleFocusMode({active:!0})}w.current=a}a&&h.length&&r.load({groupId:a,uris:h})}),[i,r,a,m,h]),se((()=>{
|
|
623
|
+
u&&!1===u.$orphan?(e.hoverAnnotation(u),e.scrollToAnnotation(u),i.selectTab(d)):u&&i.selectTab(d)}),[d,e,u,i]);const x=i.hasFetchedProfile();return se((()=>{x&&(p||l)&&o.connect({applyUpdatesImmediately:!1})}),[x,l,p,o]),Ve("div",{className:"relative",children:[Ve("h2",{className:"sr-only",children:"Annotations"}),Ve("div",{className:Je("fixed z-10","right-[9px] top-12"),children:Ve(tg,{})}),y&&Ve(Eg,{withCardContainer:!0}),Ve(_g,{onLogin:t,onSignUp:n}),f&&Ve(Bi,{errorType:"annotation",onLoginRequest:t,showClearSelection:!0}),g&&Ve(Bi,{errorType:"group",onLoginRequest:t}),!v&&Ve(Sg,{isLoading:s}),_&&Ve(yg,{onLogin:t})]})}),["frameSync","loadAnnotationsService","streamer"]);var Mg=Jn((function({api:e,toastMessenger:t}){const n=Hi(),r=n.routeParams().q,o=de((async t=>{const r={_separate_replies:!0,offset:0,limit:20,...gf(t)};try{n.annotationFetchStarted();const t=await e.search(r);n.addAnnotations([...t.rows,...t.replies])}finally{n.annotationFetchFinished()}}),[e,n]);se((()=>{n.setSortKey("newest"),
|
|
624
|
+
n.clearAnnotations(),o(r??"").catch((e=>{t.error(`Unable to fetch annotations: ${e.message}`)}))}),[r,o,n,t]);const{rootThread:i}=Sf();return Ve(Hm,{threads:i.children})}),["api","toastMessenger"]);var Ng=Jn((function({toastMessenger:e}){const t=Hi().getToastMessages();return Ve("div",{className:Je("z-10","absolute left-0 w-full"),children:Ve(Fn,{messages:t,onMessageDismiss:t=>e.dismiss(t),transitionClasses:{transitionIn:"motion-safe:animate-slide-in-from-right lg:animate-fade-in motion-reduce:animate-fade-in"}})})}),["toastMessenger"]);function Ig(e){return e.organization.name}const Og="__default__";function zg(e){const t={};return e.forEach((e=>{if("object"!=typeof e.organization)return;const n=(r=e.organization).id===Og?Og:`${r.name.toLowerCase()}${r.id}`;var r;void 0===t[n]&&(t[n]={...e.organization,groups:[]}),function(e,t){const n=Object.assign({},e),r=t.groups;!r.length&&e.organization.logo&&(n.logo=e.organization.logo),r.push(n)}(e,t[n])})),t}function Lg(e){const t=zg(e),n=[],r=[]
|
|
625
|
+
;return Object.keys(t).sort().forEach((e=>{e===Og?n.push(...t[e].groups):r.push(...t[e].groups)})),n.length&&r.push(...n),r}function Pg({heading:e,children:t}){return Ve(y,{children:[e&&Ve("h2",{className:"text-color-text-light p-3 leading-none uppercase",children:e}),Ve("ul",{className:"border-b",children:E(t).map((e=>Ve("li",{children:e},e.key)))})]})}function Rg({type:e}){return Ve("div",{className:"text-color-text-light",title:"open"===e?"Public group":"restricted"===e?"Restricted group":"Private group","data-testid":"group-icon",children:["open"===e&&Ve(zt,{}),"restricted"===e&&Ve(Lt,{}),"private"===e&&Ve(Gt,{})]})}var Dg=Jn((function({isExpanded:e,group:t,groups:n,onExpand:r,showIcon:o=!0,toastMessenger:i}){const a=t.links.html,s=a||t.canLeave,l=t.scopes&&!t.scopes.enforced||t.isScopedToUri,c=Hi(),u=c.focusedGroupId(),d=t.id===u,h=t=>{t.stopPropagation(),t.preventDefault(),r(!e)},p="private"===t.type?"Copy invite link":"Copy activity link",m=t.logo?Ve("img",{className:"w-4 h-4",alt:Ig(t),src:t.logo
|
|
626
|
+
}):Ve("span",{className:"sr-only",children:Ig(t)});return Ve(bm,{isDisabled:!l,isExpanded:!!s&&e,isSelected:d,isSubmenuVisible:s?e:void 0,label:Ve("div",{className:"grow flex items-center justify-between gap-x-2",children:[t.name,o&&Ve(Rg,{type:t.type})]}),leftChannelContent:m,onClick:l?()=>{c.clearDirectLinkedGroupFetchFailed(),c.clearDirectLinkedIds(),n.focus(t.id)}:h,onToggleSubmenu:h,submenuToggleTitle:`Show actions for ${t.name}`,submenu:Ve(y,{children:[Ve("ul",{children:[a&&Ve("li",{children:Ve(bm,{href:a,icon:Ct,isSubmenuItem:!0,label:"View group activity"})}),a&&Ve("li",{children:Ve(bm,{onClick:()=>(async e=>{try{await Lf(e),i.success(`Copied link for "${t.name}"`)}catch{i.error("Unable to copy link")}})(a),icon:_t,isSubmenuItem:!0,label:p})}),t.canLeave&&Ve("li",{children:Ve(bm,{icon:$t,isSubmenuItem:!0,label:"Leave group",onClick:async()=>{const e=`Are you sure you want to leave the group "${t.name}"?`;await wn({title:"Leave group?",message:e,confirmAction:"Leave"})&&n.leave(t.id)}})})]
|
|
627
|
+
}),!l&&Ve("p",{className:Je("p-2 pl-9 bg-grey-1 hyphens-none"),"data-testid":"unselectable-group-note",children:"This group is restricted to specific URLs."})]})})}),["groups","toastMessenger"]);function jg({expandedGroup:e,onExpandGroup:t,groups:n,heading:r,showIcons:o}){return Ve(Pg,{heading:r,children:n.map((n=>Ve(Dg,{isExpanded:n===e,onExpand:e=>t(e?n:null),group:n,showIcon:o},n.id)))})}function Hg({group:e,settings:t}){const n=e.organization.logo||function(e){const t=Kn(e);return t&&t.icon?t.icon:null}(t)||"",r=Ig(e);return Ve(y,{children:[n&&Ve("img",{className:Je("relative top-[1px] w-4 h-4","max-[350px]:hidden"),src:n,alt:r}),Ve("span",{className:Je("text-md text-color-text font-bold truncate","py-1"),children:e.name})]})}var Fg=Jn((function({settings:e}){
|
|
628
|
+
const t=Hi(),n=t.getCurrentlyViewingGroups(),r=t.getFeaturedGroups(),o=t.getMyGroups(),i=t.focusedGroup(),a=t.profile().userid,s=t.importsPending()>0,l=ue((()=>Lg(o)),[o]),c=ue((()=>Lg(r)),[r]),u=ue((()=>Lg(n)),[n]),d=t.defaultAuthority(),h=!e.groupsAllowlist&&a&&!Lr(a,d),p=t.getLink("groups.new"),[m,f]=ie(null),g=i?Ve(Hg,{group:i,settings:e}):Ve("span",{children:"…"}),v=Yn(e),b=!v;return!!v&&n.length+r.length+o.length<2?g:Ve(gm,{align:"left",contentClass:"min-w-[250px]",disabled:s,label:g,onOpenChanged:()=>f(null),title:i?`Select group (now viewing: ${i.name})`:"Select group",children:[u.length>0&&Ve(jg,{expandedGroup:m,onExpandGroup:f,heading:"Currently Viewing",groups:u,showIcons:b}),c.length>0&&Ve(jg,{expandedGroup:m,onExpandGroup:f,heading:"Featured Groups",groups:c,showIcons:b}),l.length>0&&Ve(jg,{expandedGroup:m,onExpandGroup:f,heading:"My Groups",groups:l,showIcons:b}),h&&Ve(bm,{icon:Zt,href:p,label:"Create new group"})]})}),["settings"]);const $g={newest:"Newest",oldest:"Oldest",location:"Location"}
|
|
629
|
+
;function Bg(){const e=Hi(),t=e.sortKey(),n=e.sortKeys().map((n=>Ve(bm,{label:$g[n],onClick:()=>e.setSortKey(n),isSelected:n===t},n))),r=Ve("span",{className:"p-1",children:Ve(ln,{})});return Ve("div",{"data-component":"SortMenu",children:Ve(gm,{label:r,title:`Sort by ${t}`,align:"right",menuIndicator:!1,children:n})})}function qg({classes:e,...t}){return Ve(mn,{...t,classes:Je(e,"border border-transparent","aria-pressed:border-grey-3 aria-pressed:bg-grey-1")})}function Ug(e){return Ve(qg,{size:"custom",classes:"touch:min-w-touch-minimum p-1",...e})}var Gg=Jn((function({dashboard:e,isMenuOpen:t,toastMessenger:n}){const[r,o]=ie(),i=!r,a=de((()=>{"string"!=typeof r?r&&n.error("Can't open dashboard: You must reload the page.",{autoDismiss:!1}):e.open(r)}),[r,e,n]);return se((()=>(t&&e.getAuthToken().then(o).catch((e=>{console.warn("An error occurred while getting auth token",e),o(e)})),()=>o(void 0))),[e,t]),Ve(bm,{label:"Open dashboard",isDisabled:i,onClick:a})}),["dashboard","toastMessenger"])
|
|
630
|
+
;var Vg=Jn((function({frameSync:e,onLogout:t,settings:n}){const r=Hi(),o=r.defaultAuthority(),i=r.profile(),a=Lr(i.userid,o),s=Kn(n),l=zr(i.userid),c=i.user_info?.display_name??l,[u,d]=ie(!1),h=e=>s&&!!s[e],p=!a||h("onProfileRequestProvided"),m=!a||h("onLogoutRequestProvided"),f=r.importsPending()>0,g=r.isFeatureEnabled("client_user_profile"),v=()=>{const t=r.focusedGroupId();t&&e.notifyHost("openNotebook",t)},b=()=>e.notifyHost("openProfile"),y=p&&!a?r.getLink("user",{user:l}):void 0,_=Ve("span",{className:"p-1",children:Ve(en,{})});return Ve("div",{"data-testid":"user-menu",onKeyDown:e=>{"n"===e.key?(v(),d(!1)):g&&"p"===e.key&&(b(),d(!1))},children:Ve(gm,{label:_,title:c,align:"right",open:u,onOpenChanged:d,children:[Ve(Pg,{children:[Ve(bm,{label:c,isDisabled:!p,href:y,onClick:p?()=>a&&e.notifyHost("profileRequested"):void 0}),!a&&Ve(bm,{label:"Account settings",href:r.getLink("account.settings")}),g&&Ve(bm,{label:"Your profile",onClick:()=>b()}),Ve(bm,{label:"Open notebook",onClick:()=>v()})]
|
|
631
|
+
}),n.dashboard?.showEntryPoint&&Ve(Pg,{children:Ve(Gg,{isMenuOpen:u})}),m&&Ve(Pg,{children:Ve(bm,{isDisabled:f,label:"Log out",onClick:t})})]})})}),["frameSync","settings"]);function Wg(){const e=Hi(),t=e.isLoading(),n=e.isSidebarPanelOpen("searchAnnotations"),r=de((()=>{e.toggleSidebarPanel("searchAnnotations")}),[e]);return function(e){const t=ce(null),n=de((n=>{!n.metaKey&&!n.ctrlKey&&n.target instanceof HTMLElement&&["INPUT","TEXTAREA"].includes(n.target.tagName)||(t.current=document.activeElement,e.isSidebarPanelOpen("searchAnnotations")||(e.openSidebarPanel("searchAnnotations"),n.preventDefault(),n.stopPropagation()))}),[e]),r=zp()?"meta":"ctrl";Qf("/",n),Qf(`${r}+k`,n)}(e),Ve(y,{children:[t&&Ve(Rn,{}),!t&&Ve(Ug,{icon:an,expanded:n,pressed:n,onClick:r,title:"Show search panel"})]})}function Kg({classes:e,disabled:t=!1,inputRef:n,onClearSearch:r,onKeyDown:o,onSearch:i,query:a}){const s=Hi().isLoading(),l=Ie(n),[c,u]=ie(a),[d,h]=ie(a);Qf("/",(e=>{document.activeElement!==l.current&&(e.preventDefault(),
|
|
632
|
+
l.current?.focus())}));return a!==c&&(h(a),u(a)),Ve("form",{name:"searchForm",onSubmit:e=>{e.preventDefault(),(l.current?.value||c)&&i(l.current?.value??"")},className:Je("space-y-3",e),children:Ve("div",{className:"relative",children:[Ve(mn,{classes:"absolute left-0 text-[16px] top-[50%] translate-y-[-50%]",icon:an,size:"lg",title:"Search",type:"submit",disabled:t}),Ve(An,{"aria-label":"Search",classes:Je("pl-8 pr-8","disabled:text-grey-6","text-base touch:text-touch-base"),"data-testid":"search-input",dir:"auto",name:"query",placeholder:s?"Loading…":"Search…",disabled:t||s,elementRef:l,value:d||"",onInput:e=>h(e.target.value),onKeyDown:o}),d&&Ve(mn,{classes:"absolute right-0 text-[16px] top-[50%] translate-y-[-50%]",size:"lg",icon:dt,"data-testid":"clear-button",title:"Clear search",onClick:r,disabled:t})]})})}var Yg=Jn((function({router:e}){const t=Hi(),{q:n}=t.routeParams(),r=t=>{e.navigate("stream",{q:t})};return Ve(Kg,{query:n??"",onSearch:r,onClearSearch:()=>r("")})}),["router"]);function Xg(e,t){
|
|
633
|
+
const n=Kn(e)??{};switch(t){case"share":return!e.commentsMode&&(n.enableShareImportExportPanel??!0);case"account":return n.enableAccountMenu??!0;case"help":return n.enableHelpPanel??!0;default:return!0}}var Zg=Jn((function({isSidebar:e,onLogin:t,onLogout:n,onSignUp:r,frameSync:o,settings:i}){const a=Zn(["accentColor"],i),s=Hi(),l=s.isLoggedIn(),c=s.hasFetchedProfile(),u=s.isSidebarPanelOpen("help"),d=s.isSidebarPanelOpen("shareGroupAnnotations");return Ve("div",{className:Je("absolute h-10 left-0 top-0 right-0 z-4","text-grey-7 border-b theme-clean:border-b-0 bg-white"),"data-testid":"top-bar",children:Ve("div",{className:Je("container flex items-center h-full","text-[16px]"),"data-testid":"top-bar-content",children:[Ve(e?Fg:Yg,{}),Ve("div",{className:"grow flex items-center justify-end",children:[e&&Ve(y,{children:[Ve(Wg,{}),Ve(Bg,{}),Xg(i,"share")&&Ve(Ug,{icon:sn,expanded:d,pressed:d,onClick:()=>{s.toggleSidebarPanel("shareGroupAnnotations")},title:"Show share panel","data-testid":"share-icon-button"})]
|
|
634
|
+
}),Xg(i,"help")&&Ve(Ug,{icon:Rt,expanded:u,pressed:u,onClick:()=>{const e=Kn(i);e&&e.onHelpRequestProvided?o.notifyHost("helpRequested"):s.toggleSidebarPanel("help")},title:"Show help panel","data-testid":"help-icon-button"}),l?Xg(i,"account")&&Ve(Vg,{onLogout:n}):Ve("div",{className:"flex items-center text-md font-medium space-x-1 pl-1","data-testid":"login-links",children:[!l&&!c&&Ve("span",{children:"⋯"}),!l&&c&&Ve(y,{children:[Ve(Bn,{classes:"inline",onClick:r,style:a,underline:"none",children:"Sign up"}),Ve("div",{children:"/"}),Ve(Bn,{classes:"inline",onClick:t,style:a,underline:"none",children:"Log in"})]})]})]})]})})}),["frameSync","settings"]);function Qg(){const e=Hi(),t=e.filterQuery(),n=ce(null),r=e.hasSelectedAnnotations(),o=()=>{e.closeSidebarPanel("searchAnnotations")};return Ve(If,{panelName:"searchAnnotations",label:"Search panel",initialFocus:n,onActiveChanged:t=>{t||e.setFilterQuery(null)},children:Ve(it,{children:Ve(st,{children:[Ve("div",{className:"flex gap-x-3",children:Ve(Kg,{
|
|
635
|
+
inputRef:n,classes:"grow",disabled:r,query:t||null,onClearSearch:o,onSearch:e.setFilterQuery,onKeyDown:e=>{"Escape"===e.key&&o()}})}),Ve(Eg,{})]})})})}var Jg=Jn((function({auth:e,frameSync:t,settings:n,session:r,toastMessenger:o}){const i=Hi(),a=i.profile(),s=i.route(),l="notebook"===s||"profile"===s,c=ue((()=>Zn(["appBackgroundColor"],n)),[n]),u="clean"===n.theme,d="sidebar"===s;se((()=>{(function(e,t,n){if(!e)return!1;if("object"!=typeof t.preferences||!t.preferences.show_sidebar_tutorial)return!1;const r=Kn(n);return!r?.onHelpRequestProvided&&!1!==r?.enableHelpPanel})(d,a,n)&&i.openSidebarPanel("help")}),[d,a,n,i]);const h=Yn(n),p=async t=>{try{await e.login({action:t}),i.closeSidebarPanel("loginPrompt"),i.clearGroups(),r.reload()}catch(e){o.error(e.message)}},m=async()=>{Kn(n)?t.notifyHost("loginRequested"):await p("login")},f=async()=>{Kn(n)?t.notifyHost("signupRequested"):await p("signup")};return Ve("div",{
|
|
636
|
+
className:Je("h-full min-h-full overflow-auto","lg:pb-16 bg-grey-2","js-thread-list-scroll-root",{"theme-clean":u,"pt-[49px]":!l,"p-4 lg:p-12":l}),"data-testid":"hypothesis-app",style:c,children:[!l&&Ve(Zg,{onLogin:m,onSignUp:f,onLogout:async()=>{await(async()=>{const e=i.countDrafts();if(0===e)return!0;let t="";return 1===e?t="You have an unsaved annotation.\nDo you really want to discard this draft?":e>1&&(t="You have "+e+" unsaved annotations.\nDo you really want to discard these drafts?"),wn({title:"Discard drafts?",message:t,confirmAction:"Discard"})})()&&(i.clearGroups(),i.removeAnnotations(i.unsavedAnnotations()),i.discardAllDrafts(),Kn(n)?t.notifyHost("logoutRequested"):r.logout())},isSidebar:d}),Ve("div",{className:"container",children:[Ve(Ng,{}),Ve(Ff,{}),Ve(Qg,{}),Ve(bg,{shareTab:!h}),s&&Ve("main",{children:["annotation"===s&&Ve(Ef,{onLogin:m}),"notebook"===s&&Ve(ng,{}),"profile"===s&&Ve(og,{}),"stream"===s&&Ve(Mg,{}),"sidebar"===s&&Ve(Cg,{onLogin:m,onSignUp:f})]})]})]})
|
|
637
|
+
}),["auth","frameSync","session","settings","toastMessenger"]);function ev({error:e}){return Ve("div",{className:Je("m-2 mt-12"),children:Ve(bn,{title:"Unable to start Hypothesis",children:e.message})})}function tv(e){const t=e.toString(16);return 1===t.length?"0"+t:t}function nv(e){const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t).map(tv).join("")}function rv(e,t,n,r=[],o=2e3,i=window){const a=nv(10),s={jsonrpc:"2.0",method:n,params:r,id:a};try{e.postMessage(s,t)}catch(e){return Promise.reject(e)}let l;const c=new Promise(((e,n)=>{l=r=>{if(r.origin!==t)return;if(!(r.data instanceof Object)||"2.0"!==r.data.jsonrpc||r.data.id!==a)return;const{error:o,result:i}=r.data;void 0!==o?n(o):void 0!==i?e(i):n(new Error("RPC reply had no result or error"))},i.addEventListener("message",l)})),u=[c];var d,h;return o&&u.push((d=o,h=`Request to ${t} timed out`,new Promise(((e,t)=>{setTimeout((()=>t(new Error(h))),d)})))),Promise.race(u).then((e=>(i.removeEventListener("message",l),
|
|
638
|
+
e))).catch((e=>{throw i.removeEventListener("message",l),e}))}function ov(e){const t=new URL(e).hash.slice(1),n=new URLSearchParams(t).get("config");return JSON.parse(n||"{}")}function iv(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function av(e){return parseInt(e)}function sv(e){return e&&"function"==typeof e.toString?e.toString():""}function lv(e,t=window){let n=t;for(let t=0;t<e;t++){if(n===n.top)throw new Error("The target parent frame has exceeded the ancestor tree. Try reducing the `requestConfigFromFrame.ancestorLevel` value in the `hypothesisConfig`");n=n.parent}return n}const cv=new Set;function uv(...e){const t=e.join();cv.has(t)||(console.warn(...e),cv.add(t))}var dv,hv;uv.reset=()=>{cv.clear()};var pv=Ke(hv?dv:(hv=1,dv=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}));function mv(e){const t=Kn(e)
|
|
639
|
+
;return!t||!!t.allowLeavingGroups}const fv="__world__";function gv(e,t,n,r){const o=t.find((e=>e.id===fv));o&&e.unshift(o);const i=e.map((e=>e.id));t=t.filter((e=>!i.includes(e.id))),t.forEach((e=>e.isMember=!1)),e.forEach((e=>e.isMember=!0));const a=e.concat(t);for(const e of a)e.canLeave=mv(r)&&e.isMember&&e.id!==fv;return a.forEach((e=>e.isScopedToUri=function(e,t){if(e.scopes&&e.scopes.uri_patterns.length>0&&t)return function(e,t){return t.some((t=>e.match(t.split("*").map(pv).join(".*"))))}(t,e.scopes.uri_patterns);return!0}(e,n))),a}let vv=[];const bv=e=>({changeFocusModeUser:t=>{e.changeFocusModeUser(t);const n=t?.groups??[],r=function(e,t){return function(e,t){return t.filter((t=>e.includes(t.id)||t.groupid&&e.includes(t.groupid)))}(e,t).map((e=>e.id))}(n,e.allGroups());n.length&&!r.length&&console.error("No matching groups found in list of filtered group IDs"),e.filterGroups(r)},showContentInfo:t=>{e.setContentInfo(t)}});function yv(e,t,n){const r=bv(e);function o(e){const n=t.rpcAllowedOrigins||[]
|
|
640
|
+
;if(null==(o=e.data)||"object"!=typeof o||"2.0"!==o.jsonrpc)return;var o;if(!n.includes(e.origin))return void uv(`Ignoring JSON-RPC request from non-whitelisted origin ${e.origin}`);const i=e.data;e.source.postMessage(function(e){const t=r[e.method];if(void 0===t)return{jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"Method not found"}};e.params?t(...e.params):t();return{jsonrpc:"2.0",result:"ok",id:e.id}}(i),e.origin)}vv.forEach((e=>{o(e)})),vv=[],window.removeEventListener("message",_v),n.addEventListener("message",o)}function _v(e){vv.push(e)}yv.$inject=["store","settings","$window"];class wv{constructor(e){this._api=e}trackEvent(e){this._api.analytics.events.create({},{event:e}).catch((t=>console.warn(`Could not track event "${e}"`,t)))}}wv.$inject=["api"];class xv{constructor(e){this._rpc=e.rpc,this._reportConfig=e.reportActivity}reportActivity(e,t){if(!this._rpc||!this._reportConfig)return;let n;switch(e){case"create":n=new Date(t.created).toISOString();break;case"update":
|
|
641
|
+
n=new Date(t.updated).toISOString();break;default:n=(new Date).toISOString()}const r={date:n,annotation:{id:t.id,isShared:Ap(t.permissions)}};this._reportConfig.events.includes(e)&&this.notify(this._reportConfig.method,[e,r])}notifyUnsavedChanges(e){this.notify("reportUnsavedChanges",[{unsaved:e}])}notify(e,t){this._rpc&&function(e,t,n,r=[]){const o={jsonrpc:"2.0",method:n,params:r};e.postMessage(o,t)}(this._rpc.targetFrame,this._rpc.origin,e,t)}}xv.$inject=["settings"];class kv{constructor(e,t,n,r){this._activity=e,this._api=t,this._settings=n,this._store=r}_applyDraftChanges(e,t){const n={},r=this._store.getDraft(e),o=Or(this._store.profile().userid)?.provider??this._store.defaultAuthority(),i=this._store.isFeatureEnabled("at_mentions");if(!r)return{...e};i?"username"===t.mentionMode?n.text=function(e,t){return e.replace(Pp,((e,n,r)=>`${n}${jp(function(e,t){return`acct:${e}@${t}`}(r,t),`@${r}`)}`))}(r.text,o):n.text=function(e,t){return e.replace(Dp,((e,n)=>{const r=t.get(n)
|
|
642
|
+
;return r?jp(r.userid,`@${n}`):$p(n)}))}(r.text,t.usersMap):n.text=r.text,n.tags=r.tags,n.permissions=r.isPrivate?xp(e.user):kp(e.user,e.group);const a=e.target;if(a[0]&&a[0].description!==r.description){const e=structuredClone(a);e[0].description=r.description,n.target=e}return{...e,...n}}annotationFromData(e,t=new Date){const n=this._store.getDefault("annotationPrivacy"),r=this._store.focusedGroupId(),o=this._store.profile();if(!r)throw new Error("Cannot create annotation without a group");const i=o.userid;if(!i)throw new Error("Cannot create annotation when logged out");const a=o.user_info,s=`s:${nv(8)}`,l=Object.assign({created:t.toISOString(),group:r,permissions:Sp(i,r,n),tags:[],text:"",updated:t.toISOString(),user:i,user_info:a,$tag:s,hidden:!1,links:{},document:{title:""}},e);return Fr(l)&&(l.permissions=xp(i)),this._settings.annotationMetadata&&(l.metadata={...this._settings.annotationMetadata}),l}create(e,t=new Date){const n=this.annotationFromData(e,t);this._store.addAnnotations([n]),
|
|
643
|
+
this._store.deleteNewAndEmptyDrafts(),Fr(n)||this._store.createDraft(n,{tags:n.tags,text:n.text,isPrivate:Tp(n.permissions),description:n.target[0]?.description}),Br(n)?this._store.selectTab("note"):qr(n)&&this._store.selectTab("annotation"),(n.references||[]).forEach((e=>{this._store.setExpanded(e,!0)}))}createPageNote(e){const t=this._store.mainFrame();if(!this._store.isLoggedIn())return void this._store.openSidebarPanel("loginPrompt");if(!t)return;const n={target:[{source:t.uri}],uri:t.uri,document:e};this.create(n)}async delete(e){await this._api.annotation.delete({id:e.id}),this._activity.reportActivity("delete",e),this._store.removeAnnotations([e])}async flag(e){await this._api.annotation.flag({id:e.id}),this._activity.reportActivity("flag",e),this._store.updateFlagStatus(e.id,!0)}reply(e,t){const n={group:e.group,permissions:Tp(e.permissions)?xp(t):kp(t,e.group),references:(e.references||[]).concat(e.id),target:[{source:e.target[0].source}],uri:e.uri};this.create(n)}async save(e,t={
|
|
644
|
+
mentionMode:"username"}){let n,r;const o=this._applyDraftChanges(e,t);let i;Rr(e)?(n=this._api.annotation.update({id:e.id},o),r="update"):(n=this._api.annotation.create({},o),r="create"),this._store.annotationSaveStarted(e);try{i=await n,this._activity.reportActivity(r,i)}finally{this._store.annotationSaveFinished(e)}for(const[t,n]of Object.entries(e))if(t.startsWith("$")){i[t]=n}return this._store.removeDraft(e),this._store.addAnnotations([i]),i}async moderate(e,t){const n=await this._api.annotation.moderate({id:e.id},{moderation_status:t,current_moderation_status:e.moderation_status,annotation_updated:e.updated});return this._store.addAnnotations([n]),n}async loadAnnotation(e){const t=await this._api.annotation.read({id:e});return this._store.addAnnotations([t]),t}}if(kv.$inject=["annotationActivity","api","settings","store"],"function"!=typeof Symbol){var Sv=0;Symbol=function(e){return"@@"+e+ ++Sv},Symbol.for=function(e){return"@@"+e}}
|
|
645
645
|
var Av="diffed",Tv="__s",Ev="__d",Cv=/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,Mv=/[\s\n\\/='"\0<>]/,Nv=/^(xlink|xmlns|xml)([A-Z])/,Iv=/^(?:accessK|auto[A-Z]|cell|ch|col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z])/,Ov=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/,zv=new Set(["draggable","spellcheck"]);function Lv(e){void 0!==e.__g?e.__g|=8:e[Ev]=!0}function Pv(e){void 0!==e.__g?e.__g&=-9:e[Ev]=!1}function Rv(e){return void 0!==e.__g?!!(8&e.__g):!0===e[Ev]}var Dv=/["&<]/;function jv(e){if(0===e.length||!1===Dv.test(e))return e;for(var t=0,n=0,r="",o="";n<e.length;n++){switch(e.charCodeAt(n)){case 34:o=""";break;case 38:o="&";break;case 60:o="<";break;default:continue}
|
|
646
646
|
n!==t&&(r+=e.slice(t,n)),r+=o,t=n+1}return n!==t&&(r+=e.slice(t,n)),r}var Hv=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},Fv=function(e,t,n){return String(e).length>40||-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},$v={},Bv=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","fill-opacity","flex","flex-grow","flex-negative","flex-order","flex-positive","flex-shrink","flood-opacity","font-weight","grid-column","grid-row","line-clamp","line-height","opacity","order","orphans","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","widows","z-index","zoom"]),qv=/[A-Z]/g;function Uv(e){var t="";for(var n in e){var r=e[n];if(null!=r&&""!==r){var o="-"==n[0]?n:$v[n]||($v[n]=n.replace(qv,"-$&").toLowerCase()),i=";";"number"!=typeof r||o.startsWith("--")||Bv.has(o)||(i="px;"),t=t+o+":"+r+i}}return t||void 0}
|
|
647
647
|
function Gv(e,t){return Array.isArray(t)?t.reduce(Gv,e):null!=t&&!1!==t&&e.push(t),e}function Vv(){this.__d=!0}function Wv(e,t){return{__v:e,context:t,props:e.props,setState:Vv,forceUpdate:Vv,__d:!0,__h:new Array(0)}}function Kv(e,t){var n=e.contextType,r=n&&t[n.__c];return null!=n?r?r.props.value:n.__:t}var Yv=[],Xv=[],Zv=new Set(["pre","textarea"]);function Qv(e,n,r,o){var i=t[Tv];t[Tv]=!0;try{return Jv(e,n||{},r,o)}finally{t.__c&&t.__c(e,Xv),t[Tv]=i,Xv.length=0}}function Jv(e,n,r,o,i,a){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return"function"==typeof e?"":jv(e+"");var s=r.pretty,l=s&&"string"==typeof s?s:"\t";if(Array.isArray(e)){for(var c="",u=0;u<e.length;u++)s&&u>0&&(c+="\n"),c+=Jv(e[u],n,r,o,i,a);return c}if(void 0!==e.constructor)return"";t.__b&&t.__b(e);var d,h=e.type,p=e.props,m=!1;if("function"==typeof h){if(m=!0,!r.shallow||!o&&!1!==r.renderRootComponent||h===y){if(h===y){var f=[];return Gv(f,e.props.children),Jv(f,n,r,!1!==r.shallowHighOrder,i,a)}
|
|
@@ -669,7 +669,7 @@ client_version:r.version,annotations:e.map(Cb)}}buildTextExportContent(e,{groupN
|
|
|
669
669
|
${u.join("\n\n")}`}buildCSVExportContent(e,{groupName:t="",defaultAuthority:n="",displayNamesEnabled:r=!1,separator:o=","}={}){const{uri:i,extractUsername:a}=this._exportCommon(e,{displayNamesEnabled:r,defaultAuthority:n}),s=e=>[Mb(new Date(e.created)),a(e),Qr(e)??"",i,t,Ur(e,this._settings),Kr(e)??Yr(e)??"",e.text,e.tags.join(",")].map((e=>function(e,t){return new RegExp(`["\n\r${t}]`).test(e)?`"${e.replace(/"/g,'""')}"`:e}(e,o))).join(o);return`${["Created at","Author","Page","URL","Group","Type","Quote/description","Comment","Tags"].join(o)}\n${e.map((e=>s(e))).join("\n")}`}buildHTMLExportContent(e,{groupName:t="",displayNamesEnabled:n=!1,defaultAuthority:r="",now:o=new Date}={}){const{uri:i,title:a,uniqueUsers:s,replies:l,extractUsername:c}=this._exportCommon(e,{displayNamesEnabled:n,defaultAuthority:r});return function(e,t,n){var r=Object.assign({},Ab,n||{});return r.jsx||(r.attributeHook=null),Qv(e,t,r)}(Ve("html",{lang:"en",children:[Ve("head",{children:[Ve("title",{
|
|
670
670
|
children:`Annotations on "${a}"`}),Ve("meta",{charSet:"UTF-8"})]}),Ve("body",{children:[Ve("section",{children:[Ve("h1",{children:"Summary"}),Ve("p",{children:Ve("time",{dateTime:o.toISOString(),children:Mb(o)})}),Ve("p",{children:Ve("strong",{children:a})}),Ve("p",{children:Ve("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Ve("table",{children:Ve("tbody",{style:{verticalAlign:"top"},children:[Ve("tr",{children:[Ve("td",{children:"Group:"}),Ve("td",{children:t})]}),Ve("tr",{children:[Ve("td",{children:"Total users:"}),Ve("td",{children:s.length})]}),Ve("tr",{children:[Ve("td",{children:"Users:"}),Ve("td",{children:s.join(", ")})]}),Ve("tr",{children:[Ve("td",{children:"Total annotations:"}),Ve("td",{children:e.length})]}),Ve("tr",{children:[Ve("td",{children:"Total replies:"}),Ve("td",{children:l.length})]})]})})]}),Ve("hr",{}),Ve("section",{children:[Ve("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Qr(e),r=Kr(e),o=Yr(e),i=ep(e.text),a=i===`<p>${e.text}</p>`?e.text:i
|
|
671
671
|
;return Ve("article",{children:[Ve("h2",{children:["Annotation ",t+1,":"]}),Ve("table",{children:Ve("tbody",{style:{verticalAlign:"top"},children:[Ve("tr",{children:[Ve("td",{children:"Created at:"}),Ve("td",{children:Ve("time",{dateTime:e.created,children:Mb(new Date(e.created))})})]}),Ve("tr",{children:[Ve("td",{children:"Author:"}),Ve("td",{children:c(e)})]}),n&&Ve("tr",{children:[Ve("td",{children:"Page:"}),Ve("td",{children:n})]}),Ve("tr",{children:[Ve("td",{children:"Type:"}),Ve("td",{children:Ur(e,this._settings)})]}),r&&Ve("tr",{children:[Ve("td",{children:"Quote:"}),Ve("td",{children:Ve("blockquote",{style:{margin:0},children:r})})]}),o&&Ve("tr",{children:[Ve("td",{children:"Description:"}),Ve("td",{children:o})]}),Ve("tr",{children:[Ve("td",{children:"Comment:"}),Ve("td",{dangerouslySetInnerHTML:{__html:a}})]}),e.tags.length>0&&Ve("tr",{children:[Ve("td",{children:"Tags:"}),Ve("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}
|
|
672
|
-
_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>Zi(e,n,t),{uri:i,title:a}=Qi(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>Pr(e))),extractUsername:o}}}Nb.$inject=["settings"];class Ib{constructor(e,t,n){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,l)=>{o();try{const[o,i]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.
|
|
672
|
+
_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>Zi(e,n,t),{uri:i,title:a}=Qi(r);return{uri:i,title:a,uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>Pr(e))),extractUsername:o}}}Nb.$inject=["settings"];class Ib{constructor(e,t,n){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,l)=>{o();try{const[o,i]=await Promise.all([e,n()]),c=function(e,t){let n=e;const r=t.split(".");for(const[e,t]of r.entries()){const o=n[t];if(!o||"url"in o){if(o&&e===r.length-1)return o;break}n=o}return null}(o,t);if(!c)throw new Error(`Missing API route: ${t}`);const u={"Content-Type":"application/json","Hypothesis-Client-Version":"1.1741.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:p}=ci(c.url,a),m=new URL(h);for(const[e,t]of Object.entries(p)){
|
|
673
673
|
const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&m.searchParams.append(e,t.toString())}return await yp(m.toString(),{body:s?JSON.stringify(Cb(s)):null,headers:u,method:c.method,signal:l})}finally{i()}}}(r,e,{getAccessToken:()=>t.getAccessToken(),getClientId:o,onRequestStarted:n.apiRequestStarted,onRequestFinished:n.apiRequestFinished});this.search=i("search"),this.annotation={read:i("annotation.read"),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"),moderate:i("annotation.moderate")},this.group={member:{delete:i("group.member.delete")},members:{read:i("group.members.read")},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")},this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}
|
|
674
674
|
Ib.$inject=["apiRoutes","auth","store"];var Ob,zb,Lb,Pb,Rb,Db={};function jb(){return Lb||(Lb=1,e=Db,t=function(){if(zb)return Ob;function e(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))}return zb=1,Ob=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.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),
|
|
675
675
|
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},e.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){
|
|
@@ -788,8 +788,8 @@ uv("Error connecting to H push notification service:",t);const n=new URL(e).host
|
|
|
788
788
|
this._updateImmediately=e.applyUpdatesImmediately??!0,this._reconnectSetUp||(this._reconnectSetUp=!0,oy(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}GS.$inject=["store","apiRoutes","auth","groups","session","$window"];const VS="hypothesis.user.tags.list",WS="hypothesis.user.tags.map";class KS{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(VS)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${pv(e)}`,"i");return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(WS)||{};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(WS,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(VS,n)}}KS.$inject=["localStorage"];class YS{constructor(e){this._store=e}
|
|
789
789
|
forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}YS.$inject=["store"];class XS{#t=new Map;#n=30;#r;constructor(e){this.#r=e}get cacheSize(){return this.#n}set cacheSize(e){this.#n=e,this.#o()}#o(){for(const e of this.#t.keys()){const t=this.#t.get(e);if(t&&URL.revokeObjectURL(t.url),this.#t.delete(e),this.#t.size<=this.cacheSize)break}}async fetch(e,t={}){const n=this.get(e);if(n)return n;const r=await this.#r.requestThumbnail(e,t),o=await async function(e){const t=new OffscreenCanvas(e.width,e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height);const n=await t.convertToBlob();return URL.createObjectURL(n)}(r),i={url:o,width:r.width,height:r.height};return this.#t.set(e,i),this.#t.size>this.cacheSize&&this.#o(),i}get(e){const t=this.#t.get(e);return t?(this.#t.delete(e),this.#t.set(e,t),t):null}cachedThumbnailTags(){return[...this.#t.keys()]}}XS.$inject=["frameSync"];class ZS extends $f{constructor(e,t){super(),this._store=e,
|
|
790
790
|
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:nv(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)}}ZS.$inject=["store","$window"];const QS=function(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{
|
|
791
|
-
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),JS=function(e){const{version:t,origin:n}=ov(e.location.href);return"1.
|
|
792
|
-
;return e?new URL(e).origin:null}(),n=t?[t]:void 0;NS({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.
|
|
791
|
+
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),JS=function(e){const{version:t,origin:n}=ov(e.location.href);return"1.1741.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1741.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 eA(e,t){e.setClientId(t.clientId)}function tA(e){e.sync()}function nA(e,t){e.load(),t.load()}function rA(e,t,n){e.init(),t.init(),n.init()}function oA(e,t,n){"sidebar"===t.route()&&e.connect().catch((()=>{n.error("Hypothesis failed to connect to the web page. Try reloading the page.",{autoDismiss:!1})}))}QS.sentry&&JS&&function(e){const t=function(){const e=import.meta.url
|
|
792
|
+
;return e?new URL(e).origin:null}(),n=t?[t]:void 0;NS({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1741.0",beforeSend:(e,t)=>{if(IS>=5)return uv("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++IS;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{}return e}});try{hx("host_config",ov(window.location.href))}catch{}hx("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),Zb(((e,t)=>{OS(e,t)}))}(QS.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),eA.$inject=["api","streamer"],tA.$inject=["router"],nA.$inject=["groups","session"],rA.$inject=["autosaveService","persistedDefaults","serviceURL"],
|
|
793
793
|
oA.$inject=["frameSync","store","toastMessenger"];const iA=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",_v)}(),async function(e,t=window){const n=function(e){const t=ov(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl","commentsMode","groupsAllowlist"],r={openSidebar:iv,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:sv(t.origin),ancestorLevel:av(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{
|
|
794
794
|
targetFrame:lv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await rv(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=rv(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=Kn(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(QS).then((e=>{!function(e,t){const n=new U
|
|
795
795
|
;n.register("analytics",wv).register("annotationsExporter",Nb).register("annotationsService",kv).register("annotationActivity",xv).register("api",Ib).register("apiRoutes",Bb).register("auth",Gb).register("autosaveService",Vb).register("dashboard",Wb).register("frameSync",sy).register("groups",uy).register("importAnnotationsService",LS).register("loadAnnotationsService",PS).register("localStorage",DS).register("persistedDefaults",HS).register("router",FS).register("serviceURL",$S).register("session",BS).register("streamer",GS).register("streamFilter",qS).register("tags",KS).register("threadsService",YS).register("thumbnailService",XS).register("toastMessenger",ZS).register("store",{factory:ji}),n.register("$window",{value:window}).register("settings",{value:e}),n.run(tA),n.run(rA),n.run(eA),n.run(nA),n.run(yv),n.run(oA),H(Ve(Qn.Provider,{value:n,children:Ve(Jg,{})}),t)}(e,iA)})).catch((e=>function(e,t){console.error("Failed to start Hypothesis client: ",e),H(Ve(ev,{error:e}),t)}(e,iA)));
|