@nulib/clover 0.0.0-stage → 4.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +120 -2
  3. package/dist/components/Annotations/Annotations.mjs +674 -0
  4. package/dist/components/Annotations/EntryBodies.mjs +52 -0
  5. package/dist/components/Annotations/languages.mjs +43 -0
  6. package/dist/components/Body/Body.mjs +51 -0
  7. package/dist/components/Body/BodyAlert.mjs +25 -0
  8. package/dist/components/Body/Caption.mjs +90 -0
  9. package/dist/components/Body/CaptionDetails.mjs +50 -0
  10. package/dist/components/Body/Pending.mjs +9 -0
  11. package/dist/components/Body/glyphs.mjs +66 -0
  12. package/dist/components/Body/renderers.mjs +30 -0
  13. package/dist/components/Body/useControlsVisibility.mjs +204 -0
  14. package/dist/components/Body/useNearViewport.mjs +27 -0
  15. package/dist/components/Canvas/AnnotationMenu.mjs +128 -0
  16. package/dist/components/Canvas/AnnotationState.mjs +338 -0
  17. package/dist/components/Canvas/Annotations.mjs +497 -0
  18. package/dist/components/Canvas/CanvasView.mjs +669 -0
  19. package/dist/components/Canvas/ChoiceMenu.mjs +77 -0
  20. package/dist/components/Canvas/Connected.mjs +228 -0
  21. package/dist/components/Canvas/ControlMenu.mjs +67 -0
  22. package/dist/components/Canvas/Controls.mjs +233 -0
  23. package/dist/components/Canvas/FrameAnimation.mjs +344 -0
  24. package/dist/components/Canvas/LoadedCanvas.mjs +177 -0
  25. package/dist/components/Canvas/Placeholder.mjs +105 -0
  26. package/dist/components/Canvas/fromManifest.mjs +44 -0
  27. package/dist/components/Canvas/index.mjs +19 -0
  28. package/dist/components/Canvas/layout.mjs +369 -0
  29. package/dist/components/Canvas/media/MediaBody.mjs +285 -0
  30. package/dist/components/Canvas/media/Player.mjs +193 -0
  31. package/dist/components/Canvas/media/Transport.mjs +511 -0
  32. package/dist/components/Canvas/media/TransportButton.mjs +39 -0
  33. package/dist/components/Canvas/media/useBarHeight.mjs +28 -0
  34. package/dist/components/Canvas/media/useCaptionTracks.mjs +131 -0
  35. package/dist/components/Canvas/media/useMediaController.mjs +77 -0
  36. package/dist/components/Canvas/media/useMediaElement.mjs +100 -0
  37. package/dist/components/Canvas/panClearOfControls.mjs +92 -0
  38. package/dist/components/Canvas/rendererSurface.mjs +6 -0
  39. package/dist/components/Canvas/surface.mjs +5 -0
  40. package/dist/components/Canvas/track.mjs +43 -0
  41. package/dist/components/Canvas/useSvgReader.mjs +23 -0
  42. package/dist/components/Collection/Collection.mjs +76 -0
  43. package/dist/components/CollectionSelect/CollectionSelect.mjs +114 -0
  44. package/dist/components/Contents/Contents.mjs +120 -0
  45. package/dist/components/Download/Download.mjs +105 -0
  46. package/dist/components/Items/Item.mjs +184 -0
  47. package/dist/components/Items/Items.mjs +455 -0
  48. package/dist/components/Items/Pager.mjs +190 -0
  49. package/dist/components/Items/StandaloneItems.mjs +80 -0
  50. package/dist/components/Items/clamped.mjs +90 -0
  51. package/dist/components/Label/Label.mjs +39 -0
  52. package/dist/components/Map/LoadedMap.mjs +26 -0
  53. package/dist/components/Map/Map.mjs +38 -0
  54. package/dist/components/Map/MapView.mjs +538 -0
  55. package/dist/components/Map/basemap.mjs +50 -0
  56. package/dist/components/Map/overlayImage.mjs +17 -0
  57. package/dist/components/Panel/About.mjs +143 -0
  58. package/dist/components/Panel/Panel.mjs +259 -0
  59. package/dist/components/Panel/PanelToggle.mjs +43 -0
  60. package/dist/components/Panel/PartOfManifest.mjs +52 -0
  61. package/dist/components/Primitives/Primitives.mjs +263 -0
  62. package/dist/components/Primitives/resource.mjs +11 -0
  63. package/dist/components/Provider/Provider.mjs +174 -0
  64. package/dist/components/Root/Announcer.mjs +58 -0
  65. package/dist/components/Root/Root.mjs +29 -0
  66. package/dist/components/Root/useRootState.mjs +188 -0
  67. package/dist/components/Scene/Connected.mjs +48 -0
  68. package/dist/components/Scene/Loaded.mjs +56 -0
  69. package/dist/components/Scene/RotatePad.mjs +204 -0
  70. package/dist/components/Scene/Scene.mjs +20 -0
  71. package/dist/components/Scene/SceneView.mjs +539 -0
  72. package/dist/components/Scene/cloverEngine.mjs +105 -0
  73. package/dist/components/Scene/engine.mjs +141 -0
  74. package/dist/components/Scene/engines.mjs +23 -0
  75. package/dist/components/Scene/gestures.mjs +74 -0
  76. package/dist/components/Scene/models.mjs +78 -0
  77. package/dist/components/Scene/orbit.mjs +60 -0
  78. package/dist/components/Search/Search.mjs +246 -0
  79. package/dist/components/Split/Split.mjs +203 -0
  80. package/dist/components/Split/splitting.mjs +203 -0
  81. package/dist/components/Status/Status.mjs +47 -0
  82. package/dist/components/Timeline/Connected.mjs +25 -0
  83. package/dist/components/Timeline/Timeline.mjs +40 -0
  84. package/dist/components/Timeline/playerSurface.mjs +84 -0
  85. package/dist/components/Transcript/Transcript.mjs +377 -0
  86. package/dist/components/Viewer/Viewer.mjs +19 -0
  87. package/dist/core/annotation-bodies.mjs +29 -0
  88. package/dist/core/annotation-collection.mjs +55 -0
  89. package/dist/core/annotation-name.mjs +31 -0
  90. package/dist/core/annotation-sets.mjs +155 -0
  91. package/dist/core/annotations-content.mjs +27 -0
  92. package/dist/core/annotations.mjs +73 -0
  93. package/dist/core/clover.mjs +393 -0
  94. package/dist/core/content-state-reader.mjs +82 -0
  95. package/dist/core/content-state.mjs +43 -0
  96. package/dist/core/direction.mjs +12 -0
  97. package/dist/core/geo-detect.mjs +30 -0
  98. package/dist/core/geo.mjs +283 -0
  99. package/dist/core/items.mjs +74 -0
  100. package/dist/core/keep-fragments.mjs +40 -0
  101. package/dist/core/link.mjs +28 -0
  102. package/dist/core/load.mjs +176 -0
  103. package/dist/core/map-config.mjs +12 -0
  104. package/dist/core/markdown.mjs +139 -0
  105. package/dist/core/pages.mjs +51 -0
  106. package/dist/core/painted-bodies.mjs +20 -0
  107. package/dist/core/painting.mjs +17 -0
  108. package/dist/core/presentation.mjs +27 -0
  109. package/dist/core/ranges.mjs +133 -0
  110. package/dist/core/region.mjs +32 -0
  111. package/dist/core/request.mjs +40 -0
  112. package/dist/core/sanitize.mjs +72 -0
  113. package/dist/core/search-service.mjs +22 -0
  114. package/dist/core/search.mjs +154 -0
  115. package/dist/core/selectors.mjs +94 -0
  116. package/dist/core/sequence.mjs +70 -0
  117. package/dist/core/show-link.mjs +16 -0
  118. package/dist/core/store.mjs +40 -0
  119. package/dist/core/svg-shape.mjs +183 -0
  120. package/dist/core/text.mjs +36 -0
  121. package/dist/core/thumbnail.mjs +55 -0
  122. package/dist/core/value.mjs +39 -0
  123. package/dist/core/vtt.mjs +111 -0
  124. package/dist/hooks/useFullscreen.mjs +21 -0
  125. package/dist/hooks/useFullscreenSupported.mjs +11 -0
  126. package/dist/hooks/useLoaded.mjs +27 -0
  127. package/dist/hooks/useWithinFullscreen.mjs +24 -0
  128. package/dist/i18n/config.mjs +170 -0
  129. package/dist/i18n/hostLanguage.mjs +6 -0
  130. package/dist/i18n/locales/en.json.mjs +5 -0
  131. package/dist/i18n/locales/es.json.mjs +5 -0
  132. package/dist/i18n/locales/fi.json.mjs +5 -0
  133. package/dist/i18n/locales/fr.json.mjs +5 -0
  134. package/dist/i18n/locales/index.mjs +13 -0
  135. package/dist/i18n/locales/nb.json.mjs +5 -0
  136. package/dist/i18n/locales/nn.json.mjs +5 -0
  137. package/dist/i18n/locales/no.json.mjs +5 -0
  138. package/dist/i18n/locales/pt.json.mjs +5 -0
  139. package/dist/i18n/reader.mjs +13 -0
  140. package/dist/i18n/useCloverTranslation.mjs +28 -0
  141. package/dist/index.d.mts +2204 -0
  142. package/dist/index.mjs +133 -0
  143. package/dist/lib/asArray.mjs +5 -0
  144. package/dist/lib/classnames.mjs +5 -0
  145. package/dist/lib/fullscreen.mjs +65 -0
  146. package/dist/lib/gltf/bounds.mjs +44 -0
  147. package/dist/lib/gltf/load.mjs +156 -0
  148. package/dist/lib/gltf/mat4.mjs +150 -0
  149. package/dist/lib/gltf/renderer.mjs +342 -0
  150. package/dist/lib/gltf/shaders.mjs +192 -0
  151. package/dist/lib/hls.mjs +6 -0
  152. package/dist/lib/pointer.mjs +38 -0
  153. package/dist/lib/renderer/CanvasRenderer.mjs +857 -0
  154. package/dist/lib/renderer/backends/backend.mjs +21 -0
  155. package/dist/lib/renderer/backends/canvas2d/Canvas2DBackend.mjs +91 -0
  156. package/dist/lib/renderer/backends/contexts.mjs +27 -0
  157. package/dist/lib/renderer/backends/dom/DomLayers.mjs +91 -0
  158. package/dist/lib/renderer/backends/webgl2/WebGL2Backend.mjs +248 -0
  159. package/dist/lib/renderer/backends/webgl2/shaders.mjs +28 -0
  160. package/dist/lib/renderer/camera/Camera.mjs +64 -0
  161. package/dist/lib/renderer/camera/CameraAnimator.mjs +90 -0
  162. package/dist/lib/renderer/input/GestureController.mjs +252 -0
  163. package/dist/lib/renderer/io/TileCache.mjs +207 -0
  164. package/dist/lib/renderer/io/decode.mjs +156 -0
  165. package/dist/lib/renderer/loop/FrameLoop.mjs +50 -0
  166. package/dist/lib/renderer/math/affine.mjs +68 -0
  167. package/dist/lib/renderer/math/rect.mjs +45 -0
  168. package/dist/lib/renderer/overlays/Navigator.mjs +141 -0
  169. package/dist/lib/renderer/overlays/OverlayLayer.mjs +94 -0
  170. package/dist/lib/renderer/scene/planFrame.mjs +168 -0
  171. package/dist/lib/renderer/scene/regions.mjs +30 -0
  172. package/dist/lib/renderer/scene/sceneItem.mjs +114 -0
  173. package/dist/lib/renderer/scene/uploadBudget.mjs +30 -0
  174. package/dist/lib/renderer/sources/imageService.mjs +160 -0
  175. package/dist/lib/renderer/sources/sizedImage.mjs +38 -0
  176. package/dist/lib/renderer/sources/tilePyramid.mjs +172 -0
  177. package/dist/lib/time.mjs +21 -0
  178. package/dist/map/index.d.mts +184 -0
  179. package/dist/map/index.mjs +16 -0
  180. package/dist/react/context.mjs +46 -0
  181. package/dist/react/hooks.mjs +69 -0
  182. package/dist/react/language.mjs +30 -0
  183. package/dist/styles.css +1 -0
  184. package/dist/templates/default/Default.mjs +229 -0
  185. package/dist/templates/document/Document.mjs +286 -0
  186. package/dist/templates/document/DocumentPanel.mjs +9 -0
  187. package/dist/templates/document/Sheets.mjs +360 -0
  188. package/dist/templates/gallery/Gallery.mjs +62 -0
  189. package/dist/templates/index.d.mts +273 -0
  190. package/dist/templates/index.mjs +11 -0
  191. package/dist/templates/shared/Lightbox.mjs +111 -0
  192. package/dist/templates/shared/LightboxBody.mjs +9 -0
  193. package/dist/templates/shared/dragToClose.mjs +129 -0
  194. package/dist/templates/shared/useDragToClose.mjs +35 -0
  195. package/dist/templates/shared/useDrawer.mjs +113 -0
  196. package/dist/templates/shared/useFollowFocus.mjs +24 -0
  197. package/dist/templates/shared/useSlide.mjs +52 -0
  198. package/dist/templates/shared/useSpine.mjs +26 -0
  199. package/dist/templates.css +1 -0
  200. package/dist/three/index.d.mts +6 -0
  201. package/dist/three/index.mjs +8 -0
  202. package/dist/ui/Button.mjs +53 -0
  203. package/dist/ui/ControlCluster.mjs +87 -0
  204. package/dist/ui/Cue.mjs +13 -0
  205. package/dist/ui/ErrorBoundary.mjs +26 -0
  206. package/dist/ui/ExitFullscreen.mjs +46 -0
  207. package/dist/ui/FieldPill.mjs +153 -0
  208. package/dist/ui/HideToggle.mjs +57 -0
  209. package/dist/ui/Loading.mjs +20 -0
  210. package/dist/ui/Markup.mjs +95 -0
  211. package/dist/ui/ReadMore.mjs +84 -0
  212. package/dist/ui/Sections.mjs +448 -0
  213. package/dist/ui/Steps.mjs +84 -0
  214. package/dist/ui/Tip.mjs +196 -0
  215. package/dist/ui/bringIntoView.mjs +27 -0
  216. package/dist/ui/controlGlyphs.mjs +120 -0
  217. package/dist/ui/heading.mjs +19 -0
  218. package/dist/ui/languageCode.mjs +8 -0
  219. package/dist/ui/mediaIcons.mjs +104 -0
  220. package/dist/ui/useClusterReach.mjs +50 -0
  221. package/dist/ui/useContainerName.mjs +19 -0
  222. package/dist/ui/useOneOpen.mjs +22 -0
  223. package/dist/ui/useRovingFocus.mjs +64 -0
  224. package/dist/ui/useScrollTrack.mjs +150 -0
  225. package/dist/ui/useUniqueId.mjs +10 -0
  226. package/dist/ui/visuallyHidden.mjs +15 -0
  227. package/dist/web-components/About-uKa1wfDr.mjs +1 -0
  228. package/dist/web-components/AnnotationMenu-BGIYRXW6.mjs +1 -0
  229. package/dist/web-components/AnnotationState-D2UIgIEC.mjs +1 -0
  230. package/dist/web-components/Annotations-BhwAv3ah.mjs +1 -0
  231. package/dist/web-components/Annotations-C_tBJHo3.mjs +2 -0
  232. package/dist/web-components/Body-DMEERFuB.mjs +1 -0
  233. package/dist/web-components/BodyAlert-BP8voSLv.mjs +1 -0
  234. package/dist/web-components/Button-Cl02BFDd.mjs +1 -0
  235. package/dist/web-components/Camera-Dw51CAfF.mjs +1 -0
  236. package/dist/web-components/Canvas2DBackend-RRN2bEkc.mjs +1 -0
  237. package/dist/web-components/CanvasView-B8lMMSou.mjs +1 -0
  238. package/dist/web-components/CaptionDetails-KLMDv-ec.mjs +1 -0
  239. package/dist/web-components/ChoiceMenu-CXrVOmJl.mjs +1 -0
  240. package/dist/web-components/Collection-DL4Ui4hF.mjs +1 -0
  241. package/dist/web-components/CollectionSelect-DL-bbpwJ.mjs +1 -0
  242. package/dist/web-components/Connected-B0S1HXQb.mjs +1 -0
  243. package/dist/web-components/Connected-BcjRA5si.mjs +1 -0
  244. package/dist/web-components/Connected-Q7iizBb8.mjs +1 -0
  245. package/dist/web-components/Contents-ZC8TiGaW.mjs +1 -0
  246. package/dist/web-components/ControlMenu-DIoU797-.mjs +1 -0
  247. package/dist/web-components/Cue-CJxnDMEy.mjs +1 -0
  248. package/dist/web-components/Document-DHBRAFEK.mjs +1 -0
  249. package/dist/web-components/DocumentPanel-CqvE2pu9.mjs +1 -0
  250. package/dist/web-components/DomLayers-BsR2AOy-.mjs +1 -0
  251. package/dist/web-components/Download-DBksL1C0.mjs +1 -0
  252. package/dist/web-components/EntryBodies-VwEkTVrw.mjs +1 -0
  253. package/dist/web-components/ErrorBoundary-Cy9PGoZv.mjs +1 -0
  254. package/dist/web-components/FieldPill-DCJBz6Vj.mjs +1 -0
  255. package/dist/web-components/FrameAnimation-DRbmgGpF.mjs +1 -0
  256. package/dist/web-components/Gallery-BM7-VJkB.mjs +1 -0
  257. package/dist/web-components/HideToggle-BdYgG7us.mjs +1 -0
  258. package/dist/web-components/Items-_1Jz3FMs.mjs +1 -0
  259. package/dist/web-components/Label-CAiJ49eA.mjs +1 -0
  260. package/dist/web-components/LightboxBody-DyhUZiDf.mjs +1 -0
  261. package/dist/web-components/Loaded-wQurAeJz.mjs +1 -0
  262. package/dist/web-components/LoadedCanvas-DWz5IK5m.mjs +1 -0
  263. package/dist/web-components/LoadedMap-DIeW313M.mjs +1 -0
  264. package/dist/web-components/Loading-BmA--pzr.mjs +1 -0
  265. package/dist/web-components/Map-DzVGblIS.mjs +1 -0
  266. package/dist/web-components/MapView-BJaN7VBI.mjs +1 -0
  267. package/dist/web-components/Markup-D91DbxLk.mjs +2 -0
  268. package/dist/web-components/MediaBody-BYcVPo2X.mjs +1 -0
  269. package/dist/web-components/MediaBody-FEzH8VVw.mjs +1 -0
  270. package/dist/web-components/Navigator-CIJFA3q1.mjs +1 -0
  271. package/dist/web-components/Pager-BGwCurxE.mjs +1 -0
  272. package/dist/web-components/Panel-B-GXOkzF.mjs +1 -0
  273. package/dist/web-components/PanelToggle-BYjV2t1j.mjs +1 -0
  274. package/dist/web-components/PartOfManifest-ClbGepVM.mjs +1 -0
  275. package/dist/web-components/Pending-BspZajh5.mjs +1 -0
  276. package/dist/web-components/Primitives-CTh59wvs.mjs +1 -0
  277. package/dist/web-components/Provider-C6rIiDXH.mjs +1 -0
  278. package/dist/web-components/ReadMore-BJ2i-0uN.mjs +1 -0
  279. package/dist/web-components/Root-DkkYDtur.mjs +1 -0
  280. package/dist/web-components/Scene-B_PU_TiX.mjs +1 -0
  281. package/dist/web-components/SceneView-qcW_sT3j.mjs +1 -0
  282. package/dist/web-components/Search-UOneIUcP.mjs +1 -0
  283. package/dist/web-components/Sections-we9U9fXq.mjs +2 -0
  284. package/dist/web-components/StandaloneItems-DU8oCFc_.mjs +1 -0
  285. package/dist/web-components/Status-Cs5ZvFvL.mjs +1 -0
  286. package/dist/web-components/Timeline-WtYZ1bIJ.mjs +1 -0
  287. package/dist/web-components/Tip-C8J3qsIK.mjs +1 -0
  288. package/dist/web-components/Transcript-CRL2zToL.mjs +1 -0
  289. package/dist/web-components/annotation-collection-ZPyvpLFc.mjs +1 -0
  290. package/dist/web-components/annotations-content-BZChKhJZ.mjs +1 -0
  291. package/dist/web-components/assets/maplibre-gl-worker-kTz9OPxr.js +13831 -0
  292. package/dist/web-components/body-UntgrmoV.mjs +1 -0
  293. package/dist/web-components/bringIntoView-CQH5ZgMM.mjs +1 -0
  294. package/dist/web-components/canvas-d_U4v_mh.mjs +1 -0
  295. package/dist/web-components/classnames-DukgfdpI.mjs +1 -0
  296. package/dist/web-components/cloverEngine-Dbv-26NP.mjs +164 -0
  297. package/dist/web-components/content-state-reader-DjdKWjit.mjs +1 -0
  298. package/dist/web-components/contexts-ByL3eA_T.mjs +1 -0
  299. package/dist/web-components/controls-qRYf2jO2.mjs +1 -0
  300. package/dist/web-components/custom-elements.json +2739 -0
  301. package/dist/web-components/dragToClose-C-Pf1IeO.mjs +1 -0
  302. package/dist/web-components/engine-D8JLgzqq.mjs +4228 -0
  303. package/dist/web-components/engines-BwVb9R_A.mjs +1 -0
  304. package/dist/web-components/es-BwMkoRod.mjs +1 -0
  305. package/dist/web-components/fi-gPFOn9RK.mjs +1 -0
  306. package/dist/web-components/fr-DUHmgdJo.mjs +1 -0
  307. package/dist/web-components/fromManifest-UrMJgktp.mjs +1 -0
  308. package/dist/web-components/glyphs-BoX0a88P.mjs +1 -0
  309. package/dist/web-components/heading-Cjt0f-Eu.mjs +1 -0
  310. package/dist/web-components/hls-CdKrthkC.mjs +40 -0
  311. package/dist/web-components/hooks-Dp8pjU8l.mjs +1 -0
  312. package/dist/web-components/imageService-C3yg9DxB.mjs +1 -0
  313. package/dist/web-components/index-DWxMuwDL.mjs +1 -0
  314. package/dist/web-components/index.d.mts +604 -0
  315. package/dist/web-components/index.mjs +1 -0
  316. package/dist/web-components/index.umd.js +18 -0
  317. package/dist/web-components/items--Tu7ZM3L.mjs +1 -0
  318. package/dist/web-components/items-W2vrwArM.mjs +1 -0
  319. package/dist/web-components/keep-fragments-B5nlv2ck.mjs +1 -0
  320. package/dist/web-components/label-CYQ7tVl6.mjs +1 -0
  321. package/dist/web-components/languageCode-cCpiU0b0.mjs +1 -0
  322. package/dist/web-components/layout-KL0V-iJu.mjs +1 -0
  323. package/dist/web-components/link-DRRTY4lY.mjs +1 -0
  324. package/dist/web-components/logo-CnQUCB3Y.mjs +1 -0
  325. package/dist/web-components/maplibre-gl-CQ4OueXY.mjs +823 -0
  326. package/dist/web-components/markdown-CCYJwzFn.mjs +5 -0
  327. package/dist/web-components/models-BP2qp9nT.mjs +1 -0
  328. package/dist/web-components/nb-BSvnQ6jd.mjs +1 -0
  329. package/dist/web-components/nn-Dg2_HdZu.mjs +1 -0
  330. package/dist/web-components/no-BSvnQ6jd.mjs +1 -0
  331. package/dist/web-components/nodes-Bf-Fb7e5.mjs +1 -0
  332. package/dist/web-components/overlayImage-DdPs2EGY.mjs +1 -0
  333. package/dist/web-components/panClearOfControls-ac9uf-Qs.mjs +1 -0
  334. package/dist/web-components/panel-CiqEFDzv.mjs +1 -0
  335. package/dist/web-components/part-CUBY90_b.mjs +1 -0
  336. package/dist/web-components/playerSurface-i2TJz-F4.mjs +1 -0
  337. package/dist/web-components/provider-LUmAQSoP.mjs +1 -0
  338. package/dist/web-components/pt-B3J80JgO.mjs +1 -0
  339. package/dist/web-components/read-more-BaaO77el.mjs +1 -0
  340. package/dist/web-components/rendererSurface-DAvatpMF.mjs +22 -0
  341. package/dist/web-components/renderers-Bg4QqawN.mjs +1 -0
  342. package/dist/web-components/resource-DzIvB_4m.mjs +1 -0
  343. package/dist/web-components/sanitize-Dc7nOsgO.mjs +3 -0
  344. package/dist/web-components/search-DgcgsI3I.mjs +1 -0
  345. package/dist/web-components/shared-J3w3gnXD.mjs +1 -0
  346. package/dist/web-components/show-link-DWRRXSBy.mjs +1 -0
  347. package/dist/web-components/sizedImage-DfjlV2-i.mjs +1 -0
  348. package/dist/web-components/split-m-_XivaW.mjs +1 -0
  349. package/dist/web-components/splitting-BnQUxxgH.mjs +1 -0
  350. package/dist/web-components/status-DDS7jLNd.mjs +1 -0
  351. package/dist/web-components/styles-Ypl9KrSK.mjs +1 -0
  352. package/dist/web-components/svg-shape-DLY3g7oq.mjs +1 -0
  353. package/dist/web-components/text-BTAkxEfQ.mjs +5 -0
  354. package/dist/web-components/three.mjs +1 -0
  355. package/dist/web-components/thumbnail-BZvLSwWW.mjs +1 -0
  356. package/dist/web-components/time-B9GZoYcm.mjs +1 -0
  357. package/dist/web-components/tip-BXByhOJ9.mjs +1 -0
  358. package/dist/web-components/toggle-AS72kq6v.mjs +1 -0
  359. package/dist/web-components/upgrader-XNxI-5jo.mjs +1 -0
  360. package/dist/web-components/useContainerName-DCbE5JXi.mjs +1 -0
  361. package/dist/web-components/useNearViewport-CyoK3l8W.mjs +1 -0
  362. package/dist/web-components/useScrollTrack-dLFWnT8N.mjs +1 -0
  363. package/dist/web-components/viewer/AnnotationMenu-Dd4tnzNV.mjs +1 -0
  364. package/dist/web-components/viewer/AnnotationState-DZaSy5lH.mjs +1 -0
  365. package/dist/web-components/viewer/Annotations-D1h-Yi5J.mjs +1 -0
  366. package/dist/web-components/viewer/Annotations-sj79EMen.mjs +2 -0
  367. package/dist/web-components/viewer/Canvas2DBackend-CkvI0wUT.mjs +1 -0
  368. package/dist/web-components/viewer/CaptionDetails-B_JdNjJ7.mjs +1 -0
  369. package/dist/web-components/viewer/ChoiceMenu-xa51a1DV.mjs +1 -0
  370. package/dist/web-components/viewer/Collection-CxuLCspj.mjs +1 -0
  371. package/dist/web-components/viewer/Connected-BSUBc3Ci.mjs +1 -0
  372. package/dist/web-components/viewer/Connected-CPIxNjF2.mjs +1 -0
  373. package/dist/web-components/viewer/Contents-DNh9mnsF.mjs +1 -0
  374. package/dist/web-components/viewer/ControlMenu-DdgIvBdf.mjs +1 -0
  375. package/dist/web-components/viewer/Cue-90H9_dXz.mjs +1 -0
  376. package/dist/web-components/viewer/Document-CNCpzkiN.mjs +1 -0
  377. package/dist/web-components/viewer/DocumentPanel-BdG4TVLE.mjs +1 -0
  378. package/dist/web-components/viewer/DomLayers-Dybz_aJv.mjs +1 -0
  379. package/dist/web-components/viewer/EntryBodies-DGXjFP3N.mjs +1 -0
  380. package/dist/web-components/viewer/FieldPill-Icmd98OY.mjs +1 -0
  381. package/dist/web-components/viewer/FrameAnimation-DJZN3Rd4.mjs +1 -0
  382. package/dist/web-components/viewer/Gallery-CEp3-bh2.mjs +1 -0
  383. package/dist/web-components/viewer/HideToggle-DB6HTmAO.mjs +1 -0
  384. package/dist/web-components/viewer/LightboxBody-ClQ4yrTh.mjs +1 -0
  385. package/dist/web-components/viewer/MapView-BVSdybIC.mjs +1 -0
  386. package/dist/web-components/viewer/MediaBody-BBbSMT1i.mjs +1 -0
  387. package/dist/web-components/viewer/MediaBody-BzMXMHIF.mjs +1 -0
  388. package/dist/web-components/viewer/Navigator-Duc69Yes.mjs +1 -0
  389. package/dist/web-components/viewer/PartOfManifest-X9_q-2t6.mjs +1 -0
  390. package/dist/web-components/viewer/Search-S4N5QU4R.mjs +1 -0
  391. package/dist/web-components/viewer/StandaloneItems-BO4VyWRW.mjs +1 -0
  392. package/dist/web-components/viewer/Transcript-BbDaS064.mjs +1 -0
  393. package/dist/web-components/viewer/annotation-collection-BjZ1DAHq.mjs +1 -0
  394. package/dist/web-components/viewer/annotations-content-jn3n5Y2-.mjs +1 -0
  395. package/dist/web-components/viewer/cloverEngine-CjuYjUhI.mjs +164 -0
  396. package/dist/web-components/viewer/content-state-reader-CPiShIjP.mjs +1 -0
  397. package/dist/web-components/viewer/host-yWi4R1bP.mjs +1 -0
  398. package/dist/web-components/viewer/index.d.mts +7 -0
  399. package/dist/web-components/viewer/index.mjs +1 -0
  400. package/dist/web-components/viewer/index.umd.js +18 -0
  401. package/dist/web-components/viewer/link-CwE-fg5G.mjs +1 -0
  402. package/dist/web-components/viewer/overlayImage-BpOgqsZ0.mjs +1 -0
  403. package/dist/web-components/viewer/renderers-L-IlGI1r.mjs +1 -0
  404. package/dist/web-components/viewer/search-DWkwRPo_.mjs +1 -0
  405. package/dist/web-components/viewer/styles-BRCkEU3w.mjs +1 -0
  406. package/dist/web-components/viewer/viewer--TreVlJ_.mjs +28 -0
  407. package/dist/web-components/viewer/vtt-1ZJwtElI.mjs +5 -0
  408. package/dist/web-components/viewer-DyV864Qe.mjs +1 -0
  409. package/dist/web-components/vtt-GFssZH8Y.mjs +5 -0
  410. package/package.json +110 -4
