@internetarchive/bookreader 5.0.0-95 → 5.0.0-96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/BookReader.css +2251 -0
- package/BookReader/BookReader.js +3 -0
- package/BookReader/BookReader.js.LICENSE.txt +72 -0
- package/BookReader/BookReader.js.map +1 -0
- package/BookReader/hypothesis/LICENSE +50 -0
- package/BookReader/hypothesis/README.md +55 -0
- package/BookReader/hypothesis/build/boot.js +1 -0
- package/BookReader/hypothesis/build/manifest.json +20 -0
- package/BookReader/hypothesis/build/scripts/annotator.bundle.js +184 -0
- package/BookReader/hypothesis/build/scripts/annotator.bundle.js.map +1 -0
- package/BookReader/hypothesis/build/scripts/sidebar.bundle.js +798 -0
- package/BookReader/hypothesis/build/scripts/sidebar.bundle.js.map +1 -0
- package/BookReader/hypothesis/build/scripts/ui-playground.bundle.js +711 -0
- package/BookReader/hypothesis/build/scripts/ui-playground.bundle.js.map +1 -0
- package/BookReader/hypothesis/build/styles/annotator.css +2235 -0
- package/BookReader/hypothesis/build/styles/annotator.css.map +1 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/BookReader/hypothesis/build/styles/highlights.css +2 -0
- package/BookReader/hypothesis/build/styles/highlights.css.map +1 -0
- package/BookReader/hypothesis/build/styles/katex.min.css +2 -0
- package/BookReader/hypothesis/build/styles/katex.min.css.map +1 -0
- package/BookReader/hypothesis/build/styles/pdfjs-overrides.css +2 -0
- package/BookReader/hypothesis/build/styles/pdfjs-overrides.css.map +1 -0
- package/BookReader/hypothesis/build/styles/sidebar.css +2731 -0
- package/BookReader/hypothesis/build/styles/sidebar.css.map +1 -0
- package/BookReader/hypothesis/build/styles/ui-playground.css +2659 -0
- package/BookReader/hypothesis/build/styles/ui-playground.css.map +1 -0
- package/BookReader/hypothesis/package.json +126 -0
- package/BookReader/ia-bookreader-bundle.js +1782 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -0
- package/BookReader/icons/2up.svg +1 -0
- package/BookReader/icons/advance.svg +3 -0
- package/BookReader/icons/chevron-right.svg +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/close-circle.svg +1 -0
- package/BookReader/icons/fullscreen.svg +1 -0
- package/BookReader/icons/fullscreen_exit.svg +1 -0
- package/BookReader/icons/hamburger.svg +1 -0
- package/BookReader/icons/left-arrow.svg +1 -0
- package/BookReader/icons/magnify-minus.svg +1 -0
- package/BookReader/icons/magnify-plus.svg +1 -0
- package/BookReader/icons/magnify.svg +1 -0
- package/BookReader/icons/pause.svg +1 -0
- package/BookReader/icons/play.svg +1 -0
- package/BookReader/icons/playback-speed.svg +1 -0
- package/BookReader/icons/read-aloud.svg +1 -0
- package/BookReader/icons/review.svg +3 -0
- package/BookReader/icons/thumbnails.svg +1 -0
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -0
- package/BookReader/images/BRicons.png +0 -0
- package/BookReader/images/BRicons.svg +5 -0
- package/BookReader/images/BRicons_ia.png +0 -0
- package/BookReader/images/back_pages.png +0 -0
- package/BookReader/images/book_bottom_icon.png +0 -0
- package/BookReader/images/book_down_icon.png +0 -0
- package/BookReader/images/book_left_icon.png +0 -0
- package/BookReader/images/book_leftmost_icon.png +0 -0
- package/BookReader/images/book_right_icon.png +0 -0
- package/BookReader/images/book_rightmost_icon.png +0 -0
- package/BookReader/images/book_top_icon.png +0 -0
- package/BookReader/images/book_up_icon.png +0 -0
- package/BookReader/images/books_graphic.svg +1 -0
- package/BookReader/images/booksplit.png +0 -0
- package/BookReader/images/control_pause_icon.png +0 -0
- package/BookReader/images/control_play_icon.png +0 -0
- package/BookReader/images/embed_icon.png +0 -0
- package/BookReader/images/hypothesis.ico +0 -0
- package/BookReader/images/icon-home-ia.png +0 -0
- package/BookReader/images/icon_OL-logo-xs.png +0 -0
- package/BookReader/images/icon_alert-xs.png +0 -0
- package/BookReader/images/icon_book.svg +1 -0
- package/BookReader/images/icon_bookmark.svg +1 -0
- package/BookReader/images/icon_close-pop.png +0 -0
- package/BookReader/images/icon_download.png +0 -0
- package/BookReader/images/icon_gear.svg +1 -0
- package/BookReader/images/icon_hamburger.svg +1 -0
- package/BookReader/images/icon_home.png +0 -0
- package/BookReader/images/icon_home.svg +1 -0
- package/BookReader/images/icon_home_ia.png +0 -0
- package/BookReader/images/icon_indicator.png +0 -0
- package/BookReader/images/icon_info.svg +1 -0
- package/BookReader/images/icon_one_page.svg +1 -0
- package/BookReader/images/icon_pause.svg +1 -0
- package/BookReader/images/icon_play.svg +1 -0
- package/BookReader/images/icon_playback-rate.svg +1 -0
- package/BookReader/images/icon_return.png +0 -0
- package/BookReader/images/icon_search_button.svg +1 -0
- package/BookReader/images/icon_share.svg +1 -0
- package/BookReader/images/icon_skip-ahead.svg +1 -0
- package/BookReader/images/icon_skip-back.svg +2 -0
- package/BookReader/images/icon_speaker.svg +1 -0
- package/BookReader/images/icon_speaker_open.svg +1 -0
- package/BookReader/images/icon_thumbnails.svg +1 -0
- package/BookReader/images/icon_toc.svg +1 -0
- package/BookReader/images/icon_two_pages.svg +1 -0
- package/BookReader/images/icon_zoomer.png +0 -0
- package/BookReader/images/loading.gif +0 -0
- package/BookReader/images/logo_icon.png +0 -0
- package/BookReader/images/marker_chap-off.png +0 -0
- package/BookReader/images/marker_chap-off.svg +1 -0
- package/BookReader/images/marker_chap-off_ia.png +0 -0
- package/BookReader/images/marker_chap-on.png +0 -0
- package/BookReader/images/marker_chap-on.svg +1 -0
- package/BookReader/images/marker_srch-on.svg +1 -0
- package/BookReader/images/marker_srchchap-off.png +0 -0
- package/BookReader/images/marker_srchchap-on.png +0 -0
- package/BookReader/images/nav_control-dn.png +0 -0
- package/BookReader/images/nav_control-dn_ia.png +0 -0
- package/BookReader/images/nav_control-up.png +0 -0
- package/BookReader/images/nav_control-up_ia.png +0 -0
- package/BookReader/images/nav_control.png +0 -0
- package/BookReader/images/one_page_mode_icon.png +0 -0
- package/BookReader/images/paper-badge.png +0 -0
- package/BookReader/images/print_icon.png +0 -0
- package/BookReader/images/progressbar.gif +0 -0
- package/BookReader/images/right_edges.png +0 -0
- package/BookReader/images/slider.png +0 -0
- package/BookReader/images/slider_ia.png +0 -0
- package/BookReader/images/thumbnail_mode_icon.png +0 -0
- package/BookReader/images/transparent.png +0 -0
- package/BookReader/images/two_page_mode_icon.png +0 -0
- package/BookReader/images/unviewable_page.png +0 -0
- package/BookReader/images/zoom_in_icon.png +0 -0
- package/BookReader/images/zoom_out_icon.png +0 -0
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +2 -0
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -0
- package/BookReader/plugins/plugin.autoplay.js +2 -0
- package/BookReader/plugins/plugin.autoplay.js.map +1 -0
- package/BookReader/plugins/plugin.chapters.js +26 -0
- package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.chapters.js.map +1 -0
- package/BookReader/plugins/plugin.experiments.js +3 -0
- package/BookReader/plugins/plugin.experiments.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.experiments.js.map +1 -0
- package/BookReader/plugins/plugin.iframe.js +2 -0
- package/BookReader/plugins/plugin.iframe.js.map +1 -0
- package/BookReader/plugins/plugin.iiif.js +2 -0
- package/BookReader/plugins/plugin.iiif.js.map +1 -0
- package/BookReader/plugins/plugin.resume.js +2 -0
- package/BookReader/plugins/plugin.resume.js.map +1 -0
- package/BookReader/plugins/plugin.search.js +3 -0
- package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.search.js.map +1 -0
- package/BookReader/plugins/plugin.text_selection.js +3 -0
- package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.text_selection.js.map +1 -0
- package/BookReader/plugins/plugin.tts.js +3 -0
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +29 -0
- package/BookReader/plugins/plugin.tts.js.map +1 -0
- package/BookReader/plugins/plugin.url.js +2 -0
- package/BookReader/plugins/plugin.url.js.map +1 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js +2 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -0
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/package.json +6 -1
- package/src/BookReader/BookModel.js +564 -0
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/ImageCache.js +149 -0
- package/src/BookReader/Mode1Up.js +110 -0
- package/src/BookReader/Mode1UpLit.js +388 -0
- package/src/BookReader/Mode2Up.js +107 -0
- package/src/BookReader/Mode2UpLit.js +777 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +312 -0
- package/src/BookReader/ModeThumb.js +344 -0
- package/src/BookReader/Navbar/Navbar.js +355 -0
- package/src/BookReader/PageContainer.js +172 -0
- package/src/BookReader/ReduceSet.js +26 -0
- package/src/BookReader/Toolbar/Toolbar.js +362 -0
- package/src/BookReader/events.js +19 -0
- package/src/BookReader/options.js +387 -0
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils/SelectionObserver.js +45 -0
- package/src/BookReader/utils/classes.js +36 -0
- package/src/BookReader/utils.js +313 -0
- package/.eslintrc.cjs +0 -51
- package/.gitattributes +0 -2
- package/.github/ISSUE_TEMPLATE/bug.md +0 -32
- package/.github/ISSUE_TEMPLATE/feature-request.md +0 -30
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -15
- package/.github/workflows/node.js.yml +0 -102
- package/.github/workflows/npm-publish.yml +0 -23
- package/.testcaferc.cjs +0 -10
- package/BookReaderDemo/BookReaderDemo.css +0 -40
- package/BookReaderDemo/BookReaderJSAdvanced.js +0 -112
- package/BookReaderDemo/BookReaderJSSimple.js +0 -56
- package/BookReaderDemo/IADemoBr.js +0 -149
- package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +0 -1
- package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +0 -1
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +0 -1
- package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +0 -1
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
- package/BookReaderDemo/demo-advanced.html +0 -33
- package/BookReaderDemo/demo-embed-iframe-src.html +0 -85
- package/BookReaderDemo/demo-embed.html +0 -26
- package/BookReaderDemo/demo-fullscreen-mobile.html +0 -34
- package/BookReaderDemo/demo-fullscreen.html +0 -31
- package/BookReaderDemo/demo-iiif.html +0 -121
- package/BookReaderDemo/demo-internetarchive.html +0 -271
- package/BookReaderDemo/demo-multiple.html +0 -44
- package/BookReaderDemo/demo-preview-pages.html +0 -1093
- package/BookReaderDemo/demo-simple.html +0 -35
- package/BookReaderDemo/demo-vendor-fullscreen.html +0 -34
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +0 -169
- package/BookReaderDemo/immersion-1up.html +0 -64
- package/BookReaderDemo/immersion-mode.html +0 -33
- package/BookReaderDemo/toggle_controls.html +0 -54
- package/BookReaderDemo/view_mode.html +0 -40
- package/BookReaderDemo/viewmode-cycle.html +0 -40
- package/CHANGELOG.md +0 -1087
- package/CONTRIBUTING.md +0 -7
- package/babel.config.cjs +0 -20
- package/codecov.yml +0 -23
- package/index.html +0 -34
- package/netlify.toml +0 -9
- package/renovate.json +0 -52
- package/screenshot.png +0 -0
- package/scripts/postversion.js +0 -11
- package/scripts/preversion.js +0 -15
- package/scripts/version.js +0 -24
- package/tests/e2e/README.md +0 -112
- package/tests/e2e/autoplay.test.js +0 -16
- package/tests/e2e/base.test.js +0 -27
- package/tests/e2e/helpers/base.js +0 -263
- package/tests/e2e/helpers/debug.js +0 -13
- package/tests/e2e/helpers/mockSearch.js +0 -90
- package/tests/e2e/helpers/params.js +0 -17
- package/tests/e2e/helpers/rightToLeft.js +0 -23
- package/tests/e2e/helpers/search.js +0 -73
- package/tests/e2e/models/BookReader.js +0 -11
- package/tests/e2e/models/Navigation.js +0 -39
- package/tests/e2e/rightToLeft.test.js +0 -19
- package/tests/e2e/viewmode.test.js +0 -44
- package/tests/jest/BookNavigator/book-navigator.test.js +0 -653
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +0 -43
- package/tests/jest/BookNavigator/bookmarks/bookmark-edit.test.js +0 -132
- package/tests/jest/BookNavigator/bookmarks/bookmarks-list.test.js +0 -221
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +0 -45
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +0 -67
- package/tests/jest/BookNavigator/downloads/downloads.test.js +0 -53
- package/tests/jest/BookNavigator/search/search-provider.test.js +0 -179
- package/tests/jest/BookNavigator/search/search-results.test.js +0 -289
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +0 -49
- package/tests/jest/BookNavigator/viewable-files/viewable-files-provider.test.js +0 -80
- package/tests/jest/BookNavigator/visual-adjustments.test.js +0 -200
- package/tests/jest/BookReader.keyboard.test.js +0 -190
- package/tests/jest/BookReader.options.test.js +0 -47
- package/tests/jest/BookReader.test.js +0 -316
- package/tests/jest/plugins/plugin.archive_analytics.test.js +0 -20
- package/tests/jest/plugins/plugin.autoplay.test.js +0 -35
- package/tests/jest/plugins/plugin.chapters.test.js +0 -193
- package/tests/jest/plugins/plugin.iframe.test.js +0 -42
- package/tests/jest/plugins/plugin.resume.test.js +0 -85
- package/tests/jest/plugins/plugin.text_selection.test.js +0 -447
- package/tests/jest/plugins/plugin.vendor-fullscreen.test.js +0 -65
- package/tests/jest/plugins/search/plugin.search.test.js +0 -120
- package/tests/jest/plugins/search/plugin.search.view.test.js +0 -131
- package/tests/jest/plugins/search/utils.js +0 -25
- package/tests/jest/plugins/search/utils.test.js +0 -29
- package/tests/jest/plugins/tts/AbstractTTSEngine.test.js +0 -173
- package/tests/jest/plugins/tts/FestivalTTSEngine.test.js +0 -59
- package/tests/jest/plugins/tts/PageChunk.test.js +0 -57
- package/tests/jest/plugins/tts/PageChunkIterator.test.js +0 -179
- package/tests/jest/plugins/tts/WebTTSEngine.test.js +0 -178
- package/tests/jest/plugins/tts/utils.test.js +0 -74
- package/tests/jest/plugins/url/UrlPlugin.test.js +0 -198
- package/tests/jest/plugins/url/plugin.url.test.js +0 -168
- package/tests/jest/setup.js +0 -3
- package/tests/jest/util/browserSniffing.test.js +0 -62
- package/tests/jest/util/docCookies.test.js +0 -24
- package/tests/jest/util/strings.test.js +0 -63
- package/tests/jest/utils.js +0 -83
- package/webpack.config.js +0 -97
@@ -0,0 +1,184 @@
|
|
1
|
+
!function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n;n||(n=1,function(){function e(e){var t=!0,n=!1,o=null,i={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function r(e){return!!(e&&e!==document&&"HTML"!==e.nodeName&&"BODY"!==e.nodeName&&"classList"in e&&"contains"in e.classList)}function s(e){var t=e.type,n=e.tagName;return!("INPUT"!==n||!i[t]||e.readOnly)||"TEXTAREA"===n&&!e.readOnly||!!e.isContentEditable}function a(e){e.classList.contains("focus-visible")||(e.classList.add("focus-visible"),e.setAttribute("data-focus-visible-added",""))}function l(e){e.hasAttribute("data-focus-visible-added")&&(e.classList.remove("focus-visible"),e.removeAttribute("data-focus-visible-added"))}function c(n){
|
2
|
+
n.metaKey||n.altKey||n.ctrlKey||(r(e.activeElement)&&a(e.activeElement),t=!0)}function h(e){t=!1}function d(e){r(e.target)&&(t||s(e.target))&&a(e.target)}function u(e){r(e.target)&&(e.target.classList.contains("focus-visible")||e.target.hasAttribute("data-focus-visible-added"))&&(n=!0,window.clearTimeout(o),o=window.setTimeout((function(){n=!1}),100),l(e.target))}function f(e){"hidden"===document.visibilityState&&(n&&(t=!0),m())}function m(){document.addEventListener("mousemove",g),document.addEventListener("mousedown",g),document.addEventListener("mouseup",g),document.addEventListener("pointermove",g),document.addEventListener("pointerdown",g),document.addEventListener("pointerup",g),document.addEventListener("touchmove",g),document.addEventListener("touchstart",g),document.addEventListener("touchend",g)}function p(){document.removeEventListener("mousemove",g),document.removeEventListener("mousedown",g),document.removeEventListener("mouseup",g),document.removeEventListener("pointermove",g),
|
3
|
+
document.removeEventListener("pointerdown",g),document.removeEventListener("pointerup",g),document.removeEventListener("touchmove",g),document.removeEventListener("touchstart",g),document.removeEventListener("touchend",g)}function g(e){e.target.nodeName&&"html"===e.target.nodeName.toLowerCase()||(t=!1,p())}document.addEventListener("keydown",c,!0),document.addEventListener("mousedown",h,!0),document.addEventListener("pointerdown",h,!0),document.addEventListener("touchstart",h,!0),document.addEventListener("visibilitychange",f,!0),m(),e.addEventListener("focus",d,!0),e.addEventListener("blur",u,!0),e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host?e.host.setAttribute("data-js-focus-visible",""):e.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if("undefined"!=typeof window&&"undefined"!=typeof document){var t;window.applyFocusVisiblePolyfill=e;try{t=new CustomEvent("focus-visible-polyfill-ready")
|
4
|
+
}catch(e){(t=document.createEvent("CustomEvent")).initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}"undefined"!=typeof document&&e(document)}());var o,i,r,s,a,l,c,h,d,u,f,m,p={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,b=Array.isArray;function w(e,t){for(var n in t)e[n]=t[n];return e}function v(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function y(e,t,n,o,s){var a={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==s?++r:s,__i:-1,__u:0};return null==s&&null!=i.vnode&&i.vnode(a),a}function x(e){return e.children}function N(e,t){this.props=e,this.context=t}function C(e,t){if(null==t)return e.__?C(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?C(e):null}function S(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break
|
5
|
+
}return S(e)}}function A(e){(!e.__d&&(e.__d=!0)&&s.push(e)&&!E.__r++||a!=i.debounceRendering)&&((a=i.debounceRendering)||l)(E)}function E(){for(var e,t,n,o,r,a,l,h=1;s.length;)s.length>h&&s.sort(c),e=s.shift(),h=s.length,e.__d&&(n=void 0,r=(o=(t=e).__v).__e,a=[],l=[],t.__P&&((n=w({},o)).__v=o.__v+1,i.vnode&&i.vnode(n),O(t.__P,n,o,t.__n,t.__P.namespaceURI,32&o.__u?[r]:null,a,null==r?C(o):r,!!(32&o.__u),l),n.__v=o.__v,n.__.__k[n.__i]=n,I(a,n,l),n.__e!=r&&S(n)));E.__r=0}function k(e,t,n,o,i,r,s,a,l,c,h){var d,u,f,m,_,w,v=o&&o.__k||g,N=t.length;for(l=function(e,t,n,o,i){var r,s,a,l,c,h=n.length,d=h,u=0;for(e.__k=new Array(i),r=0;r<i;r++)null!=(s=t[r])&&"boolean"!=typeof s&&"function"!=typeof s?(l=r+u,(s=e.__k[r]="string"==typeof s||"number"==typeof s||"bigint"==typeof s||s.constructor==String?y(null,s,null,null,null):b(s)?y(x,{children:s},null,null,null):null==s.constructor&&s.__b>0?y(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,-1!=(c=s.__i=P(s,n,l,d))&&(d--,(a=n[c])&&(a.__u|=2)),
|
6
|
+
null==a||null==a.__v?(-1==c&&(i>h?u--:i<h&&u++),"function"!=typeof s.type&&(s.__u|=4)):c!=l&&(c==l-1?u--:c==l+1?u++:(c>l?u--:u++,s.__u|=4))):e.__k[r]=null;if(d)for(r=0;r<h;r++)null!=(a=n[r])&&0==(2&a.__u)&&(a.__e==o&&(o=C(a)),H(a,a));return o}(n,t,v,l,N),d=0;d<N;d++)null!=(f=n.__k[d])&&(u=-1==f.__i?p:v[f.__i]||p,f.__i=d,w=O(e,f,u,i,r,s,a,l,c,h),m=f.__e,f.ref&&u.ref!=f.ref&&(u.ref&&F(u.ref,null,f),h.push(f.ref,f.__c||m,f)),null==_&&null!=m&&(_=m),4&f.__u||u.__k===f.__k?l=R(f,l,e):"function"==typeof f.type&&void 0!==w?l=w:m&&(l=m.nextSibling),f.__u&=-7);return n.__e=_,l}function R(e,t,n){var o,i;if("function"==typeof e.type){for(o=e.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=e,t=R(o[i],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=C(e)),n.insertBefore(e.__e,t||null),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function P(e,t,n,o){var i,r,s=e.key,a=e.type,l=t[n];if(null===l&&null==e.key||l&&s==l.key&&a==l.type&&0==(2&l.__u))return n;if(o>(null!=l&&0==(2&l.__u)?1:0))for(i=n-1,
|
7
|
+
r=n+1;i>=0||r<t.length;){if(i>=0){if((l=t[i])&&0==(2&l.__u)&&s==l.key&&a==l.type)return i;i--}if(r<t.length){if((l=t[r])&&0==(2&l.__u)&&s==l.key&&a==l.type)return r;r++}}return-1}function T(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||_.test(t)?n:n+"px"}function M(e,t,n,o,i){var r;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof o&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||T(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||T(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(h,"$1")),t=t.toLowerCase()in e||"onFocusOut"==t||"onFocusIn"==t?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?o?n.u=o.u:(n.u=d,e.addEventListener(t,r?f:u,r)):e.removeEventListener(t,r?f:u,r);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{
|
8
|
+
e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function L(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=d++;else if(t.t<n.u)return;return n(i.event?i.event(t):t)}}}function O(e,t,n,o,r,s,a,l,c,h){var d,u,f,m,p,g,_,y,C,S,A,E,R,P,T,M,L,O=t.type;if(null!=t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),s=[l=t.__e=n.__e]),(d=i.__b)&&d(t);e:if("function"==typeof O)try{if(y=t.props,C="prototype"in O&&O.prototype.render,S=(d=O.contextType)&&o[d.__c],A=d?S?S.props.value:d.__:o,n.__c?_=(u=t.__c=n.__c).__=u.__E:(C?t.__c=u=new O(y,A):(t.__c=u=new N(y,A),u.constructor=O,u.render=V),S&&S.sub(u),u.props=y,u.state||(u.state={}),u.context=A,u.__n=o,f=u.__d=!0,u.__h=[],u._sb=[]),C&&null==u.__s&&(u.__s=u.state),C&&null!=O.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=w({},u.__s)),w(u.__s,O.getDerivedStateFromProps(y,u.__s))),m=u.props,p=u.state,u.__v=t,
|
9
|
+
f)C&&null==O.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),C&&null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(C&&null==O.getDerivedStateFromProps&&y!==m&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(y,A),!u.__e&&null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(y,u.__s,A)||t.__v==n.__v){for(t.__v!=n.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some((function(e){e&&(e.__=t)})),E=0;E<u._sb.length;E++)u.__h.push(u._sb[E]);u._sb=[],u.__h.length&&a.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(y,u.__s,A),C&&null!=u.componentDidUpdate&&u.__h.push((function(){u.componentDidUpdate(m,p,g)}))}if(u.context=A,u.props=y,u.__P=e,u.__e=!1,R=i.__r,P=0,C){for(u.state=u.__s,u.__d=!1,R&&R(t),d=u.render(u.props,u.state,u.context),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);u._sb=[]}else do{u.__d=!1,R&&R(t),d=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++P<25);u.state=u.__s,
|
10
|
+
null!=u.getChildContext&&(o=w(w({},o),u.getChildContext())),C&&!f&&null!=u.getSnapshotBeforeUpdate&&(g=u.getSnapshotBeforeUpdate(m,p)),M=d,null!=d&&d.type===x&&null==d.key&&(M=B(d.props.children)),l=k(e,b(M)?M:[M],t,n,o,r,s,a,l,c,h),u.base=t.__e,t.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(e){if(t.__v=null,c||null!=s)if(e.then){for(t.__u|=c?160:128;l&&8==l.nodeType&&l.nextSibling;)l=l.nextSibling;s[s.indexOf(l)]=null,t.__e=l}else for(L=s.length;L--;)v(s[L]);else t.__e=n.__e,t.__k=n.__k;i.__e(e,t,n)}else null==s&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):l=t.__e=D(n.__e,t,n,o,r,s,a,c,h);return(d=i.diffed)&&d(t),128&t.__u?void 0:l}function I(e,t,n){for(var o=0;o<n.length;o++)F(n[o],n[++o],n[++o]);i.__c&&i.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){i.__e(e,t.__v)}}))}function B(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:b(e)?e.map(B):w({},e)}function D(e,t,n,r,s,a,l,c,h){var d,u,f,m,g,_,w,y=n.props,x=t.props,N=t.type
|
11
|
+
;if("svg"==N?s="http://www.w3.org/2000/svg":"math"==N?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((g=a[d])&&"setAttribute"in g==!!N&&(N?g.localName==N:3==g.nodeType)){e=g,a[d]=null;break}if(null==e){if(null==N)return document.createTextNode(x);e=document.createElementNS(s,N,x.is&&x),c&&(i.__m&&i.__m(t,a),c=!1),a=null}if(null==N)y===x||c&&e.data==x||(e.data=x);else{if(a=a&&o.call(e.childNodes),y=n.props||p,!c&&null!=a)for(y={},d=0;d<e.attributes.length;d++)y[(g=e.attributes[d]).name]=g.value;for(d in y)if(g=y[d],"children"==d);else if("dangerouslySetInnerHTML"==d)f=g;else if(!(d in x)){if("value"==d&&"defaultValue"in x||"checked"==d&&"defaultChecked"in x)continue;M(e,d,null,g,s)}for(d in x)g=x[d],"children"==d?m=g:"dangerouslySetInnerHTML"==d?u=g:"value"==d?_=g:"checked"==d?w=g:c&&"function"!=typeof g||y[d]===g||M(e,d,g,y[d],s);if(u)c||f&&(u.__html==f.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(f&&(e.innerHTML=""),
|
12
|
+
k("template"==t.type?e.content:e,b(m)?m:[m],t,n,r,"foreignObject"==N?"http://www.w3.org/1999/xhtml":s,a,l,a?a[0]:n.__k&&C(n,0),c,h),null!=a)for(d=a.length;d--;)v(a[d]);c||(d="value","progress"==N&&null==_?e.removeAttribute("value"):null!=_&&(_!==e[d]||"progress"==N&&!_||"option"==N&&_!=y[d])&&M(e,d,_,y[d],s),d="checked",null!=w&&w!=e[d]&&M(e,d,w,y[d],s))}return e}function F(e,t,n){try{if("function"==typeof e){var o="function"==typeof e.__u;o&&e.__u(),o&&null==t||(e.__u=e(t))}else e.current=t}catch(e){i.__e(e,n)}}function H(e,t,n){var o,r;if(i.unmount&&i.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||F(o,null,t)),null!=(o=e.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(e){i.__e(e,t)}o.base=o.__P=null}if(o=e.__k)for(r=0;r<o.length;r++)o[r]&&H(o[r],t,n||"function"!=typeof e.type);n||v(e.__e),e.__c=e.__=e.__e=void 0}function V(e,t,n){return this.constructor(e,n)}function U(e,t,n){var r,s,a;t==document&&(t=document.documentElement),i.__&&i.__(e,t),r=!1?null:t.__k,s=[],a=[],
|
13
|
+
O(t,e=t.__k=function(e,t,n){var i,r,s,a={};for(s in t)"key"==s?i=t[s]:"ref"==s?r=t[s]:a[s]=t[s];if(arguments.length>2&&(a.children=arguments.length>3?o.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)null==a[s]&&(a[s]=e.defaultProps[s]);return y(e,a,i,r,null)}(x,null,[e]),r||p,p,t.namespaceURI,r?null:t.firstChild?o.call(t.childNodes):null,s,r?r.__e:t.firstChild,false,a),I(s,e,a)}function q(e){function t(e){var n,o;return this.getChildContext||(n=new Set,(o={})[t.__c]=this,this.getChildContext=function(){return o},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach((function(e){e.__e=!0,A(e)}))},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+m++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}o=g.slice,i={__e:function(e,t,n,o){
|
14
|
+
for(var i,r,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(e)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,o||{}),s=i.__d),s)return i.__E=i}catch(t){e=t}throw e}},r=0,N.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=w({},this.state),"function"==typeof e&&(e=e(w({},n),this.props)),e&&w(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),A(this))},N.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),A(this))},N.prototype.render=x,s=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},E.__r=0,h=/(PointerCapture)$|Capture$/i,d=0,u=L(!1),f=L(!0),m=0;var z,$,W,j,X=0,Y=[],K=i,G=K.__b,Q=K.__r,J=K.diffed,Z=K.__c,ee=K.unmount,te=K.__;function ne(e,t){K.__h&&K.__h($,e,X||t),X=0;var n=$.__H||($.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function oe(e){
|
15
|
+
return X=1,function(e,t,n){var o=ne(z++,2);if(o.t=e,!o.__c&&(o.__=[_e(void 0,t),function(e){var t=o.__N?o.__N[0]:o.__[0],n=o.t(t,e);t!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=$,!$.__f)){var i=function(e,t,n){if(!o.__c.__H)return!0;var i=o.__c.__H.__.filter((function(e){return!!e.__c}));if(i.every((function(e){return!e.__N})))return!r||r.call(this,e,t,n);var s=o.__c.props!==e;return i.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}})),r&&r.call(this,e,t,n)||s};$.__f=!0;var r=$.shouldComponentUpdate,s=$.componentWillUpdate;$.componentWillUpdate=function(e,t,n){if(this.__e){var o=r;r=void 0,i(e,t,n),r=o}s&&s.call(this,e,t,n)},$.shouldComponentUpdate=i}return o.__N||o.__}(_e,e)}function ie(e,t){var n=ne(z++,3);!K.__s&&ge(n.__H,t)&&(n.__=e,n.u=t,$.__H.__h.push(n))}function re(e,t){var n=ne(z++,4);!K.__s&&ge(n.__H,t)&&(n.__=e,n.u=t,$.__h.push(n))}function se(e){return X=5,ae((function(){return{current:e}}),[])}function ae(e,t){var n=ne(z++,7)
|
16
|
+
;return ge(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function le(e,t){return X=8,ae((function(){return e}),t)}function ce(e){var t=$.context[e.__c],n=ne(z++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub($)),t.props.value):e.__}function he(){var e=ne(z++,11);if(!e.__){for(var t=$.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function de(){for(var e;e=Y.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(me),e.__H.__h.forEach(pe),e.__H.__h=[]}catch(t){e.__H.__h=[],K.__e(t,e.__v)}}K.__b=function(e){$=null,G&&G(e)},K.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),te&&te(e,t)},K.__r=function(e){Q&&Q(e),z=0;var t=($=e.__c).__H;t&&(W===$?(t.__h=[],$.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0}))):(t.__h.forEach(me),t.__h.forEach(pe),t.__h=[],z=0)),W=$},K.diffed=function(e){J&&J(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==Y.push(t)&&j===K.requestAnimationFrame||((j=K.requestAnimationFrame)||fe)(de)),
|
17
|
+
t.__H.__.forEach((function(e){e.u&&(e.__H=e.u),e.u=void 0}))),W=$=null},K.__c=function(e,t){t.some((function(e){try{e.__h.forEach(me),e.__h=e.__h.filter((function(e){return!e.__||pe(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],K.__e(n,e.__v)}})),Z&&Z(e,t)},K.unmount=function(e){ee&&ee(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{me(e)}catch(e){t=e}})),n.__H=void 0,t&&K.__e(t,n.__v))};var ue="function"==typeof requestAnimationFrame;function fe(e){var t,n=function(){clearTimeout(o),ue&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,100);ue&&(t=requestAnimationFrame(n))}function me(e){var t=$,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),$=t}function pe(e){var t=$;e.__c=e.__(),$=t}function ge(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function _e(e,t){return"function"==typeof t?t(e):t}function be(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){
|
18
|
+
var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class we{constructor(){be(this,"_listeners",void 0),this._listeners=new Map}add(e,t,n,o){e.addEventListener(t,n,o);const i=Symbol();return this._listeners.set(i,{eventTarget:e,eventType:t,listener:n,options:o}),i}remove(e){const t=this._listeners.get(e);if(t){const{eventTarget:n,eventType:o,listener:i,options:r}=t;n.removeEventListener(o,i,r),this._listeners.delete(e)}}removeAll(){this._listeners.forEach((({eventTarget:e,eventType:t,listener:n,options:o})=>{e.removeEventListener(t,n,o)})),this._listeners.clear()}}function ve(e){e.focus()}function ye(e,{autofocus:t=!1,loop:n=!0,horizontal:o=!0,vertical:i=!0,selector:r="a,button",containerVisible:s=!0,focusElement:a=ve}={}){const l=se(null),c=function(e){const t=se({
|
19
|
+
callback:e,call:(...e)=>t.current.callback(...e)});return t.current.callback=e,t.current.call}(a);ie((()=>{if(!s)return()=>{};if(!e.current)throw new Error("Container ref not set");const a=e.current,h=()=>{const e=Array.from(a.querySelectorAll(r)).filter((e=>null!==e.offsetParent&&!function(e){return"boolean"==typeof e.disabled&&e.disabled}(e)));return document.activeElement===a&&e.unshift(a),e},d=(e=h(),t=-1,n=!1,o)=>{t<0&&(t=e.findIndex((e=>0===e.tabIndex)))<0&&(t=0);for(const[i,r]of e.entries())r.tabIndex=i===t?0:-1,i===t&&n&&(l.current=r,c(r,o))},u=h(),f=l.current?u.indexOf(l.current):0;d(u,f,t);const m=new we;m.add(a,"focusin",(e=>{if(e.target===a&&l.current)return void c(l.current);const n=h(),o=n.indexOf(e.target);o>=0&&d(n,o,t)})),m.add(a,"keydown",(e=>{const t=h();let r=t.findIndex((e=>0===e.tabIndex)),s=!1;o&&"ArrowLeft"===e.key||i&&"ArrowUp"===e.key?(0===r?r=n?t.length-1:r:--r,s=!0):o&&"ArrowRight"===e.key||i&&"ArrowDown"===e.key?(r===t.length-1?r=n?0:r:++r,s=!0):"Home"===e.key?(r=0,
|
20
|
+
s=!0):"End"===e.key&&(r=t.length-1,s=!0),s&&(d(t,r,!0,e),e.preventDefault(),e.stopPropagation())}));const p=new MutationObserver((()=>{d()}));return p.observe(a,{subtree:!0,attributes:!0,attributeFilter:["disabled"],childList:!0}),()=>{m.removeAll(),p.disconnect()}}),[t,e,c,o,n,r,i,s])}function xe(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class Ne{constructor(e){xe(this,"_target",void 0),xe(this,"_value",void 0),this._target=e,this._value=null}get current(){return this._value}set current(e){this._value=e,this._updateTarget()}get target(){return this._target}set target(e){e!==this._target&&(this._target=e,this._updateTarget())}
|
21
|
+
_updateTarget(){const e=this._value;"function"==typeof this._target?this._target(e):this._target&&(this._target.current=e)}}function Ce(e){const t=se(new Ne(e));return t.current.target=e,t.current}var Se,Ae={exports:{}};var Ee,ke=(Se||(Se=1,Ee=Ae,function(){var e={}.hasOwnProperty;function t(){for(var e="",t=0;t<arguments.length;t++){var i=arguments[t];i&&(e=o(e,n(i)))}return e}function n(n){if("string"==typeof n||"number"==typeof n)return n;if("object"!=typeof n)return"";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var i="";for(var r in n)e.call(n,r)&&n[r]&&(i=o(i,r));return i}function o(e,t){return t?e?e+" "+t:e+t:e}Ee.exports?(t.default=t,Ee.exports=t):window.classNames=t}()),Ae.exports),Re=t(ke);var Pe=0;function Te(e,t,n,o,r,s){t||(t={});var a,l,c=t;if("ref"in c)for(l in c={},t)"ref"==l?a=t[l]:c[l]=t[l];var h={type:e,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,
|
22
|
+
__v:--Pe,__i:-1,__u:0,__source:r,__self:s};if("function"==typeof e&&(a=e.defaultProps))for(l in a)void 0===c[l]&&(c[l]=a[l]);return i.vnode&&i.vnode(h),h}q({}),q({});var Me="/home/runner/work/frontend-shared/frontend-shared/src/components/layout/Card.tsx";function Le({children:e,classes:t,elementRef:n,active:o=!1,variant:i="raised",width:r="full",...s}){return Te("div",{"data-component":"Card",...s,ref:n,className:Re("rounded-lg border bg-white",{"shadow hover:shadow-md":"raised"===i,"shadow-md":o&&"raised"===i},{"w-full":"full"===r,"w-auto":"auto"===r},t),children:e},void 0,0,{fileName:Me,lineNumber:40,columnNumber:5},this)}var Oe="/home/runner/work/frontend-shared/frontend-shared/src/components/layout/CardContent.tsx";function Ie({children:e,classes:t,elementRef:n,size:o="md",...i}){return Te("div",{"data-component":"CardContent",...i,ref:n,className:Re({"p-3 space-y-4":"md"===o,"p-2 space-y-3":"sm"===o,"p-4 space-y-6":"lg"===o},t),children:e},void 0,0,{fileName:Oe,lineNumber:29,columnNumber:5},this)}
|
23
|
+
var Be="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Annotate.tsx";function De(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"AnnotateIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:Be,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",
|
24
|
+
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"
|
25
|
+
},void 0,0,{fileName:Be,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:Be,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:Be,lineNumber:11,columnNumber:5},this)}var Fe="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Cancel.tsx";function He(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CancelIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:Fe,lineNumber:21,columnNumber:9},this),Te("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"},void 0,0,{fileName:Fe,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:Fe,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:Fe,lineNumber:11,
|
26
|
+
columnNumber:5},this)}var Ve="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/CaretDown.tsx";function Ue(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CaretDownIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:Ve,lineNumber:21,columnNumber:9},this),Te("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"},void 0,0,{fileName:Ve,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:Ve,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:Ve,lineNumber:11,columnNumber:5},this)}var qe="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/CaretLeft.tsx";function ze(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",
|
27
|
+
"aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CaretLeftIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:qe,lineNumber:21,columnNumber:9},this),Te("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"},void 0,0,{fileName:qe,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:qe,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:qe,lineNumber:11,columnNumber:5},this)}var $e="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/CaretRight.tsx";function We(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CaretRightIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:$e,lineNumber:21,columnNumber:9
|
28
|
+
},this),Te("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"},void 0,0,{fileName:$e,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:$e,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:$e,lineNumber:11,columnNumber:5},this)}var je="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Caution.tsx";function Xe(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CautionIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:je,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",
|
29
|
+
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"},void 0,0,{fileName:je,lineNumber:22,columnNumber:9},this),Te("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"},void 0,0,{fileName:je,lineNumber:26,columnNumber:9},this)]},void 0,0,{fileName:je,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:je,lineNumber:11,columnNumber:5},this)}var Ye="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Check.tsx";function Ke(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckIcon",...e,children:Te("g",{
|
30
|
+
"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:Ye,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",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"},void 0,0,{fileName:Ye,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:Ye,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:Ye,lineNumber:11,columnNumber:5},this)}var Ge="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Checkbox.tsx";function Qe(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckboxIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:Ge,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",
|
31
|
+
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"},void 0,0,{fileName:Ge,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:Ge,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:Ge,lineNumber:11,columnNumber:5},this)}var Je="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/CheckboxCheckedFilled.tsx";function Ze(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"CheckboxCheckedFilledIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:Je,lineNumber:23,columnNumber:9},this),Te("path",{fill:"currentColor",
|
32
|
+
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"},void 0,0,{fileName:Je,lineNumber:24,columnNumber:9},this)]},void 0,0,{fileName:Je,lineNumber:22,columnNumber:7},this)},void 0,0,{fileName:Je,lineNumber:13,columnNumber:5},this)}var et="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Hide.tsx";function tt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"HideIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:et,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",
|
33
|
+
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"},void 0,0,{fileName:et,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:et,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:et,lineNumber:11,columnNumber:5},this)}var nt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Highlight.tsx";function ot(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"HighlightIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:nt,lineNumber:21,
|
34
|
+
columnNumber:9},this),Te("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"},void 0,0,{fileName:nt,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:nt,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:nt,lineNumber:11,columnNumber:5},this)}var it="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/MenuCollapse.tsx";function rt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","data-component":"MenuCollapseIcon",...e,children:Te("path",{fill:"currentColor",
|
35
|
+
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"},void 0,0,{fileName:it,lineNumber:18,columnNumber:7},this)},void 0,0,{fileName:it,lineNumber:11,columnNumber:5},this)}var st="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/MenuExpand.tsx";function at(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16","data-component":"MenuExpandIcon",...e,children:Te("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"},void 0,0,{fileName:st,lineNumber:19,columnNumber:7},this)},void 0,0,{fileName:st,lineNumber:11,columnNumber:5},this)}var lt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Note.tsx";function ct(e){return Te("svg",{
|
36
|
+
xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"NoteIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:lt,lineNumber:21,columnNumber:9},this),Te("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"},void 0,0,{fileName:lt,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:lt,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:lt,lineNumber:11,columnNumber:5},this)}var ht="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Pin.tsx";function dt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"PinIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",
|
37
|
+
d:"M0 0h16v16H0z"},void 0,0,{fileName:ht,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",d:"M3 1a1 1 0 0 1 1-1h8a1 1 0 1 1 0 2 .5.5 0 0 0-.5.5v.146a.5.5 0 0 0 .053.224l1.341 2.683c.07.139.106.292.106.447v3a1 1 0 0 1-1 1H9.024l.093 4.977a1 1 0 0 1-2 .046L7.024 10H4a1 1 0 0 1-1-1V6a1 1 0 0 1 .106-.447L4.447 2.87a.5.5 0 0 0 .053-.224V2.5A.5.5 0 0 0 4 2a1 1 0 0 1-1-1m4 1a.5.5 0 0 0-.5.5V3a1 1 0 0 1-.106.447L5.053 6.13A.5.5 0 0 0 5 6.355V7.5a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5V6.354a.5.5 0 0 0-.053-.224L9.606 3.448A1 1 0 0 1 9.5 3v-.5A.5.5 0 0 0 9 2z","clip-rule":"evenodd"},void 0,0,{fileName:ht,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:ht,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:ht,lineNumber:11,columnNumber:5},this)}var ut="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/PointerDown.tsx";function ft(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"9","data-component":"PointerDownIcon",...e,children:Te("path",{
|
38
|
+
stroke:"currentColor",d:"m15.5 0-7 8-8-8"},void 0,0,{fileName:ut,lineNumber:18,columnNumber:7},this)},void 0,0,{fileName:ut,lineNumber:11,columnNumber:5},this)}var mt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/PointerUp.tsx";function pt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"9","data-component":"PointerUpIcon",...e,children:Te("path",{stroke:"currentColor",d:"m.5 9 7-8 8 8"},void 0,0,{fileName:mt,lineNumber:18,columnNumber:7},this)},void 0,0,{fileName:mt,lineNumber:11,columnNumber:5},this)}var gt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Radio.tsx";function _t(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"RadioIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:gt,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",
|
39
|
+
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"},void 0,0,{fileName:gt,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:gt,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:gt,lineNumber:11,columnNumber:5},this)}var bt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/RadioChecked.tsx";function wt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"RadioCheckedIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:bt,lineNumber:21,columnNumber:9},this),Te("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"},void 0,0,{fileName:bt,lineNumber:22,columnNumber:9},this),Te("path",{fill:"currentColor",d:"M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0"},void 0,0,{fileName:bt,lineNumber:27,columnNumber:9},this)]},void 0,0,{
|
40
|
+
fileName:bt,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:bt,lineNumber:11,columnNumber:5},this)}var vt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Selection.tsx";function yt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"SelectionIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:vt,lineNumber:21,columnNumber:9},this),Te("path",{fill:"currentColor",
|
41
|
+
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"},void 0,0,{fileName:vt,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:vt,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:vt,lineNumber:11,columnNumber:5},this)}
|
42
|
+
var xt="/home/runner/work/frontend-shared/frontend-shared/src/components/icons/Show.tsx";function Nt(e){return Te("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16","aria-hidden":"true",viewBox:"0 0 16 16","data-component":"ShowIcon",...e,children:Te("g",{"fill-rule":"evenodd",children:[Te("path",{fill:"none",d:"M0 0h16v16H0z"},void 0,0,{fileName:xt,lineNumber:21,columnNumber:9},this),Te("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"},void 0,0,{fileName:xt,lineNumber:22,columnNumber:9},this)]},void 0,0,{fileName:xt,lineNumber:20,columnNumber:7},this)},void 0,0,{fileName:xt,lineNumber:11,columnNumber:5},this)}var Ct="/home/runner/work/frontend-shared/frontend-shared/src/components/input/Button.tsx";function St({children:e,classes:t,elementRef:n,expanded:o,pressed:i,title:r,icon:s,size:a="md",variant:l="secondary",unstyled:c=!1,role:h,...d}){
|
43
|
+
const u=!c,f=u&&"custom"!==l,m=u&&"custom"!==a,p={"aria-label":r};return"tab"===h?p["aria-selected"]=i:(p["aria-pressed"]=i,p["aria-expanded"]=o),Te("button",{role:null!=h?h:"button","data-component":"Button",type:"button",...p,...d,className:Re({"focus-visible-ring transition-colors whitespace-nowrap flex items-center":u},f&&{"font-semibold rounded":!0,"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},m&&{"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},t),ref:n,title:r,children:[s&&Te(s,{className:"w-em h-em"},void 0,0,{fileName:Ct,lineNumber:120,columnNumber:16},this),e]},void 0,0,{fileName:Ct,lineNumber:89,columnNumber:5},this)}
|
44
|
+
const At=Re("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");var Et="/home/runner/work/frontend-shared/frontend-shared/src/components/input/IconButton.tsx";function kt({children:e,classes:t,elementRef:n,pressed:o,expanded:i,icon:r,size:s="md",title:a,variant:l="secondary",unstyled:c=!1,...h}){const d=!c;return Te(St,{"data-component":"IconButton",...h,classes:Re({"focus-visible-ring transition-colors rounded whitespace-nowrap":d,"flex items-center justify-center":d},d&&At,d&&"custom"!==l&&{"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&&{
|
45
|
+
"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},t),elementRef:n,title:a,pressed:o,expanded:i,unstyled:!0,children:[r&&Te(r,{className:"w-em h-em"},void 0,0,{fileName:Et,lineNumber:84,columnNumber:16},this),e]},void 0,0,{fileName:Et,lineNumber:49,columnNumber:5},this)}var Rt="/home/runner/work/frontend-shared/frontend-shared/src/components/input/ToggleInput.tsx";function Pt({children:e,elementRef:t,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 Te("label",{className:Re("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:[Te("input",{...d,type:c,ref:t,className:Re("peer","absolute w-em h-em","opacity-[.00001]",{"cursor-pointer":!s}),checked:o,disabled:s,id:l,onChange:a},void 0,0,{fileName:Rt,lineNumber:66,columnNumber:7},this),Te(u,{
|
46
|
+
className:Re("peer-focus-visible:ring","w-em h-em")},void 0,0,{fileName:Rt,lineNumber:88,columnNumber:7},this),e]},void 0,0,{fileName:Rt,lineNumber:51,columnNumber:5},this)}var Tt="/home/runner/work/frontend-shared/frontend-shared/src/components/input/Checkbox.tsx";function Mt({checked:e,defaultChecked:t=!1,icon:n=Qe,checkedIcon:o=Ze,onChange:i,...r}){const s="boolean"==typeof e,[a,l]=oe(t);return Te(Pt,{icon:n,checkedIcon:o,type:"checkbox",checked:s?e:a,onChange:function(e){null==i||i.call(this,e),s||l(e.target.checked)},...r},void 0,0,{fileName:Tt,lineNumber:65,columnNumber:5},this)}const Lt=q(null);var Ot="/home/runner/work/frontend-shared/frontend-shared/src/components/input/RadioGroup.tsx";function It({value:e,children:t,subtitle:n,disabled:o}){const i=ce(Lt);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===e;return Te("div",{role:"radio","aria-checked":l,"aria-disabled":s,
|
47
|
+
className:Re("focus-visible-ring rounded-lg px-3 py-2 flex-1 group",{"bg-grey-3/50":l,"hover:bg-grey-3/25":!l&&!s,"opacity-70":s,"cursor-pointer":!s}),"data-value":e,onClick:s?void 0:()=>a(e),onKeyDown:s?void 0:t=>{["Enter"," "].includes(t.key)&&(t.preventDefault(),a(e))},tabIndex:-1,children:[Te("div",{className:"flex items-center gap-x-1.5",children:[l?Te(wt,{},void 0,0,{fileName:Ot,lineNumber:68,columnNumber:23},this):Te(_t,{},void 0,0,{fileName:Ot,lineNumber:68,columnNumber:46},this),t]},void 0,0,{fileName:Ot,lineNumber:67,columnNumber:7},this),n&&Te("div",{className:Re("pl-4 ml-1.5 mt-1 text-sm",{"text-grey-7":l,"text-grey-6 group-hover:text-grey-7":!l&&!s}),children:n},void 0,0,{fileName:Ot,lineNumber:72,columnNumber:9},this)]},void 0,0,{fileName:Ot,lineNumber:40,columnNumber:5},this)}It.displayName="RadioGroup.Radio",Object.assign((function({direction:e="horizontal",children:t,selected:n,onChange:o,disabled:i,"aria-label":r,"aria-labelledby":s,name:a}){const l=se(null);return ye(l,{loop:!1,
|
48
|
+
selector:'[role="radio"]:not([aria-disabled="true"])',focusElement:e=>{o(e.dataset.value),e.focus()}}),Te(Lt.Provider,{value:{selected:n,disabled:i,onChange:o},children:[Te("div",{"aria-label":r,"aria-labelledby":s,ref:l,role:"radiogroup",className:Re("w-full flex gap-1.5",{"flex-col":"vertical"===e}),children:t},void 0,0,{fileName:Ot,lineNumber:134,columnNumber:7},this),a&&Te("input",{type:"hidden","data-testid":"hidden-input",name:a,value:n,disabled:i},void 0,0,{fileName:Ot,lineNumber:146,columnNumber:9},this)]},void 0,0,{fileName:Ot,lineNumber:131,columnNumber:5},this)}),{Radio:It,displayName:"RadioGroup"});var Bt="/home/runner/work/frontend-shared/frontend-shared/src/components/feedback/Popover.tsx";const Dt=".15rem",Ft=8;function Ht(e,t,n,o,i){ie((()=>{if(!i)return()=>{};const t=e.current,o=e=>{"open"===e.oldState&&"closed"===e.newState&&n()};return t.addEventListener("toggle",o),()=>t.removeEventListener("toggle",o)}),[i,n,e]);const r=o&&!i;!function(e,t,{enabled:n=!0}={}){ie((()=>{if(!n)return()=>{}
|
49
|
+
;const o=document.body,i=new we,r=n=>{e.current&&!n.composedPath().includes(e.current)&&t(n)};return i.add(o,"mousedown",r),i.add(o,"click",r),()=>{i.removeAll()}}),[e,n,t])}(e,(e=>{e.composedPath().includes(t.current)||n()}),{enabled:r}),function(e,t,{enabled:n=!0}={}){ie((()=>{if(!n)return()=>{};const o=document.body,i=new we;return i.add(o,"keydown",(n=>{e.includes(n.key)&&t(n)})),()=>{i.removeAll()}}),[n,t,e])}(["Escape"],n,{enabled:r})}function Vt({anchorElementRef:e,children:t,open:n,onClose:o,align:i="left",classes:r,variant:s="panel",onScroll:a,elementRef:l,asNativePopover:c=HTMLElement.prototype.hasOwnProperty("popover")}){const h=Ce(l);return function(e,t,n,o,i){const r=le((()=>{const n=t.current,r=e.current,s=e=>{Object.assign(n.style,e);const t=Object.keys(e);return()=>t.map((e=>n.style[e]=""))},a=window.innerHeight,{top:l,bottom:c,left:h,height:d,width:u}=r.getBoundingClientRect(),f=a-c,{height:m,width:p}=n.getBoundingClientRect(),g=f<m&&l>f;if(!o)return s(g?{bottom:"100%",marginBottom:Dt}:{
|
50
|
+
top:"100%",marginTop:Dt});const{top:_,width:b}=document.body.getBoundingClientRect(),w=Math.abs(_),v=(i?h+u:b-h)-Ft;let y=h;return p>v?y=i?Ft:y-(p-v):i&&p>u&&(y-=p-u),s({minWidth:`${u}px`,top:g?`calc(${w+l-m}px - ${Dt})`:`calc(${w+l+d}px + ${Dt})`,left:`${Math.max(Ft,y)}px`})}),[o,e,t,i]);re((()=>{if(!n)return()=>{};const e=t.current;o&&e.togglePopover(!0);const i=r();if(!o)return i;const s=new we;s.add(document.body,"scroll",r,{capture:!0});const a=new ResizeObserver(r);return a.observe(e),()=>{o&&(null==e||e.togglePopover(!1)),i(),s.removeAll(),a.disconnect()}}),[r,o,n,t])}(e,h,n,c,"right"===i),Ht(h,e,o,n,c),function({popoverRef:e,open:t}){re((()=>{const n=e.current,o=t?document.activeElement:null;return n&&o?()=>{const e=document.activeElement;e&&!n.contains(e)&&e!==document.body||o.focus()}:()=>{}}),[e,t])}({open:n,popoverRef:h}),Te("div",{
|
51
|
+
className:Re("absolute z-5","panel"===s&&["max-h-80 overflow-y-auto overflow-x-hidden","rounded border bg-white shadow hover:shadow-md focus-within:shadow-md"],c&&["max-w-[calc(100%-16px)]","p-0 m-0"],!c&&{hidden:!n,"right-0":"right"===i,"min-w-full":!0},r),ref:h,popover:c&&"auto",onScroll:a,"data-testid":"popover","data-component":"Popover",children:n&&t},void 0,0,{fileName:Bt,lineNumber:356,columnNumber:5},this)}const Ut=q(null);var qt="/home/runner/work/frontend-shared/frontend-shared/src/components/input/Select.tsx";function zt(e,t){return"function"==typeof e?e(t):e}function $t({value:e,children:t,disabled:n=!1,classes:o,elementRef:i,title:r}){const s=se(null),a=se(null),l=Ce(i),c=e=>e.target===s.current||e.target===a.current,h=ce(Ut);if(!h)throw new Error("Select.Option can only be used as Select or MultiSelect child");const{selectValue:d,value:u,multiple:f}=h,m=ae((()=>!n&&(f?u.includes(e)||0===u.length&&void 0===e:u===e)),[u,n,f,e]),p=le((()=>{const t={closeListbox:!0};d(f?void 0!==e?[e]:[]:e,t)
|
52
|
+
}),[f,d,e]),g=le((()=>{if(!f)return;const t={closeListbox:void 0===e};if(void 0===e)return void d([],t);const n=u.indexOf(e);if(-1===n)d([...u,e],t);else{const e=[...u];e.splice(n,1),d(e,t)}}),[u,f,d,e]);return Te("li",{className:Re("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:e=>{n||c(e)||p()},onKeyDown:e=>{n||(["Enter"," "].includes(e.key)&&!c(e)?(e.preventDefault(),p()):s.current&&"ArrowRight"===e.key&&(e.preventDefault(),s.current.focus()))},role:"option","aria-disabled":n,"aria-selected":m,tabIndex:m?0:-1,ref:l,title:r,children:Te("div",{className:Re("flex justify-between items-center","w-full rounded",{"hover:bg-grey-1 group-focus-visible:ring":!n,"bg-grey-1 hover:bg-grey-2":m}),children:[Te("div",{className:Re("py-2 pl-3",{truncate:"truncate"===h.listboxOverflow,"whitespace-normal":"wrap"===h.listboxOverflow}),children:zt(t,{selected:m,disabled:n})},void 0,0,{fileName:qt,lineNumber:203,
|
53
|
+
columnNumber:9},this),!f&&Te("div",{className:"px-3",children:Te(Ke,{className:Re("text-grey-6 scale-125",{"opacity-0":!m})},void 0,0,{fileName:qt,lineNumber:213,columnNumber:13},this)},void 0,0,{fileName:qt,lineNumber:212,columnNumber:11},this),f&&Te(Mt,{containerClasses:Re("self-stretch px-3","text-lg",{"text-grey-6":m,"text-grey-3 hover:text-grey-6":!m}),checked:m,checkedIcon:Ze,elementRef:s,containerRef:a,onChange:g,onKeyDown:e=>{var t;"ArrowLeft"===e.key&&(e.preventDefault(),null===(t=l.current)||void 0===t||t.focus())}},void 0,0,{fileName:qt,lineNumber:224,columnNumber:11},this)]},void 0,0,{fileName:qt,lineNumber:193,columnNumber:7},this)},void 0,0,{fileName:qt,lineNumber:146,columnNumber:5},this)}function Wt({buttonContent:e,value:t,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":m,"aria-labelledby":p,listboxAsPopover:g}){
|
54
|
+
const _=se(null),b=se(null),[w,v]=oe(!1),y=le((()=>v(!1)),[v]),x=he(),N=Ce(r),C=he(),S=le(((e,t)=>{n(e),t.closeListbox&&y()}),[n,y]);return function(e,t,{enabled:n=!0}={}){ie((()=>{if(!n||!e.current)return()=>{};const o=new we;return o.add(e.current,"focusout",(n=>{const o=n;e.current&&!e.current.contains(o.relatedTarget)&&t(o)})),()=>{o.removeAll()}}),[e,n,t])}(_,y),ye(b,{horizontal:!1,loop:!1,autofocus:!0,containerVisible:w,selector:'[role="option"]:not([aria-disabled="true"])'}),Te("div",{className:Re("relative w-full border rounded",{"border-grey-5":w},At,c),ref:_,children:[Te("button",{id:null!=s?s:C,className:Re("focus-visible-ring 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":w,"aria-haspopup":"listbox","aria-controls":x,"aria-label":m,"aria-labelledby":p,ref:N,onClick:()=>v((e=>!e)),onKeyDown:e=>{
|
55
|
+
"ArrowDown"!==e.key||w||(e.preventDefault(),v(!0))},"data-testid":"select-toggle-button",children:[Te("div",{className:"pl-2 py-2 truncate grow",children:e},void 0,0,{fileName:qt,lineNumber:429,columnNumber:9},this),Te("div",{className:"pr-2 py-2 text-grey-6",children:w?Te(rt,{},void 0,0,{fileName:qt,lineNumber:431,columnNumber:26},this):Te(at,{},void 0,0,{fileName:qt,lineNumber:431,columnNumber:49},this)},void 0,0,{fileName:qt,lineNumber:430,columnNumber:9},this)]},void 0,0,{fileName:qt,lineNumber:396,columnNumber:7},this),Te(Ut.Provider,{value:{value:t,selectValue:S,multiple:u,listboxOverflow:f},children:Te(Vt,{anchorElementRef:_,open:w,onClose:y,asNativePopover:g,align:d,classes:l,onScroll:h,children:Te("ul",{role:"listbox",id:x,ref:b,"aria-multiselectable":u,"aria-labelledby":null!=s?s:C,"aria-orientation":"vertical",children:o},void 0,0,{fileName:qt,lineNumber:453,columnNumber:11},this)},void 0,0,{fileName:qt,lineNumber:444,columnNumber:9},this)},void 0,0,{fileName:qt,lineNumber:435,columnNumber:7
|
56
|
+
},this)]},void 0,0,{fileName:qt,lineNumber:387,columnNumber:5},this)}$t.displayName="Select.Option",Object.assign((function(e){return Wt({...e,multiple:!1})}),{Option:$t,displayName:"Select"}),Object.assign((function(e){return Wt({...e,multiple:!0})}),{Option:$t,displayName:"MultiSelect"}),q({}),q(null);var jt="/home/runner/work/frontend-shared/frontend-shared/src/components/feedback/Callout.tsx";function Xt({children:e,classes:t,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=Ke;break;case"error":u=He;break;default:u=Xe}const f=h&&d;return Te("div",{"data-component":"Callout",...l,ref:n,className:Re(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,
|
57
|
+
"bg-green-success":"success"===i&&f,"bg-red-error":"error"===i&&f,"bg-white":!f},t),children:[f&&Te("div",{className:Re({"p-2":"md"===r,"p-1.5":"sm"===r,"p-3":"lg"===r}),children:Te(u,{"data-testid":"callout-icon",className:Re("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})},void 0,0,{fileName:jt,lineNumber:95,columnNumber:11},this)},void 0,0,{fileName:jt,lineNumber:88,columnNumber:9},this),Te("div",{className:Re(d&&{"p-2":"md"===r,"py-1.5 px-2":"sm"===r,"p-3":"lg"===r},c&&"grow",h&&"bg-white rounded-r"),children:e},void 0,0,{fileName:jt,lineNumber:105,columnNumber:7},this)]},void 0,0,{fileName:jt,lineNumber:64,columnNumber:5},this)}var Yt="/home/runner/work/frontend-shared/frontend-shared/src/components/feedback/ToastMessages.tsx";function Kt({message:e,onDismiss:t}){return Te(Xt,{classes:Re({"sr-only":e.visuallyHidden}),status:e.type,onClick:()=>t(e.id),variant:"raised",children:e.message},void 0,0,{fileName:Yt,lineNumber:55,columnNumber:5
|
58
|
+
},this)}const Gt=({direction:e,onTransitionEnd:t,children:n,transitionClasses:o={}})=>{const i="out"===e,r=se(null),s=ae((()=>{const{transitionIn:e="animate-fade-in",transitionOut:t="animate-fade-out"}=o;return{[e]:!i,[t]:i}}),[i,o]);return Te("div",{"data-testid":"animation-container",onAnimationEnd:n=>{n.target===r.current&&(null==t||t(null!=e?e:"in"))},ref:r,className:Re("relative w-full container",s),children:n},void 0,0,{fileName:Yt,lineNumber:103,columnNumber:5},void 0)};function Qt({messages:e,onMessageDismiss:t,transitionClasses:n,setTimeout_:o=setTimeout}){const[i,r]=oe([]),s=se(new Map),a=le((e=>r((t=>[...t,e]))),[]),l=le((e=>{const t=o((()=>{a(e),s.current.delete(e)}),5e3);s.current.set(e,t)}),[a,o]),c=le(((e,n)=>{var o;const i=null===(o=n.autoDismiss)||void 0===o||o;"in"===e&&i&&l(n.id),"out"===e&&(t(n.id),r((e=>e.filter((e=>e!==n.id)))))}),[l,t]);return re((()=>{const e=s.current;return()=>{e.forEach((e=>clearTimeout(e)))}}),[]),Te("ul",{"aria-live":"polite","aria-relevant":"additions",
|
59
|
+
className:"w-full space-y-2","data-component":"ToastMessages",children:e.map((e=>{const t=i.includes(e.id);return Te("li",{className:Re({"mb-2":!e.visuallyHidden}),children:Te(Gt,{direction:t?"out":"in",onTransitionEnd:t=>c(t,e),transitionClasses:n,children:Te(Kt,{message:e,onDismiss:a},void 0,0,{fileName:Yt,lineNumber:206,columnNumber:15},this)},void 0,0,{fileName:Yt,lineNumber:201,columnNumber:13},this)},e.id,0,{fileName:Yt,lineNumber:189,columnNumber:11},this)}))},void 0,0,{fileName:Yt,lineNumber:180,columnNumber:5},this)}var Jt="/home/runner/work/frontend-shared/frontend-shared/src/components/navigation/Link.tsx";function Zt({children:e,classes:t,elementRef:n,underline:o="none",unstyled:i=!1,variant:r="brand",...s}){const a=!i;return Te("a",{"data-component":"Link",rel:"noopener noreferrer",...s,className:Re(a&&{"focus-visible-ring rounded":!0,"no-underline hover:no-underline":"none"===o,"underline hover:underline":"always"===o,"no-underline hover:underline":"hover"===o},a&&"custom"!==r&&{
|
60
|
+
"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},t),ref:n,children:e},void 0,0,{fileName:Jt,lineNumber:37,columnNumber:5},this)}var en="/home/runner/work/frontend-shared/frontend-shared/src/components/navigation/PointerButton.tsx";function tn({children:e,classes:t,elementRef:n,expanded:o,pressed:i,title:r,direction:s,...a}){return Te(St,{"data-component":"PointerButton",...a,elementRef:n,classes:Re("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,
|
61
|
+
"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},t),expanded:o,pressed:i,title:r,variant:"custom",size:"custom",children:e},void 0,0,{fileName:en,lineNumber:48,columnNumber:5},this)}function nn(e){const t=e.toString(16)
|
62
|
+
;return 1===t.length?"0"+t:t}function on(e){const t=new Uint8Array(e/2);return window.crypto.getRandomValues(t),Array.from(t).map(nn).join("")}function rn(e){if(null===e||"object"!=typeof e)return!1;for(const t of["frame1","frame2","type","requestId"])if("string"!=typeof e[t])return!1;return!0}class sn extends Error{constructor(e){super(e)}}class an{constructor({hostFrame:e,source:t,sourceId:n}){this._hostFrame=e,this._source=t,this._sourceId=n,this._listeners=new we}destroy(){this._listeners.removeAll()}async discover(e){const t=on(6);return new Promise(((n,o)=>{const i=()=>{this._hostFrame.postMessage({frame1:this._source,frame2:e,type:"request",requestId:t,sourceId:this._sourceId},"*")},r=setInterval(i,250),s=setTimeout((()=>{clearInterval(r),o(new sn(`Unable to establish ${this._source}-${e} communication channel`))}),2e4),a=this._listeners.add(window,"message",(i=>{const{data:l,ports:c}=i;rn(l)&&l.requestId===t&&"request"!==l.type&&(clearInterval(r),clearTimeout(s),this._listeners.remove(a),
|
63
|
+
"string"==typeof l.error?o(new sn(l.error)):c.length>0?n(c[0]):o(new sn(`${this._source}-${e} port request failed`)))}));i()}))}}class ln{#e=[];destroy(){this.#e=[]}on(e,t){this.#e.push({name:e,callback:t})}off(e,t){this.#e=this.#e.filter((n=>!(n.name===e&&n.callback===t)))}emit(e,...t){for(const n of this.#e){if(n.name!==e)continue;(0,n.callback)(...t)}}}let cn=null;function hn(e){return e instanceof Error?{message:e.message,stack:e.stack}:{message:String(e),stack:void 0}}function dn(e,t){if(!cn)return;const n={type:"hypothesis-error",error:e instanceof Error?e:hn(e),context:t};try{try{cn.postMessage(n,"*")}catch(e){if(!(e instanceof DOMException&&"DataCloneError"===e.name))throw e;n.error=hn(n.error),cn.postMessage(n,"*")}}catch(e){console.warn("Unable to report Hypothesis error",e)}}function un(e){cn=e}class fn{constructor(e){this._hypothesisAppsOrigin=e,this._emitter=new ln,this._handledRequests=new Set,this._sidebarHostChannel=new MessageChannel,this._sidebarConnected=!1,this._listeners=new we,
|
64
|
+
this._allowedMessages=[{allowedOrigin:"*",frame1:"guest",frame2:"host",type:"request"},{allowedOrigin:"*",frame1:"guest",frame2:"sidebar",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"sidebar",frame2:"host",type:"request"},{allowedOrigin:this._hypothesisAppsOrigin,frame1:"notebook",frame2:"sidebar",type:"request"}],this._listen()}_listen(){const e="Handling port request",t=new Set,n=n=>{t.has(n)||(t.add(n),dn(new Error(n),e))};var o,i;this._listeners.add(window,"message",(o=e=>{const{data:t,origin:o,source:i}=e;if(!i)return;if(!rn(t)||"request"!==t.type)return;const{frame1:r,frame2:s,requestId:a,sourceId:l}=t,c=`${r}-${s}`;if(!function(e){return!(null===e||e instanceof MessagePort||window.ServiceWorker&&e instanceof ServiceWorker)}(i))return void n(`Ignored port request for channel ${c} from non-Window source`);if(void 0===this._allowedMessages.find((({allowedOrigin:e,...n})=>this._messageMatches({allowedMessage:n,allowedOrigin:e,data:t,origin:o
|
65
|
+
}))))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=e,(...e)=>{try{return o(...e)}catch(e){throw dn(e,i),e}}))}_messageMatches({allowedMessage:e,allowedOrigin:t,data:n,origin:o}){return("*"===t||o===t)&&function(e,t){return!!rn(e)&&JSON.stringify(e,Object.keys(t).sort())===JSON.stringify(t,Object.keys(t).sort())}(n,e)}on(e,t){this._emitter.on(e,t)}destroy(){
|
66
|
+
this._listeners.removeAll()}}const mn="1.0.0",pn="frame-rpc";function gn(e,t=[],n=-1){return{protocol:pn,version:mn,arguments:t,method:e,sequence:n}}function _n(e,t,n=[],o=-1){e.postMessage(gn(t,n,o))}function bn(e){const t=e.match(/\bAppleWebKit\/([0-9]+)\b/);if(!t)return!1;if(parseInt(t[1])<=537)return!1;const n=e.match(/\bVersion\/([0-9]+)\b/);if(!n)return!1;return!(parseInt(n[1])>=16)}class wn{constructor({userAgent:e=navigator.userAgent,currentWindow:t=window,forceUnloadListener:n=!1}={}){this._port=null,this._methods=new Map,this._sequence=1,this._callbacks=new Map,this._listeners=new we,"onclose"in MessagePort.prototype&&!n||this._listeners.add(t,"unload",(n=>{n instanceof CustomEvent||this._port&&(_n(this._port,"close"),t!==t.parent&&bn(e)&&t.parent.postMessage({type:"hypothesisPortClosed"},"*",[this._port]))})),this._pendingCalls=[],this._destroyed=!1,this._receivedCloseEvent=!1}on(e,t){if(this._port)throw new Error("Cannot add a method handler after a port is connected");this._methods.set(e,t)}
|
67
|
+
connect(e){this._port=e,this._listeners.add(e,"message",(e=>this._handle(e))),this._listeners.add(e,"close",(()=>{e.dispatchEvent(new MessageEvent("message",{data:gn("close")}))})),e.start(),_n(e,"connect");for(const[e,t]of this._pendingCalls)this.call(e,...t);this._pendingCalls=[]}destroy(){this._port&&(_n(this._port,"close"),this._port.close()),this._destroyed=!0,this._listeners.removeAll()}call(e,...t){if(this._port||this._pendingCalls.push([e,t]),!this._port||this._destroyed)return;const n=this._sequence++,o=t[t.length-1];"function"==typeof o&&(this._callbacks.set(n,o),t=t.slice(0,-1)),_n(this._port,e,t,n)}_parseMessage({data:e}){return e&&"object"==typeof e?e.protocol!==pn||e.version!==mn?null:Array.isArray(e.arguments)?e:null:null}_handle(e){const t=this._parseMessage(e),n=this._port;if(t&&n)if("method"in t){if("close"===t.method){if(this._receivedCloseEvent)return;this._receivedCloseEvent=!0}const e=this._methods.get(t.method);if(!e)return;const o=(...e)=>{const o={arguments:e,protocol:pn,
|
68
|
+
response:t.sequence,version:mn};n.postMessage(o)};e(...t.arguments,o)}else if("response"in t){const e=this._callbacks.get(t.response);this._callbacks.delete(t.response),e&&e(...t.arguments)}}}function vn(e){if("string"==typeof e&&"false"===e.trim().toLocaleLowerCase())return!1;const t=Number(e);return isNaN(t)?"string"==typeof e:Boolean(t)}function yn(e){for(var t={},n=e.querySelectorAll("script.js-hypothesis-config"),o=0;o<n.length;o++){var i=void 0;try{i=JSON.parse(n[o].textContent||"")}catch(e){console.warn("Could not parse settings from js-hypothesis-config tags",e),i={}}Object.assign(t,i)}return t}function xn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Nn(e){return e.width<=0||e.height<=0}function Cn(e,t,n,o){return Math.max(e,n)<Math.min(t,o)}function Sn(e,t){return!Nn(e)&&!Nn(t)&&(Cn(e.left,e.right,t.left,t.right)&&Cn(e.top,e.bottom,t.top,t.bottom))}function An(e,t){return Cn(e.top,e.bottom,t.top,t.bottom)}function En(e,t){return Cn(e.left,e.right,t.left,t.right)}function kn(e,t){
|
69
|
+
if(Nn(e))return t;if(Nn(t))return e;const n=Math.min(e.left,t.left),o=Math.min(e.top,t.top),i=Math.max(e.right,t.right),r=Math.max(e.bottom,t.bottom);return new DOMRect(n,o,i-n,r-o)}function Rn(e){return new DOMPoint((e.left+e.right)/2,(e.top+e.bottom)/2)}function Pn(e){return e.nodeType===Node.ELEMENT_NODE}function Tn(e){return e.nodeType===Node.TEXT_NODE}const Mn=["p",".para"];let Ln;function On(e,t=0,n=e.data.length){return Ln||(Ln=document.createRange()),Ln.setStart(e,t),Ln.setEnd(e,n),Ln.getBoundingClientRect()}function In(e){const t=e.getBoundingClientRect();return t.x-=e.scrollLeft,t.y-=e.scrollTop,t.height=Math.max(t.height,e.scrollHeight),t.width=Math.max(t.width,e.scrollWidth),t}function*Bn(e,t,n){let o=e.firstChild;for(;o;){if(Pn(o)){const e=Sn(In(o),t);n(o)&&e&&(yield*Bn(o,t,n))}else Tn(o)&&Sn(On(o),t)&&(yield o);o=o.nextSibling}}function Dn(e,t){let n=null;const o=e=>!function(e){switch(getComputedStyle(e).position){case"fixed":case"sticky":return!0;default:return!1}}(e)
|
70
|
+
;e:for(const s of Bn(e,t,o)){let e=0;for(const o of s.data.split(/\b/)){if(/\S/.test(o)){const a=e,l=e+o.length,c=On(s,a,l);if(r=c,!Nn(i=t)&&!Nn(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 e}}e+=o.length}}var i,r;return n}function Fn(e,t=document.documentElement,n=new DOMRect(0,0,window.innerWidth,window.innerHeight)){const o=Dn(t,n);if(!o)return e(),0;const i=o.getBoundingClientRect().top;e();const r=o.getBoundingClientRect().top-i;return t.scrollTop+=r,r}function Hn(e,t,n){const o=e.document.querySelector(`link[type="application/annotator+${n}"][rel="${t}"]`);if(!o)throw new Error(`No application/annotator+${n} (rel="${t}") link in the document`);if(!o.href)throw new Error(`application/annotator+${n} (rel="${t}") link has no href`);return o.href}function Vn(e){return"string"==typeof e?e:null}function Un(e){const t=function(e){if(!xn(e,"hypothesisConfig"))return{};if("function"!=typeof e.hypothesisConfig){
|
71
|
+
const e="https://h.readthedocs.io/projects/client/en/latest/publishers/config/#window.hypothesisConfig";return console.warn("hypothesisConfig must be a function, see: "+e),{}}return e.hypothesisConfig()}(e),n=vn(t.ignoreOtherConfiguration)?{}:yn(e.document);function o(e){return xn(t,e)?t[e]:xn(n,e)?n[e]:void 0}return{get annotations(){return Vn(n.annotations)||function(){const t=e.location.href.match(/#annotations:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get clientUrl(){return Hn(e,"hypothesis-client","javascript")},get group(){return Vn(n.group)||function(){const t=e.location.href.match(/#annotations:group:([A-Za-z0-9_-]+)$/);return t?t[1]:null}()},get notebookAppUrl(){return Hn(e,"notebook","html")},get profileAppUrl(){return Hn(e,"profile","html")},get showHighlights(){return function(){const e=o("showHighlights");switch(e){case"always":case"never":case"whenSidebarOpen":return e;case!0:return"always";case!1:return"never";default:return"always"}}()},get sidebarAppUrl(){return Hn(e,"sidebar","html")},
|
72
|
+
get query(){return Vn(n.query)||function(){const t=e.location.href.match(/#annotations:(query|q):(.+)$/i);if(t)try{return decodeURIComponent(t[2])}catch{}return null}()},get sideBySide(){return function(){const e=o("sideBySide");if(!function(e){return null!==e&&"object"==typeof e}(e))return{mode:"auto"};const t="mode"in e&&function(e){return"string"==typeof e&&["auto","manual"].includes(e)}(e.mode)?e.mode:"auto";return"auto"===t?{mode:t}:{mode:t,isActive:"isActive"in e&&"function"==typeof e.isActive?e.isActive:void 0}}()},hostPageSetting:o}}const qn=(e,t)=>e.hostPageSetting(t),zn={annotations:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.annotations},appType:{allowInBrowserExt:!0,defaultValue:null,getValue:qn},branding:{defaultValue:null,allowInBrowserExt:!1,getValue:qn},bucketContainerSelector:{defaultValue:null,allowInBrowserExt:!1,getValue:qn},clientUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.clientUrl},contentInfoBanner:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},
|
73
|
+
contentReady:{allowInBrowserExt:!0,defaultValue:null,getValue:qn},enableExperimentalNewNoteButton:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},group:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.group},focus:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},theme:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},usernameUrl:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},onLayoutChange:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},openSidebar:{allowInBrowserExt:!0,defaultValue:!1,coerce:vn,getValue:qn},query:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.query},requestConfigFromFrame:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},services:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},showHighlights:{allowInBrowserExt:!1,defaultValue:"always",getValue:e=>e.showHighlights},notebookAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.notebookAppUrl},profileAppUrl:{allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.profileAppUrl},sidebarAppUrl:{
|
74
|
+
allowInBrowserExt:!0,defaultValue:null,getValue:e=>e.sidebarAppUrl},subFrameIdentifier:{allowInBrowserExt:!0,defaultValue:null,getValue:qn},externalContainerSelector:{allowInBrowserExt:!1,defaultValue:null,getValue:qn},sideBySide:{allowInBrowserExt:!0,getValue:e=>e.sideBySide}};function $n(e,t=window){const n=Un(t),o={};for(const r of function(e){const t={annotator:["clientUrl","contentInfoBanner","contentReady","subFrameIdentifier","sideBySide"],sidebar:["appType","annotations","branding","bucketContainerSelector","enableExperimentalNewNoteButton","externalContainerSelector","focus","group","onLayoutChange","openSidebar","query","requestConfigFromFrame","services","showHighlights","sidebarAppUrl","theme","usernameUrl"],notebook:["branding","group","notebookAppUrl","requestConfigFromFrame","services","theme","usernameUrl"],profile:["profileAppUrl"]};return"all"===e?Object.values(t).flat():t[e]}(e)){
|
75
|
+
const e=zn[r],s=void 0!==e.defaultValue,a=!((i=Hn(t,"sidebar","html")).startsWith("http://")||i.startsWith("https://"));if(!e.allowInBrowserExt&&a){s&&(o[r]=e.defaultValue);continue}const l=e.getValue(n,r);void 0!==l?o[r]=e.coerce?e.coerce(l):l:s&&(o[r]=e.defaultValue)}var i;return o}const Wn={alt:1,ctrl:2,meta:4,shift:8};function jn(e,t){if(!(e instanceof KeyboardEvent))return!1;const n=t.split("+").map((e=>e.toLowerCase()));let o=0,i=null;for(const e of n){const t=Wn[e];if(t)o|=t;else{if(null!==i)throw new Error("Multiple non-modifier keys specified");i=e}}if(!i)throw new Error(`Invalid shortcut: ${t}`);return((e.ctrlKey?Wn.ctrl:0)|(e.metaKey?Wn.meta:0)|(e.altKey?Wn.alt:0)|(e.shiftKey?Wn.shift:0))===o&&e.key.toLowerCase()===i}function Xn(e,t,{rootElement:n}={}){ie((()=>{if(e)return function(e,t,{rootElement:n=document.documentElement??void 0}={}){const o=n=>{jn(n,e)&&t(n)};return n?(n.addEventListener("keydown",o),()=>n.removeEventListener("keydown",o)):()=>{}}(e,t,{rootElement:n})}),[e,t,n])}
|
76
|
+
const Yn=(e=window)=>e.matchMedia("(pointer: coarse)").matches;function Kn({badgeCount:e}){return Te("span",{className:Re("rounded px-1 py-0.5","bg-current"),children:Te("span",{className:"font-bold text-color-text-inverted",children:e})})}function Gn({arrowDirection:e}){return Te("div",{className:Re("absolute left-1/2 -translate-x-1/2 z-2","fill-white text-grey-3",{"top-0 -translate-y-full":"up"===e}),children:Te("up"===e?pt:ft,{})})}function Qn({badgeCount:e,icon:t,label:n,onClick:o,shortcut:i}){Xn(i,o);const r=i?`${n} (${i})`:n;return Te(St,{classes:Re("text-grey-7","group-hover:text-grey-5","hover:group-hover:text-grey-9"),onClick:o,title:r,size:"custom",variant:"custom",children:Te("div",{className:Re("flex flex-col items-center gap-y-1 py-2.5 px-2","text-annotator-sm leading-none"),children:[t&&Te(t,{className:"text-annotator-lg",title:r}),"number"==typeof e&&Te(Kn,{badgeCount:e}),Te("span",{"data-testid":"adder-button-label",children:n})]})})}function Jn({annotationCount:e,isVisible:t}){
|
77
|
+
return Te("div",{className:"sr-only",children:[Te("span",{"aria-live":"polite","aria-atomic":"true",role:"status","data-testid":"annotation-count-announce",children:e>0&&Te("span",{children:[e," ",1===e?"annotation":"annotations"," for this selection."]})}),Te("ul",{"aria-live":"polite","data-testid":"annotate-shortcuts-announce",children:t&&Te(x,{children:[e>0&&Te("li",{children:["Press ","'S'"," to show annotations."]}),Te("li",{children:["Press ","'A'"," to annotate."]}),Te("li",{children:["Press ","'H'"," to highlight."]})]})})]})}function Zn({arrowDirection:e,isVisible:t,onCommand:n,annotationCount:o=0}){const i=t?"a":null,r=t?"h":null,s=t?"s":null;return Xn(t?"Escape":null,(()=>n("hide"))),Te("div",{className:Re("all-initial","border border-solid border-grey-3","absolute select-none bg-white rounded shadow-intense","opacity-5",{"animate-adder-pop-up":"up"===e&&t,"animate-adder-pop-down":"down"===e&&t}),"data-component":"AdderToolbar",dir:"ltr",style:{visibility:t?"visible":"hidden"},children:[Te("div",{
|
78
|
+
className:Re("flex group"),children:[Te(Qn,{icon:De,onClick:()=>n("annotate"),label:"Annotate",shortcut:i}),Te(Qn,{icon:ot,onClick:()=>n("highlight"),label:"Highlight",shortcut:r}),o>0&&Te(x,{children:[Te("div",{className:Re("m-1.5 border-r border-grey-4 border-solid")}),Te(Qn,{badgeCount:o,onClick:()=>n("show"),label:"Show",shortcut:s})]})]}),Te(Gn,{arrowDirection:e}),Te(Jn,{annotationCount:o,isVisible:t})]})}function eo(e){const t=e.attachShadow({mode:"open"});!function(e){const t=document.querySelector('link[rel="preload"][href*="/build/styles/annotator.css"]')?.href;if(!t)return;const n=document.createElement("link");n.rel="stylesheet",n.href=t,e.appendChild(n)}(t);const n=window.applyFocusVisiblePolyfill;return n&&n(t),t}class to{constructor(e,t){const n=`hypothesis-${e}`;this._element=document.createElement(n),this._shadowRoot=eo(this._element),this._render=t}destroy(){U(null,this._shadowRoot),this._element.remove()}get element(){return this._element}render(){U(this._render(),this._shadowRoot)}}
|
79
|
+
let no=function(e){return e[e.DOWN=1]="DOWN",e[e.UP=2]="UP",e}({});function oo(e){return e.toString()+"px"}class io{constructor(e,t){this._view=e.ownerDocument.defaultView,this._isVisible=!1,this._arrowDirection="up",this._annotationsForSelection=[],this._onAnnotate=t.onAnnotate,this._onHighlight=t.onHighlight,this._onShowAnnotations=t.onShowAnnotations,this._container=new to("adder",(()=>this._render())),e.appendChild(this._container.element),Object.assign(this._container.element.style,{position:"absolute",top:0,left:0}),this._container.render()}get annotationsForSelection(){return this._annotationsForSelection}set annotationsForSelection(e){this._annotationsForSelection=e,this._container.render()}hide(){this._isVisible=!1,this._container.render(),Object.assign(this._container.element.style,{top:0,left:0})}destroy(){this._container.destroy()}show(e,t){const{left:n,top:o,arrowDirection:i}=this._calculateTarget(e,t);this._showAt(n,o),this._isVisible=!0,this._arrowDirection=i===no.UP?"up":"down",
|
80
|
+
this._container.render()}_firstChild(){return this._container.element.shadowRoot.firstChild}_width(){return this._firstChild().getBoundingClientRect().width}_height(){return this._firstChild().getBoundingClientRect().height}_calculateTarget(e,t){let n,o,i;n=t&&!Yn()?no.DOWN:no.UP;const r=Math.min(20,e.width),s=this._width(),a=Yn()?10:0,l=this._height();return i=t?e.left-s/2+r:e.left+e.width-s/2-r,e.top-l<0&&n===no.DOWN?n=no.UP:e.top+l>this._view.innerHeight&&(n=no.DOWN),o=n===no.UP?e.top+e.height+10+a:e.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(e,t){if(void 0===document.elementsFromPoint)return 32768
|
81
|
+
;const n=this._width(),o=this._height(),i=[...new Set([...document.elementsFromPoint(e,t),...document.elementsFromPoint(e,t+o),...document.elementsFromPoint(e+n/2,t+o/2),...document.elementsFromPoint(e+n,t),...document.elementsFromPoint(e+n,t+o)])].map((e=>+getComputedStyle(e).zIndex)).filter(Number.isInteger);return i.push(0),Math.max(...i)+1}_showAt(e,t){const n=function(e){let t=e.parentElement;for(;t.parentElement&&"static"===getComputedStyle(t).position;)t=t.parentElement;return t}(this._container.element).getBoundingClientRect(),o=this._findZindex(e,t);Object.assign(this._container.element.style,{left:oo(e-n.left),top:oo(t-n.top),zIndex:o})}_render(){return Te(Zn,{isVisible:this._isVisible,arrowDirection:this._arrowDirection,onCommand:e=>{switch(e){case"annotate":this._onAnnotate(),this.hide();break;case"highlight":this._onHighlight(),this.hide();break;case"show":this._onShowAnnotations(this.annotationsForSelection);break;case"hide":this.hide()}},annotationCount:this.annotationsForSelection.length})}}
|
82
|
+
var ro=function(e){return e[e.Forwards=1]="Forwards",e[e.Backwards=2]="Backwards",e}(ro||{});function so(e,t,n){const o=n===ro.Forwards?t:t-1;if(""!==e.charAt(o).trim())return t;let i,r;if(n===ro.Backwards?(i=e.substring(0,t),r=i.trimEnd()):(i=e.substring(t),r=i.trimStart()),!r.length)return-1;const s=i.length-r.length;return n===ro.Backwards?t-s:t+s}function ao(e,t){const n=e.commonAncestorContainer.ownerDocument.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_TEXT),o=t===ro.Forwards?e.startContainer:e.endContainer,i=t===ro.Forwards?e.endContainer:e.startContainer;let r=n.nextNode();for(;r&&r!==o;)r=n.nextNode();t===ro.Backwards&&(r=n.previousNode());let s=-1;const a=()=>{if(r=t===ro.Forwards?n.nextNode():n.previousNode(),r){const e=r.textContent,n=t===ro.Forwards?0:e.length;s=so(e,n,t)}};for(;r&&-1===s&&r!==i;)a();if(r&&s>=0)return{node:r,offset:s};throw new RangeError("No text nodes with non-whitespace text found in range")}function lo(e){switch(e.nodeType){case Node.ELEMENT_NODE:
|
83
|
+
case Node.TEXT_NODE:return e.textContent?.length??0;default:return 0}}function co(e){let t=e.previousSibling,n=0;for(;t;)n+=lo(t),t=t.previousSibling;return n}function ho(e,...t){let n=t.shift();const o=e.ownerDocument.createNodeIterator(e,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=t.shift()):(s=o.nextNode(),a+=r.data.length);for(;void 0!==n&&r&&a===n;)i.push({node:r,offset:r.data.length}),n=t.shift();if(void 0!==n)throw new RangeError("Offset exceeds text length");return i}let uo=function(e){return e[e.FORWARDS=1]="FORWARDS",e[e.BACKWARDS=2]="BACKWARDS",e}({});class fo{constructor(e,t){if(t<0)throw new Error("Offset is invalid");this.element=e,this.offset=t}relativeTo(e){if(!e.contains(this.element))throw new Error("Parent is not an ancestor of current element");let t=this.element,n=this.offset;for(;t!==e;)n+=co(t),t=t.parentElement;return new fo(t,n)}resolve(e={}){try{return ho(this.element,this.offset)[0]}catch(t){
|
84
|
+
if(0===this.offset&&void 0!==e.direction){const n=document.createTreeWalker(this.element.getRootNode(),NodeFilter.SHOW_TEXT);n.currentNode=this.element;const o=e.direction===uo.FORWARDS,i=o?n.nextNode():n.previousNode();if(!i)throw t;return{node:i,offset:o?0:i.data.length}}throw t}}static fromCharOffset(e,t){switch(e.nodeType){case Node.TEXT_NODE:return fo.fromPoint(e,t);case Node.ELEMENT_NODE:return new fo(e,t);default:throw new Error("Node is not an element or text node")}}static fromPoint(e,t){switch(e.nodeType){case Node.TEXT_NODE:{if(t<0||t>e.data.length)throw new Error("Text node offset is out of range");if(!e.parentElement)throw new Error("Text node has no parent");const n=co(e)+t;return new fo(e.parentElement,n)}case Node.ELEMENT_NODE:{if(t<0||t>e.childNodes.length)throw new Error("Child node offset is out of range");let n=0;for(let o=0;o<t;o++)n+=lo(e.childNodes[o]);return new fo(e,n)}default:throw new Error("Point is not in an element or text node")}}}class mo{constructor(e,t){this.start=e,
|
85
|
+
this.end=t}relativeTo(e){return new mo(this.start.relativeTo(e),this.end.relativeTo(e))}toRange(){let e,t;this.start.element===this.end.element&&this.start.offset<=this.end.offset?[e,t]=ho(this.start.element,this.start.offset,this.end.offset):(e=this.start.resolve({direction:uo.FORWARDS}),t=this.end.resolve({direction:uo.BACKWARDS}));const n=new Range;return n.setStart(e.node,e.offset),n.setEnd(t.node,t.offset),n}static fromRange(e){const t=fo.fromPoint(e.startContainer,e.startOffset),n=fo.fromPoint(e.endContainer,e.endOffset);return new mo(t,n)}static fromOffsets(e,t,n){return new mo(new fo(e,t),new fo(e,n))}static trimmedRange(e){return function(e){if(!e.toString().trim().length)throw new RangeError("Range contains no non-whitespace text");if(e.startContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range startContainer is not a text node");if(e.endContainer.nodeType!==Node.TEXT_NODE)throw new RangeError("Range endContainer is not a text node");const t=e.cloneRange();let n=!1,o=!1;const i={
|
86
|
+
start:so(e.startContainer.textContent,e.startOffset,ro.Forwards),end:so(e.endContainer.textContent,e.endOffset,ro.Backwards)};if(i.start>=0&&(t.setStart(e.startContainer,i.start),n=!0),i.end>0&&(t.setEnd(e.endContainer,i.end),o=!0),n&&o)return t;if(!n){const{node:e,offset:n}=ao(t,ro.Forwards);e&&n>=0&&t.setStart(e,n)}if(!o){const{node:e,offset:n}=ao(t,ro.Backwards);e&&n>0&&t.setEnd(e,n)}return t}(mo.fromRange(e).toRange())}}const po=".annotator-placeholder";function go(e){return!!e.parentElement&&null!==e.parentElement.closest(po)}function _o(e,t){const n=new Range;return e.compareBoundaryPoints(Range.START_TO_START,t)<=0?n.setStart(e.startContainer,e.startOffset):n.setStart(t.startContainer,t.startOffset),e.compareBoundaryPoints(Range.END_TO_END,t)>=0?n.setEnd(e.endContainer,e.endOffset):n.setEnd(t.endContainer,t.endOffset),n}function bo(e=document.getSelection()){if(!e||0===e.rangeCount)return null;let t=e.getRangeAt(0);for(let n=1;n<e.rangeCount;n++)t=_o(t,e.getRangeAt(n));return t.collapsed?null:t}
|
87
|
+
function wo(e){if(e.focusNode===e.anchorNode)return e.focusOffset<e.anchorOffset;return bo(e).startContainer===e.focusNode}function vo(e,t){try{const n=t.nodeValue?.length??t.childNodes.length;return e.comparePoint(t,0)<=0&&e.comparePoint(t,n)>=0}catch{return!1}}function yo(e,t){const n=e.commonAncestorContainer,o=n.ownerDocument.createNodeIterator(n,NodeFilter.SHOW_ALL);let i;for(;i=o.nextNode();)vo(e,i)&&t(i)}function xo(e){const t=bo(e);if(!t)return null;const n=function(e){const t=[];return yo(e,(e=>{Tn(e)&&!e.textContent.match(/^\s*$/)&&t.push(e)})),t.flatMap((t=>{const n=t.ownerDocument.createRange();if(n.selectNodeContents(t),t===e.startContainer&&n.setStart(t,e.startOffset),t===e.endContainer&&n.setEnd(t,e.endOffset),n.collapsed)return[];const o=Array.from(n.getClientRects());return n.detach(),o}))}(t);return 0===n.length?null:wo(e)?n[0]:n[n.length-1]}const No="http://www.w3.org/2000/svg",Co=["user-annotations","user-highlights","other-content"];function So(e,t){const n=function(e){
|
88
|
+
if(e.collapsed)return[];let t=e.commonAncestorContainer;if(t&&t.nodeType!==Node.ELEMENT_NODE&&(t=t.parentElement),!t)return[];const n=[],o=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT);let i;for(;i=o.nextNode();){if(!vo(e,i))continue;const t=i;t===e.startContainer&&e.startOffset>0?t.splitText(e.startOffset):(t===e.endContainer&&e.endOffset<t.data.length&&t.splitText(e.endOffset),n.push(t))}return n}(e),o=n.length>0&&go(n[0]);let i=[],r=null,s=null;n.forEach((e=>{r&&r.nextSibling===e?s.push(e):(s=[e],i.push(s)),r=e}));const a=/^\s*$/;i=i.filter((e=>{const t=e[0].parentElement;return 1===t?.childNodes.length&&"SPAN"===t?.tagName||e.some((e=>!a.test(e.data)))}));const l=[];return i.forEach((e=>{const n=document.createElement("hypothesis-highlight");n.className=Re("hypothesis-highlight",t);e[0].parentNode.replaceChild(n,e[0]),e.forEach((e=>n.appendChild(e))),l.push(n)})),o||function(e,t){if(0===e.length)return;const n=function(e){const t=e.closest(".page");if(!t)return null
|
89
|
+
;return t.querySelector(".canvasWrapper > canvas")||null}(e[0]);if(!n||!n.parentElement)return;let o=n.parentElement.querySelector(".hypothesis-highlight-layer");if(!o){o=document.createElementNS(No,"svg"),o.setAttribute("class","hypothesis-highlight-layer"),n.parentElement.appendChild(o),n.parentElement.style.position="relative";const e=o.style;e.position="absolute",e.left="0",e.top="0",e.width="100%",e.height="100%",e.mixBlendMode="multiply"}const i=n.getBoundingClientRect(),r=e.map((e=>{const n=e.getBoundingClientRect(),o=document.createElementNS(No,"rect");return o.setAttribute("x",(n.left-i.left).toString()),o.setAttribute("y",(n.top-i.top).toString()),o.setAttribute("width",n.width.toString()),o.setAttribute("height",n.height.toString()),o.setAttribute("class",Re("hypothesis-svg-highlight",t)),e.classList.add("is-transparent"),e.svgHighlight=o,o}));o.append(...r)}(l,t),l}function Ao(e,t){const n=e.parentNode;t.forEach((t=>n.insertBefore(t,e))),e.remove()}function Eo(e){ko(e,!1);for(const t of e){
|
90
|
+
if(t.parentNode){Ao(t,Array.from(t.childNodes))}t.svgHighlight&&t.svgHighlight.remove()}}function ko(e,t){e.forEach((e=>{e.svgHighlight?function(e,t){const n=e.parentNode,o=e.getAttribute("data-focused-id");if(Boolean(o)!==t)if(t){e.setAttribute("data-focused-id",on(8));const t=e.cloneNode();t.setAttribute("data-is-focused","data-is-focused"),n.append(t)}else{const t=n.querySelector(`[data-focused-id="${o}"][data-is-focused]`);t?.remove(),e.removeAttribute("data-focused-id")}}(e.svgHighlight,t):e.classList.toggle("hypothesis-highlight-focused",t)}))}function Ro(e){Mo(To(e)),function(e){for(const[t,n]of function(e){const t=new Map;for(const n of(e??document).getElementsByClassName("hypothesis-highlight-layer"))t.set(n,Array.from(n.querySelectorAll(".hypothesis-svg-highlight")));return t}(e)){n.every(((e,t,n)=>0===t||Lo(e)>=Lo(n[t-1])))||(n.sort(((e,t)=>Lo(e)-Lo(t))),t.replaceChildren(...n))}}(e)}const Po=e=>"hypothesis-highlight"===e.tagName.toLowerCase();function To(e){let t
|
91
|
+
;return t=Po(e)?Array.from(e.children).filter(Po):Array.from(e.getElementsByTagName("hypothesis-highlight")).filter((e=>!e.parentElement||!Po(e.parentElement))),t}function Mo(e,t="",n=0,o=0){for(const i of e){const e=Co.find((e=>i.classList.contains(e)))??"other-content",r=t&&e===t?o+1:0;i.setAttribute("data-nesting-level",`${n}`),i.setAttribute("data-cluster-level",`${r}`),i.svgHighlight&&(i.svgHighlight.setAttribute("data-nesting-level",`${n}`),i.svgHighlight.setAttribute("data-cluster-level",`${r}`)),Mo(To(i),e,n+1,r)}}function Lo(e){return e.getAttribute("data-is-focused")?Number.MAX_SAFE_INTEGER:parseInt(e.getAttribute("data-nesting-level")??"0",10)}function Oo(e){const t=[];return e.forEach((({annotation:e,highlights:n})=>{if(!n?.length)return;const{top:o,bottom:i}=function(e){const t=e.map((e=>e.getBoundingClientRect()));return t.reduce(((e,t)=>({top:Math.min(e.top,t.top),left:Math.min(e.left,t.left),bottom:Math.max(e.bottom,t.bottom),right:Math.max(e.right,t.right)})))}(n);o>=i||t.push({tag:e.$tag,
|
92
|
+
top:o,bottom:i})})),t.sort(((e,t)=>e.top-t.top)),t}class Io{constructor({contentContainer:e,hostRPC:t}){this._hostRPC=t,this._updatePending=!1,this._anchors=[],this._listeners=new we,this._listeners.add(window,"resize",(()=>this.update())),this._listeners.add(window,"scroll",(()=>this.update())),this._listeners.add(e,"scroll",(()=>this.update()),{capture:!0})}destroy(){this._listeners.removeAll()}update(e){e&&(this._anchors=e),this._updatePending||(this._updatePending=!0,requestAnimationFrame((()=>{const e=Oo(this._anchors);this._hostRPC.call("anchorsChanged",e),this._updatePending=!1})))}}function Bo(e){const t=Math.min(e.left,e.right),n=Math.max(e.left,e.right);return{type:"rect",left:t,top:Math.min(e.top,e.bottom),right:n,bottom:Math.max(e.top,e.bottom)}}class Do extends Error{constructor(e="Drawing failed"){super(e)}}class Fo{constructor(e){this._container=e,this._tool="rect"}destroy(){this.cancel()}async draw(e){this._tool=e,this.cancel()
|
93
|
+
;const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("data-testid","surface"),t.style.cursor="crosshair",t.style.position="absolute",t.setAttribute("width","100%"),t.setAttribute("height","100%"),t.style.left="0px",t.style.top="0px",t.style.zIndex="10",this._container.append(t),this._surface=t;const{promise:n,resolve:o,reject:i}=function(){let e,t;return{promise:new Promise(((n,o)=>{e=n,t=o})),resolve:e,reject:t}}();return this._drawEnd=o,this._drawError=i,this._surface.addEventListener("mousedown",(e=>{switch(this._tool){case"rect":this._shape={type:"rect",left:e.clientX,top:e.clientY,right:e.clientX,bottom:e.clientY},this._renderSurface();break;case"point":o({type:"point",x:e.clientX,y:e.clientY}),this._abortDraw?.abort()}})),this._surface.addEventListener("mousemove",(e=>{this._shape&&(this._shape.right=e.clientX,this._shape.bottom=e.clientY,this._renderSurface())})),this._surface.addEventListener("mouseup",(e=>{this._shape&&(this._shape.right=e.clientX,
|
94
|
+
this._shape.bottom=e.clientY,o(Bo(this._shape)),this._abortDraw?.abort())})),this._surface.addEventListener("wheel",(e=>{let t=Math.abs(e.deltaY),n=Math.abs(e.deltaX);for(const o of document.elementsFromPoint(e.clientX,e.clientY)){const i=o.scrollLeft;o.scrollLeft+=n*Math.sign(e.deltaX),n-=Math.abs(o.scrollLeft-i);const r=o.scrollTop;o.scrollTop+=t*Math.sign(e.deltaY),t-=Math.abs(o.scrollTop-r)}})),this._abortDraw=new AbortController,document.body.addEventListener("keydown",(e=>{"Escape"===e.key&&(this._drawError&&this._drawError(new Do("Drawing canceled")),this._abortDraw?.abort())}),{signal:this._abortDraw.signal}),this._abortDraw.signal.onabort=()=>{this._surface?.remove(),this._shape=void 0,this._surface=void 0,this._drawError=void 0,this._drawEnd=void 0,this._abortDraw=void 0},this._renderSurface(),n}cancel(){this._drawError&&this._drawError(new Do("Drawing canceled")),this._abortDraw?.abort()}_renderSurface(){if(this._surface)if("rect"===this._shape?.type){const e=Bo(this._shape);U(Te(x,{
|
95
|
+
children:[Te("rect",{stroke:"white","stroke-dasharray":"5","stroke-width":"1px",fill:"grey","fill-opacity":"0.5",x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}),Te("rect",{stroke:"grey","stroke-dasharray":"5","stroke-dashoffset":"5","stroke-width":"1px",fill:"none",x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top})]}),this._surface)}else U(null,this._surface)}}class Ho extends CustomEvent{constructor(e){super("hypothesis:layoutchange",{bubbles:!0,cancelable:!1,detail:e})}}const Vo=new Set;function Uo(...e){const t=e.join();Vo.has(t)||(console.warn(...e),Vo.add(t))}Uo.reset=()=>{Vo.clear()};const qo=["pdf_image_annotation","styled_highlight_clusters"];class zo extends ln{constructor(e=qo){super(),this._flags=new Map,this._knownFlags=e}update(e){this._flags.clear();for(const[t,n]of Object.entries(e))this._flags.set(t,n);this.emit("flagsChanged")}flagEnabled(e){return this._knownFlags.includes(e)?this._flags.get(e)??!1:(Uo("Looked up unknown feature",e),!1)}allFlags(){
|
96
|
+
return Object.fromEntries(this._flags)}}function $o({cluster:e,label:t,onChange:n,currentStyles:o,highlightStyles:i}){const r=o[e],s="transparent"===r;return Te("div",{className:"space-y-2",children:[Te("div",{className:"flex items-center gap-x-2 text-annotator-base",children:Te("div",{className:"grow text-color-text px-2 py-1 rounded",style:{backgroundColor:i[r].color},children:t})}),Te("div",{className:"flex items-center gap-x-2",children:Object.keys(i).map((t=>Te("div",{className:"relative",children:[Te("input",{className:Re("absolute w-6 h-6","opacity-[.00001]","cursor-pointer"),name:e,id:`hypothesis-${e}-${t}`,checked:r===t,onChange:n,type:"radio",value:t}),Te("label",{className:"block",htmlFor:`${e}-${t}`,children:[Te("div",{style:{backgroundColor:i[t].color},className:Re("block w-6 h-6 rounded-full flex items-center justify-center",{"border-2 border-slate-0":r!==t,"border-2 border-slate-3":r===t}),children:"transparent"===t&&Te(tt,{className:Re("w-3 h-3",{"text-slate-3":!s,"text-slate-7":s})})
|
97
|
+
}),Te("span",{className:"sr-only",children:t})]})]},`${e}-${t}`)))})]})}function Wo({active:e,availableStyles:t,currentStyles:n,onStyleChange:o}){const i=le((e=>{const t=e.target,n=t.name,i=t.value;o(n,i)}),[o]),[r,s]=oe(!1);return e?Te(Le,{classes:"overflow-hidden",children:Te("div",{className:"flex flex-col text-annotator-base text-color-text",children:[Te(St,{classes:"rounded-none","data-testid":"control-toggle-button",onClick:()=>s(!r),title:r?"Hide highlight settings":"Show highlight settings",children:Te(x,r?{children:[Te(Ue,{}),Te("span",{children:"Highlight Appearance"})]}:{children:[Te(We,{}),Te(ot,{})]})}),r&&Te(Ie,{"data-testid":"cluster-style-controls",size:"sm",children:[Te($o,{highlightStyles:t,label:"My annotations",cluster:"user-annotations",onChange:i,currentStyles:n}),Te($o,{highlightStyles:t,label:"My highlights",cluster:"user-highlights",onChange:i,currentStyles:n}),Te($o,{highlightStyles:t,label:"Everybody's content",cluster:"other-content",onChange:i,currentStyles:n})]})]})}):null}
|
98
|
+
const jo={transparent:{color:"transparent",secondColor:"transparent",thirdColor:"transparent"},pink:{color:"var(--hypothesis-color-pink)",secondColor:"var(--hypothesis-color-pink-1)",thirdColor:"var(--hypothesis-color-pink-2)"},orange:{color:"var(--hypothesis-color-orange)",secondColor:"var(--hypothesis-color-orange-1)",thirdColor:"var(--hypothesis-color-orange-2)"},yellow:{color:"var(--hypothesis-color-yellow)",secondColor:"var(--hypothesis-color-yellow-1)",thirdColor:"var(--hypothesis-color-yellow-2)"},green:{color:"var(--hypothesis-color-green)",secondColor:"var(--hypothesis-color-green-1)",thirdColor:"var(--hypothesis-color-green-2)"},purple:{color:"var(--hypothesis-color-purple)",secondColor:"var(--hypothesis-color-purple-1)",thirdColor:"var(--hypothesis-color-purple-2)"},grey:{color:"var(--hypothesis-color-grey)",secondColor:"var(--hypothesis-color-grey-1)",thirdColor:"var(--hypothesis-color-grey-2)"}},Xo={"other-content":"yellow","user-annotations":"orange","user-highlights":"purple"};class Yo{
|
99
|
+
constructor(e,t){this._element=e,this._features=t.features,this._container=new to("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=Xo,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 e of Object.keys(this.appliedStyles))this._setClusterStyles(e,this.appliedStyles[e]);this._activate(this._isActive())}_updateClusters(){this._isActive()&&Ro(this._element)}_isActive(){return this._features.flagEnabled("styled_highlight_clusters")}_activate(e){this._element.classList.toggle("hypothesis-highlights-clustered",e),this._container.render()}
|
100
|
+
_setClusterStyle(e,t){document.documentElement.style.setProperty(e,t)}_setClusterStyles(e,t){const n=jo[t];for(const t of Object.keys(n))this._setClusterStyle(`--hypothesis-${e}-${t}`,n[t])}_onChangeClusterStyle(e,t){this.appliedStyles[e]=t,this._setClusterStyles(e,t),this._container.render()}_render(){return Te(Wo,{active:this._isActive(),availableStyles:jo,currentStyles:this.appliedStyles,onStyleChange:(e,t)=>this._onChangeClusterStyle(e,t)})}}function Ko(e){return e.split("").reverse().join("")}function Go(e){return(e|-e)>>31&1}function Qo(e,t,n,o){let i=e.P[n],r=e.M[n];const s=o>>>31,a=t[n]|s,l=a|r,c=(a&i)+i^i|a;let h=r|~(c|i),d=i&c;const u=Go(h&e.lastRowMask[n])-Go(d&e.lastRowMask[n]);return h<<=1,d<<=1,d|=s,h|=Go(o)-s,i=d|~(l|h),r=h&l,e.P[n]=i,e.M[n]=r,u}function Jo(e,t,n){if(0===t.length)return[];n=Math.min(n,t.length);const o=[],i=32,r=Math.ceil(t.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<<(t.length-1)%i
|
101
|
+
;const a=new Uint32Array(r+1),l=new Map,c=[];for(let e=0;e<256;e++)c.push(a);for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(l.has(n))continue;const o=new Uint32Array(r+1);l.set(n,o),n<c.length&&(c[n]=o);for(let e=0;e<=r;e+=1){o[e]=0;for(let r=0;r<i;r+=1){const s=e*i+r;if(s>=t.length)continue;t.charCodeAt(s)===n&&(o[e]|=1<<r)}}}let h=Math.max(0,Math.ceil(n/i)-1);const d=new Uint32Array(r+1);for(let e=0;e<=h;e+=1)d[e]=(e+1)*i;d[r]=t.length;for(let e=0;e<=h;e+=1)s.P[e]=-1,s.M[e]=0;for(let u=0;u<e.length;u+=1){const f=e.charCodeAt(u);let m;f<c.length?m=c[f]:(m=l.get(f),void 0===m&&(m=a));let p=0;for(let e=0;e<=h;e+=1)p=Qo(s,m,e,p),d[e]+=p;if(d[h]-p<=n&&h<r&&(1&m[h+1]||p<0)){let e;if(h+=1,s.P[h]=-1,s.M[h]=0,h===r){const n=t.length%i;e=0===n?i:n}else e=i;d[h]=d[h-1]+e-p+Qo(s,m,h,p)}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 Zo(e,t,n){return function(e,t,n){const o=Ko(t);return n.map((n=>{
|
102
|
+
const i=Math.max(0,n.end-t.length-n.errors);return{start:Jo(Ko(e.slice(i,n.end)),o,n.errors).reduce(((e,t)=>n.end-t.end<e?n.end-t.end:e),n.end),end:n.end,errors:n.errors}}))}(e,t,Jo(e,t,n))}function ei(e,t,n){let o=0;const i=[];for(;-1!==o;)o=e.indexOf(t,o),-1!==o&&(i.push({start:o,end:o+t.length,errors:0}),o+=1);return i.length>0?i:Zo(e,t,n)}function ti(e,t){if(0===t.length||0===e.length)return 0;return 1-ei(e,t,t.length)[0].errors/t.length}function ni(e,t,n={}){if(0===t.length)return null;const o=Math.min(256,t.length/2),i=ei(e,t,o);if(0===i.length)return null;const r=o=>{const i=1-o.errors/t.length,r=n.prefix?ti(e.slice(Math.max(0,o.start-n.prefix.length),o.start),n.prefix):1,s=n.suffix?ti(e.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)/e.length}return(50*i+20*r+20*s+2*a)/92},s=i.map((e=>({start:e.start,end:e.end,score:r(e)})));return s.sort(((e,t)=>t.score-e.score)),s[0]}function oi(e){const t=function(e){const t=e.nodeName.toLowerCase()
|
103
|
+
;return"#text"===t?"text()":t}(e),n=function(e){let t=0,n=e;for(;n;)n.nodeName===e.nodeName&&(t+=1),n=n.previousSibling;return t}(e);return`${t}[${n}]`}function ii(e,t){let n="",o=e;for(;o!==t;){if(!o)throw new Error("Node is not a descendant of root");n=oi(o)+"/"+n,o=o.parentNode}return n="/"+n,n=n.replace(/\/$/,""),n}function ri(e,t,n){t=t.toUpperCase();let o=-1;for(let i=0;i<e.children.length;i++){const r=e.children[i];if(r.nodeName.toUpperCase()===t&&(++o,o===n))return r}return null}function si(e,t=document.body){try{return function(e,t){if(null===e.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+\])?)+$/))throw new Error("Expression is not a simple XPath");const n=e.split("/");let o=t;n.shift();for(const e of n){let t,n;const i=e.indexOf("[");if(-1!==i){t=e.slice(0,i);const o=e.slice(i+1,e.indexOf("]"));if(n=parseInt(o)-1,n<0)return null}else t=e,n=0;const r=ri(o,t,n);if(!r)return null;o=r}return o}(e,t)}catch{return document.evaluate("."+e,t,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}}class ai{
|
104
|
+
constructor(e,t){this.root=e,this.range=t}static fromRange(e,t){return new ai(e,t)}static fromSelector(e,t){const n=si(t.startContainer,e);if(!n)throw new Error("Failed to resolve startContainer XPath");const o=si(t.endContainer,e);if(!o)throw new Error("Failed to resolve endContainer XPath");const i=fo.fromCharOffset(n,t.startOffset),r=fo.fromCharOffset(o,t.endOffset),s=new mo(i,r).toRange();return new ai(e,s)}toRange(){return this.range}toSelector(){const e=mo.fromRange(this.range).toRange(),t=mo.fromRange(e),n=ii(t.start.element,this.root),o=ii(t.end.element,this.root);return{type:"RangeSelector",startContainer:n,startOffset:t.start.offset,endContainer:o,endOffset:t.end.offset}}}class li{constructor(e,t,n){this.root=e,this.start=t,this.end=n}static fromRange(e,t){const n=mo.fromRange(t).relativeTo(e);return new li(e,n.start.offset,n.end.offset)}static fromSelector(e,t){return new li(e,t.start,t.end)}toSelector(){return{type:"TextPositionSelector",start:this.start,end:this.end}}toRange(){
|
105
|
+
return mo.fromOffsets(this.root,this.start,this.end).toRange()}}class ci{constructor(e,t,n={}){this.root=e,this.exact=t,this.context=n}static fromRange(e,t){const n=e.textContent,o=mo.fromRange(t).relativeTo(e),i=o.start.offset,r=o.end.offset;return new ci(e,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(e,t){const{prefix:n,suffix:o}=t;return new ci(e,t.exact,{prefix:n,suffix:o})}toSelector(){return{type:"TextQuoteSelector",exact:this.exact,prefix:this.context.prefix,suffix:this.context.suffix}}toRange(e={}){return this.toPositionAnchor(e).toRange()}toPositionAnchor(e={}){const t=ni(this.root.textContent,this.exact,{...this.context,hint:e.hint});if(!t)throw new Error("Quote not found");return new li(this.root,t.start,t.end)}}function hi(e){const t=parseFloat(e);return!Number.isFinite(t)||t<0?null:t}function di(e){return e instanceof Element?e:e.parentElement}function ui(e,t=e){
|
106
|
+
const n=hi(e?.getAttribute("data-time-start")??""),o=hi(t?.getAttribute("data-time-end")??"");return"number"!=typeof n||"number"!=typeof o||o<n?null:[n,o]}class fi{constructor(e,t,n){this.root=e,this.start=t,this.end=n}static fromRange(e,t){const n=di(t.startContainer)?.closest("[data-time-start]"),o=di(t.endContainer)?.closest("[data-time-end]"),i=ui(n,o);if(!i)return null;const[r,s]=i;return new fi(e,r,s)}toRange(){const e=[...this.root.querySelectorAll("[data-time-start]")].map((e=>{const t=ui(e);if(!t)return null;const[n,o]=t;return{element:e,start:n,end:o}})).filter((e=>null!==e));e.sort(((e,t)=>e.start-t.start));const t=function(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}(e,(e=>e.start<=this.start&&e.end>=this.start));if(-1===t)throw new Error("Start segment not found");const n=t+e.slice(t).findIndex((e=>e.start<=this.end&&e.end>=this.end));if(-1===n)throw new Error("End segment not found");const o=new Range;o.setStart(e[t].element,0);const i=e[n].element
|
107
|
+
;return o.setEnd(i,i.childNodes.length),o}static fromSelector(e,t){const{start:n,end:o}=t;return new fi(e,n,o)}toSelector(){return{type:"MediaTimeSelector",start:this.start,end:this.end}}}async function mi(e,t){return e.toRange(t)}function pi(e,t,n){const o=e[t];if("function"!=typeof o)throw new Error("Can only intercept functions");return e[t]=(...t)=>{const i=o.call(e,...t);return n(...t),i},()=>{e[t]=o}}function gi(e){return e.replace(/#.*/,"")}class _i{constructor(e,t=(()=>location.href)){this._listeners=new we;let n=t();const o=(o=t())=>{gi(n)!==gi(o)&&(n=o,e(o))},i=function(){const e=window.navigation;return"function"==typeof Navigation&&e instanceof Navigation?e:null}();if(i)this._listeners.add(i,"navigatesuccess",(()=>o()));else{const e=[pi(window.history,"pushState",(()=>o())),pi(window.history,"replaceState",(()=>o()))];this._unpatchHistory=()=>e.forEach((e=>e())),this._listeners.add(window,"popstate",(()=>o()))}}disconnect(){this._unpatchHistory?.(),this._listeners.removeAll()}}var bi,wi
|
108
|
+
;var vi=function(){if(wi)return bi;wi=1;var e="complete",t="canceled";function n(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function o(t){var i=t._scrollSettings;if(i){var r=i.maxSynchronousAlignments,s=function(e,t){var n,o,i,r,s,a,l,c=e.align,h=e.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,m=c&&null!=c.topOffset?c.topOffset:0,p=d,g=u;if(e.isWindow(t))a=Math.min(h.width,t.innerWidth),l=Math.min(h.height,t.innerHeight),o=h.left+t.pageXOffset-t.innerWidth*p+a*p,i=h.top+t.pageYOffset-t.innerHeight*g+l*g,o-=f,i-=m,o=e.align.lockX?t.pageXOffset:o,i=e.align.lockY?t.pageYOffset:i,r=o-t.pageXOffset,s=i-t.pageYOffset;else{a=h.width,l=h.height,n=t.getBoundingClientRect();var _=h.left-(n.left-t.scrollLeft),b=h.top-(n.top-t.scrollTop);o=_+a*p-t.clientWidth*p,i=b+l*g-t.clientHeight*g,o-=f,i-=m,o=Math.max(Math.min(o,t.scrollWidth-t.clientWidth),0),i=Math.max(Math.min(i,t.scrollHeight-t.clientHeight),0),
|
109
|
+
o=e.align.lockX?t.scrollLeft:o,i=e.align.lockY?t.scrollTop:i,r=o-t.scrollLeft,s=i-t.scrollTop}return{x:o,y:i,differenceX:r,differenceY:s}}(i,t),a=Date.now()-i.startTime,l=Math.min(1/i.time*a,1);if(i.endIterations>=r)return n(t,s.x,s.y),t._scrollSettings=null,i.end(e);var c=1-i.ease(l);if(n(t,s.x-s.differenceX*c,s.y-s.differenceY*c),a>=i.time)return i.endIterations++,i.scrollAncestor&&o(i.scrollAncestor),void o(t);!function(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}(o.bind(null,t))}}function i(e){return e.self===e}function r(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function s(){return!0}function a(e){if(e.assignedSlot)return a(e.assignedSlot);if(e.parentElement)return"body"===e.parentElement.tagName.toLowerCase()?e.parentElement.ownerDocument.defaultView||e.parentElement.ownerDocument.ownerWindow:e.parentElement;if(e.getRootNode){var t=e.getRootNode()
|
110
|
+
;if(11===t.nodeType)return t.host}}return bi=function(n,l,c){if(n){"function"==typeof l&&(c=l,l=null),l||(l={}),l.time=isNaN(l.time)?1e3:l.time,l.ease=l.ease||function(e){return 1-Math.pow(1-e,e/2)},l.align=l.align||{};var 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 m=[];h;)if(l.debug&&console.log("Scrolling parent node",h),u(h,d)&&(f?f(h,r):r(h))&&(d++,m.push(h)),!(h=a(h))){p(e);break}return m.reduce(((e,r,s)=>function(e,n,r,s,a){var l,c=!n._scrollSettings,h=n._scrollSettings,d=Date.now(),u={passive:!0};function f(e){n._scrollSettings=null,n.parentElement&&n.parentElement._scrollSettings&&n.parentElement._scrollSettings.end(e),r.debug&&console.log("Scrolling ended with type",e,"for",n),a(e),l&&(n.removeEventListener("touchstart",l,u),n.removeEventListener("wheel",l,u))}h&&h.end(t);var m=r.maxSynchronousAlignments;return null==m&&(m=3),n._scrollSettings={startTime:d,
|
111
|
+
endIterations:0,target:e,time:r.time,ease:r.ease,align:r.align,isWindow:r.isWindow||i,maxSynchronousAlignments:m,end:f,scrollAncestor:s},"cancellable"in r&&!r.cancellable||(l=f.bind(null,t),n.addEventListener("touchstart",l,u),n.addEventListener("wheel",l,u)),c&&o(n),l}(n,r,l,m[s+1],p)),null)}function p(e){--d||c&&c(e)}},bi}(),yi=t(vi);function xi(e,t,n){return e+n*(t-e)}async function Ni(e,t,{maxDuration:n=500}={}){const o=e.scrollTop,i=t,r=Date.now(),s=Math.min(Math.abs(i-o)/3,n);let a=0;for(;a<1;)await new Promise((e=>{requestAnimationFrame(e)})),a=Math.min(1,(Date.now()-r)/s),e.scrollTop=xi(o,i,a)}function Ci(e,t=document.baseURI){return new URL(e,t).href.toString().replace(/#.*/,"")}class Si{constructor(e={}){this.document=e.document||document}uri(){let e=this._getDocumentHref();try{e=decodeURIComponent(e)}catch(e){console.error("Error decoding URI:",e)}const t=this._getLinks();for(const n of t)"canonical"===n.rel&&(e=n.href);return e}getDocumentMetadata(){const e={title:document.title,link:[],
|
112
|
+
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:")},t=this._getFavicon();t&&(e.favicon=t),e.title=this._getTitle(e),e.link=this._getLinks(e);const n=e.link.find((e=>e.href.startsWith("urn:x-dc")));return n&&(e.documentFingerprint=n.href),e}_getMetaTags(e,t){const n={};for(const o of Array.from(this.document.querySelectorAll("meta"))){const i=o.getAttribute(e),{content:r}=o;if(i&&r){const e=i.match(RegExp(`^${t}(.+)$`,"i"));if(e){const t=e[1].toLowerCase();n[t]?n[t].push(r):n[t]=[r]}}}return n}_getTitle(e){return e.highwire.title?e.highwire.title[0]:e.eprints.title?e.eprints.title[0]:e.prism.title?e.prism.title[0]:e.facebook.title?e.facebook.title[0]:e.twitter.title?e.twitter.title[0]:e.dc.title?e.dc.title[0]:this.document.title}_getLinks(e={dc:{},highwire:{}}){const t=[{href:this._getDocumentHref()
|
113
|
+
}],n=Array.from(this.document.querySelectorAll("link"));for(const e of n)if(["alternate","canonical","bookmark","shortlink"].includes(e.rel)){if("alternate"===e.rel){if(e.type&&e.type.match(/^application\/(rss|atom)\+xml/))continue;if(e.hreflang)continue}try{const n=this._absoluteUrl(e.href);t.push({href:n,rel:e.rel,type:e.type})}catch{}}for(const n of Object.keys(e.highwire)){const o=e.highwire[n];if("pdf_url"===n)for(const e of o)try{t.push({href:this._absoluteUrl(e),type:"application/pdf"})}catch{}if("doi"===n)for(let e of o)"doi:"!==e.slice(0,4)&&(e=`doi:${e}`),t.push({href:e})}for(const n of Object.keys(e.dc)){const o=e.dc[n];if("identifier"===n)for(const e of o)"doi:"===e.slice(0,4)&&t.push({href:e})}const o=e.dc["relation.ispartof"],i=e.dc.identifier;if(o&&i){const e=o[o.length-1],n=i[i.length-1],r="urn:x-dc:"+encodeURIComponent(e)+"/"+encodeURIComponent(n);t.push({href:r})}return t}_getFavicon(){let e=null
|
114
|
+
;for(const t of Array.from(this.document.querySelectorAll("link")))if(["shortcut icon","icon"].includes(t.rel))try{e=this._absoluteUrl(t.href)}catch{}return e}_absoluteUrl(e){return Ci(e,this.document.baseURI)}_getDocumentHref(){const{href:e}=this.document.location,t=["http:","https:","file:"],n=new URL(e).protocol;return t.includes(n)?e:this.document.baseURI&&t.includes(new URL(this.document.baseURI).protocol)?this.document.baseURI:e}}class Ai extends ln{constructor({features:e,container:t=document.body,sideBySideOptions:n}){super(),this.featureFlags=e,this.container=t,this._htmlMeta=new Si,this._prevURI=this._htmlMeta.uri(),this._sideBySideEnabled=!0,this._sideBySideOptions=n??{mode:"auto"},this._sideBySideActive=!1,this._lastLayout=null,this._navObserver=new _i((()=>this._checkForURIChange())),this._metaObserver=new MutationObserver((()=>this._checkForURIChange())),this._metaObserver.observe(document.head,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["rel","href","name","content"]}),
|
115
|
+
this._flagsChanged=()=>{},this.featureFlags.on("flagsChanged",this._flagsChanged)}anchor(e,t){return function(e,t,n={}){let o=null,i=null,r=null,s=null;for(const e of t)switch(e.type){case"TextPositionSelector":i=e,n.hint=i.start;break;case"TextQuoteSelector":r=e;break;case"RangeSelector":s=e;break;case"MediaTimeSelector":o=e}const a=e=>{if(r?.exact&&e.toString()!==r.exact)throw new Error("quote mismatch");return e};let l=Promise.reject("unable to anchor");if(s){const t=s;l=l.catch((()=>mi(ai.fromSelector(e,t),n).then(a)))}if(i){const t=i;l=l.catch((()=>mi(li.fromSelector(e,t),n).then(a)))}if(r){const t=r;l=l.catch((()=>mi(ci.fromSelector(e,t),n)))}if(o){const t=o;l=l.catch((()=>fi.fromSelector(e,t).toRange()))}return l}(e,t)}describe(e,t){if(t instanceof Range)return function(e,t){const n=[fi,ai,li,ci],o=[];for(const i of n)try{const n=i.fromRange(e,t);n&&o.push(n.toSelector())}catch{}return o}(e,t);throw new Error("Unsupported region type")}_checkForURIChange(){const e=this._htmlMeta.uri()
|
116
|
+
;e!==this._prevURI&&(this._prevURI=e,this.emit("uriChanged",e))}getAnnotatableRange(e){try{return mo.trimmedRange(e)}catch(e){if(e instanceof RangeError)return null;throw e}}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(e){this._lastLayout=e;const t=window.innerWidth-e.width,n=this._sideBySideEnabled&&"auto"===this._sideBySideOptions.mode&&e.expanded&&t>=480;return n?this._activateSideBySide(e.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(e){const t=e+12,n=e=>parseInt(window.getComputedStyle(e).marginLeft,10);Fn((()=>{document.body.style.marginLeft="",
|
117
|
+
document.body.style.marginRight="";const e=n(document.body);document.body.style.marginRight=`${t}px`;const o=function(e){const t=new Map,n=new Map,o=Mn.join(","),i=Array.from(e.querySelectorAll(o)).map((e=>({rect:e.getBoundingClientRect(),textLength:e.textContent.length}))).filter((({rect:e})=>e.width>0&&e.height>0)).sort(((e,t)=>t.textLength-e.textLength)).slice(0,15);if(i.forEach((({rect:e})=>{let o=t.get(e.left)??0;o+=1,t.set(e.left,o);let i=n.get(e.right)??0;i+=1,n.set(e.right,i)})),0===t.size||0===n.size)return null;const r=[...t.entries()].sort(((e,t)=>t[1]-e[1])),s=[...n.entries()].sort(((e,t)=>t[1]-e[1])),[a]=r[0],[l]=s[0];return{left:a,right:l}}(document.body);if(o){const i=Math.max(0,window.innerWidth-t-o.right);if(i>0){const e=Math.max(0,t-i);document.body.style.marginRight=`${e}px`}n(document.body)>e&&(document.body.style.marginLeft=`${e}px`),o.left<12&&(document.body.style.marginLeft="12px")}else document.body.style.marginLeft="",document.body.style.marginRight=""}))}_deactivateSideBySide(){
|
118
|
+
Fn((()=>{document.body.style.marginLeft="",document.body.style.marginRight=""}))}async getMetadata(){return this._htmlMeta.getDocumentMetadata()}async uri(){return this._htmlMeta.uri()}async scrollToAnchor(e){const t=e.highlights?.[0];t&&await async function(e,{maxDuration:t=500}={}){const n=e.closest("body");n&&"BODY"!==n.tagName&&Object.defineProperty(n,"tagName",{value:"BODY",configurable:!0});const o=e.closest("details");o&&!o.hasAttribute("open")&&(o.open=!0),await new Promise((n=>yi(e,{time:t},n)))}(t)}}var Ei,ki;var Ri=function(){if(ki)return Ei;ki=1;var t=NaN,n="[object Symbol]",o=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt,l="object"==typeof e&&e&&e.Object===Object&&e,c="object"==typeof self&&self&&self.Object===Object&&self,h=l||c||Function("return this")(),d=Object.prototype.toString,u=Math.max,f=Math.min,m=function(){return h.Date.now()};function p(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e
|
119
|
+
;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&d.call(e)==n}(e))return t;if(p(e)){var l="function"==typeof e.valueOf?e.valueOf():e;e=p(l)?l+"":l}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var c=r.test(e);return c||s.test(e)?a(e.slice(2),c?2:8):i.test(e)?t:+e}return Ei=function(e,t,n){var o,i,r,s,a,l,c=0,h=!1,d=!1,_=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function b(t){var n=o,r=i;return o=i=void 0,c=t,s=e.apply(r,n)}function w(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=r}function v(){var e=m();if(w(e))return y(e);a=setTimeout(v,function(e){var n=t-(e-l);return d?f(n,r-(e-c)):n}(e))}function y(e){return a=void 0,_&&o?b(e):(o=i=void 0,s)}function x(){var e=m(),n=w(e);if(o=arguments,i=this,l=e,n){if(void 0===a)return function(e){return c=e,a=setTimeout(v,t),h?b(e):s}(l);if(d)return a=setTimeout(v,t),b(l)}return void 0===a&&(a=setTimeout(v,t)),s}return t=g(t)||0,p(n)&&(h=!!n.leading,
|
120
|
+
r=(d="maxWait"in n)?u(g(n.maxWait)||0,t):r,_="trailing"in n?!!n.trailing:_),x.cancel=function(){void 0!==a&&clearTimeout(a),c=0,o=l=i=a=void 0},x.flush=function(){return void 0===a?s:y(m())},x},Ei}(),Pi=t(Ri);function Ti(e,t,n,o=0){let i=o;for(;i<e.length&&t>0;)n(e[i])&&--t,++i;return i}function Mi(e,t,n,o){let i=0;for(let r=n;r<o;r++)t(e[r])&&++i;return i}function Li(e,t,n,o,i){const r=Mi(e,i,0,n),s=Mi(e,i,n,o);let a=Ti(t,r,i);for(;a<t.length&&!i(t[a]);)++a;return[a,Ti(t,s,i,a)]}const Oi={INITIAL:0,FINISHED:3},Ii=new Map,Bi=new Map;function Di(e,t){return`${e}:${t}`}function Fi(e){let t=0;for(;e.previousSibling;)++t,e=e.previousSibling;return t}function Hi(e){const t="closest"in e?e:e.parentElement;return t?.closest(".textLayer")??null}function Vi(){return PDFViewerApplication.pdfViewer}async function Ui(e){const t=Vi();let n=t.getPageView(e);return n&&n.pdfPage||(n=await new Promise((n=>{const o=()=>{t.eventBus?t.eventBus.off("pagesloaded",o):document.removeEventListener("pagesloaded",o),n(t.getPageView(e))
|
121
|
+
};t.eventBus?t.eventBus.on("pagesloaded",o):document.addEventListener("pagesloaded",o)}))),n}function qi(e){const t=Ii.get(e);if(t)return t;const n=(async()=>{const t=await Ui(e);return(await t.pdfPage.getTextContent({normalizeWhitespace:!0})).items.map((e=>e.str)).join("")})();return Ii.set(e,n),n}async function zi(e){const t=Vi();let n=0,o=0,i="";for(let r=0;r<t.pagesCount;r++)if(i=await qi(r),n=o,o+=i.length,o>=e)return{index:r,offset:n,text:i};return{index:t.pagesCount-1,offset:n,text:i}}function $i(e){switch(e){case" ":case"\f":case"\n":case"\r":case"\t":case"\v":case" ":return!0;default:return!1}}const Wi=e=>!$i(e);function ji(e){return void 0!==e.renderingDone?e.renderingDone:!!e.div&&null!==e.div.querySelector(".endOfContent")}async function Xi(e,t,n){const[o,i]=await Promise.all([Ui(e),qi(e)]);if(o.renderingState===Oi.FINISHED&&o.textLayer&&ji(o.textLayer)){const e=o.textLayer.textLayerDiv??o.textLayer.div;if(!e)throw new Error("Unable to find PDF.js text layer root")
|
122
|
+
;const r=e.textContent,[s,a]=Li(i,r,t,n,Wi);Yi(r.slice(s,a))!==Yi(i.slice(t,n))&&Uo("Text layer text does not match page text. Highlights will be mis-aligned.");const l=new fo(e,s),c=new fo(e,a);return new mo(l,c).toRange()}const r=function(e){let t=e.querySelector(po);return t||(t=document.createElement("span"),t.classList.add("annotator-placeholder"),t.textContent="Loading annotations...",e.appendChild(t),t)}(o.div),s=document.createRange();return s.setStartBefore(r),s.setEndAfter(r),s}function Yi(e){let t="";for(let n=0;n<e.length;n++){const o=e[n];$i(o)||(t+=o)}return t}async function Ki(e){const t=e.find((e=>"TextQuoteSelector"===e.type));if(!t)throw new Error("No quote selector found");const n=e.find((e=>"TextPositionSelector"===e.type));if(n){try{const{index:e,offset:o,text:i}=await zi(n.start),r=n.start-o,s=n.end-o,a=i.substring(r,s);if(t.exact!==a)throw new Error("quote mismatch");return await Xi(e,r,s)}catch{}try{const e=Di(t.exact,n.start),o=Bi.get(e);if(o){const{pageIndex:e,anchor:t}=o
|
123
|
+
;return await Xi(e,t.start,t.end)}}catch{}}return async function(e,t){const n=Vi().pagesCount,o=Array(n).fill(0).map(((e,t)=>t));let i,r;if(t){const{index:e,offset:n}=await zi(t);i=e,r=t-n,o.sort(((t,n)=>Math.abs(t-e)-Math.abs(n-e)))}const s=void 0!==e.prefix?Yi(e.prefix):void 0,a=void 0!==e.suffix?Yi(e.suffix):void 0,l=Yi(e.exact);let c;for(const e of o){const t=await qi(e),n=Yi(t);let o;void 0!==i&&void 0!==r&&(e<i?o=n.length:e===i?[o]=Li(t,n,r,r,Wi):o=0);const h=ni(n,l,{prefix:s,suffix:a,hint:o});if(h&&(!c||h.score>c.match.score)){const[o,i]=Li(n,t,h.start,h.end,Wi);c={page:e,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(t){const i=Di(e.exact,t);Bi.set(i,{pageIndex:n,anchor:o})}return Xi(n,o.start,o.end)}throw new Error("Quote not found")}(t,n?.start)}async function Gi(e){
|
124
|
+
const t=e.find((e=>"PageSelector"===e.type)),n=e.find((e=>"ShapeSelector"===e.type));if(n){if(!t)throw new Error("Cannot anchor a shape selector without a page");return async function(e,t){const n=Vi();if("number"!=typeof e.index||e.index>=n.pagesCount)throw new Error("PDF page index is invalid");const o=await Ui(e.index),i=o.div,[r,s,a,l]=o.pdfPage.view,c=a-r,h=l-s,d=e=>(e-r)/c,u=e=>(l-e)/h;let f;switch(t.shape.type){case"rect":{const e=t.shape;f={type:"rect",left:d(e.left),right:d(e.right),top:u(e.top),bottom:u(e.bottom)}}break;case"point":{const e=t.shape;f={type:"point",x:d(e.x),y:u(e.y)}}break;default:throw new Error("Unsupported shape in shape selector")}return{anchor:i,shape:f,coordinates:"anchor"}}(t,n)}return Ki(e)}function Qi(e){try{e=mo.fromRange(e).toRange()}catch{throw new Error("Selection does not contain text")}const t=Hi(e.startContainer),n=Hi(e.endContainer);if(!t||!n)throw new Error("Selection is outside page text");if(t!==n)throw new Error("Selecting across page breaks is not supported")
|
125
|
+
;return[e,t]}async function Ji(e){const[t,n]=Qi(e),o=fo.fromPoint(t.startContainer,t.startOffset).relativeTo(n),i=fo.fromPoint(t.endContainer,t.endOffset).relativeTo(n),r=Fi(n.parentNode),s=await async function(e){if(e>=Vi().pagesCount)throw new Error("Invalid page index");let t=0;for(let n=0;n<e;n++)t+=(await qi(n)).length;return t}(r),a=await Ui(r);return[{type:"TextPositionSelector",start:s+o.offset,end:s+i.offset},ci.fromRange(a.div,t).toSelector(),er(a,r)]}async function Zi(e,t){const n=document.elementsFromPoint(e,t);for(const o of n){if(!o.classList.contains("page"))continue;const n=Fi(o),i=o.getBoundingClientRect(),r=e-i.left,s=t-i.top,a=await Ui(n),[l,c]=a.getPagePoint(r,s);return{pageIndex:n,x:l,y:c}}return null}function er(e,t){return{type:"PageSelector",index:t,label:e.pageLabel??`${t+1}`}}function tr({children:e}){return Te("div",{className:"flex flex-col",children:e})}function nr({info:e}){let t=e.item.title;return e.item.subtitle&&(t+=`: ${e.item.subtitle}`),Te("div",{
|
126
|
+
className:Re("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:[Te("div",{"data-testid":"content-logo",children:e.logo&&Te(Zt,{href:e.logo.link,target:"_blank","data-testid":"logo-link",underline:"none",children:Te("img",{alt:e.logo.title,src:e.logo.logo,"data-testid":"logo-image"})})}),Te("div",{className:Re("hidden","2xl:block 2xl:whitespace-nowrap 2xl:overflow-hidden 2xl:text-ellipsis","font-semibold"),"data-testid":"content-container-info",title:e.container.title,children:e.container.title}),Te("div",{className:Re("flex justify-center items-center gap-x-2"),"data-testid":"content-item-info",children:[Te("div",{className:Re("hidden","2xl:block 2xl:grow")}),e.links.previousItem&&Te(x,{children:[Te(Zt,{title:"Open previous item",href:e.links.previousItem,underline:"always",target:"_blank","data-testid":"content-previous-link",children:Te("div",{
|
127
|
+
className:"flex gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[Te(ze,{className:"w-em h-em"}),Te("span",{children:"Previous"})]})}),Te("div",{className:"text-annotator-sm",children:"|"})]}),Te("div",{className:Re("min-w-0 whitespace-nowrap overflow-hidden text-ellipsis shrink font-medium"),children:Te(Zt,{title:t,href:e.links.currentItem,"data-testid":"content-item-link",target:"_blank",unstyled:!0,children:t})}),e.links.nextItem&&Te(x,{children:[Te("div",{className:"text-annotator-sm",children:"|"}),Te(Zt,{title:"Open next item",href:e.links.nextItem,underline:"always",target:"_blank","data-testid":"content-next-link",children:Te("div",{className:"flex gap gap-x-1 items-center text-annotator-sm whitespace-nowrap",children:[Te("span",{children:"Next"}),Te(We,{className:"w-em h-em"})]})})]})]})]})}function or(){return Te("div",{className:"bg-white",role:"alert",children:Te("div",{
|
128
|
+
className:Re("flex items-center gap-x-2","border border-yellow-notice bg-yellow-notice/10 text-annotator-base"),children:[Te("div",{className:"bg-yellow-notice text-white p-2",children:Te(Xe,{className:"text-annotator-xl"})}),Te("div",{children:[Te("strong",{children:"This PDF does not contain selectable text:"})," ",Te(Zt,{target:"_blank",href:"https://web.hypothes.is/help/how-to-ocr-optimize-pdfs/",underline:"always",children:"Learn how to fix this"})," ","in order to annotate with Hypothesis."]})]})})}class ir{constructor(e){this._loaded=function(e){return e.initializedPromise?e.initializedPromise:e.initialized?Promise.resolve():new Promise((t=>{const n=setInterval((()=>{e.initialized&&(clearTimeout(n),t())}),5)}))}(e).then((async()=>{const t=await async function(e){return void 0!==e.downloadComplete?e.downloadComplete:(await e.pdfDocument.getDownloadInfo(),!0)}(e);return t?e:new Promise((t=>{const n=()=>{e.eventBus?(e.eventBus.off("documentload",n),
|
129
|
+
e.eventBus.off("documentloaded",n)):window.removeEventListener("documentload",n),t(e)};e.eventBus?(e.eventBus.on("documentloaded",n),e.eventBus.on("documentload",n)):window.addEventListener("documentload",n)}))}))}getUri(){return this._loaded.then((e=>{let t=ar(e);return t||(t=sr(rr(e))),t}))}async getMetadata(){const e=await this._loaded,{info:t,contentDispositionFilename:n,metadata:o}=await e.pdfDocument.getMetadata(),i=rr(e),r=ar(e);let s;s=o?.has("dc:title")&&"Untitled"!==o.get("dc:title")?o.get("dc:title"):t?.Title?t.Title:n||(r?function(e){const t=new URL(e),n=t.pathname.split("/");return n[n.length-1]}(r):"");const a=[{href:sr(i)}];return r&&a.push({href:r}),{title:s,link:a,documentFingerprint:i}}}function rr(e){return Array.isArray(e.pdfDocument.fingerprints)?e.pdfDocument.fingerprints[0]:e.pdfDocument.fingerprint}function sr(e){return`urn:x-pdf:${e}`}function ar(e){if(!e.url)return null;const t=Ci(e.url);return 0!==t.indexOf("file://")?t:null}function lr(e){const t=e.highlights?.[0];return t&&go(t)}
|
130
|
+
function cr(e){return new Promise((t=>setTimeout(t,e)))}class hr{constructor(){this._pdfjsContainer=document.querySelector("#outerContainer"),this._contentInfo=null,this._noTextWarning=!1,this._container=null}setContentInfo(e){this._contentInfo=e,this._update()}showNoTextWarning(e){this._noTextWarning=e,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 to("banner",(()=>this._render())),document.body.prepend(this._container.element)),this._container.render();const e=this._container.element.getBoundingClientRect().height;this._pdfjsContainer.style.height=`calc(100% - ${e}px)`}_render(){return Te(tr,{children:[this._contentInfo&&Te(nr,{info:this._contentInfo}),this._noTextWarning&&Te(or,{})]})}}class dr extends ln{constructor({annotator:e,features:t,reanchoringMaxWait:n}){super(),this._annotator=e
|
131
|
+
;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 ir(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 hr,this._checkForSelectableText(),this._sideBySideActive=!1,this._updateAnnotationLayerVisibility=()=>{const e=o.getSelection();this._pdfViewer.viewer.classList.toggle("is-selecting",!e.isCollapsed)},this._listeners=new we,this._listeners.add(document,"selectionchange",this._updateAnnotationLayerVisibility),this._destroyed=!1,this._features=t,this._features.on("flagsChanged",(()=>{this.emit("supportedToolsChanged",this.supportedTools())}))}destroy(){this.fitSideBySide({expanded:!1,width:0,toolbarWidth:0,height:window.innerHeight}),this._listeners.removeAll(),
|
132
|
+
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(e){this._banner.setContentInfo(e)}anchor(e,t){return Gi(t)}getAnnotatableRange(e){try{const t=mo.trimmedRange(e);if(function(e){try{return Qi(e),!0}catch{return!1}}(t))return t}catch(e){if(!(e instanceof RangeError))throw e}return null}canStyleClusteredHighlights(){return!0}describe(e,t){return t instanceof Range?Ji(t):async function(e){const t=e=>{const[t,n,o,i]=e.view;return{left:t,top:i,right:o,bottom:n}};switch(e.type){case"rect":{const[n,o]=await Promise.all([Zi(e.left,e.top),Zi(e.right,e.bottom)]);if(!n)throw new Error("Top-left point is not in a page");if(!o)throw new Error("Bottom-right point is not in a page");if(n.pageIndex!==o.pageIndex)throw new Error("Shape must start and end on same page");const i=await Ui(n.pageIndex)
|
133
|
+
;return[er(i,n.pageIndex),{type:"ShapeSelector",anchor:"page",shape:{type:"rect",left:n.x,top:n.y,right:o.x,bottom:o.y},view:t(i.pdfPage)}]}case"point":{const n=await Zi(e.x,e.y);if(!n)throw new Error("Point is not in a page");const o=await Ui(n.pageIndex);return[{type:"PageSelector",index:n.pageIndex},{type:"ShapeSelector",anchor:"page",shape:{type:"point",x:n.x,y:n.y},view:t(o.pdfPage)}]}default:throw new Error("Unsupported shape")}}(t)}async _checkForSelectableText(){try{await this.uri()}catch{return}if(!this._destroyed)try{const e=await async function(){const e=Vi();let t=!1;for(let n=0;n<e.pagesCount;n++)if((await qi(n)).trim().length>0){t=!0;break}return t}();this._banner.showNoTextWarning(!e)}catch(e){console.warn("Unable to check for text in PDF:",e)}}_update(){const e=[],t=this._pdfViewer.pagesCount;for(let e=0;e<t;e++){const t=this._pdfViewer.getPageView(e);if(t?.textLayer&&ji(t.textLayer))switch(t.renderingState){case Oi.INITIAL:t.textLayer=null;break;case Oi.FINISHED:n=t.div,
|
134
|
+
n.querySelector(po)?.remove()}}var n;for(const t of this._annotator.anchors)if(t.highlights){if(e.includes(t.annotation))continue;for(let n=0;n<t.highlights.length;n++){const o=t.highlights[n];if(!document.body.contains(o)){t.highlights.splice(n,1),delete t.region,e.push(t.annotation);break}}}e.map((e=>this._annotator.anchor(e)))}contentContainer(){return document.querySelector("#viewerContainer")}fitSideBySide(e){const t=window.innerWidth-e.width,n=e.expanded&&t>=680,o=n?e.width:e.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 e=this._features?.flagEnabled("pdf_image_annotation");return e?["selection","rect","point"]:["selection"]}async scrollToAnchor(e){const t=e.annotation,n=lr(e),o=this._anchorOffset(e)
|
135
|
+
;if(null!==o&&(await Ni(this.contentContainer(),o),n)){const e=await this._waitForAnnotationToBeAnchored(t,this._reanchoringMaxWait);if(!e)return;const n=this._anchorOffset(e);if(null===n)return;await Ni(this.contentContainer(),n)}}async _waitForAnnotationToBeAnchored(e,t){const n=Date.now();let o;do{o=this._annotator.anchors.find((t=>t.annotation===e)),o&&!lr(o)||(o=null,await cr(20))}while(!o&&Date.now()-n<t);return o??null}_anchorOffset(e){if(!e.highlights)return null;return function(e,t){let n=0;for(;e!==t&&t.contains(e);)n+=e.offsetTop,e=e.offsetParent;return n}(e.highlights[0],this.contentContainer())}async renderToBitmap(e,t){const n=e.target.selector?.find((e=>"ShapeSelector"===e.type)),o=e.target.selector?.find((e=>"PageSelector"===e.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
|
136
|
+
;case"point":{const{x:e,y:t}=n.shape,[o,,c]=i.pdfPage.view,h=.1*Math.abs(c-o);r=e-h,a=t+h,s=e+h,l=t-h}break;default:throw new Error("Unsupported shape type")}const c=96/72,h=t.devicePixelRatio??1,d=(s-r)*c*h,u=(s-r)/(a-l),f="number"==typeof t.maxWidth?Math.min(t.maxWidth,d):d,m=f/u,p=i.pdfPage.getViewport({scale:1}),g=f/d*c*h,_=new(0,p.constructor)({rotation:0,scale:g,userUnit:p.userUnit,viewBox:[r,l,s,a]}),b=new OffscreenCanvas(f,m),w=b.getContext("2d"),v=i.pdfPage.render({canvasContext:w,viewport:_});if(await v.promise,"point"===n.shape.type){w.save(),w.scale(g,g);const e=n.shape.x-r,t=n.shape.y-l,o=5;w.strokeStyle="black",w.fillStyle="yellow",w.beginPath(),w.arc(e,t,o,0,2*Math.PI),w.fill(),w.stroke(),w.restore()}return b.transferToImageBitmap()}}function ur(e){if(!e.includes("["))return e;let t="",n=!1,o=!1;for(const i of e)n||"^"!==i?(n||"["!==i?!n&&o&&"]"===i?o=!1:o||(t+=i):o=!0,n=!1):n=!0;return t}function fr(e){const t=ur(e),n=t.indexOf("!");return-1===n?t:t.slice(0,n)}class mr{constructor(e,t,n){
|
137
|
+
this._element=e,this._onFrameAdded=t,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(e){this._annotatableFrames.add(e);try{if(await pr(e),this._isDisconnected)return;e.contentWindow.addEventListener("unload",(()=>{this._removeFrame(e)})),this._onFrameAdded(e)}catch{console.warn(`Unable to inject the Hypothesis client (from '${document.location.href}' into a cross-origin frame '${e.src}')`)}}_removeFrame(e){this._annotatableFrames.delete(e),this._onFrameRemoved(e)}_discoverFrames(){const e=new Set(this._element.querySelectorAll("iframe[enable-annotation]"));for(const t of e)this._annotatableFrames.has(t)||this._addFrame(t)
|
138
|
+
;for(const t of this._annotatableFrames)e.has(t)||this._removeFrame(t)}}function pr(e){return new Promise(((t,n)=>{const o=gr(e,((e,i)=>{o(),i?t(i):n(e)}))}))}function gr(e,t,{pollInterval:n=10}={}){let o,i;const r=new WeakSet,s=()=>{clearTimeout(o),o=void 0},a=()=>{const n=e.contentDocument;if(n){if(!r.has(n)){if(r.add(n),s(),!function(e){return"about:blank"===e.contentDocument?.location.href&&e.hasAttribute("src")&&"about:blank"!==e.src}(e)){"interactive"===n.readyState||"complete"===n.readyState?t(null,n):n.addEventListener("DOMContentLoaded",(()=>t(null,n)))}e.contentDocument&&e.contentWindow?.addEventListener("unload",i)}}else{s();const n=e.isConnected?"Frame is cross-origin":"Frame is disconnected";t(new Error(n))}};let l=!1;i=()=>{s(),l||(o=setInterval(a,n))},e.addEventListener("load",a);const c=setTimeout(a,0);return()=>{l=!0,clearTimeout(c),s(),e.removeEventListener("load",a)}}class _r{constructor(e,t){this._config=t,this._frameObserver=new mr(e,(e=>br(e,t)),(()=>{}))}destroy(){
|
139
|
+
this._frameObserver.disconnect()}}async function br(e,t,n){if(null!==e.contentDocument.querySelector("script.js-hypothesis-config"))return;await pr(e);const{assetRoot:o,notebookAppUrl:i,profileAppUrl:r,sidebarAppUrl:s}=yn(document),a={...t,assetRoot:o,notebookAppUrl:i,profileAppUrl:r,sidebarAppUrl:s,subFrameIdentifier:n??on(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=t.clientUrl;const h=e.contentDocument;h.body.appendChild(l),h.body.appendChild(c)}class wr{constructor(e,t,n){if(t.length!==n.length)throw new Error("Char boxes length does not match text length");const o=e.parentNode,i=document.createElement("hypothesis-text-layer");o.insertBefore(i,e.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",
|
140
|
+
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=(e,t,n="px")=>`calc(var(--${e}-scale) * ${t}${n})`,l=function(e,t){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 e.entries()){const e=t[n],s=/\s/.test(e);o.text.length>0&&!An(o.rect,r)&&i(),o.rect=kn(o.rect,r),o.text+=s?" ":e,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 e of n){const t=s.words[s.words.length-1];if(t){const n=Rn(t.rect),o=Rn(e.rect).x-n.x;(!An(t.rect,e.rect)||o<0)&&a()}s.words.push(e),s.rect=kn(s.rect,e.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 e of r){const t=c.lines[c.lines.length-1];if(t){const n=Rn(t.rect),o=Rn(e.rect).y-n.y
|
141
|
+
;(!En(t.rect,e.rect)||An(t.rect,e.rect)||o<0||o>4*e.rect.height)&&h()}c.lines.push(e),c.rect=kn(c.rect,e.rect)}return h(),l}(t,n);for(const e of l){const t=document.createElement("hypothesis-text-column");t.style.display="block",t.style.position="absolute",t.style.left=a("x",e.rect.left),t.style.top=a("y",e.rect.top);let n=null;for(const o of e.lines){const i=document.createElement("hypothesis-text-line");i.style.display="block",i.style.marginLeft=a("x",o.rect.left-e.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 e of o.words){const t=document.createElement("hypothesis-text-word");t.style.display="inline-block",t.style.transformOrigin="top left",t.textContent=e.text,r&&(t.style.marginLeft=a("x",e.rect.left-r.rect.right)),r=e,t.style.width=a("x",e.rect.width),t.style.height=a("y",e.rect.height),t.style.whiteSpace="pre"
|
142
|
+
;const n=s.measureText(e.text),o=a("x",e.rect.width/n.width,""),l=a("y",e.rect.height/16,"");t.style.transform=`scale(${o}, ${l})`,i.append(t)}t.append(i)}i.append(t)}const c=()=>{const{width:t,height:n}=e.getBoundingClientRect();i.style.width=t+"px",i.style.height=n+"px",i.style.setProperty("--x-scale",`${t}`),i.style.setProperty("--y-scale",`${n}`)};c(),this.container=i,this._updateTextLayerSize=Pi(c,{maxWait:50}),this._listeners=new we,"undefined"!=typeof ResizeObserver&&(this._imageSizeObserver=new ResizeObserver((()=>{this._updateTextLayerSize()})),this._imageSizeObserver.observe(e)),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 vr(e=document){return e.querySelector("mosaic-book")}function yr(e=window){if(vr(e.document))return"container"
|
143
|
+
;const t=e.frameElement?.ownerDocument;return t&&vr(t)?"content":null}class xr{constructor(e){const t=vr();if(!t)throw new Error("Book container element not found");const n=new WeakSet,o=t.shadowRoot,i=()=>{const t=o.querySelector("iframe");t&&!n.has(t)&&(n.add(t),gr(t,((n,o)=>{if(n)return;const i=o.body;i&&!i.querySelector("#page-content")&&br(t,e,"vitalsource-content")})))};i(),this._frameObserver=new MutationObserver(i),this._frameObserver.observe(o,{childList:!0,subtree:!0})}destroy(){this._frameObserver.disconnect()}}function Nr(){return document.querySelector("img#pbk-page")}class Cr extends ln{constructor(e=document.body,t={}){super();const n=t.bookElement??vr(window.parent.document);if(!n)throw new Error("Failed to find <mosaic-book> element in container frame");this._bookElement=n;const o=new zo;this._htmlIntegration=new Ai({container:e,features:o}),this._listeners=new we;const i=["mouseup","mousedown","mouseout"];for(const e of i)this._listeners.add(document.documentElement,e,(e=>{
|
144
|
+
e.stopPropagation()}));const r=window.frameElement;r&&function(e){if("no"!==e.getAttribute("scrolling"))return;const t=document.createElement("style");t.textContent="iframe { height: 100% !important; }",e.insertAdjacentElement("beforebegin",t);const n=()=>e.removeAttribute("scrolling");n(),new MutationObserver(n).observe(e,{attributes:!0})}(r);const s=Nr(),a=window.innerPageData;if(s&&a){const e=a.glyphs.glyphs.map((e=>{const t=e.l/100,n=e.r/100,o=e.t/100,i=e.b/100;return new DOMRect(t,o,n-t,i-o)}));this._textLayer=new wr(s,e,a.words),this._textLayer.container.style.zIndex="100",this._sideBySideActive=!1}}getAnnotatableRange(e){return this._htmlIntegration.getAnnotatableRange(e)}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(e,t){return this._htmlIntegration.anchor(e,t)}async describe(e,t){
|
145
|
+
const n=this._htmlIntegration.describe(e,t),{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 e={type:"PageSelector",index:i,label:r};l.push(e)}return n.push(...l),n}contentContainer(){return this._htmlIntegration.contentContainer()}fitSideBySide(e){const t=Nr();if(t&&this._textLayer){const n=t.parentElement,o=this._textLayer,i=window.innerWidth-e.width;return this._sideBySideActive=!1,Fn((()=>{e.expanded&&i>480?(n.style.textAlign="left",t.style.width=`${i}px`,this._sideBySideActive=!0):(n.style.textAlign="",t.style.width=""),o.updateSync()})),this._sideBySideActive}return this._htmlIntegration.fitSideBySide(e)}sideBySideActive(){return"boolean"==typeof this._sideBySideActive?this._sideBySideActive:this._htmlIntegration.sideBySideActive()}supportedTools(){return["selection"]}async getMetadata(){return{title:this._bookElement.getBookInfo().title,link:[]}}navigateToSegment(e){
|
146
|
+
const t=e.target[0].selector?.find((e=>"EPUBContentSelector"===e.type));if(t?.cfi)this._bookElement.goToCfi(t.cfi);else{if(!t?.url)throw new Error("No segment information available");this._bookElement.goToURL(function(e){const t=new URL(e,document.baseURI);return t.pathname+t.search}(t.url))}}persistFrame(){return!0}async _getPageInfo({includeTitle:e=!1,includePageIndex:t=!1}={}){const[n,o,i]=await Promise.all([this._bookElement.getCurrentPage(),e?this._bookElement.getTOC():void 0,t?this._bookElement.getPages():void 0]),r=["absoluteURL","cfi"];for(const e of r)if(!(e in n))throw new Error(`Page metadata field "${e}" is missing`);let s;if(o){s=n.chapterTitle;const e=fr(n.cfi),t=o.data?.find((t=>fr(t.cfi)===e));t&&(s=t.title)}let a=n.index;if(void 0===a&&i){const e=i.data?.findIndex((e=>e.cfi===n.cfi));-1!==e&&(a=e)}return{cfi:n.cfi,index:a,page:n.page,title:s,url:new URL(n.absoluteURL,document.baseURI).toString()}}async _getPageRange(e){let t=[];try{const e=await this._bookElement.getPageBreaks()
|
147
|
+
;e.ok&&e.data&&(t=e.data)}catch(e){console.error("Failed to get page breaks",e)}const n=ur(e),o=t.filter((e=>e.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:e,url:t}=await this._getPageInfo();return{cfi:e,pages:await this._getPageRange(e),url:t}}async uri(){const e=this._bookElement.getBookInfo().isbn;if(!e)throw new Error("Unable to get book ID from VitalSource");return`https://bookshelf.vitalsource.com/reader/books/${e}`}async scrollToAnchor(e){return this._htmlIntegration.scrollToAnchor(e)}}function Sr(e){if(void 0!==window.PDFViewerApplication)return new dr({annotator:e,features:e.features});return"content"===yr()?new Cr(document.body):new Ai({features:e.features,sideBySideOptions:e.sideBySide})}function Ar(){return Te(Xt,{classes:"fixed left-[10px] top-[10px]","data-testid":"outside-assignment-notice",status:"notice",variant:"raised",
|
148
|
+
children:"You are outside the page range for this assignment. Annotations made here may not be counted."})}class Er{constructor(e){this._visible=!1,this._container=new to("notice",(()=>this._render())),e.appendChild(this._container.element)}destroy(){this._container.destroy()}setVisible(e){this._visible=e,this._container.render()}_render(){return this._visible?Te(Ar,{}):null}}class kr{constructor(e,t=document){let n=!1;this._pendingCallback=null;const o=(n=10)=>{this._pendingCallback=setTimeout((()=>{e(bo(t.getSelection()))}),n)},i=e=>{if("mousedown"===e.type&&(n=!0),"mouseup"===e.type&&(n=!1),n)return;this._cancelPendingCallback();const t="mouseup"===e.type?10:100;o(t)};this._document=t,this._listeners=new we,this._listeners.add(t,"selectionchange",i),this._listeners.add(t.body,"mousedown",i),this._listeners.add(t.body,"mouseup",i),o(1)}disconnect(){this._listeners.removeAll(),this._cancelPendingCallback()}_cancelPendingCallback(){this._pendingCallback&&(clearTimeout(this._pendingCallback),
|
149
|
+
this._pendingCallback=null)}}function Rr(e,t){if(e===t)return!0;if(e.parent!==t)return!1;if(!e.frameElement)return!1;return e.frameElement.getBoundingClientRect().width/e.parent.innerWidth>=.8}function Pr(){return function(e,t){const n=new Set,o=new Set;return yo(e,(e=>{for(;e&&!n.has(e);){n.add(e);const i=t(e);null!=i&&o.add(i),e=e.parentNode}})),[...o]}(bo()??new Range,(e=>e._annotation?.$tag))}function Tr(e,t){return function(e,t){const n=document.elementsFromPoint(e,t).filter((e=>"hypothesis-highlight"===e.localName)),o=[];for(const n of document.querySelectorAll("hypothesis-highlight.hypothesis-shape-highlight")){const i=n.getBoundingClientRect();e>=i.left&&e<i.right&&t>=i.top&&t<i.bottom&&o.push(n)}return[...n,...o]}(e,t).map((e=>e._annotation?.$tag)).filter((e=>void 0!==e))}function Mr(e){if(!e.region)return null;if(!function(e){return void 0!==e&&"toRange"in e&&"function"==typeof e.toRange}(e.region))return e.region;try{return e.region.toRange()}catch{return null}}function Lr(){
|
150
|
+
document.getSelection()?.removeAllRanges()}class Or extends CustomEvent{constructor(e){super("scrolltorange",{bubbles:!0,cancelable:!0,detail:e}),this._ready=null}get ready(){return this._ready}waitUntil(e){this._ready=e}}class Ir extends ln{constructor(e,t={},n=window){super(),this.element=e,this._contentReady=t.contentReady,this._hostFrame=n,this._highlightsVisible=!1,this._isAdderVisible=!1,this._informHostOnNextSelectionClear=!0,this.selectedRanges=[],this._outsideAssignmentNotice=null,this._adder=new io(this.element,{onAnnotate:()=>this.createAnnotationFromSelection(),onHighlight:()=>this.createAnnotationFromSelection({highlight:!0}),onShowAnnotations:e=>this.selectAnnotations(e,{focusInSidebar:!0})}),this._drawTool=new Fo(this.element),this._selectionObserver=new kr((e=>{e?this._onSelection(e):this._onClearSelection()})),this.anchors=[],this._annotations=new Set,this._frameIdentifier=t.subFrameIdentifier||null,this._portFinder=new an({hostFrame:this._hostFrame,source:"guest",
|
151
|
+
sourceId:this._frameIdentifier??void 0}),this.features=new zo,this._featureFlagsReceived=new Promise((e=>{this.features.on("flagsChanged",e)})),this.sideBySide=t.sideBySide,this._integration=Sr(this),this._integration.on("uriChanged",(()=>this._sendDocumentInfo())),t.contentInfoBanner&&this._integration.showContentInfo?.(t.contentInfoBanner),this._integration.canStyleClusteredHighlights?.()&&(this._clusterToolbar=new Yo(this._integration.contentContainer(),{features:this.features})),this._integration.on("supportedToolsChanged",(()=>this._notifySupportedToolsChanged())),this._hostRPC=new wn,this._connectHost(n),this._sidebarRPC=new wn,this._sidebarLayout=null,this._connectSidebar(),this._bucketBarClient=new Io({contentContainer:this._integration.contentContainer(),hostRPC:this._hostRPC}),this._listeners=new we,this._setupElementEvents(),this._hoveredAnnotations=new Set}_sideBySideActive(){
|
152
|
+
return"manual"===this.sideBySide?.mode&&this.sideBySide.isActive?this.sideBySide.isActive():this._integration.sideBySideActive()}_setupElementEvents(){this._listeners.add(this.element,"mouseup",(e=>{const{clientX:t,clientY:n,metaKey:o,ctrlKey:i}=e,r=Tr(t,n);if(r.length&&this._highlightsVisible){const e=o||i;this.selectAnnotations(r,{toggle:e})}})),this._listeners.add(this.element,"pointerdown",(e=>{this._sideBySideActive()||e.composedPath().some((e=>e instanceof Element&&e.localName.startsWith("hypothesis-")))||Tr(e.clientX,e.clientY).length||Rr(window,this._hostFrame)&&this._sidebarLayout?.expanded&&window.innerWidth-e.clientX<this._sidebarLayout.width||this._sidebarRPC.call("closeSidebar")})),this._listeners.add(this.element,"mouseover",(({clientX:e,clientY:t})=>{const n=Tr(e,t);n.length&&this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",n)})),this._listeners.add(this.element,"mouseout",(()=>{this._highlightsVisible&&this._sidebarRPC.call("hoverAnnotations",[])})),
|
153
|
+
this._listeners.add(this.element,"keydown",(e=>{this._handleShortcut(e)})),this._listeners.add(window,"resize",(()=>this._repositionAdder()))}async getDocumentInfo(){const[e,t,n]=await Promise.all([this._integration.uri(),this._integration.getMetadata(),this._integration.segmentInfo?.()]);return{uri:Ci(e),metadata:t,segmentInfo:n,persistent:this._integration.persistFrame?.()??!1}}async _sendDocumentInfo(){this._integration.waitForFeatureFlags?.()&&await this._featureFlagsReceived;const e=await this.getDocumentInfo();this._sidebarRPC.call("documentInfoChanged",e)}_repositionAdder(){if(!this._isAdderVisible)return;const e=bo();e&&this._onSelection(e)}async _connectHost(e){this._hostRPC.on("clearSelection",(()=>{bo()&&(this._informHostOnNextSelectionClear=!1,Lr())})),this._hostRPC.on("createAnnotation",(({tool:e})=>this.createAnnotation(e))),this._hostRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._hostRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),
|
154
|
+
this._hostRPC.on("selectAnnotations",((e,t)=>this.selectAnnotations(e,{toggle:t}))),this._hostRPC.on("sidebarLayoutChanged",(t=>{Rr(window,e)&&this.fitSideBySide(t),this.element.dispatchEvent(new Ho({sidebarLayout:t,sideBySideActive:this._sideBySideActive()}))})),this._hostRPC.on("close",(()=>this.emit("hostDisconnected"))),this._notifySupportedToolsChanged();const t=await this._portFinder.discover("host");this._hostRPC.connect(t)}_notifySupportedToolsChanged(){this._hostRPC.call("supportedToolsChanged",this._integration.supportedTools())}async _scrollToAnchor(e){const t=Mr(e);if(!t)return;let n;t instanceof Range?n=t:(n=new Range,n.selectNodeContents(t.anchor));const o=new Or(n);this.element.dispatchEvent(o)&&(await o.ready,await this._integration.scrollToAnchor(e))}async _scrollToAnnotation(e){const t=this.anchors.find((t=>t.annotation.$tag===e));t?.highlights&&await this._scrollToAnchor(t)}async _connectSidebar(){this._sidebarRPC.on("featureFlagsUpdated",(e=>this.features.update(e))),
|
155
|
+
this._sidebarRPC.on("hoverAnnotations",(e=>this._hoverAnnotations(e))),this._sidebarRPC.on("scrollToAnnotation",(e=>{this._scrollToAnnotation(e)})),this._sidebarRPC.on("setHighlightsVisible",(e=>{this.setHighlightsVisible(e,!1)})),this._sidebarRPC.on("deleteAnnotation",(e=>this.detach(e))),this._sidebarRPC.on("loadAnnotations",(async e=>{try{await Promise.all(e.map((e=>this.anchor(e))))}catch(e){console.warn("Failed to anchor annotations:",e)}})),this._sidebarRPC.on("showContentInfo",(e=>this._integration.showContentInfo?.(e))),this._sidebarRPC.on("setOutsideAssignmentNoticeVisible",(e=>{this._setOutsideAssignmentNoticeVisible(e)})),this._sidebarRPC.on("navigateToSegment",(e=>this._integration.navigateToSegment?.(e))),this._sidebarRPC.on("renderThumbnail",((e,t,n)=>{(async()=>{if(!this._integration.renderToBitmap)throw new Error("Thumbnail rendering not supported for document type");const n=this.anchors.find((t=>t.annotation.$tag===e));if(!n)throw new Error("Annotation not anchored in guest")
|
156
|
+
;return this._integration.renderToBitmap(n,t)})().then((e=>n({ok:!0,value:e}))).catch((e=>n({ok:!1,error:e.message})))})),this._portFinder.discover("sidebar").then((e=>{this._sidebarRPC.connect(e)})),this._sendDocumentInfo()}destroy(){var e;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(),e=this.element,Eo(Array.from(e.querySelectorAll("hypothesis-highlight"))),this._integration.destroy(),super.destroy()}async anchor(e){this._contentReady&&(await this._contentReady,this._contentReady=void 0);const t=e=>{const t=Mr(e);if(!t)return;let n;n=t instanceof Range?So(t,e.annotation?.$cluster):function(e){
|
157
|
+
const{shape:t,anchor:n}=e,o=getComputedStyle(n),i=parseInt(o.borderWidth),r=n.getBoundingClientRect(),s=new DOMRect(r.left,r.top,r.width-2*i,r.height-2*i),a=document.createElement("hypothesis-highlight");if(a.className="hypothesis-shape-highlight","rect"===t.type){const e=t.left*s.width-i,n=t.top*s.height-i,o=(t.right-t.left)*s.width,r=(t.bottom-t.top)*s.height;a.style.left=`${e}px`,a.style.top=`${n}px`,a.style.width=o-6+"px",a.style.height=r-6+"px"}else if("point"===t.type){const e=t.x*s.width-i,n=t.y*s.height-i;a.style.left=`${e}px`,a.style.top=`${n}px`,a.style.width="10px",a.style.height="10px"}return n.append(a),[a]}(t),n.forEach((t=>{t._annotation=e.annotation})),e.highlights=n,this._hoveredAnnotations.has(e.annotation.$tag)&&ko(n,!0)};this.detach(e.$tag,!1),this._annotations.add(e.$tag),e.target||(e.target=[]);const n=await Promise.all(e.target.map((async t=>{if(!t.selector||!t.selector.some((e=>"TextQuoteSelector"===e.type||"ShapeSelector"===e.type)))return{annotation:e,target:t};let n;try{
|
158
|
+
const o=await this._integration.anchor(this.element,t.selector);if(o instanceof Range){const i=mo.fromRange(o);n={annotation:e,target:t,region:i}}else n={annotation:e,target:t,region:o}}catch{n={annotation:e,target:t}}return n})));if(!this._annotations.has(e.$tag))return[];for(const e of n)t(e);return e.$orphan=n.length>0&&n.every((e=>e.target.selector&&!e.region)),this._updateAnchors(this.anchors.concat(n),!0),this._sidebarRPC.call("syncAnchoringStatus",e),n}detach(e,t=!0){this._annotations.delete(e);const n=[];for(const t of this.anchors)t.annotation.$tag!==e?n.push(t):t.highlights&&Eo(t.highlights);this._updateAnchors(n,t)}_updateAnchors(e,t){this.anchors=e,this._clusterToolbar?.scheduleClusterUpdates(),t&&this._bucketBarClient.update(this.anchors)}async createAnnotation(e){if("selection"===e)return this.createAnnotationFromSelection();if(["rect","point"].includes(e)){const t=await this._drawTool.draw(e),n=await this.getDocumentInfo(),o=[{source:n.uri,
|
159
|
+
selector:await this._integration.describe(this.element,t)}],i={uri:n.uri,document:n.metadata,target:o,$tag:"a:"+on(8)};return this._sidebarRPC.call("createAnnotation",i),this.anchor(i),i}throw new Error("Unsupported annotation tool")}async createAnnotationFromSelection({highlight:e=!1}={}){const t=this.selectedRanges;this.selectedRanges=[];const n=await this.getDocumentInfo(),o=this.element,i=(await Promise.all(t.map((e=>this._integration.describe(o,e))))).map((e=>({source:n.uri,selector:e}))),r={uri:n.uri,document:n.metadata,target:i,$highlight:e,$cluster:e?"user-highlights":"user-annotations",$tag:"a:"+on(8)};return this._sidebarRPC.call("createAnnotation",r),this.anchor(r),Lr(),r}_hoverAnnotations(e){this._hoveredAnnotations.clear(),e.forEach((e=>this._hoveredAnnotations.add(e)));for(const t of this.anchors)if(t.highlights){const n=e.includes(t.annotation.$tag);ko(t.highlights,n)}this._sidebarRPC.call("hoverAnnotations",e)}_onSelection(e){const t=this._integration.getAnnotatableRange(e)
|
160
|
+
;if(!t)return void this._onClearSelection();const n=document.getSelection(),o=wo(n),i=xo(n);i?(this.selectedRanges=[t],this._hostRPC.call("textSelected"),this._adder.annotationsForSelection=Pr(),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(e,{toggle:t=!1,focusInSidebar:n=!1}={}){t?this._sidebarRPC.call("toggleAnnotationSelection",e):this._sidebarRPC.call("showAnnotations",e,n),this._sidebarRPC.call("openSidebar")}setHighlightsVisible(e,t=!0){!function(e,t){e.classList.toggle("hypothesis-highlights-always-on",t)}(this.element,e),this._highlightsVisible=e,t&&this._hostRPC.call("highlightsVisibleChanged",e)}get highlightsVisible(){return this._highlightsVisible}fitSideBySide(e){this._sidebarLayout=e,this._integration.fitSideBySide(e)}get hoveredAnnotationTags(){
|
161
|
+
return this._hoveredAnnotations}_handleShortcut(e){jn(e,"Ctrl+Shift+H")&&this.setHighlightsVisible(!this._highlightsVisible)}_setOutsideAssignmentNoticeVisible(e){this._outsideAssignmentNotice||(this._outsideAssignmentNotice=new Er(this.element)),this._outsideAssignmentNotice.setVisible(e)}}function Br(e,t){const n=new URL(e),o=new URLSearchParams;return o.append("config",JSON.stringify(t)),n.hash=o.toString(),n.toString()}function Dr(e,t){const n={};for(const[e,o]of Object.entries(t))"notebookAppUrl"!==e&&"sidebarAppUrl"!==e&&null!=o&&(n[e]=o);n.origin=new URL(e).origin,n.version="1.1627.0";const o=new URL(window.location.href);if(o.hash="",n.hostURL=o.toString(),Array.isArray(n.services)&&n.services?.length>0){const e=n.services[0];e.onLoginRequest&&(e.onLoginRequestProvided=!0),e.onLogoutRequest&&(e.onLogoutRequestProvided=!0),e.onSignupRequest&&(e.onSignupRequestProvided=!0),e.onProfileRequest&&(e.onProfileRequestProvided=!0),e.onHelpRequest&&(e.onHelpRequestProvided=!0)}return n}
|
162
|
+
function Fr({closed:e,onClose:t,children:n,"data-testid":o,"aria-label":i}){const r=se(null);return ie((()=>{e?r.current?.close():r.current?.showModal()}),[e]),ie((()=>{const e=r.current;return e?.addEventListener("cancel",t),()=>{e?.removeEventListener("cancel",t)}}),[t]),Te("dialog",{ref:r,className:"relative w-full h-full backdrop:bg-black/50","data-testid":o,"aria-label":i,children:n})}function Hr({closed:e,children:t,...n}){return Te("div",{...n,className:Re("fixed z-max top-0 left-0 right-0 bottom-0 p-3 bg-black/50",{hidden:e}),children:Te("div",{className:"relative w-full h-full",children:t})})}function Vr({document_:e=document,...t}){return Te(ae((()=>function(e){return"function"==typeof e.createElement("dialog").showModal}(e)?Fr:Hr),[e]),{...t})}function Ur({config:e,groupId:t}){return Te("iframe",{title:"Hypothesis annotation notebook",className:"h-full w-full border-0",allow:"fullscreen; clipboard-write",src:Br(e.notebookAppUrl,{...Dr(e.notebookAppUrl,e),group:t})})}
|
163
|
+
function qr({eventBus:e,config:t}){const[n,o]=oe(0),[i,r]=oe(!0),[s,a]=oe(null),l=se(""),c=se(null);ie((()=>(l.current=document.body.style.overflow,()=>{document.body.style.overflow=l.current})),[]),ie((()=>{document.body.style.overflow=i?l.current:"hidden"}),[i]),ie((()=>{const t=e.createEmitter();return t.subscribe("openNotebook",(e=>{r(!1),o((e=>e+1)),a(e)})),c.current=t,()=>{t.destroy()}}),[e]);const h=le((()=>{r(!0),c.current?.publish("closeNotebook")}),[]);return null===s?null:Te(Vr,{closed:i,onClose:h,"data-testid":"notebook-outer","aria-label":"Hypothesis notebook",children:[Te("div",{className:"absolute right-0 m-3",children:Te(kt,{title:"Close notebook",onClick:h,variant:"dark",classes:Re("!bg-transparent enabled:hover:!bg-grey-3"),"data-testid":"close-button",children:Te(He,{className:"w-4 h-4"})})}),Te(Ur,{config:t,groupId:s},n)]})}class zr{constructor(e,t,n){this._container=new to("notebook",(()=>Te(qr,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){
|
164
|
+
this._container.destroy()}}function $r({eventBus:e,config:t}){const[n,o]=oe(!0),i=se(null);ie((()=>{const t=e.createEmitter();return t.subscribe("openProfile",(()=>{o(!1)})),i.current=t,()=>{t.destroy()}}),[e]);const r=()=>{o(!0),i.current?.publish("closeProfile")};return n?null:Te(Vr,{closed:n,onClose:r,"data-testid":"profile-outer","aria-label":"Hypothesis profile",children:[Te("div",{className:"absolute right-0 m-3",children:Te(kt,{title:"Close profile dialog",onClick:r,variant:"dark",classes:Re("!bg-transparent enabled:hover:!bg-grey-3"),children:Te(He,{className:"w-4 h-4"})})}),Te("iframe",{title:"Hypothesis profile",className:"h-full w-full border-0",src:t.profileAppUrl})]})}class Wr{constructor(e,t,n){this._container=new to("profile",(()=>Te($r,{eventBus:t,config:n}))),e.append(this._container.element),this._container.render()}destroy(){this._container.destroy()}}function jr({above:e,below:t,buckets:n,onFocusAnnotations:o,onScrollToAnnotation:i,onSelectAnnotations:r}){
|
165
|
+
const s=e.anchors.length>0,a=t.anchors.length>0,l=e=>e.anchors.map((e=>e.tag));return Te("ul",{className:"relative",children:[s&&Te("li",{className:"absolute right-0 pointer-events-auto mt-[-11px]",style:{top:e.position},children:Te(tn,{"data-testid":"up-navigation-button",direction:"up",onClick:()=>{const t=[...e.anchors].sort(((e,t)=>e.bottom-t.bottom)),n=t[t.length-1];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})}),n.map(((e,t)=>Te("li",{className:"absolute right-0 pointer-events-auto mt-[-8px]",style:{top:e.position},children:Te(tn,{direction:"left",onClick:t=>r(l(e),t.metaKey||t.ctrlKey),onBlur:()=>o([]),onFocus:()=>o(l(e)),onMouseEnter:()=>o(l(e)),onMouseOut:()=>o([]),title:`Select nearby annotations (${e.anchors.length})`,children:e.anchors.length})},t))),a&&Te("li",{className:"absolute right-0 pointer-events-auto",style:{top:t.position},children:Te(tn,{
|
166
|
+
"data-testid":"down-navigation-button",direction:"down",onClick:()=>{const e=[...t.anchors].sort(((e,t)=>e.top-t.top)),n=e[0];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})})]})}class Xr{constructor(e,{onFocusAnnotations:t,onScrollToAnnotation:n,onSelectAnnotations:o}){this._positions=[],this._container=new to("bucket-bar",(()=>this._render())),Object.assign(this._container.element.style,{display:"block",flexGrow:"1",width:"100%"}),e.appendChild(this._container.element),this._onFocusAnnotations=t,this._onScrollToAnnotation=n,this._onSelectAnnotations=o,this._container.render()}destroy(){this._container.destroy()}update(e){this._positions=e,this._container.render()}_render(){const e=function(e,t){const n=[],o=[],i=[];let r=null;function s(e){const{bottom:t,top:n}=e;return{bottom:t,position:n+(t-n)/2,anchors:[e],top:n}}const a=t.getBoundingClientRect(),l=e.map((e=>({tag:e.tag,
|
167
|
+
top:e.top-a.top,bottom:e.bottom-a.top})));for(const e of l){const t=(e.top+e.bottom)/2;if(t<30){n.push(e);continue}if(t>a.height-30){o.push(e);continue}if(!r){r=s(e);continue}const l=e.top>r.top&&e.bottom<r.bottom;if(e.top-r.bottom>60&&!l)i.push(r),r=s(e);else{const t=e.bottom>r.bottom?e.bottom:r.bottom,n=t-r.top;r.anchors.push(e),r.bottom=t,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 Te(jr,{above:e.above,below:e.below,buckets:e.buckets,onFocusAnnotations:e=>this._onFocusAnnotations(e),onScrollToAnnotation:e=>this._onScrollToAnnotation(e),onSelectAnnotations:(e,t)=>this._onSelectAnnotations(e,t)})}}function Yr({emitter:e}){const[t,n]=oe([]),o=le((e=>n((t=>[...t,e]))),[]),i=le((e=>n((t=>t.filter((t=>t.id!==e))))),[]);return ie((()=>(e.subscribe("toastMessageAdded",o),e.subscribe("toastMessageDismissed",i),()=>{e.unsubscribe("toastMessageAdded",o),
|
168
|
+
e.unsubscribe("toastMessageDismissed",i)})),[e,i,o]),Te(Qt,{messages:t,onMessageDismiss:i})}function Kr({icon:e,...t}){return Te(St,{classes:Re("justify-center rounded","w-[30px] h-[30px]","shadow border bg-white text-grey-6 hover:text-grey-9"),...t,size:"custom",variant:"custom",children:Te(e,{})})}function Gr({highlightsVisible:e}){return Te("div",{className:"sr-only",role:"status","data-testid":"toolbar-status",children:e?"Highlights visible":"Highlights hidden"})}function Qr({closeSidebar:e,createAnnotation:t,isSidebarOpen:n,sidebarContainerId:o,newAnnotationType:i,showHighlights:r,supportedTools:s=["selection"],toggleHighlights:a,toggleSidebar:l,toggleSidebarRef:c,useMinimalControls:h=!1}){return Te("div",{className:Re({"absolute right-full":h,"relative right-[11px]":!h},"w-[33px] z-2","text-px-base leading-none"),children:[h&&n&&Te(St,{
|
169
|
+
classes:Re("transition-colors focus-visible-ring ring-inset","w-[27px] h-[27px] mt-[140px] ml-px-1.5","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:Te(He,{})}),!h&&Te(x,{children:[Te(St,{classes:Re("transition-colors focus-visible-ring ring-inset","h-[40px] w-[33px] pl-[6px] rounded-bl","bg-white text-grey-5 hover:text-grey-9","border-l border-b"),elementRef:c,title:"Annotation sidebar",expanded:n,"aria-controls":o,onClick:l,unstyled:!0,children:Te(n?We:ze,{})}),Te("div",{className:"space-y-px-1.5 mt-px-2",children:[Te(Kr,{title:"Show highlights",icon:r?Nt:tt,pressed:r,onClick:a}),s.includes("selection")&&Te(Kr,{"data-testid":"text-annotation",title:"note"===i?"New page note":"New annotation",icon:"note"===i?ct:De,onClick:()=>t("selection")}),s.includes("rect")&&Te(Kr,{"data-testid":"rect-annotation",title:"Rectangle annotation",icon:yt,onClick:()=>t("rect")
|
170
|
+
}),s.includes("point")&&Te(Kr,{"data-testid":"point-annotation",title:"Pin annotation",icon:dt,onClick:()=>t("point")})]}),Te(Gr,{highlightsVisible:r})]})]})}class Jr{constructor(e,t){const{createAnnotation:n,setSidebarOpen:o,setHighlightsVisible:i}=t;this._container=e,this._useMinimalControls=!1,this._newAnnotationType="note",this._highlightsVisible=!1,this._sidebarOpen=!1,this._sidebarContainerId=t.sidebarContainerId,this._supportedAnnotationTools=["selection"],this._closeSidebar=()=>o(!1),this._toggleSidebar=()=>o(!this._sidebarOpen),this._toggleHighlights=()=>i(!this._highlightsVisible),this._createAnnotation=e=>{n(e),"selection"===e&&o(!0)},this._sidebarToggleButton={current:null},this.render()}getWidth(){return this._container.firstChild.getBoundingClientRect().width}set useMinimalControls(e){this._useMinimalControls=e,this.render()}get useMinimalControls(){return this._useMinimalControls}set sidebarOpen(e){this._sidebarOpen=e,this.render()}get sidebarOpen(){return this._sidebarOpen}
|
171
|
+
set newAnnotationType(e){this._newAnnotationType=e,this.render()}get newAnnotationType(){return this._newAnnotationType}set highlightsVisible(e){this._highlightsVisible=e,this.render()}get highlightsVisible(){return this._highlightsVisible}get sidebarToggleButton(){return this._sidebarToggleButton.current}set supportedAnnotationTools(e){this._supportedAnnotationTools=e,this.render()}get supportedAnnotationTools(){return this._supportedAnnotationTools}render(){U(Te(Qr,{closeSidebar:this._closeSidebar,createAnnotation:this._createAnnotation,newAnnotationType:this._newAnnotationType,isSidebarOpen:this._sidebarOpen,sidebarContainerId:this._sidebarContainerId,showHighlights:this._highlightsVisible,supportedTools:this._supportedAnnotationTools,toggleHighlights:this._toggleHighlights,toggleSidebar:this._toggleSidebar,toggleSidebarRef:this._sidebarToggleButton,useMinimalControls:this.useMinimalControls}),this._container)}}class Zr{constructor({target:e,threshold:t=10,onDrag:n}){e.style.touchAction="none",
|
172
|
+
this._listeners=new we,this._startX=null,this._dragActive=!1,this._threshold=t,this._listeners.add(e,"pointerdown",(e=>{this._startX=e.clientX}));const o=e=>{if(null!==this._startX&&this._dragActive){const t=e.clientX-this._startX;n({type:"dragend",deltaX:t})}this._startX=null,this._dragActive=!1};this._listeners.add(window,"pointercancel",o),this._listeners.add(window,"pointerup",o),this._listeners.add(window,"pointermove",(e=>{if(null===this._startX)return;const t=e.clientX-this._startX;!this._dragActive&&Math.abs(t)>=this._threshold&&(this._dragActive=!0,n({type:"dragstart",deltaX:t})),this._dragActive&&n({type:"dragmove",deltaX:t})}))}destroy(){this._listeners.removeAll()}}class es{constructor(e,t,n){this._emitter=t.createEmitter(),this._guestWithSelection=null,this._guestRPC=[],this._sidebarRPC=new wn,this.iframe=function(e){const t=e.sidebarAppUrl,n=Br(t,Dr(t,e)),o=document.createElement("iframe");return o.src=n,o.title="Hypothesis annotation viewer",o.className="sidebar-frame",
|
173
|
+
o.allow="fullscreen; clipboard-write",o}(n),this._config=n,this.bucketBar=null,this.features=new zo;const o="sidebar-container",i=document.createElement("div");if(i.setAttribute("data-testid","toolbar-container"),this.toolbar=new Jr(i,{sidebarContainerId:o,createAnnotation:e=>{if(0===this._guestRPC.length)return;(this._guestWithSelection??this._guestRPC[0]).call("createAnnotation",{tool:e})},setSidebarOpen:e=>e?this.open():this.close(),setHighlightsVisible:e=>this.setHighlightsVisible(e)}),n.externalContainerSelector)this.externalFrame=document.querySelector(n.externalContainerSelector)??e,this.externalFrame.appendChild(this.iframe);else{if(this.iframeContainer=document.createElement("div"),this.iframeContainer.style.display="none",this.iframeContainer.className="sidebar-container",this.iframeContainer.id=o,"clean"===n.theme)this.iframeContainer.classList.add("theme-clean"),this.iframeContainer.append(i),this.toolbar.useMinimalControls=!0;else{let e
|
174
|
+
;n.bucketContainerSelector&&(e=document.querySelector(n.bucketContainerSelector),e||console.warn(`Custom bucket container "${n.bucketContainerSelector}" not found`));const t=document.createElement("div");t.setAttribute("data-testid","sidebar-edge"),t.className=Re("absolute top-0 bottom-0 w-[23px] left-[-22px]","flex flex-col pr-[5px]","bg-grey-2 sidebar-collapsed:bg-black/[.08]","pointer-events-none"),i.className="pointer-events-auto",t.append(i),this.iframeContainer.append(t),e||(e=t),this.bucketBar=new Xr(e,{onFocusAnnotations:e=>this._guestRPC.forEach((t=>t.call("hoverAnnotations",e))),onScrollToAnnotation:e=>this._guestRPC.forEach((t=>t.call("scrollToAnnotation",e))),onSelectAnnotations:(e,t)=>this._guestRPC.forEach((n=>n.call("selectAnnotations",e,t)))})}this.iframeContainer.appendChild(this.iframe),this._hypothesisSidebar=document.createElement("hypothesis-sidebar");const t=eo(this._hypothesisSidebar);t.appendChild(this.iframeContainer),e.appendChild(this._hypothesisSidebar),
|
175
|
+
this._messagesElement=document.createElement("div"),t.appendChild(this._messagesElement),U(Te(Yr,{emitter:this._emitter}),this._messagesElement)}this.iframe.contentWindow&&un(this.iframe.contentWindow),this._listeners=new we,this.iframeContainer?this._toolbarWidth=this.toolbar.getWidth():this._toolbarWidth=0,this._listeners.add(window,"resize",(()=>this._onResize())),this._dragResizeState={initial:null,final:null};const r=this.toolbar.sidebarToggleButton;r&&(this._dragResizeHandler=new Zr({target:r,onDrag:e=>this._onDragSidebarToggleButton(e)})),this.close();const[s]=n.services||[];s&&(this.onLoginRequest=s.onLoginRequest,this.onLogoutRequest=s.onLogoutRequest,this.onSignupRequest=s.onSignupRequest,this.onProfileRequest=s.onProfileRequest,this.onHelpRequest=s.onHelpRequest),this.onLayoutChange=n.onLayoutChange,this._layoutState={expanded:!1,width:0,height:0,toolbarWidth:0},this._updateLayoutState(!1),this._setupSidebarEvents()}destroy(){this._guestRPC.forEach((e=>e.destroy())),this._sidebarRPC.destroy(),
|
176
|
+
this.bucketBar?.destroy(),this._listeners.removeAll(),this._dragResizeHandler?.destroy(),this._hypothesisSidebar?(U(null,this._messagesElement),this._hypothesisSidebar.remove()):this.iframe.remove(),this._emitter.destroy(),un(null)}onFrameConnected(e,t){switch(e){case"guest":this._connectGuest(t);break;case"sidebar":this._sidebarRPC.connect(t)}}_connectGuest(e){const t=new wn;t.on("textSelected",(()=>{this._guestWithSelection=t,this.toolbar.newAnnotationType="annotation",this._guestRPC.filter((e=>e!==t)).forEach((e=>e.call("clearSelection")))})),t.on("textUnselected",(()=>{this._guestWithSelection=null,this.toolbar.newAnnotationType="note",this._guestRPC.filter((e=>e!==t)).forEach((e=>e.call("clearSelection")))})),t.on("highlightsVisibleChanged",(e=>{this.setHighlightsVisible(e)}));const n=this.bucketBar;n&&t.on("anchorsChanged",(e=>{0===this._guestRPC.indexOf(t)&&n.update(e)})),t.on("close",(()=>{t.destroy(),t===this._guestWithSelection&&(this._guestWithSelection=null),
|
177
|
+
this._guestRPC=this._guestRPC.filter((e=>e!==t))})),t.on("supportedToolsChanged",(e=>{this.toolbar.supportedAnnotationTools=e})),t.connect(e),this._guestRPC.push(t),t.call("sidebarLayoutChanged",this._layoutState)}_setupSidebarEvents(){var e;e=document.body,this._sidebarRPC.on("publicAnnotationCountChanged",(function(t){const n=e.querySelectorAll("[data-hypothesis-annotation-count]");Array.from(n).forEach((e=>{e.textContent=t.toString()}))})),function(e,t){const n=e.querySelectorAll("[data-hypothesis-trigger]");Array.from(n).forEach((e=>{e.addEventListener("click",(e=>{t(),e.stopPropagation()}))}))}(document.body,(()=>this.open())),this._sidebarRPC.on("featureFlagsUpdated",(e=>this.features.update(e))),this._sidebarRPC.on("connect",(()=>{this.iframeContainer&&(this.iframeContainer.style.display="");const e="always"===this._config.showHighlights;this.setHighlightsVisible(e),(this._config.openSidebar||this._config.annotations||this._config.query||this._config.group)&&this.open()})),
|
178
|
+
this._sidebarRPC.on("showHighlights",(()=>this.setHighlightsVisible(!0))),this._sidebarRPC.on("openSidebar",(()=>this.open())),this._sidebarRPC.on("closeSidebar",(()=>this.close())),this._sidebarRPC.on("openNotebook",(e=>{this.hide(),this._emitter.publish("openNotebook",e)})),this._sidebarRPC.on("openProfile",(()=>{this.hide(),this._emitter.publish("openProfile")})),this._emitter.subscribe("closeProfile",(()=>{this.show()})),this._emitter.subscribe("closeNotebook",(()=>{this.show()})),this._sidebarRPC.on("toastMessageAdded",(e=>{this._emitter.publish("toastMessageAdded",e)})),this._sidebarRPC.on("toastMessageDismissed",(e=>{this._emitter.publish("toastMessageDismissed",e)}));[["loginRequested",this.onLoginRequest],["logoutRequested",this.onLogoutRequest],["signupRequested",this.onSignupRequest],["profileRequested",this.onProfileRequest],["helpRequested",this.onHelpRequest]].forEach((([e,t])=>{t&&this._sidebarRPC.on(e,(()=>t()))}))}_resetDragResizeState(){this._dragResizeState={initial:null,final:null}}
|
179
|
+
_updateLayout(){this._renderFrame||(this._renderFrame=requestAnimationFrame((()=>{if(this._renderFrame=void 0,"number"==typeof this._dragResizeState.final&&this._dragResizeState.final!==this._dragResizeState.initial&&this.iframeContainer){const e=this._dragResizeState.final,t=-e;this.iframeContainer.style.marginLeft=`${e}px`,t>=280&&(this.iframeContainer.style.width=`${t}px`),this._updateLayoutState()}})))}_updateLayoutState(e){const t=this.iframeContainer&&this.toolbar.getWidth()||0,n=this.iframeContainer??this.externalFrame,{height:o}=n.getBoundingClientRect(),i=window.getComputedStyle(n),r=parseInt(i.width),s=parseInt(i.marginLeft);let a=t;"boolean"==typeof e?e&&(a+=r):(s<280?a-=s:a+=r,e=a>t);const l={expanded:e,width:e?a:t,height:o,toolbarWidth:t};this._layoutState=l,this.onLayoutChange?.(l),this._guestRPC.forEach((e=>e.call("sidebarLayoutChanged",l)))}_onResize(){!0===this.toolbar.sidebarOpen&&(window.innerWidth<280?this.close():this.open())}isResizing(){return null!==this._dragResizeState.initial}
|
180
|
+
_onDragSidebarToggleButton(e){const t=this.iframeContainer;if(t)switch(e.type){case"dragstart":this._resetDragResizeState(),t.classList.add("sidebar-no-transition"),t.style.pointerEvents="none",this._dragResizeState.initial=parseInt(getComputedStyle(t).marginLeft);break;case"dragend":t.classList.remove("sidebar-no-transition"),t.style.pointerEvents="",null===this._dragResizeState.final||this._dragResizeState.final<=-280?this.open():this.close(),this._resetDragResizeState();break;case"dragmove":{if("number"!=typeof this._dragResizeState.initial)return;const t=this._dragResizeState.initial,n=e.deltaX;this._dragResizeState.final=Math.min(Math.round(t+n),0),this._updateLayout();break}}}open(){if(this._sidebarRPC.call("sidebarOpened"),this.iframeContainer){const e=this.iframeContainer.getBoundingClientRect().width;this.iframeContainer.style.marginLeft=-1*e+"px",this.iframeContainer.classList.remove("sidebar-collapsed")}this.toolbar.sidebarOpen=!0,
|
181
|
+
"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!0),this._updateLayoutState(!0)}close(){this._sidebarRPC.call("sidebarClosed"),this.iframeContainer&&(this.iframeContainer.style.marginLeft="",this.iframeContainer.classList.add("sidebar-collapsed")),this.toolbar.sidebarOpen=!1,"whenSidebarOpen"===this._config.showHighlights&&this.setHighlightsVisible(!1),this._updateLayoutState(!1)}setHighlightsVisible(e){this.toolbar.highlightsVisible=e,this._sidebarRPC.call("setHighlightsVisible",e)}show(){this.iframeContainer?.classList.remove("is-hidden")}hide(){this.iframeContainer?.classList.add("is-hidden")}}class ts{constructor(e){this._emitter=e,this._subscriptions=[]}publish(e,...t){this._emitter.emit(e,...t)}subscribe(e,t){this._emitter.on(e,t),this._subscriptions.push([e,t])}unsubscribe(e,t){this._emitter.off(e,t),this._subscriptions=this._subscriptions.filter((([n,o])=>n!==e||o!==t))}destroy(){for(const[e,t]of this._subscriptions)this._emitter.off(e,t);this._subscriptions=[]}}class ns{
|
182
|
+
constructor(){this._emitter=new ln}createEmitter(){return new ts(this._emitter)}}const os=document.querySelector('link[type="application/annotator+html"][rel="sidebar"]');new Promise((e=>{"loading"!==document.readyState&&e(),document.addEventListener("readystatechange",(()=>e()))})).then((function(){const e=$n("annotator");let t=()=>{};const n=new Promise((e=>{t=e}));os.addEventListener("destroy",t);const o=e.subFrameIdentifier?window.parent:window,i=[];if(o===window){if(function(){const e=document.querySelectorAll(["hypothesis-sidebar","hypothesis-notebook","hypothesis-profile"].join(","));return e.forEach((e=>e.remove())),e.length>0}())return void console.warn("Hypothesis did not load because it found an existing instance on the page.");const e=function(e=navigator.userAgent){if(!bn(e))return()=>{};const t=e=>{if("hypothesisPortClosed"===e.data?.type&&e.ports[0]){const t=e.ports[0];_n(t,"close"),t.close()}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}();i.push({
|
183
|
+
destroy:e});const t=$n("sidebar"),n=new URL(t.sidebarAppUrl).origin,o=new fn(n),r=new ns,s=new es(document.body,r,t),a=new zr(document.body,r,$n("notebook")),l=new Wr(document.body,r,$n("profile"));o.on("frameConnected",((e,t)=>s.onFrameConnected(e,t))),i.push(o,s,a,l)}if("container"===yr()){const t=new xr(e);i.push(t)}else{const n=new _r(document.body,e),r=new Ir(document.body,e,o);r.on("hostDisconnected",t),i.push(n,r)}n.then((()=>{i.forEach((e=>e.destroy()));document.querySelectorAll("[data-hypothesis-asset]").forEach((e=>e.remove())),function(e=document){Array.from(e.querySelectorAll("script.js-hypothesis-config[data-remove-on-unload]")).forEach((e=>e.remove()))}()}))}))}();
|
184
|
+
//# sourceMappingURL=annotator.bundle.js.map
|