hypothesis 1.1748.0 → 1.1750.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.
@@ -7,10 +7,10 @@ S&&null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(S&&null==D
7
7
  S&&!f&&null!=u.getSnapshotBeforeUpdate&&(v=u.getSnapshotBeforeUpdate(p,b)),L=d,null!=d&&d.type===y&&null==d.key&&(L=O(d.props.children)),l=A(t,g(L)?L:[L],n,o,i,r,s,a,l,c,h),u.base=n.__e,n.__u&=-161,u.__h.length&&a.push(u),x&&(u.__E=u.__=null)}catch(t){if(n.__v=null,c||null!=s)if(t.then){for(n.__u|=c?160:128;l&&8==l.nodeType&&l.nextSibling;)l=l.nextSibling;s[s.indexOf(l)]=null,n.__e=l}else{for(B=s.length;B--;)m(s[B]);N(n)}else n.__e=o.__e,n.__k=o.__k,t.then||N(n);e.__e(t,n,o)}else null==s&&n.__v==o.__v?(n.__k=o.__k,n.__e=o.__e):l=n.__e=I(o.__e,n,o,i,r,s,a,c,h);return(d=e.diffed)&&d(n),128&n.__u?void 0:l}function N(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(N)}function L(t,n,o){for(var i=0;i<o.length;i++)B(o[i],o[++i],o[++i]);e.__c&&e.__c(n,t),t.some((function(n){try{t=n.__h,n.__h=[],t.some((function(t){t.call(n)}))}catch(t){e.__e(t,n.__v)}}))}function O(t){return"object"!=typeof t||null==t||t.__b&&t.__b>0?t:g(t)?t.map(O):_({},t)}function I(n,o,i,r,s,a,l,c,h){
8
8
  var d,f,p,_,b,y,w,x=i.props||u,C=o.props,S=o.type;if("svg"==S?s="http://www.w3.org/2000/svg":"math"==S?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),null!=a)for(d=0;d<a.length;d++)if((b=a[d])&&"setAttribute"in b==!!S&&(S?b.localName==S:3==b.nodeType)){n=b,a[d]=null;break}if(null==n){if(null==S)return document.createTextNode(C);n=document.createElementNS(s,S,C.is&&C),c&&(e.__m&&e.__m(o,a),c=!1),a=null}if(null==S)x===C||c&&n.data==C||(n.data=C);else{if(a=a&&t.call(n.childNodes),!c&&null!=a)for(x={},d=0;d<n.attributes.length;d++)x[(b=n.attributes[d]).name]=b.value;for(d in x)if(b=x[d],"children"==d);else if("dangerouslySetInnerHTML"==d)p=b;else if(!(d in C)){if("value"==d&&"defaultValue"in C||"checked"==d&&"defaultChecked"in C)continue;E(n,d,null,b,s)}for(d in C)b=C[d],"children"==d?_=b:"dangerouslySetInnerHTML"==d?f=b:"value"==d?y=b:"checked"==d?w=b:c&&"function"!=typeof b||x[d]===b||E(n,d,b,x[d],s);if(f)c||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),
9
9
  o.__k=[];else if(p&&(n.innerHTML=""),A("template"==o.type?n.content:n,g(_)?_:[_],o,i,r,"foreignObject"==S?"http://www.w3.org/1999/xhtml":s,a,l,a?a[0]:i.__k&&v(i,0),c,h),null!=a)for(d=a.length;d--;)m(a[d]);c||(d="value","progress"==S&&null==y?n.removeAttribute("value"):null!=y&&(y!==n[d]||"progress"==S&&!y||"option"==S&&y!=x[d])&&E(n,d,y,x[d],s),d="checked",null!=w&&w!=n[d]&&E(n,d,w,x[d],s))}return n}function B(t,n,o){try{if("function"==typeof t){var i="function"==typeof t.__u;i&&t.__u(),i&&null==n||(t.__u=t(n))}else t.current=n}catch(t){e.__e(t,o)}}function D(t,n,o){var i,r;if(e.unmount&&e.unmount(t),(i=t.ref)&&(i.current&&i.current!=t.__e||B(i,null,n)),null!=(i=t.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){e.__e(t,n)}i.base=i.__P=null}if(i=t.__k)for(r=0;r<i.length;r++)i[r]&&D(i[r],n,o||"function"!=typeof t.type);o||m(t.__e),t.__c=t.__=t.__e=void 0}function F(t,e,n){return this.constructor(t,n)}function H(n,o,i){var r,s,a;o==document&&(o=document.documentElement),e.__&&e.__(n,o),
10
- r=!1?null:o.__k,s=[],a=[],T(o,n=o.__k=function(e,n,o){var i,r,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?r=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?t.call(arguments,2):o),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===a[s]&&(a[s]=e.defaultProps[s]);return b(e,a,i,r,null)}(y,null,[n]),r||u,u,o.namespaceURI,r?null:o.firstChild?t.call(o.childNodes):null,s,r?r.__e:o.firstChild,false,a),L(s,n,a)}function z(t){function e(t){var n,o;return this.getChildContext||(n=new Set,(o={})[e.__c]=this,this.getChildContext=function(){return o},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(t){this.props.value!=t.value&&n.forEach((function(t){t.__e=!0,C(t)}))},this.sub=function(t){n.add(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n&&n.delete(t),e&&e.call(t)}}),t.children}return e.__c="__cC"+d++,e.__=t,e.Provider=e.__l=(e.Consumer=function(t,e){return t.children(e)}).contextType=e,e}t=f.slice,e={__e:function(t,e,n,o){
11
- for(var i,r,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(t)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(t,o||{}),s=i.__d),s)return i.__E=i}catch(e){t=e}throw t}},n=0,w.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=_({},this.state),"function"==typeof t&&(t=t(_({},n),this.props)),t&&_(n,t),null!=t&&this.__v&&(e&&this._sb.push(e),C(this))},w.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),C(this))},w.prototype.render=y,o=[],r="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(t,e){return t.__v.__b-e.__v.__b},S.__r=0,a=/(PointerCapture)$|Capture$/i,l=0,c=P(!1),h=P(!0),d=0;var V,U,$,q,W=0,j=[],K=e,X=K.__b,Y=K.__r,G=K.diffed,Q=K.__c,J=K.unmount,Z=K.__;function tt(t,e){K.__h&&K.__h(U,t,W||e),W=0;var n=U.__H||(U.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function et(t){
12
- return W=1,function(t,e,n){var o=tt(V++,2);if(o.t=t,!o.__c&&(o.__=[gt(void 0,e),function(t){var e=o.__N?o.__N[0]:o.__[0],n=o.t(e,t);e!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=U,!U.__f)){var i=function(t,e,n){if(!o.__c.__H)return!0;var i=o.__c.__H.__.filter((function(t){return!!t.__c}));if(i.every((function(t){return!t.__N})))return!r||r.call(this,t,e,n);var s=o.__c.props!==t;return i.forEach((function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),r&&r.call(this,t,e,n)||s};U.__f=!0;var r=U.shouldComponentUpdate,s=U.componentWillUpdate;U.componentWillUpdate=function(t,e,n){if(this.__e){var o=r;r=void 0,i(t,e,n),r=o}s&&s.call(this,t,e,n)},U.shouldComponentUpdate=i}return o.__N||o.__}(gt,t)}function nt(t,e){var n=tt(V++,3);!K.__s&&pt(n.__H,e)&&(n.__=t,n.u=e,U.__H.__h.push(n))}function ot(t,e){var n=tt(V++,4);!K.__s&&pt(n.__H,e)&&(n.__=t,n.u=e,U.__h.push(n))}function it(t){return W=5,rt((function(){return{current:t}}),[])}function rt(t,e){var n=tt(V++,7)
13
- ;return pt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function st(t,e){return W=8,rt((function(){return t}),e)}function at(t){var e=U.context[t.__c],n=tt(V++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function lt(){var t=tt(V++,11);if(!t.__){for(var e=U.__v;null!==e&&!e.__m&&null!==e.__;)e=e.__;var n=e.__m||(e.__m=[0,0]);t.__="P"+n[0]+"-"+n[1]++}return t.__}function ct(){for(var t;t=j.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ut),t.__H.__h.forEach(ft),t.__H.__h=[]}catch(e){t.__H.__h=[],K.__e(e,t.__v)}}K.__b=function(t){U=null,X&&X(t)},K.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Z&&Z(t,e)},K.__r=function(t){Y&&Y(t),V=0;var e=(U=t.__c).__H;e&&($===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0}))):(e.__h.forEach(ut),e.__h.forEach(ft),e.__h=[],V=0)),$=U},K.diffed=function(t){G&&G(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==j.push(e)&&q===K.requestAnimationFrame||((q=K.requestAnimationFrame)||dt)(ct)),
10
+ r=!1?null:o.__k,s=[],a=[],T(o,n=o.__k=function(e,n,o){var i,r,s,a={};for(s in n)"key"==s?i=n[s]:"ref"==s?r=n[s]:a[s]=n[s];if(arguments.length>2&&(a.children=arguments.length>3?t.call(arguments,2):o),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===a[s]&&(a[s]=e.defaultProps[s]);return b(e,a,i,r,null)}(y,null,[n]),r||u,u,o.namespaceURI,r?null:o.firstChild?t.call(o.childNodes):null,s,r?r.__e:o.firstChild,false,a),L(s,n,a)}function V(t){function e(t){var n,o;return this.getChildContext||(n=new Set,(o={})[e.__c]=this,this.getChildContext=function(){return o},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(t){this.props.value!=t.value&&n.forEach((function(t){t.__e=!0,C(t)}))},this.sub=function(t){n.add(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){n&&n.delete(t),e&&e.call(t)}}),t.children}return e.__c="__cC"+d++,e.__=t,e.Provider=e.__l=(e.Consumer=function(t,e){return t.children(e)}).contextType=e,e}t=f.slice,e={__e:function(t,e,n,o){
11
+ for(var i,r,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(t)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(t,o||{}),s=i.__d),s)return i.__E=i}catch(e){t=e}throw t}},n=0,w.prototype.setState=function(t,e){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=_({},this.state),"function"==typeof t&&(t=t(_({},n),this.props)),t&&_(n,t),null!=t&&this.__v&&(e&&this._sb.push(e),C(this))},w.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),C(this))},w.prototype.render=y,o=[],r="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,s=function(t,e){return t.__v.__b-e.__v.__b},S.__r=0,a=/(PointerCapture)$|Capture$/i,l=0,c=P(!1),h=P(!0),d=0;var z,U,$,q,W=0,j=[],K=e,X=K.__b,Y=K.__r,G=K.diffed,Q=K.__c,J=K.unmount,Z=K.__;function tt(t,e){K.__h&&K.__h(U,t,W||e),W=0;var n=U.__H||(U.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function et(t){
12
+ return W=1,function(t,e,n){var o=tt(z++,2);if(o.t=t,!o.__c&&(o.__=[gt(void 0,e),function(t){var e=o.__N?o.__N[0]:o.__[0],n=o.t(e,t);e!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=U,!U.__f)){var i=function(t,e,n){if(!o.__c.__H)return!0;var i=o.__c.__H.__.filter((function(t){return!!t.__c}));if(i.every((function(t){return!t.__N})))return!r||r.call(this,t,e,n);var s=o.__c.props!==t;return i.forEach((function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),r&&r.call(this,t,e,n)||s};U.__f=!0;var r=U.shouldComponentUpdate,s=U.componentWillUpdate;U.componentWillUpdate=function(t,e,n){if(this.__e){var o=r;r=void 0,i(t,e,n),r=o}s&&s.call(this,t,e,n)},U.shouldComponentUpdate=i}return o.__N||o.__}(gt,t)}function nt(t,e){var n=tt(z++,3);!K.__s&&pt(n.__H,e)&&(n.__=t,n.u=e,U.__H.__h.push(n))}function ot(t,e){var n=tt(z++,4);!K.__s&&pt(n.__H,e)&&(n.__=t,n.u=e,U.__h.push(n))}function it(t){return W=5,rt((function(){return{current:t}}),[])}function rt(t,e){var n=tt(z++,7)
13
+ ;return pt(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function st(t,e){return W=8,rt((function(){return t}),e)}function at(t){var e=U.context[t.__c],n=tt(z++,9);return n.c=t,e?(null==n.__&&(n.__=!0,e.sub(U)),e.props.value):t.__}function lt(){var t=tt(z++,11);if(!t.__){for(var e=U.__v;null!==e&&!e.__m&&null!==e.__;)e=e.__;var n=e.__m||(e.__m=[0,0]);t.__="P"+n[0]+"-"+n[1]++}return t.__}function ct(){for(var t;t=j.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ut),t.__H.__h.forEach(ft),t.__H.__h=[]}catch(e){t.__H.__h=[],K.__e(e,t.__v)}}K.__b=function(t){U=null,X&&X(t)},K.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Z&&Z(t,e)},K.__r=function(t){Y&&Y(t),z=0;var e=(U=t.__c).__H;e&&($===U?(e.__h=[],U.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.u=t.__N=void 0}))):(e.__h.forEach(ut),e.__h.forEach(ft),e.__h=[],z=0)),$=U},K.diffed=function(t){G&&G(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==j.push(e)&&q===K.requestAnimationFrame||((q=K.requestAnimationFrame)||dt)(ct)),
14
14
  e.__H.__.forEach((function(t){t.u&&(t.__H=t.u),t.u=void 0}))),$=U=null},K.__c=function(t,e){e.some((function(t){try{t.__h.forEach(ut),t.__h=t.__h.filter((function(t){return!t.__||ft(t)}))}catch(n){e.some((function(t){t.__h&&(t.__h=[])})),e=[],K.__e(n,t.__v)}})),Q&&Q(t,e)},K.unmount=function(t){J&&J(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach((function(t){try{ut(t)}catch(t){e=t}})),n.__H=void 0,e&&K.__e(e,n.__v))};var ht="function"==typeof requestAnimationFrame;function dt(t){var e,n=function(){clearTimeout(o),ht&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);ht&&(e=requestAnimationFrame(n))}function ut(t){var e=U,n=t.__c;"function"==typeof n&&(t.__c=void 0,n()),U=e}function ft(t){var e=U;t.__c=t.__(),U=e}function pt(t,e){return!t||t.length!==e.length||e.some((function(e,n){return e!==t[n]}))}function gt(t,e){return"function"==typeof e?e(t):e}function _t(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e)
15
15
  ;if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}class mt{constructor(){_t(this,"_listeners",void 0),this._listeners=new Map}add(t,e,n,o){t.addEventListener(e,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:t,eventType:e,listener:n,options:o}),i}remove(t){const e=this._listeners.get(t);if(e){const{eventTarget:n,eventType:o,listener:i,options:r}=e;n.removeEventListener(o,i,r),this._listeners.delete(t)}}removeAll(){this._listeners.forEach((({eventTarget:t,eventType:e,listener:n,options:o})=>{t.removeEventListener(e,n,o)})),this._listeners.clear()}}function bt(t){t.focus()}function yt(t,{autofocus:e=!1,loop:n=!0,horizontal:o=!0,vertical:i=!0,selector:r="a,button",containerVisible:s=!0,focusElement:a=bt}={}){const l=it(null),c=function(t){const e=it({callback:t,
16
16
  call:(...t)=>e.current.callback(...t)});return e.current.callback=t,e.current.call}(a);nt((()=>{if(!s)return()=>{};if(!t.current)throw new Error("Container ref not set");const a=t.current,h=()=>{const t=Array.from(a.querySelectorAll(r)).filter((t=>null!==t.offsetParent&&!function(t){return"boolean"==typeof t.disabled&&t.disabled}(t)));return document.activeElement===a&&t.unshift(a),t},d=(t=h(),e=-1,n=!1,o)=>{e<0&&(e=t.findIndex((t=>0===t.tabIndex)))<0&&(e=0);for(const[i,r]of t.entries())r.tabIndex=i===e?0:-1,i===e&&n&&(l.current=r,c(r,o))},u=h(),f=l.current?u.indexOf(l.current):0;d(u,f,e);const p=new mt;p.add(a,"focusin",(t=>{if(t.target===a&&l.current)return void c(l.current);const n=h(),o=n.indexOf(t.target);o>=0&&d(n,o,e)})),p.add(a,"keydown",(t=>{const e=h();let r=e.findIndex((t=>0===t.tabIndex)),s=!1;o&&"ArrowLeft"===t.key||i&&"ArrowUp"===t.key?(0===r?r=n?e.length-1:r:--r,s=!0):o&&"ArrowRight"===t.key||i&&"ArrowDown"===t.key?(r===e.length-1?r=n?0:r:++r,s=!0):"Home"===t.key?(r=0,
@@ -21,8 +21,8 @@ xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",v
21
21
  d:"M14 0a2 2 0 0 1 2 2v13a1 1 0 0 1-1.555.832l-4.262-1.757A1 1 0 0 0 9.802 14H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm-2.109 3.5h-.484l-.14.006-.122.018a.7.7 0 0 0-.2.071l-.076.054-.108.1-.097.1-1.632 1.999-.091.12-.084.129a2.6 2.6 0 0 0-.291.722l-.03.142-.027.218-.009.223v2.646l.01.086.027.08a.54.54 0 0 0 .236.236l.067.028.07.017.074.005h2.907l.074-.005.094-.025a.5.5 0 0 0 .169-.108.5.5 0 0 0 .082-.096l.029-.051.027-.081.01-.086V7.336l-.006-.073-.018-.068a.44.44 0 0 0-.124-.178.6.6 0 0 0-.103-.074l-.055-.026-.087-.024-.092-.009h-.579l-.057-.006-.054-.017a.3.3 0 0 1-.096-.07.2.2 0 0 1-.045-.078l-.004-.04.01-.043.022-.043 1.311-2.227.047-.09.037-.106a.5.5 0 0 0-.06-.394.53.53 0 0 0-.255-.22l-.084-.028-.092-.016zm-5.924 0h-.424l-.121.006-.108.018a.6.6 0 0 0-.174.071l-.067.054-.095.1-.084.1-1.429 1.999-.08.12-.096.174a2.8 2.8 0 0 0-.232.677l-.025.142-.024.218L3 7.402v2.646l.008.086.024.08a.5.5 0 0 0 .097.148q.052.055.11.088l.058.028.062.017.065.005h2.543l.065-.005.082-.025a.515.515 0 0 0 .22-.204l.025-.051.024-.081.008-.086V7.336l-.005-.073-.023-.09a.487.487 0 0 0-.191-.23l-.048-.026-.076-.024-.08-.009H5.46l-.05-.006-.047-.017a.3.3 0 0 1-.084-.07.2.2 0 0 1-.04-.078l-.003-.04.008-.043.02-.043L6.411 4.36l.04-.09.033-.106a.55.55 0 0 0-.053-.394.5.5 0 0 0-.222-.22l-.074-.028-.08-.016z"
22
22
  })]})})}function It(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CancelIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"m12.322 5.085-.08.087-2.828 2.827 2.829 2.83a1 1 0 0 1-1.32 1.497l-.095-.083L8 9.414l-2.828 2.829c-.915.914-2.272-.388-1.494-1.328l.08-.087L6.584 8 3.757 5.172a1 1 0 0 1 1.32-1.498l.095.083L8 6.585l2.828-2.828c.886-.885 2.188.309 1.56 1.239z"})]})})}function Bt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CaretDownIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M3.293 5.293a1 1 0 0 1 1.32-.083l.094.083L8 8.585l3.293-3.292a1 1 0 0 1 1.32-.083l.094.083a1 1 0 0 1 .083 1.32l-.083.094-4 4a1 1 0 0 1-1.32.083l-.094-.083-4-4a1 1 0 0 1 0-1.414"
23
23
  })]})})}function Dt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CaretLeftIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M9.293 3.293a1 1 0 0 1 1.497 1.32l-.083.094L7.415 8l3.292 3.293a1 1 0 0 1 .083 1.32l-.083.094a1 1 0 0 1-1.32.083l-.094-.083-4-4a1 1 0 0 1-.083-1.32l.083-.094z"})]})})}function Ft(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CaretRightIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M5.293 3.293a1 1 0 0 1 1.32-.083l.094.083 4 4a1 1 0 0 1 .083 1.32l-.083.094-4 4a1 1 0 0 1-1.497-1.32l.083-.094L8.585 8 5.293 4.707a1 1 0 0 1-.083-1.32z"})]})})}function Ht(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",
24
- "aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CautionIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M8 0c.767 0 1.432.455 1.794 1.148l5.917 11.326c.386.738.36 1.573.071 2.23-.286.651-.926 1.296-1.864 1.296H2.082c-.938 0-1.578-.645-1.864-1.295a2.6 2.6 0 0 1 .07-2.23L6.207 1.147C6.568.455 7.233 0 8 0m0 2.038-.021.036L2.06 13.4a.6.6 0 0 0-.012.5.3.3 0 0 0 .062.1H13.89a.3.3 0 0 0 .061-.1.6.6 0 0 0-.012-.5L8.02 2.074zm5.874 11.972q0 0 .01-.006-.01.007-.01.006m-11.748 0q0 .002-.01-.006z"}),St("path",{fill:"currentColor",d:"M8 5a1 1 0 0 1 1 1v3a1 1 0 0 1-2 0V6a1 1 0 0 1 1-1M9 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0"})]})})}function zt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",
25
- d:"M12.18 2.427a1 1 0 0 1 1.705 1.04l-.066.106-7 10a1 1 0 0 1-1.606.045l-.07-.104-3-5A1 1 0 0 1 3.792 7.39l.065.097 2.207 3.677z"})]})})}function Vt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckboxIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M0 2.5A2.5 2.5 0 0 1 2.5 0h11A2.5 2.5 0 0 1 16 2.5v11a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 13.5zM2.5 1A1.5 1.5 0 0 0 1 2.5v11A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-11A1.5 1.5 0 0 0 13.5 1z","clip-rule":"evenodd"})]})})}function Ut(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckboxCheckedFilledIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",
24
+ "aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CautionIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M8 0c.767 0 1.432.455 1.794 1.148l5.917 11.326c.386.738.36 1.573.071 2.23-.286.651-.926 1.296-1.864 1.296H2.082c-.938 0-1.578-.645-1.864-1.295a2.6 2.6 0 0 1 .07-2.23L6.207 1.147C6.568.455 7.233 0 8 0m0 2.038-.021.036L2.06 13.4a.6.6 0 0 0-.012.5.3.3 0 0 0 .062.1H13.89a.3.3 0 0 0 .061-.1.6.6 0 0 0-.012-.5L8.02 2.074zm5.874 11.972q0 0 .01-.006-.01.007-.01.006m-11.748 0q0 .002-.01-.006z"}),St("path",{fill:"currentColor",d:"M8 5a1 1 0 0 1 1 1v3a1 1 0 0 1-2 0V6a1 1 0 0 1 1-1M9 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0"})]})})}function Vt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",
25
+ d:"M12.18 2.427a1 1 0 0 1 1.705 1.04l-.066.106-7 10a1 1 0 0 1-1.606.045l-.07-.104-3-5A1 1 0 0 1 3.792 7.39l.065.097 2.207 3.677z"})]})})}function zt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckboxIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M0 2.5A2.5 2.5 0 0 1 2.5 0h11A2.5 2.5 0 0 1 16 2.5v11a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 13.5zM2.5 1A1.5 1.5 0 0 0 1 2.5v11A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-11A1.5 1.5 0 0 0 13.5 1z","clip-rule":"evenodd"})]})})}function Ut(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckboxCheckedFilledIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",
26
26
  d:"M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm10.18 3.636a.75.75 0 0 0-1.044.184l-4.588 6.552-1.655-2.758-.05-.072a.75.75 0 0 0-1.236.844l2.25 3.75.053.078a.75.75 0 0 0 1.204-.034l5.25-7.5.05-.08a.75.75 0 0 0-.234-.964","clip-rule":"evenodd"})]})})}function $t(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"HideIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"m1.613.21.094.083 14 14a1 1 0 0 1-1.32 1.497l-.094-.083-14-14A1 1 0 0 1 1.613.21m.583 4.845a1 1 0 0 1 .292 1.384C2.165 6.935 2 7.46 2 8c0 2.123 2.628 4 6 4q.33 0 .657-.024a1 1 0 0 1 .147 1.994Q8.405 14 8 14c-4.36 0-8-2.6-8-6 0-.937.283-1.84.812-2.653a1 1 0 0 1 1.384-.292M16 8c0-3.4-3.64-6-8-6q-.405 0-.804.03a1 1 0 1 0 .147 1.994Q7.668 4 8 4c3.372 0 6 1.877 6 4 0 .539-.165 1.065-.488 1.561a1 1 0 1 0 1.676 1.092C15.718 9.84 16 8.937 16 8"})]})})}
27
27
  function qt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"HighlightIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M13 1a1 1 0 0 0-1-1h-2l-.117.007a1 1 0 0 0-.75 1.493A1 1 0 0 0 9 2v6l.009.134a1 1 0 0 0 .125.365.996.996 0 0 0 .374 1.37A1 1 0 0 0 9.5 10v2l.006.114c.087.814 1.098 1.196 1.701.593l1-1 .087-.099A1 1 0 0 0 12.5 11l.001-1.134a1 1 0 0 0 .365-1.366A1 1 0 0 0 13 8V2l-.009-.134a1 1 0 0 0-.125-.365A1 1 0 0 0 13 1m0 14a1 1 0 0 0-1-1H1l-.117.007A1 1 0 0 0 1 16h11l.117-.007A1 1 0 0 0 13 15"})]})})}function Wt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","data-component":"MenuCollapseIcon",...t,children:St("path",{fill:"currentColor",d:"m8.54 4.205 6.23 5.87a.69.69 0 0 1 0 1.03l-.72.68a.8.8 0 0 1-1.09 0L8 7.135l-4.96 4.65a.8.8 0 0 1-1.09 0l-.73-.69a.69.69 0 0 1 0-1.02l6.24-5.87a.8.8 0 0 1 1.08 0"})
28
28
  })}function jt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16","data-component":"MenuExpandIcon",...t,children:St("path",{fill:"currentColor",d:"M7.456 11.788 1.226 5.92a.695.695 0 0 1 0-1.025l.726-.684a.804.804 0 0 1 1.087-.001L8 8.861l4.961-4.65a.804.804 0 0 1 1.087.001l.727.684c.3.283.3.742 0 1.025l-6.23 5.867a.804.804 0 0 1-1.09 0z"})})}function Kt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"NoteIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M14 0a2 2 0 0 1 1.995 1.85L16 2v7a1 1 0 0 1-.31.724l-.09.076-8 6a1 1 0 0 1-.471.192L7 16H2a2 2 0 0 1-1.995-1.85L0 14V2A2 2 0 0 1 1.85.005L2 0zm0 2H2v12h4V9a1 1 0 0 1 .883-.993L7 8h7zm-6 8h4l-4 3z"})]})})}function Xt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16",