@@ -0,0 +1,154 @@
1
+ "use client";
2
+ import { parseAnnotationTarget } from "./annotations.mjs";
3
+ import { fetchJson } from "./request.mjs";
4
+ import { SEARCH_SET_ID } from "./search-service.mjs";
5
+ import { asArray } from "../lib/asArray.mjs";
6
+ const MAX_PAGES = 10;
7
+ async function searchInto(store, service, query, request, signal) {
8
+ var _a, _b;
9
+ const manifestId = (_a = store.get().manifest) == null ? void 0 : _a.id;
10
+ try {
11
+ const { hits, set } = await search(service, query, { request, signal });
12
+ if (signal.aborted || ((_b = store.get().manifest) == null ? void 0 : _b.id) !== manifestId) return;
13
+ store.set({ search: { query, status: "ready", hits, set } });
14
+ } catch {
15
+ if (signal.aborted) return;
16
+ store.set({ search: { query, status: "error", hits: [], set: null } });
17
+ }
18
+ }
19
+ async function search(service, query, { request, signal } = {}) {
20
+ const url = new URL(service.id);
21
+ url.searchParams.set("q", query);
22
+ const pages = [];
23
+ let next = url.toString();
24
+ const seen = /* @__PURE__ */ new Set();
25
+ while (next && pages.length < MAX_PAGES && !seen.has(next)) {
26
+ seen.add(next);
27
+ const page = await fetchJson(request, next, signal);
28
+ pages.push(page);
29
+ next = nextPage(page);
30
+ }
31
+ return readResults(pages, query);
32
+ }
33
+ function targetV1(on) {
34
+ var _a;
35
+ const value = asArray(on)[0];
36
+ if (typeof value === "string" || !value) return value;
37
+ const full = value.full ?? value["@id"];
38
+ const fragment = (_a = asArray(value.selector)[0]) == null ? void 0 : _a.value;
39
+ return typeof fragment === "string" && typeof full === "string" ? `${full}#${fragment}` : full;
40
+ }
41
+ function nextPage(page) {
42
+ var _a;
43
+ const next = page.next ?? ((_a = page.within) == null ? void 0 : _a.next);
44
+ const id = typeof next === "string" ? next : (next == null ? void 0 : next.id) ?? (next == null ? void 0 : next["@id"]);
45
+ return typeof id === "string" ? id : null;
46
+ }
47
+ function readResults(pages, query) {
48
+ var _a, _b;
49
+ const entries = [];
50
+ const hits = [];
51
+ for (const page of pages) {
52
+ const v1 = Array.isArray(page.resources);
53
+ const annotations = v1 ? page.resources : asArray(page.items);
54
+ const byId = /* @__PURE__ */ new Map();
55
+ for (const annotation of annotations) {
56
+ const id = annotation.id ?? annotation["@id"];
57
+ const raw = v1 ? targetV1(annotation.on) : asArray(annotation.target)[0];
58
+ const target = parseAnnotationTarget(raw);
59
+ if (!id || !target.id) continue;
60
+ const text = v1 ? (_a = annotation.resource) == null ? void 0 : _a.chars : asArray(annotation.body).map((body) => body == null ? void 0 : body.value).find((value) => typeof value === "string");
61
+ const entry = {
62
+ id,
63
+ setId: SEARCH_SET_ID,
64
+ canvasId: target.id,
65
+ target,
66
+ motivation: ["highlighting"],
67
+ bodies: [{ value: String(text ?? query) }],
68
+ // One shape for the Canvas whichever version answered: a highlighting annotation.
69
+ annotation: {
70
+ id,
71
+ type: "Annotation",
72
+ motivation: ["highlighting"],
73
+ body: { type: "TextualBody", value: String(text ?? query) },
74
+ target: raw
75
+ }
76
+ };
77
+ byId.set(id, entry);
78
+ entries.push(entry);
79
+ }
80
+ const grouped = v1 ? readHitsV1(page, byId) : readHitsV2(page, byId);
81
+ const listed = new Set(grouped.flatMap((hit) => hit.entryIds));
82
+ hits.push(...grouped);
83
+ for (const entry of byId.values()) {
84
+ if (listed.has(entry.id)) continue;
85
+ hits.push({
86
+ id: entry.id,
87
+ canvasId: entry.canvasId,
88
+ entryIds: [entry.id],
89
+ match: ((_b = entry.bodies[0]) == null ? void 0 : _b.value) ?? query
90
+ });
91
+ }
92
+ }
93
+ return {
94
+ query,
95
+ hits,
96
+ set: {
97
+ id: SEARCH_SET_ID,
98
+ label: { none: [query] },
99
+ source: "search",
100
+ entries
101
+ }
102
+ };
103
+ }
104
+ function readHitsV1(page, byId) {
105
+ var _a;
106
+ const hits = [];
107
+ for (const hit of asArray(page.hits)) {
108
+ const entryIds = asArray(hit.annotations).filter(
109
+ (id) => byId.has(id)
110
+ );
111
+ if (!entryIds.length) continue;
112
+ hits.push({
113
+ id: entryIds.join(" "),
114
+ canvasId: byId.get(entryIds[0]).canvasId,
115
+ entryIds,
116
+ before: hit.before,
117
+ match: String(hit.match ?? ((_a = byId.get(entryIds[0]).bodies[0]) == null ? void 0 : _a.value) ?? ""),
118
+ after: hit.after
119
+ });
120
+ }
121
+ return hits;
122
+ }
123
+ function readHitsV2(page, byId) {
124
+ var _a, _b;
125
+ const hits = [];
126
+ for (const group of asArray(page.annotations)) {
127
+ for (const annotation of asArray(group == null ? void 0 : group.items)) {
128
+ const motivation = asArray(annotation == null ? void 0 : annotation.motivation);
129
+ if (!motivation.includes("contextualizing")) continue;
130
+ for (const target of asArray(annotation.target)) {
131
+ const source = typeof (target == null ? void 0 : target.source) === "string" ? target.source : (_a = target == null ? void 0 : target.source) == null ? void 0 : _a.id;
132
+ const entry = source ? byId.get(source) : void 0;
133
+ if (!entry) continue;
134
+ const quote = asArray(target.selector).find(
135
+ (selector) => (selector == null ? void 0 : selector.type) === "TextQuoteSelector"
136
+ );
137
+ hits.push({
138
+ id: `${annotation.id ?? source}#${source}`,
139
+ canvasId: entry.canvasId,
140
+ entryIds: [entry.id],
141
+ before: quote == null ? void 0 : quote.prefix,
142
+ match: String((quote == null ? void 0 : quote.exact) ?? ((_b = entry.bodies[0]) == null ? void 0 : _b.value) ?? ""),
143
+ after: quote == null ? void 0 : quote.suffix
144
+ });
145
+ }
146
+ }
147
+ }
148
+ return hits;
149
+ }
150
+ export {
151
+ readResults,
152
+ search,
153
+ searchInto
154
+ };
@@ -0,0 +1,94 @@
1
+ "use client";
2
+ import { resolveDirection, groupViews, resolveBehavior, viewOf } from "./sequence.mjs";
3
+ import { parseAnnotationTarget } from "./annotations.mjs";
4
+ const sequences = /* @__PURE__ */ new WeakMap();
5
+ const EMPTY = { canvases: [], views: [], direction: "left-to-right" };
6
+ function selectSequence(manifest) {
7
+ if (!manifest) return EMPTY;
8
+ let sequence = sequences.get(manifest);
9
+ if (!sequence) {
10
+ const canvases = (manifest.items ?? []).filter(
11
+ // `Body` draws each with its own part: `Canvas`, `Timeline` or `Scene`.
12
+ (item) => (item == null ? void 0 : item.type) === "Canvas" || (item == null ? void 0 : item.type) === "Timeline" || (item == null ? void 0 : item.type) === "Scene"
13
+ );
14
+ sequence = {
15
+ canvases,
16
+ views: groupViews(
17
+ canvases,
18
+ resolveBehavior(manifest.behavior)
19
+ ),
20
+ direction: resolveDirection(
21
+ manifest.viewingDirection
22
+ )
23
+ };
24
+ sequences.set(manifest, sequence);
25
+ }
26
+ return sequence;
27
+ }
28
+ const byId = /* @__PURE__ */ new WeakMap();
29
+ function selectCanvas(manifest, id) {
30
+ if (!id) return null;
31
+ const sequence = selectSequence(manifest);
32
+ let canvases = byId.get(sequence);
33
+ if (!canvases) {
34
+ canvases = /* @__PURE__ */ new Map();
35
+ for (const canvas of sequence.canvases)
36
+ if (!canvases.has(canvas.id)) canvases.set(canvas.id, canvas);
37
+ byId.set(sequence, canvases);
38
+ }
39
+ return canvases.get(id) ?? null;
40
+ }
41
+ function selectPosition(manifest, canvasId) {
42
+ const { canvases, views } = selectSequence(manifest);
43
+ const index = canvases.findIndex((canvas) => canvas.id === canvasId);
44
+ return index === -1 ? 0 : viewOf(views, index);
45
+ }
46
+ const visible = /* @__PURE__ */ new WeakMap();
47
+ const NONE = [];
48
+ function selectVisibleCanvases(manifest, canvasId) {
49
+ if (!manifest) return NONE;
50
+ const position = selectPosition(manifest, canvasId);
51
+ let byView = visible.get(manifest);
52
+ if (!byView) visible.set(manifest, byView = /* @__PURE__ */ new Map());
53
+ let canvases = byView.get(position);
54
+ if (!canvases) {
55
+ const sequence = selectSequence(manifest);
56
+ canvases = (sequence.views[position] ?? []).map(
57
+ (index) => sequence.canvases[index]
58
+ );
59
+ byView.set(position, canvases);
60
+ }
61
+ return canvases;
62
+ }
63
+ function canvasOfView(manifest, view) {
64
+ var _a, _b;
65
+ const { canvases, views } = selectSequence(manifest);
66
+ const index = (_a = views[view]) == null ? void 0 : _a[0];
67
+ return index === void 0 ? null : ((_b = canvases[index]) == null ? void 0 : _b.id) ?? null;
68
+ }
69
+ function selectStart(manifest) {
70
+ const start = manifest == null ? void 0 : manifest.start;
71
+ if (!start) return null;
72
+ const parsed = parseAnnotationTarget(start);
73
+ if (!parsed.id) return null;
74
+ const target = { canvasId: parsed.id };
75
+ if (parsed.rect) target.region = parsed.rect;
76
+ const time = parsed.t ? Number(parsed.t.split(",")[0]) : NaN;
77
+ if (Number.isFinite(time)) target.time = time;
78
+ return target;
79
+ }
80
+ const hasBehavior = (resource, value) => {
81
+ const behavior = resource == null ? void 0 : resource.behavior;
82
+ return Array.isArray(behavior) ? behavior.includes(value) : behavior === value;
83
+ };
84
+ const partOfCollection = (manifest) => [(manifest == null ? void 0 : manifest.partOf) ?? []].flat().find((part) => (part == null ? void 0 : part.id) && part.type === "Collection");
85
+ export {
86
+ canvasOfView,
87
+ hasBehavior,
88
+ partOfCollection,
89
+ selectCanvas,
90
+ selectPosition,
91
+ selectSequence,
92
+ selectStart,
93
+ selectVisibleCanvases
94
+ };
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { asArray } from "../lib/asArray.mjs";
3
+ const DIRECTIONS = [
4
+ "left-to-right",
5
+ "right-to-left",
6
+ "top-to-bottom",
7
+ "bottom-to-top"
8
+ ];
9
+ function resolveDirection(declared) {
10
+ return DIRECTIONS.includes(declared) ? declared : "left-to-right";
11
+ }
12
+ const LAYOUT_BEHAVIORS = [
13
+ "individuals",
14
+ "paged",
15
+ "continuous",
16
+ "unordered"
17
+ ];
18
+ function resolveBehavior(declared) {
19
+ const match = asArray(declared).find(
20
+ (value) => LAYOUT_BEHAVIORS.includes(value)
21
+ );
22
+ return match ?? "individuals";
23
+ }
24
+ function groupViews(canvases, behavior) {
25
+ if (!canvases.length) return [];
26
+ if (behavior === "continuous") return [canvases.map((_, index) => index)];
27
+ if (behavior !== "paged") return canvases.map((_, index) => [index]);
28
+ const views = [];
29
+ let pending = [];
30
+ let offset = 0;
31
+ let closeNextPair = false;
32
+ const flush = () => {
33
+ if (pending.length) views.push(pending);
34
+ pending = [];
35
+ };
36
+ canvases.forEach((canvas, index) => {
37
+ const own = asArray(canvas.behavior);
38
+ if (own.includes("non-paged")) {
39
+ if (index === offset) offset++;
40
+ flush();
41
+ views.push([index]);
42
+ return;
43
+ }
44
+ if (index === offset || own.includes("facing-pages")) {
45
+ if (pending.length) closeNextPair = true;
46
+ flush();
47
+ views.push([index]);
48
+ return;
49
+ }
50
+ pending.push(index);
51
+ if (closeNextPair) {
52
+ flush();
53
+ closeNextPair = false;
54
+ return;
55
+ }
56
+ if (pending.length > 1) flush();
57
+ });
58
+ flush();
59
+ return views;
60
+ }
61
+ function viewOf(views, canvasIndex) {
62
+ const found = views.findIndex((view) => view.includes(canvasIndex));
63
+ return found === -1 ? 0 : found;
64
+ }
65
+ export {
66
+ groupViews,
67
+ resolveBehavior,
68
+ resolveDirection,
69
+ viewOf
70
+ };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { selectSequence } from "./selectors.mjs";
3
+ function showLink(clover, link) {
4
+ const shown = clover.store.get().manifest;
5
+ const here = link.canvasId && selectSequence(shown).canvases.some(
6
+ (canvas) => canvas.id === link.canvasId
7
+ );
8
+ if (here) clover.goTo(link.canvasId);
9
+ else if (link.manifestId && link.manifestId !== (shown == null ? void 0 : shown.id))
10
+ void clover.goToManifest(link.manifestId, link.canvasId);
11
+ else return false;
12
+ return true;
13
+ }
14
+ export {
15
+ showLink
16
+ };
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ function createStore(initial) {
3
+ let state = initial;
4
+ const listeners = /* @__PURE__ */ new Set();
5
+ return {
6
+ get: () => state,
7
+ set(patch) {
8
+ const next = typeof patch === "function" ? patch(state) : patch;
9
+ const changed = Object.keys(next).some(
10
+ (key) => !Object.is(next[key], state[key])
11
+ );
12
+ if (!changed) return;
13
+ state = { ...state, ...next };
14
+ listeners.forEach((listener) => listener());
15
+ },
16
+ subscribe(listener) {
17
+ listeners.add(listener);
18
+ return () => listeners.delete(listener);
19
+ }
20
+ };
21
+ }
22
+ function createChannel(initial) {
23
+ let value = initial;
24
+ const listeners = /* @__PURE__ */ new Set();
25
+ return {
26
+ get: () => value,
27
+ emit(next) {
28
+ value = next;
29
+ listeners.forEach((listener) => listener(next));
30
+ },
31
+ subscribe(listener) {
32
+ listeners.add(listener);
33
+ return () => listeners.delete(listener);
34
+ }
35
+ };
36
+ }
37
+ export {
38
+ createChannel,
39
+ createStore
40
+ };
@@ -0,0 +1,183 @@
1
+ "use client";
2
+ const NUMBER = /^-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;
3
+ const POINTS = /^[\d\s.,eE+-]*$/;
4
+ const PATH = /^[\d\s.,eE+\-MmLlHhVvCcSsQqTtAaZz]*$/;
5
+ const GEOMETRY = {
6
+ path: ["d"],
7
+ polygon: ["points"],
8
+ polyline: ["points"],
9
+ rect: ["x", "y", "width", "height", "rx", "ry"],
10
+ circle: ["cx", "cy", "r"],
11
+ ellipse: ["cx", "cy", "rx", "ry"],
12
+ line: ["x1", "y1", "x2", "y2"]
13
+ };
14
+ function readSvgShape(svg) {
15
+ var _a;
16
+ if (typeof DOMParser === "undefined" || !svg) return null;
17
+ let doc;
18
+ try {
19
+ doc = new DOMParser().parseFromString(svg, "image/svg+xml");
20
+ } catch {
21
+ return null;
22
+ }
23
+ if (doc.querySelector("parsererror")) return null;
24
+ const shapes = [];
25
+ const points = [];
26
+ for (const element of Array.from(
27
+ doc.querySelectorAll(Object.keys(GEOMETRY).join(","))
28
+ )) {
29
+ const tag = element.localName;
30
+ const attributes = {};
31
+ for (const name of GEOMETRY[tag]) {
32
+ const value = (_a = element.getAttribute(name)) == null ? void 0 : _a.trim();
33
+ if (value == null || value === "") continue;
34
+ const valid = name === "d" ? PATH.test(value) : name === "points" ? POINTS.test(value) : NUMBER.test(value);
35
+ if (valid) attributes[name] = value;
36
+ }
37
+ const extent = extentOf(tag, attributes);
38
+ if (!extent.length) continue;
39
+ shapes.push({ tag, attributes });
40
+ points.push(...extent);
41
+ }
42
+ if (!shapes.length) return null;
43
+ const xs = points.map(([x2]) => x2);
44
+ const ys = points.map(([, y2]) => y2);
45
+ const x = Math.min(...xs);
46
+ const y = Math.min(...ys);
47
+ const width = Math.max(...xs) - x;
48
+ const height = Math.max(...ys) - y;
49
+ if (![x, y, width, height].every(Number.isFinite)) return null;
50
+ return { box: { x, y, width, height }, shapes };
51
+ }
52
+ const num = (attributes, name) => Number(attributes[name] ?? 0);
53
+ function extentOf(tag, attributes) {
54
+ switch (tag) {
55
+ case "polygon":
56
+ case "polyline": {
57
+ const values = (attributes.points ?? "").trim().split(/[\s,]+/).filter(Boolean).map(Number);
58
+ const pairs = [];
59
+ for (let i = 0; i + 1 < values.length; i += 2) {
60
+ pairs.push([values[i], values[i + 1]]);
61
+ }
62
+ return pairs.length >= 2 ? pairs : [];
63
+ }
64
+ case "rect": {
65
+ const [x, y, w, h] = ["x", "y", "width", "height"].map(
66
+ (n) => num(attributes, n)
67
+ );
68
+ return w > 0 && h > 0 ? [
69
+ [x, y],
70
+ [x + w, y + h]
71
+ ] : [];
72
+ }
73
+ case "circle": {
74
+ const [cx, cy, r] = ["cx", "cy", "r"].map((n) => num(attributes, n));
75
+ return r > 0 ? [
76
+ [cx - r, cy - r],
77
+ [cx + r, cy + r]
78
+ ] : [];
79
+ }
80
+ case "ellipse": {
81
+ const [cx, cy, rx, ry] = ["cx", "cy", "rx", "ry"].map(
82
+ (n) => num(attributes, n)
83
+ );
84
+ return rx > 0 && ry > 0 ? [
85
+ [cx - rx, cy - ry],
86
+ [cx + rx, cy + ry]
87
+ ] : [];
88
+ }
89
+ case "line":
90
+ return [
91
+ [num(attributes, "x1"), num(attributes, "y1")],
92
+ [num(attributes, "x2"), num(attributes, "y2")]
93
+ ];
94
+ case "path":
95
+ return pathExtent(attributes.d ?? "");
96
+ }
97
+ }
98
+ function pathExtent(d) {
99
+ const tokens = d.match(
100
+ /[MmLlHhVvCcSsQqTtAaZz]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi
101
+ );
102
+ if (!tokens) return [];
103
+ const out = [];
104
+ let x = 0;
105
+ let y = 0;
106
+ let startX = 0;
107
+ let startY = 0;
108
+ let command = "";
109
+ let i = 0;
110
+ const next = () => Number(tokens[i++]);
111
+ const hasNumber = () => i < tokens.length && !/[a-z]/i.test(tokens[i]);
112
+ while (i < tokens.length) {
113
+ if (/[a-z]/i.test(tokens[i])) command = tokens[i++];
114
+ else if (!command) return [];
115
+ const relative = command === command.toLowerCase();
116
+ const upper = command.toUpperCase();
117
+ const at = (dx, dy) => relative ? [x + dx, y + dy] : [dx, dy];
118
+ if (upper === "Z") {
119
+ x = startX;
120
+ y = startY;
121
+ continue;
122
+ }
123
+ if (!hasNumber()) return out;
124
+ switch (upper) {
125
+ case "M":
126
+ case "L":
127
+ case "T": {
128
+ [x, y] = at(next(), next());
129
+ if (upper === "M") {
130
+ startX = x;
131
+ startY = y;
132
+ command = relative ? "l" : "L";
133
+ }
134
+ out.push([x, y]);
135
+ break;
136
+ }
137
+ case "H":
138
+ x = relative ? x + next() : next();
139
+ out.push([x, y]);
140
+ break;
141
+ case "V":
142
+ y = relative ? y + next() : next();
143
+ out.push([x, y]);
144
+ break;
145
+ case "C": {
146
+ const c1 = at(next(), next());
147
+ const c2 = at(next(), next());
148
+ [x, y] = at(next(), next());
149
+ out.push(c1, c2, [x, y]);
150
+ break;
151
+ }
152
+ case "S":
153
+ case "Q": {
154
+ const c = at(next(), next());
155
+ [x, y] = at(next(), next());
156
+ out.push(c, [x, y]);
157
+ break;
158
+ }
159
+ case "A": {
160
+ const rx = Math.abs(next());
161
+ const ry = Math.abs(next());
162
+ i += 3;
163
+ const from = [x, y];
164
+ [x, y] = at(next(), next());
165
+ out.push(
166
+ [Math.min(from[0], x) - rx, Math.min(from[1], y) - ry],
167
+ [Math.max(from[0], x) + rx, Math.max(from[1], y) + ry]
168
+ );
169
+ break;
170
+ }
171
+ default:
172
+ return out;
173
+ }
174
+ if (out.some(([px, py]) => !Number.isFinite(px) || !Number.isFinite(py))) {
175
+ return [];
176
+ }
177
+ }
178
+ return out;
179
+ }
180
+ export {
181
+ pathExtent,
182
+ readSvgShape
183
+ };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ const ENTITIES = {
3
+ amp: "&",
4
+ lt: "<",
5
+ gt: ">",
6
+ quot: '"',
7
+ apos: "'",
8
+ nbsp: " "
9
+ };
10
+ function toPlainText(html) {
11
+ return html.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (match, entity) => {
12
+ if (entity[0] === "#") {
13
+ const code = entity[1] === "x" || entity[1] === "X" ? parseInt(entity.slice(2), 16) : parseInt(entity.slice(1), 10);
14
+ return code > 0 && code <= 1114111 ? String.fromCodePoint(code) : match;
15
+ }
16
+ return ENTITIES[entity.toLowerCase()] ?? match;
17
+ });
18
+ }
19
+ const hasMarkup = (value) => /<[a-z!/]|&(#x?[0-9a-f]+|[a-z]+);/i.test(value);
20
+ function readAs(format, value = "") {
21
+ const type = format == null ? void 0 : format.split(";")[0].trim().toLowerCase();
22
+ if (type) {
23
+ return type === "text/html" ? "html" : type === "text/markdown" ? "markdown" : "plain";
24
+ }
25
+ const text = value.trim();
26
+ return text.startsWith("<") && text.endsWith(">") ? "html" : "plain";
27
+ }
28
+ function markdownToPlainText(markdown) {
29
+ return markdown.replace(/\r\n?/g, "\n").replace(/^\[\^[^\]]+\]:[ \t]*/gm, "").replace(/\[\^[^\]]+\]/g, "").replace(/^#{1,6}[ \t]+(\S.*?)(?:[ \t]+#+)?[ \t]*$/gm, "$1").replace(/^[ \t]*(?:[-*+]|\d+[.)])[ \t]+/gm, "").replace(/\[([^\]]+)\]\((?:https?:\/\/|mailto:)[^\s)]+\)/g, "$1").replace(/\*\*([^*]+)\*\*|__([^_]+)__/g, (_, a, b) => a ?? b).replace(/\*([^*\s][^*]*)\*|_([^_\s][^_]*)_/g, (_, a, b) => a ?? b).replace(/\\\n/g, "\n").replace(/\n\s*\n/g, "\n").trim();
30
+ }
31
+ export {
32
+ hasMarkup,
33
+ markdownToPlainText,
34
+ readAs,
35
+ toPlainText
36
+ };
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ import { fetchInfo, findImageServiceId } from "../lib/renderer/sources/imageService.mjs";
3
+ import { sizedImageUrl } from "../lib/renderer/sources/sizedImage.mjs";
4
+ import { paintedBodies } from "./painted-bodies.mjs";
5
+ import { asArray } from "../lib/asArray.mjs";
6
+ function firstPaintedImage(container) {
7
+ var _a;
8
+ return (_a = paintedBodies(container).find(
9
+ ({ body }) => body.type === "Image" || body.id && !body.type
10
+ )) == null ? void 0 : _a.body;
11
+ }
12
+ function regionShare(region, { width, height }) {
13
+ if (region === "full") return { x: 0, y: 0, width: 1, height: 1 };
14
+ const match = /^(pct:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)$/.exec(region);
15
+ if (!match) return null;
16
+ const [x, y, w, h] = match.slice(2).map(Number);
17
+ const [across, down] = match[1] ? [100, 100] : [width, height];
18
+ return { x: x / across, y: y / down, width: w / across, height: h / down };
19
+ }
20
+ function imageSource(image, region = "full") {
21
+ if (!image) return null;
22
+ const service = findImageServiceId(image.service);
23
+ if (service) {
24
+ return region === "full" ? { service, fallback: image.id } : { service, region, fallback: image.id };
25
+ }
26
+ return image.id ? { src: image.id } : null;
27
+ }
28
+ function thumbnailSource(resource) {
29
+ const value = resource;
30
+ if (!value) return null;
31
+ return imageSource(asArray(value.thumbnail)[0]) ?? imageSource(firstPaintedImage(value)) ?? imageSource(firstPaintedImage(value.placeholderContainer)) ?? imageSource(firstPaintedImage(value.accompanyingContainer));
32
+ }
33
+ function stillSource(resource) {
34
+ const value = resource;
35
+ if (!value) return null;
36
+ return imageSource(firstPaintedImage(value)) ?? imageSource(firstPaintedImage(value.placeholderContainer)) ?? imageSource(firstPaintedImage(value.accompanyingContainer)) ?? imageSource(asArray(value.thumbnail)[0]);
37
+ }
38
+ async function resolveThumbnail(source, size = 200, request) {
39
+ if (source.src) return source.src;
40
+ if (!source.service) return source.fallback;
41
+ try {
42
+ const info = await fetchInfo(source.service, { request });
43
+ const share = typeof source.region === "string" ? regionShare(source.region, info) : source.region;
44
+ if (share === null) return source.fallback;
45
+ return sizedImageUrl(info, size, share) ?? source.fallback;
46
+ } catch {
47
+ return source.fallback;
48
+ }
49
+ }
50
+ export {
51
+ imageSource,
52
+ resolveThumbnail,
53
+ stillSource,
54
+ thumbnailSource
55
+ };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { readerLanguages } from "../i18n/reader.mjs";
3
+ const baseOf = (tag) => tag.indexOf("-") === -1 ? null : tag.slice(0, tag.indexOf("-"));
4
+ function closestLanguage(language, tags, fallbacks = []) {
5
+ if (!tags.length) return void 0;
6
+ if (tags.length === 1) return tags[0];
7
+ const none = () => tags.includes("none") ? "none" : tags.includes("@none") ? "@none" : tags[0];
8
+ if (!language) return tags.includes("none") ? "none" : tags[0];
9
+ if (tags.includes(language)) return language;
10
+ const base = baseOf(language);
11
+ if (base && tags.includes(base)) return base;
12
+ const fallback = fallbacks.find((tag) => tags.includes(tag));
13
+ if (fallback) return fallback;
14
+ const regional = tags.findIndex((tag) => baseOf(tag) === language);
15
+ if (regional !== -1) return tags[regional];
16
+ for (const tag of fallbacks) {
17
+ const fallbackBase = baseOf(tag);
18
+ if (fallbackBase && tags.includes(fallbackBase)) return fallbackBase;
19
+ }
20
+ return none();
21
+ }
22
+ function localize(value, language, separator = ", ") {
23
+ if (!value) return { text: "" };
24
+ if (typeof value === "string") return { text: value };
25
+ const tags = Object.keys(value).filter((tag2) => {
26
+ var _a;
27
+ return (_a = value[tag2]) == null ? void 0 : _a.length;
28
+ });
29
+ if (!tags.length) return { text: "" };
30
+ const [first, ...rest] = language ? [language] : readerLanguages();
31
+ const tag = closestLanguage(first, tags, rest) ?? tags[0];
32
+ const entry = value[tag];
33
+ const text = Array.isArray(entry) ? entry.join(separator) : String(entry);
34
+ return { text, lang: tag === "none" ? void 0 : tag };
35
+ }
36
+ export {
37
+ closestLanguage,
38
+ localize
39
+ };