@nulib/clover 4.0.0-beta.0 → 4.0.0-beta.1

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 (181) hide show
  1. package/dist/components/Map/MapView.mjs +9 -8
  2. package/dist/components/Map/maplibre-worker.mjs +7 -0
  3. package/dist/components/Map/worker.mjs +22 -0
  4. package/dist/components/Panel/About.mjs +14 -9
  5. package/dist/components/Split/Split.mjs +9 -2
  6. package/dist/core/items.mjs +3 -1
  7. package/dist/core/load.mjs +10 -3
  8. package/dist/index.d.mts +23 -12
  9. package/dist/map/index.d.mts +15 -4
  10. package/dist/templates/index.d.mts +5 -2
  11. package/dist/templates.css +1 -1
  12. package/dist/ui/ReadMore.mjs +1 -1
  13. package/dist/web-components/About-DbrFSVBm.mjs +1 -0
  14. package/dist/web-components/{AnnotationMenu-BGIYRXW6.mjs → AnnotationMenu-EBjIQpQl.mjs} +1 -1
  15. package/dist/web-components/{AnnotationState-D2UIgIEC.mjs → AnnotationState-DQTaO6Gz.mjs} +1 -1
  16. package/dist/web-components/{Annotations-C_tBJHo3.mjs → Annotations-Cb9U7HJ_.mjs} +1 -1
  17. package/dist/web-components/{Annotations-BhwAv3ah.mjs → Annotations-Dl0SgHBS.mjs} +1 -1
  18. package/dist/web-components/{Body-DMEERFuB.mjs → Body-DxSz3iST.mjs} +1 -1
  19. package/dist/web-components/{BodyAlert-BP8voSLv.mjs → BodyAlert-C8EOXz24.mjs} +1 -1
  20. package/dist/web-components/{Button-Cl02BFDd.mjs → Button-uWgfvqsL.mjs} +1 -1
  21. package/dist/web-components/{Camera-Dw51CAfF.mjs → Camera-cdCqKMup.mjs} +1 -1
  22. package/dist/web-components/{Canvas2DBackend-RRN2bEkc.mjs → Canvas2DBackend-CnLEHRs4.mjs} +1 -1
  23. package/dist/web-components/{CanvasView-B8lMMSou.mjs → CanvasView-BI3YzNdK.mjs} +1 -1
  24. package/dist/web-components/{CaptionDetails-KLMDv-ec.mjs → CaptionDetails-B80ZhZ7v.mjs} +1 -1
  25. package/dist/web-components/{ChoiceMenu-CXrVOmJl.mjs → ChoiceMenu-DCp7-co7.mjs} +1 -1
  26. package/dist/web-components/{Collection-DL4Ui4hF.mjs → Collection-B1Le2_TU.mjs} +1 -1
  27. package/dist/web-components/{CollectionSelect-DL-bbpwJ.mjs → CollectionSelect-BL_jQog-.mjs} +1 -1
  28. package/dist/web-components/{Connected-BcjRA5si.mjs → Connected-BxqaRL9o.mjs} +1 -1
  29. package/dist/web-components/{Connected-B0S1HXQb.mjs → Connected-DCBI-j9H.mjs} +1 -1
  30. package/dist/web-components/{Connected-Q7iizBb8.mjs → Connected-DkhfVWxd.mjs} +1 -1
  31. package/dist/web-components/{Contents-ZC8TiGaW.mjs → Contents-zYEGHLfe.mjs} +1 -1
  32. package/dist/web-components/{ControlMenu-DIoU797-.mjs → ControlMenu-CAHiLAtl.mjs} +1 -1
  33. package/dist/web-components/{Cue-CJxnDMEy.mjs → Cue-BT2V9VAq.mjs} +1 -1
  34. package/dist/web-components/Document-BdCjGnJN.mjs +1 -0
  35. package/dist/web-components/DocumentPanel-X_Rta0Wu.mjs +1 -0
  36. package/dist/web-components/{DomLayers-BsR2AOy-.mjs → DomLayers-BD4QPbl6.mjs} +1 -1
  37. package/dist/web-components/{Download-DBksL1C0.mjs → Download-DqU-goFi.mjs} +1 -1
  38. package/dist/web-components/{EntryBodies-VwEkTVrw.mjs → EntryBodies-DXAQH0vR.mjs} +1 -1
  39. package/dist/web-components/{ErrorBoundary-Cy9PGoZv.mjs → ErrorBoundary-chQaO-Up.mjs} +1 -1
  40. package/dist/web-components/{FieldPill-DCJBz6Vj.mjs → FieldPill-CyEssPVm.mjs} +1 -1
  41. package/dist/web-components/{FrameAnimation-DRbmgGpF.mjs → FrameAnimation-Bb0pOoRl.mjs} +1 -1
  42. package/dist/web-components/{Gallery-BM7-VJkB.mjs → Gallery-BXU3TcT3.mjs} +1 -1
  43. package/dist/web-components/{HideToggle-BdYgG7us.mjs → HideToggle-BwMrOBMu.mjs} +1 -1
  44. package/dist/web-components/{Items-_1Jz3FMs.mjs → Items-DRj1UEpC.mjs} +1 -1
  45. package/dist/web-components/{Label-CAiJ49eA.mjs → Label-D6aVJB9s.mjs} +1 -1
  46. package/dist/web-components/LightboxBody-BzXQGMDn.mjs +1 -0
  47. package/dist/web-components/{Loaded-wQurAeJz.mjs → Loaded-D5xmFRSo.mjs} +1 -1
  48. package/dist/web-components/{LoadedCanvas-DWz5IK5m.mjs → LoadedCanvas-DOjtxLSe.mjs} +1 -1
  49. package/dist/web-components/LoadedMap-DouDS2lO.mjs +1 -0
  50. package/dist/web-components/{Loading-BmA--pzr.mjs → Loading-CBKfwsML.mjs} +1 -1
  51. package/dist/web-components/{Map-DzVGblIS.mjs → Map-Bcgp_R8H.mjs} +1 -1
  52. package/dist/web-components/MapView-CD5zkTs8.mjs +1 -0
  53. package/dist/web-components/{Markup-D91DbxLk.mjs → Markup-C1hMA8wk.mjs} +1 -1
  54. package/dist/web-components/{MediaBody-BYcVPo2X.mjs → MediaBody-B_Gii4we.mjs} +1 -1
  55. package/dist/web-components/{MediaBody-FEzH8VVw.mjs → MediaBody-BfrKIPte.mjs} +1 -1
  56. package/dist/web-components/{Navigator-CIJFA3q1.mjs → Navigator-BSJbEbuJ.mjs} +1 -1
  57. package/dist/web-components/{Pager-BGwCurxE.mjs → Pager-Di_2hHM3.mjs} +1 -1
  58. package/dist/web-components/{Panel-B-GXOkzF.mjs → Panel-DbsC8A9V.mjs} +1 -1
  59. package/dist/web-components/{PanelToggle-BYjV2t1j.mjs → PanelToggle-mUDw73zI.mjs} +1 -1
  60. package/dist/web-components/{PartOfManifest-ClbGepVM.mjs → PartOfManifest-7eOwURrF.mjs} +1 -1
  61. package/dist/web-components/{Pending-BspZajh5.mjs → Pending-BPOQ2z1L.mjs} +1 -1
  62. package/dist/web-components/{Primitives-CTh59wvs.mjs → Primitives-XQO3m1wG.mjs} +1 -1
  63. package/dist/web-components/{Provider-C6rIiDXH.mjs → Provider-B61118lU.mjs} +1 -1
  64. package/dist/web-components/{ReadMore-BJ2i-0uN.mjs → ReadMore-BJH-qqte.mjs} +1 -1
  65. package/dist/web-components/{Root-DkkYDtur.mjs → Root-Dj277K6p.mjs} +1 -1
  66. package/dist/web-components/Scene-BTWpLeec.mjs +1 -0
  67. package/dist/web-components/{SceneView-qcW_sT3j.mjs → SceneView-BYo7WmPt.mjs} +1 -1
  68. package/dist/web-components/{Search-UOneIUcP.mjs → Search-ZV8FFN4p.mjs} +1 -1
  69. package/dist/web-components/{Sections-we9U9fXq.mjs → Sections-ejwu1_Sm.mjs} +1 -1
  70. package/dist/web-components/{StandaloneItems-DU8oCFc_.mjs → StandaloneItems-BYaiyCca.mjs} +1 -1
  71. package/dist/web-components/{Status-Cs5ZvFvL.mjs → Status-YbQK2KzY.mjs} +1 -1
  72. package/dist/web-components/Timeline-ByyVSd7B.mjs +1 -0
  73. package/dist/web-components/{Tip-C8J3qsIK.mjs → Tip-IO11xX4x.mjs} +1 -1
  74. package/dist/web-components/{Transcript-CRL2zToL.mjs → Transcript-D0gUxUoA.mjs} +1 -1
  75. package/dist/web-components/{annotation-collection-ZPyvpLFc.mjs → annotation-collection-Csv7WIlm.mjs} +1 -1
  76. package/dist/web-components/{annotations-content-BZChKhJZ.mjs → annotations-content-BS_OFz5Z.mjs} +1 -1
  77. package/dist/web-components/{body-UntgrmoV.mjs → body-CKjwwFep.mjs} +1 -1
  78. package/dist/web-components/{canvas-d_U4v_mh.mjs → canvas-CIzpp-Uz.mjs} +1 -1
  79. package/dist/web-components/{cloverEngine-Dbv-26NP.mjs → cloverEngine-B4LinbSt.mjs} +1 -1
  80. package/dist/web-components/{content-state-reader-DjdKWjit.mjs → content-state-reader-D1BkpICh.mjs} +1 -1
  81. package/dist/web-components/{controls-qRYf2jO2.mjs → controls-Dj2BybWb.mjs} +1 -1
  82. package/dist/web-components/{engine-D8JLgzqq.mjs → engine-BSt8LTso.mjs} +1 -1
  83. package/dist/web-components/{engines-BwVb9R_A.mjs → engines-CC0OEsVE.mjs} +1 -1
  84. package/dist/web-components/{fromManifest-UrMJgktp.mjs → fromManifest-BhemHaoA.mjs} +1 -1
  85. package/dist/web-components/{glyphs-BoX0a88P.mjs → glyphs-drROkef9.mjs} +1 -1
  86. package/dist/web-components/{hooks-Dp8pjU8l.mjs → hooks-BXzQSllm.mjs} +1 -1
  87. package/dist/web-components/{imageService-C3yg9DxB.mjs → imageService-dsdmcegU.mjs} +1 -1
  88. package/dist/web-components/{index-DWxMuwDL.mjs → index-B7nZdqLg.mjs} +1 -1
  89. package/dist/web-components/index.mjs +1 -1
  90. package/dist/web-components/{items--Tu7ZM3L.mjs → items-CB2Uk7ts.mjs} +1 -1
  91. package/dist/web-components/items-jfQ5XzEj.mjs +1 -0
  92. package/dist/web-components/label-Vbg_cMOJ.mjs +1 -0
  93. package/dist/web-components/{layout-KL0V-iJu.mjs → layout-mMHI0lsj.mjs} +1 -1
  94. package/dist/web-components/{link-DRRTY4lY.mjs → link-ZRnv5NFR.mjs} +1 -1
  95. package/dist/web-components/logo-Boy6u4m2.mjs +1 -0
  96. package/dist/web-components/{models-BP2qp9nT.mjs → models-D1EE_CmH.mjs} +1 -1
  97. package/dist/web-components/{nodes-Bf-Fb7e5.mjs → nodes-B7JRwBgl.mjs} +1 -1
  98. package/dist/web-components/{overlayImage-DdPs2EGY.mjs → overlayImage-0OgQl1TL.mjs} +1 -1
  99. package/dist/web-components/{panel-CiqEFDzv.mjs → panel-CjXfre-g.mjs} +1 -1
  100. package/dist/web-components/part-cUiPs2-y.mjs +1 -0
  101. package/dist/web-components/{playerSurface-i2TJz-F4.mjs → playerSurface-CU5XxI1j.mjs} +1 -1
  102. package/dist/web-components/{provider-LUmAQSoP.mjs → provider-C1wKfdjb.mjs} +1 -1
  103. package/dist/web-components/{read-more-BaaO77el.mjs → read-more-DNHNtG-a.mjs} +1 -1
  104. package/dist/web-components/{rendererSurface-DAvatpMF.mjs → rendererSurface-DhIlOjGT.mjs} +2 -2
  105. package/dist/web-components/{renderers-Bg4QqawN.mjs → renderers-BMSWEFUR.mjs} +1 -1
  106. package/dist/web-components/{resource-DzIvB_4m.mjs → resource-DLHocQ1C.mjs} +1 -1
  107. package/dist/web-components/{search-DgcgsI3I.mjs → search-CLy2Wj01.mjs} +1 -1
  108. package/dist/web-components/{shared-J3w3gnXD.mjs → shared-YUjOSBKO.mjs} +1 -1
  109. package/dist/web-components/{show-link-DWRRXSBy.mjs → show-link-CyzYE1eS.mjs} +1 -1
  110. package/dist/web-components/{sizedImage-DfjlV2-i.mjs → sizedImage-uv_NlE0l.mjs} +1 -1
  111. package/dist/web-components/{split-m-_XivaW.mjs → split-CYuMjp89.mjs} +1 -1
  112. package/dist/web-components/{status-DDS7jLNd.mjs → status-Ms5L0ghK.mjs} +1 -1
  113. package/dist/web-components/{styles-Ypl9KrSK.mjs → styles-CyuM_fB1.mjs} +1 -1
  114. package/dist/web-components/three.mjs +1 -1
  115. package/dist/web-components/{thumbnail-BZvLSwWW.mjs → thumbnail-c2K_iQsD.mjs} +1 -1
  116. package/dist/web-components/{tip-BXByhOJ9.mjs → tip-dWhupWSr.mjs} +1 -1
  117. package/dist/web-components/{toggle-AS72kq6v.mjs → toggle-BQTjR1I3.mjs} +1 -1
  118. package/dist/web-components/{useContainerName-DCbE5JXi.mjs → useContainerName-BpJ3IWY0.mjs} +1 -1
  119. package/dist/web-components/{useNearViewport-CyoK3l8W.mjs → useNearViewport-CtLyYg9n.mjs} +1 -1
  120. package/dist/web-components/{useScrollTrack-dLFWnT8N.mjs → useScrollTrack-WbG28FPD.mjs} +1 -1
  121. package/dist/web-components/viewer/{AnnotationMenu-Dd4tnzNV.mjs → AnnotationMenu-ZKyBeyUU.mjs} +1 -1
  122. package/dist/web-components/viewer/{AnnotationState-DZaSy5lH.mjs → AnnotationState-DO33zokc.mjs} +1 -1
  123. package/dist/web-components/viewer/{Annotations-D1h-Yi5J.mjs → Annotations-BOjhr5ks.mjs} +1 -1
  124. package/dist/web-components/viewer/{Annotations-sj79EMen.mjs → Annotations-DkLueFLK.mjs} +1 -1
  125. package/dist/web-components/viewer/{Canvas2DBackend-CkvI0wUT.mjs → Canvas2DBackend-CAmzJD5P.mjs} +1 -1
  126. package/dist/web-components/viewer/{CaptionDetails-B_JdNjJ7.mjs → CaptionDetails-DOJlUtOn.mjs} +1 -1
  127. package/dist/web-components/viewer/{ChoiceMenu-xa51a1DV.mjs → ChoiceMenu-BDq6H34G.mjs} +1 -1
  128. package/dist/web-components/viewer/{Collection-CxuLCspj.mjs → Collection-By3puO0V.mjs} +1 -1
  129. package/dist/web-components/viewer/{Connected-BSUBc3Ci.mjs → Connected-DZNO2CPf.mjs} +1 -1
  130. package/dist/web-components/viewer/{Connected-CPIxNjF2.mjs → Connected-ESg5y49m.mjs} +1 -1
  131. package/dist/web-components/viewer/{Contents-DNh9mnsF.mjs → Contents-B_FqDwTW.mjs} +1 -1
  132. package/dist/web-components/viewer/{ControlMenu-DdgIvBdf.mjs → ControlMenu-DdQl-dTf.mjs} +1 -1
  133. package/dist/web-components/viewer/{Cue-90H9_dXz.mjs → Cue-BTRHfiWQ.mjs} +1 -1
  134. package/dist/web-components/viewer/Document-B9_PyD2w.mjs +1 -0
  135. package/dist/web-components/viewer/DocumentPanel-CtEJVPoE.mjs +1 -0
  136. package/dist/web-components/viewer/{DomLayers-Dybz_aJv.mjs → DomLayers-DRdQSEtN.mjs} +1 -1
  137. package/dist/web-components/viewer/{EntryBodies-DGXjFP3N.mjs → EntryBodies-CJuTRcTq.mjs} +1 -1
  138. package/dist/web-components/viewer/{FieldPill-Icmd98OY.mjs → FieldPill-06uwrNwE.mjs} +1 -1
  139. package/dist/web-components/viewer/{FrameAnimation-DJZN3Rd4.mjs → FrameAnimation-3dcDHf5q.mjs} +1 -1
  140. package/dist/web-components/viewer/{Gallery-CEp3-bh2.mjs → Gallery-BYasTqZc.mjs} +1 -1
  141. package/dist/web-components/viewer/{HideToggle-DB6HTmAO.mjs → HideToggle-BxkNMX-T.mjs} +1 -1
  142. package/dist/web-components/viewer/{LightboxBody-ClQ4yrTh.mjs → LightboxBody-CXMc1xOH.mjs} +1 -1
  143. package/dist/web-components/{MapView-BJaN7VBI.mjs → viewer/MapView-DCerrRRV.mjs} +1 -1
  144. package/dist/web-components/viewer/{MediaBody-BzMXMHIF.mjs → MediaBody-BdkJcyGy.mjs} +1 -1
  145. package/dist/web-components/viewer/{MediaBody-BBbSMT1i.mjs → MediaBody-waF4KvHp.mjs} +1 -1
  146. package/dist/web-components/viewer/{Navigator-Duc69Yes.mjs → Navigator-CKwDgG2x.mjs} +1 -1
  147. package/dist/web-components/viewer/{PartOfManifest-X9_q-2t6.mjs → PartOfManifest-DalHJFwC.mjs} +1 -1
  148. package/dist/web-components/viewer/{Search-S4N5QU4R.mjs → Search-Di_QQfDb.mjs} +1 -1
  149. package/dist/web-components/viewer/{StandaloneItems-BO4VyWRW.mjs → StandaloneItems-B9J6nnWn.mjs} +1 -1
  150. package/dist/web-components/viewer/{Transcript-BbDaS064.mjs → Transcript-aHOixfna.mjs} +1 -1
  151. package/dist/web-components/viewer/{annotation-collection-BjZ1DAHq.mjs → annotation-collection-I2UkdobR.mjs} +1 -1
  152. package/dist/web-components/viewer/{annotations-content-jn3n5Y2-.mjs → annotations-content-D-i4j9pD.mjs} +1 -1
  153. package/dist/web-components/viewer/{cloverEngine-CjuYjUhI.mjs → cloverEngine-CynoKdta.mjs} +1 -1
  154. package/dist/web-components/viewer/{content-state-reader-CPiShIjP.mjs → content-state-reader-D7GIMcKK.mjs} +1 -1
  155. package/dist/web-components/viewer/{host-yWi4R1bP.mjs → host-DlCltI_c.mjs} +1 -1
  156. package/dist/web-components/viewer/index.mjs +1 -1
  157. package/dist/web-components/viewer/{link-CwE-fg5G.mjs → link-BX-wzj1u.mjs} +1 -1
  158. package/dist/web-components/viewer/{overlayImage-BpOgqsZ0.mjs → overlayImage-CHqn1fG8.mjs} +1 -1
  159. package/dist/web-components/viewer/{renderers-L-IlGI1r.mjs → renderers-C_wdmw9v.mjs} +1 -1
  160. package/dist/web-components/viewer/{search-DWkwRPo_.mjs → search-BHLyNxZ6.mjs} +1 -1
  161. package/dist/web-components/viewer/{viewer--TreVlJ_.mjs → viewer-ipqAA-xQ.mjs} +5 -5
  162. package/dist/web-components/viewer/{vtt-1ZJwtElI.mjs → vtt-XiS_-5Ao.mjs} +1 -1
  163. package/dist/web-components/viewer-DEHIsIHd.mjs +1 -0
  164. package/dist/web-components/{vtt-GFssZH8Y.mjs → vtt-DYAOuQoK.mjs} +1 -1
  165. package/dist/web-components/worker-CjXN0dku.mjs +1 -0
  166. package/package.json +3 -2
  167. package/dist/web-components/About-uKa1wfDr.mjs +0 -1
  168. package/dist/web-components/Document-DHBRAFEK.mjs +0 -1
  169. package/dist/web-components/DocumentPanel-CqvE2pu9.mjs +0 -1
  170. package/dist/web-components/LightboxBody-DyhUZiDf.mjs +0 -1
  171. package/dist/web-components/LoadedMap-DIeW313M.mjs +0 -1
  172. package/dist/web-components/Scene-B_PU_TiX.mjs +0 -1
  173. package/dist/web-components/Timeline-WtYZ1bIJ.mjs +0 -1
  174. package/dist/web-components/items-W2vrwArM.mjs +0 -1
  175. package/dist/web-components/label-CYQ7tVl6.mjs +0 -1
  176. package/dist/web-components/logo-CnQUCB3Y.mjs +0 -1
  177. package/dist/web-components/part-CUBY90_b.mjs +0 -1
  178. package/dist/web-components/viewer/Document-CNCpzkiN.mjs +0 -1
  179. package/dist/web-components/viewer/DocumentPanel-BdG4TVLE.mjs +0 -1
  180. package/dist/web-components/viewer/MapView-BVSdybIC.mjs +0 -1
  181. package/dist/web-components/viewer-DyV864Qe.mjs +0 -1
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { version, source } from "./maplibre-worker.mjs";
3
+ let url;
4
+ let warned = false;
5
+ function bundledWorkerUrl(running) {
6
+ if (typeof URL.createObjectURL !== "function") return;
7
+ if (running && version !== running) {
8
+ if (!warned) {
9
+ warned = true;
10
+ console.warn(
11
+ `Clover: its map worker is MapLibre ${version}'s, and MapLibre ${running} is running; serve ${running}'s worker with setMapWorkerUrl.`
12
+ );
13
+ }
14
+ return;
15
+ }
16
+ return url ?? (url = URL.createObjectURL(
17
+ new Blob([source], { type: "text/javascript" })
18
+ ));
19
+ }
20
+ export {
21
+ bundledWorkerUrl
22
+ };
@@ -35,19 +35,24 @@ function About({
35
35
  if (!about || !image || typeof ResizeObserver === "undefined") return;
36
36
  const heading = about.querySelector(".clover-about-label");
37
37
  const write = () => {
38
- about.style.setProperty(
39
- "--clover-about-label-height",
40
- `${(heading == null ? void 0 : heading.offsetHeight) ?? 0}px`
41
- );
42
- about.style.setProperty(
43
- "--clover-about-thumbnail-width",
44
- `${image.offsetWidth}px`
45
- );
38
+ const height = `${(heading == null ? void 0 : heading.offsetHeight) ?? 0}px`;
39
+ const width = `${image.offsetWidth}px`;
40
+ const style = about.style;
41
+ if (style.getPropertyValue("--clover-about-label-height") !== height)
42
+ style.setProperty("--clover-about-label-height", height);
43
+ if (style.getPropertyValue("--clover-about-thumbnail-width") !== width)
44
+ style.setProperty("--clover-about-thumbnail-width", width);
46
45
  };
47
- const observer = new ResizeObserver(write);
46
+ write();
47
+ let frame = 0;
48
+ const observer = new ResizeObserver(() => {
49
+ cancelAnimationFrame(frame);
50
+ frame = requestAnimationFrame(write);
51
+ });
48
52
  observer.observe(image);
49
53
  if (heading) observer.observe(heading);
50
54
  return () => {
55
+ cancelAnimationFrame(frame);
51
56
  observer.disconnect();
52
57
  about.style.removeProperty("--clover-about-label-height");
53
58
  about.style.removeProperty("--clover-about-thumbnail-width");
@@ -126,9 +126,16 @@ const SplitHandle = forwardRef(
126
126
  const container = split == null ? void 0 : split.element.current;
127
127
  update();
128
128
  if (!container || typeof ResizeObserver === "undefined") return;
129
- const observer = new ResizeObserver(update);
129
+ let frame = 0;
130
+ const observer = new ResizeObserver(() => {
131
+ cancelAnimationFrame(frame);
132
+ frame = requestAnimationFrame(update);
133
+ });
130
134
  observer.observe(container);
131
- return () => observer.disconnect();
135
+ return () => {
136
+ cancelAnimationFrame(frame);
137
+ observer.disconnect();
138
+ };
132
139
  }, [update, split, split == null ? void 0 : split.sizes]);
133
140
  const percent = (px) => {
134
141
  var _a;
@@ -63,7 +63,9 @@ function itemsOfCollection(collection) {
63
63
  function itemsOf(resource) {
64
64
  if (!resource) return [];
65
65
  if (Array.isArray(resource)) {
66
- return itemsOfCollection({ items: resource });
66
+ return itemsOfCollection({
67
+ items: resource
68
+ });
67
69
  }
68
70
  return resource.type === "Collection" ? itemsOfCollection(resource) : itemsOfManifest(resource);
69
71
  }
@@ -84,7 +84,9 @@ async function firstManifest(collection, options, depth = 0) {
84
84
  }
85
85
  if (item.type === "Collection" && depth < 8) {
86
86
  const nested = await withMembers(
87
- await toPresentation4(await dereference(item, options)),
87
+ await toPresentation4(
88
+ await dereference(item, options)
89
+ ),
88
90
  options
89
91
  );
90
92
  const found = await firstManifest(nested, options, depth + 1);
@@ -96,7 +98,9 @@ async function firstManifest(collection, options, depth = 0) {
96
98
  async function fetchResource(input, { request, signal } = {}) {
97
99
  void preloadUpgrader();
98
100
  const json = typeof input === "string" ? await fetchJson(request, input.trim(), signal) : input;
99
- const resource = await toPresentation4(json);
101
+ const resource = await toPresentation4(
102
+ json
103
+ );
100
104
  return resource.type === "Collection" ? withMembers(resource, { request, signal }) : resource;
101
105
  }
102
106
  async function loadContent(input, options = {}) {
@@ -141,7 +145,10 @@ async function loadContent(input, options = {}) {
141
145
  case "Manifest":
142
146
  return { manifest: resource, target, annotation };
143
147
  case "Collection": {
144
- const collection = await withMembers(resource, options);
148
+ const collection = await withMembers(
149
+ resource,
150
+ options
151
+ );
145
152
  const pick = options.manifestId ?? member;
146
153
  const chosen = pick ? (collection.items ?? []).find(
147
154
  (item) => item.id === pick && item.type === "Manifest"
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Generated by dts-bundle-generator v8.0.1
2
2
 
3
- import { Canvas, Collection, Manifest, Scene, Timeline } from '@iiif/parser/presentation-4/types';
3
+ import * as P4 from '@iiif/parser/presentation-4/types';
4
4
  import { Annotation, IIIFExternalWebResource, InternationalString, MetadataItem } from '@iiif/presentation-3';
5
5
  import React from 'react';
6
6
  import { CSSProperties, ReactNode } from 'react';
@@ -65,16 +65,29 @@ export interface AnnotationBodyEntry {
65
65
  /** An image body's label, else its annotation's: the image's text alternative. */
66
66
  label?: LanguageMapLike;
67
67
  }
68
+ /**
69
+ * Clover's one data shape: IIIF Presentation 4.
70
+ *
71
+ * Every resource is upgraded to Presentation 4 on the way in, so no part is written for
72
+ * several shapes. Presentation 2.1 and 3.0 are upgraded by `@iiif/parser`; Presentation 4
73
+ * passes through untouched. The upgrader is imported on demand, so it costs nothing until
74
+ * the first resource that needs it arrives.
75
+ */
76
+ export type Manifest = P4.Manifest;
77
+ export type Presentation4Canvas = P4.Canvas;
78
+ export type Presentation4Collection = P4.Collection;
79
+ export type Presentation4Scene = P4.Scene;
80
+ export type Presentation4Timeline = P4.Timeline;
68
81
  /**
69
82
  * A IIIF resource Clover can show directly, a Manifest's item: a Canvas (`Canvas`), a
70
83
  * Timeline (`Timeline`, sound) or a Scene (`Scene`, 3D).
71
84
  */
72
- export type Container = Canvas | Timeline | Scene;
85
+ export type Container = Presentation4Canvas | Presentation4Timeline | Presentation4Scene;
73
86
  /**
74
87
  * `resource` as Presentation 4: a Manifest, Collection, Canvas, Timeline or Scene from any
75
88
  * supported version. Presentation 4 input is returned as it is.
76
89
  */
77
- export declare function toPresentation4<T = Manifest | Collection | Container>(resource: unknown): Promise<T>;
90
+ export declare function toPresentation4<T = Manifest | Presentation4Collection | Container>(resource: unknown): Promise<T>;
78
91
  /**
79
92
  * Annotations to read and to point at: everything a Manifest's Canvases carry in their
80
93
  * `annotations` (comments, tags, transcriptions, descriptions), and pages a host adds.
@@ -259,7 +272,7 @@ export interface CloverState {
259
272
  /** The Manifest shown, in Presentation 4. */
260
273
  manifest: Manifest | null;
261
274
  /** The Collection it was reached through, if any. */
262
- collection: Collection | null;
275
+ collection: Presentation4Collection | null;
263
276
  /** The Canvas the reader is on: the first of the view that shows it. */
264
277
  canvasId: string | null;
265
278
  /** Where to go once the view is drawn: a region, a time. Consumed once applied. */
@@ -1193,9 +1206,14 @@ export interface StatusProps {
1193
1206
  * (WCAG 4.1.3).
1194
1207
  */
1195
1208
  export declare function Status({ className, loading, error: renderError, }: StatusProps): React.JSX.Element;
1209
+ /**
1210
+ * A IIIF resource as JSON, read loosely. One declaration for the modules whose `Json`
1211
+ * reaches Clover's types: the bundled declarations (`build:types`) would hold one per
1212
+ * module, under the one name, which TypeScript rejects.
1213
+ */
1214
+ export type Json = Record<string, any>;
1196
1215
  /** Whose property a part reads: the Root's Manifest, or the Canvas in view. */
1197
1216
  export type Of = "manifest" | "canvas";
1198
- export type Json = Record<string, any>;
1199
1217
  /** The provider a part is drawn for, inside `Provider`; null outside one. */
1200
1218
  export declare const useProvider: () => Json | null;
1201
1219
  export interface PartProps<Value> extends Omit<React.HTMLAttributes<HTMLElement>, "lang"> {
@@ -1954,12 +1972,6 @@ export declare function useClover(part?: string): CloverContextValue;
1954
1972
  * return the same object for the same state (the core's are memoized), or pass `isEqual`.
1955
1973
  */
1956
1974
  export declare function useCloverSelector<Value>(selector: (state: CloverState) => Value, isEqual?: (a: Value, b: Value) => boolean, part?: string): Value;
1957
- /**
1958
- * Reading a content state: what a Root handed one (JSON or base64url, not a URL) loads
1959
- * and where it goes. Its own chunk, loaded only for a content state (`loadContent`): a
1960
- * page that opens a URL never carries it. Writing one stays in `content-state.ts`.
1961
- */
1962
- export type Json = Record<string, any>;
1963
1975
  /** A content state string (JSON, or base64url-encoded JSON) as JSON; null if neither. */
1964
1976
  export declare function decodeContentState(value: string): Json | null;
1965
1977
  /**
@@ -2038,7 +2050,6 @@ export declare function toPlainText(html: string): string;
2038
2050
  * aside; anything else is plain text.
2039
2051
  */
2040
2052
  export declare function readAs(format: string | undefined, value?: string): "markdown" | "html" | "plain";
2041
- export type Json = Record<string, any>;
2042
2053
  /**
2043
2054
  * A small picture of a region of a Canvas (an annotation's `xywh`, in the Canvas's own
2044
2055
  * coordinates), to be cut by the image server (`resolveThumbnail`): the image painted
@@ -1,7 +1,18 @@
1
1
  // Generated by dts-bundle-generator v8.0.1
2
2
 
3
+ import * as P4 from '@iiif/parser/presentation-4/types';
3
4
  import React from 'react';
4
5
 
6
+ /**
7
+ * Clover's one data shape: IIIF Presentation 4.
8
+ *
9
+ * Every resource is upgraded to Presentation 4 on the way in, so no part is written for
10
+ * several shapes. Presentation 2.1 and 3.0 are upgraded by `@iiif/parser`; Presentation 4
11
+ * passes through untouched. The upgrader is imported on demand, so it costs nothing until
12
+ * the first resource that needs it arrives.
13
+ */
14
+ export type Manifest = P4.Manifest;
15
+ export type Presentation4Collection = P4.Collection;
5
16
  /**
6
17
  * IIIF language maps as text: the closest language to the reader's, and that language's
7
18
  * tag, so the text can carry a `lang` attribute.
@@ -13,7 +24,7 @@ export type LanguageMapLike = string | Record<string, string[] | string | undefi
13
24
  * Only a look, never a read: the panel asks it to offer a Map tab, and the reading
14
25
  * (`core/geo.ts`) belongs to the map entry, so an app without a map carries none of it.
15
26
  */
16
- export declare function hasMapData(manifest: Manifest | null, collection?: Collection | null): boolean;
27
+ export declare function hasMapData(manifest: Manifest | null, collection?: Presentation4Collection | null): boolean;
17
28
  /**
18
29
  * Where a IIIF resource is, read for a map: navPlace (on a Collection, Manifest, Canvas
19
30
  * or Annotation, and annotation bodies that are GeoJSON), and Georeference Extension
@@ -78,7 +89,7 @@ export type Json = Record<string, any>;
78
89
  * 0139 has). A feature from a Canvas or annotation names that Canvas. Memoized on the
79
90
  * Manifest (and the Collection), so the same collection comes back while nothing changes.
80
91
  */
81
- export declare function navPlaceOf(manifest: Manifest | null, collection?: Collection | null, language?: string): MapFeatureCollection;
92
+ export declare function navPlaceOf(manifest: Manifest | null, collection?: Presentation4Collection | null, language?: string): MapFeatureCollection;
82
93
  /**
83
94
  * One Georeference Extension annotation as an overlay: its control points, the extent
84
95
  * they are measured in, its mask, and the image to draw (the Canvas's painted image, or
@@ -156,8 +167,8 @@ export interface MapProps extends Omit<React.HTMLAttributes<HTMLElement>, "onSel
156
167
  /** A MapLibre style URL, used as it is. Default: Clover's relief basemap (OpenFreeMap). */
157
168
  styleUrl?: string;
158
169
  /**
159
- * Where MapLibre's worker is served from, if your bundler moves MapLibre's files (see
160
- * the Map docs). By default MapLibre finds its own.
170
+ * Where MapLibre's worker is served from, to serve your own (see the Map docs). By
171
+ * default Clover brings it, from a `blob:` URL.
161
172
  */
162
173
  workerUrl?: string;
163
174
  /** Zoom with the wheel or trackpad. Default false, so an embedded map never traps page scroll. */
@@ -1,13 +1,16 @@
1
1
  // Generated by dts-bundle-generator v8.0.1
2
2
 
3
- import { Canvas, Scene, Timeline } from '@iiif/parser/presentation-4/types';
3
+ import * as P4 from '@iiif/parser/presentation-4/types';
4
4
  import React from 'react';
5
5
 
6
+ export type Presentation4Canvas = P4.Canvas;
7
+ export type Presentation4Scene = P4.Scene;
8
+ export type Presentation4Timeline = P4.Timeline;
6
9
  /**
7
10
  * A IIIF resource Clover can show directly, a Manifest's item: a Canvas (`Canvas`), a
8
11
  * Timeline (`Timeline`, sound) or a Scene (`Scene`, 3D).
9
12
  */
10
- export type Container = Canvas | Timeline | Scene;
13
+ export type Container = Presentation4Canvas | Presentation4Timeline | Presentation4Scene;
11
14
  /**
12
15
  * How Clover asks for things: one setting for every request it makes — the IIIF resource,
13
16
  * referenced annotation pages, `info.json`, tiles, captions and HLS segments.
@@ -1 +1 @@
1
- @layer clover{.clover-template-lightbox{width:min(96vw,72rem);max-height:94vh;padding:0;border:0;border-radius:var(--clover-radius, 3px);background:var(--clover-color-secondary, #fff);color:var(--clover-color-primary, #1a1d1e);box-shadow:0 8px 40px #00000059}.clover-template-lightbox::backdrop{background:#0009}.clover-template-lightbox-content{display:flex;flex-direction:column;gap:var(--clover-space-m);padding:var(--clover-inset);--clover-body-height: min(70vh, 48rem)}.clover-template-lightbox-pending{height:var(--clover-body-height, 60vh);background-color:#0001}.clover-template-lightbox-header{display:flex;align-items:center;gap:var(--clover-space-m)}.clover-template-lightbox-title{flex:1 1 auto;min-width:0;margin:0;font-size:var(--clover-text-l);font-weight:700}button.clover-template-lightbox-close{display:inline-flex;align-items:center;justify-content:center;width:var(--clover-control);height:var(--clover-control);padding:0;border:0;border-radius:var(--clover-radius-pill, 2rem);background:var(--clover-color-secondary-muted, #f1f1f1);color:inherit;cursor:pointer}button.clover-template-lightbox-close:is(:hover,:focus-visible){background:var(--clover-color-accent, #0065c3);color:var(--clover-color-control-glyph, #fff)}.clover-template-document{--clover-template-document-height: min(85vh, 56rem);display:flex;flex-direction:column;height:var(--clover-template-document-height);overflow:hidden;background-color:var(--clover-color-secondary, #fff);color:var(--clover-color-primary, #1a1d1e)}.clover-template-document-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--clover-space-s);padding:var(--clover-space-m) var(--clover-inset);border-bottom:1px solid var(--clover-color-secondary-muted, #e6e8eb)}.clover-template-document-provider{max-width:100%;margin-inline-start:auto}.clover-template-document-toolbar .clover-download-groups{flex-direction:row;flex-wrap:wrap;column-gap:var(--clover-space-m)}.clover-template-document-toolbar .clover-download-group{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:var(--clover-space-s)}.clover-template-document-toolbar .clover-download-title{margin:0}.clover-template-document-toolbar .clover-download-list{display:flex;flex-wrap:wrap;column-gap:var(--clover-space-s)}.clover-template-document-title{flex:1 1 6rem;min-width:0;margin:0;font-size:var(--clover-text-l);line-height:1.25;font-weight:400;overflow-wrap:anywhere}button.clover-template-document-sidebar-toggle{display:inline-flex;flex:none;align-items:center;gap:var(--clover-space-xs);min-height:var(--clover-control);padding-block:0;padding-inline:var(--clover-space-s) calc(var(--clover-space-xs) + var(--clover-space-3xs));border:0;border-radius:var(--clover-radius-pill, 2rem);background-color:var(--clover-color-control, #1a1d1e);color:var(--clover-color-control-glyph, #fff);cursor:pointer;transition:var(--clover-transition, all .2s cubic-bezier(.16, 1, .3, 1))}button.clover-template-document-sidebar-toggle:is(:hover,:focus-visible){background-color:var(--clover-color-accent, #0065c3)}button.clover-template-document-sidebar-toggle:focus-visible{outline:2px solid var(--clover-color-accent, #0065c3);outline-offset:2px}.clover-template-document-sidebar-toggle .clover-template-document-position{color:inherit;font-size:var(--clover-text-xs)}.clover-template-document-sidebar-toggle .clover-template-document-position>.clover-pager-room[hidden]{display:none}.clover-template-document-panes{position:relative;flex:1 1 auto;min-height:0}.clover-template-document-sidebar{overflow-y:auto;overscroll-behavior:contain;padding:var(--clover-inset);scroll-padding-top:calc(2 * var(--clover-inset) + var(--clover-control));background-color:var(--clover-color-secondary, #fff)}.clover-template-document-sidebar-closed{position:absolute;top:var(--clover-inset);inset-inline-start:var(--clover-inset);z-index:3}.clover-template-document-sidebar[hidden]{display:none}.clover-template-document-sidebar+.clover-split-handle:before{inset-inline-start:0;inset-inline-end:calc(3px - var(--clover-space-l))}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-figure{grid-template-columns:repeat(var(--parts, 1),minmax(0,1fr));gap:var(--clover-space-xs) 0}.clover-template-document-sidebar .clover-items[data-layout] :is(.clover-items-pictures,.clover-items-caption){grid-column:1 / -1;grid-template-columns:subgrid}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-label{contain:inline-size}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-picture[data-empty],.clover-template-document-sidebar .clover-items[data-layout] .clover-items-picture img{width:100%;height:auto;max-height:20rem;aspect-ratio:var(--clover-items-ratio, auto);object-fit:contain}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-caption{font-size:var(--clover-text-s)}.clover-template-document-main{position:relative;overflow:hidden;background-color:var(--clover-color-secondary-muted, #e6e8eb)}.clover-template-document-column{position:absolute;inset:0;overflow-x:hidden;overflow-y:auto;container-type:size}.clover-template-document-sheets{position:relative}.clover-template-document-sheet{--clover-template-document-tease: calc(2 * var(--clover-inset));display:flex;justify-content:center;box-sizing:border-box;height:min(100cqh - var(--clover-template-document-tease),(100cqw - 2 * var(--clover-inset)) / var(--ratio) + 2 * var(--clover-inset));padding:var(--clover-inset);transition:opacity .2s ease,height .24s cubic-bezier(.16,1,.3,1)}.clover-template-document-column[data-zoomed] .clover-template-document-sheet[data-active]{height:100cqh}.clover-template-document-column[data-zoomed] .clover-template-document-sheet[data-active]>*{visibility:hidden}.clover-template-document-column[data-zoomed] .clover-template-document-sheet:not([data-active]){--clover-template-document-muted: 0;pointer-events:none}.clover-template-document-sheet:not([data-active]){--clover-template-document-muted: .618;cursor:pointer;opacity:var(--clover-template-document-muted)}.clover-template-document-sheet:not([data-active]):hover{--clover-template-document-muted: .809}@media (prefers-reduced-motion: reduce){.clover-template-document-sheet{transition:none}}.clover-template-document-sheets[data-single]>.clover-template-document-sheet{--clover-template-document-tease: 0px}.clover-template-document-sheet>*{display:block;height:100%;min-width:0}.clover-template-document-live{--clover-body-height: 100%;position:absolute;inset-inline:0;top:0;height:100%;transition:opacity .16s ease}.clover-template-document-body .clover-canvas{--clover-canvas-inset: var(--clover-inset);background-color:transparent}.clover-template-document-live[data-moved]:not(:focus-within){opacity:0;pointer-events:none}.clover-template-document-column[data-scrolling] .clover-template-document-live:not(:focus-within) .clover-canvas-controls>*{--clover-controls-shown: 0;--clover-controls-events: none}.clover-template-document-column:not([data-zoomed]) .clover-canvas-viewport{touch-action:pan-y}.clover-template-document-panel{contain:size;overflow-y:auto;overscroll-behavior:contain;background-color:var(--clover-color-secondary, #fff)}.clover-template-document-panel[hidden]{display:none}.clover-template-document-scrim[data-for=sidebar]{z-index:2}.clover-template-document{--clover-grip: color-mix( in srgb, var(--clover-color-primary-muted, #26292b) 30%, transparent )}.clover-template-document-panes[data-narrow]{--clover-template-sidebar-width: min(14rem, 80%)}.clover-template-document-panes[data-narrow]>.clover-template-document-sidebar{position:absolute;inset-block:0;inset-inline-start:0;z-index:3;width:var(--clover-template-sidebar-width);border-inline-end:1px solid var(--clover-color-secondary-muted, #e6e8eb);background:linear-gradient(var(--clover-grip),var(--clover-grip)) no-repeat right var(--clover-space-2xs) center / 4px var(--clover-space-xl),var(--clover-color-secondary, #fff);touch-action:pan-y;box-shadow:var(--clover-space-s) 0 var(--clover-space-l) #0000001f}.clover-template-document-spine{position:relative;z-index:4;flex:none;width:0}.clover-template-document-spine>*{position:absolute;top:var(--clover-inset);inset-inline-start:-1.5px;translate:-50%}.clover-template-document-spine:dir(rtl)>*{translate:50%}.clover-template-document-spine[data-for=sidebar]>*{inset-inline:auto calc(1.5px - var(--clover-control) / 2);translate:none}.clover-template-document-panes[data-narrow]>.clover-template-document-spine[data-for=sidebar]{inset-inline-start:var(--clover-template-sidebar-width)}.clover-template-document-panes[data-narrow]>.clover-template-document-spine[data-for=sidebar]>*{inset-inline-end:calc(var(--clover-control) / -2)}.clover-template-gallery{display:flex;flex-direction:column;gap:var(--clover-space-m);color:var(--clover-color-primary, #1a1d1e)}.clover-template-gallery-header{display:flex;flex-direction:column;gap:var(--clover-space-2xs)}.clover-template-gallery-title{margin:0;font-size:var(--clover-text-l);line-height:1.25;font-weight:700}.clover-template-gallery-summary{margin:0}}
1
+ @layer clover{.clover-template-lightbox{width:min(96vw,72rem);max-height:94vh;padding:0;border:0;border-radius:var(--clover-radius, 3px);background:var(--clover-color-secondary, #fff);color:var(--clover-color-primary, #1a1d1e);box-shadow:0 8px 40px #00000059}.clover-template-lightbox::backdrop{background:#0009}.clover-template-lightbox-content{display:flex;flex-direction:column;gap:var(--clover-space-m);padding:var(--clover-inset);--clover-body-height: min(70vh, 48rem)}.clover-template-lightbox-pending{height:var(--clover-body-height, 60vh);background-color:#0001}.clover-template-lightbox-header{display:flex;align-items:center;gap:var(--clover-space-m)}.clover-template-lightbox-title{flex:1 1 auto;min-width:0;margin:0;font-size:var(--clover-text-l);font-weight:700}button.clover-template-lightbox-close{display:inline-flex;align-items:center;justify-content:center;width:var(--clover-control);height:var(--clover-control);padding:0;border:0;border-radius:var(--clover-radius-pill, 2rem);background:var(--clover-color-secondary-muted, #f1f1f1);color:inherit;cursor:pointer}button.clover-template-lightbox-close:is(:hover,:focus-visible){background:var(--clover-color-accent, #0065c3);color:var(--clover-color-control-glyph, #fff)}.clover-template-document{--clover-template-document-height: min(85vh, 56rem);display:flex;flex-direction:column;height:var(--clover-template-document-height);overflow:hidden;background-color:var(--clover-color-secondary, #fff);color:var(--clover-color-primary, #1a1d1e)}.clover-template-document-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--clover-space-s);padding:var(--clover-space-m) var(--clover-inset);border-bottom:1px solid var(--clover-color-secondary-muted, #e6e8eb)}.clover-template-document-provider{max-width:100%;margin-inline-start:auto}.clover-template-document-toolbar .clover-download-groups{flex-direction:row;flex-wrap:wrap;column-gap:var(--clover-space-m)}.clover-template-document-toolbar .clover-download-group{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:var(--clover-space-s)}.clover-template-document-toolbar .clover-download-title{margin:0}.clover-template-document-toolbar .clover-download-list{display:flex;flex-wrap:wrap;column-gap:var(--clover-space-s)}.clover-template-document-title{flex:1 1 6rem;min-width:0;margin:0;font-size:var(--clover-text-l);line-height:1.25;font-weight:400;overflow-wrap:anywhere}button.clover-template-document-sidebar-toggle{display:inline-flex;flex:none;align-items:center;gap:var(--clover-space-xs);min-height:var(--clover-control);padding-block:0;padding-inline:var(--clover-space-s) calc(var(--clover-space-xs) + var(--clover-space-3xs));border:0;border-radius:var(--clover-radius-pill, 2rem);background-color:var(--clover-color-control, #1a1d1e);color:var(--clover-color-control-glyph, #fff);cursor:pointer;transition:var(--clover-transition, all .2s cubic-bezier(.16, 1, .3, 1))}button.clover-template-document-sidebar-toggle:is(:hover,:focus-visible){background-color:var(--clover-color-accent, #0065c3)}button.clover-template-document-sidebar-toggle:focus-visible{outline:2px solid var(--clover-color-accent, #0065c3);outline-offset:2px}.clover-template-document-sidebar-toggle .clover-template-document-position{color:inherit;font-size:var(--clover-text-xs);white-space:nowrap}.clover-template-document-sidebar-toggle .clover-template-document-position>.clover-pager-room[hidden]{display:none}.clover-template-document-panes{position:relative;flex:1 1 auto;min-height:0}.clover-template-document-sidebar{overflow-y:auto;overscroll-behavior:contain;padding:var(--clover-inset);scroll-padding-top:calc(2 * var(--clover-inset) + var(--clover-control));background-color:var(--clover-color-secondary, #fff)}.clover-template-document-sidebar-closed{position:absolute;top:var(--clover-inset);inset-inline-start:var(--clover-inset);z-index:3}.clover-template-document-sidebar[hidden]{display:none}.clover-template-document-sidebar+.clover-split-handle:before{inset-inline-start:0;inset-inline-end:calc(3px - var(--clover-space-l))}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-figure{grid-template-columns:repeat(var(--parts, 1),minmax(0,1fr));gap:var(--clover-space-xs) 0}.clover-template-document-sidebar .clover-items[data-layout] :is(.clover-items-pictures,.clover-items-caption){grid-column:1 / -1;grid-template-columns:subgrid}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-label{contain:inline-size}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-picture[data-empty],.clover-template-document-sidebar .clover-items[data-layout] .clover-items-picture img{width:100%;height:auto;max-height:20rem;aspect-ratio:var(--clover-items-ratio, auto);object-fit:contain}.clover-template-document-sidebar .clover-items[data-layout] .clover-items-caption{font-size:var(--clover-text-s)}.clover-template-document-main{position:relative;overflow:hidden;background-color:var(--clover-color-secondary-muted, #e6e8eb)}.clover-template-document-column{position:absolute;inset:0;overflow-x:hidden;overflow-y:auto;container-type:size}.clover-template-document-sheets{position:relative}.clover-template-document-sheet{--clover-template-document-tease: calc(2 * var(--clover-inset));display:flex;justify-content:center;box-sizing:border-box;height:min(100cqh - var(--clover-template-document-tease),(100cqw - 2 * var(--clover-inset)) / var(--ratio) + 2 * var(--clover-inset));padding:var(--clover-inset);transition:opacity .2s ease,height .24s cubic-bezier(.16,1,.3,1)}.clover-template-document-column[data-zoomed] .clover-template-document-sheet[data-active]{height:100cqh}.clover-template-document-column[data-zoomed] .clover-template-document-sheet[data-active]>*{visibility:hidden}.clover-template-document-column[data-zoomed] .clover-template-document-sheet:not([data-active]){--clover-template-document-muted: 0;pointer-events:none}.clover-template-document-sheet:not([data-active]){--clover-template-document-muted: .618;cursor:pointer;opacity:var(--clover-template-document-muted)}.clover-template-document-sheet:not([data-active]):hover{--clover-template-document-muted: .809}@media (prefers-reduced-motion: reduce){.clover-template-document-sheet{transition:none}}.clover-template-document-sheets[data-single]>.clover-template-document-sheet{--clover-template-document-tease: 0px}.clover-template-document-sheet>*{display:block;height:100%;min-width:0}.clover-template-document-live{--clover-body-height: 100%;position:absolute;inset-inline:0;top:0;height:100%;transition:opacity .16s ease}.clover-template-document-body .clover-canvas{--clover-canvas-inset: var(--clover-inset);background-color:transparent}.clover-template-document-live[data-moved]:not(:focus-within){opacity:0;pointer-events:none}.clover-template-document-column[data-scrolling] .clover-template-document-live:not(:focus-within) .clover-canvas-controls>*{--clover-controls-shown: 0;--clover-controls-events: none}.clover-template-document-column:not([data-zoomed]) .clover-canvas-viewport{touch-action:pan-y}.clover-template-document-panel{contain:size;overflow-y:auto;overscroll-behavior:contain;background-color:var(--clover-color-secondary, #fff)}.clover-template-document-panel[hidden]{display:none}.clover-template-document-scrim[data-for=sidebar]{z-index:2}.clover-template-document{--clover-grip: color-mix( in srgb, var(--clover-color-primary-muted, #26292b) 30%, transparent )}.clover-template-document-panes[data-narrow]{--clover-template-sidebar-width: min(14rem, 80%)}.clover-template-document-panes[data-narrow]>.clover-template-document-sidebar{position:absolute;inset-block:0;inset-inline-start:0;z-index:3;width:var(--clover-template-sidebar-width);border-inline-end:1px solid var(--clover-color-secondary-muted, #e6e8eb);background:linear-gradient(var(--clover-grip),var(--clover-grip)) no-repeat right var(--clover-space-2xs) center / 4px var(--clover-space-xl),var(--clover-color-secondary, #fff);touch-action:pan-y;box-shadow:var(--clover-space-s) 0 var(--clover-space-l) #0000001f}.clover-template-document-spine{position:relative;z-index:4;flex:none;width:0}.clover-template-document-spine>*{position:absolute;top:var(--clover-inset);inset-inline-start:-1.5px;translate:-50%}.clover-template-document-spine:dir(rtl)>*{translate:50%}.clover-template-document-spine[data-for=sidebar]>*{inset-inline:auto calc(1.5px - var(--clover-control) / 2);translate:none}.clover-template-document-panes[data-narrow]>.clover-template-document-spine[data-for=sidebar]{inset-inline-start:var(--clover-template-sidebar-width)}.clover-template-document-panes[data-narrow]>.clover-template-document-spine[data-for=sidebar]>*{inset-inline-end:calc(var(--clover-control) / -2)}.clover-template-gallery{display:flex;flex-direction:column;gap:var(--clover-space-m);color:var(--clover-color-primary, #1a1d1e)}.clover-template-gallery-header{display:flex;flex-direction:column;gap:var(--clover-space-2xs)}.clover-template-gallery-title{margin:0;font-size:var(--clover-text-l);line-height:1.25;font-weight:700}.clover-template-gallery-summary{margin:0}}
@@ -54,7 +54,7 @@ function useReadMore(ref) {
54
54
  cancelAnimationFrame(frame);
55
55
  frame = requestAnimationFrame(measure);
56
56
  };
57
- const resized = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
57
+ const resized = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(again);
58
58
  resized == null ? void 0 : resized.observe(node);
59
59
  const styled = typeof MutationObserver === "undefined" ? null : new MutationObserver(again);
60
60
  styled == null ? void 0 : styled.observe(document.head, {
@@ -0,0 +1 @@
1
+ import{a as x,i as z,A as C,y as T,b as $,u as t,X as g,P as j,z as F}from"./shared-YUjOSBKO.mjs";import{j as H}from"./classnames-DukgfdpI.mjs";import{Thumbnail as I,Summary as y,Metadata as M,RequiredStatement as D,Rights as V,Homepage as B,SeeAlso as G,Id as L}from"./Primitives-XQO3m1wG.mjs";import{useDownloads as U,DownloadGroups as W}from"./Download-DqU-goFi.mjs";import{P as X}from"./Provider-B61118lU.mjs";import{a as E,t as J}from"./heading-Cjt0f-Eu.mjs";import{L as Q}from"./Label-D6aVJB9s.mjs";import"./styles-CyuM_fB1.mjs";const Y=F(()=>import("./PartOfManifest-7eOwURrF.mjs"));function re({canvasSummary:A=false,headingLevel:i=3,download:P=true,thumbnail:d=true,label:u=true,className:w,...N}){const{t:S,langOf:O}=x(),m=U(),o=z(e=>e.manifest,Object.is,"About"),v=C(null);T(()=>{const e=v.current,l=e==null?void 0:e.querySelector(".clover-about-thumbnail");if(!e||!l||typeof ResizeObserver>"u")return;const a=e.querySelector(".clover-about-label"),r=()=>{const h=`${(a==null?void 0:a.offsetHeight)??0}px`,p=`${l.offsetWidth}px`,b=e.style;b.getPropertyValue("--clover-about-label-height")!==h&&b.setProperty("--clover-about-label-height",h),b.getPropertyValue("--clover-about-thumbnail-width")!==p&&b.setProperty("--clover-about-thumbnail-width",p)};r();let n=0;const c=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(r)});return c.observe(l),a&&c.observe(a),()=>{cancelAnimationFrame(n),c.disconnect(),e.style.removeProperty("--clover-about-label-height"),e.style.removeProperty("--clover-about-thumbnail-width")}},[u,d,o]);const q=$(),R=()=>{var a,r;const e=v.current;(r=((a=e==null?void 0:e.closest(".clover-sections-item"))==null?void 0:a.querySelector(".clover-sections-button"))??e)==null||r.focus({preventScroll:true})};if(!o)return null;const s=(e,l,a)=>{if(!l)return null;const{as:r,title:n,group:c}=J(i,`${q}-${e}`);return t("section",{className:"clover-about-section",...c,children:[t(r,{className:"clover-about-heading",lang:O(e),...n,children:S(e)}),a]})},f=e=>Array.isArray(o[e])?o[e].length>0:!!o[e];return t("div",{ref:v,className:H("clover-about",w),tabIndex:-1,...N,children:[(d||u)&&t("div",{className:"clover-about-head",children:[d&&t(I,{className:"clover-about-thumbnail",size:256,alt:u?"":void 0}),u&&t(Q,{as:E(i),className:"clover-about-label"})]}),A&&t(y,{of:"canvas",className:"clover-about-summary"}),g(o)&&o.partOf&&t(j,{fallback:null,children:t(Y,{manifest:o,headingLevel:i,onOpened:R})}),t(y,{className:"clover-about-summary"}),t(M,{className:"clover-about-metadata"}),t(D,{className:"clover-about-metadata"}),s("aboutProvider",f("provider"),t(X,{})),s("aboutRights",o.rights,t(V,{})),s("aboutHomepage",f("homepage"),t(B,{})),s("aboutSeeAlso",f("seeAlso"),t(G,{})),s("download",P&&m.page.length+m.all.length>0,t(W,{page:m.page,all:m.all,headingLevel:i+1})),s(g(o)?"aboutCanvas":"aboutManifest",o.id,t(L,{}))]})}export{re as About};
@@ -1 +1 @@
1
- import{u as n,an as x}from"./shared-J3w3gnXD.mjs";import{s as I}from"./Annotations-BhwAv3ah.mjs";import{C as E}from"./ControlMenu-DIoU797-.mjs";import{C as H}from"./Cue-CJxnDMEy.mjs";import{H as T}from"./HideToggle-BdYgG7us.mjs";import{u as $}from"./useContainerName-DCbE5JXi.mjs";import"./styles-Ypl9KrSK.mjs";const j=({id:m,triggerId:f,label:N,labelLang:b,annotations:d,hiddenPages:C=[],onPageVisibilityChange:u,selected:y,onSelect:v,onActivate:i,onClose:M})=>{const g=$(N,b),r=[];d.forEach((e,c)=>{var o,l;const s=r[r.length-1];s&&((o=s.page)==null?void 0:o.text)===((l=e.page)==null?void 0:l.text)?s.items.push(c):r.push({page:e.page,items:[c]})});const k=r.some(e=>!e.page);return n(E,{className:"clover-canvas-annotation-menu","data-testid":"clover-canvas-annotation-menu",id:m,onClose:M,triggerId:f,children:[k&&g.node,r.map((e,c)=>{const s=[...new Set(e.items.flatMap(t=>d[t].pageId??[]))],o=`${m}-page-${c}`,l=u&&s.length>0&&n(T,{hidden:s.every(t=>C.includes(t)),onChange:t=>u(s,!t),of:e.page?o:void 0});return x("fieldset",{...e.page?{"aria-labelledby":o}:g.props,className:"clover-canvas-menu-group clover-annotations-set",key:c},e.page?n("legend",{className:"clover-canvas-menu-legend clover-annotations-set-header",children:[n("span",{className:"clover-annotations-title",id:o,lang:e.page.lang,children:e.page.text}),l]}):l&&n("div",{className:"clover-annotations-set-header",children:l}),n("div",{className:"clover-annotations-list",children:e.items.map(t=>{const a=d[t],h=I(a),p=y===a.id;return n("label",{className:"clover-canvas-menu-item clover-annotations-entry","data-selected":p,onMouseEnter:()=>i(a.id),onMouseLeave:()=>i(null),children:[n("input",{type:"radio",name:m,checked:p,onChange:()=>v(a),onClick:()=>p&&v(a),onFocus:()=>i(a.id),onBlur:()=>i(null)}),h!==void 0&&n(H,{start:h,className:"clover-annotations-time"}),n("span",{className:"clover-annotations-body clover-cue-text",lang:a.label?a.lang:void 0,children:a.label??String(t+1)})]},a.id)})}))})]})};export{j as default};
1
+ import{u as n,an as x}from"./shared-YUjOSBKO.mjs";import{s as I}from"./Annotations-Dl0SgHBS.mjs";import{C as E}from"./ControlMenu-CAHiLAtl.mjs";import{C as H}from"./Cue-BT2V9VAq.mjs";import{H as T}from"./HideToggle-BwMrOBMu.mjs";import{u as $}from"./useContainerName-BpJ3IWY0.mjs";import"./styles-CyuM_fB1.mjs";const j=({id:m,triggerId:f,label:N,labelLang:b,annotations:d,hiddenPages:C=[],onPageVisibilityChange:u,selected:y,onSelect:v,onActivate:i,onClose:M})=>{const g=$(N,b),r=[];d.forEach((e,c)=>{var o,l;const s=r[r.length-1];s&&((o=s.page)==null?void 0:o.text)===((l=e.page)==null?void 0:l.text)?s.items.push(c):r.push({page:e.page,items:[c]})});const k=r.some(e=>!e.page);return n(E,{className:"clover-canvas-annotation-menu","data-testid":"clover-canvas-annotation-menu",id:m,onClose:M,triggerId:f,children:[k&&g.node,r.map((e,c)=>{const s=[...new Set(e.items.flatMap(t=>d[t].pageId??[]))],o=`${m}-page-${c}`,l=u&&s.length>0&&n(T,{hidden:s.every(t=>C.includes(t)),onChange:t=>u(s,!t),of:e.page?o:void 0});return x("fieldset",{...e.page?{"aria-labelledby":o}:g.props,className:"clover-canvas-menu-group clover-annotations-set",key:c},e.page?n("legend",{className:"clover-canvas-menu-legend clover-annotations-set-header",children:[n("span",{className:"clover-annotations-title",id:o,lang:e.page.lang,children:e.page.text}),l]}):l&&n("div",{className:"clover-annotations-set-header",children:l}),n("div",{className:"clover-annotations-list",children:e.items.map(t=>{const a=d[t],h=I(a),p=y===a.id;return n("label",{className:"clover-canvas-menu-item clover-annotations-entry","data-selected":p,onMouseEnter:()=>i(a.id),onMouseLeave:()=>i(null),children:[n("input",{type:"radio",name:m,checked:p,onChange:()=>v(a),onClick:()=>p&&v(a),onFocus:()=>i(a.id),onBlur:()=>i(null)}),h!==void 0&&n(H,{start:h,className:"clover-annotations-time"}),n("span",{className:"clover-annotations-body clover-cue-text",lang:a.label?a.lang:void 0,children:a.label??String(t+1)})]},a.id)})}))})]})};export{j as default};
@@ -1 +1 @@
1
- import{T as l,n as Ot,c as Wt,d as C,ak as bt,q as k,A as i,y as j,_ as Tt,u as Gt}from"./shared-J3w3gnXD.mjs";import{w as Rt,p as kt,g as At,t as jt,A as zt}from"./Annotations-BhwAv3ah.mjs";import{g as Dt}from"./layout-KL0V-iJu.mjs";import{p as Jt}from"./time-B9GZoYcm.mjs";const Ut=()=>import("./svg-shape-DLY3g7oq.mjs");function Xt(w){var S;const c=l(()=>!!(w!=null&&w.some(({annotation:o})=>{var p;return(p=Ot(o==null?void 0:o.target))==null?void 0:p.svg})),[w]);return((S=Wt(Ut,c))==null?void 0:S.readSvgShape)??null}const It=[];function Mt({given:w,annotations:c,scene:S,renderer:o,sceneVersion:p,drawn:M,media:A,mediaElement:g,showPlaceholder:F,canvasKey:z,openImages:E,openMedia:tt,host:et,onModel:H}){const{canvases:d,language:v,hiddenPages:nt,unlistedPages:xt,onPageVisibilityChange:rt,onAnnotationActive:ct,selectedAnnotation:ut,animateAnnotations:st=false,highlightedAnnotation:qt,onAnnotationSelect:ot,onAnnotationLink:D}=w,[_,yt]=C([]),[it,Ct]=C([]),B=nt!==void 0,J=l(()=>{var n;if(B)return It;const t=new Map;for(const r of c){if(!r.pageId)continue;const f=!(Number((n=d==null?void 0:d[r.targetIndex])==null?void 0:n.duration)>0)&&bt(r.annotation.motivation,Ot(Array.isArray(r.annotation.target)?r.annotation.target[0]:r.annotation.target));t.set(r.pageId,(t.get(r.pageId)??true)&&f)}const e=[...t].filter(([,r])=>r).map(([r])=>r);return e.length?e:It},[B,c,d]),Ft=l(()=>{const t=J.filter(e=>!it.includes(e)&&!_.includes(e));return t.length?[..._,...t]:_},[_,it,J]),a=nt??Ft,U=xt??J,L=k(t=>U.length?t.filter(e=>!e.pageId||!U.includes(e.pageId)):t,[U]),lt=l(()=>L(c).length,[c,L]),T=k(t=>a.length?t.filter(e=>!e.pageId||!a.includes(e.pageId)):t,[a]),N=i(rt);N.current=rt;const Q=k((t,e)=>{var n;(n=N.current)==null||n.call(N,t,e),!B&&(yt(r=>{const s=r.filter(f=>!t.includes(f));return e?s:[...s,...t]}),Ct(r=>{const s=r.filter(f=>!t.includes(f));return e?[...s,...t]:s}))},[B]),dt=l(()=>Rt(T(c),d),[c,T,d]),I=l(()=>{if(!(!S||!d))return(t,e,n)=>{const r=d.findIndex(Qt=>Qt.id===e),s=r===-1?n:r,f=S.placements[s];return f?Dt(d[s],f,t):null}},[S,d]),W=Xt(c),P=l(()=>o&&p>0&&M?kt(c,I??((t,e,n)=>o.itemRectToWorld(n,t)),W,v):[],[o,c,p,M,I,W,v]),O=l(()=>T(P),[P,T]),X=l(()=>P.length||!I?P:kt(c,I,W,v),[P,I,c,W,v]),[Ht,_t]=C(null),[Bt,gt]=C(null),u=ut!==void 0?ut:Bt,x=i(null),m=i(ct);m.current=ct;const h=i(ot);h.current=ot;const Y=k(t=>{var e;_t(t),(e=m.current)==null||e.call(m,t)},[]),Z=i(st);Z.current=st;const ft=i(false);ft.current=F;const $=i(g);$.current=g;const pt=i(o);pt.current=o;const q=i(null),at=i(a);at.current=a;const Pt=i(Q);Pt.current=Q;const V=k(t=>{var e,n,r;if(t.pageId&&at.current.includes(t.pageId)&&Pt.current([t.pageId],true),gt(t.id),(e=m.current)==null||e.call(m,t.id),(n=h.current)==null||n.call(h,t.id),!ft.current){if("start"in t){const s=$.current;if(!s)return;q.current=t.id,Jt(s,t.start);return}if(x.current=t.id,t.track){const s=$.current;s&&At(t,s)&&(q.current=t.id);return}(r=pt.current)==null||r.fitAnnotation(t.world,!Z.current)}},[]),mt=i(u);mt.current=u;const b=k(()=>{var t;return mt.current?(gt(null),x.current=null,(t=h.current)==null||t.call(h,null),true):false},[]),G=i(D);G.current=D;const ht=!!D,Lt=l(()=>ht?t=>{var e,n;(e=et.current)==null||e.focus({preventScroll:true}),b(),t.link&&((n=G.current)==null||n.call(G,t.link))}:void 0,[ht,b,et]);j(()=>{if(!u){x.current=null;return}if(x.current===u)return;const t=r=>r.find(s=>s.id===u),e=t(O),n=e??t(P);if(n){if(x.current=n.id,n.track){!e&&g&&At(n,g);return}o==null||o.fitAnnotation(n.world,!Z.current)}},[u,O,P,g,o]);const y=l(()=>A?jt(c,v):[],[A,c,v]),R=l(()=>T(y),[y,T]),wt=l(()=>L(y.length?[...X,...y]:X),[X,y,L]);j(()=>{if(!u){q.current=null;return}if(q.current===u||!g)return;const t=R.find(e=>e.id===u);t&&(q.current=t.id,g.currentTime=t.start)},[u,R,g]);const K=i(null),[St,Nt]=C(null);j(()=>{K.current=u??null},[u]),j(()=>{const t=K.current;if(!(!t||!c.some(e=>{var n;return((n=e.annotation)==null?void 0:n.id)===t}))&&(K.current=null,!!F)){if(!A){E(true);return}tt(z),Nt(z)}},[u,c,F,A,z,E,tt]);const vt=l(()=>({menu:wt,placed:O,timed:R,hiddenPages:a,setPagesVisible:Q,listedCount:lt,comments:dt,selected:u??null,select:V,activate:Y,release:b,quietlyOpened:St}),[wt,O,R,a,Q,lt,dt,u,V,Y,b,St]);return Tt(()=>H(vt),[vt,H]),Tt(()=>()=>H(null),[H]),o&&p>0&&!F?Gt(zt,{renderer:o,placed:O,sceneVersion:p,active:Ht??qt??u,selected:u,onActivate:Y,onSelect:V,onFollow:Lt,media:A?g:void 0}):null}export{Mt as AnnotationState};
1
+ import{T as l,n as Ot,c as Wt,d as C,ak as bt,q as k,A as i,y as j,_ as Tt,u as Gt}from"./shared-YUjOSBKO.mjs";import{w as Rt,p as kt,g as At,t as jt,A as zt}from"./Annotations-Dl0SgHBS.mjs";import{g as Dt}from"./layout-mMHI0lsj.mjs";import{p as Jt}from"./time-B9GZoYcm.mjs";const Ut=()=>import("./svg-shape-DLY3g7oq.mjs");function Xt(w){var S;const c=l(()=>!!(w!=null&&w.some(({annotation:o})=>{var p;return(p=Ot(o==null?void 0:o.target))==null?void 0:p.svg})),[w]);return((S=Wt(Ut,c))==null?void 0:S.readSvgShape)??null}const It=[];function Mt({given:w,annotations:c,scene:S,renderer:o,sceneVersion:p,drawn:M,media:A,mediaElement:g,showPlaceholder:F,canvasKey:z,openImages:E,openMedia:tt,host:et,onModel:H}){const{canvases:d,language:v,hiddenPages:nt,unlistedPages:xt,onPageVisibilityChange:rt,onAnnotationActive:ct,selectedAnnotation:ut,animateAnnotations:st=false,highlightedAnnotation:qt,onAnnotationSelect:ot,onAnnotationLink:D}=w,[_,yt]=C([]),[it,Ct]=C([]),B=nt!==void 0,J=l(()=>{var n;if(B)return It;const t=new Map;for(const r of c){if(!r.pageId)continue;const f=!(Number((n=d==null?void 0:d[r.targetIndex])==null?void 0:n.duration)>0)&&bt(r.annotation.motivation,Ot(Array.isArray(r.annotation.target)?r.annotation.target[0]:r.annotation.target));t.set(r.pageId,(t.get(r.pageId)??true)&&f)}const e=[...t].filter(([,r])=>r).map(([r])=>r);return e.length?e:It},[B,c,d]),Ft=l(()=>{const t=J.filter(e=>!it.includes(e)&&!_.includes(e));return t.length?[..._,...t]:_},[_,it,J]),a=nt??Ft,U=xt??J,L=k(t=>U.length?t.filter(e=>!e.pageId||!U.includes(e.pageId)):t,[U]),lt=l(()=>L(c).length,[c,L]),T=k(t=>a.length?t.filter(e=>!e.pageId||!a.includes(e.pageId)):t,[a]),N=i(rt);N.current=rt;const Q=k((t,e)=>{var n;(n=N.current)==null||n.call(N,t,e),!B&&(yt(r=>{const s=r.filter(f=>!t.includes(f));return e?s:[...s,...t]}),Ct(r=>{const s=r.filter(f=>!t.includes(f));return e?[...s,...t]:s}))},[B]),dt=l(()=>Rt(T(c),d),[c,T,d]),I=l(()=>{if(!(!S||!d))return(t,e,n)=>{const r=d.findIndex(Qt=>Qt.id===e),s=r===-1?n:r,f=S.placements[s];return f?Dt(d[s],f,t):null}},[S,d]),W=Xt(c),P=l(()=>o&&p>0&&M?kt(c,I??((t,e,n)=>o.itemRectToWorld(n,t)),W,v):[],[o,c,p,M,I,W,v]),O=l(()=>T(P),[P,T]),X=l(()=>P.length||!I?P:kt(c,I,W,v),[P,I,c,W,v]),[Ht,_t]=C(null),[Bt,gt]=C(null),u=ut!==void 0?ut:Bt,x=i(null),m=i(ct);m.current=ct;const h=i(ot);h.current=ot;const Y=k(t=>{var e;_t(t),(e=m.current)==null||e.call(m,t)},[]),Z=i(st);Z.current=st;const ft=i(false);ft.current=F;const $=i(g);$.current=g;const pt=i(o);pt.current=o;const q=i(null),at=i(a);at.current=a;const Pt=i(Q);Pt.current=Q;const V=k(t=>{var e,n,r;if(t.pageId&&at.current.includes(t.pageId)&&Pt.current([t.pageId],true),gt(t.id),(e=m.current)==null||e.call(m,t.id),(n=h.current)==null||n.call(h,t.id),!ft.current){if("start"in t){const s=$.current;if(!s)return;q.current=t.id,Jt(s,t.start);return}if(x.current=t.id,t.track){const s=$.current;s&&At(t,s)&&(q.current=t.id);return}(r=pt.current)==null||r.fitAnnotation(t.world,!Z.current)}},[]),mt=i(u);mt.current=u;const b=k(()=>{var t;return mt.current?(gt(null),x.current=null,(t=h.current)==null||t.call(h,null),true):false},[]),G=i(D);G.current=D;const ht=!!D,Lt=l(()=>ht?t=>{var e,n;(e=et.current)==null||e.focus({preventScroll:true}),b(),t.link&&((n=G.current)==null||n.call(G,t.link))}:void 0,[ht,b,et]);j(()=>{if(!u){x.current=null;return}if(x.current===u)return;const t=r=>r.find(s=>s.id===u),e=t(O),n=e??t(P);if(n){if(x.current=n.id,n.track){!e&&g&&At(n,g);return}o==null||o.fitAnnotation(n.world,!Z.current)}},[u,O,P,g,o]);const y=l(()=>A?jt(c,v):[],[A,c,v]),R=l(()=>T(y),[y,T]),wt=l(()=>L(y.length?[...X,...y]:X),[X,y,L]);j(()=>{if(!u){q.current=null;return}if(q.current===u||!g)return;const t=R.find(e=>e.id===u);t&&(q.current=t.id,g.currentTime=t.start)},[u,R,g]);const K=i(null),[St,Nt]=C(null);j(()=>{K.current=u??null},[u]),j(()=>{const t=K.current;if(!(!t||!c.some(e=>{var n;return((n=e.annotation)==null?void 0:n.id)===t}))&&(K.current=null,!!F)){if(!A){E(true);return}tt(z),Nt(z)}},[u,c,F,A,z,E,tt]);const vt=l(()=>({menu:wt,placed:O,timed:R,hiddenPages:a,setPagesVisible:Q,listedCount:lt,comments:dt,selected:u??null,select:V,activate:Y,release:b,quietlyOpened:St}),[wt,O,R,a,Q,lt,dt,u,V,Y,b,St]);return Tt(()=>H(vt),[vt,H]),Tt(()=>()=>H(null),[H]),o&&p>0&&!F?Gt(zt,{renderer:o,placed:O,sceneVersion:p,active:Ht??qt??u,selected:u,onActivate:Y,onSelect:V,onFollow:Lt,media:A?g:void 0}):null}export{Mt as AnnotationState};
@@ -1,2 +1,2 @@
1
- import{j as z,m as Nt,n as Ct,o as O,D as lt,a as D,g as G,i as E,s as kt,r as yt,t as Lt,R as ct,y as F,u as c,w as Mt,B as rt,b as Y,E as dt,T as $,d as U,A as At,F as $t,v as ut,k as J,G as Tt,H as Ot}from"./shared-J3w3gnXD.mjs";import{E as qt}from"./EntryBodies-VwEkTVrw.mjs";import{a as Bt,r as Et}from"./link-DRRTY4lY.mjs";import{s as Ht}from"./show-link-DWRRXSBy.mjs";import{f as Vt}from"./imageService-C3yg9DxB.mjs";import{resolveThumbnail as jt}from"./thumbnail-BZvLSwWW.mjs";import{j as ft}from"./classnames-DukgfdpI.mjs";import{p as Ft}from"./time-B9GZoYcm.mjs";import{b as at,s as Pt}from"./bringIntoView-CQH5ZgMM.mjs";import{a as Q}from"./heading-Cjt0f-Eu.mjs";import{C as Rt}from"./Cue-CJxnDMEy.mjs";import{H as ht}from"./HideToggle-BdYgG7us.mjs";import{l as zt}from"./languageCode-cCpiU0b0.mjs";import{T as Dt}from"./Tip-C8J3qsIK.mjs";import{u as Gt}from"./useContainerName-DCbE5JXi.mjs";import"./styles-Ypl9KrSK.mjs";function Ut(t,e){for(const n of z(t==null?void 0:t.items))for(const o of z(n==null?void 0:n.items))if(Nt(o))for(const i of z(o==null?void 0:o.body)){if((i==null?void 0:i.type)!=="Image"||!i.width||!i.height)continue;const r=Vt(i.service);if(!r)continue;const l=Ct(z(o.target)[0]).rect??{x:0,y:0,w:t.width,h:t.height},a=(e.x-l.x)/l.w,u=(e.y-l.y)/l.h,h=Math.max(0,a),d=Math.max(0,u),v=Math.min(1,a+e.w/l.w)-h,x=Math.min(1,u+e.h/l.h)-d;if(v>0&&x>0)return{service:r,region:{x:h,y:d,width:v,height:x}}}return null}function mt(t){const e=t.bodies.filter(n=>{var o;return!n.image&&((o=n.value)==null?void 0:o.trim())}).map(n=>n.language).filter(n=>!!n&&n!=="none");return[...new Set(e)]}function gt(t){const e=t.map(mt),n=[...new Set(e.flat())];return n.length<2?[]:e.some(i=>i.length&&n.some(r=>!i.includes(r)))?n:[]}function vt(t,e,n){if(n&&t.includes(n))return n;if(!t.length)return;const o=Object.fromEntries(t.map(i=>[i,[i]]));return O(o,e).lang??t[0]}function pt(t,e){if(!e)return true;const n=mt(t);return!n.length||n.includes(e)}function Wt(t){try{return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}catch{return t}}const xn=lt(function({scope:e="all",renderEntry:n,headingLevel:o=3,as:i="div",className:r,...l},a){const{t:u,langOf:h}=D(),{clover:d,language:v}=G("Annotations"),x=E(s=>kt(s.manifest,s.addedSets)),k=E(s=>yt(s.manifest,s.canvasId)),M=E(s=>Lt(s.manifest,s.addedSets,s.hiddenSets,s.shownSets)),p=E(s=>s.annotationId),S=ct.useSyncExternalStore(d.highlight.subscribe,d.highlight.get,d.highlight.get),b=s=>{const N=Mt(x,s),w=N&&rt(N.target.t),q=d.media.get();w&&q&&k.some(H=>H.id===N.canvasId)&&Ft(q,w.start),d.selectAnnotation(s)};F(()=>{if(e==="all")return d.holdAllAnnotationPages()},[d,e]);const I=s=>s.entries.filter(N=>k.some(w=>w.id===N.canvasId)),y=x.map(s=>({set:s,entries:I(s)})).filter(({entries:s})=>s.length),C=Q(o),L={text:u("annotationsShow"),lang:h("annotationsShow")};return e==="all"?c(Xt,{ref:a,as:i,className:r,rest:l,sets:x,shown:k.map(s=>s.id),headingLevel:o,language:v,showLabel:L,hiddenSets:M,selected:p,highlighted:S,renderEntry:n,onSelect:b,onHighlight:s=>d.highlight.emit(s),onVisible:(s,N)=>s.forEach(w=>d.setSetVisible(w,N))}):y.length?c(i,{ref:a,className:ft("clover-annotations",r),...l,children:y.map(({set:s,entries:N})=>c(_t,{set:s,entries:N,canvases:k,Heading:C,headingLevel:o,language:v,title:O(s.label,v),showLabel:L,hidden:M.includes(s.id),selected:p,highlighted:S,renderEntry:n,onSelect:b,onHighlight:w=>d.highlight.emit(w),onVisible:w=>d.setSetVisible(s.id,w)},s.id))}):null});function _t({set:t,entries:e,canvases:n,Heading:o,headingLevel:i,title:r,language:l,showLabel:a,hidden:u,selected:h,highlighted:d,renderEntry:v,onSelect:x,onHighlight:k,onVisible:M}){const p=Y(),S=r.text?i+1:i,b=$(()=>gt(e),[e]),[I,y]=U(),C=vt(b,l,I),L=e.filter(s=>pt(s,C));return c("section",{className:"clover-annotations-set","aria-labelledby":r.text?`${p}-title`:void 0,"data-set":t.id,children:[c("div",{className:"clover-annotations-set-header",children:[r.text&&c(o,{className:"clover-annotations-title",id:`${p}-title`,lang:r.lang,children:r.text}),C&&c(bt,{languages:b,chosen:C,onChange:y}),c(ht,{hidden:u,onChange:s=>M(!s),of:r.text?`${p}-title`:void 0})]}),c("ol",{className:"clover-annotations-list",children:L.map((s,N)=>c(xt,{entry:s,canvas:n.find(w=>w.id===s.canvasId),index:N,headingLevel:S,language:l,showLabel:a,selected:s.id===h,highlighted:s.id===d,renderEntry:v,onSelect:x,onHighlight:k},s.id))})]})}function Kt(t,e,n){const o=new Map(e.map((r,l)=>[r.id,l])),i=new Map;for(const r of t){const l=O(r.label,n),a=l.text;let u=i.get(a);u||(u={title:l,setIds:[],byCanvas:new Map},i.set(a,u)),u.setIds.push(r.id);for(const h of r.entries){const d=u.byCanvas.get(h.canvasId)??[];d.push(h),u.byCanvas.set(h.canvasId,d)}}return[...i.entries()].map(([r,l])=>({key:r,title:l.title,setIds:l.setIds,canvases:Zt([...l.byCanvas.entries()],o).map(([a,u])=>{var h;return{canvasId:a,label:O((h=e.find(d=>d.id===a))==null?void 0:h.label,n),entries:u}})}))}function Zt(t,e){return t.every(([n])=>e.has(n))?t.sort(([n],[o])=>e.get(n)-e.get(o)):t}const it=new WeakMap;function Jt(t,e){let n=it.get(t);n||it.set(t,n=new Map);let o=n.get(e);return o||(o=Ot({id:e,type:"Manifest"},{request:t.request}).catch(()=>null),n.set(e,o)),o}function Qt(t,e){const{clover:n,language:o}=G("Annotations"),i=$(()=>{const a=new Set;for(const u of t)for(const h of u.canvases){if(e.has(h.canvasId))continue;const d=$t(h.entries[0].annotation);d&&a.add(d)}return[...a]},[t,e]),[r,l]=U([]);return F(()=>{let a=true;return Promise.all(i.map(u=>Jt(n,u))).then(u=>a&&l(u.filter(h=>!!h))),()=>{a=false}},[n,i]),$(()=>{const a=new Map;for(const u of r){const{canvases:h}=dt(u),d=O(u.label,o);for(const v of h){const x=O(v.label,o);a.set(v.id,{canvas:v,label:h.length>1&&x.text?[d,x]:[d]})}}return{named:i.length>0,of:a}},[r,i,o])}const Xt=lt(function({as:e,className:n,rest:o,sets:i,shown:r,headingLevel:l,language:a,showLabel:u,hiddenSets:h,selected:d,highlighted:v,renderEntry:x,onSelect:k,onHighlight:M,onVisible:p},S){const b=Y(),I=E(f=>dt(f.manifest).canvases),y=$(()=>Kt(i,I,a),[i,I,a]),C=$(()=>new Map(I.map(f=>[f.id,f])),[I]),L=Qt(y,C),[s,N]=U({}),w=E(f=>{var m;return(m=f.manifest)==null?void 0:m.label}),q=$(()=>O(w,a),[w,a]),H=I.length>1||L.named,P=At(null),tt=()=>{const f=P.current;if(!f||!f.getClientRects().length)return true;const m=Pt(f)??f;return m.matches(":hover")||m.contains(document.activeElement)},wt=r.join(`
1
+ import{j as z,m as Nt,n as Ct,o as O,D as lt,a as D,g as G,i as E,s as kt,r as yt,t as Lt,R as ct,y as F,u as c,w as Mt,B as rt,b as Y,E as dt,T as $,d as U,A as At,F as $t,v as ut,k as J,G as Tt,H as Ot}from"./shared-YUjOSBKO.mjs";import{E as qt}from"./EntryBodies-DXAQH0vR.mjs";import{a as Bt,r as Et}from"./link-ZRnv5NFR.mjs";import{s as Ht}from"./show-link-CyzYE1eS.mjs";import{f as Vt}from"./imageService-dsdmcegU.mjs";import{resolveThumbnail as jt}from"./thumbnail-c2K_iQsD.mjs";import{j as ft}from"./classnames-DukgfdpI.mjs";import{p as Ft}from"./time-B9GZoYcm.mjs";import{b as at,s as Pt}from"./bringIntoView-CQH5ZgMM.mjs";import{a as Q}from"./heading-Cjt0f-Eu.mjs";import{C as Rt}from"./Cue-BT2V9VAq.mjs";import{H as ht}from"./HideToggle-BwMrOBMu.mjs";import{l as zt}from"./languageCode-cCpiU0b0.mjs";import{T as Dt}from"./Tip-IO11xX4x.mjs";import{u as Gt}from"./useContainerName-BpJ3IWY0.mjs";import"./styles-CyuM_fB1.mjs";function Ut(t,e){for(const n of z(t==null?void 0:t.items))for(const o of z(n==null?void 0:n.items))if(Nt(o))for(const i of z(o==null?void 0:o.body)){if((i==null?void 0:i.type)!=="Image"||!i.width||!i.height)continue;const r=Vt(i.service);if(!r)continue;const l=Ct(z(o.target)[0]).rect??{x:0,y:0,w:t.width,h:t.height},a=(e.x-l.x)/l.w,u=(e.y-l.y)/l.h,h=Math.max(0,a),d=Math.max(0,u),v=Math.min(1,a+e.w/l.w)-h,x=Math.min(1,u+e.h/l.h)-d;if(v>0&&x>0)return{service:r,region:{x:h,y:d,width:v,height:x}}}return null}function mt(t){const e=t.bodies.filter(n=>{var o;return!n.image&&((o=n.value)==null?void 0:o.trim())}).map(n=>n.language).filter(n=>!!n&&n!=="none");return[...new Set(e)]}function gt(t){const e=t.map(mt),n=[...new Set(e.flat())];return n.length<2?[]:e.some(i=>i.length&&n.some(r=>!i.includes(r)))?n:[]}function vt(t,e,n){if(n&&t.includes(n))return n;if(!t.length)return;const o=Object.fromEntries(t.map(i=>[i,[i]]));return O(o,e).lang??t[0]}function pt(t,e){if(!e)return true;const n=mt(t);return!n.length||n.includes(e)}function Wt(t){try{return new Intl.DisplayNames([t],{type:"language"}).of(t)??t}catch{return t}}const xn=lt(function({scope:e="all",renderEntry:n,headingLevel:o=3,as:i="div",className:r,...l},a){const{t:u,langOf:h}=D(),{clover:d,language:v}=G("Annotations"),x=E(s=>kt(s.manifest,s.addedSets)),k=E(s=>yt(s.manifest,s.canvasId)),M=E(s=>Lt(s.manifest,s.addedSets,s.hiddenSets,s.shownSets)),p=E(s=>s.annotationId),S=ct.useSyncExternalStore(d.highlight.subscribe,d.highlight.get,d.highlight.get),b=s=>{const N=Mt(x,s),w=N&&rt(N.target.t),q=d.media.get();w&&q&&k.some(H=>H.id===N.canvasId)&&Ft(q,w.start),d.selectAnnotation(s)};F(()=>{if(e==="all")return d.holdAllAnnotationPages()},[d,e]);const I=s=>s.entries.filter(N=>k.some(w=>w.id===N.canvasId)),y=x.map(s=>({set:s,entries:I(s)})).filter(({entries:s})=>s.length),C=Q(o),L={text:u("annotationsShow"),lang:h("annotationsShow")};return e==="all"?c(Xt,{ref:a,as:i,className:r,rest:l,sets:x,shown:k.map(s=>s.id),headingLevel:o,language:v,showLabel:L,hiddenSets:M,selected:p,highlighted:S,renderEntry:n,onSelect:b,onHighlight:s=>d.highlight.emit(s),onVisible:(s,N)=>s.forEach(w=>d.setSetVisible(w,N))}):y.length?c(i,{ref:a,className:ft("clover-annotations",r),...l,children:y.map(({set:s,entries:N})=>c(_t,{set:s,entries:N,canvases:k,Heading:C,headingLevel:o,language:v,title:O(s.label,v),showLabel:L,hidden:M.includes(s.id),selected:p,highlighted:S,renderEntry:n,onSelect:b,onHighlight:w=>d.highlight.emit(w),onVisible:w=>d.setSetVisible(s.id,w)},s.id))}):null});function _t({set:t,entries:e,canvases:n,Heading:o,headingLevel:i,title:r,language:l,showLabel:a,hidden:u,selected:h,highlighted:d,renderEntry:v,onSelect:x,onHighlight:k,onVisible:M}){const p=Y(),S=r.text?i+1:i,b=$(()=>gt(e),[e]),[I,y]=U(),C=vt(b,l,I),L=e.filter(s=>pt(s,C));return c("section",{className:"clover-annotations-set","aria-labelledby":r.text?`${p}-title`:void 0,"data-set":t.id,children:[c("div",{className:"clover-annotations-set-header",children:[r.text&&c(o,{className:"clover-annotations-title",id:`${p}-title`,lang:r.lang,children:r.text}),C&&c(bt,{languages:b,chosen:C,onChange:y}),c(ht,{hidden:u,onChange:s=>M(!s),of:r.text?`${p}-title`:void 0})]}),c("ol",{className:"clover-annotations-list",children:L.map((s,N)=>c(xt,{entry:s,canvas:n.find(w=>w.id===s.canvasId),index:N,headingLevel:S,language:l,showLabel:a,selected:s.id===h,highlighted:s.id===d,renderEntry:v,onSelect:x,onHighlight:k},s.id))})]})}function Kt(t,e,n){const o=new Map(e.map((r,l)=>[r.id,l])),i=new Map;for(const r of t){const l=O(r.label,n),a=l.text;let u=i.get(a);u||(u={title:l,setIds:[],byCanvas:new Map},i.set(a,u)),u.setIds.push(r.id);for(const h of r.entries){const d=u.byCanvas.get(h.canvasId)??[];d.push(h),u.byCanvas.set(h.canvasId,d)}}return[...i.entries()].map(([r,l])=>({key:r,title:l.title,setIds:l.setIds,canvases:Zt([...l.byCanvas.entries()],o).map(([a,u])=>{var h;return{canvasId:a,label:O((h=e.find(d=>d.id===a))==null?void 0:h.label,n),entries:u}})}))}function Zt(t,e){return t.every(([n])=>e.has(n))?t.sort(([n],[o])=>e.get(n)-e.get(o)):t}const it=new WeakMap;function Jt(t,e){let n=it.get(t);n||it.set(t,n=new Map);let o=n.get(e);return o||(o=Ot({id:e,type:"Manifest"},{request:t.request}).catch(()=>null),n.set(e,o)),o}function Qt(t,e){const{clover:n,language:o}=G("Annotations"),i=$(()=>{const a=new Set;for(const u of t)for(const h of u.canvases){if(e.has(h.canvasId))continue;const d=$t(h.entries[0].annotation);d&&a.add(d)}return[...a]},[t,e]),[r,l]=U([]);return F(()=>{let a=true;return Promise.all(i.map(u=>Jt(n,u))).then(u=>a&&l(u.filter(h=>!!h))),()=>{a=false}},[n,i]),$(()=>{const a=new Map;for(const u of r){const{canvases:h}=dt(u),d=O(u.label,o);for(const v of h){const x=O(v.label,o);a.set(v.id,{canvas:v,label:h.length>1&&x.text?[d,x]:[d]})}}return{named:i.length>0,of:a}},[r,i,o])}const Xt=lt(function({as:e,className:n,rest:o,sets:i,shown:r,headingLevel:l,language:a,showLabel:u,hiddenSets:h,selected:d,highlighted:v,renderEntry:x,onSelect:k,onHighlight:M,onVisible:p},S){const b=Y(),I=E(f=>dt(f.manifest).canvases),y=$(()=>Kt(i,I,a),[i,I,a]),C=$(()=>new Map(I.map(f=>[f.id,f])),[I]),L=Qt(y,C),[s,N]=U({}),w=E(f=>{var m;return(m=f.manifest)==null?void 0:m.label}),q=$(()=>O(w,a),[w,a]),H=I.length>1||L.named,P=At(null),tt=()=>{const f=P.current;if(!f||!f.getClientRects().length)return true;const m=Pt(f)??f;return m.matches(":hover")||m.contains(document.activeElement)},wt=r.join(`
2
2
  `);return F(()=>{const f=P.current;if(!f||!H||tt())return;const m=r.map(W=>f.querySelector(`[data-canvas="${CSS.escape(W)}"]`)).find(Boolean);if(!m)return;const T=m.closest(".clover-annotations-set"),V=(T==null?void 0:T.querySelector("[data-canvas]"))===m;at(V&&T?T:m,"start")},[wt]),F(()=>{const f=P.current;if(!f||!d||tt())return;const m=f.querySelector(`[data-entry="${CSS.escape(d)}"]`);m&&at(m,"nearest")},[d]),y.length?c(e,{ref:f=>{P.current=f,typeof S=="function"?S(f):S&&(S.current=f)},className:ft("clover-annotations",n),"data-scope":"all",...o,children:y.map((f,m)=>{const T=Q(l),V=f.title.text?l+1:l,W=Q(V),St=f.setIds.every(g=>h.includes(g)),nt=gt(f.canvases.flatMap(g=>g.entries)),_=vt(nt,a,s[f.key]);return c("section",{className:"clover-annotations-set","aria-labelledby":f.title.text?`${b}-${m}`:void 0,children:[c("div",{className:"clover-annotations-set-header",children:[f.title.text&&c(T,{className:"clover-annotations-title",id:`${b}-${m}`,lang:f.title.lang,children:f.title.text}),_&&c(bt,{languages:nt,chosen:_,onChange:g=>N(K=>({...K,[f.key]:g}))}),c(ht,{hidden:St,onChange:g=>p(f.setIds,!g),of:f.title.text?`${b}-${m}`:void 0})]}),f.canvases.map((g,K)=>{var ot;const et=g.entries.filter(A=>pt(A,_));if(!et.length)return null;const j=L.of.get(g.canvasId),B=j?j.label:L.named&&q.text?I.length>1&&g.label.text?[q,g.label]:[q]:[g.label],Z=H&&!!((ot=B[0])!=null&&ot.text),It=H&&r.includes(g.canvasId),st=`${b}-${m}-${K}`;return c("section",{className:"clover-annotations-canvas","data-canvas":g.canvasId,"aria-labelledby":Z?st:void 0,"aria-current":It?"true":void 0,children:[Z&&c(W,{className:"clover-annotations-canvas-label",id:st,lang:B.length===1?B[0].lang:void 0,children:B.length===1?B[0].text:B.map((A,R)=>c(ct.Fragment,{children:[R>0&&", ",c("span",{lang:A.lang,children:A.text})]},R))}),c("ol",{className:"clover-annotations-list",children:et.map((A,R)=>c(xt,{entry:A,canvas:C.get(g.canvasId)??(j==null?void 0:j.canvas),index:R,headingLevel:Z?V+1:V,language:a,showLabel:u,selected:A.id===d,highlighted:A.id===v,renderEntry:x,onSelect:k,onHighlight:M},A.id))})]},g.canvasId)})]},f.key)})}):null});function bt({languages:t,chosen:e,onChange:n}){const{t:o,langOf:i}=D(),r=Y(),l=Gt(o("annotationsLanguage"),i("annotationsLanguage"));return c(J,{children:[l.node,c("fieldset",{...l.props,className:"clover-annotations-languages",children:t.map(a=>{const u=Wt(a);return c("label",{className:"clover-annotations-language",children:[c("input",{type:"radio",name:`${r}-language`,checked:a===e,onChange:()=>n(a)}),c("span",{className:"clover-annotations-language-code",children:zt(a)})," ",c("span",{style:ut,lang:a,children:u}),c(Dt,{label:u,lang:a})]},a)})})]})}const X=52;function Yt(t,e){const{clover:n}=G("Annotations"),o=$(()=>{const l=t.target.rect;return!l||!e||t.bodies.some(a=>a.image)?null:Ut(e,l)},[t,e]),[i,r]=U();return F(()=>{if(r(void 0),!o)return;let l=true;return jt(o,X,n.request).then(a=>l&&r(a)),()=>{l=false}},[o,n]),i}function xt({entry:t,canvas:e,index:n,headingLevel:o,language:i,showLabel:r,selected:l,highlighted:a,renderEntry:u,onSelect:h,onHighlight:d}){const{hostLanguage:v,t:x,langOf:k}=D(),M=nn(t,i),p=M.text?M:{text:String(n+1)},S=rt(t.target.t),b=S?{text:x("annotationsShowTime"),lang:k("annotationsShowTime")}:r,I=!b.lang&&!Tt(p.lang,v),y=p.text?`${b.text}: ${p.text}`:b.text,C=Yt(t,e);return c("li",{className:"clover-annotations-entry","data-entry":t.id,"data-selected":l,"data-highlighted":a,onMouseEnter:()=>d(t.id),onMouseLeave:()=>d(null),onFocus:()=>d(t.id),onBlur:()=>d(null),onClick:L=>{L.target.closest("a, button")||h(t.id)},children:[S&&c(Rt,{start:S.start,className:"clover-annotations-time"}),C&&c("img",{className:"clover-annotations-thumbnail",src:C,alt:"",width:X/2,height:X/2,loading:"lazy",decoding:"async"}),c("div",{className:"clover-annotations-body clover-cue-text",children:[u?u(t):c(qt,{bodies:t.bodies,language:i,headingLevel:o}),c(tn,{annotation:t.annotation})]}),c("button",{type:"button",className:"clover-annotations-show","aria-pressed":l,"aria-label":I?y:void 0,style:ut,onClick:()=>h(t.id),children:!I&&c(J,{children:[c("span",{lang:b.lang,children:[b.text,p.text&&":"]}),p.text&&c(J,{children:[" ",c("span",{lang:p.lang,children:p.text})]})]})})]})}function tn({annotation:t}){const{clover:e}=G("Annotations"),{t:n,langOf:o}=D(),i=$(()=>Et(t),[t]);if(!i)return null;const r=n("annotationsOpenLink"),l=o("annotationsOpenLink");return!i.canvasId&&!i.manifestId?c("a",{className:"clover-annotations-link",href:i.id,target:"_blank",rel:"noopener noreferrer",lang:l,children:r}):c("button",{type:"button",className:"clover-annotations-link",lang:l,onClick:a=>{var h;const u=a.currentTarget.closest(".clover-root");Ht(e,i)&&((h=u==null?void 0:u.querySelector(".clover-canvas-viewport"))==null||h.focus({preventScroll:true}))},children:r})}function nn(t,e){const{text:n="",lang:o}=Bt(t.bodies,e);return{text:n.slice(0,120),...o?{lang:o}:{}}}export{xn as Annotations};
@@ -1 +1 @@
1
- var Y=Object.defineProperty;var J=(t,o,e)=>o in t?Y(t,o,{enumerable:true,configurable:true,writable:true,value:e}):t[o]=e;var L=(t,o,e)=>J(t,typeof o!="symbol"?o+"":o,e);import{n as N,al as Q,a3 as _,B as D,T as tt,A as F,y as j,q as S,_ as ot,$ as et,u as C,k as nt,am as st,o as it,d as W,R as rt}from"./shared-J3w3gnXD.mjs";import{r as at,a as ct}from"./link-DRRTY4lY.mjs";import{T as lt}from"./Tip-C8J3qsIK.mjs";import{b as ht}from"./Camera-Dw51CAfF.mjs";import"./styles-Ypl9KrSK.mjs";const K=t=>Array.isArray(t)?t.flatMap(K):Q.includes(t==null?void 0:t.type)?K(t.items??[]):t==null?[]:[t],ut=t=>K(t).map(o=>N(o)),dt=(t,o)=>Math.abs(t.end-o.start)<.001,B=(t,o,e)=>t+(o-t)*e;function pt(t){const o=[...t].sort((e,n)=>e.start-n.start);return o.map((e,n)=>{const s=o[n+1];return e.end===1/0&&s?{...e,end:s.start}:e})}function U(t,o){let e=0,n=t.length-1,s=-1;for(;e<=n;){const l=e+n>>1;t[l].start<=o?(s=l,e=l+1):n=l-1}const r=t[s];if(!r||o>=r.end)return null;const c=t[s+1];if(!c||!dt(r,c)||!Number.isFinite(r.end))return r.world;const a=(o-r.start)/(r.end-r.start||1),[u,h]=[r.world,c.world];return{x:B(u.x,h.x,a),y:B(u.y,h.y,a),width:B(u.width,h.width,a),height:B(u.height,h.height,a)}}const Z=t=>t.overlays??(t.overlays=new ft(t.host));class ft{constructor(o){L(this,"container");L(this,"overlays",new Map);L(this,"view");const e=document.createElement("div");e.className="clover-canvas-overlays",Object.assign(e.style,{position:"absolute",inset:"0",overflow:"clip",pointerEvents:"none"}),o.appendChild(e),this.container=e}add(o,e){return this.overlays.set(o,e),o.classList.add("clover-canvas-overlay"),Object.assign(o.style,{position:"absolute",top:"0",left:"0",pointerEvents:"auto"}),o.parentElement!==this.container&&this.container.appendChild(o),()=>{this.overlays.delete(o)}}move(o,e){this.overlays.has(o)&&(this.overlays.set(o,e),this.view&&this.position(...this.view,o))}position(o,e,n){this.view=[o,e];const s=o.rotation*180/Math.PI,r=Math.cos(o.rotation)>.9999,c=r?window.devicePixelRatio||1:0,a=u=>c?Math.round(u*c)/c:u;for(const[u,h]of this.overlays){if(n&&u!==n)continue;const l=ht(o,e,{x:h.x+h.width/2,y:h.y+h.height/2}),v=a(l.x-h.width*o.zoom/2),g=a(l.y-h.height*o.zoom/2),p=a(h.width*o.zoom),m=a(h.height*o.zoom);u.style.width=`${p}px`,u.style.height=`${m}px`,u.style.transform=`translate(${v}px, ${g}px)`+(s?` rotate(${s}deg)`:"");const{style:w,dataset:$}=u;if(r){w.setProperty("--clover-overlay-x",`${l.x}px`),w.setProperty("--clover-overlay-top",`${g}px`),w.setProperty("--clover-overlay-bottom",`${g+m}px`);const k=l.y>e.height/2?"above":"below";$.overlayRoom!==k&&($.overlayRoom=k)}else w.removeProperty("--clover-overlay-x"),w.removeProperty("--clover-overlay-top"),w.removeProperty("--clover-overlay-bottom"),delete $.overlayRoom}}dispose(){this.overlays.clear(),this.container.remove()}}const gt=t=>"start"in t,Ft=t=>{var o,e;return gt(t)?t.start:(e=(o=t.track)==null?void 0:o[0])==null?void 0:e.start},vt=(t,o)=>!t.track||U(t.track,o)!==null;function wt(t,o){return vt(t,o.currentTime)?false:(o.currentTime=t.track[0].start,true)}function mt(t,o,e){var r,c,a;const n=ut(t==null?void 0:t.target);if(!((r=n[0])!=null&&r.rect)||!((c=n[0])!=null&&c.t))return null;const s=[];for(const u of n){const h=D((a=u.t)==null?void 0:a.replace(/^npt:/,""));if(!u.rect||!h)continue;const{x:l,y:v,w:g,h:p}=u.rect,m=o({x:l,y:v,width:g,height:p},u.id,e);m&&s.push({start:h.start,end:h.end??1/0,world:m})}return s.length?pt(s):null}function G(t,o){const{text:e,lang:n}=it(t,o);return e?{page:{text:e,...n?{lang:n}:{}}}:{}}function Lt(t,o){var n;const e=[];for(const{annotation:s,pageLabel:r,pageId:c}of t){const a=N([s==null?void 0:s.target].flat()[0]),u=D((n=a==null?void 0:a.t)==null?void 0:n.replace(/^npt:/,""));if(!u||a.rect||a.point||a.svg)continue;const{text:h,lang:l}=X(s,o);e.push({id:s.id,...h?{label:h}:{},...l?{lang:l}:{},...u,...G(r,o),...c?{pageId:c}:{}})}return e}const H=40;function Bt(t,o,e=null,n){var r;const s=[];for(const{annotation:c,targetIndex:a,pageLabel:u,pageId:h}of t){const l=N(c==null?void 0:c.target);if(!l)continue;let v=null,g;const p=mt(c,o,a);if(p){const{x:f,y:i,w:d,h:x}=l.rect;v={x:f,y:i,width:d,height:x}}else if(l.rect){const{x:f,y:i,w:d,h:x}=l.rect;v={x:f,y:i,width:d,height:x}}else if(l.point){const{x:f,y:i}=l.point;v={x:f-H/2,y:i-H/2,width:H,height:H},g={kind:"point"}}else if(l.svg&&e){const f=e(l.svg);f&&(v=f.box,g={kind:"svg",svg:f})}if(!v)continue;const m=p?p[0].world:o(v,l.id,a);if(!m)continue;const{text:w,lang:$}=X(c,n),k=at(c),O=(r=_(c).find(f=>(f==null?void 0:f.type)==="Image"&&/^https?:\/\//i.test(f.id??"")))==null?void 0:r.id;s.push({id:c.id,label:w,...$?{lang:$}:{},world:m,...g?{shape:g}:{},...p?{track:p}:{},...k?{link:k}:{},...O?{image:O}:{},...G(u,n),...h?{pageId:h}:{}})}return s}const z=({world:t})=>t.width*t.height,xt=(t,o)=>t.x>=o.x&&t.y>=o.y&&t.x+t.width<=o.x+o.width&&t.y+t.height<=o.y+o.height,y=t=>String(Math.round(t*1e3)/1e3||0);function $t(t,o){var g,p;const e=t.world,n=o.world;if(((g=o.shape)==null?void 0:g.kind)==="point"||n.x>=e.x+e.width||n.x+n.width<=e.x||n.y>=e.y+e.height||n.y+n.height<=e.y)return null;const[s,r]=[e.width,e.height],[c,a]=[n.x-e.x,n.y-e.y],u=`${y(-s/10)} ${y(-r/10)} ${y(s*1.2)} ${y(r*1.2)}`,h=`M${y(-s/10)} ${y(-r/10)}h${y(s*1.2)}v${y(r*1.2)}h${y(-s*1.2)}Z`;let l;if(((p=o.shape)==null?void 0:p.kind)==="svg"){const{box:m,shapes:w}=o.shape.svg,$=w.map(({tag:k,attributes:O})=>`<${k} ${Object.entries(O).map(([f,i])=>`${f}="${i}"`).join(" ")}/>`).join("");l=`<mask id="m"><path fill="#fff" d="${h}"/><svg x="${y(c)}" y="${y(a)}" width="${y(n.width)}" height="${y(n.height)}" viewBox="${m.x} ${m.y} ${Math.max(m.width,1)} ${Math.max(m.height,1)}" preserveAspectRatio="none" overflow="visible"><g fill="#000">${$}</g></svg></mask><path d="${h}" mask="url(#m)"/>`}else l=`<path fill-rule="evenodd" d="${h}M${y(c)} ${y(a)}h${y(n.width)}v${y(n.height)}h${y(-n.width)}Z"/>`;const v=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${u}" preserveAspectRatio="none">${l}</svg>`;return`url("data:image/svg+xml,${encodeURIComponent(v)}")`}const Ht=({renderer:t,placed:o,sceneVersion:e,active:n,selected:s,onActivate:r,onSelect:c,onFollow:a,media:u})=>{const h=tt(()=>{const i=new Map;return[...o].sort((d,x)=>z(x)-z(d)).forEach((d,x)=>i.set(d,x)),i},[o]),l=o.find(i=>i.id===n),v=F(null);j(()=>{const i=o.find(d=>d.id===s&&d.track);s||(v.current=null),!(!i||!u||v.current===s)&&(v.current=s,wt(i,u))},[o,s,u]);const g=i=>{const d=h.get(i)??0;return l?i===l?o.length:d>(h.get(l)??0)&&!i.track&&!l.track&&xt(i.world,l.world)?o.length+1+d:d:d},p=F(new Map),m=F(new Map),w=F(new WeakMap),$=F({placed:o,current:l,depthOf:g});$.current={placed:o,current:l,depthOf:g};const k=S(i=>{const{placed:d,current:x,depthOf:P}=$.current,R=T=>m.current.get(T.id),E=x&&R(x)!==null?x:void 0,M=T=>{const A=p.current.get(T.id);if(!A)return;const b=R(T),I=E&&T!==E&&b!==null&&P(T)<d.length?$t({...T,world:b??T.world},{...E,world:R(E)??E.world}):null;(w.current.get(A)??"")!==(I??"")&&(w.current.set(A,I??""),I?A.style.setProperty("--clover-annotation-mask",I):A.style.removeProperty("--clover-annotation-mask"))};i&&i!==x?M(i):d.forEach(M)},[]);ot(()=>k());const O=S((i,d)=>{d?p.current.set(i,d):p.current.delete(i)},[]),f=S((i,d)=>{m.current.set(i.id,d),k(i)},[k]);return et(C(nt,{children:o.map((i,d)=>C(kt,{entry:i,name:i.label??String(d+1),lang:i.label?i.lang:void 0,depth:g(i),register:O,onMove:f,renderer:t,active:n===i.id,selected:s===i.id,onActivate:r,onSelect:c,onFollow:a,media:u},`${i.id}|${e}`))}),Z(t).container)};let yt;const V=()=>yt??(yt=import("./panClearOfControls-ac9uf-Qs.mjs")),kt=({entry:t,name:o,lang:e,depth:n,register:s,onMove:r,renderer:c,active:a,selected:u,onActivate:h,onSelect:l,onFollow:v,media:g})=>{var M,T,A;const[p,m]=W(null),{id:w}=t,$=S(b=>{m(b),s(w,b)},[w,s]),{x:k,y:O,width:f,height:i}=t.world;j(()=>{if(!p)return;const b=Z(c).add(p,{x:k,y:O,width:f,height:i});return c.invalidate(),b},[p,c,k,O,f,i]);const d=bt(p,t.track,c,g,()=>h(null),b=>r(t,b)),{link:x}=t,P=x&&!x.canvasId&&!x.manifestId?x.id:void 0,R=x&&!P&&v?()=>v(t):void 0;return C(P?"a":"button",{ref:$,...P?{href:P,target:"_blank",rel:"noopener noreferrer"}:{type:"button"},id:t.id,className:"clover-canvas-annotation",hidden:!d,"data-active":a?"true":"false","data-shape":((M=t.shape)==null?void 0:M.kind)??"rect","data-track":t.track?"":void 0,"data-link":P||R?"true":void 0,"aria-label":o,"aria-current":u?"true":void 0,lang:e,style:{"--clover-annotation-depth":n},onMouseEnter:()=>h(t.id),onMouseLeave:()=>h(null),onFocus:()=>{h(t.id),V()},onKeyUp:b=>{if(b.key!=="Tab")return;const I=b.currentTarget;V().then(({panClearOfControls:q})=>{document.activeElement===I&&q(c,I)})},onBlur:()=>h(null),onKeyDown:Et,onClick:b=>{b.stopPropagation(),!P&&(R?R():l(t))},children:[((T=t.shape)==null?void 0:T.kind)==="point"&&C("span",{className:"clover-canvas-annotation-point","aria-hidden":"true"}),((A=t.shape)==null?void 0:A.kind)==="svg"&&C(Mt,{svg:t.shape.svg}),C(lt,{label:o,scrolls:true,image:t.image})]})};function bt(t,o,e,n,s,r){const c=!!o&&n!==void 0,[a,u]=W(()=>!c||(n?U(o,n.currentTime)!==null:false)),h=F(s);h.current=s;const l=F(r);return l.current=r,j(()=>{if(!o||n===void 0){u(true);return}if(!n){u(false);return}let v;const g=E=>{var A,b,I;const M=U(o,E);M&&t&&((A=e.overlays)==null||A.move(t,M)),l.current(M);const T=M!==null;if(T!==v){if(v=T,!T&&t){const q=t.matches(":hover");t.contains(document.activeElement)?(I=(b=e.overlays)==null?void 0:b.container.parentElement)==null||I.focus({preventScroll:true}):q&&h.current()}u(T)}},p=n,m=()=>typeof p.requestVideoFrameCallback=="function"&&p.videoWidth>0;let w=0,$=0;const k=(E,{mediaTime:M})=>{g(M),$=p.requestVideoFrameCallback(k)},O=()=>{g(n.currentTime),w=requestAnimationFrame(O)},f=()=>{cancelAnimationFrame(w),$&&p.cancelVideoFrameCallback($),w=$=0},i=()=>{f(),m()?$=p.requestVideoFrameCallback(k):w=requestAnimationFrame(O)},d=()=>g(n.currentTime),x=()=>n.paused&&d(),P=()=>{f(),d()},R=[["play",i],["pause",P],["ended",P],["seeking",d],["seeked",d],["loadeddata",d],["timeupdate",x]];return R.forEach(([E,M])=>n.addEventListener(E,M)),d(),n.paused||i(),()=>{f(),R.forEach(([E,M])=>n.removeEventListener(E,M))}},[t,o,n,e]),a}const Mt=({svg:t})=>{const{x:o,y:e,width:n,height:s}=t.box,r=t.shapes.map(({tag:c,attributes:a},u)=>rt.createElement(c,{key:u,...a,vectorEffect:"non-scaling-stroke"}));return C("svg",{className:"clover-canvas-annotation-shape",viewBox:`${o} ${e} ${Math.max(n,1)} ${Math.max(s,1)}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:[C("g",{children:r}),C("g",{children:r}),C("g",{children:r})]})};function X(t,o){return ct(st(t),o)}const Tt={ArrowDown:()=>32,ArrowUp:()=>-32,PageDown:t=>t.clientHeight-32,PageUp:t=>32-t.clientHeight,End:t=>t.scrollHeight,Home:t=>-t.scrollHeight};function Et(t){const o=t.currentTarget.querySelector(":scope > .clover-tip"),e=Tt[t.key];if(!o||!e||t.altKey||t.ctrlKey||t.metaKey)return false;const n=e(o);return(n>0?o.scrollHeight-o.clientHeight-o.scrollTop:o.scrollTop)<1?false:(t.preventDefault(),o.scrollBy({top:n}),true)}function St(t,o){const e=new Map;for(const{annotation:n,targetIndex:s}of t??[]){const r=N([n==null?void 0:n.target].flat()[0]);if(r.rect||r.point||r.svg||r.t||!_(n).some(a=>typeof(a==null?void 0:a.value)=="string"||(a==null?void 0:a.type)==="Image"))continue;const c=(o==null?void 0:o.find(a=>a.id===r.id))??(r.id||o==null?void 0:o[s]);c&&e.set(c.id,[...e.get(c.id)??[],n])}return e}export{Ht as A,wt as g,Bt as p,Ft as s,Lt as t,St as w};
1
+ var Y=Object.defineProperty;var J=(t,o,e)=>o in t?Y(t,o,{enumerable:true,configurable:true,writable:true,value:e}):t[o]=e;var L=(t,o,e)=>J(t,typeof o!="symbol"?o+"":o,e);import{n as N,al as Q,a3 as _,B as D,T as tt,A as F,y as j,q as S,_ as ot,$ as et,u as C,k as nt,am as st,o as it,d as W,R as rt}from"./shared-YUjOSBKO.mjs";import{r as at,a as ct}from"./link-ZRnv5NFR.mjs";import{T as lt}from"./Tip-IO11xX4x.mjs";import{b as ht}from"./Camera-cdCqKMup.mjs";import"./styles-CyuM_fB1.mjs";const K=t=>Array.isArray(t)?t.flatMap(K):Q.includes(t==null?void 0:t.type)?K(t.items??[]):t==null?[]:[t],ut=t=>K(t).map(o=>N(o)),dt=(t,o)=>Math.abs(t.end-o.start)<.001,B=(t,o,e)=>t+(o-t)*e;function pt(t){const o=[...t].sort((e,n)=>e.start-n.start);return o.map((e,n)=>{const s=o[n+1];return e.end===1/0&&s?{...e,end:s.start}:e})}function U(t,o){let e=0,n=t.length-1,s=-1;for(;e<=n;){const l=e+n>>1;t[l].start<=o?(s=l,e=l+1):n=l-1}const r=t[s];if(!r||o>=r.end)return null;const c=t[s+1];if(!c||!dt(r,c)||!Number.isFinite(r.end))return r.world;const a=(o-r.start)/(r.end-r.start||1),[u,h]=[r.world,c.world];return{x:B(u.x,h.x,a),y:B(u.y,h.y,a),width:B(u.width,h.width,a),height:B(u.height,h.height,a)}}const Z=t=>t.overlays??(t.overlays=new ft(t.host));class ft{constructor(o){L(this,"container");L(this,"overlays",new Map);L(this,"view");const e=document.createElement("div");e.className="clover-canvas-overlays",Object.assign(e.style,{position:"absolute",inset:"0",overflow:"clip",pointerEvents:"none"}),o.appendChild(e),this.container=e}add(o,e){return this.overlays.set(o,e),o.classList.add("clover-canvas-overlay"),Object.assign(o.style,{position:"absolute",top:"0",left:"0",pointerEvents:"auto"}),o.parentElement!==this.container&&this.container.appendChild(o),()=>{this.overlays.delete(o)}}move(o,e){this.overlays.has(o)&&(this.overlays.set(o,e),this.view&&this.position(...this.view,o))}position(o,e,n){this.view=[o,e];const s=o.rotation*180/Math.PI,r=Math.cos(o.rotation)>.9999,c=r?window.devicePixelRatio||1:0,a=u=>c?Math.round(u*c)/c:u;for(const[u,h]of this.overlays){if(n&&u!==n)continue;const l=ht(o,e,{x:h.x+h.width/2,y:h.y+h.height/2}),v=a(l.x-h.width*o.zoom/2),g=a(l.y-h.height*o.zoom/2),p=a(h.width*o.zoom),m=a(h.height*o.zoom);u.style.width=`${p}px`,u.style.height=`${m}px`,u.style.transform=`translate(${v}px, ${g}px)`+(s?` rotate(${s}deg)`:"");const{style:w,dataset:$}=u;if(r){w.setProperty("--clover-overlay-x",`${l.x}px`),w.setProperty("--clover-overlay-top",`${g}px`),w.setProperty("--clover-overlay-bottom",`${g+m}px`);const k=l.y>e.height/2?"above":"below";$.overlayRoom!==k&&($.overlayRoom=k)}else w.removeProperty("--clover-overlay-x"),w.removeProperty("--clover-overlay-top"),w.removeProperty("--clover-overlay-bottom"),delete $.overlayRoom}}dispose(){this.overlays.clear(),this.container.remove()}}const gt=t=>"start"in t,Ft=t=>{var o,e;return gt(t)?t.start:(e=(o=t.track)==null?void 0:o[0])==null?void 0:e.start},vt=(t,o)=>!t.track||U(t.track,o)!==null;function wt(t,o){return vt(t,o.currentTime)?false:(o.currentTime=t.track[0].start,true)}function mt(t,o,e){var r,c,a;const n=ut(t==null?void 0:t.target);if(!((r=n[0])!=null&&r.rect)||!((c=n[0])!=null&&c.t))return null;const s=[];for(const u of n){const h=D((a=u.t)==null?void 0:a.replace(/^npt:/,""));if(!u.rect||!h)continue;const{x:l,y:v,w:g,h:p}=u.rect,m=o({x:l,y:v,width:g,height:p},u.id,e);m&&s.push({start:h.start,end:h.end??1/0,world:m})}return s.length?pt(s):null}function G(t,o){const{text:e,lang:n}=it(t,o);return e?{page:{text:e,...n?{lang:n}:{}}}:{}}function Lt(t,o){var n;const e=[];for(const{annotation:s,pageLabel:r,pageId:c}of t){const a=N([s==null?void 0:s.target].flat()[0]),u=D((n=a==null?void 0:a.t)==null?void 0:n.replace(/^npt:/,""));if(!u||a.rect||a.point||a.svg)continue;const{text:h,lang:l}=X(s,o);e.push({id:s.id,...h?{label:h}:{},...l?{lang:l}:{},...u,...G(r,o),...c?{pageId:c}:{}})}return e}const H=40;function Bt(t,o,e=null,n){var r;const s=[];for(const{annotation:c,targetIndex:a,pageLabel:u,pageId:h}of t){const l=N(c==null?void 0:c.target);if(!l)continue;let v=null,g;const p=mt(c,o,a);if(p){const{x:f,y:i,w:d,h:x}=l.rect;v={x:f,y:i,width:d,height:x}}else if(l.rect){const{x:f,y:i,w:d,h:x}=l.rect;v={x:f,y:i,width:d,height:x}}else if(l.point){const{x:f,y:i}=l.point;v={x:f-H/2,y:i-H/2,width:H,height:H},g={kind:"point"}}else if(l.svg&&e){const f=e(l.svg);f&&(v=f.box,g={kind:"svg",svg:f})}if(!v)continue;const m=p?p[0].world:o(v,l.id,a);if(!m)continue;const{text:w,lang:$}=X(c,n),k=at(c),O=(r=_(c).find(f=>(f==null?void 0:f.type)==="Image"&&/^https?:\/\//i.test(f.id??"")))==null?void 0:r.id;s.push({id:c.id,label:w,...$?{lang:$}:{},world:m,...g?{shape:g}:{},...p?{track:p}:{},...k?{link:k}:{},...O?{image:O}:{},...G(u,n),...h?{pageId:h}:{}})}return s}const z=({world:t})=>t.width*t.height,xt=(t,o)=>t.x>=o.x&&t.y>=o.y&&t.x+t.width<=o.x+o.width&&t.y+t.height<=o.y+o.height,y=t=>String(Math.round(t*1e3)/1e3||0);function $t(t,o){var g,p;const e=t.world,n=o.world;if(((g=o.shape)==null?void 0:g.kind)==="point"||n.x>=e.x+e.width||n.x+n.width<=e.x||n.y>=e.y+e.height||n.y+n.height<=e.y)return null;const[s,r]=[e.width,e.height],[c,a]=[n.x-e.x,n.y-e.y],u=`${y(-s/10)} ${y(-r/10)} ${y(s*1.2)} ${y(r*1.2)}`,h=`M${y(-s/10)} ${y(-r/10)}h${y(s*1.2)}v${y(r*1.2)}h${y(-s*1.2)}Z`;let l;if(((p=o.shape)==null?void 0:p.kind)==="svg"){const{box:m,shapes:w}=o.shape.svg,$=w.map(({tag:k,attributes:O})=>`<${k} ${Object.entries(O).map(([f,i])=>`${f}="${i}"`).join(" ")}/>`).join("");l=`<mask id="m"><path fill="#fff" d="${h}"/><svg x="${y(c)}" y="${y(a)}" width="${y(n.width)}" height="${y(n.height)}" viewBox="${m.x} ${m.y} ${Math.max(m.width,1)} ${Math.max(m.height,1)}" preserveAspectRatio="none" overflow="visible"><g fill="#000">${$}</g></svg></mask><path d="${h}" mask="url(#m)"/>`}else l=`<path fill-rule="evenodd" d="${h}M${y(c)} ${y(a)}h${y(n.width)}v${y(n.height)}h${y(-n.width)}Z"/>`;const v=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${u}" preserveAspectRatio="none">${l}</svg>`;return`url("data:image/svg+xml,${encodeURIComponent(v)}")`}const Ht=({renderer:t,placed:o,sceneVersion:e,active:n,selected:s,onActivate:r,onSelect:c,onFollow:a,media:u})=>{const h=tt(()=>{const i=new Map;return[...o].sort((d,x)=>z(x)-z(d)).forEach((d,x)=>i.set(d,x)),i},[o]),l=o.find(i=>i.id===n),v=F(null);j(()=>{const i=o.find(d=>d.id===s&&d.track);s||(v.current=null),!(!i||!u||v.current===s)&&(v.current=s,wt(i,u))},[o,s,u]);const g=i=>{const d=h.get(i)??0;return l?i===l?o.length:d>(h.get(l)??0)&&!i.track&&!l.track&&xt(i.world,l.world)?o.length+1+d:d:d},p=F(new Map),m=F(new Map),w=F(new WeakMap),$=F({placed:o,current:l,depthOf:g});$.current={placed:o,current:l,depthOf:g};const k=S(i=>{const{placed:d,current:x,depthOf:P}=$.current,R=T=>m.current.get(T.id),E=x&&R(x)!==null?x:void 0,M=T=>{const A=p.current.get(T.id);if(!A)return;const b=R(T),I=E&&T!==E&&b!==null&&P(T)<d.length?$t({...T,world:b??T.world},{...E,world:R(E)??E.world}):null;(w.current.get(A)??"")!==(I??"")&&(w.current.set(A,I??""),I?A.style.setProperty("--clover-annotation-mask",I):A.style.removeProperty("--clover-annotation-mask"))};i&&i!==x?M(i):d.forEach(M)},[]);ot(()=>k());const O=S((i,d)=>{d?p.current.set(i,d):p.current.delete(i)},[]),f=S((i,d)=>{m.current.set(i.id,d),k(i)},[k]);return et(C(nt,{children:o.map((i,d)=>C(kt,{entry:i,name:i.label??String(d+1),lang:i.label?i.lang:void 0,depth:g(i),register:O,onMove:f,renderer:t,active:n===i.id,selected:s===i.id,onActivate:r,onSelect:c,onFollow:a,media:u},`${i.id}|${e}`))}),Z(t).container)};let yt;const V=()=>yt??(yt=import("./panClearOfControls-ac9uf-Qs.mjs")),kt=({entry:t,name:o,lang:e,depth:n,register:s,onMove:r,renderer:c,active:a,selected:u,onActivate:h,onSelect:l,onFollow:v,media:g})=>{var M,T,A;const[p,m]=W(null),{id:w}=t,$=S(b=>{m(b),s(w,b)},[w,s]),{x:k,y:O,width:f,height:i}=t.world;j(()=>{if(!p)return;const b=Z(c).add(p,{x:k,y:O,width:f,height:i});return c.invalidate(),b},[p,c,k,O,f,i]);const d=bt(p,t.track,c,g,()=>h(null),b=>r(t,b)),{link:x}=t,P=x&&!x.canvasId&&!x.manifestId?x.id:void 0,R=x&&!P&&v?()=>v(t):void 0;return C(P?"a":"button",{ref:$,...P?{href:P,target:"_blank",rel:"noopener noreferrer"}:{type:"button"},id:t.id,className:"clover-canvas-annotation",hidden:!d,"data-active":a?"true":"false","data-shape":((M=t.shape)==null?void 0:M.kind)??"rect","data-track":t.track?"":void 0,"data-link":P||R?"true":void 0,"aria-label":o,"aria-current":u?"true":void 0,lang:e,style:{"--clover-annotation-depth":n},onMouseEnter:()=>h(t.id),onMouseLeave:()=>h(null),onFocus:()=>{h(t.id),V()},onKeyUp:b=>{if(b.key!=="Tab")return;const I=b.currentTarget;V().then(({panClearOfControls:q})=>{document.activeElement===I&&q(c,I)})},onBlur:()=>h(null),onKeyDown:Et,onClick:b=>{b.stopPropagation(),!P&&(R?R():l(t))},children:[((T=t.shape)==null?void 0:T.kind)==="point"&&C("span",{className:"clover-canvas-annotation-point","aria-hidden":"true"}),((A=t.shape)==null?void 0:A.kind)==="svg"&&C(Mt,{svg:t.shape.svg}),C(lt,{label:o,scrolls:true,image:t.image})]})};function bt(t,o,e,n,s,r){const c=!!o&&n!==void 0,[a,u]=W(()=>!c||(n?U(o,n.currentTime)!==null:false)),h=F(s);h.current=s;const l=F(r);return l.current=r,j(()=>{if(!o||n===void 0){u(true);return}if(!n){u(false);return}let v;const g=E=>{var A,b,I;const M=U(o,E);M&&t&&((A=e.overlays)==null||A.move(t,M)),l.current(M);const T=M!==null;if(T!==v){if(v=T,!T&&t){const q=t.matches(":hover");t.contains(document.activeElement)?(I=(b=e.overlays)==null?void 0:b.container.parentElement)==null||I.focus({preventScroll:true}):q&&h.current()}u(T)}},p=n,m=()=>typeof p.requestVideoFrameCallback=="function"&&p.videoWidth>0;let w=0,$=0;const k=(E,{mediaTime:M})=>{g(M),$=p.requestVideoFrameCallback(k)},O=()=>{g(n.currentTime),w=requestAnimationFrame(O)},f=()=>{cancelAnimationFrame(w),$&&p.cancelVideoFrameCallback($),w=$=0},i=()=>{f(),m()?$=p.requestVideoFrameCallback(k):w=requestAnimationFrame(O)},d=()=>g(n.currentTime),x=()=>n.paused&&d(),P=()=>{f(),d()},R=[["play",i],["pause",P],["ended",P],["seeking",d],["seeked",d],["loadeddata",d],["timeupdate",x]];return R.forEach(([E,M])=>n.addEventListener(E,M)),d(),n.paused||i(),()=>{f(),R.forEach(([E,M])=>n.removeEventListener(E,M))}},[t,o,n,e]),a}const Mt=({svg:t})=>{const{x:o,y:e,width:n,height:s}=t.box,r=t.shapes.map(({tag:c,attributes:a},u)=>rt.createElement(c,{key:u,...a,vectorEffect:"non-scaling-stroke"}));return C("svg",{className:"clover-canvas-annotation-shape",viewBox:`${o} ${e} ${Math.max(n,1)} ${Math.max(s,1)}`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:[C("g",{children:r}),C("g",{children:r}),C("g",{children:r})]})};function X(t,o){return ct(st(t),o)}const Tt={ArrowDown:()=>32,ArrowUp:()=>-32,PageDown:t=>t.clientHeight-32,PageUp:t=>32-t.clientHeight,End:t=>t.scrollHeight,Home:t=>-t.scrollHeight};function Et(t){const o=t.currentTarget.querySelector(":scope > .clover-tip"),e=Tt[t.key];if(!o||!e||t.altKey||t.ctrlKey||t.metaKey)return false;const n=e(o);return(n>0?o.scrollHeight-o.clientHeight-o.scrollTop:o.scrollTop)<1?false:(t.preventDefault(),o.scrollBy({top:n}),true)}function St(t,o){const e=new Map;for(const{annotation:n,targetIndex:s}of t??[]){const r=N([n==null?void 0:n.target].flat()[0]);if(r.rect||r.point||r.svg||r.t||!_(n).some(a=>typeof(a==null?void 0:a.value)=="string"||(a==null?void 0:a.type)==="Image"))continue;const c=(o==null?void 0:o.find(a=>a.id===r.id))??(r.id||o==null?void 0:o[s]);c&&e.set(c.id,[...e.get(c.id)??[],n])}return e}export{Ht as A,wt as g,Bt as p,Ft as s,Lt as t,St as w};
@@ -1 +1 @@
1
- import{g as b,T as g,p as h,h as S,i as k,u as e,P as u,z as p}from"./shared-J3w3gnXD.mjs";import B from"./Connected-B0S1HXQb.mjs";import{r as T}from"./rendererSurface-DAvatpMF.mjs";import{j as L}from"./classnames-DukgfdpI.mjs";import{u as j}from"./hooks-Dp8pjU8l.mjs";import{L as c}from"./Loading-BmA--pzr.mjs";const R=p(()=>import("./Connected-BcjRA5si.mjs")),w=p(()=>import("./Connected-Q7iizBb8.mjs"));function A({className:v,style:f,renderers:y,children:r,...s}){var d;const C=b("Body"),o=j(),l=g(()=>h(o),[o]),t=S(y??C.renderers,{canvases:o,bodies:l}),a=t==null?void 0:t.component,i=((d=o.find(({type:n})=>n==="Scene"||n==="Timeline"))==null?void 0:d.type)??"Canvas",m=k(n=>n.status==="loading");return e("div",{"aria-busy":m,className:L("clover-body",v),"data-renderer":a?"custom":i.toLowerCase(),style:{position:"relative",height:"var(--clover-body-height, 60vh)",...f},children:[a?e(a,{canvases:o,bodies:l,children:r}):i==="Scene"?e(u,{fallback:e(c,{overlay:true}),children:e(w,{...s,children:r})}):i==="Timeline"?e(u,{fallback:e(c,{overlay:true}),children:e(R,{...s,children:r})}):e(B,{...s,surface:T,children:r}),m&&e(c,{overlay:true})]})}export{A as B};
1
+ import{g as b,T as g,p as h,h as S,i as k,u as e,P as u,z as p}from"./shared-YUjOSBKO.mjs";import B from"./Connected-DCBI-j9H.mjs";import{r as T}from"./rendererSurface-DhIlOjGT.mjs";import{j as L}from"./classnames-DukgfdpI.mjs";import{u as j}from"./hooks-BXzQSllm.mjs";import{L as c}from"./Loading-CBKfwsML.mjs";const R=p(()=>import("./Connected-BxqaRL9o.mjs")),w=p(()=>import("./Connected-DkhfVWxd.mjs"));function A({className:v,style:f,renderers:y,children:r,...s}){var d;const C=b("Body"),o=j(),l=g(()=>h(o),[o]),t=S(y??C.renderers,{canvases:o,bodies:l}),a=t==null?void 0:t.component,i=((d=o.find(({type:n})=>n==="Scene"||n==="Timeline"))==null?void 0:d.type)??"Canvas",m=k(n=>n.status==="loading");return e("div",{"aria-busy":m,className:L("clover-body",v),"data-renderer":a?"custom":i.toLowerCase(),style:{position:"relative",height:"var(--clover-body-height, 60vh)",...f},children:[a?e(a,{canvases:o,bodies:l,children:r}):i==="Scene"?e(u,{fallback:e(c,{overlay:true}),children:e(w,{...s,children:r})}):i==="Timeline"?e(u,{fallback:e(c,{overlay:true}),children:e(R,{...s,children:r})}):e(B,{...s,surface:T,children:r}),m&&e(c,{overlay:true})]})}export{A as B};
@@ -1 +1 @@
1
- import{a as o,u as r}from"./shared-J3w3gnXD.mjs";import{j as l}from"./classnames-DukgfdpI.mjs";function c({error:a,className:s}){const{t,langOf:e}=o();return r("div",{className:l("clover-status",s),"data-status":"error",role:"alert",children:[r("p",{lang:e("statusError"),children:t("statusError")}),r("p",{className:"clover-status-detail",lang:"en",children:a.message})]})}export{c as B};
1
+ import{a as o,u as r}from"./shared-YUjOSBKO.mjs";import{j as l}from"./classnames-DukgfdpI.mjs";function c({error:a,className:s}){const{t,langOf:e}=o();return r("div",{className:l("clover-status",s),"data-status":"error",role:"alert",children:[r("p",{lang:e("statusError"),children:t("statusError")}),r("p",{className:"clover-status-detail",lang:"en",children:a.message})]})}export{c as B};
@@ -1 +1 @@
1
- import{u as a}from"./shared-J3w3gnXD.mjs";import{j as d}from"./classnames-DukgfdpI.mjs";import{T as u}from"./Tip-C8J3qsIK.mjs";import"./styles-Ypl9KrSK.mjs";const f=({className:n,id:e,label:o,children:r,onClick:s,expanded:i,controls:p,shortcut:t,lang:l})=>{const c=e.split("-")[0].replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"");return a("button",{id:e,className:d("clover-canvas-button",n),"data-testid":"clover-canvas-button","data-button":c,onClick:s,"aria-expanded":i,"aria-controls":p,"aria-label":o,"aria-keyshortcuts":t==null?void 0:t.keys,lang:l,type:"button",children:[a("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true","data-testid":"clover-canvas-button-svg",focusable:"false",width:"16",height:"16",viewBox:"0 0 512 512",children:r}),a(u,{label:o,shortcut:t})]})};export{f as B};
1
+ import{u as a}from"./shared-YUjOSBKO.mjs";import{j as d}from"./classnames-DukgfdpI.mjs";import{T as u}from"./Tip-IO11xX4x.mjs";import"./styles-CyuM_fB1.mjs";const f=({className:n,id:e,label:o,children:r,onClick:s,expanded:i,controls:p,shortcut:t,lang:l})=>{const c=e.split("-")[0].replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"");return a("button",{id:e,className:d("clover-canvas-button",n),"data-testid":"clover-canvas-button","data-button":c,onClick:s,"aria-expanded":i,"aria-controls":p,"aria-label":o,"aria-keyshortcuts":t==null?void 0:t.keys,lang:l,type:"button",children:[a("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true","data-testid":"clover-canvas-button-svg",focusable:"false",width:"16",height:"16",viewBox:"0 0 512 512",children:r}),a(u,{label:o,shortcut:t})]})};export{f as B};
@@ -1 +1 @@
1
- import{e as f,f as l,d as i,c,r as a,t as h,s as u}from"./CanvasView-B8lMMSou.mjs";function g(t,o){return c(h(o.width/2,o.height/2),a(t.rotation),u(t.zoom),h(-t.x,-t.y))}function m(t,o){return c(h(t.x,t.y),u(1/t.zoom),a(-t.rotation),h(-o.width/2,-o.height/2))}function M(t,o,n){return i(m(t,o),n)}function w(t,o,n){return i(g(t,o),n)}function C(t,o){return f(m(t,o),{x:0,y:0,width:o.width,height:o.height})}function N(t,o,n=0,r=0){const e=f(a(n),t),s=Math.max(1,o.width*(1-r*2)),y=Math.max(1,o.height*(1-r*2)),d=Math.min(s/Math.max(e.width,Number.EPSILON),y/Math.max(e.height,Number.EPSILON)),x=l(t);return{x:x.x,y:x.y,zoom:d,rotation:n}}function P(t,o,n,r,e){const s=i(c(u(1/n),a(-r)),{x:o.x-e.width/2,y:o.y-e.height/2});return{x:t.x-s.x,y:t.y-s.y}}function S(t,o){return t.x===o.x&&t.y===o.y&&t.zoom===o.zoom&&t.rotation===o.rotation}export{P as a,w as b,S as c,N as f,M as s,C as v,g as w};
1
+ import{e as f,f as l,d as i,c,r as a,t as h,s as u}from"./CanvasView-BI3YzNdK.mjs";function g(t,o){return c(h(o.width/2,o.height/2),a(t.rotation),u(t.zoom),h(-t.x,-t.y))}function m(t,o){return c(h(t.x,t.y),u(1/t.zoom),a(-t.rotation),h(-o.width/2,-o.height/2))}function M(t,o,n){return i(m(t,o),n)}function w(t,o,n){return i(g(t,o),n)}function C(t,o){return f(m(t,o),{x:0,y:0,width:o.width,height:o.height})}function N(t,o,n=0,r=0){const e=f(a(n),t),s=Math.max(1,o.width*(1-r*2)),y=Math.max(1,o.height*(1-r*2)),d=Math.min(s/Math.max(e.width,Number.EPSILON),y/Math.max(e.height,Number.EPSILON)),x=l(t);return{x:x.x,y:x.y,zoom:d,rotation:n}}function P(t,o,n,r,e){const s=i(c(u(1/n),a(-r)),{x:o.x-e.width/2,y:o.y-e.height/2});return{x:t.x-s.x,y:t.y-s.y}}function S(t,o){return t.x===o.x&&t.y===o.y&&t.zoom===o.zoom&&t.rotation===o.rotation}export{P as a,w as b,S as c,N as f,M as s,C as v,g as w};
@@ -1 +1 @@
1
- var l=Object.defineProperty;var o=(r,t,s)=>t in r?l(r,t,{enumerable:true,configurable:true,writable:true,value:s}):r[t]=s;var i=(r,t,s)=>o(r,typeof t!="symbol"?t+"":t,s);import{h as d,b as g}from"./rendererSurface-DAvatpMF.mjs";class c{constructor(t,s){i(this,"kind","canvas2d");i(this,"canvas");i(this,"ctx");i(this,"pixelRatio",1);i(this,"drawn",new Set);this.canvas=t,this.ctx=s}static create(t){let s=null;try{s=t.getContext("2d",{alpha:true})}catch{s=null}return!s||typeof s.drawImage!="function"?null:new c(t,s)}resize(t,s,a){this.pixelRatio=a;const e=Math.max(1,Math.round(t*a)),h=Math.max(1,Math.round(s*a));this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==h&&(this.canvas.height=h)}begin(){const t=this.ctx;t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.clearRect(0,0,this.canvas.width,this.canvas.height),t.imageSmoothingEnabled=true,t.imageSmoothingQuality="high"}draw(t){if(!d(t.source))return"skipped";const s=this.ctx,a=t.transform,e=this.pixelRatio,h=t.crop??{x:0,y:0,width:t.width,height:t.height},n=g(t,e);return s.setTransform(e*a.a,e*a.b,e*a.c,e*a.d,e*a.e,e*a.f),s.globalAlpha=t.opacity,s.drawImage(t.source,h.x,h.y,h.width,h.height,h.x,h.y,h.width+n.x,h.height+n.y),this.drawn.add(t.key),"drawn"}end(){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.globalAlpha=1}has(t){return this.drawn.has(t)}release(t){this.drawn.delete(t)}dispose(){this.drawn.clear(),this.canvas.width=0,this.canvas.height=0}}export{c as Canvas2DBackend};
1
+ var l=Object.defineProperty;var o=(r,t,s)=>t in r?l(r,t,{enumerable:true,configurable:true,writable:true,value:s}):r[t]=s;var i=(r,t,s)=>o(r,typeof t!="symbol"?t+"":t,s);import{h as d,b as g}from"./rendererSurface-DhIlOjGT.mjs";class c{constructor(t,s){i(this,"kind","canvas2d");i(this,"canvas");i(this,"ctx");i(this,"pixelRatio",1);i(this,"drawn",new Set);this.canvas=t,this.ctx=s}static create(t){let s=null;try{s=t.getContext("2d",{alpha:true})}catch{s=null}return!s||typeof s.drawImage!="function"?null:new c(t,s)}resize(t,s,a){this.pixelRatio=a;const e=Math.max(1,Math.round(t*a)),h=Math.max(1,Math.round(s*a));this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==h&&(this.canvas.height=h)}begin(){const t=this.ctx;t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.clearRect(0,0,this.canvas.width,this.canvas.height),t.imageSmoothingEnabled=true,t.imageSmoothingQuality="high"}draw(t){if(!d(t.source))return"skipped";const s=this.ctx,a=t.transform,e=this.pixelRatio,h=t.crop??{x:0,y:0,width:t.width,height:t.height},n=g(t,e);return s.setTransform(e*a.a,e*a.b,e*a.c,e*a.d,e*a.e,e*a.f),s.globalAlpha=t.opacity,s.drawImage(t.source,h.x,h.y,h.width,h.height,h.x,h.y,h.width+n.x,h.height+n.y),this.drawn.add(t.key),"drawn"}end(){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.globalAlpha=1}has(t){return this.drawn.has(t)}release(t){this.drawn.delete(t)}dispose(){this.drawn.clear(),this.canvas.width=0,this.canvas.height=0}}export{c as Canvas2DBackend};