@@ -30,19 +30,19 @@ function qt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",he
30
30
  d:"m.5 9 7-8 8 8"})})}function Qt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"RadioIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8","clip-rule":"evenodd"})]})})}function Jt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"RadioCheckedIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8","clip-rule":"evenodd"}),St("path",{fill:"currentColor",d:"M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0"})]})})}function Zt(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16",
31
31
  "data-component":"SelectionIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M2.5 0h-1A1.5 1.5 0 0 0 0 1.5v1a1.5 1.5 0 0 0 1 1.415v8.17A1.5 1.5 0 0 0 0 13.5v1A1.5 1.5 0 0 0 1.5 16h1a1.5 1.5 0 0 0 1.415-1h8.17a1.5 1.5 0 0 0 1.415 1h1a1.5 1.5 0 0 0 1.5-1.5v-1a1.5 1.5 0 0 0-1-1.415v-8.17A1.5 1.5 0 0 0 16 2.5v-1A1.5 1.5 0 0 0 14.5 0h-1a1.5 1.5 0 0 0-1.415 1h-8.17A1.5 1.5 0 0 0 2.5 0m9.585 13c.151-.426.489-.764.915-.915v-8.17A1.5 1.5 0 0 1 12.085 3h-8.17c-.151.426-.489.764-.915.915v8.17c.426.151.764.489.915.915zM1 1.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zM1.5 13a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zM13 1.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm.5 11.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5z","clip-rule":"evenodd"})]})})}function te(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",
32
32
  width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"ShowIcon",...t,children:St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor",d:"M8 2c4.36 0 8 2.6 8 6s-3.64 6-8 6-8-2.6-8-6 3.64-6 8-6m0 2C4.628 4 2 5.877 2 8s2.628 4 6 4 6-1.877 6-4-2.628-4-6-4m2 4a2 2 0 1 0-4 0 2 2 0 0 0 4 0"})]})})}function ee({children:t,classes:e,elementRef:n,expanded:o,pressed:i,title:r,icon:s,size:a="md",variant:l="secondary",unstyled:c=!1,role:h,...d}){const u=!c,f=u&&"custom"!==l,p=u&&"custom"!==a,g={"aria-label":r};return"tab"===h?g["aria-selected"]=i:(g["aria-pressed"]=i,g["aria-expanded"]=o),St("button",{role:null!=h?h:"button","data-component":"Button",type:"button",...g,...d,className:Tt({"focus-visible:ring focus-visible:outline-none transition-colors whitespace-nowrap flex items-center":u},f&&{"font-semibold rounded":!0,
33
- "text-grey-7 bg-grey-1 enabled:hover:text-grey-9 enabled:hover:bg-grey-2 aria-pressed:text-grey-9 aria-expanded:text-grey-9":"secondary"===l,"text-grey-1 bg-grey-7 enabled:hover:bg-grey-8 disabled:text-grey-4":"primary"===l},p&&{"p-2 gap-x-2":"md"===a,"p-1 gap-x-1":"xs"===a,"p-1.5 gap-x-1.5":"sm"===a,"p-2.5 gap-x-1.5":"lg"===a},e),ref:n,title:r,children:[s&&St(s,{className:"w-em h-em"}),t]})}z({}),z({});const ne=Tt("input-group:border input-group:rounded-none","input-group:first:rounded-l input-group:last:rounded-r","input-group:ml-[-1px] input-group:first:ml-0","focus:z-1");function oe({children:t,classes:e,elementRef:n,pressed:o,expanded:i,icon:r,size:s="md",title:a,variant:l="secondary",unstyled:c=!1,...h}){const d=!c;return St(ee,{"data-component":"IconButton",...h,classes:Tt({"focus-visible:ring focus-visible:outline-none transition-colors rounded whitespace-nowrap":d,"flex items-center justify-center":d},d&&ne,d&&"custom"!==l&&{
33
+ "text-grey-7 bg-grey-1 enabled:hover:text-grey-9 enabled:hover:bg-grey-2 aria-pressed:text-grey-9 aria-expanded:text-grey-9":"secondary"===l,"text-grey-1 bg-grey-7 enabled:hover:bg-grey-8 disabled:text-grey-4":"primary"===l},p&&{"p-2 gap-x-2":"md"===a,"p-1 gap-x-1":"xs"===a,"p-1.5 gap-x-1.5":"sm"===a,"p-2.5 gap-x-1.5":"lg"===a},e),ref:n,title:r,children:[s&&St(s,{className:"w-em h-em"}),t]})}V({}),V({});const ne=Tt("input-group:border input-group:rounded-none","input-group:first:rounded-l input-group:last:rounded-r","input-group:ml-[-1px] input-group:first:ml-0","focus:z-1");function oe({children:t,classes:e,elementRef:n,pressed:o,expanded:i,icon:r,size:s="md",title:a,variant:l="secondary",unstyled:c=!1,...h}){const d=!c;return St(ee,{"data-component":"IconButton",...h,classes:Tt({"focus-visible:ring focus-visible:outline-none transition-colors rounded whitespace-nowrap":d,"flex items-center justify-center":d},d&&ne,d&&"custom"!==l&&{
34
34
  "text-grey-7 bg-transparent enabled:hover:text-grey-9 aria-pressed:text-brand aria-expanded:text-brand":"secondary"===l,"text-brand bg-transparent enabled:hover:text-grey-9 disabled:text-grey-7":"primary"===l,"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":"dark"===l},d&&"custom"!==s&&{"gap-x-2 touch:min-w-touch-minimum touch:min-h-touch-minimum":!0,"p-2":"md"===s,"p-1":"xs"===s,"p-1.5":"sm"===s,"p-2.5":"lg"===s},e),elementRef:n,title:a,pressed:o,expanded:i,unstyled:!0,children:[r&&St(r,{className:"w-em h-em"}),t]})}function ie({children:t,elementRef:e,containerRef:n,checked:o,icon:i,checkedIcon:r,disabled:s,onChange:a,id:l,type:c,containerClasses:h,...d}){const u=o?r:i;return St("label",{className:Tt("relative flex items-center gap-x-1.5",{"cursor-pointer":!s,"opacity-70":s},h),htmlFor:l,"data-composite-component":"checkbox"===c?"Checkbox":"RadioButton",ref:n,children:[St("input",{...d,type:c,ref:e,
35
- className:Tt("peer","absolute w-em h-em","opacity-[.00001]",{"cursor-pointer":!s}),checked:o,disabled:s,id:l,onChange:a}),St(u,{className:Tt("peer-focus-visible:ring","w-em h-em","min-w-min min-h-min")}),St("span",{children:t})]})}function re({checked:t,defaultChecked:e=!1,icon:n=Vt,checkedIcon:o=Ut,onChange:i,...r}){const s="boolean"==typeof t,[a,l]=et(e);return St(ie,{icon:n,checkedIcon:o,type:"checkbox",checked:s?t:a,onChange:function(t){null==i||i.call(this,t),s||l(t.target.checked)},...r})}const se=z(null);function ae({value:t,children:e,subtitle:n,disabled:o}){const i=at(se);if(!i)throw new Error("RadioGroup.Radio can only be used as RadioGroup child");const{selected:r,disabled:s=o,onChange:a}=i,l=!s&&r===t;return St("div",{role:"radio","aria-checked":l,"aria-disabled":s,className:Tt("focus-visible:ring focus-visible:outline-none rounded-lg px-3 py-2 flex-1 group",{"hover:bg-grey-3/25 aria-checked:bg-grey-3/50 cursor-pointer":!s,"opacity-70":s}),"data-value":t,onClick:s?void 0:()=>a(t),
35
+ className:Tt("peer","absolute w-em h-em","opacity-[.00001]",{"cursor-pointer":!s}),checked:o,disabled:s,id:l,onChange:a}),St(u,{className:Tt("peer-focus-visible:ring","w-em h-em","min-w-min min-h-min")}),St("span",{children:t})]})}function re({checked:t,defaultChecked:e=!1,icon:n=zt,checkedIcon:o=Ut,onChange:i,...r}){const s="boolean"==typeof t,[a,l]=et(e);return St(ie,{icon:n,checkedIcon:o,type:"checkbox",checked:s?t:a,onChange:function(t){null==i||i.call(this,t),s||l(t.target.checked)},...r})}const se=V(null);function ae({value:t,children:e,subtitle:n,disabled:o}){const i=at(se);if(!i)throw new Error("RadioGroup.Radio can only be used as RadioGroup child");const{selected:r,disabled:s=o,onChange:a}=i,l=!s&&r===t;return St("div",{role:"radio","aria-checked":l,"aria-disabled":s,className:Tt("focus-visible:ring focus-visible:outline-none rounded-lg px-3 py-2 flex-1 group",{"hover:bg-grey-3/25 aria-checked:bg-grey-3/50 cursor-pointer":!s,"opacity-70":s}),"data-value":t,onClick:s?void 0:()=>a(t),
36
36
  onKeyDown:s?void 0:e=>{["Enter"," "].includes(e.key)&&(e.preventDefault(),a(t))},tabIndex:-1,children:[St("div",{className:"flex items-center gap-x-1.5",children:[St(l?Jt:Qt,{}),St("span",{className:Tt("flex items-center gap-x-1.5",{"text-grey-7 group-hover:text-grey-8 group-aria-checked:text-grey-8":!s}),children:e})]}),n&&St("div",{className:Tt("pl-4 ml-1.5 mt-1 text-sm",{"text-grey-6 group-hover:text-grey-7 group-aria-checked:text-grey-7":!s}),children:n})]})}ae.displayName="RadioGroup.Radio",Object.assign((function({direction:t="horizontal",children:e,selected:n,onChange:o,disabled:i,"aria-label":r,"aria-labelledby":s,name:a}){const l=it(null);return yt(l,{loop:!1,selector:'[role="radio"]:not([aria-disabled="true"])',focusElement:t=>{o(t.dataset.value),t.focus()}}),St(se.Provider,{value:{selected:n,disabled:i,onChange:o},children:[St("div",{"aria-label":r,"aria-labelledby":s,ref:l,role:"radiogroup",className:Tt("w-full flex gap-1.5",{"flex-col":"vertical"===t}),children:e}),a&&St("input",{type:"hidden",
37
37
  "data-testid":"hidden-input",name:a,value:n,disabled:i})]})}),{Radio:ae,displayName:"RadioGroup"});const le=3,ce=8;function he(t,e,n,o,i){nt((()=>{if(!i)return()=>{};const e=t.current,o=t=>{"open"===t.oldState&&"closed"===t.newState&&n()};return e.addEventListener("toggle",o),()=>e.removeEventListener("toggle",o)}),[i,n,t]);const r=o&&!i;!function(t,e,{enabled:n=!0}={}){nt((()=>{if(!n)return()=>{};const o=document.body,i=new mt,r=n=>{t.current&&!n.composedPath().includes(t.current)&&e(n)};return i.add(o,"mousedown",r),i.add(o,"click",r),()=>{i.removeAll()}}),[t,n,e])}(t,(t=>{t.composedPath().includes(e.current)||n()}),{enabled:r}),function(t,e,{enabled:n=!0}={}){nt((()=>{if(!n)return()=>{};const o=document.body,i=new mt;return i.add(o,"keydown",(n=>{t.includes(n.key)&&e(n)})),()=>{i.removeAll()}}),[n,e,t])}(["Escape"],n,{enabled:r})}
