hypothesis 1.1571.0 → 1.1573.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.
@@ -21,7 +21,7 @@ const{eventTarget:n,eventType:r,listener:o,options:i}=t;n.removeEventListener(r,
21
21
  },h=u(),m=l.current?h.indexOf(l.current):0;d(h,m,t);const p=new ke;p.add(s,"focusin",(e=>{if(e.target===s&&l.current)return void c(l.current);const n=u(),r=n.indexOf(e.target);r>=0&&d(n,r,t)})),p.add(s,"keydown",(e=>{const t=u();let i=t.findIndex((e=>0===e.tabIndex)),a=!1;r&&"ArrowLeft"===e.key||o&&"ArrowUp"===e.key?(0===i?i=n?t.length-1:i:--i,a=!0):r&&"ArrowRight"===e.key||o&&"ArrowDown"===e.key?(i===t.length-1?i=n?0:i:++i,a=!0):"Home"===e.key?(i=0,a=!0):"End"===e.key&&(i=t.length-1,a=!0),a&&(d(t,i,!0,e),e.preventDefault(),e.stopPropagation())}));const f=new MutationObserver((()=>{d()}));return f.observe(s,{subtree:!0,attributes:!0,attributeFilter:["disabled"],childList:!0}),()=>{p.removeAll(),f.disconnect()}}),[t,e,c,r,n,i,o,a])}function Ae(e,t,{enabled:n=!0}={}){le((()=>{if(!n)return()=>{};const r=document.body,o=new ke,i=n=>{e.current&&!n.composedPath().includes(e.current)&&t(n)};return o.add(r,"mousedown",i),o.add(r,"click",i),()=>{o.removeAll()}}),[e,n,t])}function Ee(e,t,{enabled:n=!0}={}){le((()=>{
22
22
  if(!n||!e.current)return()=>{};const r=new ke;return r.add(e.current,"focusout",(n=>{const r=n;e.current&&!e.current.contains(r.relatedTarget)&&t(r)})),()=>{r.removeAll()}}),[e,n,t])}function Te(e,t,{enabled:n=!0}={}){le((()=>{if(!n)return()=>{};const r=document.body,o=new ke;return o.add(r,"keydown",(n=>{e.includes(n.key)&&t(n)})),()=>{o.removeAll()}}),[n,t,e])}function Ce(e,t,n={}){Ae(e,t,n),Ee(e,t,n),Te(["Escape"],t,n)}function Me(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class Ie{constructor(e){Me(this,"_target",void 0),Me(this,"_value",void 0),this._target=e,this._value=null}get current(){return this._value}set current(e){
23
23
  this._value=e,this._updateTarget()}get target(){return this._target}set target(e){e!==this._target&&(this._target=e,this._updateTarget())}_updateTarget(){const e=this._value;"function"==typeof this._target?this._target(e):this._target&&(this._target.current=e)}}function ze(e){const t=ue(new Ie(e));return t.current.target=e,t.current}const Le=1e3,Oe=60*Le,Re=60*Oe;let Pe=new Map;function De(e,t){return t-e}function Fe(e,t,n=window.Intl){const r=JSON.stringify(t);let o=Pe.get(r);return o||(o=new n.DateTimeFormat(void 0,t),Pe.set(r,o)),o.format(e)}const He=[{test:(e,t)=>De(e,t)<30*Le,formatter:()=>"Just now",nextUpdate:1*Le},{test:(e,t)=>De(e,t)<1*Oe,formatter:(e,t)=>`${Math.floor(De(e,t)/Le)} secs ago`,nextUpdate:1*Le},{test:(e,t)=>De(e,t)<1*Re,formatter:(e,t)=>{const n=Math.floor(De(e,t)/Oe);return`${n} min${n>1?"s":""} ago`},nextUpdate:1*Oe},{test:(e,t)=>De(e,t)<24*Re,formatter:(e,t)=>{const n=Math.floor(De(e,t)/Re);return`${n} hr${n>1?"s":""} ago`},nextUpdate:1*Re},{
24
- test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:(e,t,n)=>Fe(e,{month:"short",day:"numeric"},n),nextUpdate:null}],Be={test:()=>!0,formatter:(e,t,n)=>Fe(e,{day:"numeric",month:"short",year:"numeric"},n),nextUpdate:null};function je(e,t){for(const n of He)if(n.test(e,t))return n;return Be}function $e(e){return!isNaN(e.valueOf())}function qe(e,t){let n;const r=new Date(e),o=()=>{const e=function(e,t){if(!e||!$e(e)||!$e(t))return null;let n=je(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5*Le),n=Math.min(n,2073600*Le),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function Ue(e,t,n){return e?je(e,t).formatter(e,t,n):""}function Ge(e,t){return Fe("string"==typeof e?new Date(e):e,{year:"numeric",month:"short",day:"2-digit",weekday:null!=t&&t.includeWeekday?"long":void 0,hour:"2-digit",minute:"2-digit"},null==t?void 0:t.Intl)}var Ve,We={exports:{}};var Ke,Ye=(Ve||(Ve=1,Ke=We,function(){var e={}.hasOwnProperty;function t(){
24
+ test:(e,t)=>e.getFullYear()===t.getFullYear(),formatter:(e,t,n)=>Fe(e,{month:"short",day:"numeric"},n),nextUpdate:null}],Be={test:()=>!0,formatter:(e,t,n)=>Fe(e,{day:"numeric",month:"short",year:"numeric"},n),nextUpdate:null};function je(e,t){for(const n of He)if(n.test(e,t))return n;return Be}function $e(e){return!isNaN(e.valueOf())}function qe(e,t){let n;const r=new Date(e),o=()=>{const e=function(e,t){if(!e||!$e(e)||!$e(t))return null;let n=je(e,t).nextUpdate;return null===n?null:(n=Math.max(n,5*Le),n=Math.min(n,2073600*Le),n)}(r,new Date);if(null===e)return;n=setTimeout((()=>{t(),o()}),e+500)};return o(),()=>clearTimeout(n)}function Ue(e,t,n){return e?je(e,t).formatter(e,t,n):""}function Ge(e,{includeWeekday:t=!1,includeTime:n=!0}={},r){return Fe("string"==typeof e?new Date(e):e,{year:"numeric",month:"short",day:"2-digit",weekday:t?"long":void 0,hour:n?"2-digit":void 0,minute:n?"2-digit":void 0},r)}var Ve,We={exports:{}};var Ke,Ye=(Ve||(Ve=1,Ke=We,function(){var e={}.hasOwnProperty;function t(){
25
25
  for(var e="",t=0;t<arguments.length;t++){var o=arguments[t];o&&(e=r(e,n(o)))}return e}function n(n){if("string"==typeof n||"number"==typeof n)return n;if("object"!=typeof n)return"";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var o="";for(var i in n)e.call(n,i)&&n[i]&&(o=r(o,i));return o}function r(e,t){return t?e?e+" "+t:e+t:e}Ke.exports?(t.default=t,Ke.exports=t):window.classNames=t}()),We.exports),Xe=t(Ye);const Je='a,button:not([role="tab"]),input,select,textarea,[role="grid"],[role="tablist"]';var Ze=0;function Qe(e,t,n,r,i,a){t||(t={});var s,l,c=t;if("ref"in c)for(l in c={},t)"ref"==l?s=t[l]:c[l]=t[l];var u={type:e,props:c,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ze,__i:-1,__u:0,__source:i,__self:a};if("function"==typeof e&&(s=e.defaultProps))for(l in s)void 0===c[l]&&(c[l]=s[l]);return o.vnode&&o.vnode(u),u}
26
26
  var et="/home/runner/work/frontend-shared/frontend-shared/src/components/layout/Overlay.tsx";function tt({children:e,classes:t,elementRef:n,open:r=!0,variant:o="dark",...i}){return r?Qe("div",{"data-component":"Overlay",...i,ref:n,className:Xe("fixed top-0 left-0 w-full h-full z-10 flex items-center justify-center",{"bg-black/50":"dark"===o,"bg-white/50":"light"===o},t),children:e},void 0,0,{fileName:et,lineNumber:35,columnNumber:5},this):null}const nt=j({}),rt=j({});var ot="/home/runner/work/frontend-shared/frontend-shared/src/components/data/Scroll.tsx";function it({children:e,classes:t,elementRef:n,variant:r="raised",...o}){const i=ze(n),a=de((()=>({scrollRef:i})),[i]);return Qe(rt.Provider,{value:a,children:Qe("div",{"data-component":"Scroll",...o,ref:i,className:Xe("min-h-0","h-full w-full overflow-auto",{"scroll-shadows":"raised"===r},t),children:e},void 0,0,{fileName:ot,lineNumber:39,columnNumber:7},this)},void 0,0,{fileName:ot,lineNumber:38,columnNumber:5},this)}
27
27
  var at="/home/runner/work/frontend-shared/frontend-shared/src/components/layout/Card.tsx";function st({children:e,classes:t,elementRef:n,active:r=!1,variant:o="raised",width:i="full",...a}){return Qe("div",{"data-component":"Card",...a,ref:n,className:Xe("rounded-lg border bg-white",{"shadow hover:shadow-md":"raised"===o,"shadow-md":r&&"raised"===o},{"w-full":"full"===i,"w-auto":"auto"===i},t),children:e},void 0,0,{fileName:at,lineNumber:40,columnNumber:5},this)}var lt="/home/runner/work/frontend-shared/frontend-shared/src/components/layout/CardActions.tsx";function ct({children:e,classes:t,elementRef:n,...r}){return Qe("div",{"data-component":"CardActions",...r,className:Xe("flex items-center justify-end space-x-3",t),ref:n,children:e},void 0,0,{fileName:lt,lineNumber:21,columnNumber:5},this)}var ut="/home/runner/work/frontend-shared/frontend-shared/src/components/layout/CardContent.tsx";function dt({children:e,classes:t,elementRef:n,size:r="md",...o}){return Qe("div",{"data-component":"CardContent",...o,
@@ -167,10 +167,10 @@ classes:Xe("w-96 max-w-[85vw]","space-y-2 p-2"),width:"custom",children:[Qe("h2"
167
167
  ;var Hs=Mo((function({annotation:e,annotationsService:t,onReply:n,settings:r,toastMessenger:o}){const i=ms(),a=i.profile(),s=i.isLoggedIn(),l=t=>function(e,t,n){return-1!==e[t].indexOf(n||"")}(e.permissions,t,a.userid),c=l("delete"),u=l("update"),d=function(e){const t=So(e);return!1!==t?.allowFlagging}(r)&&!!a.userid&&a.userid!==e.user,h=function(e){const t=So(e);return!1!==t?.enableShareLinks}(r)&&function(e){return As(e.uri)?e.links?.incontext??e.links?.html??null:e.links?.html??null}(e);return Qe("div",{className:"flex text-[16px]","data-testid":"annotation-action-bar",children:[u&&Qe(kr,{icon:jt,title:"Edit",onClick:()=>{i.createDraft(e,{tags:e.tags,text:e.text,isPrivate:Is(e.permissions)})}}),c&&Qe(kr,{icon:gr,title:"Delete",onClick:async()=>{const n=Ai(e);if(await Dr({title:`Delete ${n.toLowerCase()}?`,message:`Are you sure you want to delete this ${n.toLowerCase()}?`,confirmAction:"Delete"}))try{await t.delete(e),o.success(`${n} deleted`,{visuallyHidden:!0})}catch(e){o.error(e.message)}}}),Qe(kr,{
168
168
  icon:er,title:"Reply",onClick:()=>{s?n():i.openSidebarPanel("loginPrompt")}}),h&&Qe(Fs,{annotation:e,shareUri:h}),d&&!e.flagged&&Qe(kr,{icon:an,title:"Report this annotation to moderators",onClick:()=>{t.flag(e).catch((()=>o.error("Flagging annotation failed")))}}),d&&e.flagged&&Qe(kr,{pressed:!0,icon:ln,title:"Annotation has been reported to the moderators"})]})}),["annotationsService","settings","toastMessenger"]);function Bs({isCollapsed:e,setCollapsed:t,linkStyle:n}){return Qe("div",{className:Xe("absolute block right-0 bottom-0","w-20 bg-gradient-to-l from-white"),children:Qe("div",{className:"flex justify-end",children:Qe(go,{variant:"text",onClick:()=>t(!e),expanded:!e,title:"Toggle visibility of full excerpt text",style:n,underline:"always",inline:!0,children:e?"More":"Less"})})})}const js=()=>{};var $s=Mo((function({children:e,collapse:t=!1,collapsedHeight:n,inlineControls:r=!0,onCollapsibleChanged:o=js,onToggleCollapsed:i=js,overflowThreshold:a=0,settings:s={}}){
169
169
  const[l,c]=ae(!0),u=ue(null),[d,h]=ae(0),m=he((()=>{const e=u.current.clientHeight;h(e);o(e>n+a)}),[n,o,a]);ce((()=>{const e=function(e,t){const n=new ResizeObserver((()=>t(e.clientWidth,e.clientHeight)));return n.observe(e),()=>n.disconnect()}(u.current,m);return m(),e}),[m]);const p=d>n+a,f=p&&(r?l:t),g={};0!==d&&(g["max-height"]=f?n:d);const v=e=>r?c(e):i(e);return Qe("div",{"data-testid":"excerpt-container",className:Xe("relative overflow-hidden","transition-[max-height] ease-in duration-150"),style:g,children:[Qe("div",{className:Xe("inline-block w-full"),"data-testid":"excerpt-content",ref:u,children:e}),Qe("div",{"data-testid":"excerpt-expand",role:"presentation",onClick:()=>v(!1),className:Xe("transition-[opacity] duration-150 ease-linear","absolute w-full bottom-0 h-touch-minimum",{"bg-gradient-to-b from-excerpt-stop-1 via-excerpt-stop-2 to-excerpt-stop-3":!r&&f,"bg-none":r,"opacity-0 pointer-events-none":!f}),title:"Show the full excerpt"}),p&&r&&Qe(Bs,{isCollapsed:l,setCollapsed:v,
170
- linkStyle:To(["selectionFontFamily"],s)})]})}),["settings"]);const qs=String.raw`[\s,.;:|?!'"\-()[\]{}]`,Us=new RegExp(`(^|${qs})@([A-Za-z0-9_][A-Za-z0-9._]+[A-Za-z0-9_])(?=${qs}|$)`,"g");function Gs(e,t){const n=t&&t.link?"link":t?"no-link":"invalid",r=document.createElement("link"===n?"a":"span"),o=e.textContent??"";return r.setAttribute("data-hyp-mention",""),r.setAttribute("data-hyp-mention-type",n),r.textContent=o,"link"===n&&(r.setAttribute("href",t?.link??""),r.setAttribute("target","_blank")),"invalid"!==n&&r.setAttribute("data-userid",e.dataset.userid??""),e.replaceWith(r),[r,t??o]}function Vs(e,t){const n=[...e.slice(0,t).matchAll(new RegExp(qs,"g"))],r=n.length>0?Math.max(...n.map((e=>e.index))):-1,o=e.slice(t).search(new RegExp(qs));return{start:r+1,end:-1===o?e.length:t+o}}function Ws(e,t=16/9){const n=document.createElement("iframe");return n.src=e,n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),function(e,t){e.style.position="absolute",e.style.top="0",e.style.left="0",
171
- e.style.width="100%",e.style.height="100%";const n=document.createElement("div");return n.style.paddingBottom=1/t*100+"%",n.style.position="relative",n.appendChild(e),n}(n,t)}function Ks(e){const t=/(\d+)([hms]?)/g,n={h:3600,m:60,s:1};let r,o=0;for(;null!==(r=t.exec(e));)if(r[2]){const e=r[2];o+=Number(r[1])*n[e]}else o+=+r[1];return o.toString()}function Ys(e,t){const n=function(e){const t=["end","start","t"],n=new URLSearchParams(e.search),r=new URLSearchParams;for(const[e,o]of n)t.includes(e)&&("t"===e?r.append("start",Ks(o)):r.append(e,o));r.sort();let o=r.toString();return o&&(o=`?${o}`),o}(t);return Ws(`https://www.youtube.com/embed/${e}${n}`)}function Xs(e,t,n,{aspectRatio:r}={}){return o=>{if(o.hostname!==e)return null;const i=t.exec(o.pathname);if(!i)return null;const a=i[1];return Ws(n(a),r)}}const Js=[function(e){if("www.youtube.com"!==e.hostname)return null;if(!/\/watch\/?/.test(e.pathname))return null;const t=/[&?]v=([^&#]+)/.exec(e.search);return t?Ys(t[1],e):null},function(e){
172
- if("youtu.be"!==e.hostname)return null;const t=/^\/([^/]+)\/?$/.exec(e.pathname);return t?Ys(t[1],e):null},Xs("vimeo.com",/^\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),Xs("vimeo.com",/^\/channels\/[^/]+\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),function(e){if("archive.org"!==e.hostname)return null;const t=/^\/(embed|details)\/(.+)/.exec(e.pathname);if(!t)return null;let n=t[2];const r=new URLSearchParams(e.search);let o=r.get("start"),i=r.get("end");if(!o){const e=n.match(/\/start\/([^/]+)/);e&&(o=e[1],n=n.replace(e[0],""))}if(!i){const e=n.match(/\/end\/([^/]+)/);e&&(i=e[1],n=n.replace(e[0],""))}const a=new URL(`https://archive.org/embed/${n}`);return o&&a.searchParams.append("start",o),i&&a.searchParams.append("end",i),Ws(a.href)},function(e){return e.pathname.endsWith(".mp3")||e.pathname.endsWith(".ogg")||e.pathname.endsWith(".wav")?function(e){const t=document.createElement("audio");return t.controls=!0,t.src=e,t}(e.href):null}];function Zs(e){
173
- if(e.href!==e.textContent)try{const t=encodeURI(e.textContent);if(e.href!==t)return null}catch{return null}const t=function(e){let t,n;for(n=0;n<Js.length;n++)if(t=Js[n](e),t)return t;return null}(e);return t&&e.parentElement.replaceChild(t,e),t}const{entries:Qs,setPrototypeOf:el,isFrozen:tl,getPrototypeOf:nl,getOwnPropertyDescriptor:rl}=Object;let{freeze:ol,seal:il,create:al}=Object,{apply:sl,construct:ll}="undefined"!=typeof Reflect&&Reflect;ol||(ol=function(e){return e}),il||(il=function(e){return e}),sl||(sl=function(e,t,n){return e.apply(t,n)}),ll||(ll=function(e,t){return new e(...t)})
170
+ linkStyle:To(["selectionFontFamily"],s)})]})}),["settings"]);const qs=String.raw`[\s,.;:|?!'"\-()[\]{}]`,Us=new RegExp(`(^|${qs})@([A-Za-z0-9_][A-Za-z0-9._]+[A-Za-z0-9_])(?=${qs}|$)`,"g");function Gs(e,t){const n=e.textContent??"",r=t??n;if(e.hasAttribute("data-hyp-mention-type"))return[e,r];const o=t&&t.link?"link":t?"no-link":"invalid",i=document.createElement("link"===o?"a":"span");return i.setAttribute("data-hyp-mention",""),i.setAttribute("data-hyp-mention-type",o),i.textContent=n,"link"===o&&(i.setAttribute("href",t?.link??""),i.setAttribute("target","_blank")),"invalid"!==o&&i.setAttribute("data-userid",e.dataset.userid??""),e.replaceWith(i),[i,r]}function Vs(e,t){const n=[...e.slice(0,t).matchAll(new RegExp(qs,"g"))],r=n.length>0?Math.max(...n.map((e=>e.index))):-1,o=e.slice(t).search(new RegExp(qs));return{start:r+1,end:-1===o?e.length:t+o}}function Ws(e,t=16/9){const n=document.createElement("iframe");return n.src=e,n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),
171
+ function(e,t){e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%";const n=document.createElement("div");return n.style.paddingBottom=1/t*100+"%",n.style.position="relative",n.appendChild(e),n}(n,t)}function Ks(e){const t=/(\d+)([hms]?)/g,n={h:3600,m:60,s:1};let r,o=0;for(;null!==(r=t.exec(e));)if(r[2]){const e=r[2];o+=Number(r[1])*n[e]}else o+=+r[1];return o.toString()}function Ys(e,t){const n=function(e){const t=["end","start","t"],n=new URLSearchParams(e.search),r=new URLSearchParams;for(const[e,o]of n)t.includes(e)&&("t"===e?r.append("start",Ks(o)):r.append(e,o));r.sort();let o=r.toString();return o&&(o=`?${o}`),o}(t);return Ws(`https://www.youtube.com/embed/${e}${n}`)}function Xs(e,t,n,{aspectRatio:r}={}){return o=>{if(o.hostname!==e)return null;const i=t.exec(o.pathname);if(!i)return null;const a=i[1];return Ws(n(a),r)}}const Js=[function(e){if("www.youtube.com"!==e.hostname)return null;if(!/\/watch\/?/.test(e.pathname))return null
172
+ ;const t=/[&?]v=([^&#]+)/.exec(e.search);return t?Ys(t[1],e):null},function(e){if("youtu.be"!==e.hostname)return null;const t=/^\/([^/]+)\/?$/.exec(e.pathname);return t?Ys(t[1],e):null},Xs("vimeo.com",/^\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),Xs("vimeo.com",/^\/channels\/[^/]+\/([^/?#]+)\/?$/,(e=>`https://player.vimeo.com/video/${e}`)),function(e){if("archive.org"!==e.hostname)return null;const t=/^\/(embed|details)\/(.+)/.exec(e.pathname);if(!t)return null;let n=t[2];const r=new URLSearchParams(e.search);let o=r.get("start"),i=r.get("end");if(!o){const e=n.match(/\/start\/([^/]+)/);e&&(o=e[1],n=n.replace(e[0],""))}if(!i){const e=n.match(/\/end\/([^/]+)/);e&&(i=e[1],n=n.replace(e[0],""))}const a=new URL(`https://archive.org/embed/${n}`);return o&&a.searchParams.append("start",o),i&&a.searchParams.append("end",i),Ws(a.href)},function(e){return e.pathname.endsWith(".mp3")||e.pathname.endsWith(".ogg")||e.pathname.endsWith(".wav")?function(e){const t=document.createElement("audio")
173
+ ;return t.controls=!0,t.src=e,t}(e.href):null}];function Zs(e){if(e.href!==e.textContent)try{const t=encodeURI(e.textContent);if(e.href!==t)return null}catch{return null}const t=function(e){let t,n;for(n=0;n<Js.length;n++)if(t=Js[n](e),t)return t;return null}(e);return t&&e.parentElement.replaceChild(t,e),t}const{entries:Qs,setPrototypeOf:el,isFrozen:tl,getPrototypeOf:nl,getOwnPropertyDescriptor:rl}=Object;let{freeze:ol,seal:il,create:al}=Object,{apply:sl,construct:ll}="undefined"!=typeof Reflect&&Reflect;ol||(ol=function(e){return e}),il||(il=function(e){return e}),sl||(sl=function(e,t,n){return e.apply(t,n)}),ll||(ll=function(e,t){return new e(...t)})
174
174
  ;const cl=Nl(Array.prototype.forEach),ul=Nl(Array.prototype.lastIndexOf),dl=Nl(Array.prototype.pop),hl=Nl(Array.prototype.push),ml=Nl(Array.prototype.splice),pl=Nl(String.prototype.toLowerCase),fl=Nl(String.prototype.toString),gl=Nl(String.prototype.match),vl=Nl(String.prototype.replace),bl=Nl(String.prototype.indexOf),yl=Nl(String.prototype.trim),_l=Nl(Object.prototype.hasOwnProperty),wl=Nl(RegExp.prototype.test),xl=(kl=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return ll(kl,t)});var kl;function Nl(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return sl(e,t,r)}}function Sl(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:pl;el&&el(e,null);let r=t.length;for(;r--;){let o=t[r];if("string"==typeof o){const e=n(o);e!==o&&(tl(t)||(t[r]=e),o=e)}e[o]=!0}return e}function Al(e){for(let t=0;t<e.length;t++){_l(e,t)||(e[t]=null)}return e}function El(e){const t=al(null);for(const[n,r]of Qs(e)){
175
175
  _l(e,n)&&(Array.isArray(r)?t[n]=Al(r):r&&"object"==typeof r&&r.constructor===Object?t[n]=El(r):t[n]=r)}return t}function Tl(e,t){for(;null!==e;){const n=rl(e,t);if(n){if(n.get)return Nl(n.get);if("function"==typeof n.value)return Nl(n.value)}e=nl(e)}return function(){return null}}
176
176
  const Cl=ol(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ml=ol(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Il=ol(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),zl=ol(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ll=ol(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ol=ol(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Rl=ol(["#text"]),Pl=ol(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Dl=ol(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Fl=ol(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Hl=ol(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Bl=il(/\{\{[\w\W]*|[\w\W]*\}\}/gm),jl=il(/<%[\w\W]*|[\w\W]*%>/gm),$l=il(/\$\{[\w\W]*/gm),ql=il(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ul=il(/^aria-[\-\w]+$/),Gl=il(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Vl=il(/^(?:\w+script|data):/i),Wl=il(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Kl=il(/^html$/i),Yl=il(/^[a-z][.\w]*(-[.\w]+)+$/i)
@@ -531,54 +531,55 @@ r||(o=n.subParser("makeMarkdown.pre")(e,t)+"\n\n");break;case"table":r||(o=n.sub
531
531
  ;for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t);r+="~~"}return r})),n.subParser("makeMarkdown.strong",(function(e,t){var r="";if(e.hasChildNodes()){r+="**";for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t);r+="**"}return r})),n.subParser("makeMarkdown.table",(function(e,t){var r,o,i="",a=[[],[]],s=e.querySelectorAll("thead>tr>th"),l=e.querySelectorAll("tbody>tr");for(r=0;r<s.length;++r){var c=n.subParser("makeMarkdown.tableCell")(s[r],t),u="---";if(s[r].hasAttribute("style"))switch(s[r].getAttribute("style").toLowerCase().replace(/\s/g,"")){case"text-align:left;":u=":---";break;case"text-align:right;":u="---:";break;case"text-align:center;":u=":---:"}a[0][r]=c.trim(),a[1][r]=u}for(r=0;r<l.length;++r){var d=a.push([])-1,h=l[r].getElementsByTagName("td");for(o=0;o<s.length;++o){var m=" ";void 0!==h[o]&&(m=n.subParser("makeMarkdown.tableCell")(h[o],t)),a[d].push(m)}}var p=3;for(r=0;r<a.length;++r)for(o=0;o<a[r].length;++o){
532
532
  var f=a[r][o].length;f>p&&(p=f)}for(r=0;r<a.length;++r){for(o=0;o<a[r].length;++o)1===r?":"===a[r][o].slice(-1)?a[r][o]=n.helper.padEnd(a[r][o].slice(-1),p-1,"-")+":":a[r][o]=n.helper.padEnd(a[r][o],p,"-"):a[r][o]=n.helper.padEnd(a[r][o],p);i+="| "+a[r].join(" | ")+" |\n"}return i.trim()})),n.subParser("makeMarkdown.tableCell",(function(e,t){var r="";if(!e.hasChildNodes())return"";for(var o=e.childNodes,i=o.length,a=0;a<i;++a)r+=n.subParser("makeMarkdown.node")(o[a],t,!0);return r.trim()})),n.subParser("makeMarkdown.txt",(function(e){var t=e.nodeValue;return t=(t=t.replace(/ +/g," ")).replace(/¨NBSP;/g," "),t=(t=(t=(t=(t=(t=(t=(t=(t=n.helper.unescapeHTMLEntities(t)).replace(/([*_~|`])/g,"\\$1")).replace(/^(\s*)>/g,"\\$1>")).replace(/^#/gm,"\\#")).replace(/^(\s*)([-=]{3,})(\s*)$/,"$1\\$2$3")).replace(/^( {0,3}\d+)\./gm,"$1\\.")).replace(/^( {0,3})([+-])/gm,"$1\\$2")).replace(/]([\s]*)\(/g,"\\]$1\\(")).replace(/^ {0,3}\[([\S \t]*?)]:/gm,"\\[$1]:")})),e.exports?e.exports=n:this.showdown=n}).call(op)}(rp)),
533
533
  rp.exports),ap=t(ip);const sp=ic(window);function lp(){return[{type:"output",filter:function(e){return e.replace(/<a href=/g,'<a target="_blank" href=')}}]}let cp;function up(e){return"{math:"+e.toString()+"}"}function dp(e){const t=function(e){const t=[];let n=0,r=e;for(;;){const e=r.indexOf("$$",n),o=r.indexOf("\\(",n);if(-1===e&&-1===o)break;let i,a;if(-1!==e&&(-1===o||e<o)?(i=e,a=r.indexOf("$$",i+2)):(i=o,a=r.indexOf("\\)",i+2)),-1===a)break;a+=2;const s=t.length+1,l=up(s);let c;t.push({id:s,expression:r.slice(i+2,a-2),inline:-1!==o}),c=-1!==o?l:"\n\n"+l+"\n\n",r=r.slice(0,i)+c+r.slice(a),n=i+c.length}return{mathBlocks:t,content:r}}(e),n=sp.sanitize(function(e){return cp||(cp=new ap.Converter({extensions:[lp],simplifiedAutoLink:!0,excludeTrailingPunctuationFromURLs:!0,literalMidWordUnderscores:!0,strikethrough:!0})),cp.makeHtml(e)}(t.content)),r=function(e,t){return t.reduce(((e,t)=>{let n;try{n=t.inline?np.renderToString(t.expression):np.renderToString(t.expression,{displayMode:!0})}catch{
534
- n=sc(t.expression)}return e.replace(up(t.id),n)}),e)}(n,t.mathBlocks);return r}function hp({children:e,classes:t,...n}){return Qe("div",{dir:"auto",lang:"",className:Xe("StyledText",t),...n,children:e})}function mp({content:e}){return"string"==typeof e?Qe(x,{children:["No user with username ",Qe("span",{className:"font-bold",children:e})," ","exists"]}):Qe("div",{className:"flex flex-col gap-y-1.5",children:[Qe("div",{"data-testid":"username",className:"text-md font-bold",children:["@",e.username]}),e.display_name&&Qe("div",{"data-testid":"display-name",className:"text-color-text-light",children:e.display_name})]})}function pp(e){const{markdown:t,classes:n,style:r,mentions:o=[],mentionsEnabled:i=!1,setTimeout_:a=setTimeout,clearTimeout_:s=clearTimeout}=e,l=de((()=>t?dp(t):""),[t]),c=ue(null),u=ue(null),d=ue(new Map),[h,m]=ae(null),p=ue(),f=he((e=>{p.current&&s(p.current);const t=()=>{m(e),p.current=null};null===e?t():p.current=a(t,400)}),[s,a]);return le((()=>()=>{p.current&&s(p.current)}),[s]),le((()=>{
535
- !function(e,{className:t}={}){const n=Array.from(e.getElementsByTagName("a"));for(const e of n){const n=Zs(e);n&&(t?n.className=t:n.style.width="350px")}}(c.current,{className:"w-full md:w-[380px]"})}),[t]),le((()=>{d.current=function(e,t){const n=e.querySelectorAll("a[data-hyp-mention]:not([data-hyp-mention-type])"),r=new Map;for(const e of n){const n=e,o=n.dataset.userid,i=o?t.find((e=>e.userid===o)):void 0;r.set(...Gs(n,i))}return r}(c.current,o)}),[o]),Qe("div",{className:"w-full break-anywhere cursor-text",children:Qe(hp,{classes:Xe({relative:i}),children:[Qe("div",{className:n,"data-testid":"markdown-text",ref:c,dangerouslySetInnerHTML:{__html:l},style:r,onMouseEnterCapture:i?({target:e})=>{const t=e,n=d.current.get(t);n&&(f(n),u.current=t)}:void 0,onMouseLeaveCapture:i?()=>{f(null),u.current=null}:void 0}),i&&Qe(Jr,{open:!!h,onClose:()=>f(null),anchorElementRef:u,classes:"px-3 py-2",children:null!==h&&Qe(mp,{content:h})})]})})}function fp({children:e}){return Qe("ul",{
536
- className:"flex flex-wrap gap-2 leading-none","aria-label":"Annotation tags",children:e})}function gp({href:e,onRemoveTag:t,tag:n}){return Qe("li",{className:"flex items-center border rounded bg-grey-0",children:[Qe("div",{className:"grow px-1.5 py-1 touch:p-2",children:e?Qe(po,{variant:"text-light",href:e,lang:"",target:"_blank","aria-label":`Tag: ${n}`,title:`View annotations with tag: ${n}`,underline:"none",children:n}):Qe("span",{className:"text-color-text-light cursor-default","aria-label":`Tag: ${n}`,lang:"",children:n})}),t&&Qe("button",{className:Xe("px-1.5 py-1 touch:p-2","border-l rounded rounded-l-none","text-grey-6 hover:text-color-text hover:bg-grey-2","transition-colors duration-200","focus-visible-ring ring-inset"),onClick:()=>{t(n)},title:`Remove tag: ${n}`,children:Qe(yt,{className:"font-base w-em h-em",title:`Remove ${n}`})})]})}function vp({classes:e,setCollapsed:t,collapsed:n}){const r=n?"More":"Less";return Qe(br,{classes:Xe("text-grey-7 font-normal",e),expanded:!n,onClick:()=>t(!n),
537
- title:`Toggle visibility of full annotation text: Show ${r}`,children:Qe("div",{className:"flex items-center gap-x-2",children:[Qe(n?Qt:Rt,{className:"w-3 h-3"}),Qe("div",{children:r})]})})}sp.addHook("afterSanitizeAttributes",(e=>{"target"in e&&e.setAttribute("target","_blank")}));var bp=Mo((function({annotation:e,settings:t}){const[n,r]=ae(!0),[o,i]=ae(!1),a=ms(),s=a.defaultAuthority(),l=a.getDraft(e),c=a.isFeatureEnabled("at_mentions"),u=l?.tags??e.tags,d=l?.text??e.text,h=d.length>0,m=u.length>0,p=To(["annotationFontFamily"],t),f=de((()=>e&&!ui(e?.user,s)),[e,s]),g=e=>a.getLink("search.tag",{tag:e});return Qe("div",{className:"space-y-4",children:[h&&Qe($s,{collapse:n,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:i,onToggleCollapsed:r,overflowThreshold:20,children:Qe(pp,{markdown:d,classes:Xe({"p-redacted-text":wi(e)}),style:p,mentions:e.mentions,mentionsEnabled:c})}),(o||m)&&Qe("div",{className:"flex flex-row gap-x-2",children:[Qe("div",{className:"grow",children:m&&Qe(fp,{
538
- children:u.map((e=>Qe(gp,{tag:e,href:f?g(e):void 0},e)))})}),o&&Qe("div",{children:Qe(vp,{classes:Xe("-mt-3"),collapsed:n,setCollapsed:r})})]})]})}),["settings"]);let yp,_p=function(e){return e.ANCHOR_LINK="ANCHOR_LINK",e.IMAGE_LINK="IMAGE_LINK",e}({});function wp(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,i+=r.length-n):i<=t||(o<=t&&i>=t+n?i+=r.length-n:o<t&&i<t+n?o=t:o<t+n&&i>t+n?i+=r.length-n:t<o&&t+n>i&&(o=t,i=t+n)),{text:e.text.slice(0,t)+r+e.text.slice(t+n),selectionStart:o,selectionEnd:i}}function xp(e,t=_p.ANCHOR_LINK){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===_p.IMAGE_LINK&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=wp(e,e.selectionStart,n.length,o+"["+t+"]("+n+")"),r.selectionStart=e.selectionStart+o.length+1,r.selectionEnd=r.selectionStart+t.length,r}{const t=o+"["+n+"](",i="http://insert-your-link-here.com";return r=wp(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,
539
- r.selectionEnd=r.selectionStart+i.length,r}}function kp(e,t,n,r){void 0===n&&(n=t);const o=e.text.slice(e.selectionStart-t.length,e.selectionStart),i=e.text.slice(e.selectionEnd,e.selectionEnd+t.length);let a=e;return e.selectionStart===e.selectionEnd&&r&&(a=wp(e,e.selectionStart,0,r),a.selectionStart=a.selectionEnd-r.length),o===t&&i===n?(a=wp(a,a.selectionStart-t.length,t.length,""),a=wp(a,a.selectionEnd,n.length,"")):(a=wp(a,a.selectionStart,0,t),a=wp(a,a.selectionEnd,0,n)),a}function Np(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function Sp(e,t,n,r){let o=function(e,t){const n=e.lastIndexOf("\n",t);return n<0?0:n+1}(e.text,t),i=Np(e.text,t),a=0;for(;i<=Np(e.text,n);){const t=i===e.text.length,s=i-o,l=Np((e=r(e,o,i,a)).text,o)-o;if(n+=l-s,t)break;o=o+l+1,i=Np(e.text,o),a+=1}return e}function Ap(e,t){const n=e.selectionStart,r=e.selectionEnd,o=e=>"function"==typeof t?t(e):t;let i=!0;return Sp(e,n,r,((e,t,n,r)=>{const a=o(r);return e.text.slice(t,t+a.length)!==a&&(i=!1),e})),
540
- Sp(e,n,r,i?(e,t,n,r)=>wp(e,t,o(r).length,""):(e,t,n,r)=>{const i=o(r);return e.text.slice(t,t+i.length)===i?e:wp(e,t,0,i)})}const Ep=!1;function Tp({users:e,onSelectUser:t,highlightedSuggestion:n,usersListboxId:r,...o}){return Qe(Jr,{...o,classes:"p-1",children:Qe("ul",{className:"flex-col gap-y-0.5",role:"listbox","aria-orientation":"vertical",id:r,children:[e.map(((e,o)=>Qe("li",{id:`${r}-${e.username}`,className:Xe("flex justify-between items-center gap-x-2","rounded p-2 hover:bg-grey-2",{"bg-grey-2":n===o}),onClick:n=>{n.stopPropagation(),t(e)},role:"option","aria-selected":n===o,children:[Qe("span",{className:"truncate",children:e.username}),Qe("span",{className:"text-color-text-light",children:e.displayName})]},e.username))),0===e.length&&Qe("li",{className:"italic p-2","data-testid":"suggestions-fallback",children:"No matches. You can still write the username"})]})})}const Cp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"}
541
- ;function Mp({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=de((()=>zs()?"Cmd":"Ctrl"),[]);let s=i;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?Qe(br,{classes:"p-1.5 text-grey-7 hover:text-grey-9",...l,size:"custom",variant:"custom",children:n}):Qe(kr,{classes:"px-2 py-2.5",...l,children:t&&Qe(t,{className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function Ip({classes:e,containerRef:t,mentionsEnabled:n,usersForMentions:r,onEditText:o,onKeyDown:i,...a}){const[s,l]=ae(!1),[c,u]=ae(),d=ze(t),[h,m]=ae(0),p=ue(null),f=de((()=>n&&void 0!==c?r.filter((e=>!c||`${e.username} ${e.displayName??""}`.toLowerCase().match(c.toLowerCase()))).slice(0,10):[]),[c,n,r]),g=he((e=>{if(!n)return;const{x:t,y:r}=function(e){yp||(yp=document.createElement("div"),document.body.append(yp));try{const t=e.getBoundingClientRect(),n=window.getComputedStyle(e);yp.style.font=n.font,yp.style.padding=n.padding,yp.style.whiteSpace="pre-wrap",
542
- yp.style.wordWrap="break-word",yp.style.position="fixed",Ep||(yp.style.visibility="hidden"),yp.style.width=`${t.width}px`,yp.style.height=`${t.height}px`,yp.style.top=`${t.top}px`,yp.style.left=`${t.left}px`;const r=e.selectionStart,o=document.createElement("span");o.style.display="inline-block",o.style.verticalAlign="bottom";const i=e.value.substring(0,r),a=e.value.slice(r),s="\nx";yp.innerHTML="",yp.append(i,o,a,s),yp.style.overflowY="auto",yp.scrollTop=e.scrollTop;const l=o.getBoundingClientRect();return{x:l.left-t.left,y:l.top-t.top}}finally{yp.remove(),yp=void 0}}(e);p.current&&(p.current.style.transform=`translate(${t}px, ${r}px)`);const o=function(e,t){const{start:n}=Vs(e,t);return e.slice(n,t)}(e.value,e.selectionStart),i=o.startsWith("@");l(i),u(i?o.substring(1):void 0),i||m(0)}),[n]),v=he((e=>{const t=d.current,{value:n}=t,{start:r,end:i}=Vs(n,t.selectionStart),a=`${n.slice(0,r)}@${e.username} `,s=n.slice(i);t.value=`${a}${s}`,t.selectionStart=a.length,t.selectionEnd=a.length,t.focus(),o(t.value),
543
- l(!1),m(0)}),[o,d]),b=pe(),y=de((()=>{if(!s)return{};const e=f[h],t=e?`${b}-${e.username}`:void 0;return{role:"combobox","aria-controls":b,"aria-expanded":!0,"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":t}}),[h,b,s,f]);return Qe("div",{className:"relative",children:[Qe("textarea",{className:Xe("border rounded p-2","text-color-text-light bg-grey-0","focus:bg-white focus:outline-none focus:shadow-focus-inner",e),onInput:e=>o(e.target.value),...a,onKeyUp:e=>{["Escape","Enter"].includes(e.key)||g(e.target)},onKeyDown:e=>{i?.(e),s&&0!==f.length&&("ArrowDown"===e.key?(e.preventDefault(),m((e=>Math.min(e+1,f.length-1)))):"ArrowUp"===e.key?(e.preventDefault(),m((e=>Math.max(e-1,0)))):"Enter"===e.key&&(e.preventDefault(),v(f[h])))},onClick:e=>{e.stopPropagation(),g(e.target)},ref:d,...y}),Qe("div",{ref:p,className:"absolute top-0 left-0 w-0 h-0 pointer-events-none"}),n&&Qe(Tp,{open:s,onClose:()=>l(!1),anchorElementRef:p,users:f,highlightedSuggestion:h,onSelectUser:v,usersListboxId:b})]
544
- })}function zp({isPreviewing:e,onCommand:t,onTogglePreview:n,showHelpLink:r}){const o=ue(null);return Se(o),Qe("div",{className:Xe("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:o,children:[Qe(Mp,{disabled:e,icon:Wt,onClick:()=>t("bold"),shortcutKey:Cp.bold,title:"Bold"}),Qe(Mp,{disabled:e,icon:Yt,onClick:()=>t("italic"),shortcutKey:Cp.italic,title:"Italic"}),Qe(Mp,{disabled:e,icon:Gt,onClick:()=>t("quote"),shortcutKey:Cp.quote,title:"Quote"}),Qe(Mp,{disabled:e,icon:An,onClick:()=>t("link"),shortcutKey:Cp.link,title:"Insert link"}),Qe(Mp,{disabled:e,icon:xn,onClick:()=>t("image"),shortcutKey:Cp.image,title:"Insert image"}),Qe(Mp,{disabled:e,icon:qt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Qe(Mp,{disabled:e,icon:Tn,onClick:()=>t("numlist"),shortcutKey:Cp.numlist,title:"Numbered list"}),Qe(Mp,{
545
- disabled:e,icon:Mn,onClick:()=>t("list"),shortcutKey:Cp.list,title:"Bulleted list"}),Qe("div",{className:"grow flex justify-end",children:[r&&Qe(po,{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:Qe("div",{className:Xe("flex justify-center items-center","touch:h-touch-minimum touch:w-touch-minimum","px-2 py-2.5 touch:p-0"),children:Qe(gn,{className:"w-2.5 h-2.5"})})}),Qe(Mp,{label:e?"Write":"Preview",onClick:n})]})]})}function Lp({mentionsEnabled:e=!1,label:t,onEditText:n=(()=>{}),text:r,textStyle:o={},showHelpLink:i=!0,usersForMentions:a,mentions:s}){const[l,c]=ae(!1),u=ue(null),d=de((()=>function(e){const t=document.createElement("div");t.innerHTML=e;for(const e of t.querySelectorAll("a[data-hyp-mention]"))e.replaceWith(e.textContent??"");return t.innerHTML}(r)),[r]);le((()=>{l||u.current?.focus()}),[l]);const h=e=>{
546
- u.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)?kp(e,"$$","$$","Insert LaTeX"):kp(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>kp(e,"**","**","Bold")));break;case"italic":n((e=>kp(e,"*","*","Italic")));break;case"quote":n((e=>Ap(e,"> ")));break;case"link":n((e=>xp(e)));break;case"image":n((e=>xp(e,_p.IMAGE_LINK)));break;case"math":n(r);break;case"numlist":n((e=>Ap(e,(e=>`${e+1}. `))));break;case"list":n((e=>Ap(e,"* ")))}}(e,u.current),n(u.current.value))};return Qe("div",{className:"leading-none",children:[Qe(zp,{onCommand:h,isPreviewing:l,onTogglePreview:()=>c(!l),showHelpLink:i}),l?Qe(pp,{markdown:r,classes:"border bg-grey-1 p-2",style:o,mentions:s,mentionsEnabled:e}):Qe(Ip,{"aria-label":t,placeholder:t,dir:"auto",
547
- classes:Xe("w-full min-h-[8em] resize-y","rounded-t-none","text-base touch:text-touch-base"),containerRef:u,onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(const[t,n]of Object.entries(Cp))n===e.key&&(e.stopPropagation(),e.preventDefault(),h(t))},onEditText:n,value:d,style:o,mentionsEnabled:e,usersForMentions:a})]})}const Op=e=>e;function Rp({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Op,onSelectItem:i,open:a=!1}){const s=de((()=>r.map(((t,r)=>{const a=n?{id:`${n}${r}`}:{};return Qe("li",{role:"option","aria-selected":e===r,className:Xe("flex items-center","border-l-4 py-1 px-3 cursor-pointer hover:bg-grey-2","touch:h-touch-minimum",{"border-brand bg-grey-1":e===r,"border-transparent":e!==r}),onClick:()=>{i(t)},...a,children:o(t,r)},`AutocompleteList-${r}`)}))),[e,n,r,o,i]),l=t?{id:t}:{},c=0===r.length||!a;return Qe("div",{className:"relative",children:Qe("div",{className:Xe({hidden:c},"absolute top-[3px] z-3","min-w-[10em]"),"data-testid":"autocomplete-list-container",children:Qe(st,{width:"auto",
548
- classes:"overflow-hidden",children:[Qe("ul",{tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s}),Qe(Rs,{direction:"up",classes:"top-[-8px] left-2"})]})})})}let Pp=0;var Dp=Mo((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((()=>(++Pp,`TagEditor-${Pp}`))),m=ue(null);Ce(m,(()=>d(!1)),{enabled:u});const p=()=>i.current.value.trim(),f=()=>p()&&p().length>0,g=()=>{i.current.value="",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)},y=l>=0?`${h}-AutocompleteList-item-${l}`:"";return Qe("div",{className:"space-y-4",children:[Qe(fp,{children:r.map((e=>Qe(gp,{onRemoveTag:t,tag:e},e)))}),Qe("div",{id:h,"data-testid":"combobox-container",ref:m,children:[Qe(Ur,{onInput:()=>{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=>{
549
- 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":y,"aria-controls":`${h}-AutocompleteList`,"aria-expanded":u,"aria-label":"Add tags",dir:"auto",role:"combobox",classes:Xe("text-base touch:text-touch-base")}),Qe(Rp,{id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{const t=p().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Qe("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Qe("span",{children:[Qe("strong",{children:r}),o,Qe("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"])
550
- ;function Fp(){return Qe("div",{className:"pt-2 border-t text-xs leading-none",children:Qe(po,{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:Qe("div",{className:"flex items-center",children:[Qe(St,{className:"w-[10px] h-[10px]"}),Qe(Et,{className:"w-[10px] h-[10px] ml-px"}),Qe("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})})}function Hp(e){return null!==e.offsetParent}function Bp({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 Qe("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Hp);let r=n.findIndex((e=>e.contains(document.activeElement))),i=!1;switch(e.key){
551
- 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 jp=!1;const $p=()=>{};function qp({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||$p);const m=ue(d);le((()=>{"function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{if("mousedown"===e.type)jp=!0;else if("click"===e.type&&jp)return jp=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=he((()=>h(!1)),[h]),g=ue(null);Ce(g,f,{enabled:d});const v=e=>e.stopPropagation();return Qe("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Qe("button",{
552
- "aria-expanded":d?"true":"false","aria-haspopup":!0,className:Xe("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:Qe("span",{className:"flex items-center gap-x-1",children:[a,c&&Qe("span",{className:Xe({"rotate-180 text-color-text":d}),children:Qe(Fn,{className:"w-2.5 h-2.5"})})]})}),d&&Qe("div",{className:Xe("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:Qe(Bp,{visible:!0,children:t})})]})}function Up({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?Pn:Fn;return Qe("div",{"data-testid":"submenu-toggle",role:"none",
553
- className:Xe("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:Qe(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function Gp({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d,submenuToggleTitle:h}){const m=ue(null);let p,f;const g="boolean"==typeof a,v="boolean"==typeof o;le((()=>()=>{clearTimeout(p)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},y=t?Qe(t,{className:"h-3 w-3"}):null,_=i?null:y,w=i?y:null,k=!!w,N=Qe(x,{children:[(l||i||!!_)&&Qe("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??_}),Qe("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s
554
- }),k&&Qe("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Qe(Up,{title:h??("string"==typeof s?`Show actions for ${s}`:"Toggle submenu"),isExpanded:a,onToggleSubmenu:u})]}),S=Xe("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o,"cursor-pointer":!n},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1":i||r,"hover:bg-grey-3":!n&&(i||r),"bg-white":!i&&!r,"hover:bg-grey-1":!n&&!i&&!r,"pr-1":!g},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return f=e?Qe("a",{ref:m,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:N}):Qe("div",{ref:m,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem",
555
- "aria-checked":v?o:void 0,"aria-haspopup":g,"aria-expanded":g?a:void 0,children:N}),Qe(x,{children:[f,g&&Qe(No,{direction:a?"in":"out",children:Qe(Bp,{closeMenu:e=>{u&&u(e),p=setTimeout((()=>{m.current.focus()}))},visible:a,className:"border-y border-grey-3",children:d})})]})}var Vp=Mo((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=To(["ctaTextColor","ctaBackgroundColor"],a),l=Qe("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Qe(Fn,{className:"w-4 h-4"})});return Qe("div",{className:"flex flex-row gap-x-3",children:[Qe("div",{className:"flex relative",children:[Qe(br,{classes:Xe("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]}),Qe("div",{className:Xe("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Qe(qp,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,
556
- menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Qe(Gp,{icon:"open"===e.type?un:pn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Qe(Gp,{icon:zn,label:"Only Me",isSelected:n,onClick:()=>i(!0)})]})})]}),Qe("div",{children:Qe(br,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Qe(yt,{}),"Cancel"]})})]})}),["settings"]);var Wp=Mo((function({annotation:e,draft:t,annotationsService:n,groups:r,settings:o,tags:i,toastMessenger:a}){const[s,l]=ae(null),c=ms(),u=c.getGroup(e.group),d=de((()=>fi(e)),[e]),h=!t.isPrivate&&u&&"private"!==u.type,m=So(o)?.enableHelpPanel??!0,p=t.tags,f=t.text,g=!f&&!p.length,v=he((e=>{c.createDraft(t.annotation,{...t,tags:e})}),[t,c]),b=he((e=>{if(!e||p.indexOf(e)>=0)return!1;const t=[...p,e];return i.store(t),v(t),!0}),[v,p,i]),y=he((e=>{const t=[...p],n=t.indexOf(e);return n>=0&&(t.splice(n,1),v(t),!0)}),[v,p]),_=he((e=>{c.createDraft(t.annotation,{...t,text:e})}),[t,c]),w=he((n=>{c.createDraft(e,{...t,isPrivate:n}),
557
- d||c.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,d,c]),x=async()=>{s&&b(s);const t=`${Ai(e)} ${gi(e)?"updated":"saved"}`;try{await n.save(e),a.success(t,{visuallyHidden:!0})}catch{a.error("Saving annotation failed")}},k=he((()=>{c.removeDraft(e),gi(e)||c.removeAnnotations([e])}),[e,c]),N=To(["annotationFontFamily"],o),S=c.isFeatureEnabled("at_mentions"),A=c.usersWhoAnnotated(),E=c.getFocusedGroupMembers();return le((()=>{S&&null===E&&r.loadFocusedGroupMembers()}),[E,r,S]),Qe("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;g||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),x())},children:[Qe(Lp,{textStyle:N,label:d?"Enter reply":"Enter comment",text:f,onEditText:_,mentionsEnabled:S,usersForMentions:A,showHelpLink:m,mentions:e.mentions}),Qe(Dp,{onAddTag:b,onRemoveTag:y,onTagInput:l,tagList:p}),u&&Qe(Vp,{group:u,isDisabled:g,isPrivate:t.isPrivate,onCancel:k,onSave:x,onSetPrivate:w}),h&&Qe(Fp,{})]})
558
- }),["annotationsService","groups","settings","tags","toastMessenger"]);function Kp({domain:e,link:t,title:n}){return Qe("div",{className:"flex gap-x-1",children:[Qe("div",{className:"text-color-text-light",children:['on "',t?Qe(po,{href:t,target:"_blank",underline:"none",children:n}):Qe("span",{children:n}),'"']}),e&&Qe("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function Yp({group:e}){const t=e?.links.html;return Qe(x,{children:e&&t&&Qe(po,{classes:Xe("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:Qe("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?Qe(un,{className:"w-2.5 h-2.5"}):Qe(pn,{className:"w-2.5 h-2.5"}),Qe("span",{children:e.name})]})})})}function Xp({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:Ge(a,{includeWeekday:!0}),
559
- relative:Ue(a,o)})),[a,o]),c=de((()=>s?{absolute:Ge(s,{includeWeekday:!0}),relative:Ue(s,o)}:{}),[s,o]);le((()=>qe(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Qe("div",{children:[r&&Qe("span",{className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Qe(po,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):Qe("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function Jp({authorLink:e,displayName:t}){const n=Qe("h3",{className:"text-color-text font-bold",children:t});return e?Qe(po,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Qe("div",{children:n})}var Zp=Mo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){
560
- const i=ms(),a=i.defaultAuthority(),s=i.isFeatureEnabled("client_display_names"),l=i.getLink("user",{user:e.user}),c=de((()=>Ss(e,a,s)),[e,a,s]),u=de((()=>function(e,t,n,r){return!ui(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${ci(e.user)}`)??void 0}(e,o,a,l)),[e,o,a,l]),d=fi(e)&&r,h=e.links?.html||"",m=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)&&!d),[e,d]),p=function(e){return{domain:mi(e),titleText:pi(e),titleLink:hi(e)}}(e),f=h&&p.titleLink?p.titleLink:"",g="sidebar"!==i.route()&&p.titleText;let v;"sidebar"!==i.route()&&(v=i.getGroup(e.group));const b=Mi(e);return Qe("header",{children:[Qe("div",{className:"flex gap-x-1 items-center flex-wrap-reverse",children:[Is(e.permissions)&&!t&&Qe(zn,{className:"w-[12px] h-[12px]",title:"This annotation is visible only to you"}),Qe(Jp,{authorLink:u,displayName:c}),n>0&&d&&Qe(go,{variant:"text-light",
561
- onClick:()=>i.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Qe("div",{className:"flex justify-end grow",children:Qe(Xp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,withEditedTimestamp:m})})]}),!fi(e)&&Qe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[v&&Qe(Yp,{group:v}),!t&&xi(e)&&Qe(_n,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(g||b)&&Qe("span",{className:"flex",children:[g&&Qe(Kp,{domain:p.domain,link:f,title:p.titleText}),b&&Qe("span",{className:"text-grey-6","data-testid":"page-number",children:[g&&", ","p. ",b]})]})]})]})}),["settings"]);var Qp=Mo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Qe($s,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Qe(hp,{classes:Xe({"p-redacted-text":n}),children:Qe("blockquote",{
562
- className:Xe("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:To(["selectionFontFamily"],r),children:e})})})}),["settings"]);function ef({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Qe(br,{classes:Xe("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}function tf(){return Qe("div",{className:Xe("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Qe("span",{className:"text-[16px] animate-fade-in-slow",children:Qe(io,{size:"sm"})}),Qe("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var nf=Mo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){
563
- const a=ms(),s=Ti(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&&gi(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=de((()=>Ss(e,f,g)),[e,f,g]);return Qe("article",{className:"space-y-4","aria-label":`${gi(e)?Ai(e):`New ${Ai(e).toLowerCase()}`} by ${v}${a.isAnnotationHighlighted(e)?" - Highlighted":""}`,children:[Qe(Zp,{annotation:e,isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Qe(Qp,{quote:s,isHovered:u,isOrphan:ki(e)}),!m&&!h&&Qe(bp,{annotation:e}),h&&Qe(Wp,{annotation:e,draft:l}),!m&&Qe("footer",{className:"flex items-center",children:[n&&Qe(ef,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Qe(tf,{}),p&&Qe(ct,{classes:"grow",children:Qe(Hs,{annotation:e,onReply:()=>{gi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function rf({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Qe("article",{className:"space-y-4",
564
- "aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Qe("div",{children:Qe("em",{children:"Message not available."})}),r&&Qe("footer",{className:"flex items-center",children:Qe(ef,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var of=Mo((function({annotation:e,api:t,toastMessenger:n}){const r=ms(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Qe("div",{className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!fi(e),"-mr-3":fi(e)}),children:[Qe("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Qe(bn,{className:"w-em h-em"}):Qe(an,{className:"w-em h-em"})}),Qe("div",{className:"self-center grow",children:[!e.hidden&&Qe("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Qe("span",{children:"Hidden from users"})]}),Qe("div",{className:"self-center pr-2",children:Qe(br,{
565
- classes:Xe("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 af({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:Fn,r=e?"Expand replies":"Collapse replies";return Qe("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Qe("div",{className:Xe("bg-white"),children:Qe(br,{
566
- classes:Xe("-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:Qe(n,{className:"w-em h-em"})})})})}var sf=Mo((function e({thread:t,threadsService:n}){const r=!!t.parent,o=t.children.filter((e=>ks(e)>0)),i=ms(),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&&Qe(x,{children:t.annotation?Qe(x,{children:[Qe(of,{annotation:t.annotation}),Qe(nf,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Qe(rf,{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 Qe("section",{className:"flex","data-testid":"thread-container",
567
- children:[r&&Qe(af,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Qe("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,xs(t)>0&&Qe("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Qe(Zp,{annotation:t.annotation,isEditing:l,replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Qe("div",{children:Qe(br,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",xs(t)," more in conversation"]})})]}),!t.collapsed&&Qe("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Qe("li",{className:Xe("mt-2","[text-align:start]"),children:Qe(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var lf=Mo((function({frameSync:e,thread:t}){const n=ms(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>bs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Qe(sf,{thread:t
568
- })),[t]),c=n.annotationFocusRequest(),u=ue(null);return le((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Qe(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Qe(dt,{children:l})},t.id)}),["frameSync"]);const cf=50;function uf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function df(e){return Math.max(e-e%cf,0)}function hf(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function mf(e){if(!e.annotation)return null;const t=hf(e.annotation);return t?.cfi??null}function pf({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ke,t=uf();n(t.clientHeight),
569
- o(df(t.scrollTop));const r=bs((()=>{n(t.clientHeight),o(df(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=ys){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=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=hf(n.annotation);e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=mf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ms(),f=p.countDrafts()>0,g=p.highlightedAnnotations(),v=p.allAnnotations(),b=(()=>{const e=p.unsavedAnnotations()
570
- ;return e.length?e[e.length-1].$tag:null})();le((()=>{b&&(p.setForcedVisible(b,!0),l(b))}),[p,b]);const y=de((()=>{const e=v.filter((e=>e.id&&g.includes(e.id))).reduce(((e,t)=>!e||e.updated<t.updated?t:e),null);return e?.id}),[v,g]);return le((()=>{!f&&y&&l(y)}),[f,y]),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)||ys.defaultHeight)(t)),0);uf().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=_s(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Qe("div",{children:[Qe("div",{style:{height:d}}),h.map((e=>Qe("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Qe("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Qe(lf,{thread:e})]},e.id))),Qe("div",{style:{height:u}})]})}
571
- const ff={collapsed:!1,depth:0,visible:!0,replyCount:0};function gf(e){return e.id||e.$tag}function vf(e,t,n){const r=e[n];return!(!r||r.parent===t)&&(!r.parent||vf(e,t,r.parent))}function bf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...ff,children:[],id:r},bf(e,r,n.slice(0,-1))),vf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function yf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>yf(e,t)))})}function _f(e,t,n){const r=e.children.map((e=>_f(e,n,n))).slice().sort(t);return{...e,children:r}}function wf(e,t){const n=e.children.map((e=>wf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function xf(e){return e.children.some((e=>e.visible||xf(e)))}const kf=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Nf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=gf(e)
572
- ;t[n]={...ff,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id));return bf(t,gf(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...ff,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=yf(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||xf(e))),o=yf(o,(e=>{const n={collapsed:e.collapsed};if(si(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&xf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=_f(o,t.sortCompareFn,kf),o=wf(o,-1),o}function Sf(e){const t=Af(e),[n,r]=t.split("-",2)
573
- ;return[n,r??n]}function Af(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 Ef(e,t){const n=e=>function(e){const t=Af(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(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))}function Tf(e,t,n){return Ef(e,t)>=0&&Ef(e,n)<0}function Cf(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Mf=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function If(e,t,n){
574
- return[e[0]??t,e[1]??n]}function zf(e,t){const n=Cf(e),r=Cf(t);if(!n||!r)return e&&t&&e===t?Mf.Overlap:Mf.Unknown;const o=2**31,[i,a]=If(n,1,o),[s,l]=If(r,1,o);return i<=s?s<=a?Mf.Overlap:Mf.NoOverlap:i<=l?Mf.Overlap:Mf.NoOverlap}
534
+ n=sc(t.expression)}return e.replace(up(t.id),n)}),e)}(n,t.mathBlocks);return r}function hp({children:e,classes:t,...n}){return Qe("div",{dir:"auto",lang:"",className:Xe("StyledText",t),...n,children:e})}function mp({content:e}){return"string"==typeof e?Qe(x,{children:["No user with username ",Qe("span",{className:"font-bold",children:e})," ","exists"]}):Qe("div",{className:"flex flex-col gap-y-4",children:[Qe("div",{className:"flex flex-col gap-y-1.5",children:[Qe("div",{"data-testid":"username",className:"text-md font-bold",children:["@",e.username]}),e.display_name&&Qe("div",{"data-testid":"display-name",className:"text-color-text-light",children:e.display_name})]}),e.description&&Qe("div",{"data-testid":"description",className:"line-clamp-2",children:e.description}),Qe("div",{"data-testid":"created",className:"text-color-text-light",children:["Joined ",Qe("b",{children:Ge(e.joined,{includeTime:!1})})]})]})}function pp(e){
535
+ const{markdown:t,classes:n,style:r,mentions:o=[],mentionsEnabled:i=!1,setTimeout_:a=setTimeout,clearTimeout_:s=clearTimeout}=e,l=de((()=>t?dp(t):""),[t]),c=ue(null),u=ue(null),d=ue(new Map),[h,m]=ae(null),p=ue(),f=he((e=>{p.current&&s(p.current);const t=()=>{m(e),p.current=null};null===e?t():p.current=a(t,400)}),[s,a]);return le((()=>()=>{p.current&&s(p.current)}),[s]),le((()=>{!function(e,{className:t}={}){const n=Array.from(e.getElementsByTagName("a"));for(const e of n){const n=Zs(e);n&&(t?n.className=t:n.style.width="350px")}}(c.current,{className:"w-full md:w-[380px]"})}),[t]),le((()=>{d.current=function(e,t){const n=e.querySelectorAll("[data-hyp-mention]"),r=new Map;for(const e of n){const n=e,o=n.dataset.userid,i=o?t.find((e=>e.userid===o)):void 0;r.set(...Gs(n,i))}return r}(c.current,o)}),[o]),Qe("div",{className:"w-full break-anywhere cursor-text",children:Qe(hp,{classes:Xe({relative:i}),children:[Qe("div",{className:n,"data-testid":"markdown-text",ref:c,dangerouslySetInnerHTML:{__html:l},style:r,
536
+ onMouseEnterCapture:i?({target:e})=>{const t=e,n=d.current.get(t);n&&(f(n),u.current=t)}:void 0,onMouseLeaveCapture:i?()=>{f(null),u.current=null}:void 0}),i&&Qe(Jr,{open:!!h,onClose:()=>f(null),anchorElementRef:u,classes:"px-3 py-2 !max-w-[75%]",children:null!==h&&Qe(mp,{content:h})})]})})}function fp({children:e}){return Qe("ul",{className:"flex flex-wrap gap-2 leading-none","aria-label":"Annotation tags",children:e})}function gp({href:e,onRemoveTag:t,tag:n}){return Qe("li",{className:"flex items-center border rounded bg-grey-0",children:[Qe("div",{className:"grow px-1.5 py-1 touch:p-2",children:e?Qe(po,{variant:"text-light",href:e,lang:"",target:"_blank","aria-label":`Tag: ${n}`,title:`View annotations with tag: ${n}`,underline:"none",children:n}):Qe("span",{className:"text-color-text-light cursor-default","aria-label":`Tag: ${n}`,lang:"",children:n})}),t&&Qe("button",{
537
+ className:Xe("px-1.5 py-1 touch:p-2","border-l rounded rounded-l-none","text-grey-6 hover:text-color-text hover:bg-grey-2","transition-colors duration-200","focus-visible-ring ring-inset"),onClick:()=>{t(n)},title:`Remove tag: ${n}`,children:Qe(yt,{className:"font-base w-em h-em",title:`Remove ${n}`})})]})}function vp({classes:e,setCollapsed:t,collapsed:n}){const r=n?"More":"Less";return Qe(br,{classes:Xe("text-grey-7 font-normal",e),expanded:!n,onClick:()=>t(!n),title:`Toggle visibility of full annotation text: Show ${r}`,children:Qe("div",{className:"flex items-center gap-x-2",children:[Qe(n?Qt:Rt,{className:"w-3 h-3"}),Qe("div",{children:r})]})})}sp.addHook("afterSanitizeAttributes",(e=>{"target"in e&&e.setAttribute("target","_blank")}));var bp=Mo((function({annotation:e,settings:t}){
538
+ const[n,r]=ae(!0),[o,i]=ae(!1),a=ms(),s=a.defaultAuthority(),l=a.getDraft(e),c=a.isFeatureEnabled("at_mentions"),u=l?.tags??e.tags,d=l?.text??e.text,h=d.length>0,m=u.length>0,p=To(["annotationFontFamily"],t),f=de((()=>e&&!ui(e?.user,s)),[e,s]),g=e=>a.getLink("search.tag",{tag:e});return Qe("div",{className:"space-y-4",children:[h&&Qe($s,{collapse:n,collapsedHeight:400,inlineControls:!1,onCollapsibleChanged:i,onToggleCollapsed:r,overflowThreshold:20,children:Qe(pp,{markdown:d,classes:Xe({"p-redacted-text":wi(e)}),style:p,mentions:e.mentions,mentionsEnabled:c})}),(o||m)&&Qe("div",{className:"flex flex-row gap-x-2",children:[Qe("div",{className:"grow",children:m&&Qe(fp,{children:u.map((e=>Qe(gp,{tag:e,href:f?g(e):void 0},e)))})}),o&&Qe("div",{children:Qe(vp,{classes:Xe("-mt-3"),collapsed:n,setCollapsed:r})})]})]})}),["settings"]);let yp,_p=function(e){return e.ANCHOR_LINK="ANCHOR_LINK",e.IMAGE_LINK="IMAGE_LINK",e}({});function wp(e,t,n,r){let o=e.selectionStart,i=e.selectionEnd;return o>=t+n?(o+=r.length-n,
539
+ i+=r.length-n):i<=t||(o<=t&&i>=t+n?i+=r.length-n:o<t&&i<t+n?o=t:o<t+n&&i>t+n?i+=r.length-n:t<o&&t+n>i&&(o=t,i=t+n)),{text:e.text.slice(0,t)+r+e.text.slice(t+n),selectionStart:o,selectionEnd:i}}function xp(e,t=_p.ANCHOR_LINK){const n=e.text.slice(e.selectionStart,e.selectionEnd);let r,o="";if(t===_p.IMAGE_LINK&&(o="!"),n.match(/[a-z]+:\/\/.*/)){const t="Description";return r=wp(e,e.selectionStart,n.length,o+"["+t+"]("+n+")"),r.selectionStart=e.selectionStart+o.length+1,r.selectionEnd=r.selectionStart+t.length,r}{const t=o+"["+n+"](",i="http://insert-your-link-here.com";return r=wp(e,e.selectionStart,n.length,t+i+")"),r.selectionStart=e.selectionStart+t.length,r.selectionEnd=r.selectionStart+i.length,r}}function kp(e,t,n,r){void 0===n&&(n=t);const o=e.text.slice(e.selectionStart-t.length,e.selectionStart),i=e.text.slice(e.selectionEnd,e.selectionEnd+t.length);let a=e;return e.selectionStart===e.selectionEnd&&r&&(a=wp(e,e.selectionStart,0,r),a.selectionStart=a.selectionEnd-r.length),
540
+ o===t&&i===n?(a=wp(a,a.selectionStart-t.length,t.length,""),a=wp(a,a.selectionEnd,n.length,"")):(a=wp(a,a.selectionStart,0,t),a=wp(a,a.selectionEnd,0,n)),a}function Np(e,t){const n=e.indexOf("\n",t);return n<0?e.length:n}function Sp(e,t,n,r){let o=function(e,t){const n=e.lastIndexOf("\n",t);return n<0?0:n+1}(e.text,t),i=Np(e.text,t),a=0;for(;i<=Np(e.text,n);){const t=i===e.text.length,s=i-o,l=Np((e=r(e,o,i,a)).text,o)-o;if(n+=l-s,t)break;o=o+l+1,i=Np(e.text,o),a+=1}return e}function Ap(e,t){const n=e.selectionStart,r=e.selectionEnd,o=e=>"function"==typeof t?t(e):t;let i=!0;return Sp(e,n,r,((e,t,n,r)=>{const a=o(r);return e.text.slice(t,t+a.length)!==a&&(i=!1),e})),Sp(e,n,r,i?(e,t,n,r)=>wp(e,t,o(r).length,""):(e,t,n,r)=>{const i=o(r);return e.text.slice(t,t+i.length)===i?e:wp(e,t,0,i)})}const Ep=!1;function Tp({users:e,onSelectUser:t,highlightedSuggestion:n,usersListboxId:r,...o}){return Qe(Jr,{...o,classes:"p-1",children:Qe("ul",{className:"flex-col gap-y-0.5",role:"listbox","aria-orientation":"vertical",
541
+ id:r,children:[e.map(((e,o)=>Qe("li",{id:`${r}-${e.username}`,className:Xe("flex justify-between items-center gap-x-2","rounded p-2 hover:bg-grey-2",{"bg-grey-2":n===o}),onClick:n=>{n.stopPropagation(),t(e)},role:"option","aria-selected":n===o,children:[Qe("span",{className:"truncate",children:e.username}),Qe("span",{className:"text-color-text-light",children:e.displayName})]},e.username))),0===e.length&&Qe("li",{className:"italic p-2","data-testid":"suggestions-fallback",children:"No matches. You can still write the username"})]})})}const Cp={bold:"b",image:"g",italic:"i",link:"l",list:"u",math:"m",numlist:"o",quote:"q"};function Mp({disabled:e=!1,icon:t,label:n,onClick:r,shortcutKey:o,title:i=""}){const a=de((()=>zs()?"Cmd":"Ctrl"),[]);let s=i;o&&(s+=` (${a}-${o.toUpperCase()})`);const l={disabled:e,onClick:r,title:s};return n?Qe(br,{classes:"p-1.5 text-grey-7 hover:text-grey-9",...l,size:"custom",variant:"custom",children:n}):Qe(kr,{classes:"px-2 py-2.5",...l,children:t&&Qe(t,{
542
+ className:"w-[10px] h-[10px] touch:w-[13px] touch:h-[13px]"})})}function Ip({classes:e,containerRef:t,mentionsEnabled:n,usersForMentions:r,onEditText:o,onKeyDown:i,...a}){const[s,l]=ae(!1),[c,u]=ae(),d=ze(t),[h,m]=ae(0),p=ue(null),f=de((()=>n&&void 0!==c?r.filter((e=>!c||`${e.username} ${e.displayName??""}`.toLowerCase().match(c.toLowerCase()))).slice(0,10):[]),[c,n,r]),g=he((e=>{if(!n)return;const{x:t,y:r}=function(e){yp||(yp=document.createElement("div"),document.body.append(yp));try{const t=e.getBoundingClientRect(),n=window.getComputedStyle(e);yp.style.font=n.font,yp.style.padding=n.padding,yp.style.whiteSpace="pre-wrap",yp.style.wordWrap="break-word",yp.style.position="fixed",Ep||(yp.style.visibility="hidden"),yp.style.width=`${t.width}px`,yp.style.height=`${t.height}px`,yp.style.top=`${t.top}px`,yp.style.left=`${t.left}px`;const r=e.selectionStart,o=document.createElement("span");o.style.display="inline-block",o.style.verticalAlign="bottom";const i=e.value.substring(0,r),a=e.value.slice(r),s="\nx"
543
+ ;yp.innerHTML="",yp.append(i,o,a,s),yp.style.overflowY="auto",yp.scrollTop=e.scrollTop;const l=o.getBoundingClientRect();return{x:l.left-t.left,y:l.top-t.top}}finally{yp.remove(),yp=void 0}}(e);p.current&&(p.current.style.transform=`translate(${t}px, ${r}px)`);const o=function(e,t){const{start:n}=Vs(e,t);return e.slice(n,t)}(e.value,e.selectionStart),i=o.startsWith("@");l(i),u(i?o.substring(1):void 0),i||m(0)}),[n]),v=he((e=>{const t=d.current,{value:n}=t,{start:r,end:i}=Vs(n,t.selectionStart),a=`${n.slice(0,r)}@${e.username} `,s=n.slice(i);t.value=`${a}${s}`,t.selectionStart=a.length,t.selectionEnd=a.length,t.focus(),o(t.value),l(!1),m(0)}),[o,d]),b=pe(),y=de((()=>{if(!s)return{};const e=f[h],t=e?`${b}-${e.username}`:void 0;return{role:"combobox","aria-controls":b,"aria-expanded":!0,"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":t}}),[h,b,s,f]);return Qe("div",{className:"relative",children:[Qe("textarea",{
544
+ className:Xe("border rounded p-2","text-color-text-light bg-grey-0","focus:bg-white focus:outline-none focus:shadow-focus-inner",e),onInput:e=>o(e.target.value),...a,onKeyUp:e=>{["Escape","Enter"].includes(e.key)||g(e.target)},onKeyDown:e=>{i?.(e),s&&0!==f.length&&("ArrowDown"===e.key?(e.preventDefault(),m((e=>Math.min(e+1,f.length-1)))):"ArrowUp"===e.key?(e.preventDefault(),m((e=>Math.max(e-1,0)))):"Enter"===e.key&&(e.preventDefault(),v(f[h])))},onClick:e=>{e.stopPropagation(),g(e.target)},ref:d,...y}),Qe("div",{ref:p,className:"absolute top-0 left-0 w-0 h-0 pointer-events-none"}),n&&Qe(Tp,{open:s,onClose:()=>l(!1),anchorElementRef:p,users:f,highlightedSuggestion:h,onSelectUser:v,usersListboxId:b})]})}function zp({isPreviewing:e,onCommand:t,onTogglePreview:n,showHelpLink:r}){const o=ue(null);return Se(o),Qe("div",{className:Xe("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",
545
+ role:"toolbar","aria-label":"Markdown editor toolbar",ref:o,children:[Qe(Mp,{disabled:e,icon:Wt,onClick:()=>t("bold"),shortcutKey:Cp.bold,title:"Bold"}),Qe(Mp,{disabled:e,icon:Yt,onClick:()=>t("italic"),shortcutKey:Cp.italic,title:"Italic"}),Qe(Mp,{disabled:e,icon:Gt,onClick:()=>t("quote"),shortcutKey:Cp.quote,title:"Quote"}),Qe(Mp,{disabled:e,icon:An,onClick:()=>t("link"),shortcutKey:Cp.link,title:"Insert link"}),Qe(Mp,{disabled:e,icon:xn,onClick:()=>t("image"),shortcutKey:Cp.image,title:"Insert image"}),Qe(Mp,{disabled:e,icon:qt,onClick:()=>t("math"),title:"Insert math (LaTeX is supported)"}),Qe(Mp,{disabled:e,icon:Tn,onClick:()=>t("numlist"),shortcutKey:Cp.numlist,title:"Numbered list"}),Qe(Mp,{disabled:e,icon:Mn,onClick:()=>t("list"),shortcutKey:Cp.list,title:"Bulleted list"}),Qe("div",{className:"grow flex justify-end",children:[r&&Qe(po,{classes:"text-grey-7 hover:!text-grey-7",href:"https://web.hypothes.is/help/formatting-annotations-with-markdown/",target:"_blank",title:"Formatting help",
546
+ "aria-label":"Formatting help",underline:"none",variant:"custom",children:Qe("div",{className:Xe("flex justify-center items-center","touch:h-touch-minimum touch:w-touch-minimum","px-2 py-2.5 touch:p-0"),children:Qe(gn,{className:"w-2.5 h-2.5"})})}),Qe(Mp,{label:e?"Write":"Preview",onClick:n})]})]})}function Lp({mentionsEnabled:e=!1,label:t,onEditText:n=(()=>{}),text:r,textStyle:o={},showHelpLink:i=!0,usersForMentions:a,mentions:s}){const[l,c]=ae(!1),u=ue(null),d=de((()=>function(e){const t=document.createElement("div");t.innerHTML=e;for(const e of t.querySelectorAll("a[data-hyp-mention]"))e.replaceWith(e.textContent??"");return t.innerHTML}(r)),[r]);le((()=>{l||u.current?.focus()}),[l]);const h=e=>{u.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)
547
+ ;return 0===t.length||"\n"===t.slice(-1)||"$$"===t.slice(-2)?kp(e,"$$","$$","Insert LaTeX"):kp(e,"\\(","\\)","Insert LaTeX")};switch(e){case"bold":n((e=>kp(e,"**","**","Bold")));break;case"italic":n((e=>kp(e,"*","*","Italic")));break;case"quote":n((e=>Ap(e,"> ")));break;case"link":n((e=>xp(e)));break;case"image":n((e=>xp(e,_p.IMAGE_LINK)));break;case"math":n(r);break;case"numlist":n((e=>Ap(e,(e=>`${e+1}. `))));break;case"list":n((e=>Ap(e,"* ")))}}(e,u.current),n(u.current.value))};return Qe("div",{className:"leading-none",children:[Qe(zp,{onCommand:h,isPreviewing:l,onTogglePreview:()=>c(!l),showHelpLink:i}),l?Qe(pp,{markdown:r,classes:"border bg-grey-1 p-2",style:o,mentions:s,mentionsEnabled:e}):Qe(Ip,{"aria-label":t,placeholder:t,dir:"auto",classes:Xe("w-full min-h-[8em] resize-y","rounded-t-none","text-base touch:text-touch-base"),containerRef:u,onKeyDown:e=>{if(e.ctrlKey||e.metaKey)for(const[t,n]of Object.entries(Cp))n===e.key&&(e.stopPropagation(),e.preventDefault(),h(t))},onEditText:n,value:d,style:o,
548
+ mentionsEnabled:e,usersForMentions:a})]})}const Op=e=>e;function Rp({activeItem:e=-1,id:t,itemPrefixId:n,list:r,listFormatter:o=Op,onSelectItem:i,open:a=!1}){const s=de((()=>r.map(((t,r)=>{const a=n?{id:`${n}${r}`}:{};return Qe("li",{role:"option","aria-selected":e===r,className:Xe("flex items-center","border-l-4 py-1 px-3 cursor-pointer hover:bg-grey-2","touch:h-touch-minimum",{"border-brand bg-grey-1":e===r,"border-transparent":e!==r}),onClick:()=>{i(t)},...a,children:o(t,r)},`AutocompleteList-${r}`)}))),[e,n,r,o,i]),l=t?{id:t}:{},c=0===r.length||!a;return Qe("div",{className:"relative",children:Qe("div",{className:Xe({hidden:c},"absolute top-[3px] z-3","min-w-[10em]"),"data-testid":"autocomplete-list-container",children:Qe(st,{width:"auto",classes:"overflow-hidden",children:[Qe("ul",{tabIndex:-1,"aria-label":"Suggestions",role:"listbox",...l,children:s}),Qe(Rs,{direction:"up",classes:"top-[-8px] left-2"})]})})})}let Pp=0;var Dp=Mo((function({onAddTag:e,onRemoveTag:t,onTagInput:n,tagList:r,tags:o}){
549
+ const i=ue(),[a,s]=ae([]),[l,c]=ae(-1),[u,d]=ae(!1),[h]=ae((()=>(++Pp,`TagEditor-${Pp}`))),m=ue(null);Ce(m,(()=>d(!1)),{enabled:u});const p=()=>i.current.value.trim(),f=()=>p()&&p().length>0,g=()=>{i.current.value="",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)},y=l>=0?`${h}-AutocompleteList-item-${l}`:"";return Qe("div",{className:"space-y-4",children:[Qe(fp,{children:r.map((e=>Qe(gp,{onRemoveTag:t,tag:e},e)))}),Qe("div",{id:h,"data-testid":"combobox-container",ref:m,children:[Qe(Ur,{onInput:()=>{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
550
+ ;-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":y,"aria-controls":`${h}-AutocompleteList`,"aria-expanded":u,"aria-label":"Add tags",dir:"auto",role:"combobox",classes:Xe("text-base touch:text-touch-base")}),Qe(Rp,{id:`${h}-AutocompleteList`,list:a,listFormatter:e=>{const t=p().toLowerCase(),n=e.toLowerCase().indexOf(t);if(-1===n)return Qe("span",{children:e});const r=e.slice(0,n),o=e.slice(n,n+t.length),i=e.slice(n+t.length);return Qe("span",{children:[Qe("strong",{children:r}),o,Qe("strong",{children:i})]})},open:u,onSelectItem:e=>{e&&v(e)},itemPrefixId:`${h}-AutocompleteList-item-`,activeItem:l})]})]})}),["tags"]);function Fp(){return Qe("div",{className:"pt-2 border-t text-xs leading-none",children:Qe(po,{href:"http://creativecommons.org/publicdomain/zero/1.0/",target:"_blank",
551
+ title:"View more information about the Creative Commons Public Domain dedication",underline:"none",variant:"text-light",children:Qe("div",{className:"flex items-center",children:[Qe(St,{className:"w-[10px] h-[10px]"}),Qe(Et,{className:"w-[10px] h-[10px] ml-px"}),Qe("div",{className:"ml-1",children:"Annotations can be freely reused by anyone for any purpose."})]})})})}function Hp(e){return null!==e.offsetParent}function Bp({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 Qe("div",{role:"menu",className:e,ref:o,onKeyDown:e=>{const n=Array.from(o.current.querySelectorAll('[role^="menuitem"]')).filter(Hp);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,
552
+ i=!0;break;case"End":r=n.length-1,i=!0}i&&r>=0&&(e.stopPropagation(),e.preventDefault(),n[r].focus())},children:n})}let jp=!1;const $p=()=>{};function qp({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||$p);const m=ue(d);le((()=>{"function"==typeof l&&m.current!==d&&(m.current=d,l(d))}),[d,l]);const p=e=>{if("mousedown"===e.type)jp=!0;else if("click"===e.type&&jp)return jp=!1,e.stopPropagation(),void e.preventDefault();h(!d)},f=he((()=>h(!1)),[h]),g=ue(null);Ce(g,f,{enabled:d});const v=e=>e.stopPropagation();return Qe("div",{className:"relative","data-testid":"menu-container",ref:g,style:{position:n?"relative":"static"},onClick:v,onMouseDown:v,children:[Qe("button",{"aria-expanded":d?"true":"false","aria-haspopup":!0,className:Xe("focus-visible-ring","flex items-center justify-center rounded transition-colors",{"text-grey-7 hover:text-grey-9":!d,
553
+ "text-brand":d}),"data-testid":"menu-toggle-button",disabled:i,onMouseDown:p,onClick:p,"aria-label":u,title:u,children:Qe("span",{className:"flex items-center gap-x-1",children:[a,c&&Qe("span",{className:Xe({"rotate-180 text-color-text":d}),children:Qe(Fn,{className:"w-2.5 h-2.5"})})]})}),d&&Qe("div",{className:Xe("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:Qe(Bp,{visible:!0,children:t})})]})}function Up({title:e,isExpanded:t,onToggleSubmenu:n}){const r=t?Pn:Fn;return Qe("div",{"data-testid":"submenu-toggle",role:"none",className:Xe("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,
554
+ "group-hover:bg-grey-3":!t}),onClick:n,title:e,children:Qe(r,{className:"w-3 h-3",viewBox:"0 0 16 16"})})}function Gp({href:e,icon:t,isDisabled:n,isExpanded:r,isSelected:o,isSubmenuItem:i,isSubmenuVisible:a,label:s,leftChannelContent:l,onClick:c,onToggleSubmenu:u,submenu:d,submenuToggleTitle:h}){const m=ue(null);let p,f;const g="boolean"==typeof a,v="boolean"==typeof o;le((()=>()=>{clearTimeout(p)}),[]);const b=e=>{switch(e.key){case"ArrowRight":u&&(e.stopPropagation(),e.preventDefault(),u(e));break;case"Enter":case" ":c&&c(e)}},y=t?Qe(t,{className:"h-3 w-3"}):null,_=i?null:y,w=i?y:null,k=!!w,N=Qe(x,{children:[(l||i||!!_)&&Qe("div",{className:"w-7 flex items-center justify-center","data-testid":"left-item-container",children:l??_}),Qe("span",{className:"flex items-center grow whitespace-nowrap px-1",children:s}),k&&Qe("div",{className:"w-8 flex items-center justify-center","data-testid":"right-item-container",children:w}),g&&Qe(Up,{title:h??("string"==typeof s?`Show actions for ${s}`:"Toggle submenu"),
555
+ isExpanded:a,onToggleSubmenu:u})]}),S=Xe("focus-visible-ring ring-inset","w-full min-w-[150px] flex items-center select-none","rounded-none",{"focus-visible:rounded-lg":!o,"focus-visible:rounded-r-lg":o,"cursor-pointer":!n},"group",{"min-h-[30px] font-normal":i,"min-h-[40px] font-medium":!i,"bg-grey-1":i||r,"hover:bg-grey-3":!n&&(i||r),"bg-white":!i&&!r,"hover:bg-grey-1":!n&&!i&&!r,"pr-1":!g},{"border-l-[4px] border-l-brand":o,"pl-[4px]":!o,"text-color-text-light":n,"text-color-text hover:text-color-text":!n});return f=e?Qe("a",{ref:m,className:S,"data-testid":"menu-item",href:e,target:"_blank",tabIndex:-1,rel:"noopener noreferrer",role:"menuitem",onKeyDown:b,children:N}):Qe("div",{ref:m,className:S,"data-testid":"menu-item",tabIndex:-1,onKeyDown:b,onClick:c,role:v?"menuitemradio":"menuitem","aria-checked":v?o:void 0,"aria-haspopup":g,"aria-expanded":g?a:void 0,children:N}),Qe(x,{children:[f,g&&Qe(No,{direction:a?"in":"out",children:Qe(Bp,{closeMenu:e=>{u&&u(e),p=setTimeout((()=>{m.current.focus()}))},
556
+ visible:a,className:"border-y border-grey-3",children:d})})]})}var Vp=Mo((function({group:e,isDisabled:t,isPrivate:n,onCancel:r,onSave:o,onSetPrivate:i,settings:a}){const s=To(["ctaTextColor","ctaBackgroundColor"],a),l=Qe("div",{className:"w-9 h-9 flex items-center justify-center text-color-text-inverted",style:s,children:Qe(Fn,{className:"w-4 h-4"})});return Qe("div",{className:"flex flex-row gap-x-3",children:[Qe("div",{className:"flex relative",children:[Qe(br,{classes:Xe("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]}),Qe("div",{className:Xe("flex flex-row rounded-r bg-grey-7 hover:bg-grey-8"),style:s,children:Qe(qp,{containerPositioned:!1,contentClass:Xe("min-w-full"),label:l,menuIndicator:!1,title:"Change annotation sharing setting",align:"left",children:[Qe(Gp,{icon:"open"===e.type?un:pn,label:e.name,isSelected:!n,onClick:()=>i(!1)}),Qe(Gp,{icon:zn,label:"Only Me",isSelected:n,onClick:()=>i(!0)
557
+ })]})})]}),Qe("div",{children:Qe(br,{"data-testid":"cancel-button",onClick:r,size:"lg",children:[Qe(yt,{}),"Cancel"]})})]})}),["settings"]);var Wp=Mo((function({annotation:e,draft:t,annotationsService:n,groups:r,settings:o,tags:i,toastMessenger:a}){const[s,l]=ae(null),c=ms(),u=c.getGroup(e.group),d=de((()=>fi(e)),[e]),h=!t.isPrivate&&u&&"private"!==u.type,m=So(o)?.enableHelpPanel??!0,p=t.tags,f=t.text,g=!f&&!p.length,v=he((e=>{c.createDraft(t.annotation,{...t,tags:e})}),[t,c]),b=he((e=>{if(!e||p.indexOf(e)>=0)return!1;const t=[...p,e];return i.store(t),v(t),!0}),[v,p,i]),y=he((e=>{const t=[...p],n=t.indexOf(e);return n>=0&&(t.splice(n,1),v(t),!0)}),[v,p]),_=he((e=>{c.createDraft(t.annotation,{...t,text:e})}),[t,c]),w=he((n=>{c.createDraft(e,{...t,isPrivate:n}),d||c.setDefault("annotationPrivacy",n?"private":"shared")}),[e,t,d,c]),x=async()=>{s&&b(s);const t=`${Ai(e)} ${gi(e)?"updated":"saved"}`;try{await n.save(e),a.success(t,{visuallyHidden:!0})}catch{a.error("Saving annotation failed")}},k=he((()=>{
558
+ c.removeDraft(e),gi(e)||c.removeAnnotations([e])}),[e,c]),N=To(["annotationFontFamily"],o),S=c.isFeatureEnabled("at_mentions"),A=c.usersWhoAnnotated(),E=c.getFocusedGroupMembers();return le((()=>{S&&null===E&&r.loadFocusedGroupMembers()}),[E,r,S]),Qe("div",{"data-testid":"annotation-editor",className:"space-y-4",onKeyDown:e=>{const t=e.key;g||(e.metaKey||e.ctrlKey)&&"Enter"===t&&(e.stopPropagation(),e.preventDefault(),x())},children:[Qe(Lp,{textStyle:N,label:d?"Enter reply":"Enter comment",text:f,onEditText:_,mentionsEnabled:S,usersForMentions:A,showHelpLink:m,mentions:e.mentions}),Qe(Dp,{onAddTag:b,onRemoveTag:y,onTagInput:l,tagList:p}),u&&Qe(Vp,{group:u,isDisabled:g,isPrivate:t.isPrivate,onCancel:k,onSave:x,onSetPrivate:w}),h&&Qe(Fp,{})]})}),["annotationsService","groups","settings","tags","toastMessenger"]);function Kp({domain:e,link:t,title:n}){return Qe("div",{className:"flex gap-x-1",children:[Qe("div",{className:"text-color-text-light",children:['on "',t?Qe(po,{href:t,target:"_blank",underline:"none",
559
+ children:n}):Qe("span",{children:n}),'"']}),e&&Qe("span",{className:"text-color-text-light",children:["(",e,")"]})]})}function Yp({group:e}){const t=e?.links.html;return Qe(x,{children:e&&t&&Qe(po,{classes:Xe("text-color-text-light hover:text-color-text-light"),href:e.links.html,target:"_blank",underline:"hover",variant:"custom",children:Qe("div",{className:"flex items-baseline gap-x-1",children:["open"===e.type?Qe(un,{className:"w-2.5 h-2.5"}):Qe(pn,{className:"w-2.5 h-2.5"}),Qe("span",{children:e.name})]})})})}function Xp({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:Ge(a,{includeWeekday:!0}),relative:Ue(a,o)})),[a,o]),c=de((()=>s?{absolute:Ge(s,{includeWeekday:!0}),relative:Ue(s,o)}:{}),[s,o]);le((()=>qe(s?t:e,(()=>i(new Date)))),[e,t,a,s,o]);const u=c&&c.relative!==l.relative?`edited ${c.relative}`:"edited";return Qe("div",{children:[r&&Qe("span",{
560
+ className:"text-color-text-light text-xs italic","data-testid":"timestamp-edited",title:c.absolute,children:["(",u,")"," "]}),n?Qe(po,{classes:"text-color-text-light hover:text-color-text-light",target:"_blank",title:l.absolute,href:n,underline:"hover",variant:"custom",children:l.relative}):Qe("span",{className:"color-text-color-light","data-testid":"timestamp-created",title:l.absolute,children:l.relative})]})}function Jp({authorLink:e,displayName:t}){const n=Qe("h3",{className:"text-color-text font-bold",children:t});return e?Qe(po,{href:e,target:"_blank",underline:"none",variant:"custom",children:n}):Qe("div",{children:n})}var Zp=Mo((function({annotation:e,isEditing:t,replyCount:n,threadIsCollapsed:r,settings:o}){const i=ms(),a=i.defaultAuthority(),s=i.isFeatureEnabled("client_display_names"),l=i.getLink("user",{user:e.user}),c=de((()=>Ss(e,a,s)),[e,a,s]),u=de((()=>function(e,t,n,r){return!ui(e.user,n)&&r?r:(t.usernameUrl&&`${t.usernameUrl}${ci(e.user)}`)??void 0
561
+ }(e,o,a,l)),[e,o,a,l]),d=fi(e)&&r,h=e.links?.html||"",m=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)&&!d),[e,d]),p=function(e){return{domain:mi(e),titleText:pi(e),titleLink:hi(e)}}(e),f=h&&p.titleLink?p.titleLink:"",g="sidebar"!==i.route()&&p.titleText;let v;"sidebar"!==i.route()&&(v=i.getGroup(e.group));const b=Mi(e);return Qe("header",{children:[Qe("div",{className:"flex gap-x-1 items-center flex-wrap-reverse",children:[Is(e.permissions)&&!t&&Qe(zn,{className:"w-[12px] h-[12px]",title:"This annotation is visible only to you"}),Qe(Jp,{authorLink:u,displayName:c}),n>0&&d&&Qe(go,{variant:"text-light",onClick:()=>i.setExpanded(e.id,!0),title:"Expand replies",underline:"hover",children:`${n} ${n>1?"replies":"reply"}`}),!t&&e.created&&Qe("div",{className:"flex justify-end grow",children:Qe(Xp,{annotationCreated:e.created,annotationUpdated:e.updated,annotationURL:h,
562
+ withEditedTimestamp:m})})]}),!fi(e)&&Qe("div",{className:"flex gap-x-1 items-baseline flex-wrap-reverse","data-testid":"extended-header-info",children:[v&&Qe(Yp,{group:v}),!t&&xi(e)&&Qe(_n,{title:"This is a highlight. Click 'edit' to add a note or tag.",className:"w-[10px] h-[10px] text-color-text-light"}),(g||b)&&Qe("span",{className:"flex",children:[g&&Qe(Kp,{domain:p.domain,link:f,title:p.titleText}),b&&Qe("span",{className:"text-grey-6","data-testid":"page-number",children:[g&&", ","p. ",b]})]})]})]})}),["settings"]);var Qp=Mo((function({quote:e,isHovered:t,isOrphan:n,settings:r}){return Qe($s,{collapsedHeight:35,inlineControls:!0,overflowThreshold:20,children:Qe(hp,{classes:Xe({"p-redacted-text":n}),children:Qe("blockquote",{className:Xe("hover:border-l-blue-quote",{"border-l-blue-quote":t}),style:To(["selectionFontFamily"],r),children:e})})})}),["settings"]);function ef({onToggleReplies:e,replyCount:t,threadIsCollapsed:n}){const r=`${n?"Show replies":"Hide replies"} (${t})`;return Qe(br,{
563
+ classes:Xe("text-grey-7 enabled:hover:text-brand-dark","enabled:hover:underline"),onClick:e,title:r,variant:"custom",children:r})}function tf(){return Qe("div",{className:Xe("flex grow justify-end items-center gap-x-1","h-8 touch:h-touch-minimum"),"data-testid":"saving-message",children:[Qe("span",{className:"text-[16px] animate-fade-in-slow",children:Qe(io,{size:"sm"})}),Qe("div",{className:"text-color-text-light font-medium",children:"Saving..."})]})}var nf=Mo((function({annotation:e,isReply:t,onToggleReplies:n,replyCount:r,threadIsCollapsed:o,annotationsService:i}){const a=ms(),s=Ti(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&&gi(e),f=a.defaultAuthority(),g=a.isFeatureEnabled("client_display_names"),v=de((()=>Ss(e,f,g)),[e,f,g]);return Qe("article",{className:"space-y-4","aria-label":`${gi(e)?Ai(e):`New ${Ai(e).toLowerCase()}`} by ${v}${a.isAnnotationHighlighted(e)?" - Highlighted":""}`,children:[Qe(Zp,{annotation:e,
564
+ isEditing:h,replyCount:r,threadIsCollapsed:o}),s&&Qe(Qp,{quote:s,isHovered:u,isOrphan:ki(e)}),!m&&!h&&Qe(bp,{annotation:e}),h&&Qe(Wp,{annotation:e,draft:l}),!m&&Qe("footer",{className:"flex items-center",children:[n&&Qe(ef,{onToggleReplies:n,replyCount:r,threadIsCollapsed:o}),d&&Qe(tf,{}),p&&Qe(ct,{classes:"grow",children:Qe(Hs,{annotation:e,onReply:()=>{gi(e)&&c&&i.reply(e,c)}})})]})]})}),["annotationsService"]);function rf({isReply:e,replyCount:t,threadIsCollapsed:n,onToggleReplies:r}){return Qe("article",{className:"space-y-4","aria-label":(e?"Reply":"Annotation")+" with unavailable content",children:[Qe("div",{children:Qe("em",{children:"Message not available."})}),r&&Qe("footer",{className:"flex items-center",children:Qe(ef,{onToggleReplies:r,replyCount:t,threadIsCollapsed:n})})]})}var of=Mo((function({annotation:e,api:t,toastMessenger:n}){const r=ms(),o=function(e){return e.moderation?e.moderation.flagCount:null}(e);return null!==o&&(o>0||e.hidden)?Qe("div",{
565
+ className:Xe("flex gap-x-3 bg-grey-1 text-color-text font-semibold","rounded-t-lg overflow-hidden","mb-2 ",{"-mt-3 -ml-3 -mr-3":!fi(e),"-mr-3":fi(e)}),children:[Qe("div",{className:Xe("p-3 text-white",{"bg-red-error":!e.hidden,"bg-grey-6":e.hidden}),children:e.hidden?Qe(bn,{className:"w-em h-em"}):Qe(an,{className:"w-em h-em"})}),Qe("div",{className:"self-center grow",children:[!e.hidden&&Qe("span",{children:["Flagged for review by ",o," ",1===o?"user":"users"]}),e.hidden&&Qe("span",{children:"Hidden from users"})]}),Qe("div",{className:"self-center pr-2",children:Qe(br,{classes:Xe("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((()=>{
566
+ 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 af({threadIsCollapsed:e,onToggleReplies:t}){const n=e?wt:Fn,r=e?"Expand replies":"Collapse replies";return Qe("div",{className:Xe("cursor-auto",{"bg-thread-line":!e}),"data-testid":"thread-collapse-channel",children:Qe("div",{className:Xe("bg-white"),children:Qe(br,{classes:Xe("-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:Qe(n,{className:"w-em h-em"})})})})}var sf=Mo((function e({thread:t,threadsService:n}){
567
+ const r=!!t.parent,o=t.children.filter((e=>ks(e)>0)),i=ms(),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&&Qe(x,{children:t.annotation?Qe(x,{children:[Qe(of,{annotation:t.annotation}),Qe(nf,{annotation:t.annotation,isReply:r,onToggleReplies:u?c:void 0,replyCount:t.replyCount,threadIsCollapsed:t.collapsed})]}):Qe(rf,{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 Qe("section",{className:"flex","data-testid":"thread-container",children:[r&&Qe(af,{threadIsCollapsed:t.collapsed,onToggleReplies:c}),Qe("div",{className:Xe("grow max-w-full min-w-0"),"data-testid":"thread-content",children:[d,xs(t)>0&&Qe("div",{className:"space-y-2",children:[!t.parent&&t.annotation&&Qe(Zp,{annotation:t.annotation,isEditing:l,
568
+ replyCount:t.replyCount,threadIsCollapsed:t.collapsed}),Qe("div",{children:Qe(br,{"data-testid":"show-hidden-button",onClick:()=>n.forceVisible(t),children:["Show ",xs(t)," more in conversation"]})})]}),!t.collapsed&&Qe("ul",{className:Xe("-ml-3"),"data-testid":"thread-children",children:o.map((t=>Qe("li",{className:Xe("mt-2","[text-align:start]"),children:Qe(e,{thread:t,threadsService:n})},t.id)))})]})]})}),["threadsService"]);var lf=Mo((function({frameSync:e,thread:t}){const n=ms(),r=t.annotation?.$tag??null,o=!(!r||!n.isAnnotationHovered(r)),i=de((()=>bs((t=>e.hoverAnnotation(t)),10)),[e]),a=n.isAnnotationHighlighted(t.annotation),s=he((t=>{e.scrollToAnnotation(t)}),[e]),l=de((()=>Qe(sf,{thread:t})),[t]),c=n.annotationFocusRequest(),u=ue(null);return le((()=>{c===t.id&&u.current&&(u.current.focus(),n.clearAnnotationFocusRequest())}),[c,n,t.id]),Qe(st,{active:o,classes:Xe("cursor-pointer focus-visible-ring theme-clean:border-none",{"border-brand":a}),"data-testid":"thread-card",elementRef:u,tabIndex:-1,
569
+ onClick:e=>{var n;(n=e.target).closest("button")||n.closest("a")||!t.annotation||s(t.annotation)},onMouseEnter:()=>i(t.annotation??null),onMouseLeave:()=>i(null),children:Qe(dt,{children:l})},t.id)}),["frameSync"]);const cf=50;function uf(){const e=document.querySelector(".js-thread-list-scroll-root");if(!e)throw new Error("Scroll container is missing");return e}function df(e){return Math.max(e-e%cf,0)}function hf(e){const t=e.target[0];if(t)return t.selector?.find((e=>"EPUBContentSelector"===e.type))}function mf(e){if(!e.annotation)return null;const t=hf(e.annotation);return t?.cfi??null}function pf({threads:e}){const[t,n]=ae(0),[r,o]=ae(0);ce((()=>{const e=new ke,t=uf();n(t.clientHeight),o(df(t.scrollTop));const r=bs((()=>{n(t.clientHeight),o(df(t.scrollTop))}),10,{maxWait:100});return e.add(t,"scroll",r),e.add(window,"resize",r),()=>{e.removeAll(),r.cancel()}}),[])
570
+ ;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=ys){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=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=hf(n.annotation);e?.title&&t.set(e.cfi,e.title)}return t}(e),o=new Map;for(const i of e){const e=mf(i);if(!e||t===e)continue;t=e;const a=r.get(e)??"Untitled chapter";n!==a&&(n=a,o.set(i,a))}return o}),[e]),p=ms(),f=p.countDrafts()>0,g=p.highlightedAnnotations(),v=p.allAnnotations(),b=(()=>{const e=p.unsavedAnnotations();return e.length?e[e.length-1].$tag:null})();le((()=>{b&&(p.setForcedVisible(b,!0),l(b))}),[p,b]);const y=de((()=>{
571
+ const e=v.filter((e=>e.id&&g.includes(e.id))).reduce(((e,t)=>!e||e.updated<t.updated?t:e),null);return e?.id}),[v,g]);return le((()=>{!f&&y&&l(y)}),[f,y]),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)||ys.defaultHeight)(t)),0);uf().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=_s(r);o!==e.get(n)&&t.set(n,o)}return 0===t.size?e:new Map([...e,...t])}))}),[h]),Qe("div",{children:[Qe("div",{style:{height:d}}),h.map((e=>Qe("div",{className:Xe("mb-3"),"data-testid":"thread-card-container",id:e.id,children:[m.get(e)&&Qe("h3",{className:"text-md text-grey-7 font-bold pt-3 pb-2",children:m.get(e)}),Qe(lf,{thread:e})]},e.id))),Qe("div",{style:{height:u}})]})}const ff={collapsed:!1,depth:0,visible:!0,replyCount:0};function gf(e){return e.id||e.$tag}function vf(e,t,n){
572
+ const r=e[n];return!(!r||r.parent===t)&&(!r.parent||vf(e,t,r.parent))}function bf(e,t,n){if(e[t].parent||!n.length)return;const r=n[n.length-1];e[r]||(e[r]={...ff,children:[],id:r},bf(e,r,n.slice(0,-1))),vf(e,t,r)&&(e[t].parent=r,e[r].children.push(e[t]))}function yf(e,t){return Object.assign({},t(e),{children:e.children.map((e=>yf(e,t)))})}function _f(e,t,n){const r=e.children.map((e=>_f(e,n,n))).slice().sort(t);return{...e,children:r}}function wf(e,t){const n=e.children.map((e=>wf(e,t+1))),r=n.reduce(((e,t)=>e+1+t.replyCount),0);return{...e,children:n,depth:t,replyCount:r}}function xf(e){return e.children.some((e=>e.visible||xf(e)))}const kf=(e,t)=>e.annotation&&t.annotation?e.annotation.created<t.annotation.created?-1:e.annotation.created>t.annotation.created?1:0:0;function Nf(e,t){const n=t.selected.length>0,r=t.forcedVisible.length>0;let o=function(e){const t={};e.forEach((e=>{const n=gf(e);t[n]={...ff,children:[],annotation:e,id:n}})),e.forEach((e=>{const n=(e.references||[]).filter((t=>t!==e.id))
573
+ ;return bf(t,gf(e),n)}));const n=[];for(const e in t)t[e].parent||(t[e].collapsed=!0,n.push(t[e]));return{...ff,id:"root",children:n}}(e);if(n)o.children=o.children.filter((e=>{const n=t.selected.includes(e.id),o=r&&t.forcedVisible.includes(e.id);return n||o}));else if(t.threadFilterFn){const e=t.threadFilterFn;o.children=o.children.filter((n=>!(!r||!t.forcedVisible.includes(n.id))||e(n)))}return o.visible=!1,o=yf(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||xf(e))),o=yf(o,(e=>{const n={collapsed:e.collapsed};if(si(t.expanded,e.id))n.collapsed=!t.expanded[e.id];else{const r=t.filterFn&&xf(e);n.collapsed=e.collapsed&&!r}return{...e,...n}})),o=_f(o,t.sortCompareFn,kf),o=wf(o,-1),o}function Sf(e){const t=Af(e),[n,r]=t.split("-",2);return[n,r??n]}function Af(e){if(!e.includes("["))return e;let t="",n=!1,r=!1
574
+ ;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 Ef(e,t){const n=e=>function(e){const t=Af(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}(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))}function Tf(e,t,n){return Ef(e,t)>=0&&Ef(e,n)<0}function Cf(e){if(!e)return null;const[t,n]=e.includes("-")?e.split("-"):[e,e];let r=null;if(t&&(r=parseInt(t),!Number.isInteger(r)))return null;let o=null;return n&&(o=parseInt(n),!Number.isInteger(o))?null:null===r||null===o?[r,o]:[Math.min(r,o),Math.max(r,o)]}let Mf=function(e){return e[e.Overlap=0]="Overlap",e[e.NoOverlap=1]="NoOverlap",e[e.Unknown=2]="Unknown",e}({});function If(e,t,n){return[e[0]??t,e[1]??n]}function zf(e,t){const n=Cf(e),r=Cf(t)
575
+ ;if(!n||!r)return e&&t&&e===t?Mf.Overlap:Mf.Unknown;const o=2**31,[i,a]=If(n,1,o),[s,l]=If(r,1,o);return i<=s?s<=a?Mf.Overlap:Mf.NoOverlap:i<=l?Mf.Overlap:Mf.NoOverlap}
575
576
  const Lf=/[\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
576
577
  ;function Of(e){return function(e){return e.replace(Lf,"")}((t=e,t.normalize("NFKD"))).toLowerCase();var t}class Rf{constructor(e,t){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 Pf{constructor(e,t){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 Df(e){return{fieldValues:e,matches:(e,t)=>e.includes(t),normalize:Of}}const Ff={quote:Df((e=>[Ti(e)??""])),cfi:{fieldValues:e=>[Ci(e)?.trim()??""],matches:(e,t)=>{const[n,r]=Sf(t);return Tf(e,n,r)},normalize:e=>Af(e.trim())},page:{fieldValues:e=>[Mi(e)?.trim()??""],matches:(e,t)=>zf(e,t)===Mf.Overlap,normalize:e=>e.trim()},since:{fieldValues:e=>[new Date(e.updated).valueOf()],matches:(e,t)=>(Date.now()-e)/1e3<=t,normalize:e=>e},tag:Df((e=>e.tags)),text:Df((e=>[e.text])),uri:Df((e=>[e.uri])),user:Df((e=>[e.user,e.user_info?.display_name??""]))}
577
578
  ;function Hf(e,t){const n=(e,t)=>new Rf(t,Ff[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 Pf("or",e.map((e=>n(e,t))))))}else r=t.terms.map((t=>n(e,t)));return new Pf(t.operator,r)})),o=new Pf("and",r);return e.filter((e=>o.matches(e)))}const Bf=["cfi","quote","page","since","tag","text","uri","user"],jf=["group","quote","tag","text","uri","user"];function $f(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 qf(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){const n=e.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);return n?n.map(qf).filter((e=>e.length>0)).map((e=>{const[n,r]=$f(e,t);return n?n+":"+qf(r):e})):[]}function Gf(e){const t={},n=e=>"tag"===e?"tags":e,r=Uf(e,jf);for(const e of r){let[r,o]=$f(e,jf);r||(r="any",o=e);const i=n(r);t[i]?t[i].push(o):t[i]=[o]}
578
579
  return t}function Vf(e){return ki(e)?"orphan":Ni(e)?"note":"annotation"}function Wf(e){return Ns([e]).reduce(((e,t)=>t.created>e?t.created:e),"")}function Kf(e){return Ns([e]).reduce(((e,t)=>(e||(e=t.created),t.created<e?t.created:e)),"")}const Yf={Newest:(e,t)=>{const n=Wf(e),r=Wf(t);return n>r?-1:n<r?1:0},Oldest:(e,t)=>{const n=Kf(e),r=Kf(t);return n<r?-1:n>r?1:0},Location:(e,t)=>{if(!e.annotation||!t.annotation)return function(e,t){return e.annotation||t.annotation?e.annotation?1:-1:0}(e,t);const n=Ei(e.annotation),r=Ei(t.annotation);if(n.cfi&&r.cfi){const e=Ef(n.cfi,r.cfi);if(0!==e)return Math.sign(e)}else{if(n.cfi)return-1;if(r.cfi)return 1}const o=n.position??Number.MAX_SAFE_INTEGER,i=r.position??Number.MAX_SAFE_INTEGER;return Math.sign(o-i)}};const Xf=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,
579
580
  selected:t.selected,sortCompareFn:Yf[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,Bf);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},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,
580
581
  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={};for(const[t,n]of Object.entries(e))n.filterReplies?r[t]=n:o[t]=n;n.filterFn=e=>Hf([e],r).length>0,Object.values(o).some((e=>e.terms.length>0))&&(n.threadFilterFn=e=>!!e.annotation&&Hf([e.annotation],o).length>0)}const r=Nf(e.annotations,n),o={annotation:0,note:0,orphan:0};return e.showTabs&&(r.children=r.children.filter((e=>{if(!e.annotation)return!1;if(_i(e.annotation))return!1;const n=Vf(e.annotation);return o[n]+=1,n===t.selectedTab}))),{tabCounts:o,rootThread:r}}));function Jf(){const e=ms(),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 Xf(s)}
581
- var Zf,Qf,eg=Mo((function({loadAnnotationsService:e,onLogin:t}){const n=ms(),r=n.routeParams().id??"",{rootThread:o}=Jf(),i=n.profile().userid,[a,s]=ae(!1);return le((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{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]),Qe(x,{children:[a&&Qe(ps,{errorType:"annotation",onLoginRequest:t}),Qe(pf,{threads:o.children})]})}),["loadAnnotationsService"]);class tg{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.1571.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])}
582
+ var Zf,Qf,eg=Mo((function({loadAnnotationsService:e,onLogin:t}){const n=ms(),r=n.routeParams().id??"",{rootThread:o}=Jf(),i=n.profile().userid,[a,s]=ae(!1);return le((()=>{s(!1),n.clearAnnotations(),e.loadThread(r).then((e=>{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]),Qe(x,{children:[a&&Qe(ps,{errorType:"annotation",onLoginRequest:t}),Qe(pf,{threads:o.children})]})}),["loadAnnotationsService"]);class tg{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.1573.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])}
582
583
  i.url&&e.push(["URL",i.url]),this.segment=e.map((([e,t])=>`${e}: ${t}`)).join(", ")}}asFormattedString(){return`Version: ${this.version}\nUser Agent: ${this.userAgent}\nURL: ${this.urls}\nFingerprint: ${this.fingerprint}\nAccount: ${this.account}\nDate: ${this.timestamp}\n`}asEncodedURLString(){return encodeURIComponent(this.asFormattedString())}}var ng=function(){if(Qf)return Zf;Qf=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,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,
583
584
  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),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){
584
585
  return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function a(){return!0}function s(e){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 Zf=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,m=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 p=[];u;)if(l.debug&&console.log("Scrolling parent node",u),h(u,d)&&(m?m(u,i):i(u))&&(d++,p.push(u)),!(u=s(u))){f(e);break}return p.reduce(((e,i,a)=>function(e,n,i,a,s){
@@ -665,7 +666,7 @@ buildTextExportContent(e,{groupName:t="",displayNamesEnabled:n=!1,defaultAuthori
665
666
  }),Qe("body",{children:[Qe("section",{children:[Qe("h1",{children:"Summary"}),Qe("p",{children:Qe("time",{dateTime:o.toISOString(),children:Gb(o)})}),Qe("p",{children:Qe("strong",{children:a})}),Qe("p",{children:Qe("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),Qe("table",{children:Qe("tbody",{style:{verticalAlign:"top"},children:[Qe("tr",{children:[Qe("td",{children:"Group:"}),Qe("td",{children:t})]}),Qe("tr",{children:[Qe("td",{children:"Total users:"}),Qe("td",{children:s.length})]}),Qe("tr",{children:[Qe("td",{children:"Users:"}),Qe("td",{children:s.join(", ")})]}),Qe("tr",{children:[Qe("td",{children:"Total annotations:"}),Qe("td",{children:e.length})]}),Qe("tr",{children:[Qe("td",{children:"Total replies:"}),Qe("td",{children:l.length})]})]})})]}),Qe("hr",{}),Qe("section",{children:[Qe("h1",{children:"Annotations"}),e.map(((e,t)=>{const n=Mi(e),r=Ti(e),o=dp(e.text),i=o===`<p>${e.text}</p>`?e.text:o;return Qe("article",{children:[Qe("h2",{children:["Annotation ",t+1,":"]
666
667
  }),Qe("table",{children:Qe("tbody",{style:{verticalAlign:"top"},children:[Qe("tr",{children:[Qe("td",{children:"Created at:"}),Qe("td",{children:Qe("time",{dateTime:e.created,children:Gb(new Date(e.created))})})]}),Qe("tr",{children:[Qe("td",{children:"Author:"}),Qe("td",{children:c(e)})]}),n&&Qe("tr",{children:[Qe("td",{children:"Page:"}),Qe("td",{children:n})]}),Qe("tr",{children:[Qe("td",{children:"Type:"}),Qe("td",{children:Ai(e)})]}),r&&Qe("tr",{children:[Qe("td",{children:"Quote:"}),Qe("td",{children:Qe("blockquote",{style:{margin:0},children:r})})]}),Qe("tr",{children:[Qe("td",{children:"Comment:"}),Qe("td",{dangerouslySetInnerHTML:{__html:i}})]}),e.tags.length>0&&Qe("tr",{children:[Qe("td",{children:"Tags:"}),Qe("td",{children:e.tags.join(", ")})]})]})})]},e.id)}))]})]})]}),{},{pretty:!0}).replace(/\t/g," ")}_exportCommon(e,{displayNamesEnabled:t,defaultAuthority:n}){const[r]=e;if(!r)throw new Error("No annotations to export");const o=e=>Ss(e,n,t),{uri:i,title:a}=di(r);return{uri:i,title:a,
667
668
  uniqueUsers:[...new Set(e.map((e=>o(e))).filter(Boolean))],replies:e.filter((e=>fi(e))),extractUsername:o}}}Vb.$inject=[];class Wb extends Error{constructor(e,t,n=""){let r="Network request failed";t&&(r+=` (${t.status})`),n&&(r+=`: ${n}`),super(r),this.url=e,this.response=t,this.reason=n}}async function Kb(e,t){let n,r;try{n=await fetch(e,t)}catch(t){throw new Wb(e,null,t.message)}if(204===n.status)return null;try{r=await n.json()}catch{throw new Wb(e,n,"Failed to parse response")}if(!n.ok)throw new Wb(e,n,r?.reason);return r}class Yb{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={
668
- "Content-Type":"application/json","Hypothesis-Client-Version":"1.1571.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:m}=Ha(c.url,a),p=new URL(h);for(const[e,t]of Object.entries(m)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&p.searchParams.append(e,t.toString())}return await Kb(p.toString(),{body:s?JSON.stringify(Ub(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={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")},members:{read:i("group.members.read")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},
669
+ "Content-Type":"application/json","Hypothesis-Client-Version":"1.1573.0"};i&&(u.Authorization="Bearer "+i);const d=r();d&&(u["X-Client-Id"]=d);const{url:h,unusedParams:m}=Ha(c.url,a),p=new URL(h);for(const[e,t]of Object.entries(m)){const n=Array.isArray(t)?t:[t];for(const t of n)null!=t&&p.searchParams.append(e,t.toString())}return await Kb(p.toString(),{body:s?JSON.stringify(Ub(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={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")},members:{read:i("group.members.read")},read:i("group.read")},this.groups={list:i("groups.read")},this.profile={groups:{read:i("profile.groups.read")},
669
670
  read:i("profile.read"),update:i("profile.update")},this.analytics={events:{create:i("analytics.events.create")}}}setClientId(e){this._clientId=e}}Yb.$inject=["apiRoutes","auth","store"];var Xb,Jb,Zb,Qb,ey,ty={};function ny(){return Zb||(Zb=1,e=ty,t=function(){if(Jb)return Xb;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 Jb=1,Xb=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){
670
671
  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},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)},
671
672
  e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.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},Xb}(),e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t))
@@ -779,7 +780,7 @@ const e=Object.values(this._store.pendingUpdates());e.length&&(this._store.addAn
779
780
  const e=1e3*2**this._reconnectionAttempts;setTimeout((()=>this._reconnect()),e)}else console.error("Gave up trying to reconnect to Hypothesis real time update service")})),r.on("error",(t=>this._handleSocketError(e,t))),r.on("message",(e=>this._handleSocketMessage(e))),this._socket=r,this.setConfig("client-id",{messageType:"client_id",value:this.clientId}),this.setConfig("auth-check",{type:"whoami",id:1})}async connect(e={}){this._updateImmediately=e.applyUpdatesImmediately??!0,this._reconnectSetUp||(this._reconnectSetUp=!0,xy(this._store.subscribe,(()=>this._store.profile().userid),(()=>this._reconnect()))),this._socket||await this._reconnect()}}CN.$inject=["store","apiRoutes","auth","groups","session","$window"];const MN="hypothesis.user.tags.list",IN="hypothesis.user.tags.map";class zN{constructor(e){this._storage=e}filter(e,t=null){const n=this._storage.getObject(MN)||[];let r=0;return n.filter((n=>{if(null!==t&&r>=t)return!1;const o=n.split(/\W+/),i=new RegExp(`^${Dv(e)}`,"i")
780
781
  ;return!(!o.some((e=>e.match(i)))&&!n.match(i))&&(++r,!0)}))}store(e){const t=this._storage.getObject(IN)||{};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(IN,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(MN,n)}}zN.$inject=["localStorage"];class LN{constructor(e){this._store=e}forceVisible(e){e.children.forEach((e=>{this.forceVisible(e)})),e.visible||this._store.setForcedVisible(e.id,!0)}}LN.$inject=["store"];class ON extends fg.TinyEmitter{constructor(e,t){super(),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))}
781
782
  _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:Av(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)}}ON.$inject=["store","$window"];const RN=function(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),r=0;r<n.length;r++){var o=void 0;try{o=JSON.parse(n[r].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),o={}}Object.assign(t,o)}return t}(document),PN=function(e){const{version:t,origin:n}=Tv(e.location.href)
782
- ;return"1.1571.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1571.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 DN(e,t){e.setClientId(t.clientId)}function FN(e){e.sync()}function HN(e,t){e.load(),t.load()}function BN(e,t,n){e.init(),t.init(),n.init()}function jN(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})}))}RN.sentry&&PN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;pN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1571.0",beforeSend:(e,t)=>{
783
+ ;return"1.1573.0"!==t?(console.warn(`The Hypothesis sidebar is using a different version (1.1573.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 DN(e,t){e.setClientId(t.clientId)}function FN(e){e.sync()}function HN(e,t){e.load(),t.load()}function BN(e,t,n){e.init(),t.init(),n.init()}function jN(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})}))}RN.sentry&&PN&&function(e){const t=function(){const e=import.meta.url;return e?new URL(e).origin:null}(),n=t?[t]:void 0;pN({dsn:e.dsn,environment:e.environment,allowUrls:n,ignoreErrors:["Network request failed","Object Not Found Matching Id"],release:"1.1573.0",beforeSend:(e,t)=>{
783
784
  if(fN>=5)return Ov("Client-side Sentry quota reached. No further Sentry events will be sent"),null;++fN;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{px("host_config",Tv(window.location.href))}catch{}px("loaded_scripts",Array.from(document.querySelectorAll("script")).filter((e=>!e.type||e.type.match(/javascript|module/))).map((e=>e.src||"<inline>"))),fy(((e,t)=>{gN(e,t)}))}(RN.sentry),document.body.addEventListener("click",(e=>{const t=e.target;"A"===t.tagName&&"_blank"===t.target&&(t.rel="noopener")})),DN.$inject=["api","streamer"],FN.$inject=["router"],HN.$inject=["groups","session"],BN.$inject=["autosaveService","persistedDefaults","serviceURL"],jN.$inject=["frameSync","store","toastMessenger"];const $N=document.querySelector("hypothesis-app");!function(e=window){e.addEventListener("message",Uv)}(),async function(e,t=window){const n=function(e){
784
785
  const t=Tv(e.location.href),n=["annotations","group","query","appType","openSidebar","showHighlights","services","branding","enableExperimentalNewNoteButton","focus","requestConfigFromFrame","theme","usernameUrl"],r={openSidebar:Cv,requestConfigFromFrame:e=>{if("string"==typeof e)return e;const t=function(e){return"object"==typeof e&&null!==e?e:{}}(e);return{origin:Iv(t.origin),ancestorLevel:Mv(t.ancestorLevel)}}},o={};for(const[e,i]of Object.entries(t))n.includes(e)&&null!==i&&(r[e]?o[e]=r[e](i):o[e]=i);return o}(window),r=function(e,t){const n=e.requestConfigFromFrame;if(!n)return null;if("number"!=typeof n.ancestorLevel||"string"!=typeof n.origin)throw new Error("Improper `requestConfigFromFrame` object. Both `ancestorLevel` and `origin` need to be specified");return{targetFrame:zv(n.ancestorLevel,t),origin:n.origin}}(n,t);let o;if(r){const e=await async function(e,t){return{...await Ev(t.targetFrame,t.origin,"requestConfig",[],3e3),...e.group?{group:e.group}:{}}}(n,r);o=function(e,t){const n=e.services
785
786
  ;return Array.isArray(n)?(n.forEach(((e,n)=>{"$rpc:requestGroups"===e.groups&&(e.groups=Ev(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=So(e);if(!t)return e.apiUrl;if(t.apiUrl)return t.apiUrl;throw new Error("Service should contain an apiUrl value.")}(i),i}(RN).then((e=>{!function(e,t){const n=new G