@react-pdf-kit/viewer 2.0.0-beta.0 → 2.0.0-beta.2

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 (201) hide show
  1. package/dist/{LayoutWrapper-a871c161.js → LayoutWrapper-6224491f.js} +1 -1
  2. package/dist/{RotateTool.module-03987eba.js → RotateTool.module-67946714.js} +1 -1
  3. package/dist/{SearchCloseButton-cbf182aa.js → SearchCloseButton-08d57275.js} +1 -1
  4. package/dist/ToolbarLayout.module-3a77cc37.js +3556 -0
  5. package/dist/assets/style.css +1 -0
  6. package/dist/assets/style.js +74 -0
  7. package/dist/components/RPConfig.js +14 -1489
  8. package/dist/components/RPController.js +175 -61
  9. package/dist/components/RPDropFileZone.js +26 -12
  10. package/dist/components/RPPages.js +82 -8
  11. package/dist/components/RPProvider.js +173 -19
  12. package/dist/components/RPTheme.js +6 -5
  13. package/dist/components/icons/DualPageIcon.js +6 -6
  14. package/dist/components/icons/LoaderIcon.js +1 -1
  15. package/dist/components/icons/SinglePageIcon.js +6 -6
  16. package/dist/components/layout/Container.js +1 -1
  17. package/dist/components/layout/LayoutContainer.js +87 -7
  18. package/dist/components/layout/LayoutWrapper.js +2 -1
  19. package/dist/components/layout/RPDefaultLayout.js +127 -3
  20. package/dist/components/layout/RPLayout.js +108 -20
  21. package/dist/components/layout/WrapperLayout.js +22 -9
  22. package/dist/components/layout/sidebar/RPSidebar.js +127 -2
  23. package/dist/components/layout/sidebar/RPSplitter.js +1 -1
  24. package/dist/components/layout/sidebar/Thumbnail.js +89 -8
  25. package/dist/components/layout/sidebar/Thumbnails.js +134 -2
  26. package/dist/components/layout/toolbar/DarkModeTool.js +22 -13
  27. package/dist/components/layout/toolbar/DocumentDialog.js +89 -8
  28. package/dist/components/layout/toolbar/DocumentProperties.js +18 -8
  29. package/dist/components/layout/toolbar/FileDownloadTool.js +127 -2
  30. package/dist/components/layout/toolbar/FileUploadTool.js +31 -10
  31. package/dist/components/layout/toolbar/FullScreenTool.js +39 -27
  32. package/dist/components/layout/toolbar/MenuItem.js +12 -8
  33. package/dist/components/layout/toolbar/MenuSeparator.js +8 -4
  34. package/dist/components/layout/toolbar/MostPageTool.js +89 -9
  35. package/dist/components/layout/toolbar/OtherTool.js +119 -3
  36. package/dist/components/layout/toolbar/Paginate.js +123 -2
  37. package/dist/components/layout/toolbar/PrintTool.js +127 -2
  38. package/dist/components/layout/toolbar/PropertyItem.js +1 -1
  39. package/dist/components/layout/toolbar/RPMenuItem.js +20 -13
  40. package/dist/components/layout/toolbar/RPMoreOptions.js +169 -44
  41. package/dist/components/layout/toolbar/RPToolbar.js +133 -3
  42. package/dist/components/layout/toolbar/RPToolbarEnd.js +133 -2
  43. package/dist/components/layout/toolbar/RotateTool.js +39 -18
  44. package/dist/components/layout/toolbar/ScrollModeTool.js +27 -18
  45. package/dist/components/layout/toolbar/SearchCloseButton.js +11 -2
  46. package/dist/components/layout/toolbar/SearchResultNavigator.js +133 -3
  47. package/dist/components/layout/toolbar/SearchTool.js +87 -8
  48. package/dist/components/layout/toolbar/SelectionModeTool.js +19 -10
  49. package/dist/components/layout/toolbar/ThumbnailTool.js +139 -10
  50. package/dist/components/layout/toolbar/ToolbarCustom.js +104 -23
  51. package/dist/components/layout/toolbar/ToolbarDefault.js +113 -31
  52. package/dist/components/layout/toolbar/ToolbarLayout.js +145 -6
  53. package/dist/components/layout/toolbar/ViewModeTool.js +28 -19
  54. package/dist/components/layout/toolbar/ZoomTool.js +138 -128
  55. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +137 -7
  56. package/dist/components/layout/toolbar/tools/DualPageTool.js +144 -0
  57. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +140 -9
  58. package/dist/components/layout/toolbar/tools/FileUploadTool.js +27 -8
  59. package/dist/components/layout/toolbar/tools/FullScreenTool.js +23 -13
  60. package/dist/components/layout/toolbar/tools/InputPageTool.js +157 -26
  61. package/dist/components/layout/toolbar/tools/NextPageTool.js +89 -9
  62. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +142 -11
  63. package/dist/components/layout/toolbar/tools/PrintTool.js +138 -7
  64. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +29 -8
  65. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +32 -11
  66. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +29 -0
  67. package/dist/components/layout/toolbar/tools/SinglePageTool.js +144 -0
  68. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +15 -6
  69. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +142 -11
  70. package/dist/components/layout/toolbar/tools/ZoomInTool.js +47 -20
  71. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +140 -0
  72. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +158 -29
  73. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +45 -18
  74. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +104 -19
  75. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +144 -11
  76. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +15 -5
  77. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +141 -11
  78. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +90 -9
  79. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +21 -9
  80. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +90 -10
  81. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +137 -7
  82. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +33 -12
  83. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +23 -14
  84. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +22 -13
  85. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +27 -18
  86. package/dist/components/page/AnnotationLayer.js +87 -9
  87. package/dist/components/page/CanvasLayer.js +90 -8
  88. package/dist/components/page/CustomElement.js +49 -18
  89. package/dist/components/page/DualPage.js +136 -2
  90. package/dist/components/page/RPPage.js +88 -8
  91. package/dist/components/page/SinglePage.js +136 -2
  92. package/dist/components/page/TextHighlightLayer.js +88 -8
  93. package/dist/components/page/TextLayer.js +89 -9
  94. package/dist/components/ui/Button.js +9 -8
  95. package/dist/components/ui/Checkbox.js +6 -5
  96. package/dist/components/ui/DropDown.js +18 -14
  97. package/dist/components/ui/Input.js +10 -9
  98. package/dist/components/ui/LoadingIndicator.js +135 -2
  99. package/dist/components/ui/PasswordModal.js +18 -15
  100. package/dist/components/ui/RPTooltip.js +202 -415
  101. package/dist/contexts/DimensionPagesContext.js +35 -17
  102. package/dist/contexts/DropFileZoneContext.js +32 -22
  103. package/dist/contexts/ElementPageContext.js +114 -51
  104. package/dist/contexts/EventCallbackContext.js +30 -0
  105. package/dist/contexts/FileInputContext.js +32 -22
  106. package/dist/contexts/GlobalCurrentPage.js +13 -10
  107. package/dist/contexts/HighlightContext.js +24 -11
  108. package/dist/contexts/LicenseContext.js +1 -0
  109. package/dist/contexts/LoaderContext.js +10 -9
  110. package/dist/contexts/LocalizationContext.js +11 -10
  111. package/dist/contexts/PagesRotateContext.js +36 -18
  112. package/dist/contexts/PaginationContext.js +135 -4
  113. package/dist/contexts/PrintContext.js +138 -4
  114. package/dist/contexts/RPDocumentContext.js +46 -28
  115. package/dist/contexts/RenderQueueProvider.js +136 -4
  116. package/dist/contexts/RotationContext.js +25 -15
  117. package/dist/contexts/ScrollModeContext.js +7 -6
  118. package/dist/contexts/SearchContext.js +138 -4
  119. package/dist/contexts/SelectionModeContext.js +5 -4
  120. package/dist/contexts/ThumbnailsContext.js +138 -4
  121. package/dist/contexts/ViewModeContext.js +10 -9
  122. package/dist/contexts/ZoomContext.js +34 -24
  123. package/dist/index-808ea7bf.js +1685 -0
  124. package/dist/index-a48ec088.js +1672 -0
  125. package/dist/{index-35c7f4a2.js → index-c9a2990a.js} +3 -3
  126. package/dist/libInjectCss.js +9 -0
  127. package/dist/main.js +222 -84
  128. package/dist/types/assets/style.d.ts +1 -0
  129. package/dist/types/components/icons/DualPageIcon.d.ts +1 -1
  130. package/dist/types/components/icons/SinglePageIcon.d.ts +1 -1
  131. package/dist/types/components/layout/toolbar/tools/DualPageTool.d.ts +3 -0
  132. package/dist/types/components/layout/toolbar/tools/SelectionModeSwitcherTool.d.ts +3 -0
  133. package/dist/types/components/layout/toolbar/tools/SinglePageTool.d.ts +3 -0
  134. package/dist/types/components/layout/toolbar/tools/ZoomLevelDisplay.d.ts +7 -0
  135. package/dist/types/contexts/EventCallbackContext.d.ts +5 -0
  136. package/dist/types/contexts/RenderQueueProvider.d.ts +2 -2
  137. package/dist/types/libInjectCss.d.ts +1 -0
  138. package/dist/types/main.d.ts +5 -5
  139. package/dist/types/utils/annotations.d.ts +1 -2
  140. package/dist/types/utils/approximateFragtion.d.ts +9 -0
  141. package/dist/types/utils/getElementPositionInPage.d.ts +5 -0
  142. package/dist/types/utils/hooks/useCopyText.d.ts +1 -0
  143. package/dist/types/utils/hooks/usePrint.d.ts +3 -2
  144. package/dist/types/utils/hooks/useSearch.d.ts +1 -2
  145. package/dist/types/utils/injectPrintCSS.d.ts +1 -0
  146. package/dist/types/utils/link_service.d.ts +11 -1
  147. package/dist/types/utils/renderPage.d.ts +2 -2
  148. package/dist/types/utils/types.d.ts +38 -5
  149. package/dist/types/utils/zoom.d.ts +2 -0
  150. package/dist/utils/annotations.js +48 -58
  151. package/dist/utils/approximateFragtion.js +22 -0
  152. package/dist/utils/getElementPositionInPage.js +84 -0
  153. package/dist/utils/getWordPositionInPage.js +5 -5
  154. package/dist/utils/getZoomLevel.js +9 -8
  155. package/dist/utils/highlight.js +72 -72
  156. package/dist/utils/hooks/useCopyText.js +36 -0
  157. package/dist/utils/hooks/useDarkModeProps.js +3 -2
  158. package/dist/utils/hooks/useFileDownload.js +90 -8
  159. package/dist/utils/hooks/useHighlight.js +13 -12
  160. package/dist/utils/hooks/useLicense.js +1 -1
  161. package/dist/utils/hooks/useLoadPdf.js +44 -36
  162. package/dist/utils/hooks/useLoadWorker.js +8 -8
  163. package/dist/utils/hooks/usePageRotateContext.js +33 -17
  164. package/dist/utils/hooks/usePaginate.js +88 -8
  165. package/dist/utils/hooks/usePinch.js +62 -41
  166. package/dist/utils/hooks/usePresentPage.js +88 -8
  167. package/dist/utils/hooks/usePrint.js +90 -9
  168. package/dist/utils/hooks/useRotate.js +21 -7
  169. package/dist/utils/hooks/useScrollToPage.js +86 -8
  170. package/dist/utils/hooks/useSearch.js +86 -8
  171. package/dist/utils/hooks/useThumbnail.js +89 -8
  172. package/dist/utils/hooks/useVirtualReactWindow.js +88 -8
  173. package/dist/utils/hooks/useWatermark.js +18 -15
  174. package/dist/utils/injectPrintCSS.js +22 -0
  175. package/dist/utils/link_service.js +49 -9
  176. package/dist/utils/renderPage.js +13 -10
  177. package/dist/utils/zoom.js +6 -0
  178. package/package.json +5 -6
  179. package/dist/ToolbarLayout.module-c588d36b.js +0 -3411
  180. package/dist/ZoomTool.module-6c5eabbb.js +0 -12
  181. package/dist/assets/Button.css +0 -1
  182. package/dist/assets/Checkbox.css +0 -1
  183. package/dist/assets/Container.css +0 -1
  184. package/dist/assets/DropDown.css +0 -1
  185. package/dist/assets/Input.css +0 -1
  186. package/dist/assets/LayoutWrapper.css +0 -1
  187. package/dist/assets/LoaderIcon.css +0 -1
  188. package/dist/assets/MenuItem.css +0 -1
  189. package/dist/assets/MenuSeparator.css +0 -1
  190. package/dist/assets/PasswordModal.css +0 -1
  191. package/dist/assets/PropertyItem.css +0 -1
  192. package/dist/assets/RPDropFileZone.css +0 -1
  193. package/dist/assets/RPSplitter.css +0 -1
  194. package/dist/assets/RPTooltip.css +0 -1
  195. package/dist/assets/RotateTool.css +0 -1
  196. package/dist/assets/SearchCloseButton.css +0 -1
  197. package/dist/assets/ToolbarLayout.css +0 -1
  198. package/dist/assets/WrapperLayout.css +0 -1
  199. package/dist/assets/ZoomTool.css +0 -1
  200. package/dist/floating-ui.react-dom-6b2fe0df.js +0 -1474
  201. package/dist/index-f563c6f0.js +0 -1889