38
38
  function de({anchorElementRef:t,children:e,open:n,onClose:o,align:i="left",placement:r="below",arrow:s=!1,classes:a,variant:l="panel",onScroll:c,elementRef:h,asNativePopover:d=HTMLElement.prototype.hasOwnProperty("popover")}){const u=xt(h),f=function(t,e,{open:n,asNativePopover:o,alignToRight:i,placement:r,arrow:s}){const[a,l]=et(r),c=st((()=>{const n=t.current,a=e.current,c=t=>{Object.assign(n.style,t);const e=Object.keys(t);return()=>e.map((t=>n.style[t]=""))},h=window.innerHeight,{top:d,bottom:u,left:f,height:p,width:g}=a.getBoundingClientRect(),_=h-u,{height:m,width:b}=n.getBoundingClientRect(),y="above"===r&&(d>m||_<d)||"below"===r&&_<m&&d>_;l(y?"above":"below");const w=s?le+8:le;if(!o)return c(y?{bottom:"100%",marginBottom:`${w}px`}:{top:"100%",marginTop:`${w}px`});const{top:v,width:x}=document.body.getBoundingClientRect(),C=Math.abs(v),S=(i?f+g:x-f)-ce;let A=f;return b>S?A=i?ce:A-(b-S):i&&b>g&&(A-=b-g),c({minWidth:`${g}px`,top:y?C+d-m-w+"px":`${C+d+p+w}px`,left:`${Math.max(ce,A)}px`})}),[t,e,r,s,o,i])
39
39
  ;return ot((()=>{if(!n)return()=>{};const e=t.current;o&&e.togglePopover(!0);const i=c();if(!o)return i;const r=new mt;r.add(document.body,"scroll",c,{capture:!0});const s=new ResizeObserver(c);return s.observe(e),()=>{o&&(null==e||e.togglePopover(!1)),i(),r.removeAll(),s.disconnect()}}),[c,o,n,t]),a}(u,t,{open:n,placement:r,arrow:s,alignToRight:"right"===i,asNativePopover:d});return he(u,t,o,n,d),function({popoverRef:t,open:e}){ot((()=>{const n=t.current,o=e?document.activeElement:null;return n&&o?()=>{const t=document.activeElement;t&&!n.contains(t)&&t!==document.body||o.focus()}:()=>{}}),[t,e])}({open:n,popoverRef:u}),St("div",{className:Tt("absolute z-5","panel"===l&&["max-h-80 ","rounded border bg-white shadow hover:shadow-md focus-within:shadow-md",!s&&"overflow-y-auto overflow-x-hidden"],s&&"overflow-visible",d&&["max-w-[calc(100%-16px)]","p-0 m-0"],!d&&{hidden:!n,"right-0":"right"===i,"min-w-full":!0},a),ref:u,popover:d&&"auto",onScroll:c,"data-testid":"popover","data-component":"Popover",
40
- children:[n&&s&&St("div",{className:Tt("absolute z-10","fill-white text-grey-3",{"top-full":"above"===f,"bottom-full":"below"===f,"left-2":"left"===i,"right-2":"right"===i}),"data-testid":"arrow",children:St("below"===f?Gt:Yt,{})}),n&&e]})}const ue=z(null);function fe(t,e){return"function"==typeof t?t(e):t}function pe({value:t,children:e,disabled:n=!1,classes:o,elementRef:i,title:r}){const s=it(null),a=it(null),l=xt(i),c=t=>t.target===s.current||t.target===a.current,h=at(ue);if(!h)throw new Error("Select.Option can only be used as Select or MultiSelect child");const{selectValue:d,value:u,multiple:f}=h,p=rt((()=>!n&&(f?u.includes(t)||0===u.length&&void 0===t:u===t)),[u,n,f,t]),g=st((()=>{const e={closeListbox:!0};d(f?void 0!==t?[t]:[]:t,e)}),[f,d,t]),_=st((()=>{if(!f)return;const e={closeListbox:void 0===t};if(void 0===t)return void d([],e);const n=u.indexOf(t);if(-1===n)d([...u,t],e);else{const t=[...u];t.splice(n,1),d(t,e)}}),[u,f,d,t]);return St("li",{
41
- className:Tt("w-full ring-inset outline-none rounded-none select-none","px-1 mb-1 first:mt-1 whitespace-nowrap group",{"text-grey-4":n,"cursor-pointer":!n},o),onClick:t=>{n||c(t)||g()},onKeyDown:t=>{n||(["Enter"," "].includes(t.key)&&!c(t)?(t.preventDefault(),g()):s.current&&"ArrowRight"===t.key&&(t.preventDefault(),s.current.focus()))},role:"option","aria-disabled":n,"aria-selected":p,tabIndex:p?0:-1,ref:l,title:r,children:St("div",{className:Tt("flex justify-between items-center","w-full rounded",{"hover:bg-grey-1 group-focus-visible:ring":!n,"bg-grey-1 hover:bg-grey-2":p}),children:[St("div",{className:Tt("py-2 pl-3",{truncate:"truncate"===h.listboxOverflow,"whitespace-normal":"wrap"===h.listboxOverflow}),children:fe(e,{selected:p,disabled:n})}),!f&&St("div",{className:"px-3",children:St(zt,{className:Tt("text-grey-6 scale-125",{"opacity-0":!p})})}),f&&St(re,{containerClasses:Tt("self-stretch px-3","text-lg",{"text-grey-6":p,"text-grey-3 hover:text-grey-6":!p}),checked:p,checkedIcon:Ut,elementRef:s,
40
+ children:[n&&s&&St("div",{className:Tt("absolute z-10","fill-white text-grey-3",{"top-full":"above"===f,"bottom-full":"below"===f,"left-2":"left"===i,"right-2":"right"===i}),"data-testid":"arrow",children:St("below"===f?Gt:Yt,{})}),n&&e]})}const ue=V(null);function fe(t,e){return"function"==typeof t?t(e):t}function pe({value:t,children:e,disabled:n=!1,classes:o,elementRef:i,title:r}){const s=it(null),a=it(null),l=xt(i),c=t=>t.target===s.current||t.target===a.current,h=at(ue);if(!h)throw new Error("Select.Option can only be used as Select or MultiSelect child");const{selectValue:d,value:u,multiple:f}=h,p=rt((()=>!n&&(f?u.includes(t)||0===u.length&&void 0===t:u===t)),[u,n,f,t]),g=st((()=>{const e={closeListbox:!0};d(f?void 0!==t?[t]:[]:t,e)}),[f,d,t]),_=st((()=>{if(!f)return;const e={closeListbox:void 0===t};if(void 0===t)return void d([],e);const n=u.indexOf(t);if(-1===n)d([...u,t],e);else{const t=[...u];t.splice(n,1),d(t,e)}}),[u,f,d,t]);return St("li",{
41
+ className:Tt("w-full ring-inset outline-none rounded-none select-none","px-1 mb-1 first:mt-1 whitespace-nowrap group",{"text-grey-4":n,"cursor-pointer":!n},o),onClick:t=>{n||c(t)||g()},onKeyDown:t=>{n||(["Enter"," "].includes(t.key)&&!c(t)?(t.preventDefault(),g()):s.current&&"ArrowRight"===t.key&&(t.preventDefault(),s.current.focus()))},role:"option","aria-disabled":n,"aria-selected":p,tabIndex:p?0:-1,ref:l,title:r,children:St("div",{className:Tt("flex justify-between items-center","w-full rounded",{"hover:bg-grey-1 group-focus-visible:ring":!n,"bg-grey-1 hover:bg-grey-2":p}),children:[St("div",{className:Tt("py-2 pl-3",{truncate:"truncate"===h.listboxOverflow,"whitespace-normal":"wrap"===h.listboxOverflow}),children:fe(e,{selected:p,disabled:n})}),!f&&St("div",{className:"px-3",children:St(Vt,{className:Tt("text-grey-6 scale-125",{"opacity-0":!p})})}),f&&St(re,{containerClasses:Tt("self-stretch px-3","text-lg",{"text-grey-6":p,"text-grey-3 hover:text-grey-6":!p}),checked:p,checkedIcon:Ut,elementRef:s,
42
42
  containerRef:a,onChange:_,onKeyDown:t=>{var e;"ArrowLeft"===t.key&&(t.preventDefault(),null===(e=l.current)||void 0===e||e.focus())}})]})})}function ge({buttonContent:t,value:e,onChange:n,children:o,disabled:i,elementRef:r,buttonId:s,buttonClasses:a,popoverClasses:l,containerClasses:c,onPopoverScroll:h,alignListbox:d="left",multiple:u,listboxOverflow:f="truncate","aria-label":p,"aria-labelledby":g,listboxAsPopover:_}){const m=it(null),b=it(null),[y,w]=et(!1),v=st((()=>w(!1)),[w]),x=lt(),C=xt(r),S=lt(),A=st(((t,e)=>{n(t),e.closeListbox&&v()}),[n,v]);return function(t,e,{enabled:n=!0}={}){nt((()=>{if(!n||!t.current)return()=>{};const o=new mt;return o.add(t.current,"focusout",(n=>{const o=n;t.current&&!t.current.contains(o.relatedTarget)&&e(o)})),()=>{o.removeAll()}}),[t,n,e])}(m,v),yt(b,{horizontal:!1,loop:!1,autofocus:!0,containerVisible:y,selector:'[role="option"]:not([aria-disabled="true"])'}),St("div",{className:Tt("relative w-full border rounded",{"border-grey-5":y},ne,c),ref:m,children:[St("button",{
43
43
  id:null!=s?s:S,className:Tt("focus-visible:ring focus-visible:outline-none transition-colors whitespace-nowrap","w-full flex items-center justify-between gap-x-2","bg-grey-0 disabled:bg-grey-1 disabled:text-grey-6","text-left","rounded-[inherit]",a),type:"button",role:"combobox",disabled:i,"aria-expanded":y,"aria-haspopup":"listbox","aria-controls":x,"aria-label":p,"aria-labelledby":g,ref:C,onClick:()=>w((t=>!t)),onKeyDown:t=>{"ArrowDown"!==t.key||y||(t.preventDefault(),w(!0))},"data-testid":"select-toggle-button",children:[St("div",{className:"pl-2 py-2 truncate grow",children:t}),St("div",{className:"pr-2 py-2 text-grey-6",children:St(y?Wt:jt,{})})]}),St(ue.Provider,{value:{value:e,selectValue:A,multiple:u,listboxOverflow:f},children:St(de,{anchorElementRef:m,open:y,onClose:v,asNativePopover:_,align:d,classes:l,onScroll:h,children:St("ul",{role:"listbox",id:x,ref:b,"aria-multiselectable":u,"aria-labelledby":null!=s?s:S,"aria-orientation":"vertical",children:o})})})]})}
44
- function _e({children:t,classes:e,elementRef:n,icon:o,status:i="notice",size:r="md",variant:s="outlined",unstyled:a=!1,...l}){const c=!a,h=c&&"custom"!==s,d=c&&"custom"!==r;let u=o;if(!u)switch(i){case"success":u=zt;break;case"error":u=It;break;default:u=Ht}const f=h&&d;return St("div",{"data-component":"Callout",...l,ref:n,className:Tt(c&&"flex items-center border",h&&{"rounded border":!0,"shadow hover:shadow-md cursor-pointer":"raised"===s,"border-yellow-notice":"notice"===i,"border-green-success":"success"===i,"border-red-error":"error"===i},h&&{"bg-yellow-notice":"notice"===i&&f,"bg-green-success":"success"===i&&f,"bg-red-error":"error"===i&&f,"bg-white":!f},e),children:[f&&St("div",{className:Tt({"p-2":"md"===r,"p-1.5":"sm"===r,"p-3":"lg"===r}),children:St(u,{"data-testid":"callout-icon",className:Tt("text-white",{"w-[1.25em] h-[1.25em]":"md"===r,"w-[0.85em] h-[0.85em]":"sm"===r,"w-[1.5em] h-[1.5em]":"lg"===r})})}),St("div",{className:Tt(d&&{"p-2":"md"===r,"py-1.5 px-2":"sm"===r,"p-3":"lg"===r
45
- },c&&"grow",h&&"bg-white rounded-r"),children:t})]})}function me({message:t,onDismiss:e}){return St(_e,{classes:Tt({"sr-only":t.visuallyHidden}),status:t.type,onClick:()=>e(t.id),variant:"raised",children:t.message})}pe.displayName="Select.Option",Object.assign((function(t){return ge({...t,multiple:!1})}),{Option:pe,displayName:"Select"}),Object.assign((function(t){return ge({...t,multiple:!0})}),{Option:pe,displayName:"MultiSelect"}),z({}),z(null);const be=({direction:t,onTransitionEnd:e,children:n,transitionClasses:o={}})=>{const i="out"===t,r=it(null),s=rt((()=>{const{transitionIn:t="animate-fade-in",transitionOut:e="animate-fade-out"}=o;return{[t]:!i,[e]:i}}),[i,o]);return St("div",{"data-testid":"animation-container",onAnimationEnd:n=>{n.target===r.current&&(null==e||e(null!=t?t:"in"))},ref:r,className:Tt("relative w-full container",s),children:n})};function ye({messages:t,onMessageDismiss:e,transitionClasses:n,setTimeout_:o=setTimeout}){
44
+ function _e({children:t,classes:e,elementRef:n,icon:o,status:i="notice",size:r="md",variant:s="outlined",unstyled:a=!1,...l}){const c=!a,h=c&&"custom"!==s,d=c&&"custom"!==r;let u=o;if(!u)switch(i){case"success":u=Vt;break;case"error":u=It;break;default:u=Ht}const f=h&&d;return St("div",{"data-component":"Callout",...l,ref:n,className:Tt(c&&"flex items-center border",h&&{"rounded border":!0,"shadow hover:shadow-md cursor-pointer":"raised"===s,"border-yellow-notice":"notice"===i,"border-green-success":"success"===i,"border-red-error":"error"===i},h&&{"bg-yellow-notice":"notice"===i&&f,"bg-green-success":"success"===i&&f,"bg-red-error":"error"===i&&f,"bg-white":!f},e),children:[f&&St("div",{className:Tt({"p-2":"md"===r,"p-1.5":"sm"===r,"p-3":"lg"===r}),children:St(u,{"data-testid":"callout-icon",className:Tt("text-white",{"w-[1.25em] h-[1.25em]":"md"===r,"w-[0.85em] h-[0.85em]":"sm"===r,"w-[1.5em] h-[1.5em]":"lg"===r})})}),St("div",{className:Tt(d&&{"p-2":"md"===r,"py-1.5 px-2":"sm"===r,"p-3":"lg"===r
45
+ },c&&"grow",h&&"bg-white rounded-r"),children:t})]})}function me({message:t,onDismiss:e}){return St(_e,{classes:Tt({"sr-only":t.visuallyHidden}),status:t.type,onClick:()=>e(t.id),variant:"raised",children:t.message})}pe.displayName="Select.Option",Object.assign((function(t){return ge({...t,multiple:!1})}),{Option:pe,displayName:"Select"}),Object.assign((function(t){return ge({...t,multiple:!0})}),{Option:pe,displayName:"MultiSelect"}),V({}),V(null);const be=({direction:t,onTransitionEnd:e,children:n,transitionClasses:o={}})=>{const i="out"===t,r=it(null),s=rt((()=>{const{transitionIn:t="animate-fade-in",transitionOut:e="animate-fade-out"}=o;return{[t]:!i,[e]:i}}),[i,o]);return St("div",{"data-testid":"animation-container",onAnimationEnd:n=>{n.target===r.current&&(null==e||e(null!=t?t:"in"))},ref:r,className:Tt("relative w-full container",s),children:n})};function ye({messages:t,onMessageDismiss:e,transitionClasses:n,setTimeout_:o=setTimeout}){
46
46
  const[i,r]=et([]),s=it(new Map),a=st((t=>r((e=>[...e,t]))),[]),l=st((t=>{const e=o((()=>{a(t),s.current.delete(t)}),5e3);s.current.set(t,e)}),[a,o]),c=st(((t,n)=>{var o;const i=null===(o=n.autoDismiss)||void 0===o||o;"in"===t&&i&&l(n.id),"out"===t&&(e(n.id),r((t=>t.filter((t=>t!==n.id)))))}),[l,e]);return ot((()=>{const t=s.current;return()=>{t.forEach((t=>clearTimeout(t)))}}),[]),St("ul",{"aria-live":"polite","aria-relevant":"additions",className:"w-full space-y-2","data-component":"ToastMessages",children:t.map((t=>{const e=i.includes(t.id);return St("li",{className:Tt({"mb-2":!t.visuallyHidden}),children:St(be,{direction:e?"out":"in",onTransitionEnd:e=>c(e,t),transitionClasses:n,children:St(me,{message:t,onDismiss:a})})},t.id)}))})}function we({children:t,classes:e,elementRef:n,underline:o="none",unstyled:i=!1,variant:r="brand",...s}){const a=!i;return St("a",{"data-component":"Link",rel:"noopener noreferrer",...s,className:Tt(a&&{"focus-visible:ring focus-visible:outline-none rounded":!0,
47
47
  "no-underline hover:no-underline":"none"===o,"underline hover:underline":"always"===o,"no-underline hover:underline":"hover"===o},a&&"custom"!==r&&{"text-brand hover:text-brand-dark":"brand"===r,"text-color-text-light hover:text-brand":"text-light"===r,"text-color-text hover:text-brand-dark":"text"===r},e),ref:n,children:t})}function ve({children:t,classes:e,elementRef:n,expanded:o,pressed:i,title:r,direction:s,...a}){return St(ee,{"data-component":"PointerButton",...a,elementRef:n,classes:Tt("relative w-[26px] h-[16px]","flex items-center justify-center","bg-white rounded-[4px] border","before:absolute before:border-transparent","after:absolute after:border-transparent","text-[10px] text-color-text-light leading-none font-semibold",{"shadow-[1px_1px_1px_rgba(0,0,0,0.1)]":"down"!==s,"shadow-[1px_0px_1px_rgba(0,0,0,0.1)]":"down"===s},{"rounded-r-[4px] rounded-l-[2px]":"left"===s,"before:right-full before:top-1/2 after:right-full after:top-1/2":"left"===s,
48
48
  "before:mt-[-8px] before:border-8 before:border-r-[5px] before:border-r-grey-3":"left"===s,"after:mt-[-7px] after:border-[7px] after:border-r-[4px] after:border-r-white":"left"===s},{"z-1 rounded-t-px-sm rounded-b-px":"up"===s,"before:top-auto before:left-1/2 before:bottom-full after:top-auto after:left-1/2 after:bottom-full":"up"===s,"before:ml-[-13px] before:border-[13px] before:border-b-[6px] before:border-b-grey-3":"up"===s,"after:ml-[-12px] after:border-[12px] after:border-b-[5px] after:border-b-white":"up"===s},{"z-1 rounded-t-px rounded-b-px-sm":"down"===s,"before:top-full before:left-1/2 after:top-full after:left-1/2":"down"===s,"before:ml-[-13px] before:border-[13px] before:border-t-[6px] before:border-t-grey-3":"down"===s,"after:ml-[-12px] after:border-[12px] after:border-t-[5px] after:border-t-white":"down"===s},e),expanded:o,pressed:i,title:r,variant:"custom",size:"custom",children:t})}function xe(t){const e=t.toString(16);return 1===e.length?"0"+e:e}function Ce(t){const e=new Uint8Array(t/2)
@@ -52,10 +52,10 @@ this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"req
52
52
  }))))return void n(`Ignored invalid port request for channel ${c} from ${o}`);if(this._handledRequests.has(a))return;this._handledRequests.add(a);const h="null"===o?"*":o,d="sidebar-host"===c?this._sidebarHostChannel:new MessageChannel,u={frame1:r,frame2:s,type:"offer",requestId:a,sourceId:l};if(d===this._sidebarHostChannel){if(this._sidebarConnected)return console.warn("Ignoring second request from Hypothesis sidebar to connect to host frame"),u.error="Received duplicate port request",void i.postMessage(u,h);this._sidebarConnected=!0}i.postMessage(u,h,[d.port1]),"sidebar"===s?this._sidebarHostChannel.port2.postMessage(u,[d.port2]):"host"===s&&this._emitter.emit("frameConnected",r,d.port2)},i=t,(...t)=>{try{return o(...t)}catch(t){throw Pe(t,i),t}}))}_messageMatches({allowedMessage:t,allowedOrigin:e,data:n,origin:o}){return("*"===e||o===e)&&function(t,e){return!!Se(t)&&JSON.stringify(t,Object.keys(e).sort())===JSON.stringify(e,Object.keys(e).sort())}(n,t)}on(t,e){this._emitter.on(t,e)}destroy(){
53
53
  this._listeners.removeAll()}}const Le="1.0.0",Oe="frame-rpc";function Ie(t,e=[],n=-1){return{protocol:Oe,version:Le,arguments:e,method:t,sequence:n}}function Be(t,e,n=[],o=-1){t.postMessage(Ie(e,n,o))}class De{constructor({currentWindow:t=window,forceUnloadListener:e=!1}={}){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new mt,"onclose"in MessagePort.prototype&&!e||this._listeners.add(t,"unload",(t=>{t instanceof CustomEvent||this._port&&Be(this._port,"close")})),this._pendingCalls=[],this._destroyed=!1,this._receivedCloseEvent=!1}on(t,e){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(t,e)}connect(t){this._port=t,this._listeners.add(t,"message",(t=>this._handle(t))),this._listeners.add(t,"close",(()=>{t.dispatchEvent(new MessageEvent("message",{data:Ie("close")}))})),t.start(),Be(t,"connect");for(const[t,e]of this._pendingCalls)this.call(t,...e);this._pendingCalls=[]}destroy(){
54
54
  this._port&&(Be(this._port,"close"),this._port.close()),this._destroyed=!0,this._listeners.removeAll()}call(t,...e){if(this._port||this._pendingCalls.push([t,e]),!this._port||this._destroyed)return;const n=this._sequence++,o=e[e.length-1];"function"==typeof o&&(this._callbacks.set(n,o),e=e.slice(0,-1)),Be(this._port,t,e,n)}_parseMessage({data:t}){return t&&"object"==typeof t?t.protocol!==Oe||t.version!==Le?null:Array.isArray(t.arguments)?t:null:null}_handle(t){const e=this._parseMessage(t),n=this._port;if(e&&n)if("method"in e){if("close"===e.method){if(this._receivedCloseEvent)return;this._receivedCloseEvent=!0}const t=this._methods.get(e.method);if(!t)return;const o=(...t)=>{const o={arguments:t,protocol:Oe,response:e.sequence,version:Le};n.postMessage(o)};t(...e.arguments,o)}else if("response"in e){const t=this._callbacks.get(e.response);this._callbacks.delete(e.response),t&&t(...e.arguments)}}}function Fe(t){if("string"==typeof t&&"false"===t.trim().toLocaleLowerCase())return!1;const e=Number(t)
55
- ;return isNaN(e)?"string"==typeof t:Boolean(e)}function He(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Object.assign(e,i)}return e}function ze(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ve(t){return t.width<=0||t.height<=0}function Ue(t,e,n,o){return Math.max(t,n)<Math.min(e,o)}function $e(t,e){return!Ve(t)&&!Ve(e)&&(Ue(t.left,t.right,e.left,e.right)&&Ue(t.top,t.bottom,e.top,e.bottom))}function qe(t,e){return Ue(t.top,t.bottom,e.top,e.bottom)}function We(t,e){return Ue(t.left,t.right,e.left,e.right)}function je(t,e){if(Ve(t))return e;if(Ve(e))return t;const n=Math.min(t.left,e.left),o=Math.min(t.top,e.top),i=Math.max(t.right,e.right),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,o,i-n,r-o)}function Ke(t){return new DOMPoint((t.left+t.right)/2,(t.top+t.bottom)/2)}function Xe(t){
55
+ ;return isNaN(e)?"string"==typeof t:Boolean(e)}function He(t){for(var e={},n=t.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(t){console.warn("Could not parse settings from js-hypothesis-config tags",t),i={}}Object.assign(e,i)}return e}function Ve(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ze(t){return t.width<=0||t.height<=0}function Ue(t,e,n,o){return Math.max(t,n)<Math.min(e,o)}function $e(t,e){return!ze(t)&&!ze(e)&&(Ue(t.left,t.right,e.left,e.right)&&Ue(t.top,t.bottom,e.top,e.bottom))}function qe(t,e){return Ue(t.top,t.bottom,e.top,e.bottom)}function We(t,e){return Ue(t.left,t.right,e.left,e.right)}function je(t,e){if(ze(t))return e;if(ze(e))return t;const n=Math.min(t.left,e.left),o=Math.min(t.top,e.top),i=Math.max(t.right,e.right),r=Math.max(t.bottom,e.bottom);return new DOMRect(n,o,i-n,r-o)}function Ke(t){return new DOMPoint((t.left+t.right)/2,(t.top+t.bottom)/2)}function Xe(t){
56
56
  return t.nodeType===Node.ELEMENT_NODE}function Ye(t){return t.nodeType===Node.TEXT_NODE}function Ge(t){if(!(t&&t instanceof HTMLElement))return!1;const e=t;return!!["INPUT","TEXTAREA"].includes(e.tagName.toUpperCase())||(!!e.isContentEditable||!(!["textbox","searchbox","combobox"].includes(e.getAttribute?.("role")||"")&&!e.closest?.('[role="textbox"], [role="searchbox"], [role="combobox"]')))}const Qe=["p",".para"];let Je;function Ze(t,e=0,n=t.data.length){return Je||(Je=document.createRange()),Je.setStart(t,e),Je.setEnd(t,n),Je.getBoundingClientRect()}function tn(t){const e=t.getBoundingClientRect();return e.x-=t.scrollLeft,e.y-=t.scrollTop,e.height=Math.max(e.height,t.scrollHeight),e.width=Math.max(e.width,t.scrollWidth),e}function*en(t,e,n){let o=t.firstChild;for(;o;){if(Xe(o)){const t=$e(tn(o),e);n(o)&&t&&(yield*en(o,e,n))}else Ye(o)&&$e(Ze(o),e)&&(yield o);o=o.nextSibling}}function nn(t,e){let n=null;const o=t=>!function(t){switch(getComputedStyle(t).position){case"fixed":case"sticky":return!0;default:
57
- return!1}}(t);t:for(const s of en(t,e,o)){let t=0;for(const o of s.data.split(/\b/)){if(/\S/.test(o)){const a=t,l=t+o.length,c=Ze(s,a,l);if(r=c,!Ve(i=e)&&!Ve(r)&&r.left>=i.left&&r.right<=i.right&&r.top>=i.top&&r.bottom<=i.bottom){n=document.createRange(),n.setStart(s,a),n.setEnd(s,l);break t}}t+=o.length}}var i,r;return n}function on(t,e=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const o=nn(e,n);if(!o)return t(),0;const i=o.getBoundingClientRect().top;t();const r=o.getBoundingClientRect().top-i;return e.scrollTop+=r,r}function rn(t,e,n){const o=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return o.href}function sn(t){return"string"==typeof t?t:null}function an(t){const e=function(t){if(!ze(t,"hypothesisConfig"))return{};if("function"!=typeof t.hypothesisConfig){
58
- const t="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+t),{}}return t.hypothesisConfig()}(t),n=Fe(e.ignoreOtherConfiguration)?{}:He(t.document);function o(t){return ze(e,t)?e[t]:ze(n,t)?n[t]:void 0}return{get annotations(){return sn(n.annotations)||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return rn(t,"hypothesis-client","javascript")},get group(){return sn(n.group)||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return rn(t,"notebook","html")},get profileAppUrl(){return rn(t,"profile","html")},get showHighlights(){return function(){const t=o("showHighlights");switch(t){case"always":case"never":case"whenSidebarOpen":return t;case!0:return"always";case!1:return"never";default:return"always"}}()},get sidebarAppUrl(){return rn(t,"sidebar","html")},
57
+ return!1}}(t);t:for(const s of en(t,e,o)){let t=0;for(const o of s.data.split(/\b/)){if(/\S/.test(o)){const a=t,l=t+o.length,c=Ze(s,a,l);if(r=c,!ze(i=e)&&!ze(r)&&r.left>=i.left&&r.right<=i.right&&r.top>=i.top&&r.bottom<=i.bottom){n=document.createRange(),n.setStart(s,a),n.setEnd(s,l);break t}}t+=o.length}}var i,r;return n}function on(t,e=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const o=nn(e,n);if(!o)return t(),0;const i=o.getBoundingClientRect().top;t();const r=o.getBoundingClientRect().top-i;return e.scrollTop+=r,r}function rn(t,e,n){const o=t.document.querySelector(`link[type="application/annotator+${n}"][rel="${e}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${e}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${e}") link has no href`);return o.href}function sn(t){return"string"==typeof t?t:null}function an(t){const e=function(t){if(!Ve(t,"hypothesisConfig"))return{};if("function"!=typeof t.hypothesisConfig){
58
+ const t="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+t),{}}return t.hypothesisConfig()}(t),n=Fe(e.ignoreOtherConfiguration)?{}:He(t.document);function o(t){return Ve(e,t)?e[t]:Ve(n,t)?n[t]:void 0}return{get annotations(){return sn(n.annotations)||function(){const e=t.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get clientUrl(){return rn(t,"hypothesis-client","javascript")},get group(){return sn(n.group)||function(){const e=t.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return e?e[1]:null}()},get notebookAppUrl(){return rn(t,"notebook","html")},get profileAppUrl(){return rn(t,"profile","html")},get showHighlights(){return function(){const t=o("showHighlights");switch(t){case"always":case"never":case"whenSidebarOpen":return t;case!0:return"always";case!1:return"never";default:return"always"}}()},get sidebarAppUrl(){return rn(t,"sidebar","html")},
59
59
  get query(){return sn(n.query)||function(){const e=t.location.href.match(/#annotations:(query|q):(.+)$/i);if(e)try{return decodeURIComponent(e[2])}catch{}return null}()},get sideBySide(){return function(){const t=o("sideBySide");if(!function(t){return null!==t&&"object"==typeof t}(t))return{mode:"auto"};const e="mode"in t&&function(t){return"string"==typeof t&&["auto","manual"].includes(t)}(t.mode)?t.mode:"auto";return"auto"===e?{mode:e}:{mode:e,isActive:"isActive"in t&&"function"==typeof t.isActive?t.isActive:void 0}}()},hostPageSetting:o}}const ln=(t,e)=>t.hostPageSetting(e),cn={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:ln},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:ln},bucketContainerSelector:{defaultValue:null,allowInBrowserExt:!1,getValue:ln},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.clientUrl},contentInfoBanner:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},
60
60
  contentReady:{allowInBrowserExt:!0,defaultValue:null,getValue:ln},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},group:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:Fe,getValue:ln},query:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},services:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:t=>t.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.notebookAppUrl},profileAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.profileAppUrl},sidebarAppUrl:{
61
61
  allowInBrowserExt:!0,defaultValue:null,getValue:t=>t.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:ln},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:ln},sideBySide:{allowInBrowserExt:!0,getValue:t=>t.sideBySide},commentsMode:{defaultValue:!1,allowInBrowserExt:!1,getValue:ln},groupsAllowlist:{allowInBrowserExt:!1,getValue:ln}};function hn(t,e=window){const n=an(e),o={};for(const r of function(t){const e={annotator:["clientUrl","contentInfoBanner","contentReady","subFrameIdentifier","sideBySide","commentsMode"],sidebar:["appType","annotations","branding","bucketContainerSelector","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl","commentsMode","groupsAllowlist"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"],profile:["profileAppUrl"]}
@@ -68,9 +68,9 @@ const n=`hypothesis-${t}`;this._element=document.createElement(n);const{shadowRo
68
68
  this._container.render(),Object.assign(this._container.element.style,{top:0,left:0})}destroy(){this._container.destroy()}show(t,e){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(t,e);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=i===Tn.UP?"up":"down",this._container.render()}_firstChild(){return this._container.element.shadowRoot.firstChild}_width(){return this._firstChild().getBoundingClientRect().width}_height(){return this._firstChild().getBoundingClientRect().height}_calculateTarget(t,e){let n,o,i;n=e&&!xn()?Tn.DOWN:Tn.UP;const r=Math.min(20,t.width),s=this._width(),a=xn()?10:0,l=this._height();return i=e?t.left-s/2+r:t.left+t.width-s/2-r,t.top-l<0&&n===Tn.DOWN?n=Tn.UP:t.top+l>this._view.innerHeight&&(n=Tn.DOWN),o=n===Tn.UP?t.top+t.height+10+a:t.top-l-10,i=Math.max(i,0),i=Math.min(i,this._view.innerWidth-s),o=Math.max(o,0),o=Math.min(o,this._view.innerHeight-l),{top:o,left:i,arrowDirection:n}}_findZindex(t,e){if(void 0===document.elementsFromPoint)return 32768
69
69
  ;const n=this._width(),o=this._height(),i=t=>{const e=parseInt(getComputedStyle(t).zIndex);return Number.isInteger(e)?e:0},r=[...new Set([...document.elementsFromPoint(t,e),...document.elementsFromPoint(t,e+o),...document.elementsFromPoint(t+n/2,e+o/2),...document.elementsFromPoint(t+n,e),...document.elementsFromPoint(t+n,e+o)])].map(i).filter(Number.isInteger);let s=0;for(const t of document.querySelectorAll("hypothesis-highlight"))s=Math.max(s,i(t));return r.push(s),Math.max(...r)+1}_showAt(t,e){const n=function(t){let e=t.parentElement;for(;e.parentElement&&"static"===getComputedStyle(e).position;)e=e.parentElement;return e}(this._container.element).getBoundingClientRect(),o=this._findZindex(t,e);Object.assign(this._container.element.style,{left:Nn(t-n.left),top:Nn(e-n.top),zIndex:o})}_render(){return St(Mn,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:t=>{switch(t){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break
70
70
  ;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length})}}var On=function(t){return t[t.Forwards=1]="Forwards",t[t.Backwards=2]="Backwards",t}(On||{});function In(t,e,n){const o=n===On.Forwards?e:e-1;if(""!==t.charAt(o).trim())return e;let i,r;if(n===On.Backwards?(i=t.substring(0,e),r=i.trimEnd()):(i=t.substring(e),r=i.trimStart()),!r.length)return-1;const s=i.length-r.length;return n===On.Backwards?e-s:e+s}function Bn(t,e){const n=t.commonAncestorContainer.ownerDocument.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_TEXT),o=e===On.Forwards?t.startContainer:t.endContainer,i=e===On.Forwards?t.endContainer:t.startContainer;let r=n.nextNode();for(;r&&r!==o;)r=n.nextNode();e===On.Backwards&&(r=n.previousNode());let s=-1;const a=()=>{if(r=e===On.Forwards?n.nextNode():n.previousNode(),r){const t=r.textContent,n=e===On.Forwards?0:t.length;s=In(t,n,e)}};for(;r&&-1===s&&r!==i;)a();if(r&&s>=0)return{node:r,
71
- offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function Dn(t){switch(t.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return t.textContent?.length??0;default:return 0}}function Fn(t){let e=t.previousSibling,n=0;for(;e;)n+=Dn(e),e=e.previousSibling;return n}function Hn(t,...e){let n=e.shift();const o=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),i=[];let r,s=o.nextNode(),a=0;for(;void 0!==n&&s;)r=s,a+r.data.length>n?(i.push({node:r,offset:n-a}),n=e.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=e.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}let zn=function(t){return t[t.FORWARDS=1]="FORWARDS",t[t.BACKWARDS=2]="BACKWARDS",t}({});class Vn{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element")
72
- ;let e=this.element,n=this.offset;for(;e!==t;)n+=Fn(e),e=e.parentElement;return new Vn(e,n)}resolve(t={}){try{return Hn(this.element,this.offset)[0]}catch(e){if(0===this.offset&&void 0!==t.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=t.direction===zn.FORWARDS,i=o?n.nextNode():n.previousNode();if(!i)throw e;return{node:i,offset:o?0:i.data.length}}throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return Vn.fromPoint(t,e);case Node.ELEMENT_NODE:return new Vn(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const n=Fn(t)+e;return new Vn(t.parentElement,n)}case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let n=0
73
- ;for(let o=0;o<e;o++)n+=Dn(t.childNodes[o]);return new Vn(t,n)}default:throw new Error("Point is not in an element or text node")}}}class Un{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new Un(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=Hn(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:zn.FORWARDS}),e=this.end.resolve({direction:zn.BACKWARDS}));const n=new Range;return n.setStart(t.node,t.offset),n.setEnd(e.node,e.offset),n}static fromRange(t){const e=Vn.fromPoint(t.startContainer,t.startOffset),n=Vn.fromPoint(t.endContainer,t.endOffset);return new Un(e,n)}static fromOffsets(t,e,n){return new Un(new Vn(t,e),new Vn(t,n))}static trimmedRange(t){return function(t){if(!t.toString().trim().length)throw new RangeError("Range contains no non-whitespace text")
71
+ offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function Dn(t){switch(t.nodeType){case Node.ELEMENT_NODE:case Node.TEXT_NODE:return t.textContent?.length??0;default:return 0}}function Fn(t){let e=t.previousSibling,n=0;for(;e;)n+=Dn(e),e=e.previousSibling;return n}function Hn(t,...e){let n=e.shift();const o=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),i=[];let r,s=o.nextNode(),a=0;for(;void 0!==n&&s;)r=s,a+r.data.length>n?(i.push({node:r,offset:n-a}),n=e.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=e.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}let Vn=function(t){return t[t.FORWARDS=1]="FORWARDS",t[t.BACKWARDS=2]="BACKWARDS",t}({});class zn{constructor(t,e){if(e<0)throw new Error("Offset is invalid");this.element=t,this.offset=e}relativeTo(t){if(!t.contains(this.element))throw new Error("Parent is not an ancestor of current element")
72
+ ;let e=this.element,n=this.offset;for(;e!==t;)n+=Fn(e),e=e.parentElement;return new zn(e,n)}resolve(t={}){try{return Hn(this.element,this.offset)[0]}catch(e){if(0===this.offset&&void 0!==t.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=t.direction===Vn.FORWARDS,i=o?n.nextNode():n.previousNode();if(!i)throw e;return{node:i,offset:o?0:i.data.length}}throw e}}static fromCharOffset(t,e){switch(t.nodeType){case Node.TEXT_NODE:return zn.fromPoint(t,e);case Node.ELEMENT_NODE:return new zn(t,e);default:throw new Error("Node is not an element or text node")}}static fromPoint(t,e){switch(t.nodeType){case Node.TEXT_NODE:{if(e<0||e>t.data.length)throw new Error("Text node offset is out of range");if(!t.parentElement)throw new Error("Text node has no parent");const n=Fn(t)+e;return new zn(t.parentElement,n)}case Node.ELEMENT_NODE:{if(e<0||e>t.childNodes.length)throw new Error("Child node offset is out of range");let n=0
73
+ ;for(let o=0;o<e;o++)n+=Dn(t.childNodes[o]);return new zn(t,n)}default:throw new Error("Point is not in an element or text node")}}}class Un{constructor(t,e){this.start=t,this.end=e}relativeTo(t){return new Un(this.start.relativeTo(t),this.end.relativeTo(t))}toRange(){let t,e;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[t,e]=Hn(this.start.element,this.start.offset,this.end.offset):(t=this.start.resolve({direction:Vn.FORWARDS}),e=this.end.resolve({direction:Vn.BACKWARDS}));const n=new Range;return n.setStart(t.node,t.offset),n.setEnd(e.node,e.offset),n}static fromRange(t){const e=zn.fromPoint(t.startContainer,t.startOffset),n=zn.fromPoint(t.endContainer,t.endOffset);return new Un(e,n)}static fromOffsets(t,e,n){return new Un(new zn(t,e),new zn(t,n))}static trimmedRange(t){return function(t){if(!t.toString().trim().length)throw new RangeError("Range contains no non-whitespace text")
74
74
  ;if(t.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(t.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const e=t.cloneRange();let n=!1,o=!1;const i={start:In(t.startContainer.textContent,t.startOffset,On.Forwards),end:In(t.endContainer.textContent,t.endOffset,On.Backwards)};if(i.start>=0&&(e.setStart(t.startContainer,i.start),n=!0),i.end>0&&(e.setEnd(t.endContainer,i.end),o=!0),n&&o)return e;if(!n){const{node:t,offset:n}=Bn(e,On.Forwards);t&&n>=0&&e.setStart(t,n)}if(!o){const{node:t,offset:n}=Bn(e,On.Backwards);t&&n>0&&e.setEnd(t,n)}return e}(Un.fromRange(t).toRange())}}const $n=".annotator-placeholder";function qn(t){return!!t.parentElement&&null!==t.parentElement.closest($n)}function Wn(t,e){const n=new Range;return t.compareBoundaryPoints(Range.START_TO_START,e)<=0?n.setStart(t.startContainer,t.startOffset):n.setStart(e.startContainer,e.startOffset),
75
75
  t.compareBoundaryPoints(Range.END_TO_END,e)>=0?n.setEnd(t.endContainer,t.endOffset):n.setEnd(e.endContainer,e.endOffset),n}function jn(t=document.getSelection()){if(!t||0===t.rangeCount)return null;let e=t.getRangeAt(0);for(let n=1;n<t.rangeCount;n++)e=Wn(e,t.getRangeAt(n));return e.collapsed?null:e}function Kn(t){if(t.focusNode===t.anchorNode)return t.focusOffset<t.anchorOffset;return jn(t).startContainer===t.focusNode}function Xn(t,e){try{const n=e.nodeValue?.length??e.childNodes.length;return t.comparePoint(e,0)<=0&&t.comparePoint(e,n)>=0}catch{return!1}}function Yn(t,e){const n=t.commonAncestorContainer,o=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let i;for(;i=o.nextNode();)Xn(t,i)&&e(i)}function Gn(t){const e=jn(t);if(!e)return null;const n=function(t){const e=[];return Yn(t,(t=>{Ye(t)&&!t.textContent.match(/^\s*$/)&&e.push(t)})),e.flatMap((e=>{const n=e.ownerDocument.createRange();if(n.selectNodeContents(e),e===t.startContainer&&n.setStart(e,t.startOffset),
76
76
  e===t.endContainer&&n.setEnd(e,t.endOffset),n.collapsed)return[];const o=Array.from(n.getClientRects());return n.detach(),o}))}(e);return 0===n.length?null:Kn(t)?n[0]:n[n.length-1]}const Qn="http://www.w3.org/2000/svg",Jn=["user-annotations","user-highlights","other-content"];class Zn{constructor(t=document.body){this.root=t}highlightShape(t){const{shape:e,anchor:n}=t,o=document.createElement("hypothesis-highlight");if(o.className="hypothesis-shape-highlight","rect"===e.type){const t=e.right-e.left,n=e.bottom-e.top;o.style.left=100*e.left+"%",o.style.top=100*e.top+"%",o.style.width=`calc(${100*t}% - 6px)`,o.style.height=`calc(${100*n}% - 6px)`}else if("point"===e.type){const t=7;o.style.left=`calc(${100*e.x}% - ${t+3}px)`,o.style.top=`calc(${100*e.y}% - ${t+3}px)`,o.style.width=2*t+"px",o.style.height=2*t+"px",o.style.borderRadius="50%"}return n.append(o),[o]}highlightRange(t,e){const n=function(t){if(t.collapsed)return[];let e=t.commonAncestorContainer;e&&e.nodeType!==Node.ELEMENT_NODE&&(e=e.parentElement)
@@ -103,83 +103,83 @@ secondColor:"transparent",thirdColor:"transparent"},pink:{color:"var(--hypothesi
103
103
  this._features=e.features,this._container=new Pn("highlight-cluster-toolbar",(()=>this._render())),this._element.appendChild(this._container.element),Object.assign(this._container.element.style,{position:"fixed",top:`${this._element.offsetTop+4}px`,left:"4px"}),this.appliedStyles=To,this._init(),this._features.on("flagsChanged",(()=>{this._activate(this._isActive())})),this._container.render()}destroy(){clearTimeout(this._updateTimeout),this._activate(!1),this._container.destroy()}scheduleClusterUpdates(){clearTimeout(this._updateTimeout),this._updateTimeout=setTimeout((()=>this._updateClusters()),100)}_init(){for(const t of Object.keys(this.appliedStyles))this._setClusterStyles(t,this.appliedStyles[t]);this._activate(this._isActive())}_updateClusters(){this._isActive()&&io(this._element)}_isActive(){return this._features.flagEnabled("styled_highlight_clusters")}_activate(t){this._element.classList.toggle("hypothesis-highlights-clustered",t),this._container.render()}_setClusterStyle(t,e){
104
104
  document.documentElement.style.setProperty(t,e)}_setClusterStyles(t,e){const n=Po[e];for(const e of Object.keys(n))this._setClusterStyle(`--hypothesis-${t}-${e}`,n[e])}_onChangeClusterStyle(t,e){this.appliedStyles[t]=e,this._setClusterStyles(t,e),this._container.render()}_render(){return St(Eo,{active:this._isActive(),availableStyles:Po,currentStyles:this.appliedStyles,onStyleChange:(t,e)=>this._onChangeClusterStyle(t,e)})}}function Lo(t){return t.split("").reverse().join("")}function Oo(t){return(t|-t)>>31&1}function Io(t,e,n,o){let i=t.P[n],r=t.M[n];const s=o>>>31,a=e[n]|s,l=a|r,c=(a&i)+i^i|a;let h=r|~(c|i),d=i&c;const u=Oo(h&t.lastRowMask[n])-Oo(d&t.lastRowMask[n]);return h<<=1,d<<=1,d|=s,h|=Oo(o)-s,i=d|~(l|h),r=h&l,t.P[n]=i,t.M[n]=r,u}function Bo(t,e,n){if(0===e.length)return[];n=Math.min(n,e.length);const o=[],i=32,r=Math.ceil(e.length/i)-1,s={P:new Uint32Array(r+1),M:new Uint32Array(r+1),lastRowMask:new Uint32Array(r+1)};s.lastRowMask.fill(1<<31),s.lastRowMask[r]=1<<(e.length-1)%i
105
105
  ;const a=new Uint32Array(r+1),l=new Map,c=[];for(let t=0;t<256;t++)c.push(a);for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(l.has(n))continue;const o=new Uint32Array(r+1);l.set(n,o),n<c.length&&(c[n]=o);for(let t=0;t<=r;t+=1){o[t]=0;for(let r=0;r<i;r+=1){const s=t*i+r;if(s>=e.length)continue;e.charCodeAt(s)===n&&(o[t]|=1<<r)}}}let h=Math.max(0,Math.ceil(n/i)-1);const d=new Uint32Array(r+1);for(let t=0;t<=h;t+=1)d[t]=(t+1)*i;d[r]=e.length;for(let t=0;t<=h;t+=1)s.P[t]=-1,s.M[t]=0;for(let u=0;u<t.length;u+=1){const f=t.charCodeAt(u);let p;f<c.length?p=c[f]:(p=l.get(f),void 0===p&&(p=a));let g=0;for(let t=0;t<=h;t+=1)g=Io(s,p,t,g),d[t]+=g;if(d[h]-g<=n&&h<r&&(1&p[h+1]||g<0)){let t;if(h+=1,s.P[h]=-1,s.M[h]=0,h===r){const n=e.length%i;t=0===n?i:n}else t=i;d[h]=d[h-1]+t-g+Io(s,p,h,g)}else for(;h>0&&d[h]>=n+i;)h-=1;h===r&&d[h]<=n&&(d[h]<n&&o.splice(0,o.length),o.push({start:-1,end:u+1,errors:d[h]}),n=d[h])}return o}function Do(t,e,n){return function(t,e,n){const o=Lo(e);return n.map((n=>{
106
- const i=Math.max(0,n.end-e.length-n.errors);return{start:Bo(Lo(t.slice(i,n.end)),o,n.errors).reduce(((t,e)=>n.end-e.end<t?n.end-e.end:t),n.end),end:n.end,errors:n.errors}}))}(t,e,Bo(t,e,n))}function Fo(t,e,n){let o=0;const i=[];for(;-1!==o;)o=t.indexOf(e,o),-1!==o&&(i.push({start:o,end:o+e.length,errors:0}),o+=1);return i.length>0?i:Do(t,e,n)}function Ho(t,e){if(0===e.length||0===t.length)return 0;return 1-Fo(t,e,e.length)[0].errors/e.length}function zo(t,e,n={}){if(0===e.length)return null;const o=Math.min(256,e.length/2),i=Fo(t,e,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/e.length,r=n.prefix?Ho(t.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?Ho(t.slice(o.end,o.end+n.suffix.length),n.suffix):1;let a=1;if("number"==typeof n.hint){a=1-Math.abs(o.start-n.hint)/t.length}return(50*i+20*r+20*s+2*a)/92},s=i.map((t=>({start:t.start,end:t.end,score:r(t)})));return s.sort(((t,e)=>e.score-t.score)),s[0]}function Vo(t){const e=function(t){const e=t.nodeName.toLowerCase()
107
- ;return"#text"===e?"text()":e}(t),n=function(t){let e=0,n=t;for(;n;)n.nodeName===t.nodeName&&(e+=1),n=n.previousSibling;return e}(t);return`${e}[${n}]`}function Uo(t,e){let n="",o=t;for(;o!==e;){if(!o)throw new Error("Node is not a descendant of root");n=Vo(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function $o(t,e,n){e=e.toUpperCase();let o=-1;for(let i=0;i<t.children.length;i++){const r=t.children[i];if(r.nodeName.toUpperCase()===e&&(++o,o===n))return r}return null}function qo(t,e=document.body){try{return function(t,e){if(null===t.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=t.split("/");let o=e;n.shift();for(const t of n){let e,n;const i=t.indexOf("[");if(-1!==i){e=t.slice(0,i);const o=t.slice(i+1,t.indexOf("]"));if(n=parseInt(o)-1,n<0)return null}else e=t,n=0;const r=$o(o,e,n);if(!r)return null;o=r}return o}(t,e)}catch{return document.evaluate("."+t,e,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}}class Wo{
108
- constructor(t,e){this.root=t,this.range=e}static fromRange(t,e){return new Wo(t,e)}static fromSelector(t,e){const n=qo(e.startContainer,t);if(!n)throw new Error("Failed to resolve startContainer XPath");const o=qo(e.endContainer,t);if(!o)throw new Error("Failed to resolve endContainer XPath");const i=Vn.fromCharOffset(n,e.startOffset),r=Vn.fromCharOffset(o,e.endOffset),s=new Un(i,r).toRange();return new Wo(t,s)}toRange(){return this.range}toSelector(){const t=Un.fromRange(this.range).toRange(),e=Un.fromRange(t),n=Uo(e.start.element,this.root),o=Uo(e.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:e.start.offset,endContainer:o,endOffset:e.end.offset}}}class jo{constructor(t,e,n){this.root=t,this.start=e,this.end=n}static fromRange(t,e){const n=Un.fromRange(e).relativeTo(t);return new jo(t,n.start.offset,n.end.offset)}static fromSelector(t,e){return new jo(t,e.start,e.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){
109
- return Un.fromOffsets(this.root,this.start,this.end).toRange()}}class Ko{constructor(t,e,n={}){this.root=t,this.exact=e,this.context=n}static fromRange(t,e){const n=t.textContent,o=Un.fromRange(e).relativeTo(t),i=o.start.offset,r=o.end.offset;return new Ko(t,n.slice(i,r),{prefix:n.slice(Math.max(0,i-32),i),suffix:n.slice(r,Math.min(n.length,r+32))})}static fromSelector(t,e){const{prefix:n,suffix:o}=e;return new Ko(t,e.exact,{prefix:n,suffix:o})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(t={}){return this.toPositionAnchor(t).toRange()}toPositionAnchor(t={}){const e=zo(this.root.textContent,this.exact,{...this.context,hint:t.hint});if(!e)throw new Error("Quote not found");return new jo(this.root,e.start,e.end)}}function Xo(t){const e=parseFloat(t);return!Number.isFinite(e)||e<0?null:e}function Yo(t){return t instanceof Element?t:t.parentElement}function Go(t,e=t){
106
+ const i=Math.max(0,n.end-e.length-n.errors);return{start:Bo(Lo(t.slice(i,n.end)),o,n.errors).reduce(((t,e)=>n.end-e.end<t?n.end-e.end:t),n.end),end:n.end,errors:n.errors}}))}(t,e,Bo(t,e,n))}function Fo(t,e,n){let o=0;const i=[];for(;-1!==o;)o=t.indexOf(e,o),-1!==o&&(i.push({start:o,end:o+e.length,errors:0}),o+=1);return i.length>0?i:Do(t,e,n)}function Ho(t,e){if(0===e.length||0===t.length)return 0;return 1-Fo(t,e,e.length)[0].errors/e.length}function Vo(t,e,n={}){if(0===e.length)return null;const o=Math.min(256,e.length/2),i=Fo(t,e,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/e.length,r=n.prefix?Ho(t.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?Ho(t.slice(o.end,o.end+n.suffix.length),n.suffix):1;let a=1;if("number"==typeof n.hint){a=1-Math.abs(o.start-n.hint)/t.length}return(50*i+20*r+20*s+2*a)/92},s=i.map((t=>({start:t.start,end:t.end,score:r(t)})));return s.sort(((t,e)=>e.score-t.score)),s[0]}function zo(t){const e=function(t){const e=t.nodeName.toLowerCase()
107
+ ;return"#text"===e?"text()":e}(t),n=function(t){let e=0,n=t;for(;n;)n.nodeName===t.nodeName&&(e+=1),n=n.previousSibling;return e}(t);return`${e}[${n}]`}function Uo(t,e){let n="",o=t;for(;o!==e;){if(!o)throw new Error("Node is not a descendant of root");n=zo(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function $o(t,e,n){e=e.toUpperCase();let o=-1;for(let i=0;i<t.children.length;i++){const r=t.children[i];if(r.nodeName.toUpperCase()===e&&(++o,o===n))return r}return null}function qo(t,e=document.body){try{return function(t,e){if(null===t.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=t.split("/");let o=e;n.shift();for(const t of n){let e,n;const i=t.indexOf("[");if(-1!==i){e=t.slice(0,i);const o=t.slice(i+1,t.indexOf("]"));if(n=parseInt(o)-1,n<0)return null}else e=t,n=0;const r=$o(o,e,n);if(!r)return null;o=r}return o}(t,e)}catch{return document.evaluate("."+t,e,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}}class Wo{
108
+ constructor(t,e){this.root=t,this.range=e}static fromRange(t,e){return new Wo(t,e)}static fromSelector(t,e){const n=qo(e.startContainer,t);if(!n)throw new Error("Failed to resolve startContainer XPath");const o=qo(e.endContainer,t);if(!o)throw new Error("Failed to resolve endContainer XPath");const i=zn.fromCharOffset(n,e.startOffset),r=zn.fromCharOffset(o,e.endOffset),s=new Un(i,r).toRange();return new Wo(t,s)}toRange(){return this.range}toSelector(){const t=Un.fromRange(this.range).toRange(),e=Un.fromRange(t),n=Uo(e.start.element,this.root),o=Uo(e.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:e.start.offset,endContainer:o,endOffset:e.end.offset}}}class jo{constructor(t,e,n){this.root=t,this.start=e,this.end=n}static fromRange(t,e){const n=Un.fromRange(e).relativeTo(t);return new jo(t,n.start.offset,n.end.offset)}static fromSelector(t,e){return new jo(t,e.start,e.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){
109
+ return Un.fromOffsets(this.root,this.start,this.end).toRange()}}class Ko{constructor(t,e,n={}){this.root=t,this.exact=e,this.context=n}static fromRange(t,e){const n=t.textContent,o=Un.fromRange(e).relativeTo(t),i=o.start.offset,r=o.end.offset;return new Ko(t,n.slice(i,r),{prefix:n.slice(Math.max(0,i-32),i),suffix:n.slice(r,Math.min(n.length,r+32))})}static fromSelector(t,e){const{prefix:n,suffix:o}=e;return new Ko(t,e.exact,{prefix:n,suffix:o})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(t={}){return this.toPositionAnchor(t).toRange()}toPositionAnchor(t={}){const e=Vo(this.root.textContent,this.exact,{...this.context,hint:t.hint});if(!e)throw new Error("Quote not found");return new jo(this.root,e.start,e.end)}}function Xo(t){const e=parseFloat(t);return!Number.isFinite(e)||e<0?null:e}function Yo(t){return t instanceof Element?t:t.parentElement}function Go(t,e=t){
110
110
  const n=Xo(t?.getAttribute("data-time-start")??""),o=Xo(e?.getAttribute("data-time-end")??"");return"number"!=typeof n||"number"!=typeof o||o<n?null:[n,o]}class Qo{constructor(t,e,n){this.root=t,this.start=e,this.end=n}static fromRange(t,e){const n=Yo(e.startContainer)?.closest("[data-time-start]"),o=Yo(e.endContainer)?.closest("[data-time-end]"),i=Go(n,o);if(!i)return null;const[r,s]=i;return new Qo(t,r,s)}toRange(){const t=[...this.root.querySelectorAll("[data-time-start]")].map((t=>{const e=Go(t);if(!e)return null;const[n,o]=e;return{element:t,start:n,end:o}})).filter((t=>null!==t));t.sort(((t,e)=>t.start-e.start));const e=function(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}(t,(t=>t.start<=this.start&&t.end>=this.start));if(-1===e)throw new Error("Start segment not found");const n=e+t.slice(e).findIndex((t=>t.start<=this.end&&t.end>=this.end));if(-1===n)throw new Error("End segment not found");const o=new Range;o.setStart(t[e].element,0);const i=t[n].element
111
111
  ;return o.setEnd(i,i.childNodes.length),o}static fromSelector(t,e){const{start:n,end:o}=e;return new Qo(t,n,o)}toSelector(){return{type:"MediaTimeSelector",start:this.start,end:this.end}}}async function Jo(t,e){return t.toRange(e)}function Zo(t,e,n){const o=t[e];if("function"!=typeof o)throw new Error("Can only intercept functions");return t[e]=(...e)=>{const i=o.call(t,...e);return n(...e),i},()=>{t[e]=o}}function ti(t){return t.replace(/#.*/,"")}class ei{constructor(t,e=(()=>location.href)){this._listeners=new mt;let n=e();const o=(o=e())=>{ti(n)!==ti(o)&&(n=o,t(o))},i=function(){const t=window.navigation;return"function"==typeof Navigation&&t instanceof Navigation?t:null}();if(i)this._listeners.add(i,"navigatesuccess",(()=>o()));else{const t=[Zo(window.history,"pushState",(()=>o())),Zo(window.history,"replaceState",(()=>o()))];this._unpatchHistory=()=>t.forEach((t=>t())),this._listeners.add(window,"popstate",(()=>o()))}}disconnect(){this._unpatchHistory?.(),this._listeners.removeAll()}}var ni,oi
112
112
  ;var ii=function(){if(oi)return ni;oi=1;var t="complete",e="canceled";function n(t,e,n){t.self===t?t.scrollTo(e,n):(t.scrollLeft=e,t.scrollTop=n)}function o(e){var i=e._scrollSettings;if(i){var r=i.maxSynchronousAlignments,s=function(t,e){var n,o,i,r,s,a,l,c=t.align,h=t.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,u=c&&null!=c.top?c.top:.5,f=c&&null!=c.leftOffset?c.leftOffset:0,p=c&&null!=c.topOffset?c.topOffset:0,g=d,_=u;if(t.isWindow(e))a=Math.min(h.width,e.innerWidth),l=Math.min(h.height,e.innerHeight),o=h.left+e.pageXOffset-e.innerWidth*g+a*g,i=h.top+e.pageYOffset-e.innerHeight*_+l*_,o-=f,i-=p,o=t.align.lockX?e.pageXOffset:o,i=t.align.lockY?e.pageYOffset:i,r=o-e.pageXOffset,s=i-e.pageYOffset;else{a=h.width,l=h.height,n=e.getBoundingClientRect();var m=h.left-(n.left-e.scrollLeft),b=h.top-(n.top-e.scrollTop);o=m+a*g-e.clientWidth*g,i=b+l*_-e.clientHeight*_,o-=f,i-=p,o=Math.max(Math.min(o,e.scrollWidth-e.clientWidth),0),i=Math.max(Math.min(i,e.scrollHeight-e.clientHeight),0),
113
113
  o=t.align.lockX?e.scrollLeft:o,i=t.align.lockY?e.scrollTop:i,r=o-e.scrollLeft,s=i-e.scrollTop}return{x:o,y:i,differenceX:r,differenceY:s}}(i,e),a=Date.now()-i.startTime,l=Math.min(1/i.time*a,1);if(i.endIterations>=r)return n(e,s.x,s.y),e._scrollSettings=null,i.end(t);var c=1-i.ease(l);if(n(e,s.x-s.differenceX*c,s.y-s.differenceY*c),a>=i.time)return i.endIterations++,i.scrollAncestor&&o(i.scrollAncestor),void o(e);!function(t){if("requestAnimationFrame"in window)return window.requestAnimationFrame(t);setTimeout(t,16)}(o.bind(null,e))}}function i(t){return t.self===t}function r(t){return"pageXOffset"in t||(t.scrollHeight!==t.clientHeight||t.scrollWidth!==t.clientWidth)&&"hidden"!==getComputedStyle(t).overflow}function s(){return!0}function a(t){if(t.assignedSlot)return a(t.assignedSlot);if(t.parentElement)return"body"===t.parentElement.tagName.toLowerCase()?t.parentElement.ownerDocument.defaultView||t.parentElement.ownerDocument.ownerWindow:t.parentElement;if(t.getRootNode){var e=t.getRootNode()
114
114
  ;if(11===e.nodeType)return e.host}}return ni=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(t){return 1-Math.pow(1-t,t/2)},l.align=l.align||{};var h=a(n),d=1,u=l.validTarget||s,f=l.isScrollable;l.debug&&(console.log("About to scroll to",n),h||console.error("Target did not have a parent, is it mounted in the DOM?"));for(var p=[];h;)if(l.debug&&console.log("Scrolling parent node",h),u(h,d)&&(f?f(h,r):r(h))&&(d++,p.push(h)),!(h=a(h))){g(t);break}return p.reduce(((t,r,s)=>function(t,n,r,s,a){var l,c=!n._scrollSettings,h=n._scrollSettings,d=Date.now(),u={passive:!0};function f(t){n._scrollSettings=null,n.parentElement&&n.parentElement._scrollSettings&&n.parentElement._scrollSettings.end(t),r.debug&&console.log("Scrolling ended with type",t,"for",n),a(t),l&&(n.removeEventListener("touchstart",l,u),n.removeEventListener("wheel",l,u))}h&&h.end(e);var p=r.maxSynchronousAlignments;return null==p&&(p=3),n._scrollSettings={startTime:d,
115
115
  endIterations:0,target:t,time:r.time,ease:r.ease,align:r.align,isWindow:r.isWindow||i,maxSynchronousAlignments:p,end:f,scrollAncestor:s},"cancellable"in r&&!r.cancellable||(l=f.bind(null,e),n.addEventListener("touchstart",l,u),n.addEventListener("wheel",l,u)),c&&o(n),l}(n,r,l,p[s+1],g)),null)}function g(t){--d||c&&c(t)}},ni}(),ri=kt(ii);function si(t,e,n){return t+n*(e-t)}async function ai(t,e,{maxDuration:n=500}={}){const o=t.scrollTop,i=e,r=Date.now(),s=Math.min(Math.abs(i-o)/3,n);let a=0;for(;a<1;)await new Promise((t=>{requestAnimationFrame(t)})),a=Math.min(1,(Date.now()-r)/s),t.scrollTop=si(o,i,a)}function li(t,e=document.baseURI){return new URL(t,e).href.toString().replace(/#.*/,"")}class ci{constructor(t={}){this.document=t.document||document}uri(){let t=this._getDocumentHref();try{t=decodeURIComponent(t)}catch(t){console.error("Error decoding URI:",t)}const e=this._getLinks();for(const n of e)"canonical"===n.rel&&(t=n.href);return t}getDocumentMetadata(){const t={title:document.title,link:[],
116
- dc:this._getMetaTags("name","dc."),eprints:this._getMetaTags("name","eprints."),facebook:this._getMetaTags("property","og:"),highwire:this._getMetaTags("name","citation_"),prism:this._getMetaTags("name","prism."),twitter:this._getMetaTags("name","twitter:")},e=this._getFavicon();e&&(t.favicon=e),t.title=this._getTitle(t),t.link=this._getLinks(t);const n=t.link.find((t=>t.href.startsWith("urn:x-dc")));return n&&(t.documentFingerprint=n.href),t}_getMetaTags(t,e){const n={};for(const o of Array.from(this.document.querySelectorAll("meta"))){const i=o.getAttribute(t),{content:r}=o;if(i&&r){const t=i.match(RegExp(`^${e}(.+)$`,"i"));if(t){const e=t[1].toLowerCase();n[e]?n[e].push(r):n[e]=[r]}}}return n}_getTitle(t){return t.highwire.title?t.highwire.title[0]:t.eprints.title?t.eprints.title[0]:t.prism.title?t.prism.title[0]:t.facebook.title?t.facebook.title[0]:t.twitter.title?t.twitter.title[0]:t.dc.title?t.dc.title[0]:this.document.title}_getLinks(t={dc:{},highwire:{}}){const e=[{href:this._getDocumentHref()
117
- }],n=Array.from(this.document.querySelectorAll("link"));for(const t of n)if(["alternate","canonical","bookmark","shortlink"].includes(t.rel)){if("alternate"===t.rel){if(t.type&&t.type.match(/^application\/(rss|atom)\+xml/))continue;if(t.hreflang)continue}try{const n=this._absoluteUrl(t.href);e.push({href:n,rel:t.rel,type:t.type})}catch{}}for(const n of Object.keys(t.highwire)){const o=t.highwire[n];if("pdf_url"===n)for(const t of o)try{e.push({href:this._absoluteUrl(t),type:"application/pdf"})}catch{}if("doi"===n)for(let t of o)"doi:"!==t.slice(0,4)&&(t=`doi:${t}`),e.push({href:t})}for(const n of Object.keys(t.dc)){const o=t.dc[n];if("identifier"===n)for(const t of o)"doi:"===t.slice(0,4)&&e.push({href:t})}const o=t.dc["relation.ispartof"],i=t.dc.identifier;if(o&&i){const t=o[o.length-1],n=i[i.length-1],r="urn:x-dc:"+encodeURIComponent(t)+"/"+encodeURIComponent(n);e.push({href:r})}return e}_getFavicon(){let t=null
118
- ;for(const e of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(e.rel))try{t=this._absoluteUrl(e.href)}catch{}return t}_absoluteUrl(t){return li(t,this.document.baseURI)}_getDocumentHref(){const{href:t}=this.document.location,e=["http:","https:","file:"],n=new URL(t).protocol;return e.includes(n)?t:this.document.baseURI&&e.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:t}}class hi extends Me{constructor({features:t,container:e=document.body,sideBySideOptions:n}){super(),this.featureFlags=t,this.container=e,this._htmlMeta=new ci,this._prevURI=this._htmlMeta.uri(),this._sideBySideEnabled=!0,this._sideBySideOptions=n??{mode:"auto"},this._sideBySideActive=!1,this._lastLayout=null,this._navObserver=new ei((()=>this._checkForURIChange())),this._metaObserver=new MutationObserver((()=>this._checkForURIChange())),this._metaObserver.observe(document.head,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["rel","href","name","content"]}),
119
- this._flagsChanged=()=>{},this.featureFlags.on("flagsChanged",this._flagsChanged)}anchor(t,e){return function(t,e,n={}){let o=null,i=null,r=null,s=null;for(const t of e)switch(t.type){case"TextPositionSelector":i=t,n.hint=i.start;break;case"TextQuoteSelector":r=t;break;case"RangeSelector":s=t;break;case"MediaTimeSelector":o=t}const a=t=>{if(r?.exact&&t.toString()!==r.exact)throw new Error("quote mismatch");return t};let l=Promise.reject("unable to anchor");if(s){const e=s;l=l.catch((()=>Jo(Wo.fromSelector(t,e),n).then(a)))}if(i){const e=i;l=l.catch((()=>Jo(jo.fromSelector(t,e),n).then(a)))}if(r){const e=r;l=l.catch((()=>Jo(Ko.fromSelector(t,e),n)))}if(o){const e=o;l=l.catch((()=>Qo.fromSelector(t,e).toRange()))}return l}(t,e)}describe(t,e){if(e instanceof Range)return function(t,e){const n=[Qo,Wo,jo,Ko],o=[];for(const i of n)try{const n=i.fromRange(t,e);n&&o.push(n.toSelector())}catch{}return o}(t,e);throw new Error("Unsupported region type")}_checkForURIChange(){const t=this._htmlMeta.uri()
120
- ;t!==this._prevURI&&(this._prevURI=t,this.emit("uriChanged",t))}getAnnotatableRange(t){try{return Un.trimmedRange(t)}catch(t){if(t instanceof RangeError)return null;throw t}}canStyleClusteredHighlights(){return!0}destroy(){this._deactivateSideBySide(),this._navObserver.disconnect(),this._metaObserver.disconnect(),this.featureFlags.off("flagsChanged",this._flagsChanged),super.destroy()}contentContainer(){return this.container}fitSideBySide(t){this._lastLayout=t;const e=window.innerWidth-t.width,n=this._sideBySideEnabled&&"auto"===this._sideBySideOptions.mode&&t.expanded&&e>=480;return n?this._activateSideBySide(t.width):this._sideBySideActive&&this._deactivateSideBySide(),this._sideBySideActive=n,this.container.classList.toggle("hypothesis-sidebyside-active",this._sideBySideActive),n}sideBySideActive(){return this._sideBySideActive}supportedTools(){return["selection"]}_activateSideBySide(t){const e=t+12,n=t=>parseInt(window.getComputedStyle(t).marginLeft,10);on((()=>{document.body.style.marginLeft="",
121
- document.body.style.marginRight="";const t=n(document.body);document.body.style.marginRight=`${e}px`;const o=function(t){const e=new Map,n=new Map,o=Qe.join(","),i=Array.from(t.querySelectorAll(o)).map((t=>({rect:t.getBoundingClientRect(),textLength:t.textContent.length}))).filter((({rect:t})=>t.width>0&&t.height>0)).sort(((t,e)=>e.textLength-t.textLength)).slice(0,15);if(i.forEach((({rect:t})=>{let o=e.get(t.left)??0;o+=1,e.set(t.left,o);let i=n.get(t.right)??0;i+=1,n.set(t.right,i)})),0===e.size||0===n.size)return null;const r=[...e.entries()].sort(((t,e)=>e[1]-t[1])),s=[...n.entries()].sort(((t,e)=>e[1]-t[1])),[a]=r[0],[l]=s[0];return{left:a,right:l}}(document.body);if(o){const i=Math.max(0,window.innerWidth-e-o.right);if(i>0){const t=Math.max(0,e-i);document.body.style.marginRight=`${t}px`}n(document.body)>t&&(document.body.style.marginLeft=`${t}px`),o.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){
122
- on((()=>{document.body.style.marginLeft="",document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(t){const e=t.highlights?.[0];e&&await async function(t,{maxDuration:e=500}={}){const n=t.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{value:"BODY",configurable:!0});const o=t.closest("details");o&&!o.hasAttribute("open")&&(o.open=!0),await new Promise((n=>ri(t,{time:e},n)))}(e)}}var di,ui;var fi=function(){if(ui)return di;ui=1;var t=NaN,e="[object Symbol]",n=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,r=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof At&&At&&At.Object===Object&&At,l="object"==typeof self&&self&&self.Object===Object&&self,c=a||l||Function("return this")(),h=Object.prototype.toString,d=Math.max,u=Math.min,f=function(){return c.Date.now()};function p(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(a){if("number"==typeof a)return a
123
- ;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&h.call(t)==e}(a))return t;if(p(a)){var l="function"==typeof a.valueOf?a.valueOf():a;a=p(l)?l+"":l}if("string"!=typeof a)return 0===a?a:+a;a=a.replace(n,"");var c=i.test(a);return c||r.test(a)?s(a.slice(2),c?2:8):o.test(a)?t:+a}return di=function(t,e,n){var o,i,r,s,a,l,c=0,h=!1,_=!1,m=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function b(e){var n=o,r=i;return o=i=void 0,c=e,s=t.apply(r,n)}function y(t){var n=t-l;return void 0===l||n>=e||n<0||_&&t-c>=r}function w(){var t=f();if(y(t))return v(t);a=setTimeout(w,function(t){var n=e-(t-l);return _?u(n,r-(t-c)):n}(t))}function v(t){return a=void 0,m&&o?b(t):(o=i=void 0,s)}function x(){var t=f(),n=y(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return function(t){return c=t,a=setTimeout(w,e),h?b(t):s}(l);if(_)return a=setTimeout(w,e),b(l)}return void 0===a&&(a=setTimeout(w,e)),s}return e=g(e)||0,p(n)&&(h=!!n.leading,
124
- r=(_="maxWait"in n)?d(g(n.maxWait)||0,e):r,m="trailing"in n?!!n.trailing:m),x.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},x.flush=function(){return void 0===a?s:v(f())},x},di}(),pi=kt(fi);function gi(t,e,n,o=0){let i=o;for(;i<t.length&&e>0;)n(t[i])&&--e,++i;return i}function _i(t,e,n,o){let i=0;for(let r=n;r<o;r++)e(t[r])&&++i;return i}const mi=new Map;function bi(t,e){const n=t.normalize("NFKD");if(n===t)return{input:t,output:n};const o=[],i=[];let r=0,s=0;for(const n of t){const t=n.codePointAt(0);let a=mi.get(t);if(void 0===a&&(a=n.normalize("NFKD").length,mi.set(t,a)),e.offsets){for(let t=0;t<n.length;t++)i.push(s);s+=a}if(e.reverseOffsets){for(let t=0;t<a;t++)o.push(r);r+=n.length}}return e.offsets&&i.push(n.length),e.reverseOffsets&&o.push(r),{input:t,output:n,reverseOffsets:o,offsets:i}}function yi(t,e,n,o,i,r={}){n=Math.max(0,Math.min(n,t.length)),o=Math.max(n,Math.min(o,t.length));const s=r.normalize?bi(t,{offsets:!0}):{output:t},a=r.normalize?bi(e,{reverseOffsets:!0}):{output:e
125
- },l=s.offsets?.[n]??n,c=s.offsets?.[o]??o,h=_i(s.output,i,0,l),d=_i(s.output,i,l,c);let u=gi(a.output,h,i);for(;u<a.output.length&&!i(a.output[u]);)++u;const f=gi(a.output,d,i,u);return[a.reverseOffsets?.[u]??u,a.reverseOffsets?.[f]??f]}const wi={INITIAL:0,FINISHED:3},vi=new Map,xi=new Map;function Ci(t,e){return`${t}:${e}`}function Si(t){const e="closest"in t?t:t.parentElement;return e?.closest(".textLayer")??null}function Ai(){return PDFViewerApplication.pdfViewer}async function ki(t){const e=Ai();let n=e.getPageView(t);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{e.eventBus?e.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(e.getPageView(t))};e.eventBus?e.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function Mi(t,e){return document.elementsFromPoint(t,e).find((t=>t.classList.contains("textLayer")))}function Ri(t){const e=vi.get(t);if(e)return e;const n=(async()=>{const e=await ki(t);return(await e.pdfPage.getTextContent({
126
- normalizeWhitespace:!0})).items.map((t=>t.str)).join("")})();return vi.set(t,n),n}async function Ei(t){const e=Ai();let n=0,o=0,i="";for(let r=0;r<e.pagesCount;r++)if(i=await Ri(r),n=o,o+=i.length,o>=t)return{index:r,offset:n,text:i};return{index:e.pagesCount-1,offset:n,text:i}}function Pi(t){switch(t){case" ":case"\f":case"\n":case"\r":case"\t":case"\v":case" ":return!0;default:return!1}}const Ti=t=>!Pi(t);function Ni(t){return void 0!==t.renderingDone?t.renderingDone:!!t.div&&null!==t.div.querySelector(".endOfContent")}async function Li(t,e,n){const[o,i]=await Promise.all([ki(t),Ri(t)]);if(o.renderingState===wi.FINISHED&&o.textLayer&&Ni(o.textLayer)){const t=o.textLayer.textLayerDiv??o.textLayer.div;if(!t)throw new Error("Unable to find PDF.js text layer root");const r=t.textContent,[s,a]=yi(i,r,e,n,Ti,{normalize:!0}),l=Oi(r.slice(s,a)),c=Oi(i.slice(e,n));l.normalize("NFKD")!==c.normalize("NFKD")&&Ao("Text layer text does not match page text. Highlights will be mis-aligned.")
127
- ;const h=new Vn(t,s),d=new Vn(t,a);return new Un(h,d).toRange()}const r=function(t){let e=t.querySelector($n);return e||(e=document.createElement("span"),e.classList.add("annotator-placeholder"),e.textContent="Loading annotations...",t.appendChild(e),e)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function Oi(t){let e="";for(let n=0;n<t.length;n++){const o=t[n];Pi(o)||(e+=o)}return e}async function Ii(t){const e=t.find((t=>"TextQuoteSelector"===t.type));if(!e)throw new Error("No quote selector found");const n=t.find((t=>"TextPositionSelector"===t.type));if(n){try{const{index:t,offset:o,text:i}=await Ei(n.start),r=n.start-o,s=n.end-o,a=i.substring(r,s);if(e.exact!==a)throw new Error("quote mismatch");return await Li(t,r,s)}catch{}try{const t=Ci(e.exact,n.start),o=xi.get(t);if(o){const{pageIndex:t,anchor:e}=o;return await Li(t,e.start,e.end)}}catch{}}return async function(t,e){const n=Ai().pagesCount,o=Array(n).fill(0).map(((t,e)=>e));let i,r;if(e){
128
- const{index:t,offset:n}=await Ei(e);i=t,r=e-n,o.sort(((e,n)=>Math.abs(e-t)-Math.abs(n-t)))}const s=void 0!==t.prefix?Oi(t.prefix):void 0,a=void 0!==t.suffix?Oi(t.suffix):void 0,l=Oi(t.exact);let c;for(const t of o){const e=await Ri(t),n=Oi(e);let o;void 0!==i&&void 0!==r&&(t<i?o=n.length:t===i?[o]=yi(e,n,r,r,Ti,{normalize:!1}):o=0);const h=zo(n,l,{prefix:s,suffix:a,hint:o});if(h&&(!c||h.score>c.match.score)){const[o,i]=yi(n,e,h.start,h.end,Ti);c={page:t,match:{start:o,end:i,score:h.score}};const r=n.slice(h.start,h.end)===l,d=void 0!==s&&n.slice(Math.max(0,h.start-s.length),h.start)===s,u=void 0!==a&&n.slice(h.end,a.length)===a;if(r&&(d||u||void 0===s&&void 0===a))break}}if(c){const{page:n,match:o}=c;if(e){const i=Ci(t.exact,e);xi.set(i,{pageIndex:n,anchor:o})}return Li(n,o.start,o.end)}throw new Error("Quote not found")}(e,n?.start)}async function Bi(t){const e=t.find((t=>"PageSelector"===t.type)),n=t.find((t=>"ShapeSelector"===t.type));if(n){
129
- if(!e)throw new Error("Cannot anchor a shape selector without a page");return async function(t,e){const n=Ai();if("number"!=typeof t.index||t.index<0||t.index>=n.pagesCount)throw new Error("PDF page index is invalid");const o=await ki(t.index),i=o.div,r=o.viewport,s=t=>function(t,e,n){return Math.max(Math.min(t,n),e)}(t,0,1);let a;switch(e.shape.type){case"rect":{const t=e.shape;let[n,o]=r.convertToViewportPoint(t.left,t.top),[i,l]=r.convertToViewportPoint(t.right,t.bottom);i<n&&([n,i]=[i,n]),l<o&&([o,l]=[l,o]),a={type:"rect",left:s(n/r.width),top:s(o/r.height),right:s(i/r.width),bottom:s(l/r.height)}}break;case"point":{const t=e.shape,[n,i]=o.viewport.convertToViewportPoint(t.x,t.y);a={type:"point",x:s(n/r.width),y:s(i/r.height)}}break;default:throw new Error("Unsupported shape in shape selector")}return{anchor:i,shape:a,coordinates:"anchor"}}(e,n)}return Ii(t)}function Di(t){try{t=Un.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}
130
- const e=Si(t.startContainer),n=Si(t.endContainer);if(!e||!n)throw new Error("Selection is outside page text");if(e!==n)throw new Error("Selecting across page breaks is not supported");return[t,e]}function Fi(t){const e=t.closest(".page"),n=parseInt(e?.getAttribute("data-page-number")??"");if(!Number.isInteger(n))throw new Error("Unable to get page number from element");return n-1}async function Hi(t){const[e,n]=Di(t),o=Vn.fromPoint(e.startContainer,e.startOffset).relativeTo(n),i=Vn.fromPoint(e.endContainer,e.endOffset).relativeTo(n),r=Fi(n),s=await async function(t){if(t>=Ai().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await Ri(n)).length;return e}(r),a=await ki(r);return[{type:"TextPositionSelector",start:s+o.offset,end:s+i.offset},Ko.fromRange(a.div,e).toSelector(),Vi(a,r)]}async function zi(t,e){const n=document.elementsFromPoint(t,e);for(const o of n){if(!o.classList.contains("page"))continue
131
- ;const n=Fi(o),i=getComputedStyle(o),r=parseFloat(i.borderLeftWidth),s=parseFloat(i.borderTopWidth),a=o.getBoundingClientRect(),l=t-a.left-r,c=e-a.top-s,h=await ki(n),[d,u]=h.getPagePoint(l,c);return{pageIndex:n,x:d,y:u}}return null}function Vi(t,e){return{type:"PageSelector",index:e,label:t.pageLabel??`${e+1}`}}async function Ui(t){const e=t=>{const[e,n,o,i]=t.view;return{left:e,top:i,right:o,bottom:n}},n=(t,e)=>function(t,e){const n=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),o=[];let i,r;for(;r=n.nextNode();){const t=r,n=t.data.split(/\b/);let s=0;for(const r of n){const n=new Range;n.setStart(t,s);const a=s+r.length;n.setEnd(t,a);const l=n.getBoundingClientRect();$e(l,e)&&(i&&!qe(i,l)&&o.push(" "),o.push(r),i=l),s=a}}return o.join("")}(t,e).slice(0,256);switch(t.type){case"rect":{const[o,i]=await Promise.all([zi(t.left,t.top),zi(t.right,t.bottom)]);if(!o)throw new Error("Top-left point is not in a page");if(!i)throw new Error("Bottom-right point is not in a page")
132
- ;if(o.pageIndex!==i.pageIndex)throw new Error("Shape must start and end on same page");const r=await ki(o.pageIndex),s={type:"rect",left:o.x,top:o.y,right:i.x,bottom:i.y},a=Mi(t.left,t.top);let l;if(a){l=n(a,new DOMRect(t.left,t.top,t.right-t.left,t.bottom-t.top))}return[Vi(r,o.pageIndex),{type:"ShapeSelector",anchor:"page",shape:s,view:e(r.pdfPage),text:l}]}case"point":{const o=await zi(t.x,t.y);if(!o)throw new Error("Point is not in a page");const i=Mi(t.x,t.y);let r;if(i){r=n(i,new DOMRect(t.x,t.y,1,1))}const s=await ki(o.pageIndex);return[Vi(s,o.pageIndex),{type:"ShapeSelector",anchor:"page",shape:{type:"point",x:o.x,y:o.y},text:r,view:e(s.pdfPage)}]}default:throw new Error("Unsupported shape")}}function $i({children:t}){return St("div",{className:"flex flex-col",children:t})}function qi({info:t}){let e=t.item.title;return t.item.subtitle&&(e+=`: ${t.item.subtitle}`),St("div",{
133
- className:Tt("h-10 bg-white px-4 text-slate-7 text-annotator-base border-b","grid items-center","grid-cols-[100px_minmax(0,auto)]","2xl:grid-cols-[100px_minmax(0,auto)_minmax(0,auto)] 2xl:gap-x-3"),children:[St("div",{"data-testid":"content-logo",children:t.logo&&St(we,{href:t.logo.link,target:"_blank","data-testid":"logo-link",underline:"none",children:St("img",{alt:t.logo.title,src:t.logo.logo,"data-testid":"logo-image"})})}),St("div",{className:Tt("hidden","2xl:block 2xl:whitespace-nowrap 2xl:overflow-hidden 2xl:text-ellipsis","font-semibold"),"data-testid":"content-container-info",title:t.container.title,children:t.container.title}),St("div",{className:Tt("flex justify-center items-center gap-x-2"),"data-testid":"content-item-info",children:[St("div",{className:Tt("hidden","2xl:block 2xl:grow")}),t.links.previousItem&&St(y,{children:[St(we,{title:"Open previous item",href:t.links.previousItem,underline:"always",target:"_blank","data-testid":"content-previous-link",children:St("div",{
134
- className:"flex gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[St(Dt,{className:"w-em h-em"}),St("span",{children:"Previous"})]})}),St("div",{className:"text-annotator-sm",children:"|"})]}),St("div",{className:Tt("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis shrink font-medium"),children:St(we,{title:e,href:t.links.currentItem,"data-testid":"content-item-link",target:"_blank",unstyled:!0,children:e})}),t.links.nextItem&&St(y,{children:[St("div",{className:"text-annotator-sm",children:"|"}),St(we,{title:"Open next item",href:t.links.nextItem,underline:"always",target:"_blank","data-testid":"content-next-link",children:St("div",{className:"flex gap gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[St("span",{children:"Next"}),St(Ft,{className:"w-em h-em"})]})})]})]})]})}function Wi(){return St("div",{className:"bg-white",role:"alert",children:St("div",{
135
- className:Tt("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[St("div",{className:"bg-yellow-notice text-white p-2",children:St(Ht,{className:"text-annotator-xl"})}),St("div",{children:[St("strong",{children:"Text annotation tools are unavailable because this PDF does not contain selectable text."})," ",St(we,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",underline:"always",children:"Learn more here"}),"."]})]})})}class ji{constructor(t){this._loaded=function(t){return t.initializedPromise?t.initializedPromise:t.initialized?Promise.resolve():new Promise((e=>{const n=setInterval((()=>{t.initialized&&(clearTimeout(n),e())}),5)}))}(t).then((async()=>{const e=await async function(t){return void 0!==t.downloadComplete?t.downloadComplete:(await t.pdfDocument.getDownloadInfo(),!0)}(t);return e?t:new Promise((e=>{const n=()=>{t.eventBus?(t.eventBus.off("documentload",n),
136
- t.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),e(t)};t.eventBus?(t.eventBus.on("documentloaded",n),t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))}))}getUri(){return this._loaded.then((t=>{let e=Yi(t);return e||(e=Xi(Ki(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:o}=await t.pdfDocument.getMetadata(),i=Ki(t),r=Yi(t),s=o?.get("dc:title");let a;a=s&&"Untitled"!==s?s:e?.Title?e.Title:n||(r?function(t){const e=new URL(t),n=e.pathname.split("/");return n[n.length-1]}(r):"");const l=[{href:Xi(i)}];return r&&l.push({href:r}),{title:a,link:l,documentFingerprint:i}}}function Ki(t){return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function Xi(t){return`urn:x-pdf:${t}`}function Yi(t){if(!t.url)return null;const e=li(t.url);return 0!==e.indexOf("file://")?e:null}function Gi(t){const e=t.highlights?.[0];return e&&qn(e)}function Qi(t){
137
- return new Promise((e=>setTimeout(e,t)))}class Ji{constructor(){this._pdfjsContainer=document.querySelector("#outerContainer"),this._contentInfo=null,this._noTextWarning=!1,this._container=null}setContentInfo(t){this._contentInfo=t,this._update()}showNoTextWarning(t){this._noTextWarning=t,this._update()}destroy(){this._container?.destroy()}_update(){if(!(this._noTextWarning||this._contentInfo))return this._container?.destroy(),this._container=null,void(this._pdfjsContainer.style.height="");this._container||(this._container=new Pn("banner",(()=>this._render())),document.body.prepend(this._container.element)),this._container.render();const t=this._container.element.getBoundingClientRect().height;this._pdfjsContainer.style.height=`calc(100% - ${t}px)`}_render(){return St($i,{children:[this._contentInfo&&St(qi,{info:this._contentInfo}),this._noTextWarning&&St(Wi,{})]})}}class Zi extends Me{constructor({annotator:t,features:e,reanchoringMaxWait:n}){super(),this._annotator=t;const o=window,i=o.PDFViewerApplication
138
- ;this._pdfViewer=i.pdfViewer,this._pdfViewer.viewer.classList.add("has-transparent-text-layer"),this._pdfContainer=i.appConfig?.appContainer??document.body,this._pdfMetadata=new ji(i),this._observer=new MutationObserver(pi((()=>this._update()),100)),this._observer.observe(this._pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=n??3e3,this._banner=new Ji,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const t=o.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new mt,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1,this._features=e,this._features.on("flagsChanged",(()=>{this.emit("supportedToolsChanged",this.supportedTools())})),this._pdfViewer.viewer.addEventListener("click",(t=>{const e=t.target;e instanceof HTMLAnchorElement&&(e.target="blank")
139
- ;oo(t.clientX,t.clientY).length>0&&t.preventDefault()}))}destroy(){this.fitSideBySide({expanded:!1,width:0,toolbarWidth:0,height:window.innerHeight}),this._listeners.removeAll(),this._pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this._observer.disconnect(),this._banner.destroy(),this._destroyed=!0,super.destroy()}uri(){return this._pdfMetadata.getUri()}getMetadata(){return this._pdfMetadata.getMetadata()}showContentInfo(t){this._banner.setContentInfo(t)}anchor(t,e){return Bi(e)}getAnnotatableRange(t){try{const e=Un.trimmedRange(t);if(function(t){try{return Di(t),!0}catch{return!1}}(e))return e}catch(t){if(!(t instanceof RangeError))throw t}return null}canStyleClusteredHighlights(){return!0}describe(t,e){return e instanceof Range?Hi(e):Ui(e)}async _checkForSelectableText(){try{await this.uri()}catch{return}if(!this._destroyed)try{const t=await async function(){const t=Ai();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await Ri(n)).trim().length>0){e=!0;break}return e}()
140
- ;this._banner.showNoTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_update(){const t=[],e=this._pdfViewer.pagesCount;for(let t=0;t<e;t++){const e=this._pdfViewer.getPageView(t);if(e?.textLayer&&Ni(e.textLayer))switch(e.renderingState){case wi.INITIAL:e.textLayer=null;break;case wi.FINISHED:n=e.div,n.querySelector($n)?.remove()}}var n;for(const e of this._annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const o=e.highlights[n];if(!document.body.contains(o)){e.highlights.splice(n,1),delete e.region,t.push(e.annotation);break}}}t.map((t=>this._annotator.anchor(t)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(t){const e=window.innerWidth-t.width,n=t.expanded&&e>=680,o=n?t.width:t.toolbarWidth;this._pdfContainer.style.width=`calc(100% - ${o}px)`;const i=this._pdfViewer.currentScaleValue;return"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(this._pdfViewer.currentScaleValue=i),
141
- this._pdfViewer.update(),this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}supportedTools(){const t=this._features?.flagEnabled("pdf_image_annotation");return t?["selection","rect","point"]:["selection"]}async scrollToAnchor(t){const e=t.annotation,n=Gi(t),o=this._anchorOffset(t);if(null!==o&&(await ai(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await ai(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){const n=Date.now();let o;do{o=this._annotator.anchors.find((e=>e.annotation===t)),o&&!Gi(o)||(o=null,await Qi(20))}while(!o&&Date.now()-n<e);return o??null}_anchorOffset(t){if(!t.highlights)return null;const e=t.highlights[0];return function(t,e,n={}){let o=0,i=e;for(;i!==t&&t.contains(i);)o+=i.offsetTop,i=i.offsetParent;if("center"===n.position){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect();o-=n.height/2-i.height/2}return o
142
- }(this.contentContainer(),e,{position:"center"})}async renderToBitmap(t,e){const n=t.target.selector?.find((t=>"ShapeSelector"===t.type)),o=t.target.selector?.find((t=>"PageSelector"===t.type));if(!o||!n)throw new Error("Can only render bitmaps for anchors with shapes");const i=this._pdfViewer.getPageView(o.index);if(!i)throw new Error("Failed to get page view");let r,s,a,l;switch(n.shape.type){case"rect":({left:r,right:s,top:a,bottom:l}=n.shape);break;case"point":{const{x:t,y:e}=n.shape,[o,,c]=i.pdfPage.view,h=.1*Math.abs(c-o);r=t-h,a=e+h,s=t+h,l=e-h}break;default:throw new Error("Unsupported shape type")}s<r&&([r,s]=[s,r]),s=Math.max(s,r+1),a<l&&([a,l]=[l,a]),a=Math.max(a,l+1);const c=i.pdfPage.rotate%360;if(c%90!=0)throw new Error("Page rotation is not a multiple of 90 degrees");let h,d;0===c||180===c?(h=Math.abs(s-r),d=Math.abs(l-a)):(h=Math.abs(l-a),d=Math.abs(s-r));const u=96/72,f=e.devicePixelRatio??1,p=h*u*f,g=h/d,_="number"==typeof e.maxWidth?Math.min(e.maxWidth,p):p,m=_/g,b=i.pdfPage.getViewport({
143
- scale:1}),y=_/p*u*f,w=new(0,b.constructor)({rotation:c,scale:y,userUnit:b.userUnit,viewBox:[r,l,s,a]}),v=Math.max(_,1),x=Math.max(m,1),C=new OffscreenCanvas(v,x),S=C.getContext("2d"),A=i.pdfPage.render({canvasContext:S,viewport:w});if(await A.promise,"point"===n.shape.type){S.save(),S.scale(y,y);const t=n.shape.x-r,e=n.shape.y-l,o=5;S.strokeStyle="black",S.fillStyle="yellow",S.beginPath(),S.arc(t,e,o,0,2*Math.PI),S.fill(),S.stroke(),S.restore()}return C.transferToImageBitmap()}}function tr(t){if(!t.includes("["))return t;let e="",n=!1,o=!1;for(const i of t)n||"^"!==i?(n||"["!==i?!n&&o&&"]"===i?o=!1:o||(e+=i):o=!0,n=!1):n=!0;return e}function er(t){const e=tr(t),n=e.indexOf("!");return-1===n?e:e.slice(0,n)}class nr{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(pi((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,
144
- subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(t){this._annotatableFrames.add(t);try{if(await or(t),this._isDisconnected)return;t.contentWindow.addEventListener("unload",(()=>{this._removeFrame(t)})),this._onFrameAdded(t)}catch{console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${t.src}')`)}}_removeFrame(t){this._annotatableFrames.delete(t),this._onFrameRemoved(t)}_discoverFrames(){const t=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const e of t)this._annotatableFrames.has(e)||this._addFrame(e);for(const e of this._annotatableFrames)t.has(e)||this._removeFrame(e)}}function or(t){return new Promise(((e,n)=>{const o=ir(t,((t,i)=>{o(),i?e(i):n(t)}))}))}function ir(t,e,{pollInterval:n=10}={}){let o,i;const r=new WeakSet,s=()=>{clearTimeout(o),o=void 0},a=()=>{const n=t.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),
145
- !function(t){return"about:blank"===t.contentDocument?.location.href&&t.hasAttribute("src")&&"about:blank"!==t.src}(t)){"interactive"===n.readyState||"complete"===n.readyState?e(null,n):n.addEventListener("DOMContentLoaded",(()=>e(null,n)))}t.contentDocument&&t.contentWindow?.addEventListener("unload",i)}}else{s();const n=t.isConnected?"Frame is cross-origin":"Frame is disconnected";e(new Error(n))}};let l=!1;i=()=>{s(),l||(o=setInterval(a,n))},t.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),t.removeEventListener("load",a)}}class rr{constructor(t,e){this._config=e,this._frameObserver=new nr(t,(t=>sr(t,e)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function sr(t,e,n){if(null!==t.contentDocument.querySelector("script.js-hypothesis-config"))return;await or(t);const{assetRoot:o,notebookAppUrl:i,profileAppUrl:r,sidebarAppUrl:s}=He(document),a={...e,assetRoot:o,notebookAppUrl:i,profileAppUrl:r,sidebarAppUrl:s,subFrameIdentifier:n??Ce(10)
146
- },l=document.createElement("script");l.className="js-hypothesis-config",l.setAttribute("data-remove-on-unload",""),l.type="application/json",l.innerText=JSON.stringify(a);const c=document.createElement("script");c.async=!0,c.src=e.clientUrl;const h=t.contentDocument;h.body.appendChild(l),h.body.appendChild(c)}class ar{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length");const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.color="transparent",i.style.textAlign="left",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font=`16px ${r}`;const a=(t,e,n="px")=>`calc(var(--${t}-scale) * ${e}${n})`,l=function(t,e){const n=[];let o={text:"",rect:new DOMRect};const i=()=>{o.text.length>0&&(n.push(o),o={text:"",
147
- rect:new DOMRect})};for(const[n,r]of t.entries()){const t=e[n],s=/\s/.test(t);o.text.length>0&&!qe(o.rect,r)&&i(),o.rect=je(o.rect,r),o.text+=s?" ":t,s&&i()}i();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(const t of n){const e=s.words[s.words.length-1];if(e){const n=Ke(e.rect),o=Ke(t.rect).x-n.x;(!qe(e.rect,t.rect)||o<0)&&a()}s.words.push(t),s.rect=je(s.rect,t.rect)}a();const l=[];let c={lines:[],rect:new DOMRect};const h=()=>{c.lines.length>0&&(l.push(c),c={lines:[],rect:new DOMRect})};for(const t of r){const e=c.lines[c.lines.length-1];if(e){const n=Ke(e.rect),o=Ke(t.rect).y-n.y;(!We(e.rect,t.rect)||qe(e.rect,t.rect)||o<0||o>4*t.rect.height)&&h()}c.lines.push(t),c.rect=je(c.rect,t.rect)}return h(),l}(e,n);for(const t of l){const e=document.createElement("hypothesis-text-column");e.style.display="block",e.style.position="absolute",e.style.left=a("x",t.rect.left),e.style.top=a("y",t.rect.top);let n=null;for(const o of t.lines){
148
- const i=document.createElement("hypothesis-text-line");i.style.display="block",i.style.marginLeft=a("x",o.rect.left-t.rect.left),i.style.height=a("y",o.rect.height),n&&(i.style.marginTop=a("y",o.rect.top-n.rect.bottom)),n=o,i.style.whiteSpace="nowrap";let r=null;for(const t of o.words){const e=document.createElement("hypothesis-text-word");e.style.display="inline-block",e.style.transformOrigin="top left",e.textContent=t.text,r&&(e.style.marginLeft=a("x",t.rect.left-r.rect.right)),r=t,e.style.width=a("x",t.rect.width),e.style.height=a("y",t.rect.height),e.style.whiteSpace="pre";const n=s.measureText(t.text),o=a("x",t.rect.width/n.width,""),l=a("y",t.rect.height/16,"");e.style.transform=`scale(${o}, ${l})`,i.append(e)}e.append(i)}i.append(e)}const c=()=>{const{width:e,height:n}=t.getBoundingClientRect();i.style.width=e+"px",i.style.height=n+"px",i.style.setProperty("--x-scale",`${e}`),i.style.setProperty("--y-scale",`${n}`)};c(),this.container=i,this._updateTextLayerSize=pi(c,{maxWait:50}),
149
- this._listeners=new mt,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(t)),this._listeners.add(window,"resize",this._updateTextLayerSize)}updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),this._imageSizeObserver?.disconnect()}}function lr(t=document){return t.querySelector("mosaic-book")}function cr(t=window){if(lr(t.document))return"container";const e=t.frameElement?.ownerDocument;return e&&lr(e)?"content":null}class hr{constructor(t){const e=lr();if(!e)throw new Error("Book container element not found");const n=new WeakSet,o=e.shadowRoot,i=()=>{const e=o.querySelector("iframe");e&&!n.has(e)&&(n.add(e),ir(e,((n,o)=>{if(n)return;const i=o.body;i&&!i.querySelector("#page-content")&&sr(e,t,"vitalsource-content")})))};i(),this._frameObserver=new MutationObserver(i),
150
- this._frameObserver.observe(o,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function dr(){return document.querySelector("img#pbk-page")}class ur extends Me{constructor(t=document.body,e={}){super();const n=e.bookElement??lr(window.parent.document);if(!n)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=n;const o=new Mo;this._htmlIntegration=new hi({container:t,features:o}),this._listeners=new mt;const i=["mouseup","mousedown","mouseout"];for(const t of i)this._listeners.add(document.documentElement,t,(t=>{t.stopPropagation()}));const r=window.frameElement;r&&function(t){if("no"!==t.getAttribute("scrolling"))return;const e=document.createElement("style");e.textContent="iframe { height: 100% !important; }",t.insertAdjacentElement("beforebegin",e);const n=()=>t.removeAttribute("scrolling");n(),new MutationObserver(n).observe(t,{attributes:!0})}(r);const s=dr(),a=window.innerPageData;if(s&&a){const t=a.glyphs.glyphs.map((t=>{
151
- const e=t.l/100,n=t.r/100,o=t.t/100,i=t.b/100;return new DOMRect(e,o,n-e,i-o)}));this._textLayer=new ar(s,t,a.words),this._textLayer.container.style.zIndex="100",this._sideBySideActive=!1}}getAnnotatableRange(t){return this._htmlIntegration.getAnnotatableRange(t)}destroy(){this._textLayer&&(this._textLayer.destroy(),this.fitSideBySide({expanded:!1,height:window.innerHeight,width:0,toolbarWidth:0})),this._listeners.removeAll(),this._htmlIntegration.destroy(),super.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}async describe(t,e){const n=this._htmlIntegration.describe(t,e),{cfi:o,index:i,page:r,title:s,url:a}=await this._getPageInfo({includeTitle:!0,includePageIndex:!0}),l=[{type:"EPUBContentSelector",cfi:o,url:a,title:s}];if("number"==typeof i){const t={type:"PageSelector",index:i,label:r};l.push(t)}return n.push(...l),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(t){const e=dr();if(e&&this._textLayer){
152
- const n=e.parentElement,o=this._textLayer,i=window.innerWidth-t.width;return this._sideBySideActive=!1,on((()=>{t.expanded&&i>480?(n.style.textAlign="left",e.style.width=`${i}px`,this._sideBySideActive=!0):(n.style.textAlign="",e.style.width=""),o.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(t)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}supportedTools(){return["selection"]}async getMetadata(){return{title:this._bookElement.getBookInfo().title,link:[]}}navigateToSegment(t){const e=t.target[0].selector?.find((t=>"EPUBContentSelector"===t.type));if(e?.cfi)this._bookElement.goToCfi(e.cfi);else{if(!e?.url)throw new Error("No segment information available");this._bookElement.goToURL(function(t){const e=new URL(t,document.baseURI);return e.pathname+e.search}(e.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:t=!1,includePageIndex:e=!1}={}){
153
- const[n,o,i]=await Promise.all([this._bookElement.getCurrentPage(),t?this._bookElement.getTOC():void 0,e?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const t of r)if(!(t in n))throw new Error(`Page metadata field "${t}" is missing`);let s;if(o){s=n.chapterTitle;const t=er(n.cfi),e=o.data?.find((e=>er(e.cfi)===t));e&&(s=e.title)}let a=n.index;if(void 0===a&&i){const t=i.data?.findIndex((t=>t.cfi===n.cfi));-1!==t&&(a=t)}return{cfi:n.cfi,index:a,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(t){let e=[];try{const t=await this._bookElement.getPageBreaks();t.ok&&t.data&&(e=t.data)}catch(t){console.error("Failed to get page breaks",t)}const n=tr(t),o=e.filter((t=>t.cfiWithoutAssertions.split("!")[0]===n));let i;if(o.length>0){i={start:o[0].label,end:o[o.length-1].label}}return i}async segmentInfo(){const{cfi:t,url:e}=await this._getPageInfo();return{cfi:t,pages:await this._getPageRange(t),url:e}}async uri(){
154
- const t=this._bookElement.getBookInfo().isbn;if(!t)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${t}`}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function fr(t){if(void 0!==window.PDFViewerApplication)return new Zi({annotator:t,features:t.features});return"content"===cr()?new ur(document.body):new hi({features:t.features,sideBySideOptions:t.sideBySide})}function pr(){return St(_e,{classes:"fixed left-[10px] top-[10px]","data-testid":"outside-assignment-notice",status:"notice",variant:"raised",children:"You are outside the page range for this assignment. Annotations made here may not be counted."})}class gr{constructor(t){this._visible=!1,this._container=new Pn("notice",(()=>this._render())),t.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(t){this._visible=t,this._container.render()}_render(){return this._visible?St(pr,{}):null}}class _r{constructor(t,e=document){let n=!1
155
- ;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(jn(e.getSelection()))}),n)},i=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;o(e)};this._document=e,this._listeners=new mt,this._listeners.add(e,"selectionchange",i),this._listeners.add(e.body,"mousedown",i),this._listeners.add(e.body,"mouseup",i),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),this._pendingCallback=null)}}function mr(t,e){if(t===e)return!0;if(t.parent!==e)return!1;if(!t.frameElement)return!1;return t.frameElement.getBoundingClientRect().width/t.parent.innerWidth>=.8}function br(){return function(t,e){const n=new Set,o=new Set;return Yn(t,(t=>{for(;t&&!n.has(t);){n.add(t);const i=e(t);null!=i&&o.add(i),t=t.parentNode}})),[...o]}(jn()??new Range,(t=>t._annotation?.$tag))}function yr(t,e,n){
156
- return t.getHighlightsFromPoint(e,n).map((t=>t._annotation?.$tag)).filter((t=>void 0!==t))}function wr(t){if(!t.region)return null;if(!function(t){return void 0!==t&&"toRange"in t&&"function"==typeof t.toRange}(t.region))return t.region;try{return t.region.toRange()}catch{return null}}function vr(){document.getSelection()?.removeAllRanges()}class xr extends CustomEvent{constructor(t){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:t}),this._ready=null}get ready(){return this._ready}waitUntil(t){this._ready=t}}class Cr extends Me{constructor(t,e={},n=window){super(),this.element=t,this._contentReady=e.contentReady,this._commentsMode=e.commentsMode??!1,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._highlighter=new Zn(this.element),this._adder=new Ln(this.element,{onAnnotate:()=>this.createAnnotationFromSelection(),onHighlight:()=>this.createAnnotationFromSelection({highlight:!0}),
157
- onShowAnnotations:t=>this.selectAnnotations(t,{focusInSidebar:!0})}),this._drawTool=new xo(this.element),this._drawTool.setOnKeyboardModeChange((t=>{this._hostRPC.call("keyboardModeChanged",t)})),this._setupGlobalKeyboardListener(),this._selectionObserver=new _r((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new ke({hostFrame:this._hostFrame,source:"guest",sourceId:this._frameIdentifier??void 0}),this.features=new Mo,this._featureFlagsReceived=new Promise((t=>{this.features.on("flagsChanged",t)})),this.sideBySide=e.sideBySide,this._integration=fr(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),e.contentInfoBanner&&this._integration.showContentInfo?.(e.contentInfoBanner),this._integration.canStyleClusteredHighlights?.()&&(this._clusterToolbar=new No(this._integration.contentContainer(),{features:this.features})),
158
- this._integration.on("supportedToolsChanged",(()=>this._notifySupportedToolsChanged())),this._hostRPC=new De,this._connectHost(n),this._sidebarRPC=new De,this._sidebarLayout=null,this._connectSidebar(),this._bucketBarClient=new ho({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new mt,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){return"manual"===this.sideBySide?.mode&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(t=>{if(!document.getSelection()?.isCollapsed)return;const{clientX:e,clientY:n,metaKey:o,ctrlKey:i}=t,r=yr(this._highlighter,e,n);if(r.length){const t=o||i;this.selectAnnotations(r,{toggle:t})}})),this._listeners.add(this.element,"pointerdown",(t=>{
159
- this._sideBySideActive()||t.composedPath().some((t=>t instanceof Element&&t.localName.startsWith("hypothesis-")))||yr(this._highlighter,t.clientX,t.clientY).length||mr(window,this._hostFrame)&&this._sidebarLayout?.expanded&&window.innerWidth-t.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),this._listeners.add(this.element,"mouseover",(({clientX:t,clientY:e})=>{const n=yr(this._highlighter,t,e);n.length&&this._sidebarRPC.call("hoverAnnotations",n)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(t=>{this._handleShortcut(t)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){const[t,e,n]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),this._integration.segmentInfo?.()]);return{uri:li(t),metadata:e,segmentInfo:n,persistent:this._integration.persistFrame?.()??!1}}async _sendDocumentInfo(){
160
- this._integration.waitForFeatureFlags?.()&&await this._featureFlagsReceived;const t=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",t)}_repositionAdder(){if(!this._isAdderVisible)return;const t=jn();t&&this._onSelection(t)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{jn()&&(this._informHostOnNextSelectionClear=!1,vr())})),this._hostRPC.on("createAnnotation",(({tool:t})=>t?("rect"===t&&void 0===this._pendingKeyboardMode&&(this._pendingKeyboardMode="move"),this.createAnnotation(t)):(this._drawTool.cancel(),null))),this._hostRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._hostRPC.on("scrollToAnnotation",(t=>{this._scrollToAnnotation(t)})),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e}))),this._hostRPC.on("setKeyboardMode",(({mode:t})=>{["move","resize","rect"].includes(t)&&this._drawTool.setKeyboardMode(t)})),this._hostRPC.on("activateMoveMode",(()=>{this._activateToolWithMoveMode("rect")})),
161
- this._hostRPC.on("activatePointMoveMode",(()=>{this._activateToolWithMoveMode("point")})),this._hostRPC.on("sidebarLayoutChanged",(e=>{mr(window,t)&&this.fitSideBySide(e),this.element.dispatchEvent(new Co({sidebarLayout:e,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected"))),this._notifySupportedToolsChanged();const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}_notifySupportedToolsChanged(){this._hostRPC.call("supportedToolsChanged",this._integration.supportedTools())}async _scrollToAnchor(t){const e=wr(t);if(!e)return;let n;e instanceof Range?n=e:(n=new Range,n.selectNodeContents(e.anchor));const o=new xr(n);this.element.dispatchEvent(o)&&(await o.ready,await this._integration.scrollToAnchor(t))}async _scrollToAnnotation(t){const e=this.anchors.find((e=>e.annotation.$tag===t));e?.highlights&&await this._scrollToAnchor(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),
162
- this._sidebarRPC.on("shortcutsUpdated",(t=>{wn(t)})),this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{this._scrollToAnnotation(t)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("getDocumentInfo",(async t=>t(await this.getDocumentInfo()))),this._sidebarRPC.on("loadAnnotations",(async t=>{try{await Promise.all(t.map((t=>this.anchor(t))))}catch(t){console.warn("Failed to anchor annotations:",t)}})),this._sidebarRPC.on("showContentInfo",(t=>this._integration.showContentInfo?.(t))),this._sidebarRPC.on("setOutsideAssignmentNoticeVisible",(t=>{this._setOutsideAssignmentNoticeVisible(t)})),this._sidebarRPC.on("navigateToSegment",(t=>this._integration.navigateToSegment?.(t))),this._sidebarRPC.on("renderThumbnail",((t,e,n)=>{(async()=>{
163
- if(!this._integration.renderToBitmap)throw new Error("Thumbnail rendering not supported for document type");const n=this.anchors.find((e=>e.annotation.$tag===t));if(!n)throw new Error("Annotation not anchored in guest");return this._integration.renderToBitmap(n,e)})().then((t=>n({ok:!0,value:t}))).catch((t=>n({ok:!1,error:t.message})))})),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this._sendDocumentInfo()}destroy(){this._drawTool.destroy(),this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),this._clusterToolbar?.destroy(),this._outsideAssignmentNotice?.destroy(),this._highlighter.removeAllHighlights(),this._integration.destroy(),this._globalKeyboardListenerCleanup?.(),super.destroy()}_isKeyboardAnnotationModeEnabled(){return this.features.flagEnabled("vpat_keyboard")}_setupGlobalKeyboardListener(){const t=t=>{if(Ge(t.target))return
164
- ;if(!this._isKeyboardAnnotationModeEnabled())return;const e=yn(),n=this._integration.supportedTools(),o=n.includes("rect"),i=n.includes("point"),r=e.activateRectMove;if(r&&un(t,r)&&o){t.preventDefault(),t.stopPropagation();return void(this._drawTool.getKeyboardModeState().keyboardActive?this._drawTool.setKeyboardMode("move"):(this._pendingKeyboardMode="move",this.createAnnotation("rect").catch((()=>{this._pendingKeyboardMode=void 0}))))}const s=e.activateRectResize;if(s&&un(t,s)&&o){t.preventDefault(),t.stopPropagation();return void(this._drawTool.getKeyboardModeState().keyboardActive?this._drawTool.setKeyboardMode("resize"):(this._pendingKeyboardMode="resize",this.createAnnotation("rect").catch((()=>{this._pendingKeyboardMode=void 0}))))}const a=e.activatePoint;if(a&&un(t,a)&&i){t.preventDefault(),t.stopPropagation();this._drawTool.getKeyboardModeState().keyboardActive||(this._pendingKeyboardMode="move",this.createAnnotation("point").catch((()=>{this._pendingKeyboardMode=void 0})))}else;}
165
- ;document.body.addEventListener("keydown",t),this._globalKeyboardListenerCleanup=()=>{document.body.removeEventListener("keydown",t)}}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{const e=wr(t);if(!e)return;let n;n=e instanceof Range?this._highlighter.highlightRange(e,t.annotation?.$cluster):this._highlighter.highlightShape(e),n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._hoveredAnnotations.has(t.annotation.$tag)&&this._highlighter.setHighlightsFocused(n,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type||"ShapeSelector"===t.type)))return{annotation:t,target:e};let n;try{const o=await this._integration.anchor(this.element,e.selector);if(o instanceof Range){const i=Un.fromRange(o);n={annotation:t,target:e,region:i}}else n={annotation:t,target:e,region:o}}catch{n={annotation:t,target:e}}
166
- return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.region)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&this._highlighter.removeHighlights(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,this._clusterToolbar?.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation(t){if("selection"===t)return this.createAnnotationFromSelection();if(!["rect","point"].includes(t))throw new Error("Unsupported annotation tool");{let e=!1;try{this._hostRPC.call("activeToolChanged",t);const e=this._pendingKeyboardMode;this._pendingKeyboardMode=void 0;const n=await this._drawTool.draw(t,e),o=await this.getDocumentInfo(),i=[{source:o.uri,selector:await this._integration.describe(this.element,n)}],r={
167
- uri:o.uri,document:o.metadata,target:i,$tag:"a:"+Ce(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),r}catch(t){if(t instanceof vo&&["canceled","restarted"].includes(t.kind))return e="restarted"===t.kind,null;throw t}finally{e||this._hostRPC.call("activeToolChanged",null)}}}_activateToolWithMoveMode(t){this._drawTool.getKeyboardModeState().keyboardActive?this._drawTool.setKeyboardMode("move"):(this._pendingKeyboardMode="move",this.createAnnotation(t).catch((()=>{this._pendingKeyboardMode=void 0})))}async createAnnotationFromSelection({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(e.map((t=>this._integration.describe(o,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+Ce(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),vr(),r}_hoverAnnotations(t){
168
- this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);this._highlighter.setHighlightsFocused(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),o=Kn(n),i=Gn(n);i?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._commentsMode||(this._adder.annotationsForSelection=br(),this._isAdderVisible=!0,this._adder.show(i,o))):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}
169
- setHighlightsVisible(t,e=!0){this._highlighter.setHighlightsVisible(t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){const e=yn().toggleHighlights;e&&un(t,e)&&this.setHighlightsVisible(!this._highlightsVisible&&!this._commentsMode)}_setOutsideAssignmentNoticeVisible(t){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new gr(this.element)),this._outsideAssignmentNotice.setVisible(t)}}function Sr(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function Ar(t,e){const n={};for(const[t,o]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=o&&(n[t]=o);n.origin=new URL(t).origin,n.version="1.1748.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),
170
- Array.isArray(n.services)&&n.services?.length>0){const t=n.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return n}function kr({closed:t,onClose:e,children:n,className:o,"data-testid":i,"aria-label":r}){const s=it(null);return nt((()=>{t?s.current?.close():s.current?.showModal()}),[t]),nt((()=>{const t=s.current;return t?.addEventListener("cancel",e),()=>{t?.removeEventListener("cancel",e)}}),[e]),St("dialog",{ref:s,className:Tt("relative m-5 w-full h-full backdrop:bg-black/50",o),"data-testid":i,"aria-label":r,children:n})}function Mr({closed:t,children:e,className:n,...o}){return St("div",{...o,className:Tt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:t}),children:St("div",{className:Tt("relative w-full h-full",n),children:e})})}function Rr({document_:t=document,...e}){
171
- return St(rt((()=>function(t){return"function"==typeof t.createElement("dialog").showModal}(t)?kr:Mr),[t]),{...e})}function Er({config:t,groupId:e}){return St("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Sr(t.notebookAppUrl,{...Ar(t.notebookAppUrl,t),group:e})})}function Pr({eventBus:t,config:e}){const[n,o]=et(0),[i,r]=et(!0),[s,a]=et(null),l=it(""),c=it(null);nt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),nt((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),nt((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);const h=st((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:St(Rr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[St("div",{className:"absolute right-0 m-3",children:St(oe,{title:"Close notebook",onClick:h,
172
- variant:"dark",classes:Tt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:St(It,{className:"w-4 h-4"})})}),St(Er,{config:e,groupId:s},n)]})}class Tr{constructor(t,e,n){this._container=new Pn("notebook",(()=>St(Pr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Nr({eventBus:t,config:e}){const[n,o]=et(!0),i=it(null);nt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{o(!1)})),i.current=e,()=>{e.destroy()}}),[t]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:St(Rr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[St("div",{className:"absolute right-0 m-3",children:St(oe,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Tt("!bg-transparent enabled:hover:!bg-grey-3"),children:St(It,{className:"w-4 h-4"})})}),St("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",
173
- src:e.profileAppUrl})]})}class Lr{constructor(t,e,n){this._container=new Pn("profile",(()=>St(Nr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Or({above:t,below:e,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=t.anchors.length>0,a=e.anchors.length>0,l=t=>t.anchors.map((t=>t.tag));return St("ul",{className:"relative",children:[s&&St("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:t.position},children:St(ve,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const e=[...t.anchors].sort(((t,e)=>t.bottom-e.bottom)),n=e[e.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(t)),onMouseEnter:()=>o(l(t)),onMouseOut:()=>o([]),title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})}),n.map(((t,e)=>St("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:t.position},children:St(ve,{direction:"left",
174
- onClick:e=>r(l(t),e.metaKey||e.ctrlKey),onBlur:()=>o([]),onFocus:()=>o(l(t)),onMouseEnter:()=>o(l(t)),onMouseOut:()=>o([]),title:`Select nearby annotations (${t.anchors.length})`,children:t.anchors.length})},e))),a&&St("li",{className:"absolute right-0 pointer-events-auto",style:{top:e.position},children:St(ve,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const t=[...e.anchors].sort(((t,e)=>t.top-e.top)),n=t[0];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})})]})}class Ir{constructor(t,{onFocusAnnotations:e,onScrollToAnnotation:n,onSelectAnnotations:o}){this._positions=[],this._container=new Pn("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),t.appendChild(this._container.element),this._onFocusAnnotations=e,this._onScrollToAnnotation=n,this._onSelectAnnotations=o,
175
- this._container.render()}destroy(){this._container.destroy()}update(t){this._positions=t,this._container.render()}_render(){const t=function(t,e){const n=[],o=[],i=[];let r=null;function s(t){const{bottom:e,top:n}=t;return{bottom:e,position:n+(e-n)/2,anchors:[t],top:n}}const a=e.getBoundingClientRect(),l=t.map((t=>({tag:t.tag,top:t.top-a.top,bottom:t.bottom-a.top})));for(const t of l){const e=(t.top+t.bottom)/2;if(e<30){n.push(t);continue}if(e>a.height-30){o.push(t);continue}if(!r){r=s(t);continue}const l=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!l)i.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t),r.bottom=e,r.position=r.top+n/2}}return r&&i.push(r),{above:{anchors:n,position:25},below:{anchors:o,position:a.height-30},buckets:i}}(this._positions,this._container.element);return St(Or,{above:t.above,below:t.below,buckets:t.buckets,onFocusAnnotations:t=>this._onFocusAnnotations(t),onScrollToAnnotation:t=>this._onScrollToAnnotation(t),
176
- onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e)})}}function Br({emitter:t}){const[e,n]=et([]),o=st((t=>n((e=>[...e,t]))),[]),i=st((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return nt((()=>(t.subscribe("toastMessageAdded",o),t.subscribe("toastMessageDismissed",i),()=>{t.unsubscribe("toastMessageAdded",o),t.unsubscribe("toastMessageDismissed",i)})),[t,i,o]),St(ye,{messages:e,onMessageDismiss:i})}function Dr(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",...t,children:[St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor","clip-rule":"evenodd",
116
+ dc:this._getMetaTags("name","dc."),eprints:this._getMetaTags("name","eprints."),facebook:this._getMetaTags("property","og:"),highwire:this._getMetaTags("name","citation_"),prism:this._getMetaTags("name","prism."),twitter:this._getMetaTags("name","twitter:")},e=this._getFavicon();e&&(t.favicon=e),t.title=this._getTitle(t),t.link=this._getLinks(t);const n=t.link.find((t=>t.href.startsWith("urn:x-dc")));n&&(t.documentFingerprint=n.href);const o=this._getVersion(t);return null!==o&&(t.version=o),t}_getVersion(t){const e=[t.highwire.id??[],t.highwire.public_url??[],[t.link.find((t=>"canonical"===t.rel))?.href]];let n=null;for(const t of e){const e=this._findVersion(t);if(!e)return null;if(null===n)n=e;else if(n!==e)return null}return n}_findVersion(t){for(const e of t){const t=this._extractVersionFromUri(e);if(null!==t)return t}return null}_extractVersionFromUri(t){if(void 0===t)return null;const e=t.trim().match(/(?<![a-zA-Z])v(\d+)$/i);if(!e)return null;const n=parseInt(e[1],10);return n>=1&&n<=25?n:null}
117
+ _getMetaTags(t,e){const n={};for(const o of Array.from(this.document.querySelectorAll("meta"))){const i=o.getAttribute(t),{content:r}=o;if(i&&r){const t=i.match(RegExp(`^${e}(.+)$`,"i"));if(t){const e=t[1].toLowerCase();n[e]?n[e].push(r):n[e]=[r]}}}return n}_getTitle(t){return t.highwire.title?t.highwire.title[0]:t.eprints.title?t.eprints.title[0]:t.prism.title?t.prism.title[0]:t.facebook.title?t.facebook.title[0]:t.twitter.title?t.twitter.title[0]:t.dc.title?t.dc.title[0]:this.document.title}_getLinks(t={dc:{},highwire:{}}){const e=[{href:this._getDocumentHref()}],n=Array.from(this.document.querySelectorAll("link"));for(const t of n)if(["alternate","canonical","bookmark","shortlink"].includes(t.rel)){if("alternate"===t.rel){if(t.type&&t.type.match(/^application\/(rss|atom)\+xml/))continue;if(t.hreflang)continue}try{const n=this._absoluteUrl(t.href);e.push({href:n,rel:t.rel,type:t.type})}catch{}}for(const n of Object.keys(t.highwire)){const o=t.highwire[n];if("pdf_url"===n)for(const t of o)try{e.push({
118
+ href:this._absoluteUrl(t),type:"application/pdf"})}catch{}if("doi"===n)for(let t of o)"doi:"!==t.slice(0,4)&&(t=`doi:${t}`),e.push({href:t})}for(const n of Object.keys(t.dc)){const o=t.dc[n];if("identifier"===n)for(const t of o)"doi:"===t.slice(0,4)&&e.push({href:t})}const o=t.dc["relation.ispartof"],i=t.dc.identifier;if(o&&i){const t=o[o.length-1],n=i[i.length-1],r="urn:x-dc:"+encodeURIComponent(t)+"/"+encodeURIComponent(n);e.push({href:r})}return e}_getFavicon(){let t=null;for(const e of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(e.rel))try{t=this._absoluteUrl(e.href)}catch{}return t}_absoluteUrl(t){return li(t,this.document.baseURI)}_getDocumentHref(){const{href:t}=this.document.location,e=["http:","https:","file:"],n=new URL(t).protocol;return e.includes(n)?t:this.document.baseURI&&e.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:t}}class hi extends Me{constructor({features:t,container:e=document.body,sideBySideOptions:n}){super(),
119
+ this.featureFlags=t,this.container=e,this._htmlMeta=new ci,this._prevURI=this._htmlMeta.uri(),this._sideBySideEnabled=!0,this._sideBySideOptions=n??{mode:"auto"},this._sideBySideActive=!1,this._lastLayout=null,this._navObserver=new ei((()=>this._checkForURIChange())),this._metaObserver=new MutationObserver((()=>this._checkForURIChange())),this._metaObserver.observe(document.head,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["rel","href","name","content"]}),this._flagsChanged=()=>{},this.featureFlags.on("flagsChanged",this._flagsChanged)}anchor(t,e){return function(t,e,n={}){let o=null,i=null,r=null,s=null;for(const t of e)switch(t.type){case"TextPositionSelector":i=t,n.hint=i.start;break;case"TextQuoteSelector":r=t;break;case"RangeSelector":s=t;break;case"MediaTimeSelector":o=t}const a=t=>{if(r?.exact&&t.toString()!==r.exact)throw new Error("quote mismatch");return t};let l=Promise.reject("unable to anchor");if(s){const e=s;l=l.catch((()=>Jo(Wo.fromSelector(t,e),n).then(a)))}if(i){const e=i
120
+ ;l=l.catch((()=>Jo(jo.fromSelector(t,e),n).then(a)))}if(r){const e=r;l=l.catch((()=>Jo(Ko.fromSelector(t,e),n)))}if(o){const e=o;l=l.catch((()=>Qo.fromSelector(t,e).toRange()))}return l}(t,e)}describe(t,e){if(e instanceof Range)return function(t,e){const n=[Qo,Wo,jo,Ko],o=[];for(const i of n)try{const n=i.fromRange(t,e);n&&o.push(n.toSelector())}catch{}return o}(t,e);throw new Error("Unsupported region type")}_checkForURIChange(){const t=this._htmlMeta.uri();t!==this._prevURI&&(this._prevURI=t,this.emit("uriChanged",t))}getAnnotatableRange(t){try{return Un.trimmedRange(t)}catch(t){if(t instanceof RangeError)return null;throw t}}canStyleClusteredHighlights(){return!0}destroy(){this._deactivateSideBySide(),this._navObserver.disconnect(),this._metaObserver.disconnect(),this.featureFlags.off("flagsChanged",this._flagsChanged),super.destroy()}contentContainer(){return this.container}fitSideBySide(t){this._lastLayout=t
121
+ ;const e=window.innerWidth-t.width,n=this._sideBySideEnabled&&"auto"===this._sideBySideOptions.mode&&t.expanded&&e>=480;return n?this._activateSideBySide(t.width):this._sideBySideActive&&this._deactivateSideBySide(),this._sideBySideActive=n,this.container.classList.toggle("hypothesis-sidebyside-active",this._sideBySideActive),n}sideBySideActive(){return this._sideBySideActive}supportedTools(){return["selection"]}_activateSideBySide(t){const e=t+12,n=t=>parseInt(window.getComputedStyle(t).marginLeft,10);on((()=>{document.body.style.marginLeft="",document.body.style.marginRight="";const t=n(document.body);document.body.style.marginRight=`${e}px`;const o=function(t){const e=new Map,n=new Map,o=Qe.join(","),i=Array.from(t.querySelectorAll(o)).map((t=>({rect:t.getBoundingClientRect(),textLength:t.textContent.length}))).filter((({rect:t})=>t.width>0&&t.height>0)).sort(((t,e)=>e.textLength-t.textLength)).slice(0,15);if(i.forEach((({rect:t})=>{let o=e.get(t.left)??0;o+=1,e.set(t.left,o);let i=n.get(t.right)??0;i+=1,
122
+ n.set(t.right,i)})),0===e.size||0===n.size)return null;const r=[...e.entries()].sort(((t,e)=>e[1]-t[1])),s=[...n.entries()].sort(((t,e)=>e[1]-t[1])),[a]=r[0],[l]=s[0];return{left:a,right:l}}(document.body);if(o){const i=Math.max(0,window.innerWidth-e-o.right);if(i>0){const t=Math.max(0,e-i);document.body.style.marginRight=`${t}px`}n(document.body)>t&&(document.body.style.marginLeft=`${t}px`),o.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){on((()=>{document.body.style.marginLeft="",document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(t){const e=t.highlights?.[0];e&&await async function(t,{maxDuration:e=500}={}){const n=t.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{value:"BODY",configurable:!0});const o=t.closest("details");o&&!o.hasAttribute("open")&&(o.open=!0),
123
+ await new Promise((n=>ri(t,{time:e},n)))}(e)}}var di,ui;var fi=function(){if(ui)return di;ui=1;var t=NaN,e="[object Symbol]",n=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,r=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof At&&At&&At.Object===Object&&At,l="object"==typeof self&&self&&self.Object===Object&&self,c=a||l||Function("return this")(),h=Object.prototype.toString,d=Math.max,u=Math.min,f=function(){return c.Date.now()};function p(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(a){if("number"==typeof a)return a;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&h.call(t)==e}(a))return t;if(p(a)){var l="function"==typeof a.valueOf?a.valueOf():a;a=p(l)?l+"":l}if("string"!=typeof a)return 0===a?a:+a;a=a.replace(n,"");var c=i.test(a);return c||r.test(a)?s(a.slice(2),c?2:8):o.test(a)?t:+a}return di=function(t,e,n){var o,i,r,s,a,l,c=0,h=!1,_=!1,m=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function b(e){var n=o,r=i
124
+ ;return o=i=void 0,c=e,s=t.apply(r,n)}function y(t){var n=t-l;return void 0===l||n>=e||n<0||_&&t-c>=r}function w(){var t=f();if(y(t))return v(t);a=setTimeout(w,function(t){var n=e-(t-l);return _?u(n,r-(t-c)):n}(t))}function v(t){return a=void 0,m&&o?b(t):(o=i=void 0,s)}function x(){var t=f(),n=y(t);if(o=arguments,i=this,l=t,n){if(void 0===a)return function(t){return c=t,a=setTimeout(w,e),h?b(t):s}(l);if(_)return a=setTimeout(w,e),b(l)}return void 0===a&&(a=setTimeout(w,e)),s}return e=g(e)||0,p(n)&&(h=!!n.leading,r=(_="maxWait"in n)?d(g(n.maxWait)||0,e):r,m="trailing"in n?!!n.trailing:m),x.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},x.flush=function(){return void 0===a?s:v(f())},x},di}(),pi=kt(fi);function gi(t,e,n,o=0){let i=o;for(;i<t.length&&e>0;)n(t[i])&&--e,++i;return i}function _i(t,e,n,o){let i=0;for(let r=n;r<o;r++)e(t[r])&&++i;return i}const mi=new Map;function bi(t,e){const n=t.normalize("NFKD");if(n===t)return{input:t,output:n};const o=[],i=[];let r=0,s=0;for(const n of t){
125
+ const t=n.codePointAt(0);let a=mi.get(t);if(void 0===a&&(a=n.normalize("NFKD").length,mi.set(t,a)),e.offsets){for(let t=0;t<n.length;t++)i.push(s);s+=a}if(e.reverseOffsets){for(let t=0;t<a;t++)o.push(r);r+=n.length}}return e.offsets&&i.push(n.length),e.reverseOffsets&&o.push(r),{input:t,output:n,reverseOffsets:o,offsets:i}}function yi(t,e,n,o,i,r={}){n=Math.max(0,Math.min(n,t.length)),o=Math.max(n,Math.min(o,t.length));const s=r.normalize?bi(t,{offsets:!0}):{output:t},a=r.normalize?bi(e,{reverseOffsets:!0}):{output:e},l=s.offsets?.[n]??n,c=s.offsets?.[o]??o,h=_i(s.output,i,0,l),d=_i(s.output,i,l,c);let u=gi(a.output,h,i);for(;u<a.output.length&&!i(a.output[u]);)++u;const f=gi(a.output,d,i,u);return[a.reverseOffsets?.[u]??u,a.reverseOffsets?.[f]??f]}const wi={INITIAL:0,FINISHED:3},vi=new Map,xi=new Map;function Ci(t,e){return`${t}:${e}`}function Si(t){const e="closest"in t?t:t.parentElement;return e?.closest(".textLayer")??null}function Ai(){return PDFViewerApplication.pdfViewer}async function ki(t){
126
+ const e=Ai();let n=e.getPageView(t);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{e.eventBus?e.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(e.getPageView(t))};e.eventBus?e.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function Mi(t,e){return document.elementsFromPoint(t,e).find((t=>t.classList.contains("textLayer")))}function Ri(t){const e=vi.get(t);if(e)return e;const n=(async()=>{const e=await ki(t);return(await e.pdfPage.getTextContent({normalizeWhitespace:!0})).items.map((t=>t.str)).join("")})();return vi.set(t,n),n}async function Ei(t){const e=Ai();let n=0,o=0,i="";for(let r=0;r<e.pagesCount;r++)if(i=await Ri(r),n=o,o+=i.length,o>=t)return{index:r,offset:n,text:i};return{index:e.pagesCount-1,offset:n,text:i}}function Pi(t){switch(t){case" ":case"\f":case"\n":case"\r":case"\t":case"\v":case" ":return!0;default:return!1}}const Ti=t=>!Pi(t);function Ni(t){
127
+ return void 0!==t.renderingDone?t.renderingDone:!!t.div&&null!==t.div.querySelector(".endOfContent")}async function Li(t,e,n){const[o,i]=await Promise.all([ki(t),Ri(t)]);if(o.renderingState===wi.FINISHED&&o.textLayer&&Ni(o.textLayer)){const t=o.textLayer.textLayerDiv??o.textLayer.div;if(!t)throw new Error("Unable to find PDF.js text layer root");const r=t.textContent,[s,a]=yi(i,r,e,n,Ti,{normalize:!0}),l=Oi(r.slice(s,a)),c=Oi(i.slice(e,n));l.normalize("NFKD")!==c.normalize("NFKD")&&Ao("Text layer text does not match page text. Highlights will be mis-aligned.");const h=new zn(t,s),d=new zn(t,a);return new Un(h,d).toRange()}const r=function(t){let e=t.querySelector($n);return e||(e=document.createElement("span"),e.classList.add("annotator-placeholder"),e.textContent="Loading annotations...",t.appendChild(e),e)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function Oi(t){let e="";for(let n=0;n<t.length;n++){const o=t[n];Pi(o)||(e+=o)}return e}async function Ii(t){
128
+ const e=t.find((t=>"TextQuoteSelector"===t.type));if(!e)throw new Error("No quote selector found");const n=t.find((t=>"TextPositionSelector"===t.type));if(n){try{const{index:t,offset:o,text:i}=await Ei(n.start),r=n.start-o,s=n.end-o,a=i.substring(r,s);if(e.exact!==a)throw new Error("quote mismatch");return await Li(t,r,s)}catch{}try{const t=Ci(e.exact,n.start),o=xi.get(t);if(o){const{pageIndex:t,anchor:e}=o;return await Li(t,e.start,e.end)}}catch{}}return async function(t,e){const n=Ai().pagesCount,o=Array(n).fill(0).map(((t,e)=>e));let i,r;if(e){const{index:t,offset:n}=await Ei(e);i=t,r=e-n,o.sort(((e,n)=>Math.abs(e-t)-Math.abs(n-t)))}const s=void 0!==t.prefix?Oi(t.prefix):void 0,a=void 0!==t.suffix?Oi(t.suffix):void 0,l=Oi(t.exact);let c;for(const t of o){const e=await Ri(t),n=Oi(e);let o;void 0!==i&&void 0!==r&&(t<i?o=n.length:t===i?[o]=yi(e,n,r,r,Ti,{normalize:!1}):o=0);const h=Vo(n,l,{prefix:s,suffix:a,hint:o});if(h&&(!c||h.score>c.match.score)){const[o,i]=yi(n,e,h.start,h.end,Ti);c={page:t,match:{
129
+ start:o,end:i,score:h.score}};const r=n.slice(h.start,h.end)===l,d=void 0!==s&&n.slice(Math.max(0,h.start-s.length),h.start)===s,u=void 0!==a&&n.slice(h.end,a.length)===a;if(r&&(d||u||void 0===s&&void 0===a))break}}if(c){const{page:n,match:o}=c;if(e){const i=Ci(t.exact,e);xi.set(i,{pageIndex:n,anchor:o})}return Li(n,o.start,o.end)}throw new Error("Quote not found")}(e,n?.start)}async function Bi(t){const e=t.find((t=>"PageSelector"===t.type)),n=t.find((t=>"ShapeSelector"===t.type));if(n){if(!e)throw new Error("Cannot anchor a shape selector without a page");return async function(t,e){const n=Ai();if("number"!=typeof t.index||t.index<0||t.index>=n.pagesCount)throw new Error("PDF page index is invalid");const o=await ki(t.index),i=o.div,r=o.viewport,s=t=>function(t,e,n){return Math.max(Math.min(t,n),e)}(t,0,1);let a;switch(e.shape.type){case"rect":{const t=e.shape;let[n,o]=r.convertToViewportPoint(t.left,t.top),[i,l]=r.convertToViewportPoint(t.right,t.bottom);i<n&&([n,i]=[i,n]),l<o&&([o,l]=[l,o]),a={
130
+ type:"rect",left:s(n/r.width),top:s(o/r.height),right:s(i/r.width),bottom:s(l/r.height)}}break;case"point":{const t=e.shape,[n,i]=o.viewport.convertToViewportPoint(t.x,t.y);a={type:"point",x:s(n/r.width),y:s(i/r.height)}}break;default:throw new Error("Unsupported shape in shape selector")}return{anchor:i,shape:a,coordinates:"anchor"}}(e,n)}return Ii(t)}function Di(t){try{t=Un.fromRange(t).toRange()}catch{throw new Error("Selection does not contain text")}const e=Si(t.startContainer),n=Si(t.endContainer);if(!e||!n)throw new Error("Selection is outside page text");if(e!==n)throw new Error("Selecting across page breaks is not supported");return[t,e]}function Fi(t){const e=t.closest(".page"),n=parseInt(e?.getAttribute("data-page-number")??"");if(!Number.isInteger(n))throw new Error("Unable to get page number from element");return n-1}async function Hi(t){
131
+ const[e,n]=Di(t),o=zn.fromPoint(e.startContainer,e.startOffset).relativeTo(n),i=zn.fromPoint(e.endContainer,e.endOffset).relativeTo(n),r=Fi(n),s=await async function(t){if(t>=Ai().pagesCount)throw new Error("Invalid page index");let e=0;for(let n=0;n<t;n++)e+=(await Ri(n)).length;return e}(r),a=await ki(r);return[{type:"TextPositionSelector",start:s+o.offset,end:s+i.offset},Ko.fromRange(a.div,e).toSelector(),zi(a,r)]}async function Vi(t,e){const n=document.elementsFromPoint(t,e);for(const o of n){if(!o.classList.contains("page"))continue;const n=Fi(o),i=getComputedStyle(o),r=parseFloat(i.borderLeftWidth),s=parseFloat(i.borderTopWidth),a=o.getBoundingClientRect(),l=t-a.left-r,c=e-a.top-s,h=await ki(n),[d,u]=h.getPagePoint(l,c);return{pageIndex:n,x:d,y:u}}return null}function zi(t,e){return{type:"PageSelector",index:e,label:t.pageLabel??`${e+1}`}}async function Ui(t){const e=t=>{const[e,n,o,i]=t.view;return{left:e,top:i,right:o,bottom:n}},n=(t,e)=>function(t,e){
132
+ const n=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),o=[];let i,r;for(;r=n.nextNode();){const t=r,n=t.data.split(/\b/);let s=0;for(const r of n){const n=new Range;n.setStart(t,s);const a=s+r.length;n.setEnd(t,a);const l=n.getBoundingClientRect();$e(l,e)&&(i&&!qe(i,l)&&o.push(" "),o.push(r),i=l),s=a}}return o.join("")}(t,e).slice(0,256);switch(t.type){case"rect":{const[o,i]=await Promise.all([Vi(t.left,t.top),Vi(t.right,t.bottom)]);if(!o)throw new Error("Top-left point is not in a page");if(!i)throw new Error("Bottom-right point is not in a page");if(o.pageIndex!==i.pageIndex)throw new Error("Shape must start and end on same page");const r=await ki(o.pageIndex),s={type:"rect",left:o.x,top:o.y,right:i.x,bottom:i.y},a=Mi(t.left,t.top);let l;if(a){l=n(a,new DOMRect(t.left,t.top,t.right-t.left,t.bottom-t.top))}return[zi(r,o.pageIndex),{type:"ShapeSelector",anchor:"page",shape:s,view:e(r.pdfPage),text:l}]}case"point":{const o=await Vi(t.x,t.y);if(!o)throw new Error("Point is not in a page")
133
+ ;const i=Mi(t.x,t.y);let r;if(i){r=n(i,new DOMRect(t.x,t.y,1,1))}const s=await ki(o.pageIndex);return[zi(s,o.pageIndex),{type:"ShapeSelector",anchor:"page",shape:{type:"point",x:o.x,y:o.y},text:r,view:e(s.pdfPage)}]}default:throw new Error("Unsupported shape")}}function $i({children:t}){return St("div",{className:"flex flex-col",children:t})}function qi({info:t}){let e=t.item.title;return t.item.subtitle&&(e+=`: ${t.item.subtitle}`),St("div",{className:Tt("h-10 bg-white px-4 text-slate-7 text-annotator-base border-b","grid items-center","grid-cols-[100px_minmax(0,auto)]","2xl:grid-cols-[100px_minmax(0,auto)_minmax(0,auto)] 2xl:gap-x-3"),children:[St("div",{"data-testid":"content-logo",children:t.logo&&St(we,{href:t.logo.link,target:"_blank","data-testid":"logo-link",underline:"none",children:St("img",{alt:t.logo.title,src:t.logo.logo,"data-testid":"logo-image"})})}),St("div",{className:Tt("hidden","2xl:block 2xl:whitespace-nowrap 2xl:overflow-hidden 2xl:text-ellipsis","font-semibold"),
134
+ "data-testid":"content-container-info",title:t.container.title,children:t.container.title}),St("div",{className:Tt("flex justify-center items-center gap-x-2"),"data-testid":"content-item-info",children:[St("div",{className:Tt("hidden","2xl:block 2xl:grow")}),t.links.previousItem&&St(y,{children:[St(we,{title:"Open previous item",href:t.links.previousItem,underline:"always",target:"_blank","data-testid":"content-previous-link",children:St("div",{className:"flex gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[St(Dt,{className:"w-em h-em"}),St("span",{children:"Previous"})]})}),St("div",{className:"text-annotator-sm",children:"|"})]}),St("div",{className:Tt("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis shrink font-medium"),children:St(we,{title:e,href:t.links.currentItem,"data-testid":"content-item-link",target:"_blank",unstyled:!0,children:e})}),t.links.nextItem&&St(y,{children:[St("div",{className:"text-annotator-sm",children:"|"}),St(we,{title:"Open next item",
135
+ href:t.links.nextItem,underline:"always",target:"_blank","data-testid":"content-next-link",children:St("div",{className:"flex gap gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[St("span",{children:"Next"}),St(Ft,{className:"w-em h-em"})]})})]})]})]})}function Wi(){return St("div",{className:"bg-white",role:"alert",children:St("div",{className:Tt("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[St("div",{className:"bg-yellow-notice text-white p-2",children:St(Ht,{className:"text-annotator-xl"})}),St("div",{children:[St("strong",{children:"Text annotation tools are unavailable because this PDF does not contain selectable text."})," ",St(we,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",underline:"always",children:"Learn more here"}),"."]})]})})}class ji{constructor(t){this._loaded=function(t){return t.initializedPromise?t.initializedPromise:t.initialized?Promise.resolve():new Promise((e=>{
136
+ const n=setInterval((()=>{t.initialized&&(clearTimeout(n),e())}),5)}))}(t).then((async()=>{const e=await async function(t){return void 0!==t.downloadComplete?t.downloadComplete:(await t.pdfDocument.getDownloadInfo(),!0)}(t);return e?t:new Promise((e=>{const n=()=>{t.eventBus?(t.eventBus.off("documentload",n),t.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),e(t)};t.eventBus?(t.eventBus.on("documentloaded",n),t.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))}))}getUri(){return this._loaded.then((t=>{let e=Yi(t);return e||(e=Xi(Ki(t))),e}))}async getMetadata(){const t=await this._loaded,{info:e,contentDispositionFilename:n,metadata:o}=await t.pdfDocument.getMetadata(),i=Ki(t),r=Yi(t),s=o?.get("dc:title");let a;a=s&&"Untitled"!==s?s:e?.Title?e.Title:n||(r?function(t){const e=new URL(t),n=e.pathname.split("/");return n[n.length-1]}(r):"");const l=[{href:Xi(i)}];return r&&l.push({href:r}),{title:a,link:l,documentFingerprint:i}}}function Ki(t){
137
+ return Array.isArray(t.pdfDocument.fingerprints)?t.pdfDocument.fingerprints[0]:t.pdfDocument.fingerprint}function Xi(t){return`urn:x-pdf:${t}`}function Yi(t){if(!t.url)return null;const e=li(t.url);return 0!==e.indexOf("file://")?e:null}function Gi(t){const e=t.highlights?.[0];return e&&qn(e)}function Qi(t){return new Promise((e=>setTimeout(e,t)))}class Ji{constructor(){this._pdfjsContainer=document.querySelector("#outerContainer"),this._contentInfo=null,this._noTextWarning=!1,this._container=null}setContentInfo(t){this._contentInfo=t,this._update()}showNoTextWarning(t){this._noTextWarning=t,this._update()}destroy(){this._container?.destroy()}_update(){if(!(this._noTextWarning||this._contentInfo))return this._container?.destroy(),this._container=null,void(this._pdfjsContainer.style.height="");this._container||(this._container=new Pn("banner",(()=>this._render())),document.body.prepend(this._container.element)),this._container.render();const t=this._container.element.getBoundingClientRect().height
138
+ ;this._pdfjsContainer.style.height=`calc(100% - ${t}px)`}_render(){return St($i,{children:[this._contentInfo&&St(qi,{info:this._contentInfo}),this._noTextWarning&&St(Wi,{})]})}}class Zi extends Me{constructor({annotator:t,features:e,reanchoringMaxWait:n}){super(),this._annotator=t;const o=window,i=o.PDFViewerApplication;this._pdfViewer=i.pdfViewer,this._pdfViewer.viewer.classList.add("has-transparent-text-layer"),this._pdfContainer=i.appConfig?.appContainer??document.body,this._pdfMetadata=new ji(i),this._observer=new MutationObserver(pi((()=>this._update()),100)),this._observer.observe(this._pdfViewer.viewer,{attributes:!0,attributeFilter:["data-loaded"],childList:!0,subtree:!0}),this._reanchoringMaxWait=n??3e3,this._banner=new Ji,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const t=o.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!t.isCollapsed)},this._listeners=new mt,
139
+ this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1,this._features=e,this._features.on("flagsChanged",(()=>{this.emit("supportedToolsChanged",this.supportedTools())})),this._pdfViewer.viewer.addEventListener("click",(t=>{const e=t.target;e instanceof HTMLAnchorElement&&(e.target="blank");oo(t.clientX,t.clientY).length>0&&t.preventDefault()}))}destroy(){this.fitSideBySide({expanded:!1,width:0,toolbarWidth:0,height:window.innerHeight}),this._listeners.removeAll(),this._pdfViewer.viewer.classList.remove("has-transparent-text-layer"),this._observer.disconnect(),this._banner.destroy(),this._destroyed=!0,super.destroy()}uri(){return this._pdfMetadata.getUri()}getMetadata(){return this._pdfMetadata.getMetadata()}showContentInfo(t){this._banner.setContentInfo(t)}anchor(t,e){return Bi(e)}getAnnotatableRange(t){try{const e=Un.trimmedRange(t);if(function(t){try{return Di(t),!0}catch{return!1}}(e))return e}catch(t){if(!(t instanceof RangeError))throw t}return null}
140
+ canStyleClusteredHighlights(){return!0}describe(t,e){return e instanceof Range?Hi(e):Ui(e)}async _checkForSelectableText(){try{await this.uri()}catch{return}if(!this._destroyed)try{const t=await async function(){const t=Ai();let e=!1;for(let n=0;n<t.pagesCount;n++)if((await Ri(n)).trim().length>0){e=!0;break}return e}();this._banner.showNoTextWarning(!t)}catch(t){console.warn("Unable to check for text in PDF:",t)}}_update(){const t=[],e=this._pdfViewer.pagesCount;for(let t=0;t<e;t++){const e=this._pdfViewer.getPageView(t);if(e?.textLayer&&Ni(e.textLayer))switch(e.renderingState){case wi.INITIAL:e.textLayer=null;break;case wi.FINISHED:n=e.div,n.querySelector($n)?.remove()}}var n;for(const e of this._annotator.anchors)if(e.highlights){if(t.includes(e.annotation))continue;for(let n=0;n<e.highlights.length;n++){const o=e.highlights[n];if(!document.body.contains(o)){e.highlights.splice(n,1),delete e.region,t.push(e.annotation);break}}}t.map((t=>this._annotator.anchor(t)))}contentContainer(){
141
+ return document.querySelector("#viewerContainer")}fitSideBySide(t){const e=window.innerWidth-t.width,n=t.expanded&&e>=680,o=n?t.width:t.toolbarWidth;this._pdfContainer.style.width=`calc(100% - ${o}px)`;const i=this._pdfViewer.currentScaleValue;return"auto"!==i&&"page-fit"!==i&&"page-width"!==i||(this._pdfViewer.currentScaleValue=i),this._pdfViewer.update(),this._sideBySideActive=n,n}sideBySideActive(){return this._sideBySideActive}supportedTools(){const t=this._features?.flagEnabled("pdf_image_annotation");return t?["selection","rect","point"]:["selection"]}async scrollToAnchor(t){const e=t.annotation,n=Gi(t),o=this._anchorOffset(t);if(null!==o&&(await ai(this.contentContainer(),o),n)){const t=await this._waitForAnnotationToBeAnchored(e,this._reanchoringMaxWait);if(!t)return;const n=this._anchorOffset(t);if(null===n)return;await ai(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(t,e){const n=Date.now();let o;do{o=this._annotator.anchors.find((e=>e.annotation===t)),o&&!Gi(o)||(o=null,
142
+ await Qi(20))}while(!o&&Date.now()-n<e);return o??null}_anchorOffset(t){if(!t.highlights)return null;const e=t.highlights[0];return function(t,e,n={}){let o=0,i=e;for(;i!==t&&t.contains(i);)o+=i.offsetTop,i=i.offsetParent;if("center"===n.position){const n=t.getBoundingClientRect(),i=e.getBoundingClientRect();o-=n.height/2-i.height/2}return o}(this.contentContainer(),e,{position:"center"})}async renderToBitmap(t,e){const n=t.target.selector?.find((t=>"ShapeSelector"===t.type)),o=t.target.selector?.find((t=>"PageSelector"===t.type));if(!o||!n)throw new Error("Can only render bitmaps for anchors with shapes");const i=this._pdfViewer.getPageView(o.index);if(!i)throw new Error("Failed to get page view");let r,s,a,l;switch(n.shape.type){case"rect":({left:r,right:s,top:a,bottom:l}=n.shape);break;case"point":{const{x:t,y:e}=n.shape,[o,,c]=i.pdfPage.view,h=.1*Math.abs(c-o);r=t-h,a=e+h,s=t+h,l=e-h}break;default:throw new Error("Unsupported shape type")}s<r&&([r,s]=[s,r]),s=Math.max(s,r+1),a<l&&([a,l]=[l,a]),
143
+ a=Math.max(a,l+1);const c=i.pdfPage.rotate%360;if(c%90!=0)throw new Error("Page rotation is not a multiple of 90 degrees");let h,d;0===c||180===c?(h=Math.abs(s-r),d=Math.abs(l-a)):(h=Math.abs(l-a),d=Math.abs(s-r));const u=96/72,f=e.devicePixelRatio??1,p=h*u*f,g=h/d,_="number"==typeof e.maxWidth?Math.min(e.maxWidth,p):p,m=_/g,b=i.pdfPage.getViewport({scale:1}),y=_/p*u*f,w=new(0,b.constructor)({rotation:c,scale:y,userUnit:b.userUnit,viewBox:[r,l,s,a]}),v=Math.max(_,1),x=Math.max(m,1),C=new OffscreenCanvas(v,x),S=C.getContext("2d"),A=i.pdfPage.render({canvasContext:S,viewport:w});if(await A.promise,"point"===n.shape.type){S.save(),S.scale(y,y);const t=n.shape.x-r,e=n.shape.y-l,o=5;S.strokeStyle="black",S.fillStyle="yellow",S.beginPath(),S.arc(t,e,o,0,2*Math.PI),S.fill(),S.stroke(),S.restore()}return C.transferToImageBitmap()}}function tr(t){if(!t.includes("["))return t;let e="",n=!1,o=!1;for(const i of t)n||"^"!==i?(n||"["!==i?!n&&o&&"]"===i?o=!1:o||(e+=i):o=!0,n=!1):n=!0;return e}function er(t){
144
+ const e=tr(t),n=e.indexOf("!");return-1===n?e:e.slice(0,n)}class nr{constructor(t,e,n){this._element=t,this._onFrameAdded=e,this._onFrameRemoved=n,this._annotatableFrames=new Set,this._isDisconnected=!1,this._mutationObserver=new MutationObserver(pi((()=>{this._discoverFrames()}),40)),this._discoverFrames(),this._mutationObserver.observe(this._element,{childList:!0,subtree:!0,attributeFilter:["enable-annotation"]})}disconnect(){this._isDisconnected=!0,this._mutationObserver.disconnect()}async _addFrame(t){this._annotatableFrames.add(t);try{if(await or(t),this._isDisconnected)return;t.contentWindow.addEventListener("unload",(()=>{this._removeFrame(t)})),this._onFrameAdded(t)}catch{console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${t.src}')`)}}_removeFrame(t){this._annotatableFrames.delete(t),this._onFrameRemoved(t)}_discoverFrames(){const t=new Set(this._element.querySelectorAll("iframe[enable-annotation]"))
145
+ ;for(const e of t)this._annotatableFrames.has(e)||this._addFrame(e);for(const e of this._annotatableFrames)t.has(e)||this._removeFrame(e)}}function or(t){return new Promise(((e,n)=>{const o=ir(t,((t,i)=>{o(),i?e(i):n(t)}))}))}function ir(t,e,{pollInterval:n=10}={}){let o,i;const r=new WeakSet,s=()=>{clearTimeout(o),o=void 0},a=()=>{const n=t.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),!function(t){return"about:blank"===t.contentDocument?.location.href&&t.hasAttribute("src")&&"about:blank"!==t.src}(t)){"interactive"===n.readyState||"complete"===n.readyState?e(null,n):n.addEventListener("DOMContentLoaded",(()=>e(null,n)))}t.contentDocument&&t.contentWindow?.addEventListener("unload",i)}}else{s();const n=t.isConnected?"Frame is cross-origin":"Frame is disconnected";e(new Error(n))}};let l=!1;i=()=>{s(),l||(o=setInterval(a,n))},t.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),t.removeEventListener("load",a)}}class rr{constructor(t,e){this._config=e,
146
+ this._frameObserver=new nr(t,(t=>sr(t,e)),(()=>{}))}destroy(){this._frameObserver.disconnect()}}async function sr(t,e,n){if(null!==t.contentDocument.querySelector("script.js-hypothesis-config"))return;await or(t);const{assetRoot:o,notebookAppUrl:i,profileAppUrl:r,sidebarAppUrl:s}=He(document),a={...e,assetRoot:o,notebookAppUrl:i,profileAppUrl:r,sidebarAppUrl:s,subFrameIdentifier:n??Ce(10)},l=document.createElement("script");l.className="js-hypothesis-config",l.setAttribute("data-remove-on-unload",""),l.type="application/json",l.innerText=JSON.stringify(a);const c=document.createElement("script");c.async=!0,c.src=e.clientUrl;const h=t.contentDocument;h.body.appendChild(l),h.body.appendChild(c)}class ar{constructor(t,e,n){if(e.length!==n.length)throw new Error("Char boxes length does not match text length");const o=t.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,t.nextSibling),o.style.position="relative",i.style.position="absolute",i.style.top="0",i.style.left="0",
147
+ i.style.color="transparent",i.style.textAlign="left",i.style.mixBlendMode="multiply";const r="sans-serif";i.style.fontSize="16px",i.style.fontFamily=r;const s=document.createElement("canvas").getContext("2d");s.font=`16px ${r}`;const a=(t,e,n="px")=>`calc(var(--${t}-scale) * ${e}${n})`,l=function(t,e){const n=[];let o={text:"",rect:new DOMRect};const i=()=>{o.text.length>0&&(n.push(o),o={text:"",rect:new DOMRect})};for(const[n,r]of t.entries()){const t=e[n],s=/\s/.test(t);o.text.length>0&&!qe(o.rect,r)&&i(),o.rect=je(o.rect,r),o.text+=s?" ":t,s&&i()}i();const r=[];let s={words:[],rect:new DOMRect};const a=()=>{s.words.length>0&&(r.push(s),s={words:[],rect:new DOMRect})};for(const t of n){const e=s.words[s.words.length-1];if(e){const n=Ke(e.rect),o=Ke(t.rect).x-n.x;(!qe(e.rect,t.rect)||o<0)&&a()}s.words.push(t),s.rect=je(s.rect,t.rect)}a();const l=[];let c={lines:[],rect:new DOMRect};const h=()=>{c.lines.length>0&&(l.push(c),c={lines:[],rect:new DOMRect})};for(const t of r){const e=c.lines[c.lines.length-1]
148
+ ;if(e){const n=Ke(e.rect),o=Ke(t.rect).y-n.y;(!We(e.rect,t.rect)||qe(e.rect,t.rect)||o<0||o>4*t.rect.height)&&h()}c.lines.push(t),c.rect=je(c.rect,t.rect)}return h(),l}(e,n);for(const t of l){const e=document.createElement("hypothesis-text-column");e.style.display="block",e.style.position="absolute",e.style.left=a("x",t.rect.left),e.style.top=a("y",t.rect.top);let n=null;for(const o of t.lines){const i=document.createElement("hypothesis-text-line");i.style.display="block",i.style.marginLeft=a("x",o.rect.left-t.rect.left),i.style.height=a("y",o.rect.height),n&&(i.style.marginTop=a("y",o.rect.top-n.rect.bottom)),n=o,i.style.whiteSpace="nowrap";let r=null;for(const t of o.words){const e=document.createElement("hypothesis-text-word");e.style.display="inline-block",e.style.transformOrigin="top left",e.textContent=t.text,r&&(e.style.marginLeft=a("x",t.rect.left-r.rect.right)),r=t,e.style.width=a("x",t.rect.width),e.style.height=a("y",t.rect.height),e.style.whiteSpace="pre"
149
+ ;const n=s.measureText(t.text),o=a("x",t.rect.width/n.width,""),l=a("y",t.rect.height/16,"");e.style.transform=`scale(${o}, ${l})`,i.append(e)}e.append(i)}i.append(e)}const c=()=>{const{width:e,height:n}=t.getBoundingClientRect();i.style.width=e+"px",i.style.height=n+"px",i.style.setProperty("--x-scale",`${e}`),i.style.setProperty("--y-scale",`${n}`)};c(),this.container=i,this._updateTextLayerSize=pi(c,{maxWait:50}),this._listeners=new mt,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(t)),this._listeners.add(window,"resize",this._updateTextLayerSize)}updateSync(){this._updateTextLayerSize(),this._updateTextLayerSize.flush()}destroy(){this.container.remove(),this._listeners.removeAll(),this._updateTextLayerSize.cancel(),this._imageSizeObserver?.disconnect()}}function lr(t=document){return t.querySelector("mosaic-book")}function cr(t=window){if(lr(t.document))return"container"
150
+ ;const e=t.frameElement?.ownerDocument;return e&&lr(e)?"content":null}class hr{constructor(t){const e=lr();if(!e)throw new Error("Book container element not found");const n=new WeakSet,o=e.shadowRoot,i=()=>{const e=o.querySelector("iframe");e&&!n.has(e)&&(n.add(e),ir(e,((n,o)=>{if(n)return;const i=o.body;i&&!i.querySelector("#page-content")&&sr(e,t,"vitalsource-content")})))};i(),this._frameObserver=new MutationObserver(i),this._frameObserver.observe(o,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function dr(){return document.querySelector("img#pbk-page")}class ur extends Me{constructor(t=document.body,e={}){super();const n=e.bookElement??lr(window.parent.document);if(!n)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=n;const o=new Mo;this._htmlIntegration=new hi({container:t,features:o}),this._listeners=new mt;const i=["mouseup","mousedown","mouseout"];for(const t of i)this._listeners.add(document.documentElement,t,(t=>{
151
+ t.stopPropagation()}));const r=window.frameElement;r&&function(t){if("no"!==t.getAttribute("scrolling"))return;const e=document.createElement("style");e.textContent="iframe { height: 100% !important; }",t.insertAdjacentElement("beforebegin",e);const n=()=>t.removeAttribute("scrolling");n(),new MutationObserver(n).observe(t,{attributes:!0})}(r);const s=dr(),a=window.innerPageData;if(s&&a){const t=a.glyphs.glyphs.map((t=>{const e=t.l/100,n=t.r/100,o=t.t/100,i=t.b/100;return new DOMRect(e,o,n-e,i-o)}));this._textLayer=new ar(s,t,a.words),this._textLayer.container.style.zIndex="100",this._sideBySideActive=!1}}getAnnotatableRange(t){return this._htmlIntegration.getAnnotatableRange(t)}destroy(){this._textLayer&&(this._textLayer.destroy(),this.fitSideBySide({expanded:!1,height:window.innerHeight,width:0,toolbarWidth:0})),this._listeners.removeAll(),this._htmlIntegration.destroy(),super.destroy()}anchor(t,e){return this._htmlIntegration.anchor(t,e)}async describe(t,e){
152
+ const n=this._htmlIntegration.describe(t,e),{cfi:o,index:i,page:r,title:s,url:a}=await this._getPageInfo({includeTitle:!0,includePageIndex:!0}),l=[{type:"EPUBContentSelector",cfi:o,url:a,title:s}];if("number"==typeof i){const t={type:"PageSelector",index:i,label:r};l.push(t)}return n.push(...l),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(t){const e=dr();if(e&&this._textLayer){const n=e.parentElement,o=this._textLayer,i=window.innerWidth-t.width;return this._sideBySideActive=!1,on((()=>{t.expanded&&i>480?(n.style.textAlign="left",e.style.width=`${i}px`,this._sideBySideActive=!0):(n.style.textAlign="",e.style.width=""),o.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(t)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}supportedTools(){return["selection"]}async getMetadata(){return{title:this._bookElement.getBookInfo().title,link:[]}}navigateToSegment(t){
153
+ const e=t.target[0].selector?.find((t=>"EPUBContentSelector"===t.type));if(e?.cfi)this._bookElement.goToCfi(e.cfi);else{if(!e?.url)throw new Error("No segment information available");this._bookElement.goToURL(function(t){const e=new URL(t,document.baseURI);return e.pathname+e.search}(e.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:t=!1,includePageIndex:e=!1}={}){const[n,o,i]=await Promise.all([this._bookElement.getCurrentPage(),t?this._bookElement.getTOC():void 0,e?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const t of r)if(!(t in n))throw new Error(`Page metadata field "${t}" is missing`);let s;if(o){s=n.chapterTitle;const t=er(n.cfi),e=o.data?.find((e=>er(e.cfi)===t));e&&(s=e.title)}let a=n.index;if(void 0===a&&i){const t=i.data?.findIndex((t=>t.cfi===n.cfi));-1!==t&&(a=t)}return{cfi:n.cfi,index:a,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(t){let e=[];try{const t=await this._bookElement.getPageBreaks()
154
+ ;t.ok&&t.data&&(e=t.data)}catch(t){console.error("Failed to get page breaks",t)}const n=tr(t),o=e.filter((t=>t.cfiWithoutAssertions.split("!")[0]===n));let i;if(o.length>0){i={start:o[0].label,end:o[o.length-1].label}}return i}async segmentInfo(){const{cfi:t,url:e}=await this._getPageInfo();return{cfi:t,pages:await this._getPageRange(t),url:e}}async uri(){const t=this._bookElement.getBookInfo().isbn;if(!t)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${t}`}async scrollToAnchor(t){return this._htmlIntegration.scrollToAnchor(t)}}function fr(t){if(void 0!==window.PDFViewerApplication)return new Zi({annotator:t,features:t.features});return"content"===cr()?new ur(document.body):new hi({features:t.features,sideBySideOptions:t.sideBySide})}function pr(){return St(_e,{classes:"fixed left-[10px] top-[10px]","data-testid":"outside-assignment-notice",status:"notice",variant:"raised",
155
+ children:"You are outside the page range for this assignment. Annotations made here may not be counted."})}class gr{constructor(t){this._visible=!1,this._container=new Pn("notice",(()=>this._render())),t.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(t){this._visible=t,this._container.render()}_render(){return this._visible?St(pr,{}):null}}class _r{constructor(t,e=document){let n=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{t(jn(e.getSelection()))}),n)},i=t=>{if("mousedown"===t.type&&(n=!0),"mouseup"===t.type&&(n=!1),n)return;this._cancelPendingCallback();const e="mouseup"===t.type?10:100;o(e)};this._document=e,this._listeners=new mt,this._listeners.add(e,"selectionchange",i),this._listeners.add(e.body,"mousedown",i),this._listeners.add(e.body,"mouseup",i),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),
156
+ this._pendingCallback=null)}}function mr(t,e){if(t===e)return!0;if(t.parent!==e)return!1;if(!t.frameElement)return!1;return t.frameElement.getBoundingClientRect().width/t.parent.innerWidth>=.8}function br(){return function(t,e){const n=new Set,o=new Set;return Yn(t,(t=>{for(;t&&!n.has(t);){n.add(t);const i=e(t);null!=i&&o.add(i),t=t.parentNode}})),[...o]}(jn()??new Range,(t=>t._annotation?.$tag))}function yr(t,e,n){return t.getHighlightsFromPoint(e,n).map((t=>t._annotation?.$tag)).filter((t=>void 0!==t))}function wr(t){if(!t.region)return null;if(!function(t){return void 0!==t&&"toRange"in t&&"function"==typeof t.toRange}(t.region))return t.region;try{return t.region.toRange()}catch{return null}}function vr(){document.getSelection()?.removeAllRanges()}class xr extends CustomEvent{constructor(t){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:t}),this._ready=null}get ready(){return this._ready}waitUntil(t){this._ready=t}}class Cr extends Me{constructor(t,e={},n=window){super(),this.element=t,
157
+ this._contentReady=e.contentReady,this._commentsMode=e.commentsMode??!1,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._highlighter=new Zn(this.element),this._adder=new Ln(this.element,{onAnnotate:()=>this.createAnnotationFromSelection(),onHighlight:()=>this.createAnnotationFromSelection({highlight:!0}),onShowAnnotations:t=>this.selectAnnotations(t,{focusInSidebar:!0})}),this._drawTool=new xo(this.element),this._drawTool.setOnKeyboardModeChange((t=>{this._hostRPC.call("keyboardModeChanged",t)})),this._setupGlobalKeyboardListener(),this._selectionObserver=new _r((t=>{t?this._onSelection(t):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=e.subFrameIdentifier||null,this._portFinder=new ke({hostFrame:this._hostFrame,source:"guest",sourceId:this._frameIdentifier??void 0}),this.features=new Mo,this._featureFlagsReceived=new Promise((t=>{
158
+ this.features.on("flagsChanged",t)})),this.sideBySide=e.sideBySide,this._integration=fr(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),e.contentInfoBanner&&this._integration.showContentInfo?.(e.contentInfoBanner),this._integration.canStyleClusteredHighlights?.()&&(this._clusterToolbar=new No(this._integration.contentContainer(),{features:this.features})),this._integration.on("supportedToolsChanged",(()=>this._notifySupportedToolsChanged())),this._hostRPC=new De,this._connectHost(n),this._sidebarRPC=new De,this._sidebarLayout=null,this._connectSidebar(),this._bucketBarClient=new ho({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new mt,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){return"manual"===this.sideBySide?.mode&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(t=>{
159
+ if(!document.getSelection()?.isCollapsed)return;const{clientX:e,clientY:n,metaKey:o,ctrlKey:i}=t,r=yr(this._highlighter,e,n);if(r.length){const t=o||i;this.selectAnnotations(r,{toggle:t})}})),this._listeners.add(this.element,"pointerdown",(t=>{this._sideBySideActive()||t.composedPath().some((t=>t instanceof Element&&t.localName.startsWith("hypothesis-")))||yr(this._highlighter,t.clientX,t.clientY).length||mr(window,this._hostFrame)&&this._sidebarLayout?.expanded&&window.innerWidth-t.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),this._listeners.add(this.element,"mouseover",(({clientX:t,clientY:e})=>{const n=yr(this._highlighter,t,e);n.length&&this._sidebarRPC.call("hoverAnnotations",n)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),this._listeners.add(this.element,"keydown",(t=>{this._handleShortcut(t)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){
160
+ const[t,e,n]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),this._integration.segmentInfo?.()]);return{uri:li(t),metadata:e,segmentInfo:n,persistent:this._integration.persistFrame?.()??!1}}async _sendDocumentInfo(){this._integration.waitForFeatureFlags?.()&&await this._featureFlagsReceived;const t=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",t)}_repositionAdder(){if(!this._isAdderVisible)return;const t=jn();t&&this._onSelection(t)}async _connectHost(t){this._hostRPC.on("clearSelection",(()=>{jn()&&(this._informHostOnNextSelectionClear=!1,vr())})),this._hostRPC.on("createAnnotation",(({tool:t})=>t?("rect"===t&&void 0===this._pendingKeyboardMode&&(this._pendingKeyboardMode="move"),this.createAnnotation(t)):(this._drawTool.cancel(),null))),this._hostRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._hostRPC.on("scrollToAnnotation",(t=>{this._scrollToAnnotation(t)})),this._hostRPC.on("selectAnnotations",((t,e)=>this.selectAnnotations(t,{toggle:e
161
+ }))),this._hostRPC.on("setKeyboardMode",(({mode:t})=>{["move","resize","rect"].includes(t)&&this._drawTool.setKeyboardMode(t)})),this._hostRPC.on("activateMoveMode",(()=>{this._activateToolWithMoveMode("rect")})),this._hostRPC.on("activatePointMoveMode",(()=>{this._activateToolWithMoveMode("point")})),this._hostRPC.on("sidebarLayoutChanged",(e=>{mr(window,t)&&this.fitSideBySide(e),this.element.dispatchEvent(new Co({sidebarLayout:e,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected"))),this._notifySupportedToolsChanged();const e=await this._portFinder.discover("host");this._hostRPC.connect(e)}_notifySupportedToolsChanged(){this._hostRPC.call("supportedToolsChanged",this._integration.supportedTools())}async _scrollToAnchor(t){const e=wr(t);if(!e)return;let n;e instanceof Range?n=e:(n=new Range,n.selectNodeContents(e.anchor));const o=new xr(n);this.element.dispatchEvent(o)&&(await o.ready,await this._integration.scrollToAnchor(t))}
162
+ async _scrollToAnnotation(t){const e=this.anchors.find((e=>e.annotation.$tag===t));e?.highlights&&await this._scrollToAnchor(e)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(t=>this.features.update(t))),this._sidebarRPC.on("shortcutsUpdated",(t=>{wn(t)})),this._sidebarRPC.on("hoverAnnotations",(t=>this._hoverAnnotations(t))),this._sidebarRPC.on("scrollToAnnotation",(t=>{this._scrollToAnnotation(t)})),this._sidebarRPC.on("setHighlightsVisible",(t=>{this.setHighlightsVisible(t,!1)})),this._sidebarRPC.on("deleteAnnotation",(t=>this.detach(t))),this._sidebarRPC.on("getDocumentInfo",(async t=>t(await this.getDocumentInfo()))),this._sidebarRPC.on("loadAnnotations",(async t=>{try{await Promise.all(t.map((t=>this.anchor(t))))}catch(t){console.warn("Failed to anchor annotations:",t)}})),this._sidebarRPC.on("showContentInfo",(t=>this._integration.showContentInfo?.(t))),this._sidebarRPC.on("setOutsideAssignmentNoticeVisible",(t=>{this._setOutsideAssignmentNoticeVisible(t)})),
163
+ this._sidebarRPC.on("navigateToSegment",(t=>this._integration.navigateToSegment?.(t))),this._sidebarRPC.on("renderThumbnail",((t,e,n)=>{(async()=>{if(!this._integration.renderToBitmap)throw new Error("Thumbnail rendering not supported for document type");const n=this.anchors.find((e=>e.annotation.$tag===t));if(!n)throw new Error("Annotation not anchored in guest");return this._integration.renderToBitmap(n,e)})().then((t=>n({ok:!0,value:t}))).catch((t=>n({ok:!1,error:t.message})))})),this._portFinder.discover("sidebar").then((t=>{this._sidebarRPC.connect(t)})),this._sendDocumentInfo()}destroy(){this._drawTool.destroy(),this._portFinder.destroy(),this._hostRPC.destroy(),this._sidebarRPC.destroy(),this._listeners.removeAll(),this._selectionObserver.disconnect(),this._adder.destroy(),this._bucketBarClient.destroy(),this._clusterToolbar?.destroy(),this._outsideAssignmentNotice?.destroy(),this._highlighter.removeAllHighlights(),this._integration.destroy(),this._globalKeyboardListenerCleanup?.(),super.destroy()}
164
+ _isKeyboardAnnotationModeEnabled(){return this.features.flagEnabled("vpat_keyboard")}_setupGlobalKeyboardListener(){const t=t=>{if(Ge(t.target))return;if(!this._isKeyboardAnnotationModeEnabled())return;const e=yn(),n=this._integration.supportedTools(),o=n.includes("rect"),i=n.includes("point"),r=e.activateRectMove;if(r&&un(t,r)&&o){t.preventDefault(),t.stopPropagation();return void(this._drawTool.getKeyboardModeState().keyboardActive?this._drawTool.setKeyboardMode("move"):(this._pendingKeyboardMode="move",this.createAnnotation("rect").catch((()=>{this._pendingKeyboardMode=void 0}))))}const s=e.activateRectResize;if(s&&un(t,s)&&o){t.preventDefault(),t.stopPropagation();return void(this._drawTool.getKeyboardModeState().keyboardActive?this._drawTool.setKeyboardMode("resize"):(this._pendingKeyboardMode="resize",this.createAnnotation("rect").catch((()=>{this._pendingKeyboardMode=void 0}))))}const a=e.activatePoint;if(a&&un(t,a)&&i){t.preventDefault(),t.stopPropagation()
165
+ ;this._drawTool.getKeyboardModeState().keyboardActive||(this._pendingKeyboardMode="move",this.createAnnotation("point").catch((()=>{this._pendingKeyboardMode=void 0})))}else;};document.body.addEventListener("keydown",t),this._globalKeyboardListenerCleanup=()=>{document.body.removeEventListener("keydown",t)}}async anchor(t){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const e=t=>{const e=wr(t);if(!e)return;let n;n=e instanceof Range?this._highlighter.highlightRange(e,t.annotation?.$cluster):this._highlighter.highlightShape(e),n.forEach((e=>{e._annotation=t.annotation})),t.highlights=n,this._hoveredAnnotations.has(t.annotation.$tag)&&this._highlighter.setHighlightsFocused(n,!0)};this.detach(t.$tag,!1),this._annotations.add(t.$tag),t.target||(t.target=[]);const n=await Promise.all(t.target.map((async e=>{if(!e.selector||!e.selector.some((t=>"TextQuoteSelector"===t.type||"ShapeSelector"===t.type)))return{annotation:t,target:e};let n;try{
166
+ const o=await this._integration.anchor(this.element,e.selector);if(o instanceof Range){const i=Un.fromRange(o);n={annotation:t,target:e,region:i}}else n={annotation:t,target:e,region:o}}catch{n={annotation:t,target:e}}return n})));if(!this._annotations.has(t.$tag))return[];for(const t of n)e(t);return t.$orphan=n.length>0&&n.every((t=>t.target.selector&&!t.region)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",t),n}detach(t,e=!0){this._annotations.delete(t);const n=[];for(const e of this.anchors)e.annotation.$tag!==t?n.push(e):e.highlights&&this._highlighter.removeHighlights(e.highlights);this._updateAnchors(n,e)}_updateAnchors(t,e){this.anchors=t,this._clusterToolbar?.scheduleClusterUpdates(),e&&this._bucketBarClient.update(this.anchors)}async createAnnotation(t){if("selection"===t)return this.createAnnotationFromSelection();if(!["rect","point"].includes(t))throw new Error("Unsupported annotation tool");{let e=!1;try{this._hostRPC.call("activeToolChanged",t)
167
+ ;const e=this._pendingKeyboardMode;this._pendingKeyboardMode=void 0;const n=await this._drawTool.draw(t,e),o=await this.getDocumentInfo(),i=[{source:o.uri,selector:await this._integration.describe(this.element,n)}],r={uri:o.uri,document:o.metadata,target:i,$tag:"a:"+Ce(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),r}catch(t){if(t instanceof vo&&["canceled","restarted"].includes(t.kind))return e="restarted"===t.kind,null;throw t}finally{e||this._hostRPC.call("activeToolChanged",null)}}}_activateToolWithMoveMode(t){this._drawTool.getKeyboardModeState().keyboardActive?this._drawTool.setKeyboardMode("move"):(this._pendingKeyboardMode="move",this.createAnnotation(t).catch((()=>{this._pendingKeyboardMode=void 0})))}async createAnnotationFromSelection({highlight:t=!1}={}){const e=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(e.map((t=>this._integration.describe(o,t))))).map((t=>({source:n.uri,selector:t}))),r={uri:n.uri,
168
+ document:n.metadata,target:i,$highlight:t,$cluster:t?"user-highlights":"user-annotations",$tag:"a:"+Ce(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),vr(),r}_hoverAnnotations(t){this._hoveredAnnotations.clear(),t.forEach((t=>this._hoveredAnnotations.add(t)));for(const e of this.anchors)if(e.highlights){const n=t.includes(e.annotation.$tag);this._highlighter.setHighlightsFocused(e.highlights,n)}this._sidebarRPC.call("hoverAnnotations",t)}_onSelection(t){const e=this._integration.getAnnotatableRange(t);if(!e)return void this._onClearSelection();const n=document.getSelection(),o=Kn(n),i=Gn(n);i?(this.selectedRanges=[e],this._hostRPC.call("textSelected"),this._commentsMode||(this._adder.annotationsForSelection=br(),this._isAdderVisible=!0,this._adder.show(i,o))):this._onClearSelection()}_onClearSelection(){this._isAdderVisible=!1,this._adder.hide(),this.selectedRanges=[],this._informHostOnNextSelectionClear&&this._hostRPC.call("textUnselected"),this._informHostOnNextSelectionClear=!0}
169
+ selectAnnotations(t,{toggle:e=!1,focusInSidebar:n=!1}={}){e?this._sidebarRPC.call("toggleAnnotationSelection",t):this._sidebarRPC.call("showAnnotations",t,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(t,e=!0){this._highlighter.setHighlightsVisible(t),this._highlightsVisible=t,e&&this._hostRPC.call("highlightsVisibleChanged",t)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(t){this._sidebarLayout=t,this._integration.fitSideBySide(t)}get hoveredAnnotationTags(){return this._hoveredAnnotations}_handleShortcut(t){const e=yn().toggleHighlights;e&&un(t,e)&&this.setHighlightsVisible(!this._highlightsVisible&&!this._commentsMode)}_setOutsideAssignmentNoticeVisible(t){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new gr(this.element)),this._outsideAssignmentNotice.setVisible(t)}}function Sr(t,e){const n=new URL(t),o=new URLSearchParams;return o.append("config",JSON.stringify(e)),n.hash=o.toString(),n.toString()}function Ar(t,e){const n={}
170
+ ;for(const[t,o]of Object.entries(e))"notebookAppUrl"!==t&&"sidebarAppUrl"!==t&&null!=o&&(n[t]=o);n.origin=new URL(t).origin,n.version="1.1750.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const t=n.services[0];t.onLoginRequest&&(t.onLoginRequestProvided=!0),t.onLogoutRequest&&(t.onLogoutRequestProvided=!0),t.onSignupRequest&&(t.onSignupRequestProvided=!0),t.onProfileRequest&&(t.onProfileRequestProvided=!0),t.onHelpRequest&&(t.onHelpRequestProvided=!0)}return n}function kr({closed:t,onClose:e,children:n,className:o,"data-testid":i,"aria-label":r}){const s=it(null);return nt((()=>{t?s.current?.close():s.current?.showModal()}),[t]),nt((()=>{const t=s.current;return t?.addEventListener("cancel",e),()=>{t?.removeEventListener("cancel",e)}}),[e]),St("dialog",{ref:s,className:Tt("relative m-5 w-full h-full backdrop:bg-black/50",o),"data-testid":i,"aria-label":r,children:n})}function Mr({closed:t,children:e,className:n,...o}){
171
+ return St("div",{...o,className:Tt("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:t}),children:St("div",{className:Tt("relative w-full h-full",n),children:e})})}function Rr({document_:t=document,...e}){return St(rt((()=>function(t){return"function"==typeof t.createElement("dialog").showModal}(t)?kr:Mr),[t]),{...e})}function Er({config:t,groupId:e}){return St("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Sr(t.notebookAppUrl,{...Ar(t.notebookAppUrl,t),group:e})})}function Pr({eventBus:t,config:e}){const[n,o]=et(0),[i,r]=et(!0),[s,a]=et(null),l=it(""),c=it(null);nt((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),nt((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),nt((()=>{const e=t.createEmitter();return e.subscribe("openNotebook",(t=>{r(!1),o((t=>t+1)),a(t)})),c.current=e,()=>{e.destroy()}}),[t]);const h=st((()=>{r(!0),
172
+ c.current?.publish("closeNotebook")}),[]);return null===s?null:St(Rr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[St("div",{className:"absolute right-0 m-3",children:St(oe,{title:"Close notebook",onClick:h,variant:"dark",classes:Tt("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:St(It,{className:"w-4 h-4"})})}),St(Er,{config:e,groupId:s},n)]})}class Tr{constructor(t,e,n){this._container=new Pn("notebook",(()=>St(Pr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Nr({eventBus:t,config:e}){const[n,o]=et(!0),i=it(null);nt((()=>{const e=t.createEmitter();return e.subscribe("openProfile",(()=>{o(!1)})),i.current=e,()=>{e.destroy()}}),[t]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:St(Rr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[St("div",{className:"absolute right-0 m-3",
173
+ children:St(oe,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Tt("!bg-transparent enabled:hover:!bg-grey-3"),children:St(It,{className:"w-4 h-4"})})}),St("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:e.profileAppUrl})]})}class Lr{constructor(t,e,n){this._container=new Pn("profile",(()=>St(Nr,{eventBus:e,config:n}))),t.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function Or({above:t,below:e,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){const s=t.anchors.length>0,a=e.anchors.length>0,l=t=>t.anchors.map((t=>t.tag));return St("ul",{className:"relative",children:[s&&St("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:t.position},children:St(ve,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const e=[...t.anchors].sort(((t,e)=>t.bottom-e.bottom)),n=e[e.length-1];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(t)),onMouseEnter:()=>o(l(t)),
174
+ onMouseOut:()=>o([]),title:`Go up to next annotations (${t.anchors.length})`,children:t.anchors.length})}),n.map(((t,e)=>St("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:t.position},children:St(ve,{direction:"left",onClick:e=>r(l(t),e.metaKey||e.ctrlKey),onBlur:()=>o([]),onFocus:()=>o(l(t)),onMouseEnter:()=>o(l(t)),onMouseOut:()=>o([]),title:`Select nearby annotations (${t.anchors.length})`,children:t.anchors.length})},e))),a&&St("li",{className:"absolute right-0 pointer-events-auto",style:{top:e.position},children:St(ve,{"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const t=[...e.anchors].sort(((t,e)=>t.top-e.top)),n=t[0];i(n.tag)},onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Go up to next annotations (${e.anchors.length})`,children:e.anchors.length})})]})}class Ir{constructor(t,{onFocusAnnotations:e,onScrollToAnnotation:n,onSelectAnnotations:o}){this._positions=[],
175
+ this._container=new Pn("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),t.appendChild(this._container.element),this._onFocusAnnotations=e,this._onScrollToAnnotation=n,this._onSelectAnnotations=o,this._container.render()}destroy(){this._container.destroy()}update(t){this._positions=t,this._container.render()}_render(){const t=function(t,e){const n=[],o=[],i=[];let r=null;function s(t){const{bottom:e,top:n}=t;return{bottom:e,position:n+(e-n)/2,anchors:[t],top:n}}const a=e.getBoundingClientRect(),l=t.map((t=>({tag:t.tag,top:t.top-a.top,bottom:t.bottom-a.top})));for(const t of l){const e=(t.top+t.bottom)/2;if(e<30){n.push(t);continue}if(e>a.height-30){o.push(t);continue}if(!r){r=s(t);continue}const l=t.top>r.top&&t.bottom<r.bottom;if(t.top-r.bottom>60&&!l)i.push(r),r=s(t);else{const e=t.bottom>r.bottom?t.bottom:r.bottom,n=e-r.top;r.anchors.push(t),r.bottom=e,r.position=r.top+n/2}}return r&&i.push(r),{above:{anchors:n,position:25},below:{
176
+ anchors:o,position:a.height-30},buckets:i}}(this._positions,this._container.element);return St(Or,{above:t.above,below:t.below,buckets:t.buckets,onFocusAnnotations:t=>this._onFocusAnnotations(t),onScrollToAnnotation:t=>this._onScrollToAnnotation(t),onSelectAnnotations:(t,e)=>this._onSelectAnnotations(t,e)})}}function Br({emitter:t}){const[e,n]=et([]),o=st((t=>n((e=>[...e,t]))),[]),i=st((t=>n((e=>e.filter((e=>e.id!==t))))),[]);return nt((()=>(t.subscribe("toastMessageAdded",o),t.subscribe("toastMessageDismissed",i),()=>{t.unsubscribe("toastMessageAdded",o),t.unsubscribe("toastMessageDismissed",i)})),[t,i,o]),St(ye,{messages:e,onMessageDismiss:i})}function Dr(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",...t,children:[St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor","clip-rule":"evenodd",
177
177
  d:"M2.5 0h-1A1.5 1.5 0 0 0 0 1.5v1 a1.5 1.5 0 0 0 1 1.415v8.17 A1.5 1.5 0 0 0 0 13.5v1 A1.5 1.5 0 0 0 1.5 16h1 a1.5 1.5 0 0 0 1.415-1h8.17 a1.5 1.5 0 0 0 1.415 1h1 a1.5 1.5 0 0 0 1.5-1.5v-1 a1.5 1.5 0 0 0-1-1.415v-8.17 A1.5 1.5 0 0 0 16 2.5v-1 A1.5 1.5 0 0 0 14.5 0h-1 a1.5 1.5 0 0 0-1.415 1h-8.17 A1.5 1.5 0 0 0 2.5 0 m9.585 13 c.151-.426.489-.764.915-.915v-8.17 A1.5 1.5 0 0 1 12.085 3h-8.17 c-.151.426-.489.764-.915.915v8.17 c.426.151.764.489.915.915z M1 1.5 a.5.5 0 0 1 .5-.5h1 a.5.5 0 0 1 .5.5v1 a.5.5 0 0 1-.5.5h-1 a.5.5 0 0 1-.5-.5z M1.5 13 a.5.5 0 0 0-.5.5v1 a.5.5 0 0 0 .5.5h1 a.5.5 0 0 0 .5-.5v-1 a.5.5 0 0 0-.5-.5z M13 1.5 a.5.5 0 0 1 .5-.5h1 a.5.5 0 0 1 .5.5v1 a.5.5 0 0 1-.5.5h-1 a.5.5 0 0 1-.5-.5z m.5 11.5 a.5.5 0 0 0-.5.5v1 a.5.5 0 0 0 .5.5h1 a.5.5 0 0 0 .5-.5v-1 a.5.5 0 0 0-.5-.5z"})]}),St("g",{transform:"translate(3 3) scale(0.0833)",stroke:"currentColor","stroke-width":"10","stroke-linecap":"round","stroke-linejoin":"round",fill:"none",children:[St("path",{d:"M60 15 L60 48"}),St("path",{
178
178
  d:"M45 30 L60 15 L75 30"}),St("path",{d:"M60 72 L60 105"}),St("path",{d:"M45 90 L60 105 L75 90"}),St("path",{d:"M15 60 L48 60"}),St("path",{d:"M30 45 L15 60 L30 75"}),St("path",{d:"M72 60 L105 60"}),St("path",{d:"M90 45 L105 60 L90 75"})]})]})}function Fr(t){return St("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",...t,children:[St("g",{"fill-rule":"evenodd",children:[St("path",{fill:"none",d:"M0 0h16v16H0z"}),St("path",{fill:"currentColor","clip-rule":"evenodd",
179
179
  d:"M2.5 0h-1A1.5 1.5 0 0 0 0 1.5v1 a1.5 1.5 0 0 0 1 1.415v8.17 A1.5 1.5 0 0 0 0 13.5v1 A1.5 1.5 0 0 0 1.5 16h1 a1.5 1.5 0 0 0 1.415-1h8.17 a1.5 1.5 0 0 0 1.415 1h1 a1.5 1.5 0 0 0 1.5-1.5v-1 a1.5 1.5 0 0 0-1-1.415v-8.17 A1.5 1.5 0 0 0 16 2.5v-1 A1.5 1.5 0 0 0 14.5 0h-1 a1.5 1.5 0 0 0-1.415 1h-8.17 A1.5 1.5 0 0 0 2.5 0 m9.585 13 c.151-.426.489-.764.915-.915v-8.17 A1.5 1.5 0 0 1 12.085 3h-8.17 c-.151.426-.489.764-.915.915v8.17 c.426.151.764.489.915.915z M1 1.5 a.5.5 0 0 1 .5-.5h1 a.5.5 0 0 1 .5.5v1 a.5.5 0 0 1-.5.5h-1 a.5.5 0 0 1-.5-.5z M1.5 13 a.5.5 0 0 0-.5.5v1 a.5.5 0 0 0 .5.5h1 a.5.5 0 0 0 .5-.5v-1 a.5.5 0 0 0-.5-.5z M13 1.5 a.5.5 0 0 1 .5-.5h1 a.5.5 0 0 1 .5.5v1 a.5.5 0 0 1-.5.5h-1 a.5.5 0 0 1-.5-.5z m.5 11.5 a.5.5 0 0 0-.5.5v1 a.5.5 0 0 0 .5.5h1 a.5.5 0 0 0 .5-.5v-1 a.5.5 0 0 0-.5-.5z"})]}),St("g",{transform:"translate(3 3) scale(0.0833)",stroke:"currentColor","stroke-width":"18","stroke-linecap":"round","stroke-linejoin":"round",fill:"none",children:[St("path",{d:"M30 30 L55 55"}),St("path",{
180
- d:"M65 65 L90 90"}),St("path",{d:"M30 45 L30 30 L45 30"}),St("path",{d:"M75 90 L90 90 L90 75"})]})]})}function Hr(t,e,n){return t&&"rect"===e?"move"===n?"Move mode (Ctrl+Shift+Y) - Click to switch to Resize mode":"resize"===n?"Resize mode (Ctrl+Shift+J) - Click to switch to Rectangle mode":"Rectangle mode - Click to switch to Move mode":"Rectangle annotation"}function zr(t,e){return n=>{"Enter"===n.key&&t&&!e&&(n.preventDefault(),n.stopPropagation(),t())}}function Vr({mode:t}){return St("move"===t?Dr:"resize"===t?Fr:Zt,{})}function Ur({icon:t,pressedBackground:e=!0,...n}){return St(ee,{classes:Tt("justify-center rounded","w-[30px] h-[30px] touch:h-[40px]","shadow border bg-white text-grey-6 hover:text-grey-9",e&&"aria-pressed:bg-grey-3"),...n,size:"custom",variant:"custom",children:St(t,{})})}function $r({highlightsVisible:t}){return St("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}
180
+ d:"M65 65 L90 90"}),St("path",{d:"M30 45 L30 30 L45 30"}),St("path",{d:"M75 90 L90 90 L90 75"})]})]})}function Hr(t,e,n){return t&&"rect"===e?"move"===n?"Move mode (Ctrl+Shift+Y) - Click to switch to Resize mode":"resize"===n?"Resize mode (Ctrl+Shift+J) - Click to switch to Rectangle mode":"Rectangle mode - Click to switch to Move mode":"Rectangle annotation"}function Vr(t,e){return n=>{"Enter"===n.key&&t&&!e&&(n.preventDefault(),n.stopPropagation(),t())}}function zr({mode:t}){return St("move"===t?Dr:"resize"===t?Fr:Zt,{})}function Ur({icon:t,pressedBackground:e=!0,...n}){return St(ee,{classes:Tt("justify-center rounded","w-[30px] h-[30px] touch:h-[40px]","shadow border bg-white text-grey-6 hover:text-grey-9",e&&"aria-pressed:bg-grey-3"),...n,size:"custom",variant:"custom",children:St(t,{})})}function $r({highlightsVisible:t}){return St("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:t?"Highlights visible":"Highlights hidden"})}
181
181
  function qr({activeTool:t=null,closeSidebar:e,createAnnotation:n,isSidebarOpen:o,sidebarContainerId:i,newAnnotationType:r,showHighlights:s,supportedTools:a=["selection"],toggleHighlights:l,toggleSidebar:c,toggleSidebarRef:h,useMinimalControls:d=!1,keyboardMode:u=null,keyboardActive:f=!1,onModeClick:p,onActivateMoveMode:g,onActivatePointMoveMode:_}){return St("div",{className:Tt({"absolute right-full":d,"relative right-[11px]":!d},"w-[33px] z-2","text-px-base leading-none"),children:[d&&o&&St(ee,{classes:Tt("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-[6px]","flex items-center justify-center bg-white border","text-grey-6 hover:text-grey-9 transition-colors","border-r-0","shadow-sidebar"),title:"Close annotation sidebar",onClick:e,unstyled:!0,children:St(It,{})}),!d&&St(y,{children:[St(ee,{classes:Tt("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px] rounded-bl","bg-white text-grey-6 hover:text-grey-9","border-l border-b"),elementRef:h,
182
- title:"Annotation sidebar",expanded:o,"aria-controls":i,onClick:c,unstyled:!0,children:St(o?Ft:Dt,{})}),St("div",{className:"space-y-[6px] mt-[8px]",children:[St(Ur,{title:"Show highlights",icon:s?te:$t,pressed:s,pressedBackground:!1,onClick:l}),a.includes("selection")&&St(Ur,{"data-testid":"text-annotation",title:"note"===r?"New page note":"New annotation",icon:"note"===r?Kt:Ot,onClick:()=>n("selection")}),a.includes("rect")&&St(Ur,{"data-testid":"rect-annotation",pressed:"rect"===t,title:Hr(f,t,u??null),icon:f&&"rect"===t?()=>St(Vr,{mode:u??"rect"}):Zt,onClick:()=>{f&&"rect"===t?p?.():n("rect"===t?null:"rect")},onKeyDown:zr(g,f)}),a.includes("point")&&St(Ur,{"data-testid":"point-annotation",pressed:"point"===t,title:"Pin annotation",icon:Xt,onClick:()=>n("point"===t?null:"point"),onKeyDown:zr(_,f)})]}),St($r,{highlightsVisible:s})]})]})}class Wr{constructor(t,e){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=e;this.container=t,this._activeTool=null,this._useMinimalControls=!1,
182
+ title:"Annotation sidebar",expanded:o,"aria-controls":i,onClick:c,unstyled:!0,children:St(o?Ft:Dt,{})}),St("div",{className:"space-y-[6px] mt-[8px]",children:[St(Ur,{title:"Show highlights",icon:s?te:$t,pressed:s,pressedBackground:!1,onClick:l}),a.includes("selection")&&St(Ur,{"data-testid":"text-annotation",title:"note"===r?"New page note":"New annotation",icon:"note"===r?Kt:Ot,onClick:()=>n("selection")}),a.includes("rect")&&St(Ur,{"data-testid":"rect-annotation",pressed:"rect"===t,title:Hr(f,t,u??null),icon:f&&"rect"===t?()=>St(zr,{mode:u??"rect"}):Zt,onClick:()=>{f&&"rect"===t?p?.():n("rect"===t?null:"rect")},onKeyDown:Vr(g,f)}),a.includes("point")&&St(Ur,{"data-testid":"point-annotation",pressed:"point"===t,title:"Pin annotation",icon:Xt,onClick:()=>n("point"===t?null:"point"),onKeyDown:Vr(_,f)})]}),St($r,{highlightsVisible:s})]})]})}class Wr{constructor(t,e){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=e;this.container=t,this._activeTool=null,this._useMinimalControls=!1,
183
183
  this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._sidebarContainerId=e.sidebarContainerId,this._supportedAnnotationTools=["selection"],this._keyboardMode=null,this._keyboardActive=!1,this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>i(!this._highlightsVisible),this._createAnnotation=t=>{n(t),"selection"===t&&o(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this.container.firstChild.getBoundingClientRect().width}set activeTool(t){this._activeTool=t,this.render()}get activeTool(){return this._activeTool}set useMinimalControls(t){this._useMinimalControls=t,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(t){this._sidebarOpen=t,this.render()}get sidebarOpen(){return this._sidebarOpen}set newAnnotationType(t){this._newAnnotationType=t,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(t){this._highlightsVisible=t,
184
184
  this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}set supportedAnnotationTools(t){this._supportedAnnotationTools=t,this.render()}get supportedAnnotationTools(){return this._supportedAnnotationTools}set keyboardModeState(t){this._keyboardActive=t.keyboardActive,this._keyboardMode=t.keyboardMode,this.render()}get keyboardModeState(){return{keyboardActive:this._keyboardActive,keyboardMode:this._keyboardMode}}set modeButtonCallbacks(t){this._onModeClick=t.onModeClick,this._onActivateMoveMode=t.onActivateMoveMode,this._onActivatePointMoveMode=t.onActivatePointMoveMode,this.render()}get modeButtonCallbacks(){return{onModeClick:this._onModeClick,onActivateMoveMode:this._onActivateMoveMode,onActivatePointMoveMode:this._onActivatePointMoveMode}}render(){H(St(qr,{activeTool:this._activeTool,closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,
185
185
  sidebarContainerId:this._sidebarContainerId,showHighlights:this._highlightsVisible,supportedTools:this._supportedAnnotationTools,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls,keyboardMode:this._keyboardMode,keyboardActive:this._keyboardActive,onModeClick:this._onModeClick,onActivateMoveMode:this._onActivateMoveMode,onActivatePointMoveMode:this._onActivatePointMoveMode}),this.container)}}class jr{constructor({target:t,threshold:e=10,onDrag:n}){t.style.touchAction="none",this._listeners=new mt,this._startX=null,this._dragActive=!1,this._threshold=e,this._listeners.add(t,"pointerdown",(t=>{this._startX=t.clientX}));const o=t=>{if(null!==this._startX&&this._dragActive){const e=t.clientX-this._startX;n({type:"dragend",deltaX:e})}this._startX=null,this._dragActive=!1};this._listeners.add(window,"pointercancel",o),this._listeners.add(window,"pointerup",o),this._listeners.add(window,"pointermove",(t=>{