@m3ui-vue/m3ui-vue 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/dist/API.md +2776 -351
  2. package/dist/MButton-CuNzpoxm.js +172 -0
  3. package/dist/MButton-CuNzpoxm.js.map +1 -0
  4. package/dist/MDialog-HxEL-m58.js +173 -0
  5. package/dist/MDialog-HxEL-m58.js.map +1 -0
  6. package/dist/MIconButton-DoNotQ9v.js +282 -0
  7. package/dist/MIconButton-DoNotQ9v.js.map +1 -0
  8. package/dist/MListItem-DnPtv-hY.js +824 -0
  9. package/dist/MListItem-DnPtv-hY.js.map +1 -0
  10. package/dist/MLoadingIndicator-BQMNX6Dx.js +115 -0
  11. package/dist/MLoadingIndicator-BQMNX6Dx.js.map +1 -0
  12. package/dist/MMenuItem-Bih0h4-n.js +604 -0
  13. package/dist/MMenuItem-Bih0h4-n.js.map +1 -0
  14. package/dist/MProgressBar-BCoruxA-.js +184 -0
  15. package/dist/MProgressBar-BCoruxA-.js.map +1 -0
  16. package/dist/MSeekBar-LURE1Ah7.js +435 -0
  17. package/dist/MSeekBar-LURE1Ah7.js.map +1 -0
  18. package/dist/MSegmentedButton-DL9JtJFX.js +65 -0
  19. package/dist/MSegmentedButton-DL9JtJFX.js.map +1 -0
  20. package/dist/MSlider-_J4IS2_z.js +691 -0
  21. package/dist/MSlider-_J4IS2_z.js.map +1 -0
  22. package/dist/MSpinner-BhkMYKOM.js +65 -0
  23. package/dist/MSpinner-BhkMYKOM.js.map +1 -0
  24. package/dist/MTextField-CkzwNBWS.js +296 -0
  25. package/dist/MTextField-CkzwNBWS.js.map +1 -0
  26. package/dist/MTooltip-B67ZDSGp.js +756 -0
  27. package/dist/MTooltip-B67ZDSGp.js.map +1 -0
  28. package/dist/_storageKeys-CYXsUBwK.js +18 -0
  29. package/dist/_storageKeys-CYXsUBwK.js.map +1 -0
  30. package/dist/_useEscapeStack-CjndQhqg.js +19 -0
  31. package/dist/_useEscapeStack-CjndQhqg.js.map +1 -0
  32. package/dist/api.json +1 -1
  33. package/dist/chart.js +1 -1
  34. package/dist/code-editor.js +1 -1
  35. package/dist/components/MAudioPlayer.vue.d.ts +115 -0
  36. package/dist/components/MBadge.vue.d.ts +1 -1
  37. package/dist/components/MBottomSheetScaffold.vue.d.ts +1 -1
  38. package/dist/components/MBox.vue.d.ts +1 -1
  39. package/dist/components/MButton.vue.d.ts +1 -1
  40. package/dist/components/MConfirmDialog.vue.d.ts +1 -1
  41. package/dist/components/MCopyButton.vue.d.ts +2 -2
  42. package/dist/components/MDataTable.vue.d.ts +2 -2
  43. package/dist/components/MDialog.vue.d.ts +2 -2
  44. package/dist/components/MDivider.vue.d.ts +1 -1
  45. package/dist/components/MDragHandle.vue.d.ts +1 -1
  46. package/dist/components/MDrawCanvas.vue.d.ts +148 -0
  47. package/dist/components/MDrawLayers.vue.d.ts +3 -0
  48. package/dist/components/MDrawToolbar.vue.d.ts +34 -0
  49. package/dist/components/MExportButton.vue.d.ts +1 -1
  50. package/dist/components/MFab.vue.d.ts +2 -2
  51. package/dist/components/MFabMenu.vue.d.ts +2 -2
  52. package/dist/components/MFixed.vue.d.ts +1 -1
  53. package/dist/components/MFlex.vue.d.ts +2 -2
  54. package/dist/components/MFloorPlan.vue.d.ts +160 -0
  55. package/dist/components/MFlow.vue.d.ts +305 -0
  56. package/dist/components/MFlowControls.vue.d.ts +33 -0
  57. package/dist/components/MFlowHandle.vue.d.ts +16 -0
  58. package/dist/components/MFlowMinimap.vue.d.ts +22 -0
  59. package/dist/components/MFlowNode.vue.d.ts +35 -0
  60. package/dist/components/MGantt.vue.d.ts +141 -0
  61. package/dist/components/MGanttControls.vue.d.ts +32 -0
  62. package/dist/components/MIconButton.vue.d.ts +3 -1
  63. package/dist/components/MImageCropper.vue.d.ts +110 -0
  64. package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
  65. package/dist/components/MLightbox.vue.d.ts +2 -2
  66. package/dist/components/MList.vue.d.ts +1 -1
  67. package/dist/components/MLoadingOverlay.vue.d.ts +1 -1
  68. package/dist/components/MMapControl.vue.d.ts +1 -1
  69. package/dist/components/MMapSearch.vue.d.ts +1 -1
  70. package/dist/components/MMaskField.vue.d.ts +12 -1
  71. package/dist/components/MMenu.vue.d.ts +1 -1
  72. package/dist/components/MNavigationDrawer.vue.d.ts +1 -1
  73. package/dist/components/MNumberField.vue.d.ts +11 -2
  74. package/dist/components/MPdfViewer.vue.d.ts +174 -0
  75. package/dist/components/MPullToRefresh.vue.d.ts +1 -1
  76. package/dist/components/MResourceTimeline.vue.d.ts +149 -0
  77. package/dist/components/MScheduler.vue.d.ts +3 -3
  78. package/dist/components/MScheme.vue.d.ts +1 -1
  79. package/dist/components/MSearchField.vue.d.ts +1 -1
  80. package/dist/components/MSeekBar.vue.d.ts +1 -1
  81. package/dist/components/MSimpleCarousel.vue.d.ts +1 -1
  82. package/dist/components/MSkeleton.vue.d.ts +1 -1
  83. package/dist/components/MSlider.vue.d.ts +2 -2
  84. package/dist/components/MSparkline.vue.d.ts +1 -1
  85. package/dist/components/MSplitter.vue.d.ts +1 -1
  86. package/dist/components/MStack.vue.d.ts +2 -2
  87. package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
  88. package/dist/components/MSwitch.vue.d.ts +1 -1
  89. package/dist/components/MTable.vue.d.ts +1 -1
  90. package/dist/components/MTagInput.vue.d.ts +12 -1
  91. package/dist/components/MTextField.vue.d.ts +13 -2
  92. package/dist/components/MToolbar.vue.d.ts +1 -1
  93. package/dist/components/MTree.vue.d.ts +2 -2
  94. package/dist/components/MVideoPlayer.vue.d.ts +253 -0
  95. package/dist/components/MVirtualTable.vue.d.ts +1 -1
  96. package/dist/components/MWindow.vue.d.ts +3 -3
  97. package/dist/components/_MFlowEdge.vue.d.ts +9 -0
  98. package/dist/components/_MFlowEdgeLabel.vue.d.ts +9 -0
  99. package/dist/components/_MFlowNodeShell.vue.d.ts +9 -0
  100. package/dist/components/_MPdfPage.vue.d.ts +76 -0
  101. package/dist/components/_MTimeBackground.vue.d.ts +14 -0
  102. package/dist/components/_MTimeHeader.vue.d.ts +20 -0
  103. package/dist/composables/_flowPanel.d.ts +2 -0
  104. package/dist/composables/_flowSlot.d.ts +5 -0
  105. package/dist/composables/_ganttTime.d.ts +41 -0
  106. package/dist/composables/_useTimeAxis.d.ts +90 -0
  107. package/dist/composables/drawGeometry.d.ts +119 -0
  108. package/dist/composables/flowFormats.d.ts +79 -0
  109. package/dist/composables/flowLayout.d.ts +45 -0
  110. package/dist/composables/flowPaths.d.ts +53 -0
  111. package/dist/composables/ganttFormats.d.ts +52 -0
  112. package/dist/composables/ganttSchedule.d.ts +99 -0
  113. package/dist/composables/useDrawing.d.ts +44 -0
  114. package/dist/composables/useFlow.d.ts +266 -0
  115. package/dist/composables/useGantt.d.ts +87 -0
  116. package/dist/composables/useLocale.d.ts +163 -0
  117. package/dist/composables/useMediaPlayer.d.ts +101 -0
  118. package/dist/composables/usePdf.d.ts +119 -0
  119. package/dist/composables/useResourceTimeline.d.ts +70 -0
  120. package/dist/draw.d.ts +7 -0
  121. package/dist/draw.js +1700 -0
  122. package/dist/draw.js.map +1 -0
  123. package/dist/flow.d.ts +14 -0
  124. package/dist/flow.js +3542 -0
  125. package/dist/flow.js.map +1 -0
  126. package/dist/flowPaths-CUc6X373.js +161 -0
  127. package/dist/flowPaths-CUc6X373.js.map +1 -0
  128. package/dist/gantt.d.ts +12 -0
  129. package/dist/gantt.js +3575 -0
  130. package/dist/gantt.js.map +1 -0
  131. package/dist/index.d.ts +4 -0
  132. package/dist/locales/index.js +1148 -7
  133. package/dist/locales/index.js.map +1 -1
  134. package/dist/m3ui-vue.css +1 -1
  135. package/dist/m3ui.js +7286 -7654
  136. package/dist/m3ui.js.map +1 -1
  137. package/dist/map.js +113 -108
  138. package/dist/map.js.map +1 -1
  139. package/dist/media.d.ts +5 -0
  140. package/dist/media.js +1311 -0
  141. package/dist/media.js.map +1 -0
  142. package/dist/pdf.d.ts +4 -0
  143. package/dist/pdf.js +1871 -0
  144. package/dist/pdf.js.map +1 -0
  145. package/dist/rich-text-editor.js +28 -26
  146. package/dist/rich-text-editor.js.map +1 -1
  147. package/dist/styles.css +1 -1
  148. package/dist/{useLocale-JYxDDeXC.js → useLocale-BpGxplLV.js} +165 -2
  149. package/dist/useLocale-BpGxplLV.js.map +1 -0
  150. package/dist/{useThemeTokens-y0HZpyhL.js → useThemeTokens-DQQcaWbE.js} +40 -54
  151. package/dist/useThemeTokens-DQQcaWbE.js.map +1 -0
  152. package/package.json +29 -5
  153. package/src/__tests__/MAudioPlayer.test.ts +75 -0
  154. package/src/__tests__/MDrawCanvas.test.ts +110 -0
  155. package/src/__tests__/MFloorPlan.test.ts +97 -0
  156. package/src/__tests__/MFlow.test.ts +575 -0
  157. package/src/__tests__/MGantt.test.ts +130 -0
  158. package/src/__tests__/MImageCropper.test.ts +89 -0
  159. package/src/__tests__/MPdfViewer.test.ts +235 -0
  160. package/src/__tests__/MResourceTimeline.test.ts +102 -0
  161. package/src/__tests__/MVideoPlayer.test.ts +201 -0
  162. package/src/__tests__/drawGeometry.test.ts +58 -0
  163. package/src/__tests__/fieldExpose.test.ts +30 -0
  164. package/src/__tests__/flowFormats.test.ts +185 -0
  165. package/src/__tests__/flowLayout.test.ts +113 -0
  166. package/src/__tests__/ganttFormats.test.ts +76 -0
  167. package/src/__tests__/ganttSchedule.test.ts +136 -0
  168. package/src/__tests__/pdfMock.ts +83 -0
  169. package/src/__tests__/useMediaPlayer.test.ts +182 -0
  170. package/src/__tests__/usePdf.test.ts +102 -0
  171. package/src/components/MAudioPlayer.vue +319 -0
  172. package/src/components/MDrawCanvas.vue +813 -0
  173. package/src/components/MDrawLayers.vue +114 -0
  174. package/src/components/MDrawToolbar.vue +171 -0
  175. package/src/components/MFloorPlan.vue +581 -0
  176. package/src/components/MFlow.vue +2049 -0
  177. package/src/components/MFlowControls.vue +110 -0
  178. package/src/components/MFlowHandle.vue +60 -0
  179. package/src/components/MFlowMinimap.vue +134 -0
  180. package/src/components/MFlowNode.vue +98 -0
  181. package/src/components/MGantt.vue +1609 -0
  182. package/src/components/MGanttControls.vue +77 -0
  183. package/src/components/MIconButton.vue +3 -1
  184. package/src/components/MImageCropper.vue +507 -0
  185. package/src/components/MMaskField.vue +13 -0
  186. package/src/components/MNumberField.vue +13 -0
  187. package/src/components/MPdfViewer.vue +1269 -0
  188. package/src/components/MResourceTimeline.vue +1020 -0
  189. package/src/components/MTagInput.vue +13 -0
  190. package/src/components/MTextField.vue +16 -0
  191. package/src/components/MVideoPlayer.vue +839 -0
  192. package/src/components/_MFlowEdge.vue +100 -0
  193. package/src/components/_MFlowEdgeLabel.vue +56 -0
  194. package/src/components/_MFlowNodeShell.vue +111 -0
  195. package/src/components/_MPdfPage.vue +456 -0
  196. package/src/components/_MTimeBackground.vue +16 -0
  197. package/src/components/_MTimeHeader.vue +31 -0
  198. package/src/composables/_flowPanel.ts +13 -0
  199. package/src/composables/_flowSlot.ts +6 -0
  200. package/src/composables/_ganttTime.ts +200 -0
  201. package/src/composables/_useTimeAxis.ts +224 -0
  202. package/src/composables/drawGeometry.ts +405 -0
  203. package/src/composables/flowFormats.ts +916 -0
  204. package/src/composables/flowLayout.ts +297 -0
  205. package/src/composables/flowPaths.ts +239 -0
  206. package/src/composables/ganttFormats.ts +366 -0
  207. package/src/composables/ganttSchedule.ts +403 -0
  208. package/src/composables/useDrawing.ts +53 -0
  209. package/src/composables/useFlow.ts +250 -0
  210. package/src/composables/useGantt.ts +92 -0
  211. package/src/composables/useLocale.ts +328 -0
  212. package/src/composables/useMediaPlayer.ts +406 -0
  213. package/src/composables/usePdf.ts +456 -0
  214. package/src/composables/useResourceTimeline.ts +76 -0
  215. package/src/draw.ts +25 -0
  216. package/src/flow.ts +26 -0
  217. package/src/gantt.ts +12 -0
  218. package/src/index.ts +4 -0
  219. package/src/locales/de.ts +163 -0
  220. package/src/locales/es.ts +163 -0
  221. package/src/locales/fr.ts +163 -0
  222. package/src/locales/ja.ts +163 -0
  223. package/src/locales/ko.ts +163 -0
  224. package/src/locales/pt.ts +163 -0
  225. package/src/locales/zh.ts +163 -0
  226. package/src/media.ts +5 -0
  227. package/src/pdf.ts +15 -0
  228. package/dist/MMenuItem-D4Gx_l3F.js +0 -929
  229. package/dist/MMenuItem-D4Gx_l3F.js.map +0 -1
  230. package/dist/MSlider-Dx_S3vJ9.js +0 -1506
  231. package/dist/MSlider-Dx_S3vJ9.js.map +0 -1
  232. package/dist/MTextField-Bz8JIsnl.js +0 -633
  233. package/dist/MTextField-Bz8JIsnl.js.map +0 -1
  234. package/dist/useLocale-JYxDDeXC.js.map +0 -1
  235. package/dist/useThemeTokens-y0HZpyhL.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf.js","names":["$attrs"],"sources":["../src/composables/usePdf.ts","../src/components/_MPdfPage.vue","../src/components/_MPdfPage.vue","../src/components/MPdfViewer.vue","../src/components/MPdfViewer.vue"],"sourcesContent":["import { computed, getCurrentScope, onScopeDispose, ref, shallowRef, toValue, watch, type MaybeRefOrGetter, type Ref, type ShallowRef } from 'vue'\nimport type * as Pdfjs from 'pdfjs-dist'\n\n/** The `pdfjs-dist` module */\nexport type PdfjsModule = typeof import('pdfjs-dist')\nexport type PdfDocument = Pdfjs.PDFDocumentProxy\nexport type PdfPage = Pdfjs.PDFPageProxy\n\n/** What `usePdf` loads: a URL, the file's bytes, or a `File`/`Blob` (an upload) */\nexport type PdfSource = string | URL | Uint8Array | ArrayBuffer | Blob\n\nexport interface PdfOutlineItem {\n title: string\n /** 1-based page it points to (undefined for an external link or a destination that can't be resolved) */\n page?: number\n /** Where on that page, in PDF points from the bottom, when the destination says */\n top?: number\n /** An external link */\n url?: string\n children: PdfOutlineItem[]\n}\n\nexport interface PdfSearchMatch {\n /** 1-based page */\n page: number\n /** Index of the match on its page */\n index: number\n /** Character offsets in the page's text (see `pageText`) */\n start: number\n end: number\n /** The text around it, for a results list */\n context: string\n}\n\nexport interface PdfMetadata {\n title?: string\n author?: string\n subject?: string\n creator?: string\n producer?: string\n creationDate?: Date\n modificationDate?: Date\n}\n\n/** A page's text as `usePdf` indexes it: its text items joined, and where each item starts */\nexport interface PdfPageText {\n text: string\n /** Start offset of each text item (the text layer's spans, in order) */\n starts: number[]\n}\n\nexport interface PdfOptions {\n /** A password to try first (the `needsPassword` flow handles the rest) */\n password?: MaybeRefOrGetter<string | undefined>\n /** Send cookies with a cross-origin URL */\n withCredentials?: boolean\n /**\n * The pdf.js worker's URL (with Vite: `import workerSrc from 'pdfjs-dist/build/pdf.worker.min.mjs?url'`), or\n * set it once for the app with `setPdfWorker()`. Without one, pdf.js runs on the main thread: it works, but\n * parsing a big file blocks the page meanwhile\n */\n workerSrc?: string\n}\n\nexport interface PdfState {\n /** The pdf.js document, once loaded */\n doc: ShallowRef<PdfDocument | null>\n /** The `pdfjs-dist` module, loaded with the first document */\n pdfjs: ShallowRef<PdfjsModule | null>\n loading: Readonly<Ref<boolean>>\n /** Download progress, 0 to 1 (0 while the size is unknown) */\n progress: Readonly<Ref<number>>\n error: Readonly<Ref<Error | null>>\n /** The file is encrypted: call `submitPassword()` */\n needsPassword: Readonly<Ref<boolean>>\n /** The last password was wrong */\n wrongPassword: Readonly<Ref<boolean>>\n submitPassword: (password: string) => void\n numPages: Readonly<Ref<number>>\n /**\n * Each page's size in PDF points at zoom 1, with its own rotation (index 0 = page 1). Every page starts as the\n * first one's size and gets its own as the pages are read, in the background\n */\n pageSizes: Readonly<Ref<{ width: number; height: number }[]>>\n outline: Readonly<Ref<PdfOutlineItem[]>>\n metadata: Readonly<Ref<PdfMetadata>>\n getPage: (page: number) => Promise<PdfPage>\n /** A page's text (cached) */\n pageText: (page: number) => Promise<PdfPageText>\n /** Finds text in every page (case and accent insensitive unless `caseSensitive`) */\n search: (query: string, options?: { caseSensitive?: boolean; signal?: AbortSignal }) => Promise<PdfSearchMatch[]>\n /** A picture of a page `width` CSS pixels wide, as an object URL (cached; revoked when the document changes) */\n thumbnail: (page: number, width?: number) => Promise<string>\n /** Resolves a link destination (a name or an explicit array) to a page and a position */\n resolveDest: (dest: unknown) => Promise<{ page: number; top?: number } | null>\n /** The file's bytes */\n getData: () => Promise<Uint8Array>\n /** Saves the file */\n download: (fileName?: string) => Promise<void>\n /** Opens the browser's print dialog for the file */\n print: () => Promise<void>\n}\n\nlet globalWorkerSrc: string | undefined\n\n/** Sets the pdf.js worker URL for every `usePdf`/`MPdfViewer` of the app (see `PdfOptions.workerSrc`) */\nexport function setPdfWorker(src: string) {\n globalWorkerSrc = src\n}\n\nlet pdfjsPromise: Promise<PdfjsModule> | null = null\n\n/** Internal: loads pdf.js once, with its worker (or, without one, the worker's code on the main thread) */\nexport function loadPdfjs(workerSrc?: string): Promise<PdfjsModule> {\n pdfjsPromise ??= (async () => {\n const pdfjs = await import('pdfjs-dist')\n const src = workerSrc ?? globalWorkerSrc\n if (src) pdfjs.GlobalWorkerOptions.workerSrc = src\n // @ts-ignore: the worker module has no types (importing it registers globalThis.pdfjsWorker)\n else if (!pdfjs.GlobalWorkerOptions.workerSrc) await import('pdfjs-dist/build/pdf.worker.min.mjs')\n return pdfjs\n })()\n return pdfjsPromise\n}\n\n// Case and accent folding that keeps one character per character, so offsets stay valid\nfunction fold(s: string, caseSensitive: boolean) {\n let out = ''\n for (const c of s) {\n const base = c.normalize('NFD').replace(/\\p{M}/gu, '')\n const one = base.length === 1 ? base : c\n out += caseSensitive ? one : one.toLowerCase()\n }\n return out\n}\n\nfunction parseDate(pdfjs: PdfjsModule, v: unknown) {\n return typeof v === 'string' ? pdfjs.PDFDateString.toDateObject(v) ?? undefined : undefined\n}\n\n/**\n * Loads a PDF with pdf.js and exposes what a viewer needs: pages and their sizes, the outline, metadata, text\n * search, thumbnails, download and print. `MPdfViewer` is built on it; use it for a viewer of your own, a\n * thumbnail grid, or a search over a document. Reactive to `src`: a new one replaces the document.\n *\n * ```ts\n * const pdf = usePdf(() => file.value)\n * watchEffect(async () => { if (pdf.doc.value) cover.value = await pdf.thumbnail(1, 160) })\n * const hits = await pdf.search('invoice')\n * ```\n */\nexport function usePdf(src: MaybeRefOrGetter<PdfSource | null | undefined>, options: PdfOptions = {}): PdfState {\n const doc = shallowRef<PdfDocument | null>(null)\n const pdfjs = shallowRef<PdfjsModule | null>(null)\n const loading = ref(false)\n const progress = ref(0)\n const error = shallowRef<Error | null>(null)\n const needsPassword = ref(false)\n const wrongPassword = ref(false)\n const pageSizes = shallowRef<{ width: number; height: number }[]>([])\n const outline = shallowRef<PdfOutlineItem[]>([])\n const metadata = shallowRef<PdfMetadata>({})\n const numPages = computed(() => doc.value?.numPages ?? 0)\n\n let task: Pdfjs.PDFDocumentLoadingTask | null = null\n let passwordCallback: ((pw: string) => void) | null = null\n let generation = 0\n const texts = new Map<number, Promise<PdfPageText>>()\n const thumbs = new Map<string, Promise<string>>()\n\n function reset() {\n for (const p of thumbs.values()) p.then((url) => URL.revokeObjectURL(url), () => {})\n thumbs.clear()\n texts.clear()\n const old = task\n task = null\n old?.destroy()\n doc.value = null\n pageSizes.value = []\n outline.value = []\n metadata.value = {}\n needsPassword.value = false\n wrongPassword.value = false\n passwordCallback = null\n }\n\n async function load(source: PdfSource | null | undefined) {\n const gen = ++generation\n reset()\n error.value = null\n progress.value = 0\n if (!source || typeof window === 'undefined') {\n loading.value = false\n return\n }\n loading.value = true\n try {\n const lib = await loadPdfjs(options.workerSrc)\n if (gen !== generation) return\n pdfjs.value = lib\n let data: Uint8Array | undefined\n let url: string | undefined\n if (typeof source === 'string' || source instanceof URL) url = String(source)\n else if (source instanceof Blob) data = new Uint8Array(await source.arrayBuffer())\n // pdf.js transfers the buffer to its worker: give it a copy, so the caller's stays usable\n else data = new Uint8Array(source instanceof ArrayBuffer ? source.slice(0) : source.slice())\n if (gen !== generation) return\n task = lib.getDocument({ url, data, password: toValue(options.password), withCredentials: options.withCredentials })\n task.onProgress = ({ loaded, total }: { loaded: number; total: number }) => {\n if (gen === generation && total) progress.value = Math.min(1, loaded / total)\n }\n task.onPassword = (update: (pw: string) => void, reason: number) => {\n if (gen !== generation) return\n passwordCallback = update\n wrongPassword.value = reason === lib.PasswordResponses.INCORRECT_PASSWORD\n needsPassword.value = true\n }\n const mine = task\n const d = await mine.promise\n if (gen !== generation) {\n mine.destroy()\n return\n }\n needsPassword.value = false\n wrongPassword.value = false\n progress.value = 1\n const first = (await d.getPage(1)).getViewport({ scale: 1 })\n pageSizes.value = Array.from({ length: d.numPages }, () => ({ width: first.width, height: first.height }))\n doc.value = d\n loading.value = false\n readSizes(d, gen)\n readOutline(d, gen)\n readMetadata(d, lib, gen)\n } catch (e) {\n if (gen !== generation) return\n error.value = e instanceof Error ? e : new Error(String(e))\n loading.value = false\n }\n }\n\n // Every page's own size, a batch at a time so a long document lays out right without blocking anything\n async function readSizes(d: PdfDocument, gen: number) {\n const sizes = pageSizes.value.slice()\n let changed = false\n for (let i = 2; i <= d.numPages; i++) {\n if (gen !== generation) return\n const v = (await d.getPage(i)).getViewport({ scale: 1 })\n const s = sizes[i - 1]!\n if (s.width !== v.width || s.height !== v.height) {\n sizes[i - 1] = { width: v.width, height: v.height }\n changed = true\n }\n if (changed && (i % 25 === 0 || i === d.numPages)) {\n pageSizes.value = sizes.slice()\n changed = false\n }\n }\n }\n\n async function resolveDest(dest: unknown): Promise<{ page: number; top?: number } | null> {\n const d = doc.value\n if (!d || !dest) return null\n try {\n const explicit = typeof dest === 'string' ? await d.getDestination(dest) : (dest as unknown[])\n if (!Array.isArray(explicit)) return null\n const ref = explicit[0]\n const index = typeof ref === 'number' ? ref : await d.getPageIndex(ref as Parameters<PdfDocument['getPageIndex']>[0])\n // [ref, { name: 'XYZ' }, left, top, zoom] or [ref, { name: 'FitH' }, top]\n const kind = (explicit[1] as { name?: string } | undefined)?.name\n const top = kind === 'XYZ' ? explicit[3] : kind === 'FitH' || kind === 'FitBH' ? explicit[2] : null\n return { page: index + 1, top: typeof top === 'number' ? top : undefined }\n } catch {\n return null\n }\n }\n\n async function readOutline(d: PdfDocument, gen: number) {\n const raw = await d.getOutline().catch(() => null)\n if (!raw || gen !== generation) return\n type Raw = { title: string; dest: unknown; url: string | null; items: Raw[] }\n const walk = async (items: Raw[]): Promise<PdfOutlineItem[]> =>\n Promise.all(items.map(async (it) => {\n const at = it.dest ? await resolveDest(it.dest) : null\n return { title: it.title, page: at?.page, top: at?.top, url: it.url ?? undefined, children: await walk(it.items ?? []) }\n }))\n const tree = await walk(raw as Raw[])\n if (gen === generation) outline.value = tree\n }\n\n async function readMetadata(d: PdfDocument, lib: PdfjsModule, gen: number) {\n const m = await d.getMetadata().catch(() => null)\n if (!m || gen !== generation) return\n const info = m.info as Record<string, unknown>\n const str = (v: unknown) => (typeof v === 'string' && v.trim() ? v : undefined)\n metadata.value = {\n title: str(m.metadata?.get('dc:title')) ?? str(info.Title),\n author: str(m.metadata?.get('dc:creator')) ?? str(info.Author),\n subject: str(info.Subject),\n creator: str(info.Creator),\n producer: str(info.Producer),\n creationDate: parseDate(lib, info.CreationDate),\n modificationDate: parseDate(lib, info.ModDate),\n }\n }\n\n async function getPage(n: number) {\n const d = doc.value\n if (!d) throw new Error('No document loaded')\n return d.getPage(n)\n }\n\n function pageText(n: number): Promise<PdfPageText> {\n let p = texts.get(n)\n if (!p) {\n p = getPage(n).then(async (page) => {\n const content = await page.getTextContent()\n let text = ''\n const starts: number[] = []\n for (const item of content.items) {\n if (!('str' in item)) continue\n starts.push(text.length)\n text += item.str\n // A line break reads as a space, so a phrase split across lines is still found\n if (item.hasEOL) text += ' '\n }\n return { text, starts }\n })\n texts.set(n, p)\n }\n return p\n }\n\n async function search(query: string, opts: { caseSensitive?: boolean; signal?: AbortSignal } = {}) {\n const q = fold(query.trim(), !!opts.caseSensitive)\n const out: PdfSearchMatch[] = []\n if (!q || !doc.value) return out\n for (let n = 1; n <= numPages.value; n++) {\n if (opts.signal?.aborted) break\n const { text } = await pageText(n)\n const hay = fold(text, !!opts.caseSensitive)\n let index = 0\n for (let at = hay.indexOf(q); at >= 0; at = hay.indexOf(q, at + q.length)) {\n const a = Math.max(0, at - 40)\n const b = Math.min(text.length, at + q.length + 40)\n out.push({ page: n, index: index++, start: at, end: at + q.length, context: (a ? '…' : '') + text.slice(a, b).trim() + (b < text.length ? '…' : '') })\n }\n }\n return out\n }\n\n function thumbnail(n: number, width = 160): Promise<string> {\n const ratio = typeof window !== 'undefined' ? Math.min(2, window.devicePixelRatio || 1) : 1\n const key = `${n}@${width}`\n let p = thumbs.get(key)\n if (!p) {\n p = getPage(n).then(async (page) => {\n const base = page.getViewport({ scale: 1 })\n const viewport = page.getViewport({ scale: (width / base.width) * ratio })\n const canvas = document.createElement('canvas')\n canvas.width = Math.ceil(viewport.width)\n canvas.height = Math.ceil(viewport.height)\n await page.render({ canvas, viewport }).promise\n const blob = await new Promise<Blob | null>((resolve) => canvas.toBlob(resolve, 'image/png'))\n if (!blob) throw new Error('Thumbnail failed')\n return URL.createObjectURL(blob)\n })\n thumbs.set(key, p)\n }\n return p\n }\n\n const getData = async () => {\n const d = doc.value\n if (!d) throw new Error('No document loaded')\n return d.getData()\n }\n\n async function blobUrl() {\n const bytes = await getData()\n return URL.createObjectURL(new Blob([bytes as BlobPart], { type: 'application/pdf' }))\n }\n\n async function download(fileName?: string) {\n const url = await blobUrl()\n const s = toValue(src)\n const fromUrl = typeof s === 'string' ? decodeURIComponent(s.split(/[?#]/)[0]!.split('/').pop() ?? '') : ''\n const a = document.createElement('a')\n a.href = url\n a.download = fileName ?? (s instanceof File ? s.name : fromUrl.toLowerCase().endsWith('.pdf') ? fromUrl : `${metadata.value.title ?? 'document'}.pdf`)\n document.body.appendChild(a)\n a.click()\n a.remove()\n setTimeout(() => URL.revokeObjectURL(url), 30_000)\n }\n\n // The browser's own PDF viewer prints it, in a hidden frame\n async function print() {\n const url = await blobUrl()\n const frame = document.createElement('iframe')\n frame.style.cssText = 'position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden'\n frame.src = url\n frame.onload = () => {\n try {\n frame.contentWindow?.focus()\n frame.contentWindow?.print()\n } catch {\n window.open(url, '_blank')\n }\n setTimeout(() => {\n frame.remove()\n URL.revokeObjectURL(url)\n }, 60_000)\n }\n document.body.appendChild(frame)\n }\n\n function submitPassword(pw: string) {\n const cb = passwordCallback\n if (!cb) return\n passwordCallback = null\n needsPassword.value = false\n cb(pw)\n }\n\n watch(() => toValue(src), (s) => { load(s) }, { immediate: true })\n\n if (getCurrentScope()) {\n onScopeDispose(() => {\n generation++\n reset()\n })\n }\n\n return {\n doc,\n pdfjs,\n loading,\n progress,\n error,\n needsPassword,\n wrongPassword,\n submitPassword,\n numPages,\n pageSizes,\n outline,\n metadata,\n getPage,\n pageText,\n search,\n thumbnail,\n resolveDest,\n getData,\n download,\n print,\n }\n}\n","<script setup lang=\"ts\">\n// Internal to MPdfViewer: one page. The canvas renders only while `active` (near the viewport), at the device's\n// pixel ratio, swapped in once ready so a zoom never flashes blank; meanwhile the old picture is stretched. Over it:\n// pdf.js's text layer (selectable, with search hits marked in place), the page's links, and an SVG with the\n// annotations, drawn from PDF points through the viewport so they follow zoom and rotation.\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type { PdfPage, PdfState } from '../composables/usePdf'\nimport type { PdfAnnotation, PdfTool } from './MPdfViewer.vue'\nimport MIcon from './MIcon.vue'\n\ntype Viewport = ReturnType<PdfPage['getViewport']>\n\nconst props = defineProps<{\n pdf: PdfState\n page: number\n scale: number\n /** Extra rotation from the viewer, on top of the page's own */\n rotation: number\n /** Near the viewport: render the canvas and the layers */\n active: boolean\n /** Search hits on this page, as offsets in its text; `current` is the focused one */\n hits: { start: number; end: number; current: boolean }[]\n annotations: PdfAnnotation[]\n tool: PdfTool\n color: string\n inkWidth: number\n selectedId: string | null\n}>()\n\nconst emit = defineEmits<{\n link: [{ url?: string; dest?: unknown }]\n add: [PdfAnnotation]\n select: [{ id: string; anchor: DOMRect } | null]\n erase: [string]\n 'erase-start': []\n 'erase-at': [{ x: number; y: number; r: number }]\n 'text-selection': [{ page: number; rects: [number, number, number, number][]; quote: string; anchor: DOMRect } | null]\n rendered: [number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst canvasHost = ref<HTMLElement>()\nconst textHost = ref<HTMLElement>()\nconst pageProxy = shallowRef<PdfPage | null>(null)\nconst viewport = shallowRef<Viewport | null>(null)\n\nfunction makeViewport(p: PdfPage) {\n return p.getViewport({ scale: props.scale, rotation: (p.rotate + props.rotation) % 360 })\n}\n\n// ── Canvas ──────────────────────────────────────────────────────────────────────────────────────────────\nlet renderTask: { cancel(): void; promise: Promise<void> } | null = null\nlet renderedKey = ''\n// Browsers cap a canvas's area; past it, render at a lower ratio\nconst MAX_PIXELS = 16_000_000\n\nasync function render() {\n if (!props.active) return\n const p = pageProxy.value ?? (pageProxy.value = await props.pdf.getPage(props.page).catch(() => null))\n if (!p || !props.active) return\n const vp = makeViewport(p)\n viewport.value = vp\n let ratio = Math.min(2, window.devicePixelRatio || 1)\n if (vp.width * vp.height * ratio * ratio > MAX_PIXELS) ratio = Math.sqrt(MAX_PIXELS / (vp.width * vp.height))\n const key = `${props.scale}|${props.rotation}|${ratio}`\n if (key === renderedKey) return\n renderTask?.cancel()\n const canvas = document.createElement('canvas')\n canvas.width = Math.floor(vp.width * ratio)\n canvas.height = Math.floor(vp.height * ratio)\n canvas.className = 'absolute inset-0 h-full w-full'\n const task = p.render({ canvas, viewport: vp, transform: ratio !== 1 ? [ratio, 0, 0, ratio, 0, 0] : undefined })\n renderTask = task\n try {\n await task.promise\n } catch {\n return // cancelled by a newer render\n }\n if (renderTask !== task) return\n renderTask = null\n renderedKey = key\n const host = canvasHost.value\n if (!host) return\n host.replaceChildren(canvas)\n emit('rendered', props.page)\n renderText(p, vp)\n readLinks(p, vp)\n}\n\nfunction release() {\n renderTask?.cancel()\n renderTask = null\n renderedKey = ''\n // Free the bitmap now rather than whenever the canvas gets collected\n const c = canvasHost.value?.querySelector('canvas')\n if (c) {\n c.width = 0\n c.height = 0\n }\n canvasHost.value?.replaceChildren()\n textLayer?.cancel()\n textLayer = null\n textHost.value?.replaceChildren()\n links.value = []\n pageProxy.value?.cleanup()\n}\n\nlet timer: ReturnType<typeof setTimeout> | undefined\n\n// ── Text layer and search hits ──────────────────────────────────────────────────────────────────────────\nlet textLayer: { render(): Promise<unknown>; cancel(): void; textDivs: HTMLElement[]; textContentItemsStr: string[] } | null = null\nlet textContent: unknown = null\n\nasync function renderText(p: PdfPage, vp: Viewport) {\n const lib = props.pdf.pdfjs.value\n const host = textHost.value\n if (!lib || !host) return\n textLayer?.cancel()\n textContent ??= await p.getTextContent()\n const container = document.createElement('div')\n container.className = 'textLayer'\n const layer = new lib.TextLayer({ textContentSource: textContent as never, container, viewport: vp }) as unknown as typeof textLayer\n textLayer = layer\n try {\n await layer!.render()\n } catch {\n return\n }\n if (textLayer !== layer) return\n host.replaceChildren(container)\n markHits()\n}\n\nlet marked: number[] = []\nconst escape = (s: string) => s.replace(/[&<>\"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;' })[c]!)\n\nasync function markHits() {\n const layer = textLayer\n if (!layer) return\n // Put back what the last marking changed\n for (const i of marked) if (layer.textDivs[i]) layer.textDivs[i]!.textContent = layer.textContentItemsStr[i] ?? ''\n marked = []\n if (!props.hits.length) return\n const { starts } = await props.pdf.pageText(props.page)\n if (layer !== textLayer) return\n const parts = new Map<number, { a: number; b: number; current: boolean }[]>()\n for (const h of props.hits) {\n for (let i = 0; i < starts.length; i++) {\n const s = starts[i]!\n const str = layer.textContentItemsStr[i] ?? ''\n const a = Math.max(h.start, s)\n const b = Math.min(h.end, s + str.length)\n if (b > a) {\n const list = parts.get(i) ?? []\n list.push({ a: a - s, b: b - s, current: h.current })\n parts.set(i, list)\n }\n }\n }\n let currentEl: HTMLElement | null = null\n for (const [i, ranges] of parts) {\n const div = layer.textDivs[i]\n const str = layer.textContentItemsStr[i] ?? ''\n if (!div) continue\n ranges.sort((x, y) => x.a - y.a)\n let html = ''\n let at = 0\n for (const r of ranges) {\n html += escape(str.slice(at, r.a)) + `<span class=\"m3-pdf-hit${r.current ? ' m3-pdf-hit-current' : ''}\">${escape(str.slice(r.a, r.b))}</span>`\n at = r.b\n }\n div.innerHTML = html + escape(str.slice(at))\n marked.push(i)\n if (ranges.some((r) => r.current)) currentEl ??= div.querySelector<HTMLElement>('.m3-pdf-hit-current')\n }\n currentHit.value = currentEl\n}\nconst currentHit = shallowRef<HTMLElement | null>(null)\nwatch(() => props.hits, markHits)\n\n// ── Links ───────────────────────────────────────────────────────────────────────────────────────────────\ninterface Link { left: number; top: number; width: number; height: number; url?: string; dest?: unknown }\nconst links = ref<Link[]>([])\nlet rawLinks: { rect: number[]; url?: string; dest?: unknown }[] | null = null\n\nasync function readLinks(p: PdfPage, vp: Viewport) {\n rawLinks ??= (await p.getAnnotations().catch(() => []))\n .filter((a: { subtype?: string; url?: string; dest?: unknown }) => a.subtype === 'Link' && (a.url || a.dest))\n .map((a: { rect: number[]; url?: string; dest?: unknown }) => ({ rect: a.rect, url: a.url, dest: a.dest }))\n links.value = rawLinks!.map((l) => {\n const [x1, y1] = vp.convertToViewportPoint(l.rect[0]!, l.rect[1]!) as [number, number]\n const [x2, y2] = vp.convertToViewportPoint(l.rect[2]!, l.rect[3]!) as [number, number]\n return { left: Math.min(x1, x2), top: Math.min(y1, y2), width: Math.abs(x2 - x1), height: Math.abs(y2 - y1), url: l.url, dest: l.dest }\n })\n}\n// Links scale with the page between renders\nconst linkScale = computed(() => (viewport.value && renderedKey ? props.scale / Number(renderedKey.split('|')[0]) : 1))\n\n// ── Annotations ─────────────────────────────────────────────────────────────────────────────────────────\nconst toView = (x: number, y: number): [number, number] => (viewport.value ? (viewport.value.convertToViewportPoint(x, y) as [number, number]) : [0, 0])\nconst toPdf = (x: number, y: number): [number, number] => (viewport.value ? (viewport.value.convertToPdfPoint(x, y) as [number, number]) : [0, 0])\n\nconst shapes = computed(() => {\n void props.scale\n void props.rotation\n return props.annotations.map((a) => {\n if (a.type === 'highlight') {\n const rects = (a.rects ?? []).map(([x1, y1, x2, y2]) => {\n const [ax, ay] = toView(x1, y1)\n const [bx, by] = toView(x2, y2)\n return { x: Math.min(ax, bx), y: Math.min(ay, by), w: Math.abs(bx - ax), h: Math.abs(by - ay) }\n })\n return { a, rects }\n }\n if (a.type === 'ink') {\n const d = (a.paths ?? []).map((path) => path.map(([x, y], i) => {\n const [vx, vy] = toView(x, y)\n return `${i ? 'L' : 'M'}${vx.toFixed(1)},${vy.toFixed(1)}`\n }).join('')).join('')\n return { a, d, w: (a.width ?? 2) * props.scale }\n }\n const [x, y] = toView(a.at?.[0] ?? 0, a.at?.[1] ?? 0)\n return { a, x, y }\n })\n})\n\nfunction onAnnotationClick(e: MouseEvent, a: PdfAnnotation) {\n // The eraser works by dragging (see onInkDown), a click included\n if (props.tool !== 'select') return\n e.stopPropagation()\n emit('select', { id: a.id, anchor: (e.currentTarget as Element).getBoundingClientRect() })\n}\n\nconst uid = () => (typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `a${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`)\nconst now = () => new Date().toISOString()\n\nfunction local(e: { clientX: number; clientY: number }) {\n const r = root.value!.getBoundingClientRect()\n // The page may be stretched by a pending zoom: map into the viewport's pixels\n const vp = viewport.value!\n return [((e.clientX - r.left) / (r.width || 1)) * vp.width, ((e.clientY - r.top) / (r.height || 1)) * vp.height] as [number, number]\n}\n\n// Note: a click places one\nfunction onPageClick(e: MouseEvent) {\n if (props.tool !== 'note' || !viewport.value) return\n const [x, y] = toPdf(...local(e))\n emit('add', { id: uid(), type: 'note', page: props.page, color: props.color, at: [x, y], text: '', createdAt: now() })\n}\n\n// Ink: a drag draws, in viewport pixels while drawing, stored in PDF points. The eraser drags too: everything it\n// passes over goes (strokes are cut where it passes); a stylus's eraser end erases whatever the tool\nconst drawing = ref<[number, number][] | null>(null)\nconst erasing = ref(false)\nconst eraserAt = ref<[number, number] | null>(null)\n// The eraser's radius on screen, whatever the zoom\nconst ERASER_PX = 12\nlet drawId = -1\nconst isPenEraser = (e: PointerEvent) => e.pointerType === 'pen' && (e.button === 5 || (e.buttons & 32) !== 0)\nfunction eraseAt(e: PointerEvent) {\n const p = local(e)\n eraserAt.value = p\n const [x, y] = toPdf(p[0], p[1])\n emit('erase-at', { x, y, r: ERASER_PX / props.scale })\n}\nfunction onInkDown(e: PointerEvent) {\n const pen = isPenEraser(e)\n if ((props.tool !== 'ink' && props.tool !== 'eraser' && !pen) || (e.button !== 0 && !pen) || !viewport.value) return\n e.preventDefault()\n drawId = e.pointerId\n try {\n ;(e.currentTarget as Element).setPointerCapture(e.pointerId)\n } catch { /* a pointer that's already gone */ }\n if (props.tool === 'eraser' || pen) {\n erasing.value = true\n emit('erase-start')\n eraseAt(e)\n } else drawing.value = [local(e)]\n}\nfunction onInkMove(e: PointerEvent) {\n if (props.tool === 'eraser' && !erasing.value && e.pointerType !== 'touch') eraserAt.value = local(e)\n if (e.pointerId !== drawId) return\n if (erasing.value) return eraseAt(e)\n if (!drawing.value) return\n const p = local(e)\n const last = drawing.value[drawing.value.length - 1]!\n if (Math.hypot(p[0] - last[0], p[1] - last[1]) >= 1.5) drawing.value = [...drawing.value, p]\n}\nfunction onInkUp(e: PointerEvent) {\n if (e.pointerId !== drawId) return\n drawId = -1\n if (erasing.value) {\n erasing.value = false\n if (e.pointerType === 'touch') eraserAt.value = null\n return\n }\n if (!drawing.value) return\n const pts = drawing.value\n drawing.value = null\n if (pts.length < 2) return\n emit('add', {\n id: uid(), type: 'ink', page: props.page, color: props.color, width: props.inkWidth,\n paths: [pts.map(([x, y]) => toPdf(x, y).map((v) => Math.round(v * 100) / 100) as [number, number])], createdAt: now(),\n })\n}\nconst drawingPath = computed(() => (drawing.value ?? []).map(([x, y], i) => `${i ? 'L' : 'M'}${x.toFixed(1)},${y.toFixed(1)}`).join(''))\n\nfunction openHighlightAt(clientX: number, clientY: number): boolean {\n const vp = viewport.value\n if (!vp || !root.value) return false\n const r = root.value.getBoundingClientRect()\n const sx = vp.width / (r.width || 1)\n const sy = vp.height / (r.height || 1)\n const x = (clientX - r.left) * sx\n const y = (clientY - r.top) * sy\n const PAD = 2\n // The last one drawn is on top\n for (const s of [...shapes.value].reverse()) {\n if (!('rects' in s) || !s.rects) continue\n const hit = s.rects.find((b) => x >= b.x - PAD && x <= b.x + b.w + PAD && y >= b.y - PAD && y <= b.y + b.h + PAD)\n if (!hit) continue\n emit('select', { id: s.a.id, anchor: new DOMRect(r.left + hit.x / sx, r.top + hit.y / sy, hit.w / sx, hit.h / sy) })\n return true\n }\n return false\n}\n\n// Text selection: its rects, in PDF points, for a highlight (made at once with the highlight tool)\nfunction onTextPointerUp(e?: PointerEvent) {\n const at = e ? { x: e.clientX, y: e.clientY } : null\n setTimeout(() => {\n const sel = window.getSelection()\n const host = textHost.value\n if (!sel || sel.isCollapsed || !sel.rangeCount || !host || !viewport.value) {\n // A tap on a highlight opens it (to comment on, recolor or delete): the text layer above it takes the tap\n if (at && (props.tool === 'select' || props.tool === 'highlight') && openHighlightAt(at.x, at.y)) return\n if (props.tool === 'select') emit('text-selection', null)\n return\n }\n const range = sel.getRangeAt(0)\n if (!host.contains(range.commonAncestorContainer)) return\n const r = root.value!.getBoundingClientRect()\n const vp = viewport.value\n const sx = vp.width / (r.width || 1)\n const sy = vp.height / (r.height || 1)\n const rects: [number, number, number, number][] = []\n for (const c of Array.from(range.getClientRects())) {\n if (c.width < 1 || c.height < 1) continue\n const [x1, y1] = toPdf((c.left - r.left) * sx, (c.top - r.top) * sy)\n const [x2, y2] = toPdf((c.right - r.left) * sx, (c.bottom - r.top) * sy)\n rects.push([x1, y1, x2, y2].map((v) => Math.round(v * 100) / 100) as [number, number, number, number])\n }\n if (!rects.length) return\n const quote = sel.toString().replace(/\\s+/g, ' ').trim()\n if (props.tool === 'highlight') {\n emit('add', { id: uid(), type: 'highlight', page: props.page, color: props.color, rects, quote, text: '', createdAt: now() })\n sel.removeAllRanges()\n } else {\n emit('text-selection', { page: props.page, rects, quote, anchor: range.getBoundingClientRect() })\n }\n })\n}\n\n// Last, so everything render() and release() touch is declared\nwatch(() => props.active, (on) => (on ? render() : release()), { immediate: true })\n// A zoom re-renders shortly after it settles (the stretched picture stands in meanwhile)\nwatch(() => [props.scale, props.rotation], () => {\n if (pageProxy.value) viewport.value = makeViewport(pageProxy.value)\n clearTimeout(timer)\n timer = setTimeout(render, 140)\n})\n\nonBeforeUnmount(() => {\n clearTimeout(timer)\n release()\n})\n\ndefineExpose({ root, currentHit })\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-pdf-page relative bg-white shadow-elevation-1\"\n :data-page=\"page\"\n :style=\"{ '--scale-factor': scale, '--total-scale-factor': scale, '--user-unit': 1, '--scale-round-x': '1px', '--scale-round-y': '1px' }\"\n @click=\"onPageClick\"\n >\n <div ref=\"canvasHost\" class=\"absolute inset-0\" />\n <div\n ref=\"textHost\"\n class=\"absolute inset-0 overflow-hidden\"\n :class=\"{ 'pointer-events-none': tool === 'ink' || tool === 'note' || tool === 'eraser' }\"\n @pointerup=\"onTextPointerUp\"\n />\n\n <a\n v-for=\"(l, i) in links\"\n :key=\"i\"\n :href=\"l.url ?? '#'\"\n :target=\"l.url ? '_blank' : undefined\"\n :rel=\"l.url ? 'noopener noreferrer' : undefined\"\n class=\"absolute rounded-xs hover:bg-primary/12\"\n :class=\"{ 'pointer-events-none': tool !== 'select' }\"\n :style=\"{ left: `${l.left * linkScale}px`, top: `${l.top * linkScale}px`, width: `${l.width * linkScale}px`, height: `${l.height * linkScale}px` }\"\n @click=\"(e: MouseEvent) => { if (!l.url) { e.preventDefault(); emit('link', { dest: l.dest }) } else emit('link', { url: l.url }) }\"\n />\n\n <svg\n class=\"absolute inset-0 h-full w-full overflow-visible\"\n :class=\"tool === 'ink' ? 'cursor-crosshair touch-none' : tool === 'eraser' ? 'cursor-none touch-none' : 'pointer-events-none'\"\n :viewBox=\"viewport ? `0 0 ${viewport.width} ${viewport.height}` : undefined\"\n preserveAspectRatio=\"none\"\n @pointerdown=\"onInkDown\"\n @pointermove=\"onInkMove\"\n @pointerup=\"onInkUp\"\n @pointercancel=\"onInkUp\"\n @pointerleave=\"eraserAt = erasing ? eraserAt : null\"\n >\n <template v-for=\"s in shapes\" :key=\"s.a.id\">\n <g v-if=\"'rects' in s\" class=\"m3-pdf-highlight\" :class=\"{ 'm3-pdf-selected': s.a.id === selectedId }\" @click=\"(e: MouseEvent) => onAnnotationClick(e, s.a)\">\n <rect v-for=\"(r, i) in s.rects\" :key=\"i\" :x=\"r.x\" :y=\"r.y\" :width=\"r.w\" :height=\"r.h\" rx=\"2\" :fill=\"s.a.color\" />\n </g>\n <path\n v-else-if=\"'d' in s\"\n :d=\"s.d\"\n fill=\"none\"\n :stroke=\"s.a.color\"\n :stroke-width=\"s.w\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"m3-pdf-ink\"\n :class=\"{ 'm3-pdf-selected': s.a.id === selectedId }\"\n @click=\"(e: MouseEvent) => onAnnotationClick(e, s.a)\"\n />\n </template>\n <circle v-if=\"eraserAt && tool === 'eraser'\" :cx=\"eraserAt[0]\" :cy=\"eraserAt[1]\" :r=\"ERASER_PX\" class=\"pointer-events-none fill-surface/40 stroke-on-surface\" stroke-width=\"1.5\" />\n <path v-if=\"drawing\" :d=\"drawingPath\" fill=\"none\" :stroke=\"color\" :stroke-width=\"inkWidth * scale\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n\n <!-- Notes: an icon at their point -->\n <template v-for=\"s in shapes\" :key=\"`n-${s.a.id}`\">\n <button\n v-if=\"'x' in s\"\n type=\"button\"\n class=\"m3-pdf-note absolute flex size-7 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full shadow-elevation-2 outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n :class=\"{ 'ring-2 ring-primary': s.a.id === selectedId }\"\n :style=\"{ left: `${s.x}px`, top: `${s.y}px`, backgroundColor: s.a.color }\"\n :aria-label=\"s.a.text || 'Note'\"\n @click=\"(e: MouseEvent) => { e.stopPropagation(); if (tool === 'eraser') emit('erase', s.a.id); else emit('select', { id: s.a.id, anchor: (e.currentTarget as Element).getBoundingClientRect() }) }\"\n >\n <MIcon name=\"sticky_note_2\" :size=\"16\" filled class=\"text-black/70\" />\n </button>\n </template>\n </div>\n</template>\n","<script setup lang=\"ts\">\n// Internal to MPdfViewer: one page. The canvas renders only while `active` (near the viewport), at the device's\n// pixel ratio, swapped in once ready so a zoom never flashes blank; meanwhile the old picture is stretched. Over it:\n// pdf.js's text layer (selectable, with search hits marked in place), the page's links, and an SVG with the\n// annotations, drawn from PDF points through the viewport so they follow zoom and rotation.\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type { PdfPage, PdfState } from '../composables/usePdf'\nimport type { PdfAnnotation, PdfTool } from './MPdfViewer.vue'\nimport MIcon from './MIcon.vue'\n\ntype Viewport = ReturnType<PdfPage['getViewport']>\n\nconst props = defineProps<{\n pdf: PdfState\n page: number\n scale: number\n /** Extra rotation from the viewer, on top of the page's own */\n rotation: number\n /** Near the viewport: render the canvas and the layers */\n active: boolean\n /** Search hits on this page, as offsets in its text; `current` is the focused one */\n hits: { start: number; end: number; current: boolean }[]\n annotations: PdfAnnotation[]\n tool: PdfTool\n color: string\n inkWidth: number\n selectedId: string | null\n}>()\n\nconst emit = defineEmits<{\n link: [{ url?: string; dest?: unknown }]\n add: [PdfAnnotation]\n select: [{ id: string; anchor: DOMRect } | null]\n erase: [string]\n 'erase-start': []\n 'erase-at': [{ x: number; y: number; r: number }]\n 'text-selection': [{ page: number; rects: [number, number, number, number][]; quote: string; anchor: DOMRect } | null]\n rendered: [number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst canvasHost = ref<HTMLElement>()\nconst textHost = ref<HTMLElement>()\nconst pageProxy = shallowRef<PdfPage | null>(null)\nconst viewport = shallowRef<Viewport | null>(null)\n\nfunction makeViewport(p: PdfPage) {\n return p.getViewport({ scale: props.scale, rotation: (p.rotate + props.rotation) % 360 })\n}\n\n// ── Canvas ──────────────────────────────────────────────────────────────────────────────────────────────\nlet renderTask: { cancel(): void; promise: Promise<void> } | null = null\nlet renderedKey = ''\n// Browsers cap a canvas's area; past it, render at a lower ratio\nconst MAX_PIXELS = 16_000_000\n\nasync function render() {\n if (!props.active) return\n const p = pageProxy.value ?? (pageProxy.value = await props.pdf.getPage(props.page).catch(() => null))\n if (!p || !props.active) return\n const vp = makeViewport(p)\n viewport.value = vp\n let ratio = Math.min(2, window.devicePixelRatio || 1)\n if (vp.width * vp.height * ratio * ratio > MAX_PIXELS) ratio = Math.sqrt(MAX_PIXELS / (vp.width * vp.height))\n const key = `${props.scale}|${props.rotation}|${ratio}`\n if (key === renderedKey) return\n renderTask?.cancel()\n const canvas = document.createElement('canvas')\n canvas.width = Math.floor(vp.width * ratio)\n canvas.height = Math.floor(vp.height * ratio)\n canvas.className = 'absolute inset-0 h-full w-full'\n const task = p.render({ canvas, viewport: vp, transform: ratio !== 1 ? [ratio, 0, 0, ratio, 0, 0] : undefined })\n renderTask = task\n try {\n await task.promise\n } catch {\n return // cancelled by a newer render\n }\n if (renderTask !== task) return\n renderTask = null\n renderedKey = key\n const host = canvasHost.value\n if (!host) return\n host.replaceChildren(canvas)\n emit('rendered', props.page)\n renderText(p, vp)\n readLinks(p, vp)\n}\n\nfunction release() {\n renderTask?.cancel()\n renderTask = null\n renderedKey = ''\n // Free the bitmap now rather than whenever the canvas gets collected\n const c = canvasHost.value?.querySelector('canvas')\n if (c) {\n c.width = 0\n c.height = 0\n }\n canvasHost.value?.replaceChildren()\n textLayer?.cancel()\n textLayer = null\n textHost.value?.replaceChildren()\n links.value = []\n pageProxy.value?.cleanup()\n}\n\nlet timer: ReturnType<typeof setTimeout> | undefined\n\n// ── Text layer and search hits ──────────────────────────────────────────────────────────────────────────\nlet textLayer: { render(): Promise<unknown>; cancel(): void; textDivs: HTMLElement[]; textContentItemsStr: string[] } | null = null\nlet textContent: unknown = null\n\nasync function renderText(p: PdfPage, vp: Viewport) {\n const lib = props.pdf.pdfjs.value\n const host = textHost.value\n if (!lib || !host) return\n textLayer?.cancel()\n textContent ??= await p.getTextContent()\n const container = document.createElement('div')\n container.className = 'textLayer'\n const layer = new lib.TextLayer({ textContentSource: textContent as never, container, viewport: vp }) as unknown as typeof textLayer\n textLayer = layer\n try {\n await layer!.render()\n } catch {\n return\n }\n if (textLayer !== layer) return\n host.replaceChildren(container)\n markHits()\n}\n\nlet marked: number[] = []\nconst escape = (s: string) => s.replace(/[&<>\"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;' })[c]!)\n\nasync function markHits() {\n const layer = textLayer\n if (!layer) return\n // Put back what the last marking changed\n for (const i of marked) if (layer.textDivs[i]) layer.textDivs[i]!.textContent = layer.textContentItemsStr[i] ?? ''\n marked = []\n if (!props.hits.length) return\n const { starts } = await props.pdf.pageText(props.page)\n if (layer !== textLayer) return\n const parts = new Map<number, { a: number; b: number; current: boolean }[]>()\n for (const h of props.hits) {\n for (let i = 0; i < starts.length; i++) {\n const s = starts[i]!\n const str = layer.textContentItemsStr[i] ?? ''\n const a = Math.max(h.start, s)\n const b = Math.min(h.end, s + str.length)\n if (b > a) {\n const list = parts.get(i) ?? []\n list.push({ a: a - s, b: b - s, current: h.current })\n parts.set(i, list)\n }\n }\n }\n let currentEl: HTMLElement | null = null\n for (const [i, ranges] of parts) {\n const div = layer.textDivs[i]\n const str = layer.textContentItemsStr[i] ?? ''\n if (!div) continue\n ranges.sort((x, y) => x.a - y.a)\n let html = ''\n let at = 0\n for (const r of ranges) {\n html += escape(str.slice(at, r.a)) + `<span class=\"m3-pdf-hit${r.current ? ' m3-pdf-hit-current' : ''}\">${escape(str.slice(r.a, r.b))}</span>`\n at = r.b\n }\n div.innerHTML = html + escape(str.slice(at))\n marked.push(i)\n if (ranges.some((r) => r.current)) currentEl ??= div.querySelector<HTMLElement>('.m3-pdf-hit-current')\n }\n currentHit.value = currentEl\n}\nconst currentHit = shallowRef<HTMLElement | null>(null)\nwatch(() => props.hits, markHits)\n\n// ── Links ───────────────────────────────────────────────────────────────────────────────────────────────\ninterface Link { left: number; top: number; width: number; height: number; url?: string; dest?: unknown }\nconst links = ref<Link[]>([])\nlet rawLinks: { rect: number[]; url?: string; dest?: unknown }[] | null = null\n\nasync function readLinks(p: PdfPage, vp: Viewport) {\n rawLinks ??= (await p.getAnnotations().catch(() => []))\n .filter((a: { subtype?: string; url?: string; dest?: unknown }) => a.subtype === 'Link' && (a.url || a.dest))\n .map((a: { rect: number[]; url?: string; dest?: unknown }) => ({ rect: a.rect, url: a.url, dest: a.dest }))\n links.value = rawLinks!.map((l) => {\n const [x1, y1] = vp.convertToViewportPoint(l.rect[0]!, l.rect[1]!) as [number, number]\n const [x2, y2] = vp.convertToViewportPoint(l.rect[2]!, l.rect[3]!) as [number, number]\n return { left: Math.min(x1, x2), top: Math.min(y1, y2), width: Math.abs(x2 - x1), height: Math.abs(y2 - y1), url: l.url, dest: l.dest }\n })\n}\n// Links scale with the page between renders\nconst linkScale = computed(() => (viewport.value && renderedKey ? props.scale / Number(renderedKey.split('|')[0]) : 1))\n\n// ── Annotations ─────────────────────────────────────────────────────────────────────────────────────────\nconst toView = (x: number, y: number): [number, number] => (viewport.value ? (viewport.value.convertToViewportPoint(x, y) as [number, number]) : [0, 0])\nconst toPdf = (x: number, y: number): [number, number] => (viewport.value ? (viewport.value.convertToPdfPoint(x, y) as [number, number]) : [0, 0])\n\nconst shapes = computed(() => {\n void props.scale\n void props.rotation\n return props.annotations.map((a) => {\n if (a.type === 'highlight') {\n const rects = (a.rects ?? []).map(([x1, y1, x2, y2]) => {\n const [ax, ay] = toView(x1, y1)\n const [bx, by] = toView(x2, y2)\n return { x: Math.min(ax, bx), y: Math.min(ay, by), w: Math.abs(bx - ax), h: Math.abs(by - ay) }\n })\n return { a, rects }\n }\n if (a.type === 'ink') {\n const d = (a.paths ?? []).map((path) => path.map(([x, y], i) => {\n const [vx, vy] = toView(x, y)\n return `${i ? 'L' : 'M'}${vx.toFixed(1)},${vy.toFixed(1)}`\n }).join('')).join('')\n return { a, d, w: (a.width ?? 2) * props.scale }\n }\n const [x, y] = toView(a.at?.[0] ?? 0, a.at?.[1] ?? 0)\n return { a, x, y }\n })\n})\n\nfunction onAnnotationClick(e: MouseEvent, a: PdfAnnotation) {\n // The eraser works by dragging (see onInkDown), a click included\n if (props.tool !== 'select') return\n e.stopPropagation()\n emit('select', { id: a.id, anchor: (e.currentTarget as Element).getBoundingClientRect() })\n}\n\nconst uid = () => (typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `a${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`)\nconst now = () => new Date().toISOString()\n\nfunction local(e: { clientX: number; clientY: number }) {\n const r = root.value!.getBoundingClientRect()\n // The page may be stretched by a pending zoom: map into the viewport's pixels\n const vp = viewport.value!\n return [((e.clientX - r.left) / (r.width || 1)) * vp.width, ((e.clientY - r.top) / (r.height || 1)) * vp.height] as [number, number]\n}\n\n// Note: a click places one\nfunction onPageClick(e: MouseEvent) {\n if (props.tool !== 'note' || !viewport.value) return\n const [x, y] = toPdf(...local(e))\n emit('add', { id: uid(), type: 'note', page: props.page, color: props.color, at: [x, y], text: '', createdAt: now() })\n}\n\n// Ink: a drag draws, in viewport pixels while drawing, stored in PDF points. The eraser drags too: everything it\n// passes over goes (strokes are cut where it passes); a stylus's eraser end erases whatever the tool\nconst drawing = ref<[number, number][] | null>(null)\nconst erasing = ref(false)\nconst eraserAt = ref<[number, number] | null>(null)\n// The eraser's radius on screen, whatever the zoom\nconst ERASER_PX = 12\nlet drawId = -1\nconst isPenEraser = (e: PointerEvent) => e.pointerType === 'pen' && (e.button === 5 || (e.buttons & 32) !== 0)\nfunction eraseAt(e: PointerEvent) {\n const p = local(e)\n eraserAt.value = p\n const [x, y] = toPdf(p[0], p[1])\n emit('erase-at', { x, y, r: ERASER_PX / props.scale })\n}\nfunction onInkDown(e: PointerEvent) {\n const pen = isPenEraser(e)\n if ((props.tool !== 'ink' && props.tool !== 'eraser' && !pen) || (e.button !== 0 && !pen) || !viewport.value) return\n e.preventDefault()\n drawId = e.pointerId\n try {\n ;(e.currentTarget as Element).setPointerCapture(e.pointerId)\n } catch { /* a pointer that's already gone */ }\n if (props.tool === 'eraser' || pen) {\n erasing.value = true\n emit('erase-start')\n eraseAt(e)\n } else drawing.value = [local(e)]\n}\nfunction onInkMove(e: PointerEvent) {\n if (props.tool === 'eraser' && !erasing.value && e.pointerType !== 'touch') eraserAt.value = local(e)\n if (e.pointerId !== drawId) return\n if (erasing.value) return eraseAt(e)\n if (!drawing.value) return\n const p = local(e)\n const last = drawing.value[drawing.value.length - 1]!\n if (Math.hypot(p[0] - last[0], p[1] - last[1]) >= 1.5) drawing.value = [...drawing.value, p]\n}\nfunction onInkUp(e: PointerEvent) {\n if (e.pointerId !== drawId) return\n drawId = -1\n if (erasing.value) {\n erasing.value = false\n if (e.pointerType === 'touch') eraserAt.value = null\n return\n }\n if (!drawing.value) return\n const pts = drawing.value\n drawing.value = null\n if (pts.length < 2) return\n emit('add', {\n id: uid(), type: 'ink', page: props.page, color: props.color, width: props.inkWidth,\n paths: [pts.map(([x, y]) => toPdf(x, y).map((v) => Math.round(v * 100) / 100) as [number, number])], createdAt: now(),\n })\n}\nconst drawingPath = computed(() => (drawing.value ?? []).map(([x, y], i) => `${i ? 'L' : 'M'}${x.toFixed(1)},${y.toFixed(1)}`).join(''))\n\nfunction openHighlightAt(clientX: number, clientY: number): boolean {\n const vp = viewport.value\n if (!vp || !root.value) return false\n const r = root.value.getBoundingClientRect()\n const sx = vp.width / (r.width || 1)\n const sy = vp.height / (r.height || 1)\n const x = (clientX - r.left) * sx\n const y = (clientY - r.top) * sy\n const PAD = 2\n // The last one drawn is on top\n for (const s of [...shapes.value].reverse()) {\n if (!('rects' in s) || !s.rects) continue\n const hit = s.rects.find((b) => x >= b.x - PAD && x <= b.x + b.w + PAD && y >= b.y - PAD && y <= b.y + b.h + PAD)\n if (!hit) continue\n emit('select', { id: s.a.id, anchor: new DOMRect(r.left + hit.x / sx, r.top + hit.y / sy, hit.w / sx, hit.h / sy) })\n return true\n }\n return false\n}\n\n// Text selection: its rects, in PDF points, for a highlight (made at once with the highlight tool)\nfunction onTextPointerUp(e?: PointerEvent) {\n const at = e ? { x: e.clientX, y: e.clientY } : null\n setTimeout(() => {\n const sel = window.getSelection()\n const host = textHost.value\n if (!sel || sel.isCollapsed || !sel.rangeCount || !host || !viewport.value) {\n // A tap on a highlight opens it (to comment on, recolor or delete): the text layer above it takes the tap\n if (at && (props.tool === 'select' || props.tool === 'highlight') && openHighlightAt(at.x, at.y)) return\n if (props.tool === 'select') emit('text-selection', null)\n return\n }\n const range = sel.getRangeAt(0)\n if (!host.contains(range.commonAncestorContainer)) return\n const r = root.value!.getBoundingClientRect()\n const vp = viewport.value\n const sx = vp.width / (r.width || 1)\n const sy = vp.height / (r.height || 1)\n const rects: [number, number, number, number][] = []\n for (const c of Array.from(range.getClientRects())) {\n if (c.width < 1 || c.height < 1) continue\n const [x1, y1] = toPdf((c.left - r.left) * sx, (c.top - r.top) * sy)\n const [x2, y2] = toPdf((c.right - r.left) * sx, (c.bottom - r.top) * sy)\n rects.push([x1, y1, x2, y2].map((v) => Math.round(v * 100) / 100) as [number, number, number, number])\n }\n if (!rects.length) return\n const quote = sel.toString().replace(/\\s+/g, ' ').trim()\n if (props.tool === 'highlight') {\n emit('add', { id: uid(), type: 'highlight', page: props.page, color: props.color, rects, quote, text: '', createdAt: now() })\n sel.removeAllRanges()\n } else {\n emit('text-selection', { page: props.page, rects, quote, anchor: range.getBoundingClientRect() })\n }\n })\n}\n\n// Last, so everything render() and release() touch is declared\nwatch(() => props.active, (on) => (on ? render() : release()), { immediate: true })\n// A zoom re-renders shortly after it settles (the stretched picture stands in meanwhile)\nwatch(() => [props.scale, props.rotation], () => {\n if (pageProxy.value) viewport.value = makeViewport(pageProxy.value)\n clearTimeout(timer)\n timer = setTimeout(render, 140)\n})\n\nonBeforeUnmount(() => {\n clearTimeout(timer)\n release()\n})\n\ndefineExpose({ root, currentHit })\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-pdf-page relative bg-white shadow-elevation-1\"\n :data-page=\"page\"\n :style=\"{ '--scale-factor': scale, '--total-scale-factor': scale, '--user-unit': 1, '--scale-round-x': '1px', '--scale-round-y': '1px' }\"\n @click=\"onPageClick\"\n >\n <div ref=\"canvasHost\" class=\"absolute inset-0\" />\n <div\n ref=\"textHost\"\n class=\"absolute inset-0 overflow-hidden\"\n :class=\"{ 'pointer-events-none': tool === 'ink' || tool === 'note' || tool === 'eraser' }\"\n @pointerup=\"onTextPointerUp\"\n />\n\n <a\n v-for=\"(l, i) in links\"\n :key=\"i\"\n :href=\"l.url ?? '#'\"\n :target=\"l.url ? '_blank' : undefined\"\n :rel=\"l.url ? 'noopener noreferrer' : undefined\"\n class=\"absolute rounded-xs hover:bg-primary/12\"\n :class=\"{ 'pointer-events-none': tool !== 'select' }\"\n :style=\"{ left: `${l.left * linkScale}px`, top: `${l.top * linkScale}px`, width: `${l.width * linkScale}px`, height: `${l.height * linkScale}px` }\"\n @click=\"(e: MouseEvent) => { if (!l.url) { e.preventDefault(); emit('link', { dest: l.dest }) } else emit('link', { url: l.url }) }\"\n />\n\n <svg\n class=\"absolute inset-0 h-full w-full overflow-visible\"\n :class=\"tool === 'ink' ? 'cursor-crosshair touch-none' : tool === 'eraser' ? 'cursor-none touch-none' : 'pointer-events-none'\"\n :viewBox=\"viewport ? `0 0 ${viewport.width} ${viewport.height}` : undefined\"\n preserveAspectRatio=\"none\"\n @pointerdown=\"onInkDown\"\n @pointermove=\"onInkMove\"\n @pointerup=\"onInkUp\"\n @pointercancel=\"onInkUp\"\n @pointerleave=\"eraserAt = erasing ? eraserAt : null\"\n >\n <template v-for=\"s in shapes\" :key=\"s.a.id\">\n <g v-if=\"'rects' in s\" class=\"m3-pdf-highlight\" :class=\"{ 'm3-pdf-selected': s.a.id === selectedId }\" @click=\"(e: MouseEvent) => onAnnotationClick(e, s.a)\">\n <rect v-for=\"(r, i) in s.rects\" :key=\"i\" :x=\"r.x\" :y=\"r.y\" :width=\"r.w\" :height=\"r.h\" rx=\"2\" :fill=\"s.a.color\" />\n </g>\n <path\n v-else-if=\"'d' in s\"\n :d=\"s.d\"\n fill=\"none\"\n :stroke=\"s.a.color\"\n :stroke-width=\"s.w\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"m3-pdf-ink\"\n :class=\"{ 'm3-pdf-selected': s.a.id === selectedId }\"\n @click=\"(e: MouseEvent) => onAnnotationClick(e, s.a)\"\n />\n </template>\n <circle v-if=\"eraserAt && tool === 'eraser'\" :cx=\"eraserAt[0]\" :cy=\"eraserAt[1]\" :r=\"ERASER_PX\" class=\"pointer-events-none fill-surface/40 stroke-on-surface\" stroke-width=\"1.5\" />\n <path v-if=\"drawing\" :d=\"drawingPath\" fill=\"none\" :stroke=\"color\" :stroke-width=\"inkWidth * scale\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n\n <!-- Notes: an icon at their point -->\n <template v-for=\"s in shapes\" :key=\"`n-${s.a.id}`\">\n <button\n v-if=\"'x' in s\"\n type=\"button\"\n class=\"m3-pdf-note absolute flex size-7 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full shadow-elevation-2 outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n :class=\"{ 'ring-2 ring-primary': s.a.id === selectedId }\"\n :style=\"{ left: `${s.x}px`, top: `${s.y}px`, backgroundColor: s.a.color }\"\n :aria-label=\"s.a.text || 'Note'\"\n @click=\"(e: MouseEvent) => { e.stopPropagation(); if (tool === 'eraser') emit('erase', s.a.id); else emit('select', { id: s.a.id, anchor: (e.currentTarget as Element).getBoundingClientRect() }) }\"\n >\n <MIcon name=\"sticky_note_2\" :size=\"16\" filled class=\"text-black/70\" />\n </button>\n </template>\n </div>\n</template>\n","<script lang=\"ts\">\n/** One annotation, in PDF points (origin at the page's bottom left), so it survives zoom, rotation and reflows */\nexport interface PdfAnnotation {\n id: string\n type: 'highlight' | 'note' | 'ink'\n /** 1-based page */\n page: number\n /** Any CSS color */\n color: string\n /** highlight: the selected lines, `[x1, y1, x2, y2]` each */\n rects?: [number, number, number, number][]\n /** highlight: the text it covers */\n quote?: string\n /** note: where its icon sits */\n at?: [number, number]\n /** ink: strokes, each a list of points */\n paths?: [number, number][][]\n /** ink: stroke width in points */\n width?: number\n /** A note's text, or a comment on a highlight or drawing */\n text?: string\n author?: string\n /** ISO date */\n createdAt: string\n}\n\nexport type PdfTool = 'select' | 'highlight' | 'note' | 'ink' | 'eraser'\n\n/**\n * What's left of an annotation after the eraser passed over `at` (PDF points, radius `r`): an ink stroke is cut\n * where it passes (null once nothing is left), a highlight or a note it touches goes entirely. The same object\n * back means it wasn't touched\n */\nexport function eraseFrom(a: PdfAnnotation, at: { x: number; y: number; r: number }): PdfAnnotation | null {\n const { x, y, r } = at\n if (a.type === 'note') {\n const [nx, ny] = a.at ?? [0, 0]\n return Math.hypot(nx - x, ny - y) <= r + 10 ? null : a\n }\n if (a.type === 'highlight') {\n const hit = (a.rects ?? []).some(([x1, y1, x2, y2]) =>\n x >= Math.min(x1, x2) - r && x <= Math.max(x1, x2) + r && y >= Math.min(y1, y2) - r && y <= Math.max(y1, y2) + r)\n return hit ? null : a\n }\n const reach = r + (a.width ?? 2) / 2\n // Distance from the eraser to a segment\n const near = (p: [number, number], q: [number, number]) => {\n const dx = q[0] - p[0]\n const dy = q[1] - p[1]\n const len = dx * dx + dy * dy\n const t = len ? Math.max(0, Math.min(1, ((x - p[0]) * dx + (y - p[1]) * dy) / len)) : 0\n return Math.hypot(p[0] + t * dx - x, p[1] + t * dy - y) <= reach\n }\n let touched = false\n const paths: [number, number][][] = []\n for (const path of a.paths ?? []) {\n let run: [number, number][] = []\n path.forEach((p, i) => {\n const prev = path[i - 1]\n const gone = Math.hypot(p[0] - x, p[1] - y) <= reach\n const crossed = !!prev && run.length > 0 && near(prev, p)\n if (gone || crossed) {\n touched = true\n if (run.length > 1) paths.push(run)\n run = gone ? [] : [p]\n } else run.push(p)\n })\n if (run.length > 1) paths.push(run)\n }\n if (!touched) return a\n return paths.length ? { ...a, paths } : null\n}\nexport type PdfZoom = number | 'fit-width' | 'fit-page'\n</script>\n\n<script setup lang=\"ts\">\n/**\n * A PDF viewer on pdf.js (not an M3 spec component; after androidx.pdf's `PdfView` and Google Drive's viewer). The\n * pages scroll continuously, each rendered only near the viewport, with selectable text and working links. Zoom:\n * fit to width (the default) or the page, a percentage, Ctrl + wheel or a trackpad pinch, a pinch on touch, and a\n * double click or double tap (zooms in there, or back to the width). A top bar with the page, zoom, search (hits\n * marked in the text), and download, print, rotate and full screen; a side panel with thumbnails and the outline;\n * a page indicator while scrolling (a draggable thumb on touch). With `annotate`, an edit button opens a floating\n * toolbar to highlight text, place notes and draw, kept in `v-model:annotations` as JSON (not written into the file).\n *\n * Needs the `pdfjs-dist` package. Set its worker once with `setPdfWorker()` (or `worker-src`); without it pdf.js\n * runs on the main thread.\n *\n * @slot actions Extra buttons at the end of the top bar. Props: `{ pdf }`\n * @slot empty Shown without a `src`\n * @event loaded The document loaded, with its pdf.js proxy\n * @event error The document failed to load\n * @event link A link was followed: `{ url }` (opens in a new tab) or `{ page }` (scrolled to)\n * @event annotation-click An annotation was clicked with the select tool\n */\nimport { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, shallowRef, watch } from 'vue'\nimport { usePdf, type PdfDocument, type PdfSource } from '../composables/usePdf'\nimport { useLocale } from '../composables/useLocale'\nimport PdfPageView from './_MPdfPage.vue'\nimport MIconButton from './MIconButton.vue'\nimport MIcon from './MIcon.vue'\nimport MMenu from './MMenu.vue'\nimport MMenuItem from './MMenuItem.vue'\nimport MProgressBar from './MProgressBar.vue'\nimport MTextField from './MTextField.vue'\nimport MButton from './MButton.vue'\nimport MLoadingIndicator from './MLoadingIndicator.vue'\n\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(defineProps<{\n /** The PDF: a URL, its bytes, or a `File`/`Blob` */\n src?: PdfSource | null\n /** Shown in the top bar; default the document's own title */\n title?: string\n /** Current page, 1-based (v-model) */\n page?: number\n /** `fit-width`, `fit-page`, or a zoom where 1 is 100% (v-model) */\n zoom?: PdfZoom\n /** Extra rotation in degrees, a multiple of 90 (v-model) */\n rotation?: number\n /** Annotations to draw (v-model) */\n annotations?: PdfAnnotation[]\n /** Shows the edit button and the annotation toolbar */\n annotate?: boolean\n /** The active tool (v-model) */\n tool?: PdfTool\n /** Colors offered for annotations */\n colors?: string[]\n /** The pen's widths offered in the toolbar, in PDF points (the first one is the default) */\n inkWidths?: number[]\n /** Written into new annotations' `author` */\n author?: string\n /** The side panel: thumbnails, the outline, or closed (v-model) */\n sidebar?: 'thumbnails' | 'outline' | null\n /** Shows the top bar */\n toolbar?: boolean\n /** Shows download and print */\n downloadable?: boolean\n /** File name for downloads; default the URL's or the document's title */\n fileName?: string\n /** A password to try first */\n password?: string\n /** The pdf.js worker URL (or `setPdfWorker()` once for the app) */\n workerSrc?: string\n minZoom?: number\n maxZoom?: number\n}>(), {\n src: null,\n page: undefined,\n zoom: 'fit-width',\n rotation: 0,\n annotations: () => [],\n annotate: false,\n tool: 'select',\n colors: () => ['#FFE14D', '#7ED957', '#5EB8FF', '#FF7EB6', '#B388FF', '#1F1F1F'],\n inkWidths: () => [1, 2, 4, 8],\n sidebar: null,\n toolbar: true,\n downloadable: true,\n minZoom: 0.25,\n maxZoom: 8,\n})\n\nconst emit = defineEmits<{\n 'update:page': [number]\n 'update:zoom': [PdfZoom]\n 'update:rotation': [number]\n 'update:annotations': [PdfAnnotation[]]\n 'update:tool': [PdfTool]\n 'update:sidebar': ['thumbnails' | 'outline' | null]\n loaded: [PdfDocument]\n error: [Error]\n link: [{ url?: string; page?: number }]\n 'annotation-click': [PdfAnnotation]\n}>()\n\nconst locale = useLocale()\nconst pdf = usePdf(() => props.src, { password: () => props.password, workerSrc: props.workerSrc })\nwatch(pdf.doc, (d) => { if (d) emit('loaded', d) })\nwatch(pdf.error, (e) => { if (e) emit('error', e) })\n\nconst root = ref<HTMLElement>()\nconst scroller = ref<HTMLElement>()\nconst viewW = ref(800)\nconst viewH = ref(600)\nconst rootW = ref(800)\nconst compact = computed(() => rootW.value < 600)\n\n// ── Layout: CSS px per PDF point at 100% (pdf.js's and the browser's 100%), page gap and padding ─────────\nconst PT = 96 / 72\nconst GAP = 8\nconst PAD = 16\nconst rotation = ref(((props.rotation % 360) + 360) % 360)\nwatch(() => props.rotation, (r) => { rotation.value = ((r % 360) + 360) % 360 })\n\nconst sizes = computed(() => {\n const swap = rotation.value % 180 !== 0\n return pdf.pageSizes.value.map((s) => (swap ? { width: s.height, height: s.width } : s))\n})\nconst zoomMode = ref<PdfZoom>(props.zoom)\nwatch(() => props.zoom, (z) => { if (z !== zoomMode.value) setZoom(z) })\n\nconst refSize = computed(() => sizes.value[Math.max(0, currentPage.value - 1)] ?? sizes.value[0] ?? { width: 612, height: 792 })\nfunction fitScale(mode: 'fit-width' | 'fit-page') {\n const w = (viewW.value - 2 * (compact.value ? 8 : PAD)) / refSize.value.width\n if (mode === 'fit-width') return w\n return Math.min(w, (viewH.value - 2 * PAD) / refSize.value.height)\n}\n// The scale actually used (px per point); a numeric zoom is relative to 100%\nconst scale = computed(() => {\n const z = zoomMode.value\n const s = typeof z === 'number' ? z * PT : fitScale(z)\n return Math.max(props.minZoom * PT, Math.min(props.maxZoom * PT, s || PT))\n})\nconst zoomPercent = computed(() => Math.round((scale.value / PT) * 100))\n\nconst layout = computed(() => {\n const pad = compact.value ? 8 : PAD\n let y = pad\n let maxW = 0\n const boxes = sizes.value.map((s) => {\n const w = Math.floor(s.width * scale.value)\n const h = Math.floor(s.height * scale.value)\n const box = { top: y, width: w, height: h }\n y += h + GAP\n maxW = Math.max(maxW, w)\n return box\n })\n return { boxes, height: y - GAP + pad, width: maxW + 2 * pad, pad }\n})\n\n// ── Scroll position → current page and the pages to render ──────────────────────────────────────────────\nconst scrollTop = ref(0)\nfunction pageAt(y: number) {\n const boxes = layout.value.boxes\n let lo = 0\n let hi = boxes.length - 1\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1\n if (boxes[mid]!.top <= y) lo = mid\n else hi = mid - 1\n }\n return lo\n}\nconst currentPage = ref(1)\nfunction updateCurrent() {\n if (!layout.value.boxes.length) return\n // The page under a third of the way down the view\n const p = pageAt(scrollTop.value + viewH.value / 3) + 1\n if (p !== currentPage.value) {\n currentPage.value = p\n emit('update:page', p)\n }\n}\nconst activePages = computed(() => {\n const boxes = layout.value.boxes\n if (!boxes.length) return new Set<number>()\n const a = pageAt(Math.max(0, scrollTop.value - viewH.value))\n const b = pageAt(scrollTop.value + viewH.value * 2)\n const set = new Set<number>()\n for (let i = a; i <= b; i++) set.add(i + 1)\n return set\n})\n\nlet scrollingTimer: ReturnType<typeof setTimeout> | undefined\nconst scrolling = ref(false)\n// A scroll we made to keep the reading point through a resize: no page indicator for it\nlet keptTop: number | null = null\nfunction onScroll() {\n const el = scroller.value!\n scrollTop.value = el.scrollTop\n updateCurrent()\n if (keptTop !== null && Math.abs(el.scrollTop - keptTop) < 1) {\n keptTop = null\n return\n }\n keptTop = null\n scrolling.value = true\n clearTimeout(scrollingTimer)\n scrollingTimer = setTimeout(() => (scrolling.value = false), 1200)\n}\n\nfunction goTo(page: number, top?: number, smooth = false) {\n const el = scroller.value\n const box = layout.value.boxes[page - 1]\n if (!el || !box) return\n // A destination's `top` is in PDF points from the page's bottom (unrotated pages only)\n const size = sizes.value[page - 1]!\n const within = top !== undefined && rotation.value === 0 ? Math.max(0, (size.height - top) * scale.value) : 0\n el.scrollTo({ top: box.top + within - (within ? 8 : layout.value.pad), behavior: smooth ? 'smooth' : 'auto' })\n currentPage.value = page\n emit('update:page', page)\n}\nwatch(() => props.page, (p) => { if (p && p !== currentPage.value) goTo(p) })\n\n// ── Zoom about a point, keeping what's under it in place ────────────────────────────────────────────────\nfunction setZoom(z: PdfZoom, anchor?: { x: number; y: number }) {\n const el = scroller.value\n const nextScale = typeof z === 'number' ? Math.max(props.minZoom, Math.min(props.maxZoom, z)) : z\n if (!el || !layout.value.boxes.length) {\n zoomMode.value = nextScale\n emit('update:zoom', nextScale)\n return\n }\n const r = el.getBoundingClientRect()\n const ax = anchor ? anchor.x - r.left : el.clientWidth / 2\n const ay = anchor ? anchor.y - r.top : el.clientHeight / 2\n const docY = el.scrollTop + ay\n const i = pageAt(docY)\n const box = layout.value.boxes[i]!\n const fy = (docY - box.top) / box.height\n const contentW = Math.max(layout.value.width, el.clientWidth)\n const left = (contentW - box.width) / 2\n const fx = (el.scrollLeft + ax - left) / box.width\n zoomMode.value = nextScale\n emit('update:zoom', nextScale)\n nextTick(() => {\n const nb = layout.value.boxes[i]!\n const nContentW = Math.max(layout.value.width, el.clientWidth)\n el.scrollTop = nb.top + fy * nb.height - ay\n el.scrollLeft = (nContentW - nb.width) / 2 + fx * nb.width - ax\n onScroll()\n })\n}\nconst zoomBy = (f: number, anchor?: { x: number; y: number }) => setZoom((scale.value / PT) * f, anchor)\nconst ZOOM_STEPS = [0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4]\nfunction stepZoom(dir: 1 | -1) {\n const z = scale.value / PT\n const next = dir > 0 ? ZOOM_STEPS.find((s) => s > z + 0.01) ?? props.maxZoom : [...ZOOM_STEPS].reverse().find((s) => s < z - 0.01) ?? props.minZoom\n setZoom(next)\n}\n\n// Ctrl + wheel (a trackpad pinch arrives as one too)\nfunction onWheel(e: WheelEvent) {\n if (!e.ctrlKey && !e.metaKey) return\n e.preventDefault()\n zoomBy(Math.exp(-e.deltaY * (e.deltaMode === 1 ? 0.05 : 0.0025)), { x: e.clientX, y: e.clientY })\n}\n\n// Double click / double tap: zoom in there, or back to the width (androidx.pdf's double tap)\nfunction onDblClick(e: MouseEvent) {\n if (props.tool !== 'select' || (e.target as HTMLElement).closest('button, a, input, textarea')) return\n const fit = fitScale('fit-width')\n if (scale.value > fit * 1.05) setZoom('fit-width', { x: e.clientX, y: e.clientY })\n else setZoom(Math.min(props.maxZoom, (fit * 2) / PT), { x: e.clientX, y: e.clientY })\n}\n\n// Pinch on touch: pdf.js's TouchManager owns two-finger gestures (one finger still scrolls natively)\nlet touchAC: AbortController | null = null\nlet pinchFrame = 0\nlet pinchFactor = 1\nlet pinchOrigin = { x: 0, y: 0 }\nfunction setupPinch() {\n const lib = pdf.pdfjs.value\n const el = scroller.value\n if (!lib || !el || touchAC) return\n touchAC = new AbortController()\n new lib.TouchManager({\n container: el,\n isPinchingDisabled: () => props.tool === 'ink',\n onPinching: (origin: [number, number], prevDistance: number, distance: number) => {\n pinchFactor *= distance / (prevDistance || distance)\n pinchOrigin = { x: origin[0], y: origin[1] }\n pinchFrame ||= requestAnimationFrame(() => {\n pinchFrame = 0\n const f = pinchFactor\n pinchFactor = 1\n zoomBy(f, pinchOrigin)\n })\n },\n signal: touchAC.signal,\n })\n}\nwatch(() => pdf.pdfjs.value, setupPinch)\n\n// ── Fit modes follow the size; a new document starts at the top ─────────────────────────────────────────\nlet ro: ResizeObserver | undefined\nwatch(pdf.doc, async (d) => {\n if (!d) return\n await nextTick()\n const p = props.page && props.page <= d.numPages ? props.page : 1\n currentPage.value = p\n if (p > 1) goTo(p)\n else if (scroller.value) scroller.value.scrollTop = 0\n setupPinch()\n})\n\n// ── Rotation ────────────────────────────────────────────────────────────────────────────────────────────\nfunction rotate() {\n const page = currentPage.value\n rotation.value = (rotation.value + 90) % 360\n emit('update:rotation', rotation.value)\n nextTick(() => goTo(page))\n}\n\n// ── Search ──────────────────────────────────────────────────────────────────────────────────────────────\nconst searchOpen = ref(false)\nconst query = ref('')\nconst matches = shallowRef<{ page: number; start: number; end: number }[]>([])\nconst matchIndex = ref(-1)\nconst searching = ref(false)\nlet searchAC: AbortController | null = null\nlet searchTimer: ReturnType<typeof setTimeout> | undefined\nwatch(query, (q) => {\n clearTimeout(searchTimer)\n searchTimer = setTimeout(() => runSearch(q), 250)\n})\nasync function runSearch(q: string) {\n searchAC?.abort()\n matches.value = []\n matchIndex.value = -1\n if (!q.trim() || !pdf.doc.value) return\n const ac = (searchAC = new AbortController())\n searching.value = true\n const found = await pdf.search(q, { signal: ac.signal })\n if (ac.signal.aborted) return\n searching.value = false\n matches.value = found\n // The first hit at or after the current page\n const i = found.findIndex((m) => m.page >= currentPage.value)\n if (found.length) showMatch(i < 0 ? 0 : i)\n}\nfunction showMatch(i: number) {\n const n = matches.value.length\n if (!n) return\n matchIndex.value = ((i % n) + n) % n\n const m = matches.value[matchIndex.value]!\n // Scroll its page in, then the hit itself once marked\n if (!activePages.value.has(m.page) || Math.abs(m.page - currentPage.value) > 0) goTo(m.page)\n pendingHitScroll = true\n}\nlet pendingHitScroll = false\nconst hitsByPage = computed(() => {\n const map = new Map<number, { start: number; end: number; current: boolean }[]>()\n matches.value.forEach((m, i) => {\n const list = map.get(m.page) ?? []\n list.push({ start: m.start, end: m.end, current: i === matchIndex.value })\n map.set(m.page, list)\n })\n return map\n})\nconst NO_HITS: { start: number; end: number; current: boolean }[] = []\nconst pageRefs = reactive(new Map<number, InstanceType<typeof PdfPageView>>())\nfunction setPageRef(n: number, el: unknown) {\n if (el) pageRefs.set(n, el as InstanceType<typeof PdfPageView>)\n else pageRefs.delete(n)\n}\n// Once the focused hit is marked in its page's text layer, bring it to the middle of the view\nwatch(() => {\n const m = matches.value[matchIndex.value]\n return m ? pageRefs.get(m.page)?.currentHit : null\n}, (el) => {\n if (!el || !pendingHitScroll || !scroller.value) return\n pendingHitScroll = false\n const r = (el as HTMLElement).getBoundingClientRect()\n const s = scroller.value.getBoundingClientRect()\n scroller.value.scrollBy({ top: r.top - s.top - s.height / 2, left: r.left < s.left || r.right > s.right ? r.left - s.left - s.width / 2 : 0 })\n})\nfunction openSearch() {\n searchOpen.value = true\n nextTick(() => root.value?.querySelector<HTMLInputElement>('.m3-pdf-search input')?.focus())\n}\nfunction closeSearch() {\n searchOpen.value = false\n query.value = ''\n searchAC?.abort()\n matches.value = []\n matchIndex.value = -1\n}\nconst matchText = computed(() =>\n !query.value.trim() ? '' : searching.value ? '…' : matches.value.length ? locale.pdfMatchCount.replace('{current}', String(matchIndex.value + 1)).replace('{total}', String(matches.value.length)) : locale.pdfNoMatches,\n)\n\n// ── Side panel: thumbnails and outline ──────────────────────────────────────────────────────────────────\nconst panel = ref<'thumbnails' | 'outline' | null>(props.sidebar)\nwatch(() => props.sidebar, (v) => { panel.value = v })\nfunction setPanel(v: 'thumbnails' | 'outline' | null) {\n panel.value = v\n emit('update:sidebar', v)\n}\nconst thumbs = reactive(new Map<number, string>())\nconst thumbList = ref<HTMLElement>()\nlet thumbObserver: IntersectionObserver | null = null\nfunction observeThumb(el: unknown, n: number) {\n if (!(el instanceof HTMLElement)) return\n el.dataset.page = String(n)\n thumbObserver?.observe(el)\n}\nwatch([panel, pdf.doc], async ([p, d]) => {\n thumbObserver?.disconnect()\n thumbs.clear()\n if (p !== 'thumbnails' || !d || typeof IntersectionObserver === 'undefined') return\n await nextTick()\n thumbObserver = new IntersectionObserver((entries) => {\n for (const e of entries) {\n if (!e.isIntersecting) continue\n const n = Number((e.target as HTMLElement).dataset.page)\n if (thumbs.has(n)) continue\n thumbs.set(n, '')\n pdf.thumbnail(n, 120).then((url) => thumbs.set(n, url), () => {})\n }\n }, { root: thumbList.value, rootMargin: '200px' })\n thumbList.value?.querySelectorAll<HTMLElement>('[data-page]').forEach((el) => thumbObserver!.observe(el))\n thumbList.value?.querySelector(`[data-page=\"${currentPage.value}\"]`)?.scrollIntoView({ block: 'center' })\n})\nfunction pickFromPanel(page: number, top?: number) {\n goTo(page, top)\n if (compact.value) setPanel(null)\n}\nconst outlineOpen = reactive(new Set<string>())\ntype FlatOutline = { key: string; title: string; page?: number; top?: number; url?: string; depth: number; hasChildren: boolean }\nconst flatOutline = computed(() => {\n const out: FlatOutline[] = []\n const walk = (items: typeof pdf.outline.value, depth: number, prefix: string) => {\n items.forEach((it, i) => {\n const key = `${prefix}${i}`\n out.push({ key, title: it.title, page: it.page, top: it.top, url: it.url, depth, hasChildren: it.children.length > 0 })\n if (it.children.length && outlineOpen.has(key)) walk(it.children, depth + 1, `${key}.`)\n })\n }\n walk(pdf.outline.value, 0, '')\n return out\n})\nfunction toggleOutline(key: string) {\n if (outlineOpen.has(key)) outlineOpen.delete(key)\n else outlineOpen.add(key)\n}\n\n// ── Links ───────────────────────────────────────────────────────────────────────────────────────────────\nasync function onLink(l: { url?: string; dest?: unknown }) {\n if (l.url) {\n emit('link', { url: l.url })\n return\n }\n const at = await pdf.resolveDest(l.dest)\n if (!at) return\n goTo(at.page, at.top)\n emit('link', { page: at.page })\n}\n\n// ── Annotations ─────────────────────────────────────────────────────────────────────────────────────────\nconst tool = ref<PdfTool>(props.tool)\nwatch(() => props.tool, (t) => { tool.value = t })\nfunction setTool(t: PdfTool) {\n tool.value = t\n emit('update:tool', t)\n selection.value = null\n selected.value = null\n}\nconst color = ref(props.colors[0]!)\nconst inkWidth = ref(props.inkWidths[1] ?? props.inkWidths[0] ?? 2)\nconst editing = ref(false)\nwatch(() => props.annotate, (on) => { if (!on) closeEditing() })\nfunction openEditing() {\n editing.value = true\n setTool('highlight')\n}\nfunction closeEditing() {\n editing.value = false\n setTool('select')\n}\n\nconst byPage = computed(() => {\n const map = new Map<number, PdfAnnotation[]>()\n for (const a of props.annotations) {\n const list = map.get(a.page) ?? []\n list.push(a)\n map.set(a.page, list)\n }\n return map\n})\nconst NO_ANNOTATIONS: PdfAnnotation[] = []\nconst history: PdfAnnotation[][] = []\nfunction commit(next: PdfAnnotation[]) {\n history.push(props.annotations)\n if (history.length > 50) history.shift()\n canUndo.value = true\n emit('update:annotations', next)\n}\nconst canUndo = ref(false)\nfunction undo() {\n const prev = history.pop()\n canUndo.value = history.length > 0\n if (prev) emit('update:annotations', prev)\n selected.value = null\n}\nfunction add(a: PdfAnnotation) {\n if (props.author) a.author = props.author\n commit([...props.annotations, a])\n // A new note opens for its text\n if (a.type === 'note') nextTick(() => selectById(a.id))\n}\nfunction erase(id: string) {\n commit(props.annotations.filter((a) => a.id !== id))\n if (selected.value?.id === id) selected.value = null\n}\n// The eraser dragged across a page: one undo step per stroke of it\nfunction eraseStart() {\n history.push(props.annotations)\n if (history.length > 50) history.shift()\n canUndo.value = true\n}\nfunction eraseAt(page: number, at: { x: number; y: number; r: number }) {\n let changed = false\n const next: PdfAnnotation[] = []\n for (const a of props.annotations) {\n const kept = a.page === page ? eraseFrom(a, at) : a\n if (kept !== a) changed = true\n if (kept) next.push(kept)\n }\n if (!changed) return\n if (selected.value && !next.some((a) => a.id === selected.value!.id)) selected.value = null\n emit('update:annotations', next)\n}\nfunction update(id: string, patch: Partial<PdfAnnotation>) {\n emit('update:annotations', props.annotations.map((a) => (a.id === id ? { ...a, ...patch } : a)))\n}\n\n// The selected annotation's card, and the popup over a text selection, placed near what they're about\nconst selected = ref<{ id: string; x: number; y: number } | null>(null)\nconst selectedAnnotation = computed(() => props.annotations.find((a) => a.id === selected.value?.id) ?? null)\nfunction place(anchor: DOMRect) {\n const r = root.value!.getBoundingClientRect()\n return { x: Math.min(Math.max(8, anchor.left - r.left + anchor.width / 2), r.width - 8), y: anchor.bottom - r.top + 8 }\n}\nfunction onSelect(s: { id: string; anchor: DOMRect } | null) {\n if (!s) {\n selected.value = null\n return\n }\n selection.value = null\n selected.value = { id: s.id, ...place(s.anchor) }\n const a = props.annotations.find((x) => x.id === s.id)\n if (a) emit('annotation-click', a)\n}\nfunction selectById(id: string) {\n const el = root.value?.querySelector(`.m3-pdf-note[aria-label]`)\n const a = props.annotations.find((x) => x.id === id)\n if (!a) return\n const page = pageRefs.get(a.page)?.root as HTMLElement | undefined\n const target = [...(page?.querySelectorAll<HTMLElement>('.m3-pdf-note') ?? [])].pop() ?? el\n if (target) selected.value = { id, ...place(target.getBoundingClientRect()) }\n}\nconst cardStyle = computed(() => {\n const s = selected.value ?? selection.value\n if (!s) return {}\n const w = Math.min(300, rootW.value - 16)\n return { left: `${Math.min(Math.max(8, s.x - w / 2), rootW.value - w - 8)}px`, top: `${s.y}px`, width: `${w}px` }\n})\n\nconst selection = ref<{ page: number; rects: [number, number, number, number][]; quote: string; x: number; y: number } | null>(null)\nfunction onTextSelection(s: { page: number; rects: [number, number, number, number][]; quote: string; anchor: DOMRect } | null) {\n if (!s || !props.annotate) {\n selection.value = null\n return\n }\n selected.value = null\n selection.value = { page: s.page, rects: s.rects, quote: s.quote, ...place(s.anchor) }\n}\nfunction highlightSelection() {\n const s = selection.value\n if (!s) return\n add({ id: crypto.randomUUID?.() ?? String(Date.now()), type: 'highlight', page: s.page, color: color.value, rects: s.rects, quote: s.quote, text: '', createdAt: new Date().toISOString() })\n window.getSelection()?.removeAllRanges()\n selection.value = null\n}\nasync function copySelection() {\n const s = selection.value\n if (s) await navigator.clipboard?.writeText(s.quote).catch(() => {})\n window.getSelection()?.removeAllRanges()\n selection.value = null\n}\n// Scrolling moves the anchors away: close the floating cards\nwatch(scrollTop, () => {\n selection.value = null\n if (selectedAnnotation.value?.type !== 'note') selected.value = null\n})\n\n// ── Fast scroll (touch): a thumb on the edge while scrolling, with the page ─────────────────────────────\nconst coarse = typeof window !== 'undefined' && !!window.matchMedia?.('(pointer: coarse)').matches\nconst thumbTop = computed(() => {\n const el = scroller.value\n const max = layout.value.height - viewH.value\n void scrollTop.value\n return el && max > 0 ? (scrollTop.value / max) * (viewH.value - 48) : 0\n})\nconst dragging = ref(false)\nfunction onThumbDown(e: PointerEvent) {\n e.preventDefault()\n dragging.value = true\n ;(e.currentTarget as Element).setPointerCapture(e.pointerId)\n const startY = e.clientY\n const start = scroller.value!.scrollTop\n const max = layout.value.height - viewH.value\n const move = (ev: PointerEvent) => {\n scroller.value!.scrollTop = start + ((ev.clientY - startY) / Math.max(1, viewH.value - 48)) * max\n }\n const up = () => {\n dragging.value = false\n window.removeEventListener('pointermove', move)\n window.removeEventListener('pointerup', up)\n }\n window.addEventListener('pointermove', move)\n window.addEventListener('pointerup', up)\n}\n\n// ── Full screen ─────────────────────────────────────────────────────────────────────────────────────────\nconst fullscreen = ref(false)\nasync function toggleFullscreen() {\n if (document.fullscreenElement) await document.exitFullscreen().catch(() => {})\n else await root.value?.requestFullscreen?.().catch(() => {})\n}\nconst onFullscreenChange = () => { fullscreen.value = document.fullscreenElement === root.value }\n\n// ── Keys ────────────────────────────────────────────────────────────────────────────────────────────────\nfunction onKey(e: KeyboardEvent) {\n const t = e.target as HTMLElement\n const typing = !!t.closest('input, textarea, [contenteditable]')\n const mod = e.ctrlKey || e.metaKey\n if (mod && e.key.toLowerCase() === 'f') {\n e.preventDefault()\n openSearch()\n } else if (mod && (e.key === '=' || e.key === '+')) {\n e.preventDefault()\n stepZoom(1)\n } else if (mod && e.key === '-') {\n e.preventDefault()\n stepZoom(-1)\n } else if (mod && e.key === '0') {\n e.preventDefault()\n setZoom('fit-width')\n } else if (mod && e.key.toLowerCase() === 'z' && !typing && props.annotate) {\n e.preventDefault()\n undo()\n } else if (e.key === 'Escape') {\n if (selected.value || selection.value) {\n selected.value = null\n selection.value = null\n } else if (searchOpen.value) closeSearch()\n else if (editing.value) closeEditing()\n else return\n e.stopPropagation()\n } else if (!typing && (e.key === 'Delete' || e.key === 'Backspace') && selected.value) {\n erase(selected.value.id)\n } else if (!typing && !mod && (e.key === 'PageDown' || e.key === 'PageUp')) {\n e.preventDefault()\n goTo(Math.max(1, Math.min(pdf.numPages.value, currentPage.value + (e.key === 'PageDown' ? 1 : -1))))\n }\n}\n\n// ── Page field ──────────────────────────────────────────────────────────────────────────────────────────\nconst pageInput = ref('')\nwatch(currentPage, (p) => { pageInput.value = String(p) }, { immediate: true })\nfunction commitPageInput() {\n const n = Math.round(Number(pageInput.value))\n if (n >= 1 && n <= pdf.numPages.value) goTo(n)\n else pageInput.value = String(currentPage.value)\n}\n\n// ── Password ────────────────────────────────────────────────────────────────────────────────────────────\nconst passwordInput = ref('')\nfunction submitPassword() {\n pdf.submitPassword(passwordInput.value)\n passwordInput.value = ''\n}\n\nconst docTitle = computed(() => props.title ?? pdf.metadata.value.title ?? '')\n\nonMounted(() => {\n const el = scroller.value!\n el.addEventListener('wheel', onWheel, { passive: false })\n ro = new ResizeObserver(() => {\n // A fit mode rescales every page when the size changes (the side panel opening, a rotated phone):\n // keep the point being read, a third of the way down like the current page, where it was\n const boxes = layout.value.boxes\n const ay = viewH.value / 3\n const i = boxes.length ? pageAt(el.scrollTop + ay) : -1\n const fy = i >= 0 ? (el.scrollTop + ay - boxes[i]!.top) / boxes[i]!.height : 0\n viewW.value = el.clientWidth\n viewH.value = el.clientHeight\n rootW.value = root.value?.clientWidth ?? rootW.value\n if (i < 0) return\n nextTick(() => {\n const nb = layout.value.boxes[i]\n if (!nb) return\n const top = Math.round(nb.top + fy * nb.height - ay)\n if (Math.abs(top - el.scrollTop) < 1) return\n el.scrollTop = top\n scrollTop.value = el.scrollTop\n updateCurrent()\n keptTop = el.scrollTop\n })\n })\n ro.observe(el)\n ro.observe(root.value!)\n viewW.value = el.clientWidth || viewW.value\n viewH.value = el.clientHeight || viewH.value\n rootW.value = root.value!.clientWidth || rootW.value\n document.addEventListener('fullscreenchange', onFullscreenChange)\n})\nonBeforeUnmount(() => {\n ro?.disconnect()\n touchAC?.abort()\n thumbObserver?.disconnect()\n searchAC?.abort()\n cancelAnimationFrame(pinchFrame)\n clearTimeout(scrollingTimer)\n clearTimeout(searchTimer)\n document.removeEventListener('fullscreenchange', onFullscreenChange)\n})\n\ndefineExpose({\n pdf,\n goToPage: (p: number) => goTo(p),\n setZoom: (z: PdfZoom) => setZoom(z),\n search: (q: string) => { openSearch(); query.value = q },\n undo,\n})\n\nconst TOOLS = computed(() => [\n { id: 'select' as const, icon: 'arrow_selector_tool', label: locale.pdfSelect },\n { id: 'highlight' as const, icon: 'ink_highlighter', label: locale.pdfHighlight },\n { id: 'note' as const, icon: 'sticky_note_2', label: locale.pdfNote },\n { id: 'ink' as const, icon: 'draw', label: locale.pdfDraw },\n { id: 'eraser' as const, icon: 'ink_eraser', label: locale.pdfEraser },\n])\n</script>\n\n<template>\n <div\n ref=\"root\"\n v-bind=\"$attrs\"\n role=\"region\"\n :aria-label=\"docTitle || locale.pdfViewer\"\n class=\"m3-pdf bg-surface-container text-on-surface\"\n @keydown=\"onKey\"\n >\n <!-- Top bar -->\n <div v-if=\"toolbar\" class=\"relative z-10 flex h-16 shrink-0 items-center gap-1 bg-surface-container px-1 sm:px-2\">\n <MIconButton\n :icon=\"panel ? 'left_panel_close' : 'left_panel_open'\"\n :label=\"locale.pdfThumbnails\"\n :disabled=\"!pdf.doc.value\"\n @click=\"setPanel(panel ? null : 'thumbnails')\"\n />\n <p class=\"min-w-0 flex-1 truncate px-1 text-title-medium\">{{ docTitle }}</p>\n\n <template v-if=\"pdf.doc.value\">\n <div v-if=\"!compact\" class=\"flex items-center gap-1 text-body-medium text-on-surface-variant\">\n <input\n v-model=\"pageInput\"\n inputmode=\"numeric\"\n class=\"h-8 w-11 rounded-sm bg-surface-container-highest text-center text-body-medium text-on-surface tabular-nums outline-none focus:ring-2 focus:ring-primary\"\n :aria-label=\"locale.pdfPage\"\n @keydown.enter=\"commitPageInput\"\n @blur=\"commitPageInput\"\n />\n <span class=\"tabular-nums\">/ {{ pdf.numPages.value }}</span>\n </div>\n <div v-if=\"!compact\" class=\"mx-1 flex items-center\">\n <MIconButton icon=\"remove\" :label=\"locale.pdfZoomOut\" size=\"xs\" @click=\"stepZoom(-1)\" />\n <MMenu align=\"right\">\n <template #trigger>\n <button type=\"button\" class=\"h-8 min-w-14 cursor-pointer rounded-full px-2 text-label-large tabular-nums hover:bg-on-surface/8\" :aria-label=\"locale.pdfZoom\">{{ zoomPercent }}%</button>\n </template>\n <MMenuItem icon=\"fit_width\" :selected=\"zoomMode === 'fit-width'\" @click=\"setZoom('fit-width')\">{{ locale.pdfFitWidth }}</MMenuItem>\n <MMenuItem icon=\"fit_page\" :selected=\"zoomMode === 'fit-page'\" @click=\"setZoom('fit-page')\">{{ locale.pdfFitPage }}</MMenuItem>\n <MMenuItem v-for=\"z in ZOOM_STEPS\" :key=\"z\" :selected=\"zoomMode === z\" @click=\"setZoom(z)\">{{ z * 100 }}%</MMenuItem>\n </MMenu>\n <MIconButton icon=\"add\" :label=\"locale.pdfZoomIn\" size=\"xs\" @click=\"stepZoom(1)\" />\n </div>\n <MIconButton icon=\"search\" :label=\"locale.pdfSearch\" :checked=\"searchOpen\" @update:checked=\"(v: boolean) => (v ? openSearch() : closeSearch())\" />\n <slot name=\"actions\" :pdf=\"pdf\" />\n <MMenu align=\"right\">\n <template #trigger>\n <MIconButton icon=\"more_vert\" :label=\"locale.pdfMore\" />\n </template>\n <template v-if=\"compact\">\n <MMenuItem icon=\"zoom_in\" @click=\"stepZoom(1)\">{{ locale.pdfZoomIn }}</MMenuItem>\n <MMenuItem icon=\"zoom_out\" @click=\"stepZoom(-1)\">{{ locale.pdfZoomOut }}</MMenuItem>\n <MMenuItem icon=\"fit_width\" @click=\"setZoom('fit-width')\">{{ locale.pdfFitWidth }}</MMenuItem>\n </template>\n <MMenuItem icon=\"list\" :disabled=\"!pdf.outline.value.length\" @click=\"setPanel('outline')\">{{ locale.pdfOutline }}</MMenuItem>\n <MMenuItem icon=\"rotate_right\" @click=\"rotate\">{{ locale.pdfRotate }}</MMenuItem>\n <MMenuItem v-if=\"downloadable\" icon=\"download\" @click=\"pdf.download(fileName)\">{{ locale.pdfDownload }}</MMenuItem>\n <MMenuItem v-if=\"downloadable\" icon=\"print\" @click=\"pdf.print()\">{{ locale.pdfPrint }}</MMenuItem>\n <MMenuItem :icon=\"fullscreen ? 'fullscreen_exit' : 'fullscreen'\" @click=\"toggleFullscreen\">{{ fullscreen ? locale.pdfExitFullscreen : locale.pdfFullscreen }}</MMenuItem>\n </MMenu>\n </template>\n <MProgressBar v-if=\"pdf.loading.value\" :value=\"pdf.progress.value ? pdf.progress.value * 100 : undefined\" :indeterminate=\"!pdf.progress.value\" class=\"absolute inset-x-0 bottom-0\" />\n </div>\n\n <!-- Search -->\n <Transition name=\"m3-pdf-drop\">\n <div v-if=\"searchOpen\" class=\"m3-pdf-search z-10 flex shrink-0 items-center gap-1 bg-surface-container px-2 pb-2\">\n <div class=\"flex h-12 min-w-0 flex-1 items-center gap-2 rounded-full bg-surface-container-highest pr-1 pl-4\">\n <MIcon name=\"search\" :size=\"20\" class=\"text-on-surface-variant\" />\n <input\n v-model=\"query\"\n type=\"search\"\n class=\"min-w-0 flex-1 bg-transparent text-body-large outline-none placeholder:text-on-surface-variant\"\n :placeholder=\"locale.pdfSearch\"\n :aria-label=\"locale.pdfSearch\"\n @keydown.enter.prevent=\"showMatch(matchIndex + ((($event as KeyboardEvent).shiftKey) ? -1 : 1))\"\n />\n <span class=\"shrink-0 text-label-medium whitespace-nowrap text-on-surface-variant tabular-nums\" aria-live=\"polite\">{{ matchText }}</span>\n <MIconButton icon=\"keyboard_arrow_up\" :label=\"locale.pdfSearchPrevious\" size=\"xs\" :disabled=\"!matches.length\" @click=\"showMatch(matchIndex - 1)\" />\n <MIconButton icon=\"keyboard_arrow_down\" :label=\"locale.pdfSearchNext\" size=\"xs\" :disabled=\"!matches.length\" @click=\"showMatch(matchIndex + 1)\" />\n </div>\n <MIconButton icon=\"close\" :label=\"locale.close\" @click=\"closeSearch\" />\n </div>\n </Transition>\n\n <div class=\"relative flex min-h-0 flex-1\">\n <!-- Side panel: inline on wide screens, over the pages on narrow ones -->\n <Transition name=\"m3-pdf-fade\">\n <div v-if=\"panel && compact\" class=\"absolute inset-0 z-20 bg-scrim/32\" @click=\"setPanel(null)\" />\n </Transition>\n <Transition name=\"m3-pdf-panel\">\n <aside\n v-if=\"panel && pdf.doc.value\"\n class=\"flex w-56 shrink-0 flex-col bg-surface-container\"\n :class=\"compact ? 'absolute inset-y-0 left-0 z-30 rounded-r-lg shadow-elevation-2' : 'relative'\"\n >\n <div class=\"flex shrink-0 gap-1 px-3 pt-1 pb-2\">\n <button\n v-for=\"tab in (['thumbnails', 'outline'] as const)\"\n :key=\"tab\"\n type=\"button\"\n class=\"h-8 flex-1 cursor-pointer rounded-full text-label-large transition-colors\"\n :class=\"panel === tab ? 'bg-secondary-container text-on-secondary-container' : 'text-on-surface-variant hover:bg-on-surface/8'\"\n :disabled=\"tab === 'outline' && !pdf.outline.value.length\"\n @click=\"setPanel(tab)\"\n >{{ tab === 'thumbnails' ? locale.pdfThumbnails : locale.pdfOutline }}</button>\n </div>\n <div v-if=\"panel === 'thumbnails'\" ref=\"thumbList\" class=\"min-h-0 flex-1 overflow-y-auto px-3 pb-3\">\n <div class=\"flex flex-col items-center gap-3\">\n <button\n v-for=\"n in pdf.numPages.value\"\n :key=\"n\"\n :ref=\"(el) => observeThumb(el, n)\"\n type=\"button\"\n class=\"group flex cursor-pointer flex-col items-center gap-1 outline-none\"\n :aria-label=\"`${locale.pdfPage} ${n}`\"\n :aria-current=\"n === currentPage ? 'page' : undefined\"\n @click=\"pickFromPanel(n)\"\n >\n <span\n class=\"block w-30 overflow-hidden rounded-sm bg-white shadow-elevation-1 ring-offset-2 ring-offset-surface-container transition-shadow group-focus-visible:ring-2 group-focus-visible:ring-secondary\"\n :class=\"n === currentPage && 'ring-3 ring-primary'\"\n :style=\"{ aspectRatio: `${sizes[n - 1]?.width ?? 3} / ${sizes[n - 1]?.height ?? 4}` }\"\n >\n <img v-if=\"thumbs.get(n)\" :src=\"thumbs.get(n)\" alt=\"\" class=\"h-full w-full object-contain\" :style=\"{ transform: rotation ? `rotate(${rotation}deg)` : undefined }\" />\n </span>\n <span class=\"text-label-medium tabular-nums\" :class=\"n === currentPage ? 'text-primary' : 'text-on-surface-variant'\">{{ n }}</span>\n </button>\n </div>\n </div>\n <nav v-else class=\"min-h-0 flex-1 overflow-y-auto px-2 pb-3\" :aria-label=\"locale.pdfOutline\">\n <div v-for=\"o in flatOutline\" :key=\"o.key\" class=\"flex items-center\" :style=\"{ paddingLeft: `${o.depth * 12}px` }\">\n <button\n v-if=\"o.hasChildren\"\n type=\"button\"\n class=\"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-on-surface-variant hover:bg-on-surface/8\"\n :aria-label=\"outlineOpen.has(o.key) ? locale.collapse : locale.expand\"\n @click=\"toggleOutline(o.key)\"\n ><MIcon :name=\"outlineOpen.has(o.key) ? 'expand_more' : 'chevron_right'\" :size=\"20\" /></button>\n <span v-else class=\"w-8 shrink-0\" />\n <component\n :is=\"o.url ? 'a' : 'button'\"\n :href=\"o.url\"\n :target=\"o.url ? '_blank' : undefined\"\n :type=\"o.url ? undefined : 'button'\"\n class=\"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-full px-3 text-left text-label-large hover:bg-on-surface/8\"\n @click=\"o.page && pickFromPanel(o.page, o.top)\"\n >\n <span class=\"min-w-0 flex-1 truncate\">{{ o.title }}</span>\n <span v-if=\"o.page\" class=\"text-label-small text-on-surface-variant tabular-nums\">{{ o.page }}</span>\n </component>\n </div>\n </nav>\n </aside>\n </Transition>\n\n <!-- Pages -->\n <div class=\"relative min-w-0 flex-1\">\n <div\n ref=\"scroller\"\n class=\"m3-pdf-scroller absolute inset-0 overflow-auto overscroll-contain bg-surface-container-highest outline-none\"\n :class=\"[tool === 'select' ? '' : 'm3-pdf-annotating', coarse && 'scrollbar-none']\"\n tabindex=\"0\"\n @scroll=\"onScroll\"\n @dblclick=\"onDblClick\"\n >\n <div\n v-if=\"pdf.doc.value\"\n class=\"relative mx-auto\"\n :style=\"{ width: `${layout.width}px`, height: `${layout.height}px` }\"\n >\n <div\n v-for=\"(box, i) in layout.boxes\"\n :key=\"i\"\n class=\"absolute left-1/2 -translate-x-1/2\"\n :style=\"{ top: `${box.top}px`, width: `${box.width}px`, height: `${box.height}px` }\"\n >\n <PdfPageView\n :ref=\"(el) => setPageRef(i + 1, el)\"\n :pdf=\"pdf\"\n :page=\"i + 1\"\n :scale=\"scale\"\n :rotation=\"rotation\"\n :active=\"activePages.has(i + 1)\"\n :hits=\"hitsByPage.get(i + 1) ?? NO_HITS\"\n :annotations=\"byPage.get(i + 1) ?? NO_ANNOTATIONS\"\n :tool=\"tool\"\n :color=\"color\"\n :ink-width=\"inkWidth\"\n :selected-id=\"selected?.id ?? null\"\n class=\"h-full w-full\"\n @link=\"onLink\"\n @add=\"add\"\n @erase=\"erase\"\n @erase-start=\"eraseStart\"\n @erase-at=\"(at: { x: number; y: number; r: number }) => eraseAt(i + 1, at)\"\n @select=\"onSelect\"\n @text-selection=\"onTextSelection\"\n />\n </div>\n </div>\n\n <div v-else-if=\"pdf.needsPassword.value\" class=\"flex h-full items-center justify-center p-6\">\n <form class=\"flex w-full max-w-sm flex-col items-center gap-4 rounded-xl bg-surface-container-low p-6 text-center shadow-elevation-1\" @submit.prevent=\"submitPassword\">\n <MIcon name=\"lock\" :size=\"32\" class=\"text-primary\" />\n <p class=\"text-title-medium\">{{ locale.pdfPassword }}</p>\n <MTextField\n v-model=\"passwordInput\"\n type=\"password\"\n :label=\"locale.pdfPasswordLabel\"\n :error=\"pdf.wrongPassword.value\"\n :error-label=\"pdf.wrongPassword.value ? locale.pdfWrongPassword : undefined\"\n autocomplete=\"off\"\n class=\"w-full\"\n />\n <MButton type=\"submit\" :disabled=\"!passwordInput\" class=\"self-end\">{{ locale.pdfOpen }}</MButton>\n </form>\n </div>\n <div v-else-if=\"pdf.error.value\" class=\"flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-on-surface-variant\">\n <MIcon name=\"error\" :size=\"32\" class=\"text-error\" />\n <p class=\"text-title-medium text-on-surface\">{{ locale.pdfError }}</p>\n <p class=\"text-body-medium\">{{ pdf.error.value.message }}</p>\n </div>\n <div v-else-if=\"pdf.loading.value\" class=\"flex h-full items-center justify-center\">\n <MLoadingIndicator :label=\"locale.pdfLoading\" />\n </div>\n <div v-else class=\"flex h-full items-center justify-center p-6\">\n <slot name=\"empty\" />\n </div>\n </div>\n\n <!-- Page indicator while scrolling; a draggable thumb on touch (androidx.pdf's fast scroller) -->\n <Transition name=\"m3-pdf-fade\">\n <div v-if=\"pdf.doc.value && (scrolling || dragging) && pdf.numPages.value > 1\" class=\"pointer-events-none absolute inset-y-0 right-0 w-full\">\n <div class=\"absolute right-1 flex items-center gap-2\" :style=\"{ top: `${coarse ? thumbTop : Math.min(viewH - 40, Math.max(8, thumbTop))}px` }\">\n <span class=\"rounded-full bg-inverse-surface px-3 py-1 text-label-large text-inverse-on-surface tabular-nums shadow-elevation-1\">{{ currentPage }} / {{ pdf.numPages.value }}</span>\n <span v-if=\"coarse\" class=\"pointer-events-auto flex h-12 w-6 touch-none items-center justify-center\" @pointerdown=\"onThumbDown\">\n <span class=\"h-12 w-1.5 rounded-full bg-on-surface-variant\" />\n </span>\n <span v-else class=\"w-3\" />\n </div>\n </div>\n </Transition>\n\n <!-- Edit button, and the annotation toolbar (androidx.pdf's edit FAB) -->\n <Transition name=\"m3-pdf-fade\">\n <button\n v-if=\"annotate && pdf.doc.value && !editing\"\n type=\"button\"\n class=\"absolute right-4 bottom-4 flex size-14 cursor-pointer items-center justify-center rounded-lg bg-primary-container text-on-primary-container shadow-elevation-3 transition-shadow outline-none hover:shadow-elevation-4 focus-visible:ring-2 focus-visible:ring-primary\"\n :aria-label=\"locale.pdfAnnotate\"\n @click=\"openEditing\"\n ><MIcon name=\"edit\" :size=\"24\" /></button>\n </Transition>\n <Transition name=\"m3-pdf-rise\">\n <div v-if=\"annotate && editing\" class=\"absolute inset-x-0 bottom-4 z-10 flex justify-center px-2\">\n <div class=\"flex max-w-full items-center gap-1 overflow-x-auto rounded-full bg-surface-container-high p-2 shadow-elevation-3 scrollbar-none\" role=\"toolbar\" :aria-label=\"locale.pdfAnnotate\">\n <MIconButton\n v-for=\"t in TOOLS\"\n :key=\"t.id\"\n :icon=\"t.icon\"\n :label=\"t.label\"\n :checked=\"tool === t.id\"\n variant=\"standard\"\n @update:checked=\"setTool(t.id)\"\n />\n <span class=\"mx-1 h-6 w-px shrink-0 bg-outline-variant\" />\n <button\n v-for=\"c in colors\"\n :key=\"c\"\n type=\"button\"\n class=\"flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n :aria-label=\"`${locale.pdfColor} ${c}`\"\n :aria-pressed=\"color === c\"\n @click=\"color = c\"\n >\n <span class=\"size-6 rounded-full border border-outline-variant transition-transform\" :class=\"color === c && 'scale-125 ring-2 ring-on-surface ring-offset-2 ring-offset-surface-container-high'\" :style=\"{ backgroundColor: c }\" />\n </button>\n <!-- The pen's widths, drawn as dots of their size -->\n <template v-if=\"tool === 'ink' && inkWidths.length > 1\">\n <span class=\"mx-1 h-6 w-px shrink-0 bg-outline-variant\" />\n <button\n v-for=\"w in inkWidths\"\n :key=\"w\"\n type=\"button\"\n class=\"flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-primary\"\n :class=\"inkWidth === w && 'bg-secondary-container'\"\n :aria-label=\"locale.pdfInkWidth.replace('{n}', String(w))\"\n :aria-pressed=\"inkWidth === w\"\n @click=\"inkWidth = w\"\n >\n <span class=\"rounded-full\" :style=\"{ width: `${Math.min(22, 3 + w * 2)}px`, height: `${Math.min(22, 3 + w * 2)}px`, backgroundColor: color }\" />\n </button>\n </template>\n <span class=\"mx-1 h-6 w-px shrink-0 bg-outline-variant\" />\n <MIconButton icon=\"undo\" :label=\"locale.pdfUndo\" :disabled=\"!canUndo\" @click=\"undo\" />\n <MIconButton icon=\"close\" :label=\"locale.close\" @click=\"closeEditing\" />\n </div>\n </div>\n </Transition>\n </div>\n </div>\n\n <!-- A text selection: copy, or highlight it -->\n <div v-if=\"selection\" class=\"absolute z-40 flex justify-center\" :style=\"cardStyle\">\n <div class=\"flex items-center gap-1 rounded-full bg-surface-container-high p-1 shadow-elevation-2\">\n <MButton variant=\"text\" icon=\"content_copy\" size=\"sm\" @click=\"copySelection\">{{ locale.pdfCopy }}</MButton>\n <MButton variant=\"text\" icon=\"ink_highlighter\" size=\"sm\" @click=\"highlightSelection\">{{ locale.pdfHighlight }}</MButton>\n </div>\n </div>\n\n <!-- The selected annotation -->\n <div v-if=\"selected && selectedAnnotation\" class=\"absolute z-40\" :style=\"cardStyle\" @keydown.stop=\"(e: KeyboardEvent) => e.key === 'Escape' && (selected = null)\">\n <div class=\"flex flex-col gap-3 rounded-lg bg-surface-container-high p-3 shadow-elevation-2\">\n <p v-if=\"selectedAnnotation.quote\" class=\"line-clamp-3 border-l-4 pl-2 text-body-medium text-on-surface-variant\" :style=\"{ borderColor: selectedAnnotation.color }\">{{ selectedAnnotation.quote }}</p>\n <MTextField\n :model-value=\"selectedAnnotation.text ?? ''\"\n :label=\"selectedAnnotation.type === 'note' ? locale.pdfNotePlaceholder : locale.pdfAddComment\"\n multiline\n auto-grow\n :rows=\"2\"\n :max-rows=\"6\"\n variant=\"outlined\"\n field-bg=\"var(--color-surface-container-high)\"\n @update:model-value=\"(v: string | number) => update(selectedAnnotation!.id, { text: String(v) })\"\n />\n <div class=\"flex items-center gap-1\">\n <button\n v-for=\"c in colors\"\n :key=\"c\"\n type=\"button\"\n class=\"flex size-8 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n :aria-label=\"`${locale.pdfColor} ${c}`\"\n :aria-pressed=\"selectedAnnotation.color === c\"\n @click=\"update(selectedAnnotation!.id, { color: c })\"\n >\n <span class=\"size-5 rounded-full border border-outline-variant\" :class=\"selectedAnnotation.color === c && 'ring-2 ring-on-surface ring-offset-1 ring-offset-surface-container-high'\" :style=\"{ backgroundColor: c }\" />\n </button>\n <span class=\"flex-1\" />\n <MIconButton icon=\"delete\" :label=\"locale.pdfDelete\" size=\"xs\" @click=\"erase(selectedAnnotation!.id)\" />\n <MIconButton icon=\"check\" :label=\"locale.close\" size=\"xs\" @click=\"selected = null\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style>\n/* Root defaults in the base layer, so any class the consumer gives (absolute inset-0, hidden…) wins */\n@layer base {\n .m3-pdf {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n}\n\n/* pdf.js's text layer (from pdfjs-dist's pdf_viewer.css, Apache-2.0), for selectable text over the canvas */\n.m3-pdf .textLayer {\n position: absolute;\n inset: 0;\n overflow: clip;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n z-index: 0;\n --min-font-size: 1;\n --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));\n --min-font-size-inv: calc(1 / var(--min-font-size));\n}\n.m3-pdf .textLayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n user-select: text;\n}\n.m3-pdf .textLayer > :not(.markedContent),\n.m3-pdf .textLayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n --scale-x: 1;\n --rotate: 0deg;\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n}\n.m3-pdf .textLayer .markedContent { display: contents; }\n.m3-pdf .textLayer span.m3-pdf-hit {\n position: static;\n margin: -1px;\n padding: 1px;\n border-radius: 3px;\n background-color: color-mix(in srgb, var(--color-tertiary) 30%, transparent);\n}\n.m3-pdf .textLayer span.m3-pdf-hit-current { background-color: color-mix(in srgb, var(--color-primary) 45%, transparent); }\n.m3-pdf .textLayer ::selection { background: color-mix(in srgb, var(--color-primary) 30%, transparent); color: transparent; }\n.m3-pdf .textLayer br::selection { background: transparent; }\n.m3-pdf .textLayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n user-select: none;\n}\n.m3-pdf .textLayer.selecting .endOfContent { top: 0; }\n.m3-pdf [data-main-rotation='90'] { transform: rotate(90deg) translateY(-100%); }\n.m3-pdf [data-main-rotation='180'] { transform: rotate(180deg) translate(-100%, -100%); }\n.m3-pdf [data-main-rotation='270'] { transform: rotate(270deg) translateX(-100%); }\n\n/* Highlights tint the text under them, like a marker */\n.m3-pdf .m3-pdf-highlight { mix-blend-mode: multiply; opacity: 0.45; }\n.m3-pdf .m3-pdf-annotating .m3-pdf-highlight,\n.m3-pdf .m3-pdf-annotating .m3-pdf-ink { cursor: inherit; }\n.m3-pdf .m3-pdf-scroller:not(.m3-pdf-annotating) :is(.m3-pdf-highlight, .m3-pdf-ink) { pointer-events: auto; cursor: pointer; }\n.m3-pdf .m3-pdf-scroller.m3-pdf-annotating :is(.m3-pdf-highlight, .m3-pdf-ink) { pointer-events: none; }\n.m3-pdf .m3-pdf-selected { filter: drop-shadow(0 0 2px var(--color-primary)); opacity: 0.7; }\n\n.m3-pdf-fade-enter-active,\n.m3-pdf-fade-leave-active { transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1); }\n.m3-pdf-fade-enter-from,\n.m3-pdf-fade-leave-to { opacity: 0; }\n.m3-pdf-drop-enter-active,\n.m3-pdf-drop-leave-active { transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1), transform 250ms cubic-bezier(0.2, 0, 0, 1); }\n.m3-pdf-drop-enter-from,\n.m3-pdf-drop-leave-to { opacity: 0; transform: translateY(-8px); }\n.m3-pdf-rise-enter-active,\n.m3-pdf-rise-leave-active { transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1), transform 300ms cubic-bezier(0.05, 0.7, 0.1, 1); }\n.m3-pdf-rise-enter-from,\n.m3-pdf-rise-leave-to { opacity: 0; transform: translateY(24px); }\n.m3-pdf-panel-enter-active,\n.m3-pdf-panel-leave-active { transition: margin 300ms cubic-bezier(0.2, 0, 0, 1), opacity 200ms; }\n.m3-pdf-panel-enter-from,\n.m3-pdf-panel-leave-to { margin-left: -14rem; opacity: 0; }\n</style>\n","<script lang=\"ts\">\n/** One annotation, in PDF points (origin at the page's bottom left), so it survives zoom, rotation and reflows */\nexport interface PdfAnnotation {\n id: string\n type: 'highlight' | 'note' | 'ink'\n /** 1-based page */\n page: number\n /** Any CSS color */\n color: string\n /** highlight: the selected lines, `[x1, y1, x2, y2]` each */\n rects?: [number, number, number, number][]\n /** highlight: the text it covers */\n quote?: string\n /** note: where its icon sits */\n at?: [number, number]\n /** ink: strokes, each a list of points */\n paths?: [number, number][][]\n /** ink: stroke width in points */\n width?: number\n /** A note's text, or a comment on a highlight or drawing */\n text?: string\n author?: string\n /** ISO date */\n createdAt: string\n}\n\nexport type PdfTool = 'select' | 'highlight' | 'note' | 'ink' | 'eraser'\n\n/**\n * What's left of an annotation after the eraser passed over `at` (PDF points, radius `r`): an ink stroke is cut\n * where it passes (null once nothing is left), a highlight or a note it touches goes entirely. The same object\n * back means it wasn't touched\n */\nexport function eraseFrom(a: PdfAnnotation, at: { x: number; y: number; r: number }): PdfAnnotation | null {\n const { x, y, r } = at\n if (a.type === 'note') {\n const [nx, ny] = a.at ?? [0, 0]\n return Math.hypot(nx - x, ny - y) <= r + 10 ? null : a\n }\n if (a.type === 'highlight') {\n const hit = (a.rects ?? []).some(([x1, y1, x2, y2]) =>\n x >= Math.min(x1, x2) - r && x <= Math.max(x1, x2) + r && y >= Math.min(y1, y2) - r && y <= Math.max(y1, y2) + r)\n return hit ? null : a\n }\n const reach = r + (a.width ?? 2) / 2\n // Distance from the eraser to a segment\n const near = (p: [number, number], q: [number, number]) => {\n const dx = q[0] - p[0]\n const dy = q[1] - p[1]\n const len = dx * dx + dy * dy\n const t = len ? Math.max(0, Math.min(1, ((x - p[0]) * dx + (y - p[1]) * dy) / len)) : 0\n return Math.hypot(p[0] + t * dx - x, p[1] + t * dy - y) <= reach\n }\n let touched = false\n const paths: [number, number][][] = []\n for (const path of a.paths ?? []) {\n let run: [number, number][] = []\n path.forEach((p, i) => {\n const prev = path[i - 1]\n const gone = Math.hypot(p[0] - x, p[1] - y) <= reach\n const crossed = !!prev && run.length > 0 && near(prev, p)\n if (gone || crossed) {\n touched = true\n if (run.length > 1) paths.push(run)\n run = gone ? [] : [p]\n } else run.push(p)\n })\n if (run.length > 1) paths.push(run)\n }\n if (!touched) return a\n return paths.length ? { ...a, paths } : null\n}\nexport type PdfZoom = number | 'fit-width' | 'fit-page'\n</script>\n\n<script setup lang=\"ts\">\n/**\n * A PDF viewer on pdf.js (not an M3 spec component; after androidx.pdf's `PdfView` and Google Drive's viewer). The\n * pages scroll continuously, each rendered only near the viewport, with selectable text and working links. Zoom:\n * fit to width (the default) or the page, a percentage, Ctrl + wheel or a trackpad pinch, a pinch on touch, and a\n * double click or double tap (zooms in there, or back to the width). A top bar with the page, zoom, search (hits\n * marked in the text), and download, print, rotate and full screen; a side panel with thumbnails and the outline;\n * a page indicator while scrolling (a draggable thumb on touch). With `annotate`, an edit button opens a floating\n * toolbar to highlight text, place notes and draw, kept in `v-model:annotations` as JSON (not written into the file).\n *\n * Needs the `pdfjs-dist` package. Set its worker once with `setPdfWorker()` (or `worker-src`); without it pdf.js\n * runs on the main thread.\n *\n * @slot actions Extra buttons at the end of the top bar. Props: `{ pdf }`\n * @slot empty Shown without a `src`\n * @event loaded The document loaded, with its pdf.js proxy\n * @event error The document failed to load\n * @event link A link was followed: `{ url }` (opens in a new tab) or `{ page }` (scrolled to)\n * @event annotation-click An annotation was clicked with the select tool\n */\nimport { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, shallowRef, watch } from 'vue'\nimport { usePdf, type PdfDocument, type PdfSource } from '../composables/usePdf'\nimport { useLocale } from '../composables/useLocale'\nimport PdfPageView from './_MPdfPage.vue'\nimport MIconButton from './MIconButton.vue'\nimport MIcon from './MIcon.vue'\nimport MMenu from './MMenu.vue'\nimport MMenuItem from './MMenuItem.vue'\nimport MProgressBar from './MProgressBar.vue'\nimport MTextField from './MTextField.vue'\nimport MButton from './MButton.vue'\nimport MLoadingIndicator from './MLoadingIndicator.vue'\n\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(defineProps<{\n /** The PDF: a URL, its bytes, or a `File`/`Blob` */\n src?: PdfSource | null\n /** Shown in the top bar; default the document's own title */\n title?: string\n /** Current page, 1-based (v-model) */\n page?: number\n /** `fit-width`, `fit-page`, or a zoom where 1 is 100% (v-model) */\n zoom?: PdfZoom\n /** Extra rotation in degrees, a multiple of 90 (v-model) */\n rotation?: number\n /** Annotations to draw (v-model) */\n annotations?: PdfAnnotation[]\n /** Shows the edit button and the annotation toolbar */\n annotate?: boolean\n /** The active tool (v-model) */\n tool?: PdfTool\n /** Colors offered for annotations */\n colors?: string[]\n /** The pen's widths offered in the toolbar, in PDF points (the first one is the default) */\n inkWidths?: number[]\n /** Written into new annotations' `author` */\n author?: string\n /** The side panel: thumbnails, the outline, or closed (v-model) */\n sidebar?: 'thumbnails' | 'outline' | null\n /** Shows the top bar */\n toolbar?: boolean\n /** Shows download and print */\n downloadable?: boolean\n /** File name for downloads; default the URL's or the document's title */\n fileName?: string\n /** A password to try first */\n password?: string\n /** The pdf.js worker URL (or `setPdfWorker()` once for the app) */\n workerSrc?: string\n minZoom?: number\n maxZoom?: number\n}>(), {\n src: null,\n page: undefined,\n zoom: 'fit-width',\n rotation: 0,\n annotations: () => [],\n annotate: false,\n tool: 'select',\n colors: () => ['#FFE14D', '#7ED957', '#5EB8FF', '#FF7EB6', '#B388FF', '#1F1F1F'],\n inkWidths: () => [1, 2, 4, 8],\n sidebar: null,\n toolbar: true,\n downloadable: true,\n minZoom: 0.25,\n maxZoom: 8,\n})\n\nconst emit = defineEmits<{\n 'update:page': [number]\n 'update:zoom': [PdfZoom]\n 'update:rotation': [number]\n 'update:annotations': [PdfAnnotation[]]\n 'update:tool': [PdfTool]\n 'update:sidebar': ['thumbnails' | 'outline' | null]\n loaded: [PdfDocument]\n error: [Error]\n link: [{ url?: string; page?: number }]\n 'annotation-click': [PdfAnnotation]\n}>()\n\nconst locale = useLocale()\nconst pdf = usePdf(() => props.src, { password: () => props.password, workerSrc: props.workerSrc })\nwatch(pdf.doc, (d) => { if (d) emit('loaded', d) })\nwatch(pdf.error, (e) => { if (e) emit('error', e) })\n\nconst root = ref<HTMLElement>()\nconst scroller = ref<HTMLElement>()\nconst viewW = ref(800)\nconst viewH = ref(600)\nconst rootW = ref(800)\nconst compact = computed(() => rootW.value < 600)\n\n// ── Layout: CSS px per PDF point at 100% (pdf.js's and the browser's 100%), page gap and padding ─────────\nconst PT = 96 / 72\nconst GAP = 8\nconst PAD = 16\nconst rotation = ref(((props.rotation % 360) + 360) % 360)\nwatch(() => props.rotation, (r) => { rotation.value = ((r % 360) + 360) % 360 })\n\nconst sizes = computed(() => {\n const swap = rotation.value % 180 !== 0\n return pdf.pageSizes.value.map((s) => (swap ? { width: s.height, height: s.width } : s))\n})\nconst zoomMode = ref<PdfZoom>(props.zoom)\nwatch(() => props.zoom, (z) => { if (z !== zoomMode.value) setZoom(z) })\n\nconst refSize = computed(() => sizes.value[Math.max(0, currentPage.value - 1)] ?? sizes.value[0] ?? { width: 612, height: 792 })\nfunction fitScale(mode: 'fit-width' | 'fit-page') {\n const w = (viewW.value - 2 * (compact.value ? 8 : PAD)) / refSize.value.width\n if (mode === 'fit-width') return w\n return Math.min(w, (viewH.value - 2 * PAD) / refSize.value.height)\n}\n// The scale actually used (px per point); a numeric zoom is relative to 100%\nconst scale = computed(() => {\n const z = zoomMode.value\n const s = typeof z === 'number' ? z * PT : fitScale(z)\n return Math.max(props.minZoom * PT, Math.min(props.maxZoom * PT, s || PT))\n})\nconst zoomPercent = computed(() => Math.round((scale.value / PT) * 100))\n\nconst layout = computed(() => {\n const pad = compact.value ? 8 : PAD\n let y = pad\n let maxW = 0\n const boxes = sizes.value.map((s) => {\n const w = Math.floor(s.width * scale.value)\n const h = Math.floor(s.height * scale.value)\n const box = { top: y, width: w, height: h }\n y += h + GAP\n maxW = Math.max(maxW, w)\n return box\n })\n return { boxes, height: y - GAP + pad, width: maxW + 2 * pad, pad }\n})\n\n// ── Scroll position → current page and the pages to render ──────────────────────────────────────────────\nconst scrollTop = ref(0)\nfunction pageAt(y: number) {\n const boxes = layout.value.boxes\n let lo = 0\n let hi = boxes.length - 1\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1\n if (boxes[mid]!.top <= y) lo = mid\n else hi = mid - 1\n }\n return lo\n}\nconst currentPage = ref(1)\nfunction updateCurrent() {\n if (!layout.value.boxes.length) return\n // The page under a third of the way down the view\n const p = pageAt(scrollTop.value + viewH.value / 3) + 1\n if (p !== currentPage.value) {\n currentPage.value = p\n emit('update:page', p)\n }\n}\nconst activePages = computed(() => {\n const boxes = layout.value.boxes\n if (!boxes.length) return new Set<number>()\n const a = pageAt(Math.max(0, scrollTop.value - viewH.value))\n const b = pageAt(scrollTop.value + viewH.value * 2)\n const set = new Set<number>()\n for (let i = a; i <= b; i++) set.add(i + 1)\n return set\n})\n\nlet scrollingTimer: ReturnType<typeof setTimeout> | undefined\nconst scrolling = ref(false)\n// A scroll we made to keep the reading point through a resize: no page indicator for it\nlet keptTop: number | null = null\nfunction onScroll() {\n const el = scroller.value!\n scrollTop.value = el.scrollTop\n updateCurrent()\n if (keptTop !== null && Math.abs(el.scrollTop - keptTop) < 1) {\n keptTop = null\n return\n }\n keptTop = null\n scrolling.value = true\n clearTimeout(scrollingTimer)\n scrollingTimer = setTimeout(() => (scrolling.value = false), 1200)\n}\n\nfunction goTo(page: number, top?: number, smooth = false) {\n const el = scroller.value\n const box = layout.value.boxes[page - 1]\n if (!el || !box) return\n // A destination's `top` is in PDF points from the page's bottom (unrotated pages only)\n const size = sizes.value[page - 1]!\n const within = top !== undefined && rotation.value === 0 ? Math.max(0, (size.height - top) * scale.value) : 0\n el.scrollTo({ top: box.top + within - (within ? 8 : layout.value.pad), behavior: smooth ? 'smooth' : 'auto' })\n currentPage.value = page\n emit('update:page', page)\n}\nwatch(() => props.page, (p) => { if (p && p !== currentPage.value) goTo(p) })\n\n// ── Zoom about a point, keeping what's under it in place ────────────────────────────────────────────────\nfunction setZoom(z: PdfZoom, anchor?: { x: number; y: number }) {\n const el = scroller.value\n const nextScale = typeof z === 'number' ? Math.max(props.minZoom, Math.min(props.maxZoom, z)) : z\n if (!el || !layout.value.boxes.length) {\n zoomMode.value = nextScale\n emit('update:zoom', nextScale)\n return\n }\n const r = el.getBoundingClientRect()\n const ax = anchor ? anchor.x - r.left : el.clientWidth / 2\n const ay = anchor ? anchor.y - r.top : el.clientHeight / 2\n const docY = el.scrollTop + ay\n const i = pageAt(docY)\n const box = layout.value.boxes[i]!\n const fy = (docY - box.top) / box.height\n const contentW = Math.max(layout.value.width, el.clientWidth)\n const left = (contentW - box.width) / 2\n const fx = (el.scrollLeft + ax - left) / box.width\n zoomMode.value = nextScale\n emit('update:zoom', nextScale)\n nextTick(() => {\n const nb = layout.value.boxes[i]!\n const nContentW = Math.max(layout.value.width, el.clientWidth)\n el.scrollTop = nb.top + fy * nb.height - ay\n el.scrollLeft = (nContentW - nb.width) / 2 + fx * nb.width - ax\n onScroll()\n })\n}\nconst zoomBy = (f: number, anchor?: { x: number; y: number }) => setZoom((scale.value / PT) * f, anchor)\nconst ZOOM_STEPS = [0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4]\nfunction stepZoom(dir: 1 | -1) {\n const z = scale.value / PT\n const next = dir > 0 ? ZOOM_STEPS.find((s) => s > z + 0.01) ?? props.maxZoom : [...ZOOM_STEPS].reverse().find((s) => s < z - 0.01) ?? props.minZoom\n setZoom(next)\n}\n\n// Ctrl + wheel (a trackpad pinch arrives as one too)\nfunction onWheel(e: WheelEvent) {\n if (!e.ctrlKey && !e.metaKey) return\n e.preventDefault()\n zoomBy(Math.exp(-e.deltaY * (e.deltaMode === 1 ? 0.05 : 0.0025)), { x: e.clientX, y: e.clientY })\n}\n\n// Double click / double tap: zoom in there, or back to the width (androidx.pdf's double tap)\nfunction onDblClick(e: MouseEvent) {\n if (props.tool !== 'select' || (e.target as HTMLElement).closest('button, a, input, textarea')) return\n const fit = fitScale('fit-width')\n if (scale.value > fit * 1.05) setZoom('fit-width', { x: e.clientX, y: e.clientY })\n else setZoom(Math.min(props.maxZoom, (fit * 2) / PT), { x: e.clientX, y: e.clientY })\n}\n\n// Pinch on touch: pdf.js's TouchManager owns two-finger gestures (one finger still scrolls natively)\nlet touchAC: AbortController | null = null\nlet pinchFrame = 0\nlet pinchFactor = 1\nlet pinchOrigin = { x: 0, y: 0 }\nfunction setupPinch() {\n const lib = pdf.pdfjs.value\n const el = scroller.value\n if (!lib || !el || touchAC) return\n touchAC = new AbortController()\n new lib.TouchManager({\n container: el,\n isPinchingDisabled: () => props.tool === 'ink',\n onPinching: (origin: [number, number], prevDistance: number, distance: number) => {\n pinchFactor *= distance / (prevDistance || distance)\n pinchOrigin = { x: origin[0], y: origin[1] }\n pinchFrame ||= requestAnimationFrame(() => {\n pinchFrame = 0\n const f = pinchFactor\n pinchFactor = 1\n zoomBy(f, pinchOrigin)\n })\n },\n signal: touchAC.signal,\n })\n}\nwatch(() => pdf.pdfjs.value, setupPinch)\n\n// ── Fit modes follow the size; a new document starts at the top ─────────────────────────────────────────\nlet ro: ResizeObserver | undefined\nwatch(pdf.doc, async (d) => {\n if (!d) return\n await nextTick()\n const p = props.page && props.page <= d.numPages ? props.page : 1\n currentPage.value = p\n if (p > 1) goTo(p)\n else if (scroller.value) scroller.value.scrollTop = 0\n setupPinch()\n})\n\n// ── Rotation ────────────────────────────────────────────────────────────────────────────────────────────\nfunction rotate() {\n const page = currentPage.value\n rotation.value = (rotation.value + 90) % 360\n emit('update:rotation', rotation.value)\n nextTick(() => goTo(page))\n}\n\n// ── Search ──────────────────────────────────────────────────────────────────────────────────────────────\nconst searchOpen = ref(false)\nconst query = ref('')\nconst matches = shallowRef<{ page: number; start: number; end: number }[]>([])\nconst matchIndex = ref(-1)\nconst searching = ref(false)\nlet searchAC: AbortController | null = null\nlet searchTimer: ReturnType<typeof setTimeout> | undefined\nwatch(query, (q) => {\n clearTimeout(searchTimer)\n searchTimer = setTimeout(() => runSearch(q), 250)\n})\nasync function runSearch(q: string) {\n searchAC?.abort()\n matches.value = []\n matchIndex.value = -1\n if (!q.trim() || !pdf.doc.value) return\n const ac = (searchAC = new AbortController())\n searching.value = true\n const found = await pdf.search(q, { signal: ac.signal })\n if (ac.signal.aborted) return\n searching.value = false\n matches.value = found\n // The first hit at or after the current page\n const i = found.findIndex((m) => m.page >= currentPage.value)\n if (found.length) showMatch(i < 0 ? 0 : i)\n}\nfunction showMatch(i: number) {\n const n = matches.value.length\n if (!n) return\n matchIndex.value = ((i % n) + n) % n\n const m = matches.value[matchIndex.value]!\n // Scroll its page in, then the hit itself once marked\n if (!activePages.value.has(m.page) || Math.abs(m.page - currentPage.value) > 0) goTo(m.page)\n pendingHitScroll = true\n}\nlet pendingHitScroll = false\nconst hitsByPage = computed(() => {\n const map = new Map<number, { start: number; end: number; current: boolean }[]>()\n matches.value.forEach((m, i) => {\n const list = map.get(m.page) ?? []\n list.push({ start: m.start, end: m.end, current: i === matchIndex.value })\n map.set(m.page, list)\n })\n return map\n})\nconst NO_HITS: { start: number; end: number; current: boolean }[] = []\nconst pageRefs = reactive(new Map<number, InstanceType<typeof PdfPageView>>())\nfunction setPageRef(n: number, el: unknown) {\n if (el) pageRefs.set(n, el as InstanceType<typeof PdfPageView>)\n else pageRefs.delete(n)\n}\n// Once the focused hit is marked in its page's text layer, bring it to the middle of the view\nwatch(() => {\n const m = matches.value[matchIndex.value]\n return m ? pageRefs.get(m.page)?.currentHit : null\n}, (el) => {\n if (!el || !pendingHitScroll || !scroller.value) return\n pendingHitScroll = false\n const r = (el as HTMLElement).getBoundingClientRect()\n const s = scroller.value.getBoundingClientRect()\n scroller.value.scrollBy({ top: r.top - s.top - s.height / 2, left: r.left < s.left || r.right > s.right ? r.left - s.left - s.width / 2 : 0 })\n})\nfunction openSearch() {\n searchOpen.value = true\n nextTick(() => root.value?.querySelector<HTMLInputElement>('.m3-pdf-search input')?.focus())\n}\nfunction closeSearch() {\n searchOpen.value = false\n query.value = ''\n searchAC?.abort()\n matches.value = []\n matchIndex.value = -1\n}\nconst matchText = computed(() =>\n !query.value.trim() ? '' : searching.value ? '…' : matches.value.length ? locale.pdfMatchCount.replace('{current}', String(matchIndex.value + 1)).replace('{total}', String(matches.value.length)) : locale.pdfNoMatches,\n)\n\n// ── Side panel: thumbnails and outline ──────────────────────────────────────────────────────────────────\nconst panel = ref<'thumbnails' | 'outline' | null>(props.sidebar)\nwatch(() => props.sidebar, (v) => { panel.value = v })\nfunction setPanel(v: 'thumbnails' | 'outline' | null) {\n panel.value = v\n emit('update:sidebar', v)\n}\nconst thumbs = reactive(new Map<number, string>())\nconst thumbList = ref<HTMLElement>()\nlet thumbObserver: IntersectionObserver | null = null\nfunction observeThumb(el: unknown, n: number) {\n if (!(el instanceof HTMLElement)) return\n el.dataset.page = String(n)\n thumbObserver?.observe(el)\n}\nwatch([panel, pdf.doc], async ([p, d]) => {\n thumbObserver?.disconnect()\n thumbs.clear()\n if (p !== 'thumbnails' || !d || typeof IntersectionObserver === 'undefined') return\n await nextTick()\n thumbObserver = new IntersectionObserver((entries) => {\n for (const e of entries) {\n if (!e.isIntersecting) continue\n const n = Number((e.target as HTMLElement).dataset.page)\n if (thumbs.has(n)) continue\n thumbs.set(n, '')\n pdf.thumbnail(n, 120).then((url) => thumbs.set(n, url), () => {})\n }\n }, { root: thumbList.value, rootMargin: '200px' })\n thumbList.value?.querySelectorAll<HTMLElement>('[data-page]').forEach((el) => thumbObserver!.observe(el))\n thumbList.value?.querySelector(`[data-page=\"${currentPage.value}\"]`)?.scrollIntoView({ block: 'center' })\n})\nfunction pickFromPanel(page: number, top?: number) {\n goTo(page, top)\n if (compact.value) setPanel(null)\n}\nconst outlineOpen = reactive(new Set<string>())\ntype FlatOutline = { key: string; title: string; page?: number; top?: number; url?: string; depth: number; hasChildren: boolean }\nconst flatOutline = computed(() => {\n const out: FlatOutline[] = []\n const walk = (items: typeof pdf.outline.value, depth: number, prefix: string) => {\n items.forEach((it, i) => {\n const key = `${prefix}${i}`\n out.push({ key, title: it.title, page: it.page, top: it.top, url: it.url, depth, hasChildren: it.children.length > 0 })\n if (it.children.length && outlineOpen.has(key)) walk(it.children, depth + 1, `${key}.`)\n })\n }\n walk(pdf.outline.value, 0, '')\n return out\n})\nfunction toggleOutline(key: string) {\n if (outlineOpen.has(key)) outlineOpen.delete(key)\n else outlineOpen.add(key)\n}\n\n// ── Links ───────────────────────────────────────────────────────────────────────────────────────────────\nasync function onLink(l: { url?: string; dest?: unknown }) {\n if (l.url) {\n emit('link', { url: l.url })\n return\n }\n const at = await pdf.resolveDest(l.dest)\n if (!at) return\n goTo(at.page, at.top)\n emit('link', { page: at.page })\n}\n\n// ── Annotations ─────────────────────────────────────────────────────────────────────────────────────────\nconst tool = ref<PdfTool>(props.tool)\nwatch(() => props.tool, (t) => { tool.value = t })\nfunction setTool(t: PdfTool) {\n tool.value = t\n emit('update:tool', t)\n selection.value = null\n selected.value = null\n}\nconst color = ref(props.colors[0]!)\nconst inkWidth = ref(props.inkWidths[1] ?? props.inkWidths[0] ?? 2)\nconst editing = ref(false)\nwatch(() => props.annotate, (on) => { if (!on) closeEditing() })\nfunction openEditing() {\n editing.value = true\n setTool('highlight')\n}\nfunction closeEditing() {\n editing.value = false\n setTool('select')\n}\n\nconst byPage = computed(() => {\n const map = new Map<number, PdfAnnotation[]>()\n for (const a of props.annotations) {\n const list = map.get(a.page) ?? []\n list.push(a)\n map.set(a.page, list)\n }\n return map\n})\nconst NO_ANNOTATIONS: PdfAnnotation[] = []\nconst history: PdfAnnotation[][] = []\nfunction commit(next: PdfAnnotation[]) {\n history.push(props.annotations)\n if (history.length > 50) history.shift()\n canUndo.value = true\n emit('update:annotations', next)\n}\nconst canUndo = ref(false)\nfunction undo() {\n const prev = history.pop()\n canUndo.value = history.length > 0\n if (prev) emit('update:annotations', prev)\n selected.value = null\n}\nfunction add(a: PdfAnnotation) {\n if (props.author) a.author = props.author\n commit([...props.annotations, a])\n // A new note opens for its text\n if (a.type === 'note') nextTick(() => selectById(a.id))\n}\nfunction erase(id: string) {\n commit(props.annotations.filter((a) => a.id !== id))\n if (selected.value?.id === id) selected.value = null\n}\n// The eraser dragged across a page: one undo step per stroke of it\nfunction eraseStart() {\n history.push(props.annotations)\n if (history.length > 50) history.shift()\n canUndo.value = true\n}\nfunction eraseAt(page: number, at: { x: number; y: number; r: number }) {\n let changed = false\n const next: PdfAnnotation[] = []\n for (const a of props.annotations) {\n const kept = a.page === page ? eraseFrom(a, at) : a\n if (kept !== a) changed = true\n if (kept) next.push(kept)\n }\n if (!changed) return\n if (selected.value && !next.some((a) => a.id === selected.value!.id)) selected.value = null\n emit('update:annotations', next)\n}\nfunction update(id: string, patch: Partial<PdfAnnotation>) {\n emit('update:annotations', props.annotations.map((a) => (a.id === id ? { ...a, ...patch } : a)))\n}\n\n// The selected annotation's card, and the popup over a text selection, placed near what they're about\nconst selected = ref<{ id: string; x: number; y: number } | null>(null)\nconst selectedAnnotation = computed(() => props.annotations.find((a) => a.id === selected.value?.id) ?? null)\nfunction place(anchor: DOMRect) {\n const r = root.value!.getBoundingClientRect()\n return { x: Math.min(Math.max(8, anchor.left - r.left + anchor.width / 2), r.width - 8), y: anchor.bottom - r.top + 8 }\n}\nfunction onSelect(s: { id: string; anchor: DOMRect } | null) {\n if (!s) {\n selected.value = null\n return\n }\n selection.value = null\n selected.value = { id: s.id, ...place(s.anchor) }\n const a = props.annotations.find((x) => x.id === s.id)\n if (a) emit('annotation-click', a)\n}\nfunction selectById(id: string) {\n const el = root.value?.querySelector(`.m3-pdf-note[aria-label]`)\n const a = props.annotations.find((x) => x.id === id)\n if (!a) return\n const page = pageRefs.get(a.page)?.root as HTMLElement | undefined\n const target = [...(page?.querySelectorAll<HTMLElement>('.m3-pdf-note') ?? [])].pop() ?? el\n if (target) selected.value = { id, ...place(target.getBoundingClientRect()) }\n}\nconst cardStyle = computed(() => {\n const s = selected.value ?? selection.value\n if (!s) return {}\n const w = Math.min(300, rootW.value - 16)\n return { left: `${Math.min(Math.max(8, s.x - w / 2), rootW.value - w - 8)}px`, top: `${s.y}px`, width: `${w}px` }\n})\n\nconst selection = ref<{ page: number; rects: [number, number, number, number][]; quote: string; x: number; y: number } | null>(null)\nfunction onTextSelection(s: { page: number; rects: [number, number, number, number][]; quote: string; anchor: DOMRect } | null) {\n if (!s || !props.annotate) {\n selection.value = null\n return\n }\n selected.value = null\n selection.value = { page: s.page, rects: s.rects, quote: s.quote, ...place(s.anchor) }\n}\nfunction highlightSelection() {\n const s = selection.value\n if (!s) return\n add({ id: crypto.randomUUID?.() ?? String(Date.now()), type: 'highlight', page: s.page, color: color.value, rects: s.rects, quote: s.quote, text: '', createdAt: new Date().toISOString() })\n window.getSelection()?.removeAllRanges()\n selection.value = null\n}\nasync function copySelection() {\n const s = selection.value\n if (s) await navigator.clipboard?.writeText(s.quote).catch(() => {})\n window.getSelection()?.removeAllRanges()\n selection.value = null\n}\n// Scrolling moves the anchors away: close the floating cards\nwatch(scrollTop, () => {\n selection.value = null\n if (selectedAnnotation.value?.type !== 'note') selected.value = null\n})\n\n// ── Fast scroll (touch): a thumb on the edge while scrolling, with the page ─────────────────────────────\nconst coarse = typeof window !== 'undefined' && !!window.matchMedia?.('(pointer: coarse)').matches\nconst thumbTop = computed(() => {\n const el = scroller.value\n const max = layout.value.height - viewH.value\n void scrollTop.value\n return el && max > 0 ? (scrollTop.value / max) * (viewH.value - 48) : 0\n})\nconst dragging = ref(false)\nfunction onThumbDown(e: PointerEvent) {\n e.preventDefault()\n dragging.value = true\n ;(e.currentTarget as Element).setPointerCapture(e.pointerId)\n const startY = e.clientY\n const start = scroller.value!.scrollTop\n const max = layout.value.height - viewH.value\n const move = (ev: PointerEvent) => {\n scroller.value!.scrollTop = start + ((ev.clientY - startY) / Math.max(1, viewH.value - 48)) * max\n }\n const up = () => {\n dragging.value = false\n window.removeEventListener('pointermove', move)\n window.removeEventListener('pointerup', up)\n }\n window.addEventListener('pointermove', move)\n window.addEventListener('pointerup', up)\n}\n\n// ── Full screen ─────────────────────────────────────────────────────────────────────────────────────────\nconst fullscreen = ref(false)\nasync function toggleFullscreen() {\n if (document.fullscreenElement) await document.exitFullscreen().catch(() => {})\n else await root.value?.requestFullscreen?.().catch(() => {})\n}\nconst onFullscreenChange = () => { fullscreen.value = document.fullscreenElement === root.value }\n\n// ── Keys ────────────────────────────────────────────────────────────────────────────────────────────────\nfunction onKey(e: KeyboardEvent) {\n const t = e.target as HTMLElement\n const typing = !!t.closest('input, textarea, [contenteditable]')\n const mod = e.ctrlKey || e.metaKey\n if (mod && e.key.toLowerCase() === 'f') {\n e.preventDefault()\n openSearch()\n } else if (mod && (e.key === '=' || e.key === '+')) {\n e.preventDefault()\n stepZoom(1)\n } else if (mod && e.key === '-') {\n e.preventDefault()\n stepZoom(-1)\n } else if (mod && e.key === '0') {\n e.preventDefault()\n setZoom('fit-width')\n } else if (mod && e.key.toLowerCase() === 'z' && !typing && props.annotate) {\n e.preventDefault()\n undo()\n } else if (e.key === 'Escape') {\n if (selected.value || selection.value) {\n selected.value = null\n selection.value = null\n } else if (searchOpen.value) closeSearch()\n else if (editing.value) closeEditing()\n else return\n e.stopPropagation()\n } else if (!typing && (e.key === 'Delete' || e.key === 'Backspace') && selected.value) {\n erase(selected.value.id)\n } else if (!typing && !mod && (e.key === 'PageDown' || e.key === 'PageUp')) {\n e.preventDefault()\n goTo(Math.max(1, Math.min(pdf.numPages.value, currentPage.value + (e.key === 'PageDown' ? 1 : -1))))\n }\n}\n\n// ── Page field ──────────────────────────────────────────────────────────────────────────────────────────\nconst pageInput = ref('')\nwatch(currentPage, (p) => { pageInput.value = String(p) }, { immediate: true })\nfunction commitPageInput() {\n const n = Math.round(Number(pageInput.value))\n if (n >= 1 && n <= pdf.numPages.value) goTo(n)\n else pageInput.value = String(currentPage.value)\n}\n\n// ── Password ────────────────────────────────────────────────────────────────────────────────────────────\nconst passwordInput = ref('')\nfunction submitPassword() {\n pdf.submitPassword(passwordInput.value)\n passwordInput.value = ''\n}\n\nconst docTitle = computed(() => props.title ?? pdf.metadata.value.title ?? '')\n\nonMounted(() => {\n const el = scroller.value!\n el.addEventListener('wheel', onWheel, { passive: false })\n ro = new ResizeObserver(() => {\n // A fit mode rescales every page when the size changes (the side panel opening, a rotated phone):\n // keep the point being read, a third of the way down like the current page, where it was\n const boxes = layout.value.boxes\n const ay = viewH.value / 3\n const i = boxes.length ? pageAt(el.scrollTop + ay) : -1\n const fy = i >= 0 ? (el.scrollTop + ay - boxes[i]!.top) / boxes[i]!.height : 0\n viewW.value = el.clientWidth\n viewH.value = el.clientHeight\n rootW.value = root.value?.clientWidth ?? rootW.value\n if (i < 0) return\n nextTick(() => {\n const nb = layout.value.boxes[i]\n if (!nb) return\n const top = Math.round(nb.top + fy * nb.height - ay)\n if (Math.abs(top - el.scrollTop) < 1) return\n el.scrollTop = top\n scrollTop.value = el.scrollTop\n updateCurrent()\n keptTop = el.scrollTop\n })\n })\n ro.observe(el)\n ro.observe(root.value!)\n viewW.value = el.clientWidth || viewW.value\n viewH.value = el.clientHeight || viewH.value\n rootW.value = root.value!.clientWidth || rootW.value\n document.addEventListener('fullscreenchange', onFullscreenChange)\n})\nonBeforeUnmount(() => {\n ro?.disconnect()\n touchAC?.abort()\n thumbObserver?.disconnect()\n searchAC?.abort()\n cancelAnimationFrame(pinchFrame)\n clearTimeout(scrollingTimer)\n clearTimeout(searchTimer)\n document.removeEventListener('fullscreenchange', onFullscreenChange)\n})\n\ndefineExpose({\n pdf,\n goToPage: (p: number) => goTo(p),\n setZoom: (z: PdfZoom) => setZoom(z),\n search: (q: string) => { openSearch(); query.value = q },\n undo,\n})\n\nconst TOOLS = computed(() => [\n { id: 'select' as const, icon: 'arrow_selector_tool', label: locale.pdfSelect },\n { id: 'highlight' as const, icon: 'ink_highlighter', label: locale.pdfHighlight },\n { id: 'note' as const, icon: 'sticky_note_2', label: locale.pdfNote },\n { id: 'ink' as const, icon: 'draw', label: locale.pdfDraw },\n { id: 'eraser' as const, icon: 'ink_eraser', label: locale.pdfEraser },\n])\n</script>\n\n<template>\n <div\n ref=\"root\"\n v-bind=\"$attrs\"\n role=\"region\"\n :aria-label=\"docTitle || locale.pdfViewer\"\n class=\"m3-pdf bg-surface-container text-on-surface\"\n @keydown=\"onKey\"\n >\n <!-- Top bar -->\n <div v-if=\"toolbar\" class=\"relative z-10 flex h-16 shrink-0 items-center gap-1 bg-surface-container px-1 sm:px-2\">\n <MIconButton\n :icon=\"panel ? 'left_panel_close' : 'left_panel_open'\"\n :label=\"locale.pdfThumbnails\"\n :disabled=\"!pdf.doc.value\"\n @click=\"setPanel(panel ? null : 'thumbnails')\"\n />\n <p class=\"min-w-0 flex-1 truncate px-1 text-title-medium\">{{ docTitle }}</p>\n\n <template v-if=\"pdf.doc.value\">\n <div v-if=\"!compact\" class=\"flex items-center gap-1 text-body-medium text-on-surface-variant\">\n <input\n v-model=\"pageInput\"\n inputmode=\"numeric\"\n class=\"h-8 w-11 rounded-sm bg-surface-container-highest text-center text-body-medium text-on-surface tabular-nums outline-none focus:ring-2 focus:ring-primary\"\n :aria-label=\"locale.pdfPage\"\n @keydown.enter=\"commitPageInput\"\n @blur=\"commitPageInput\"\n />\n <span class=\"tabular-nums\">/ {{ pdf.numPages.value }}</span>\n </div>\n <div v-if=\"!compact\" class=\"mx-1 flex items-center\">\n <MIconButton icon=\"remove\" :label=\"locale.pdfZoomOut\" size=\"xs\" @click=\"stepZoom(-1)\" />\n <MMenu align=\"right\">\n <template #trigger>\n <button type=\"button\" class=\"h-8 min-w-14 cursor-pointer rounded-full px-2 text-label-large tabular-nums hover:bg-on-surface/8\" :aria-label=\"locale.pdfZoom\">{{ zoomPercent }}%</button>\n </template>\n <MMenuItem icon=\"fit_width\" :selected=\"zoomMode === 'fit-width'\" @click=\"setZoom('fit-width')\">{{ locale.pdfFitWidth }}</MMenuItem>\n <MMenuItem icon=\"fit_page\" :selected=\"zoomMode === 'fit-page'\" @click=\"setZoom('fit-page')\">{{ locale.pdfFitPage }}</MMenuItem>\n <MMenuItem v-for=\"z in ZOOM_STEPS\" :key=\"z\" :selected=\"zoomMode === z\" @click=\"setZoom(z)\">{{ z * 100 }}%</MMenuItem>\n </MMenu>\n <MIconButton icon=\"add\" :label=\"locale.pdfZoomIn\" size=\"xs\" @click=\"stepZoom(1)\" />\n </div>\n <MIconButton icon=\"search\" :label=\"locale.pdfSearch\" :checked=\"searchOpen\" @update:checked=\"(v: boolean) => (v ? openSearch() : closeSearch())\" />\n <slot name=\"actions\" :pdf=\"pdf\" />\n <MMenu align=\"right\">\n <template #trigger>\n <MIconButton icon=\"more_vert\" :label=\"locale.pdfMore\" />\n </template>\n <template v-if=\"compact\">\n <MMenuItem icon=\"zoom_in\" @click=\"stepZoom(1)\">{{ locale.pdfZoomIn }}</MMenuItem>\n <MMenuItem icon=\"zoom_out\" @click=\"stepZoom(-1)\">{{ locale.pdfZoomOut }}</MMenuItem>\n <MMenuItem icon=\"fit_width\" @click=\"setZoom('fit-width')\">{{ locale.pdfFitWidth }}</MMenuItem>\n </template>\n <MMenuItem icon=\"list\" :disabled=\"!pdf.outline.value.length\" @click=\"setPanel('outline')\">{{ locale.pdfOutline }}</MMenuItem>\n <MMenuItem icon=\"rotate_right\" @click=\"rotate\">{{ locale.pdfRotate }}</MMenuItem>\n <MMenuItem v-if=\"downloadable\" icon=\"download\" @click=\"pdf.download(fileName)\">{{ locale.pdfDownload }}</MMenuItem>\n <MMenuItem v-if=\"downloadable\" icon=\"print\" @click=\"pdf.print()\">{{ locale.pdfPrint }}</MMenuItem>\n <MMenuItem :icon=\"fullscreen ? 'fullscreen_exit' : 'fullscreen'\" @click=\"toggleFullscreen\">{{ fullscreen ? locale.pdfExitFullscreen : locale.pdfFullscreen }}</MMenuItem>\n </MMenu>\n </template>\n <MProgressBar v-if=\"pdf.loading.value\" :value=\"pdf.progress.value ? pdf.progress.value * 100 : undefined\" :indeterminate=\"!pdf.progress.value\" class=\"absolute inset-x-0 bottom-0\" />\n </div>\n\n <!-- Search -->\n <Transition name=\"m3-pdf-drop\">\n <div v-if=\"searchOpen\" class=\"m3-pdf-search z-10 flex shrink-0 items-center gap-1 bg-surface-container px-2 pb-2\">\n <div class=\"flex h-12 min-w-0 flex-1 items-center gap-2 rounded-full bg-surface-container-highest pr-1 pl-4\">\n <MIcon name=\"search\" :size=\"20\" class=\"text-on-surface-variant\" />\n <input\n v-model=\"query\"\n type=\"search\"\n class=\"min-w-0 flex-1 bg-transparent text-body-large outline-none placeholder:text-on-surface-variant\"\n :placeholder=\"locale.pdfSearch\"\n :aria-label=\"locale.pdfSearch\"\n @keydown.enter.prevent=\"showMatch(matchIndex + ((($event as KeyboardEvent).shiftKey) ? -1 : 1))\"\n />\n <span class=\"shrink-0 text-label-medium whitespace-nowrap text-on-surface-variant tabular-nums\" aria-live=\"polite\">{{ matchText }}</span>\n <MIconButton icon=\"keyboard_arrow_up\" :label=\"locale.pdfSearchPrevious\" size=\"xs\" :disabled=\"!matches.length\" @click=\"showMatch(matchIndex - 1)\" />\n <MIconButton icon=\"keyboard_arrow_down\" :label=\"locale.pdfSearchNext\" size=\"xs\" :disabled=\"!matches.length\" @click=\"showMatch(matchIndex + 1)\" />\n </div>\n <MIconButton icon=\"close\" :label=\"locale.close\" @click=\"closeSearch\" />\n </div>\n </Transition>\n\n <div class=\"relative flex min-h-0 flex-1\">\n <!-- Side panel: inline on wide screens, over the pages on narrow ones -->\n <Transition name=\"m3-pdf-fade\">\n <div v-if=\"panel && compact\" class=\"absolute inset-0 z-20 bg-scrim/32\" @click=\"setPanel(null)\" />\n </Transition>\n <Transition name=\"m3-pdf-panel\">\n <aside\n v-if=\"panel && pdf.doc.value\"\n class=\"flex w-56 shrink-0 flex-col bg-surface-container\"\n :class=\"compact ? 'absolute inset-y-0 left-0 z-30 rounded-r-lg shadow-elevation-2' : 'relative'\"\n >\n <div class=\"flex shrink-0 gap-1 px-3 pt-1 pb-2\">\n <button\n v-for=\"tab in (['thumbnails', 'outline'] as const)\"\n :key=\"tab\"\n type=\"button\"\n class=\"h-8 flex-1 cursor-pointer rounded-full text-label-large transition-colors\"\n :class=\"panel === tab ? 'bg-secondary-container text-on-secondary-container' : 'text-on-surface-variant hover:bg-on-surface/8'\"\n :disabled=\"tab === 'outline' && !pdf.outline.value.length\"\n @click=\"setPanel(tab)\"\n >{{ tab === 'thumbnails' ? locale.pdfThumbnails : locale.pdfOutline }}</button>\n </div>\n <div v-if=\"panel === 'thumbnails'\" ref=\"thumbList\" class=\"min-h-0 flex-1 overflow-y-auto px-3 pb-3\">\n <div class=\"flex flex-col items-center gap-3\">\n <button\n v-for=\"n in pdf.numPages.value\"\n :key=\"n\"\n :ref=\"(el) => observeThumb(el, n)\"\n type=\"button\"\n class=\"group flex cursor-pointer flex-col items-center gap-1 outline-none\"\n :aria-label=\"`${locale.pdfPage} ${n}`\"\n :aria-current=\"n === currentPage ? 'page' : undefined\"\n @click=\"pickFromPanel(n)\"\n >\n <span\n class=\"block w-30 overflow-hidden rounded-sm bg-white shadow-elevation-1 ring-offset-2 ring-offset-surface-container transition-shadow group-focus-visible:ring-2 group-focus-visible:ring-secondary\"\n :class=\"n === currentPage && 'ring-3 ring-primary'\"\n :style=\"{ aspectRatio: `${sizes[n - 1]?.width ?? 3} / ${sizes[n - 1]?.height ?? 4}` }\"\n >\n <img v-if=\"thumbs.get(n)\" :src=\"thumbs.get(n)\" alt=\"\" class=\"h-full w-full object-contain\" :style=\"{ transform: rotation ? `rotate(${rotation}deg)` : undefined }\" />\n </span>\n <span class=\"text-label-medium tabular-nums\" :class=\"n === currentPage ? 'text-primary' : 'text-on-surface-variant'\">{{ n }}</span>\n </button>\n </div>\n </div>\n <nav v-else class=\"min-h-0 flex-1 overflow-y-auto px-2 pb-3\" :aria-label=\"locale.pdfOutline\">\n <div v-for=\"o in flatOutline\" :key=\"o.key\" class=\"flex items-center\" :style=\"{ paddingLeft: `${o.depth * 12}px` }\">\n <button\n v-if=\"o.hasChildren\"\n type=\"button\"\n class=\"flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-on-surface-variant hover:bg-on-surface/8\"\n :aria-label=\"outlineOpen.has(o.key) ? locale.collapse : locale.expand\"\n @click=\"toggleOutline(o.key)\"\n ><MIcon :name=\"outlineOpen.has(o.key) ? 'expand_more' : 'chevron_right'\" :size=\"20\" /></button>\n <span v-else class=\"w-8 shrink-0\" />\n <component\n :is=\"o.url ? 'a' : 'button'\"\n :href=\"o.url\"\n :target=\"o.url ? '_blank' : undefined\"\n :type=\"o.url ? undefined : 'button'\"\n class=\"flex min-h-10 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-full px-3 text-left text-label-large hover:bg-on-surface/8\"\n @click=\"o.page && pickFromPanel(o.page, o.top)\"\n >\n <span class=\"min-w-0 flex-1 truncate\">{{ o.title }}</span>\n <span v-if=\"o.page\" class=\"text-label-small text-on-surface-variant tabular-nums\">{{ o.page }}</span>\n </component>\n </div>\n </nav>\n </aside>\n </Transition>\n\n <!-- Pages -->\n <div class=\"relative min-w-0 flex-1\">\n <div\n ref=\"scroller\"\n class=\"m3-pdf-scroller absolute inset-0 overflow-auto overscroll-contain bg-surface-container-highest outline-none\"\n :class=\"[tool === 'select' ? '' : 'm3-pdf-annotating', coarse && 'scrollbar-none']\"\n tabindex=\"0\"\n @scroll=\"onScroll\"\n @dblclick=\"onDblClick\"\n >\n <div\n v-if=\"pdf.doc.value\"\n class=\"relative mx-auto\"\n :style=\"{ width: `${layout.width}px`, height: `${layout.height}px` }\"\n >\n <div\n v-for=\"(box, i) in layout.boxes\"\n :key=\"i\"\n class=\"absolute left-1/2 -translate-x-1/2\"\n :style=\"{ top: `${box.top}px`, width: `${box.width}px`, height: `${box.height}px` }\"\n >\n <PdfPageView\n :ref=\"(el) => setPageRef(i + 1, el)\"\n :pdf=\"pdf\"\n :page=\"i + 1\"\n :scale=\"scale\"\n :rotation=\"rotation\"\n :active=\"activePages.has(i + 1)\"\n :hits=\"hitsByPage.get(i + 1) ?? NO_HITS\"\n :annotations=\"byPage.get(i + 1) ?? NO_ANNOTATIONS\"\n :tool=\"tool\"\n :color=\"color\"\n :ink-width=\"inkWidth\"\n :selected-id=\"selected?.id ?? null\"\n class=\"h-full w-full\"\n @link=\"onLink\"\n @add=\"add\"\n @erase=\"erase\"\n @erase-start=\"eraseStart\"\n @erase-at=\"(at: { x: number; y: number; r: number }) => eraseAt(i + 1, at)\"\n @select=\"onSelect\"\n @text-selection=\"onTextSelection\"\n />\n </div>\n </div>\n\n <div v-else-if=\"pdf.needsPassword.value\" class=\"flex h-full items-center justify-center p-6\">\n <form class=\"flex w-full max-w-sm flex-col items-center gap-4 rounded-xl bg-surface-container-low p-6 text-center shadow-elevation-1\" @submit.prevent=\"submitPassword\">\n <MIcon name=\"lock\" :size=\"32\" class=\"text-primary\" />\n <p class=\"text-title-medium\">{{ locale.pdfPassword }}</p>\n <MTextField\n v-model=\"passwordInput\"\n type=\"password\"\n :label=\"locale.pdfPasswordLabel\"\n :error=\"pdf.wrongPassword.value\"\n :error-label=\"pdf.wrongPassword.value ? locale.pdfWrongPassword : undefined\"\n autocomplete=\"off\"\n class=\"w-full\"\n />\n <MButton type=\"submit\" :disabled=\"!passwordInput\" class=\"self-end\">{{ locale.pdfOpen }}</MButton>\n </form>\n </div>\n <div v-else-if=\"pdf.error.value\" class=\"flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-on-surface-variant\">\n <MIcon name=\"error\" :size=\"32\" class=\"text-error\" />\n <p class=\"text-title-medium text-on-surface\">{{ locale.pdfError }}</p>\n <p class=\"text-body-medium\">{{ pdf.error.value.message }}</p>\n </div>\n <div v-else-if=\"pdf.loading.value\" class=\"flex h-full items-center justify-center\">\n <MLoadingIndicator :label=\"locale.pdfLoading\" />\n </div>\n <div v-else class=\"flex h-full items-center justify-center p-6\">\n <slot name=\"empty\" />\n </div>\n </div>\n\n <!-- Page indicator while scrolling; a draggable thumb on touch (androidx.pdf's fast scroller) -->\n <Transition name=\"m3-pdf-fade\">\n <div v-if=\"pdf.doc.value && (scrolling || dragging) && pdf.numPages.value > 1\" class=\"pointer-events-none absolute inset-y-0 right-0 w-full\">\n <div class=\"absolute right-1 flex items-center gap-2\" :style=\"{ top: `${coarse ? thumbTop : Math.min(viewH - 40, Math.max(8, thumbTop))}px` }\">\n <span class=\"rounded-full bg-inverse-surface px-3 py-1 text-label-large text-inverse-on-surface tabular-nums shadow-elevation-1\">{{ currentPage }} / {{ pdf.numPages.value }}</span>\n <span v-if=\"coarse\" class=\"pointer-events-auto flex h-12 w-6 touch-none items-center justify-center\" @pointerdown=\"onThumbDown\">\n <span class=\"h-12 w-1.5 rounded-full bg-on-surface-variant\" />\n </span>\n <span v-else class=\"w-3\" />\n </div>\n </div>\n </Transition>\n\n <!-- Edit button, and the annotation toolbar (androidx.pdf's edit FAB) -->\n <Transition name=\"m3-pdf-fade\">\n <button\n v-if=\"annotate && pdf.doc.value && !editing\"\n type=\"button\"\n class=\"absolute right-4 bottom-4 flex size-14 cursor-pointer items-center justify-center rounded-lg bg-primary-container text-on-primary-container shadow-elevation-3 transition-shadow outline-none hover:shadow-elevation-4 focus-visible:ring-2 focus-visible:ring-primary\"\n :aria-label=\"locale.pdfAnnotate\"\n @click=\"openEditing\"\n ><MIcon name=\"edit\" :size=\"24\" /></button>\n </Transition>\n <Transition name=\"m3-pdf-rise\">\n <div v-if=\"annotate && editing\" class=\"absolute inset-x-0 bottom-4 z-10 flex justify-center px-2\">\n <div class=\"flex max-w-full items-center gap-1 overflow-x-auto rounded-full bg-surface-container-high p-2 shadow-elevation-3 scrollbar-none\" role=\"toolbar\" :aria-label=\"locale.pdfAnnotate\">\n <MIconButton\n v-for=\"t in TOOLS\"\n :key=\"t.id\"\n :icon=\"t.icon\"\n :label=\"t.label\"\n :checked=\"tool === t.id\"\n variant=\"standard\"\n @update:checked=\"setTool(t.id)\"\n />\n <span class=\"mx-1 h-6 w-px shrink-0 bg-outline-variant\" />\n <button\n v-for=\"c in colors\"\n :key=\"c\"\n type=\"button\"\n class=\"flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n :aria-label=\"`${locale.pdfColor} ${c}`\"\n :aria-pressed=\"color === c\"\n @click=\"color = c\"\n >\n <span class=\"size-6 rounded-full border border-outline-variant transition-transform\" :class=\"color === c && 'scale-125 ring-2 ring-on-surface ring-offset-2 ring-offset-surface-container-high'\" :style=\"{ backgroundColor: c }\" />\n </button>\n <!-- The pen's widths, drawn as dots of their size -->\n <template v-if=\"tool === 'ink' && inkWidths.length > 1\">\n <span class=\"mx-1 h-6 w-px shrink-0 bg-outline-variant\" />\n <button\n v-for=\"w in inkWidths\"\n :key=\"w\"\n type=\"button\"\n class=\"flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none hover:bg-on-surface/8 focus-visible:ring-2 focus-visible:ring-primary\"\n :class=\"inkWidth === w && 'bg-secondary-container'\"\n :aria-label=\"locale.pdfInkWidth.replace('{n}', String(w))\"\n :aria-pressed=\"inkWidth === w\"\n @click=\"inkWidth = w\"\n >\n <span class=\"rounded-full\" :style=\"{ width: `${Math.min(22, 3 + w * 2)}px`, height: `${Math.min(22, 3 + w * 2)}px`, backgroundColor: color }\" />\n </button>\n </template>\n <span class=\"mx-1 h-6 w-px shrink-0 bg-outline-variant\" />\n <MIconButton icon=\"undo\" :label=\"locale.pdfUndo\" :disabled=\"!canUndo\" @click=\"undo\" />\n <MIconButton icon=\"close\" :label=\"locale.close\" @click=\"closeEditing\" />\n </div>\n </div>\n </Transition>\n </div>\n </div>\n\n <!-- A text selection: copy, or highlight it -->\n <div v-if=\"selection\" class=\"absolute z-40 flex justify-center\" :style=\"cardStyle\">\n <div class=\"flex items-center gap-1 rounded-full bg-surface-container-high p-1 shadow-elevation-2\">\n <MButton variant=\"text\" icon=\"content_copy\" size=\"sm\" @click=\"copySelection\">{{ locale.pdfCopy }}</MButton>\n <MButton variant=\"text\" icon=\"ink_highlighter\" size=\"sm\" @click=\"highlightSelection\">{{ locale.pdfHighlight }}</MButton>\n </div>\n </div>\n\n <!-- The selected annotation -->\n <div v-if=\"selected && selectedAnnotation\" class=\"absolute z-40\" :style=\"cardStyle\" @keydown.stop=\"(e: KeyboardEvent) => e.key === 'Escape' && (selected = null)\">\n <div class=\"flex flex-col gap-3 rounded-lg bg-surface-container-high p-3 shadow-elevation-2\">\n <p v-if=\"selectedAnnotation.quote\" class=\"line-clamp-3 border-l-4 pl-2 text-body-medium text-on-surface-variant\" :style=\"{ borderColor: selectedAnnotation.color }\">{{ selectedAnnotation.quote }}</p>\n <MTextField\n :model-value=\"selectedAnnotation.text ?? ''\"\n :label=\"selectedAnnotation.type === 'note' ? locale.pdfNotePlaceholder : locale.pdfAddComment\"\n multiline\n auto-grow\n :rows=\"2\"\n :max-rows=\"6\"\n variant=\"outlined\"\n field-bg=\"var(--color-surface-container-high)\"\n @update:model-value=\"(v: string | number) => update(selectedAnnotation!.id, { text: String(v) })\"\n />\n <div class=\"flex items-center gap-1\">\n <button\n v-for=\"c in colors\"\n :key=\"c\"\n type=\"button\"\n class=\"flex size-8 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary\"\n :aria-label=\"`${locale.pdfColor} ${c}`\"\n :aria-pressed=\"selectedAnnotation.color === c\"\n @click=\"update(selectedAnnotation!.id, { color: c })\"\n >\n <span class=\"size-5 rounded-full border border-outline-variant\" :class=\"selectedAnnotation.color === c && 'ring-2 ring-on-surface ring-offset-1 ring-offset-surface-container-high'\" :style=\"{ backgroundColor: c }\" />\n </button>\n <span class=\"flex-1\" />\n <MIconButton icon=\"delete\" :label=\"locale.pdfDelete\" size=\"xs\" @click=\"erase(selectedAnnotation!.id)\" />\n <MIconButton icon=\"check\" :label=\"locale.close\" size=\"xs\" @click=\"selected = null\" />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style>\n/* Root defaults in the base layer, so any class the consumer gives (absolute inset-0, hidden…) wins */\n@layer base {\n .m3-pdf {\n position: relative;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n}\n\n/* pdf.js's text layer (from pdfjs-dist's pdf_viewer.css, Apache-2.0), for selectable text over the canvas */\n.m3-pdf .textLayer {\n position: absolute;\n inset: 0;\n overflow: clip;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n z-index: 0;\n --min-font-size: 1;\n --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));\n --min-font-size-inv: calc(1 / var(--min-font-size));\n}\n.m3-pdf .textLayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n user-select: text;\n}\n.m3-pdf .textLayer > :not(.markedContent),\n.m3-pdf .textLayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n --scale-x: 1;\n --rotate: 0deg;\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n}\n.m3-pdf .textLayer .markedContent { display: contents; }\n.m3-pdf .textLayer span.m3-pdf-hit {\n position: static;\n margin: -1px;\n padding: 1px;\n border-radius: 3px;\n background-color: color-mix(in srgb, var(--color-tertiary) 30%, transparent);\n}\n.m3-pdf .textLayer span.m3-pdf-hit-current { background-color: color-mix(in srgb, var(--color-primary) 45%, transparent); }\n.m3-pdf .textLayer ::selection { background: color-mix(in srgb, var(--color-primary) 30%, transparent); color: transparent; }\n.m3-pdf .textLayer br::selection { background: transparent; }\n.m3-pdf .textLayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n user-select: none;\n}\n.m3-pdf .textLayer.selecting .endOfContent { top: 0; }\n.m3-pdf [data-main-rotation='90'] { transform: rotate(90deg) translateY(-100%); }\n.m3-pdf [data-main-rotation='180'] { transform: rotate(180deg) translate(-100%, -100%); }\n.m3-pdf [data-main-rotation='270'] { transform: rotate(270deg) translateX(-100%); }\n\n/* Highlights tint the text under them, like a marker */\n.m3-pdf .m3-pdf-highlight { mix-blend-mode: multiply; opacity: 0.45; }\n.m3-pdf .m3-pdf-annotating .m3-pdf-highlight,\n.m3-pdf .m3-pdf-annotating .m3-pdf-ink { cursor: inherit; }\n.m3-pdf .m3-pdf-scroller:not(.m3-pdf-annotating) :is(.m3-pdf-highlight, .m3-pdf-ink) { pointer-events: auto; cursor: pointer; }\n.m3-pdf .m3-pdf-scroller.m3-pdf-annotating :is(.m3-pdf-highlight, .m3-pdf-ink) { pointer-events: none; }\n.m3-pdf .m3-pdf-selected { filter: drop-shadow(0 0 2px var(--color-primary)); opacity: 0.7; }\n\n.m3-pdf-fade-enter-active,\n.m3-pdf-fade-leave-active { transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1); }\n.m3-pdf-fade-enter-from,\n.m3-pdf-fade-leave-to { opacity: 0; }\n.m3-pdf-drop-enter-active,\n.m3-pdf-drop-leave-active { transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1), transform 250ms cubic-bezier(0.2, 0, 0, 1); }\n.m3-pdf-drop-enter-from,\n.m3-pdf-drop-leave-to { opacity: 0; transform: translateY(-8px); }\n.m3-pdf-rise-enter-active,\n.m3-pdf-rise-leave-active { transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1), transform 300ms cubic-bezier(0.05, 0.7, 0.1, 1); }\n.m3-pdf-rise-enter-from,\n.m3-pdf-rise-leave-to { opacity: 0; transform: translateY(24px); }\n.m3-pdf-panel-enter-active,\n.m3-pdf-panel-leave-active { transition: margin 300ms cubic-bezier(0.2, 0, 0, 1), opacity 200ms; }\n.m3-pdf-panel-enter-from,\n.m3-pdf-panel-leave-to { margin-left: -14rem; opacity: 0; }\n</style>\n"],"mappings":";;;;;;;;;;AAuGA,IAAI;AAGJ,SAAgB,EAAa,GAAa;CACxC,IAAkB;AACpB;AAEA,IAAI,IAA4C;AAGhD,SAAgB,EAAU,GAA0C;CASlE,OARA,OAAkB,YAAY;EAC5B,IAAM,IAAQ,MAAM,OAAO,eACrB,IAAM,KAAa;EAIzB,OAHI,IAAK,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