@@ -224,10 +224,11 @@ export interface DarkModeProps {
224
224
  export interface DarkMode extends DarkModeProps {
225
225
  onDarkModeChange: (value: boolean) => void;
226
226
  }
227
- export interface renderOptions {
227
+ export interface RenderOptions {
228
228
  scale?: number;
229
229
  rotate?: number;
230
230
  renderForms?: boolean;
231
+ interactiveForm?: boolean;
231
232
  }
232
233
  export interface License {
233
234
  validating?: boolean;
@@ -321,13 +322,18 @@ export interface PreparePrintProgress {
321
322
  totalPages: number;
322
323
  percentage: number;
323
324
  }
325
+ export interface PrintConfiguration {
326
+ visibleDefaultProgress?: boolean;
327
+ }
328
+ export type PrintOptions = PrintConfiguration | React.MouseEvent<{}>;
324
329
  export interface PrintToolProps {
325
- print: () => void;
330
+ print: (options?: PrintOptions) => Promise<void>;
326
331
  cancel: () => void;
327
332
  setOnProgress: (callback: (progress: PreparePrintProgress) => void) => void;
328
333
  setOnComplete: (callback: () => void) => void;
329
334
  setOnError: (callback: (error: Error) => void) => void;
330
335
  progress: PreparePrintProgress;
336
+ showDefaultProgress?: boolean;
331
337
  }
332
338
  export interface ThumbnailToolProps {
333
339
  onClick: () => void;
@@ -456,7 +462,12 @@ export interface CharacterMap {
456
462
  url: string;
457
463
  isCompressed: boolean;
458
464
  }
459
- export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPControllerProps {
465
+ export interface EventCallbackContextType {
466
+ onPageChange?: (page: number) => void;
467
+ onRotate?: (rotation: Record<number, number>) => void;
468
+ onScroll?: (scroll: Event) => void;
469
+ }
470
+ export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPControllerProps, EventCallbackContextType {
460
471
  src: RPSrc;
461
472
  workerUrl?: string;
462
473
  characterMap?: CharacterMap;
@@ -468,6 +479,8 @@ export interface RPControllerProps extends PropsWithChildren, DarkModeProviderPr
468
479
  locale?: string;
469
480
  localization?: LocalizationMap;
470
481
  downloadFilename?: string;
482
+ initialSelectionMode?: SelectionMode;
483
+ interactiveForm?: boolean;
471
484
  }
472
485
  export interface RPConfigProps extends Omit<ConfigContextType, 'workerUrlAdded'>, RPThemeContextType, PropsWithChildren {
473
486
  workerUrl?: string;
@@ -502,6 +515,7 @@ export interface ZoomContextType {
502
515
  export type ZoomProps = Omit<ZoomContextType, 'currentZoom'>;
503
516
  export type InitialStateContextType = {
504
517
  instanceId: string;
518
+ interactiveForm?: boolean;
505
519
  } & ZoomProviderProps & PageProviderProps & ViewModeInitialProps & ScrollModeInitialProps & RotateProviderProps;
506
520
  export interface ZoomProviderProps {
507
521
  initialScale?: number | ZoomLevel;
@@ -535,6 +549,12 @@ export interface ScrollModeInitialProps {
535
549
  initialScrollMode?: ScrollMode;
536
550
  }
537
551
  export interface RectPosition {
552
+ left: number;
553
+ bottom: number;
554
+ width: number;
555
+ height: number;
556
+ }
557
+ export interface ElementPosition {
538
558
  left: number;
539
559
  top: number;
540
560
  width: number;
@@ -605,8 +625,7 @@ export interface SearchContextType {
605
625
  prevMatch: () => void;
606
626
  searchOptions: SearchOptions;
607
627
  setSearchOptions: Dispatch<SetStateAction<SearchOptions>>;
608
- currentMatchElement: HTMLElement | null;
609
- setCurrentMatchElement: Dispatch<SetStateAction<HTMLElement | null>>;
628
+ setCurrentMatchPosition: Dispatch<React.SetStateAction<number>>;
610
629
  }
611
630
  export declare enum SelectionMode {
612
631
  TEXT = "TEXT",
@@ -623,7 +642,11 @@ export type LoaderImage = JSX.Element | string;
623
642
  export interface LoadPDFOptions {
624
643
  onLoadError?: (error: any) => void;
625
644
  onLoaded?: (pdfDocument: PDFDocumentProxy) => void;
645
+ onLoadProgress?: (progress: number) => void;
626
646
  loaderImage?: LoaderImage;
647
+ disableAutoFetch?: boolean;
648
+ disableStream?: boolean;
649
+ rangeChunkSize?: number;
627
650
  }
628
651
  export interface ScrollPosition {
629
652
  left: number;
@@ -659,6 +682,9 @@ export interface useElementPage {
659
682
  removeElement: (pageNumber: number, index: number) => void;
660
683
  clearElements: (pageNumber: number) => void;
661
684
  elementList: Record<number, Array<HTMLElement | JSX.Element>>;
685
+ scrollToElement: (page: number, index: number, config?: {
686
+ behavior: 'smooth' | 'auto' | 'instant';
687
+ }) => void;
662
688
  }
663
689
  export interface MatchHighlight extends MatchValue {
664
690
  keyword: string | RegExp;
@@ -710,6 +736,13 @@ export interface ThemeSwitcherIcons {
710
736
  export interface ThemeSwitcherToolProps {
711
737
  icons?: ThemeSwitcherIcons;
712
738
  }
739
+ export interface SelectionModeSwitcherIcons {
740
+ textSelectionIcon?: React.ReactNode;
741
+ handModeIcon?: React.ReactNode;
742
+ }
743
+ export interface SelectionModeSwitcherToolProps {
744
+ icons?: SelectionModeSwitcherIcons;
745
+ }
713
746
  export interface ToolbarSection {
714
747
  component: React.ReactNode;
715
748
  }
@@ -0,0 +1,2 @@
1
+ export declare const isZoomOutDisabled: (currentZoom: number) => boolean;
2
+ export declare const isZoomInDisabled: (currentZoom: number) => boolean;
@@ -1,14 +1,15 @@
1
- import { sanitizeExternalUrl as L } from "./sanitizeExternalUrl.js";
2
- import { AnnotationSubType as _, AnnotationType as l } from "./types.js";
3
- import { dateFormatter as I } from "./dateFormatter.js";
4
- const v = ["click", "dblclick", "input", "change"], g = /* @__PURE__ */ new Map(), E = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
5
- function x(e, t) {
6
- const n = E(e, t);
7
- return g.has(n) ? g.get(n) ?? null : null;
1
+ import { sanitizeExternalUrl as _ } from "./sanitizeExternalUrl.js";
2
+ import { AnnotationType as l } from "./types.js";
3
+ import { dateFormatter as L } from "./dateFormatter.js";
4
+ import "../th_TH-d627cd51.js";
5
+ const T = ["click", "dblclick", "input", "change"], m = /* @__PURE__ */ new Map(), v = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
6
+ function I(e, t) {
7
+ const n = v(e, t);
8
+ return m.has(n) ? m.get(n) ?? null : null;
8
9
  }
9
- const B = (e, t, n) => {
10
- g.set(E(e, t), n);
11
- }, O = (e, t) => {
10
+ const x = (e, t, n) => {
11
+ m.set(v(e, t), n);
12
+ }, A = (e, t) => {
12
13
  switch (t[1].name) {
13
14
  case "XYZ":
14
15
  return {
@@ -42,19 +43,19 @@ const B = (e, t, n) => {
42
43
  };
43
44
  }
44
45
  };
45
- async function b(e, t) {
46
+ async function E(e, t) {
46
47
  let n;
47
48
  if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
48
- const a = n[0], s = x(e, a);
49
+ const a = n[0], s = I(e, a);
49
50
  if (s === null) {
50
51
  const r = await e.getPageIndex(a);
51
- return B(e, a, r), await b(e, n);
52
+ return x(e, a, r), await E(e, n);
52
53
  } else
53
- return O(s, n);
54
+ return A(s, n);
54
55
  } else
55
- return O(n[0], n);
56
+ return A(n[0], n);
56
57
  }
57
- const H = (e) => {
58
+ const M = (e) => {
58
59
  const n = e.target.parentNode;
59
60
  if (!n)
60
61
  return;
@@ -67,7 +68,7 @@ const H = (e) => {
67
68
  if (c) {
68
69
  try {
69
70
  const { dateObj: i } = JSON.parse(c);
70
- i && (o.textContent = I(i));
71
+ i && (o.textContent = L(i));
71
72
  } catch {
72
73
  }
73
74
  a.disconnect();
@@ -83,43 +84,33 @@ const H = (e) => {
83
84
  attributes: !0
84
85
  // Watch for changes to attributes
85
86
  }), () => a.disconnect();
86
- }, M = (e, t, n, a) => {
87
- if (e.type !== "click")
88
- return;
89
- const s = e.target, r = s.getAttribute("data-element-id"), o = s.getAttribute("href");
90
- if (o && o !== "#")
91
- return;
92
- const c = t.find((i) => i.id === r);
93
- !c || c.annotationType !== _.Link || c.dest && b(n, c.dest).then((i) => {
94
- a(i);
95
- });
96
87
  };
97
- function P(e, t) {
98
- for (const n of v)
88
+ function H(e, t) {
89
+ for (const n of T)
99
90
  e.addEventListener(n, t);
100
91
  }
101
- function U(e, t) {
102
- for (const n of v)
92
+ function P(e, t) {
93
+ for (const n of T)
103
94
  e.removeEventListener(n, t);
104
95
  }
105
- function V(e) {
96
+ function U(e) {
106
97
  const { id: t, url: n, unsafeUrl: a } = e;
107
98
  new MutationObserver((r, o) => {
108
99
  const c = document.querySelector(`[data-annotation-id="${t}"]`);
109
100
  if (c) {
110
- const i = c.querySelector("a"), p = L((n || a) ?? "", "");
101
+ const i = c.querySelector("a"), p = _((n || a) ?? "", "");
111
102
  i && (i == null || i.setAttribute("target", "_blank"), i == null || i.setAttribute("href", p), i == null || i.setAttribute("rel", "noopener noreferrer")), o.disconnect();
112
103
  }
113
104
  }).observe(document.body, { childList: !0, subtree: !0 });
114
105
  }
115
- function $(e, t, n) {
106
+ function V(e, t, n) {
116
107
  const { rotation: a, scale: s } = t, r = a % 180 === 0;
117
108
  if (e.fieldType === "Btn" && e.pushButton) {
118
109
  const o = e.rect[2] - e.rect[0], c = e.rect[3] - e.rect[1], i = document.createElement("canvas");
119
110
  i.setAttribute("width", ((r ? o : c) * s).toString()), i.setAttribute("height", ((r ? c : o) * s).toString()), n.set(e.id, i);
120
111
  }
121
112
  }
122
- function k(e) {
113
+ function B(e) {
123
114
  var r;
124
115
  let t = e;
125
116
  for (; t.tagName !== "SECTION"; )
@@ -131,14 +122,14 @@ function k(e) {
131
122
  if (s || (s = (r = t.firstChild) == null ? void 0 : r.id), s && t.parentElement) {
132
123
  const o = t.parentElement.querySelector(`[aria-controls="${s}"]`);
133
124
  o && new MutationObserver((i, p) => {
134
- const h = document.querySelectorAll(".popupDate");
135
- h.length > 0 && (h.forEach((m) => {
136
- if (m.innerHTML)
125
+ const b = document.querySelectorAll(".popupDate");
126
+ b.length > 0 && (b.forEach((g) => {
127
+ if (g.innerHTML)
137
128
  return !1;
138
- const N = m.getAttribute("data-l10n-args");
129
+ const N = g.getAttribute("data-l10n-args");
139
130
  if (N) {
140
- const { date: y, time: A } = JSON.parse(N);
141
- y && A && (m.textContent = `${y}, ${A}`);
131
+ const { date: h, time: y } = JSON.parse(N);
132
+ h && y && (g.textContent = `${h}, ${y}`);
142
133
  }
143
134
  }), p.disconnect());
144
135
  }).observe(o, { childList: !0, subtree: !0 });
@@ -154,10 +145,10 @@ function d(e, t, n) {
154
145
  function u(e, t) {
155
146
  return { type: e, data: t };
156
147
  }
157
- async function S(e, t) {
148
+ async function w(e, t) {
158
149
  if (e.dest)
159
150
  if (typeof e.dest == "string") {
160
- const n = await b(t, e.dest);
151
+ const n = await E(t, e.dest);
161
152
  return u(l.INTERNAL_LINK, {
162
153
  referencedPage: n.pageIndex,
163
154
  offset: null
@@ -178,7 +169,7 @@ async function S(e, t) {
178
169
  unsafeUrl: e.unsafeUrl
179
170
  });
180
171
  }
181
- function T(e) {
172
+ function O(e) {
182
173
  for (const t of e.getElementsByTagName("span")) {
183
174
  let n = t.textContent;
184
175
  const a = JSON.parse(t.dataset.l10nArgs ?? "{}");
@@ -188,7 +179,7 @@ function T(e) {
188
179
  t.textContent = n;
189
180
  }
190
181
  }
191
- function w(e) {
182
+ function S(e) {
192
183
  return u(l.FILE_ATTACHMENT, e.file);
193
184
  }
194
185
  function f(e, t) {
@@ -235,27 +226,27 @@ function f(e, t) {
235
226
  });
236
227
  }
237
228
  }
238
- async function D(e, t, n) {
229
+ async function $(e, t, n) {
239
230
  var s;
240
231
  let a = e.target.parentNode;
241
- if (a.tagName === "DIV" && (a = a.firstChild), k(a), typeof a.className != "object")
232
+ if (a.tagName === "DIV" && (a = a.firstChild), B(a), typeof a.className != "object")
242
233
  if (a.className === "linkAnnotation" && e.type === "click") {
243
234
  const r = (s = a.dataset) == null ? void 0 : s.annotationId;
244
235
  if (r) {
245
236
  const o = d("id", r, n);
246
237
  if (o.length)
247
- return await S(o[0], t);
238
+ return await w(o[0], t);
248
239
  }
249
240
  } else if (
250
241
  /* annotation.className.includes('popupAnnotation') || */
251
242
  a.className.includes("textAnnotation")
252
243
  )
253
- T(a);
244
+ O(a);
254
245
  else if (a.className.includes("fileAttachmentAnnotation")) {
255
- T(a);
246
+ O(a);
256
247
  const r = a.dataset.annotationId;
257
248
  if (r && e.type === "dblclick")
258
- return w(d("id", r, n)[0]);
249
+ return S(d("id", r, n)[0]);
259
250
  } else if (a.className.includes("textWidgetAnnotation") && e.type === "input") {
260
251
  let r = a.getElementsByTagName("input")[0];
261
252
  return r || (r = a.getElementsByTagName("textarea")[0]), f(r);
@@ -296,11 +287,10 @@ async function D(e, t, n) {
296
287
  }
297
288
  }
298
289
  export {
299
- D as annotationEventsHandler,
300
- H as annotationsEvents,
301
- P as bindLayerEvents,
302
- V as handleAnnotationLink,
303
- $ as handleAnnotationWidget,
304
- M as handleClick,
305
- U as unbindLayerEvents
290
+ $ as annotationEventsHandler,
291
+ M as annotationsEvents,
292
+ H as bindLayerEvents,
293
+ U as handleAnnotationLink,
294
+ V as handleAnnotationWidget,
295
+ P as unbindLayerEvents
306
296
  };
@@ -0,0 +1,22 @@
1
+ function u(t) {
2
+ if (Math.floor(t) === t)
3
+ return [t, 1];
4
+ const e = 1 / t, s = 8;
5
+ if (e > s)
6
+ return [1, s];
7
+ if (Math.floor(e) === e)
8
+ return [1, e];
9
+ const r = t > 1 ? e : t;
10
+ let i = 0, n = 1, o = 1, l = 1;
11
+ for (; ; ) {
12
+ const c = i + o, f = n + l;
13
+ if (f > s)
14
+ break;
15
+ r <= c / f ? (o = c, l = f) : (i = c, n = f);
16
+ }
17
+ let a;
18
+ return r - i / n < o / l - r ? a = r === t ? [i, n] : [n, i] : a = r === t ? [o, l] : [l, o], a;
19
+ }
20
+ export {
21
+ u as approximateFraction
22
+ };
@@ -0,0 +1,84 @@
1
+ function g(e, o) {
2
+ !e || typeof e != "object" || Object.entries(e).forEach(([d, i]) => {
3
+ if (i == null)
4
+ return;
5
+ const s = d.replace(/([A-Z])/g, "-$1").toLowerCase(), n = [
6
+ "width",
7
+ "height",
8
+ "top",
9
+ "right",
10
+ "bottom",
11
+ "left",
12
+ "margin",
13
+ "margin-top",
14
+ "margin-right",
15
+ "margin-bottom",
16
+ "margin-left",
17
+ "padding",
18
+ "padding-top",
19
+ "padding-right",
20
+ "padding-bottom",
21
+ "padding-left",
22
+ "border-width",
23
+ "border-top-width",
24
+ "border-right-width",
25
+ "border-bottom-width",
26
+ "border-left-width",
27
+ "font-size",
28
+ "line-height",
29
+ "letter-spacing",
30
+ "word-spacing",
31
+ "min-width",
32
+ "min-height",
33
+ "max-width",
34
+ "max-height",
35
+ "flex-basis",
36
+ "grid-gap",
37
+ "grid-row-gap",
38
+ "grid-column-gap"
39
+ ];
40
+ let t;
41
+ typeof i == "number" && i !== 0 ? t = n.includes(s) ? `${i}px` : String(i) : t = String(i), o.style.setProperty(s, t);
42
+ });
43
+ }
44
+ const f = (e, o, d, i, s) => {
45
+ let n = "center";
46
+ switch (i) {
47
+ case 90:
48
+ n = `${e.width / 2}px ${e.width / 2}px`;
49
+ break;
50
+ case -90:
51
+ case 270:
52
+ n = `${e.height / 2}px ${e.height / 2}px`;
53
+ break;
54
+ default:
55
+ n = "center";
56
+ }
57
+ const t = document.createElement("div");
58
+ t.id = "parent-element", t.style.width = `${e.width}px`, t.style.height = `${e.height}px`, t.style.setProperty("--scale-factor", s.toString()), t.style.setProperty("--rotation", i.toString()), t.style.setProperty("--transform-origin", n), t.style.left = "-99999px", t.style.visibility = "hidden", t.style.position = "absolute";
59
+ const l = document.createElement("div");
60
+ l.style.position = "relative", l.style.width = "100%", l.style.height = "100%", t.appendChild(l);
61
+ let r;
62
+ if (d instanceof HTMLElement)
63
+ r = d.cloneNode(!0), l.appendChild(r);
64
+ else {
65
+ const p = d.props;
66
+ r = document.createElement("div"), p.style && g(p.style, r), p.className && (r.className = p.className), l.appendChild(r);
67
+ }
68
+ o.appendChild(t);
69
+ const c = t.getBoundingClientRect(), h = r.getBoundingClientRect();
70
+ o.removeChild(t);
71
+ const a = {
72
+ top: o.clientHeight / 2,
73
+ left: o.clientWidth / 2
74
+ };
75
+ return {
76
+ left: h.left - c.left - a.left,
77
+ top: h.top - c.top - a.top,
78
+ width: h.width,
79
+ height: h.height
80
+ };
81
+ };
82
+ export {
83
+ f as getElementPagePosition
84
+ };
@@ -1,5 +1,5 @@
1
1
  const a = (i, h, l, o, n) => {
2
- const c = l.height * o, s = l.width * o, y = l.top * o, w = l.left * o, d = {
2
+ const c = l.height * o, s = l.width * o, y = l.bottom * o, m = l.left * o, d = {
3
3
  width: n % 180 === 90 ? i.height : i.width,
4
4
  height: n % 180 === 90 ? i.width : i.height
5
5
  }, r = {
@@ -8,16 +8,16 @@ const a = (i, h, l, o, n) => {
8
8
  }, t = document.createElement("div");
9
9
  t.style.width = `${d.width}px`, t.style.height = `${d.height}px`, t.style.position = "absolute", t.style.transform = `rotate(${n}deg)`, t.style.transformOrigin = "center center", t.style.visibility = "hidden", t.style.left = "-99999px";
10
10
  const e = document.createElement("div");
11
- e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${w}px`, t.appendChild(e), h.appendChild(t);
12
- const p = t.getBoundingClientRect(), g = e.getBoundingClientRect();
11
+ e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${m}px`, t.appendChild(e), h.appendChild(t);
12
+ const g = t.getBoundingClientRect(), p = e.getBoundingClientRect();
13
13
  h.removeChild(t);
14
14
  const u = {
15
15
  top: h.clientHeight / 2,
16
16
  left: h.clientWidth / 2
17
17
  };
18
18
  return {
19
- leftInPage: g.left - p.left - u.left + r.width / 2,
20
- topInPage: g.top - p.top - u.top + r.height / 2
19
+ leftInPage: p.left - g.left - u.left + r.width / 2,
20
+ topInPage: p.top - g.top - u.top + r.height / 2
21
21
  };
22
22
  };
23
23
  export {
@@ -1,23 +1,24 @@
1
- import { SCROLL_BAR_WIDTH as a, PAGE_PADDING as f } from "./constants.js";
2
- import { ViewMode as u, ZoomLevel as r } from "./types.js";
3
- const l = (o, t, m, e, A, c) => {
1
+ import { SCROLL_BAR_WIDTH as n, PAGE_PADDING as f } from "./constants.js";
2
+ import { ViewMode as i, ZoomLevel as r } from "./types.js";
3
+ import "../th_TH-d627cd51.js";
4
+ const D = (o, t, a, e, A, c) => {
4
5
  if (typeof o == "number")
5
6
  return o;
6
- const n = c === u.DUAL_PAGE ? 2 * e : e;
7
+ const m = c === i.DUAL_PAGE ? 2 * e : e;
7
8
  switch (o) {
8
9
  case r.PAGE_FIT:
9
10
  const s = Math.min(
10
- (t - a) / n,
11
- (m - f) / A
11
+ (t - n) / m,
12
+ (a - f) / A
12
13
  );
13
14
  return Math.floor(s * 100);
14
15
  case r.PAGE_WIDTH:
15
- return Math.floor((t - a) / n * 100);
16
+ return Math.floor((t - n) / m * 100);
16
17
  case r.ACTUAL:
17
18
  default:
18
19
  return 100;
19
20
  }
20
21
  };
21
22
  export {
22
- l as getZoomLevel
23
+ D as getZoomLevel
23
24
  };