@m3ui-vue/m3ui-vue 1.8.0 → 1.9.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 (297) hide show
  1. package/dist/API.md +34 -19
  2. package/dist/MButton-LiZRRP4h.js +171 -0
  3. package/dist/MButton-LiZRRP4h.js.map +1 -0
  4. package/dist/{MColorPickerModal-H8nuX0Wu.js → MColorPickerModal-IjciC8zh.js} +185 -184
  5. package/dist/MColorPickerModal-IjciC8zh.js.map +1 -0
  6. package/dist/MDialog-BLpfgIA3.js +167 -0
  7. package/dist/MDialog-BLpfgIA3.js.map +1 -0
  8. package/dist/MIcon-BSsJZhK7.js +116 -0
  9. package/dist/MIcon-BSsJZhK7.js.map +1 -0
  10. package/dist/{MIconButton-BBggVwBV.js → MIconButton-CNjN0xwW.js} +18 -18
  11. package/dist/{MIconButton-BBggVwBV.js.map → MIconButton-CNjN0xwW.js.map} +1 -1
  12. package/dist/{MListItem-DiOAxaN7.js → MListItem-BBQ-6i3v.js} +139 -139
  13. package/dist/MListItem-BBQ-6i3v.js.map +1 -0
  14. package/dist/{MLoadingIndicator-CuTZYFFj.js → MLoadingIndicator-dejdXpu8.js} +2 -2
  15. package/dist/{MLoadingIndicator-CuTZYFFj.js.map → MLoadingIndicator-dejdXpu8.js.map} +1 -1
  16. package/dist/MMenuItem-E31tMzOt.js +577 -0
  17. package/dist/MMenuItem-E31tMzOt.js.map +1 -0
  18. package/dist/MPdfViewer-B5Q9Xs9d.js +1866 -0
  19. package/dist/MPdfViewer-B5Q9Xs9d.js.map +1 -0
  20. package/dist/MProgressBar-CPrZhQbA.js +179 -0
  21. package/dist/MProgressBar-CPrZhQbA.js.map +1 -0
  22. package/dist/{MSeekBar-BCDQTx2t.js → MSeekBar-NwkuAzx-.js} +2 -2
  23. package/dist/{MSeekBar-BCDQTx2t.js.map → MSeekBar-NwkuAzx-.js.map} +1 -1
  24. package/dist/{MSegmentedButton-BXzRsg1S.js → MSegmentedButton-DZuZLBML.js} +4 -4
  25. package/dist/{MSegmentedButton-BXzRsg1S.js.map → MSegmentedButton-DZuZLBML.js.map} +1 -1
  26. package/dist/MSignaturePad-Bqr-1R9f.js +140 -0
  27. package/dist/MSignaturePad-Bqr-1R9f.js.map +1 -0
  28. package/dist/MSlider-B7dIcHVn.js +745 -0
  29. package/dist/MSlider-B7dIcHVn.js.map +1 -0
  30. package/dist/{MSpinner-UCdtSOHP.js → MSpinner-CXLY7lWw.js} +2 -2
  31. package/dist/{MSpinner-UCdtSOHP.js.map → MSpinner-CXLY7lWw.js.map} +1 -1
  32. package/dist/{MTextField-CYk9yFvi.js → MTextField-CryHMs8-.js} +18 -18
  33. package/dist/MTextField-CryHMs8-.js.map +1 -0
  34. package/dist/MTooltip-Cn_DYm9M.js +90 -0
  35. package/dist/MTooltip-Cn_DYm9M.js.map +1 -0
  36. package/dist/{_popupPosition-nL8SVKPK.js → _popupPosition-C_lxj9qU.js} +7 -7
  37. package/dist/_popupPosition-C_lxj9qU.js.map +1 -0
  38. package/dist/{_useFieldValidation-B0B44M_t.js → _useFieldValidation-CvZnZfl-.js} +2 -2
  39. package/dist/{_useFieldValidation-B0B44M_t.js.map → _useFieldValidation-CvZnZfl-.js.map} +1 -1
  40. package/dist/api.json +1 -1
  41. package/dist/code-editor.js +129 -128
  42. package/dist/code-editor.js.map +1 -1
  43. package/dist/components/MAddressField.vue.d.ts +1 -1
  44. package/dist/components/MAudioPlayer.vue.d.ts +1 -1
  45. package/dist/components/MAutocomplete.vue.d.ts +1 -1
  46. package/dist/components/MAvailabilityCalendar.vue.d.ts +3 -3
  47. package/dist/components/MBadge.vue.d.ts +2 -2
  48. package/dist/components/MBar.vue.d.ts +1 -1
  49. package/dist/components/MBeforeAfter.vue.d.ts +3 -3
  50. package/dist/components/MButton.vue.d.ts +1 -1
  51. package/dist/components/MCalendarHeatmap.vue.d.ts +1 -1
  52. package/dist/components/MChatBubble.vue.d.ts +1 -1
  53. package/dist/components/MCodeEditor.vue.d.ts +1 -1
  54. package/dist/components/MContainerTransform.vue.d.ts +1 -1
  55. package/dist/components/MCopyButton.vue.d.ts +2 -2
  56. package/dist/components/MCountrySelect.vue.d.ts +1 -1
  57. package/dist/components/MCreditCardInput.vue.d.ts +2 -2
  58. package/dist/components/MDiffViewer.vue.d.ts +1 -1
  59. package/dist/components/MDrawCanvas.vue.d.ts +2 -2
  60. package/dist/components/MExpansionPanel.vue.d.ts +1 -1
  61. package/dist/components/MExportButton.vue.d.ts +1 -1
  62. package/dist/components/MFab.vue.d.ts +1 -1
  63. package/dist/components/MFilterBuilder.vue.d.ts +1 -1
  64. package/dist/components/MFlex.vue.d.ts +2 -2
  65. package/dist/components/MFloorPlan.vue.d.ts +2 -2
  66. package/dist/components/MFlow.vue.d.ts +2 -2
  67. package/dist/components/MFormRenderer.vue.d.ts +2 -2
  68. package/dist/components/MGantt.vue.d.ts +2 -2
  69. package/dist/components/MGanttControls.vue.d.ts +1 -1
  70. package/dist/components/MGrid.vue.d.ts +1 -1
  71. package/dist/components/MIcon.vue.d.ts +3 -5
  72. package/dist/components/MIconButton.vue.d.ts +1 -1
  73. package/dist/components/MLightbox.vue.d.ts +2 -2
  74. package/dist/components/MMapMeasure.vue.d.ts +2 -2
  75. package/dist/components/MMenu.vue.d.ts +6 -3
  76. package/dist/components/MMortgageCalculator.vue.d.ts +2 -2
  77. package/dist/components/MMultiAutocomplete.vue.d.ts +1 -1
  78. package/dist/components/MMultiSelect.vue.d.ts +1 -1
  79. package/dist/components/MNavigationDrawer.vue.d.ts +5 -4
  80. package/dist/components/MNavigationRail.vue.d.ts +1 -1
  81. package/dist/components/MNumberField.vue.d.ts +1 -1
  82. package/dist/components/MOdontogram.vue.d.ts +2 -2
  83. package/dist/components/MPdfSigner.vue.d.ts +1 -1
  84. package/dist/components/MPhoneInput.vue.d.ts +2 -2
  85. package/dist/components/MPinInput.vue.d.ts +3 -3
  86. package/dist/components/MPosKeypad.vue.d.ts +1 -1
  87. package/dist/components/MProductConfigurator.vue.d.ts +1 -1
  88. package/dist/components/MResourceTimeline.vue.d.ts +2 -2
  89. package/dist/components/MRichTextEditor.vue.d.ts +1 -1
  90. package/dist/components/MScheme.vue.d.ts +1 -1
  91. package/dist/components/MSearchBar.vue.d.ts +2 -2
  92. package/dist/components/MSearchField.vue.d.ts +1 -1
  93. package/dist/components/MSeatMap.vue.d.ts +1 -1
  94. package/dist/components/MSeekBar.vue.d.ts +2 -2
  95. package/dist/components/MSelect.vue.d.ts +1 -1
  96. package/dist/components/MShortNavigationBar.vue.d.ts +1 -1
  97. package/dist/components/MSkeleton.vue.d.ts +1 -1
  98. package/dist/components/MSpreadsheet.vue.d.ts +2 -2
  99. package/dist/components/MStack.vue.d.ts +2 -2
  100. package/dist/components/MSubtitle.vue.d.ts +1 -1
  101. package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
  102. package/dist/components/MSwitch.vue.d.ts +1 -1
  103. package/dist/components/MTagInput.vue.d.ts +1 -1
  104. package/dist/components/MText.vue.d.ts +1 -1
  105. package/dist/components/MTextField.vue.d.ts +3 -3
  106. package/dist/components/MTimeScroll.vue.d.ts +1 -1
  107. package/dist/components/MTimezoneSelect.vue.d.ts +1 -1
  108. package/dist/components/MTitle.vue.d.ts +1 -1
  109. package/dist/components/MToolbar.vue.d.ts +1 -1
  110. package/dist/components/MTooltip.vue.d.ts +1 -1
  111. package/dist/components/MTopAppBar.vue.d.ts +2 -2
  112. package/dist/components/MVitalsChart.vue.d.ts +1 -1
  113. package/dist/components/MWindow.vue.d.ts +3 -3
  114. package/dist/components/_MDrawerItemList.vue.d.ts +8 -1
  115. package/dist/composables/_fieldLayout.d.ts +8 -8
  116. package/dist/composables/_popupPosition.d.ts +3 -2
  117. package/dist/composables/_rtl.d.ts +26 -0
  118. package/dist/composables/useColorPalette.d.ts +1 -1
  119. package/dist/composables/useLocale.d.ts +4 -0
  120. package/dist/draw.js +5 -5
  121. package/dist/flow.js +2 -2
  122. package/dist/gantt.js +3 -3
  123. package/dist/locales/ar.d.ts +6 -0
  124. package/dist/locales/index.d.ts +1 -0
  125. package/dist/locales/index.js +768 -1
  126. package/dist/locales/index.js.map +1 -1
  127. package/dist/m3ui-vue.css +1 -1
  128. package/dist/m3ui.js +11962 -12039
  129. package/dist/m3ui.js.map +1 -1
  130. package/dist/map.js +1127 -1149
  131. package/dist/map.js.map +1 -1
  132. package/dist/markdown.js +1 -1
  133. package/dist/markdown.js.map +1 -1
  134. package/dist/media.js +7 -7
  135. package/dist/pdf-sign.d.ts +3 -0
  136. package/dist/pdf-sign.js +548 -0
  137. package/dist/pdf-sign.js.map +1 -0
  138. package/dist/pdf.d.ts +0 -3
  139. package/dist/pdf.js +1 -2400
  140. package/dist/plugin.d.ts +8 -0
  141. package/dist/rich-text-editor.js +79 -77
  142. package/dist/rich-text-editor.js.map +1 -1
  143. package/dist/styles/theme.css +13 -0
  144. package/dist/styles.css +1 -1
  145. package/dist/terminal.js +5 -2
  146. package/dist/terminal.js.map +1 -1
  147. package/dist/{useLocale-DL96OFgr.js → useLocale-ybIju59R.js} +3 -1
  148. package/dist/useLocale-ybIju59R.js.map +1 -0
  149. package/dist/vTooltip-xESB2YOb.js +154 -0
  150. package/dist/vTooltip-xESB2YOb.js.map +1 -0
  151. package/package.json +5 -1
  152. package/src/__tests__/MAddressField.test.ts +1 -1
  153. package/src/__tests__/MChip.test.ts +3 -3
  154. package/src/__tests__/MFab.test.ts +6 -6
  155. package/src/__tests__/MListItemNestedControl.test.ts +2 -2
  156. package/src/__tests__/MScheduler.test.ts +1 -1
  157. package/src/__tests__/MTrackingTimeline.test.ts +1 -1
  158. package/src/__tests__/MWindow.test.ts +16 -0
  159. package/src/__tests__/fieldOverflow.test.ts +9 -9
  160. package/src/__tests__/hydration.test.ts +39 -0
  161. package/src/__tests__/localePresets.test.ts +2 -0
  162. package/src/__tests__/rtl.test.ts +167 -0
  163. package/src/__tests__/ssr.test.ts +6 -0
  164. package/src/components/MAlert.vue +1 -1
  165. package/src/components/MAutocomplete.vue +7 -7
  166. package/src/components/MAvailabilityCalendar.vue +5 -3
  167. package/src/components/MBadge.vue +12 -3
  168. package/src/components/MBar.vue +1 -1
  169. package/src/components/MBottomAppBar.vue +1 -1
  170. package/src/components/MCalendar.vue +3 -3
  171. package/src/components/MCalendarHeatmap.vue +3 -3
  172. package/src/components/MChatBubble.vue +3 -3
  173. package/src/components/MChip.vue +6 -6
  174. package/src/components/MCodeEditor.vue +7 -3
  175. package/src/components/MColorPicker.vue +1 -1
  176. package/src/components/MCommandPalette.vue +1 -1
  177. package/src/components/MContainerTransform.vue +1 -1
  178. package/src/components/MContextMenu.vue +1 -1
  179. package/src/components/MDataTable.vue +5 -5
  180. package/src/components/MDatePicker.vue +3 -2
  181. package/src/components/MDateRangePicker.vue +3 -2
  182. package/src/components/MDialog.vue +5 -5
  183. package/src/components/MDiffViewer.vue +1 -1
  184. package/src/components/MDivider.vue +1 -1
  185. package/src/components/MDragDropList.vue +1 -1
  186. package/src/components/MEmojiSelector.vue +11 -7
  187. package/src/components/MExpansionPanel.vue +1 -1
  188. package/src/components/MFab.vue +5 -5
  189. package/src/components/MFormBuilder.vue +3 -3
  190. package/src/components/MIcon.vue +14 -2
  191. package/src/components/MJsonEditor.vue +1 -3
  192. package/src/components/MJsonViewer.vue +1 -1
  193. package/src/components/MKanban.vue +2 -1
  194. package/src/components/MListDetail.vue +2 -2
  195. package/src/components/MListGroup.vue +1 -1
  196. package/src/components/MListItem.vue +5 -5
  197. package/src/components/MListSubheader.vue +1 -1
  198. package/src/components/MMapDraw.vue +3 -2
  199. package/src/components/MMapHover.vue +2 -1
  200. package/src/components/MMapMeasure.vue +2 -1
  201. package/src/components/MMapRoute.vue +2 -1
  202. package/src/components/MMarkdown.vue +9 -6
  203. package/src/components/MMaskField.vue +6 -6
  204. package/src/components/MMenu.vue +13 -6
  205. package/src/components/MMenuItem.vue +8 -6
  206. package/src/components/MMultiAutocomplete.vue +9 -8
  207. package/src/components/MMultiSelect.vue +9 -8
  208. package/src/components/MNavigationDrawer.vue +39 -27
  209. package/src/components/MNavigationRail.vue +28 -19
  210. package/src/components/MNavigationSuite.vue +1 -1
  211. package/src/components/MNotificationCenter.vue +1 -1
  212. package/src/components/MNotificationHost.vue +1 -1
  213. package/src/components/MNumberField.vue +6 -6
  214. package/src/components/MOrderTicket.vue +1 -1
  215. package/src/components/MPageProgress.vue +1 -1
  216. package/src/components/MPdfSigner.vue +1 -1
  217. package/src/components/MPhoneInput.vue +5 -4
  218. package/src/components/MPinInput.vue +3 -2
  219. package/src/components/MPosKeypad.vue +2 -1
  220. package/src/components/MProductConfigurator.vue +2 -1
  221. package/src/components/MProgressBar.vue +2 -2
  222. package/src/components/MRichTextEditor.vue +8 -4
  223. package/src/components/MScheduler.vue +14 -14
  224. package/src/components/MSearchField.vue +1 -1
  225. package/src/components/MSeatMap.vue +2 -1
  226. package/src/components/MSegmentedButton.vue +1 -1
  227. package/src/components/MSelect.vue +7 -7
  228. package/src/components/MSideSheet.vue +3 -2
  229. package/src/components/MSimpleCarousel.vue +20 -11
  230. package/src/components/MSlider.vue +15 -5
  231. package/src/components/MSnackbar.vue +2 -2
  232. package/src/components/MSplitButton.vue +3 -2
  233. package/src/components/MSplitter.vue +6 -3
  234. package/src/components/MSpotlightSearch.vue +1 -1
  235. package/src/components/MSwitch.vue +5 -5
  236. package/src/components/MTable.vue +3 -3
  237. package/src/components/MTabs.vue +4 -1
  238. package/src/components/MTagInput.vue +6 -6
  239. package/src/components/MTerminal.vue +1 -1
  240. package/src/components/MText.vue +1 -1
  241. package/src/components/MTextField.vue +7 -7
  242. package/src/components/MTimePicker.vue +3 -2
  243. package/src/components/MTimePickerModal.vue +2 -2
  244. package/src/components/MTimeScroll.vue +1 -1
  245. package/src/components/MTimeline.vue +12 -12
  246. package/src/components/MToolbar.vue +3 -3
  247. package/src/components/MTrackingTimeline.vue +3 -2
  248. package/src/components/MTransition.vue +8 -3
  249. package/src/components/MTreeTable.vue +1 -1
  250. package/src/components/MTypewriter.vue +1 -1
  251. package/src/components/MVirtualTable.vue +2 -2
  252. package/src/components/MWindow.vue +4 -3
  253. package/src/components/_MColorPanel.vue +5 -4
  254. package/src/components/_MDrawerItemList.vue +9 -5
  255. package/src/components/_MMapAttribution.vue +2 -1
  256. package/src/components/_MMonthYearButton.vue +1 -1
  257. package/src/components/_MTransferPane.vue +8 -1
  258. package/src/components/_MTreeNode.vue +3 -3
  259. package/src/components/_MYearGrid.vue +4 -2
  260. package/src/composables/_fieldLayout.ts +19 -19
  261. package/src/composables/_popupPosition.ts +5 -3
  262. package/src/composables/_rtl.ts +76 -0
  263. package/src/composables/_useMenuNav.ts +24 -17
  264. package/src/composables/_useSheetMotion.ts +10 -3
  265. package/src/composables/pdfSign.ts +2 -2
  266. package/src/composables/useLocale.ts +6 -0
  267. package/src/locales/ar.ts +798 -0
  268. package/src/locales/de.ts +2 -0
  269. package/src/locales/es.ts +2 -0
  270. package/src/locales/fr.ts +2 -0
  271. package/src/locales/index.ts +1 -0
  272. package/src/locales/ja.ts +2 -0
  273. package/src/locales/ko.ts +2 -0
  274. package/src/locales/pt.ts +2 -0
  275. package/src/locales/zh.ts +2 -0
  276. package/src/pdf-sign.ts +5 -0
  277. package/src/pdf.ts +0 -3
  278. package/src/plugin.ts +10 -0
  279. package/src/styles/theme.css +13 -0
  280. package/dist/MColorPickerModal-H8nuX0Wu.js.map +0 -1
  281. package/dist/MDialog-B42Mhn8W.js +0 -331
  282. package/dist/MDialog-B42Mhn8W.js.map +0 -1
  283. package/dist/MIcon-DpajuUTJ.js +0 -33
  284. package/dist/MIcon-DpajuUTJ.js.map +0 -1
  285. package/dist/MListItem-DiOAxaN7.js.map +0 -1
  286. package/dist/MMenuItem-BuxYoASE.js +0 -574
  287. package/dist/MMenuItem-BuxYoASE.js.map +0 -1
  288. package/dist/MSignaturePad-BTqGaPXA.js +0 -313
  289. package/dist/MSignaturePad-BTqGaPXA.js.map +0 -1
  290. package/dist/MSlider-D_O8J9YH.js +0 -739
  291. package/dist/MSlider-D_O8J9YH.js.map +0 -1
  292. package/dist/MTextField-CYk9yFvi.js.map +0 -1
  293. package/dist/MTooltip-CK39Zon4.js +0 -183
  294. package/dist/MTooltip-CK39Zon4.js.map +0 -1
  295. package/dist/_popupPosition-nL8SVKPK.js.map +0 -1
  296. package/dist/pdf.js.map +0 -1
  297. package/dist/useLocale-DL96OFgr.js.map +0 -1
package/dist/pdf.js CHANGED
@@ -1,2400 +1 @@
1
- import { i as e } from "./useLocale-DL96OFgr.js";
2
- import { t } from "./MIcon-DpajuUTJ.js";
3
- import { t as n } from "./MIconButton-BBggVwBV.js";
4
- import { n as r, t as i } from "./MMenuItem-BuxYoASE.js";
5
- import { n as a, t as o } from "./MSignaturePad-BTqGaPXA.js";
6
- import { t as s } from "./MTextField-CYk9yFvi.js";
7
- import { n as c, t as l } from "./MDialog-B42Mhn8W.js";
8
- import { t as u } from "./MLoadingIndicator-CuTZYFFj.js";
9
- import { t as d } from "./MSegmentedButton-BXzRsg1S.js";
10
- import { Fragment as f, Transition as p, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, createTextVNode as y, createVNode as b, defineComponent as x, getCurrentScope as S, mergeProps as ee, nextTick as te, normalizeClass as C, normalizeStyle as w, onBeforeUnmount as ne, onMounted as re, onScopeDispose as T, openBlock as E, reactive as D, ref as O, renderList as k, renderSlot as ie, resolveDynamicComponent as ae, shallowRef as A, toDisplayString as j, toValue as M, unref as N, useId as P, vModelText as oe, watch as F, withCtx as I, withDirectives as L, withKeys as se, withModifiers as ce } from "vue";
11
- // src/composables/usePdf.ts
12
- var R;
13
- function z(e) {
14
- R = e;
15
- }
16
- var B = null;
17
- function V(e) {
18
- return B ??= (async () => {
19
- let t = await import("pdfjs-dist"), n = e ?? R;
20
- return n ? t.GlobalWorkerOptions.workerSrc = n : t.GlobalWorkerOptions.workerSrc || await import("pdfjs-dist/build/pdf.worker.min.mjs"), t;
21
- })(), B;
22
- }
23
- function H(e, t) {
24
- let n = "";
25
- for (let r of e) {
26
- let e = r.normalize("NFD").replace(/\p{M}/gu, ""), i = e.length === 1 ? e : r;
27
- n += t ? i : i.toLowerCase();
28
- }
29
- return n;
30
- }
31
- function U(e, t) {
32
- return typeof t == "string" ? e.PDFDateString.toDateObject(t) ?? void 0 : void 0;
33
- }
34
- function le(e, t = {}) {
35
- let n = A(null), r = A(null), i = O(!1), a = O(0), o = A(null), s = O(!1), c = O(!1), l = A([]), u = A([]), d = A({}), f = m(() => n.value?.numPages ?? 0), p = null, h = null, g = 0, _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
36
- function y() {
37
- for (let e of v.values()) e.then((e) => URL.revokeObjectURL(e), () => {});
38
- v.clear(), _.clear();
39
- let e = p;
40
- p = null, e?.destroy(), n.value = null, l.value = [], u.value = [], d.value = {}, s.value = !1, c.value = !1, h = null;
41
- }
42
- async function b(e) {
43
- let u = ++g;
44
- if (y(), o.value = null, a.value = 0, !e || typeof window > "u") i.value = !1;
45
- else {
46
- i.value = !0;
47
- try {
48
- let o = await V(t.workerSrc);
49
- if (u !== g) return;
50
- r.value = o;
51
- let d, f;
52
- if (typeof e == "string" || e instanceof URL ? f = String(e) : d = e instanceof Blob ? new Uint8Array(await e.arrayBuffer()) : new Uint8Array(e instanceof ArrayBuffer ? e.slice(0) : e.slice()), u !== g) return;
53
- p = o.getDocument({
54
- url: f,
55
- data: d,
56
- password: M(t.password),
57
- withCredentials: t.withCredentials
58
- }), p.onProgress = ({ loaded: e, total: t }) => {
59
- u === g && t && (a.value = Math.min(1, e / t));
60
- }, p.onPassword = (e, t) => {
61
- u === g && (h = e, c.value = t === o.PasswordResponses.INCORRECT_PASSWORD, s.value = !0);
62
- };
63
- let m = p, _ = await m.promise;
64
- if (u !== g) {
65
- m.destroy();
66
- return;
67
- }
68
- s.value = !1, c.value = !1, a.value = 1;
69
- let v = (await _.getPage(1)).getViewport({ scale: 1 });
70
- l.value = Array.from({ length: _.numPages }, () => ({
71
- width: v.width,
72
- height: v.height
73
- })), n.value = _, i.value = !1, x(_, u), te(_, u), C(_, o, u);
74
- } catch (e) {
75
- if (u !== g) return;
76
- o.value = e instanceof Error ? e : Error(String(e)), i.value = !1;
77
- }
78
- }
79
- }
80
- async function x(e, t) {
81
- let n = l.value.slice(), r = !1;
82
- for (let i = 2; i <= e.numPages; i++) {
83
- if (t !== g) return;
84
- let a = (await e.getPage(i)).getViewport({ scale: 1 }), o = n[i - 1];
85
- (o.width !== a.width || o.height !== a.height) && (n[i - 1] = {
86
- width: a.width,
87
- height: a.height
88
- }, r = !0), r && (i % 25 == 0 || i === e.numPages) && (l.value = n.slice(), r = !1);
89
- }
90
- }
91
- async function ee(e) {
92
- let t = n.value;
93
- if (!t || !e) return null;
94
- try {
95
- let n = typeof e == "string" ? await t.getDestination(e) : e;
96
- if (!Array.isArray(n)) return null;
97
- let r = n[0], i = typeof r == "number" ? r : await t.getPageIndex(r), a = n[1]?.name, o = a === "XYZ" ? n[3] : a === "FitH" || a === "FitBH" ? n[2] : null;
98
- return {
99
- page: i + 1,
100
- top: typeof o == "number" ? o : void 0
101
- };
102
- } catch {
103
- return null;
104
- }
105
- }
106
- async function te(e, t) {
107
- let n = await e.getOutline().catch(() => null);
108
- if (!n || t !== g) return;
109
- let r = async (e) => Promise.all(e.map(async (e) => {
110
- let t = e.dest ? await ee(e.dest) : null;
111
- return {
112
- title: e.title,
113
- page: t?.page,
114
- top: t?.top,
115
- url: e.url ?? void 0,
116
- children: await r(e.items ?? [])
117
- };
118
- })), i = await r(n);
119
- t === g && (u.value = i);
120
- }
121
- async function C(e, t, n) {
122
- let r = await e.getMetadata().catch(() => null);
123
- if (!r || n !== g) return;
124
- let i = r.info, a = (e) => typeof e == "string" && e.trim() ? e : void 0;
125
- d.value = {
126
- title: a(r.metadata?.get("dc:title")) ?? a(i.Title),
127
- author: a(r.metadata?.get("dc:creator")) ?? a(i.Author),
128
- subject: a(i.Subject),
129
- creator: a(i.Creator),
130
- producer: a(i.Producer),
131
- creationDate: U(t, i.CreationDate),
132
- modificationDate: U(t, i.ModDate)
133
- };
134
- }
135
- async function w(e) {
136
- let t = n.value;
137
- if (!t) throw Error("No document loaded");
138
- return t.getPage(e);
139
- }
140
- function ne(e) {
141
- let t = _.get(e);
142
- return t || (t = w(e).then(async (e) => {
143
- let t = await e.getTextContent(), n = "", r = [];
144
- for (let e of t.items) "str" in e && (r.push(n.length), n += e.str, e.hasEOL && (n += " "));
145
- return {
146
- text: n,
147
- starts: r
148
- };
149
- }), _.set(e, t)), t;
150
- }
151
- async function re(e, t = {}) {
152
- let r = H(e.trim(), !!t.caseSensitive), i = [];
153
- if (!r || !n.value) return i;
154
- for (let e = 1; e <= f.value && !t.signal?.aborted; e++) {
155
- let { text: n } = await ne(e), a = H(n, !!t.caseSensitive), o = 0;
156
- for (let t = a.indexOf(r); t >= 0; t = a.indexOf(r, t + r.length)) {
157
- let a = Math.max(0, t - 40), s = Math.min(n.length, t + r.length + 40);
158
- i.push({
159
- page: e,
160
- index: o++,
161
- start: t,
162
- end: t + r.length,
163
- context: (a ? "…" : "") + n.slice(a, s).trim() + (s < n.length ? "…" : "")
164
- });
165
- }
166
- }
167
- return i;
168
- }
169
- function E(e, t = 160) {
170
- let n = typeof window < "u" ? Math.min(2, window.devicePixelRatio || 1) : 1, r = `${e}@${t}`, i = v.get(r);
171
- return i || (i = w(e).then(async (e) => {
172
- let r = e.getViewport({ scale: 1 }), i = e.getViewport({ scale: t / r.width * n }), a = document.createElement("canvas");
173
- a.width = Math.ceil(i.width), a.height = Math.ceil(i.height), await e.render({
174
- canvas: a,
175
- viewport: i
176
- }).promise;
177
- let o = await new Promise((e) => a.toBlob(e, "image/png"));
178
- if (!o) throw Error("Thumbnail failed");
179
- return URL.createObjectURL(o);
180
- }), v.set(r, i)), i;
181
- }
182
- let D = async () => {
183
- let e = n.value;
184
- if (!e) throw Error("No document loaded");
185
- return e.getData();
186
- };
187
- async function k() {
188
- let e = await D();
189
- return URL.createObjectURL(new Blob([e], { type: "application/pdf" }));
190
- }
191
- async function ie(t) {
192
- let n = await k(), r = M(e), i = typeof r == "string" ? decodeURIComponent(r.split(/[?#]/)[0].split("/").pop() ?? "") : "", a = document.createElement("a");
193
- a.href = n, a.download = t ?? (r instanceof File ? r.name : i.toLowerCase().endsWith(".pdf") ? i : `${d.value.title ?? "document"}.pdf`), document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(n), 3e4);
194
- }
195
- async function ae() {
196
- let e = await k(), t = document.createElement("iframe");
197
- t.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden", t.src = e, t.onload = () => {
198
- try {
199
- t.contentWindow?.focus(), t.contentWindow?.print();
200
- } catch {
201
- window.open(e, "_blank");
202
- }
203
- setTimeout(() => {
204
- t.remove(), URL.revokeObjectURL(e);
205
- }, 6e4);
206
- }, document.body.appendChild(t);
207
- }
208
- function j(e) {
209
- let t = h;
210
- t && (h = null, s.value = !1, t(e));
211
- }
212
- return F(() => M(e), (e) => {
213
- b(e);
214
- }, { immediate: !0 }), S() && T(() => {
215
- g++, y();
216
- }), {
217
- doc: n,
218
- pdfjs: r,
219
- loading: i,
220
- progress: a,
221
- error: o,
222
- needsPassword: s,
223
- wrongPassword: c,
224
- submitPassword: j,
225
- numPages: f,
226
- pageSizes: l,
227
- outline: u,
228
- metadata: d,
229
- getPage: w,
230
- pageText: ne,
231
- search: re,
232
- thumbnail: E,
233
- resolveDest: ee,
234
- getData: D,
235
- download: ie,
236
- print: ae
237
- };
238
- }
239
- // src/components/_MPdfPage.vue?vue&type=script&setup=true&lang.ts
240
- var W = ["data-page"], ue = [
241
- "href",
242
- "target",
243
- "rel",
244
- "onClick"
245
- ], de = ["viewBox"], fe = ["onClick"], pe = [
246
- "x",
247
- "y",
248
- "width",
249
- "height",
250
- "fill"
251
- ], G = [
252
- "d",
253
- "stroke",
254
- "stroke-width",
255
- "onClick"
256
- ], me = ["cx", "cy"], K = [
257
- "d",
258
- "stroke",
259
- "stroke-width"
260
- ], he = ["aria-label", "onClick"], q = 16e6, J = 12, ge = /* @__PURE__ */ x({
261
- __name: "_MPdfPage",
262
- props: {
263
- pdf: {},
264
- page: {},
265
- scale: {},
266
- rotation: {},
267
- active: { type: Boolean },
268
- hits: {},
269
- annotations: {},
270
- tool: {},
271
- color: {},
272
- inkWidth: {},
273
- selectedId: {}
274
- },
275
- emits: [
276
- "link",
277
- "add",
278
- "select",
279
- "erase",
280
- "erase-start",
281
- "erase-at",
282
- "text-selection",
283
- "rendered"
284
- ],
285
- setup(e, { expose: n, emit: r }) {
286
- let i = e, a = r, o = O(), s = O(), c = O(), l = A(null), u = A(null);
287
- function d(e) {
288
- return e.getViewport({
289
- scale: i.scale,
290
- rotation: (e.rotate + i.rotation) % 360
291
- });
292
- }
293
- let p = null, h = "";
294
- async function y() {
295
- if (!i.active) return;
296
- let e = l.value ??= await i.pdf.getPage(i.page).catch(() => null);
297
- if (!e || !i.active) return;
298
- let t = d(e);
299
- u.value = t;
300
- let n = Math.min(2, window.devicePixelRatio || 1);
301
- t.width * t.height * n * n > q && (n = Math.sqrt(q / (t.width * t.height)));
302
- let r = `${i.scale}|${i.rotation}|${n}`;
303
- if (r === h) return;
304
- p?.cancel();
305
- let o = document.createElement("canvas");
306
- o.width = Math.floor(t.width * n), o.height = Math.floor(t.height * n), o.className = "absolute inset-0 h-full w-full";
307
- let c = e.render({
308
- canvas: o,
309
- viewport: t,
310
- transform: n === 1 ? void 0 : [
311
- n,
312
- 0,
313
- 0,
314
- n,
315
- 0,
316
- 0
317
- ]
318
- });
319
- p = c;
320
- try {
321
- await c.promise;
322
- } catch {
323
- return;
324
- }
325
- if (p !== c) return;
326
- p = null, h = r;
327
- let f = s.value;
328
- f && (f.replaceChildren(o), a("rendered", i.page), re(e, t), N(e, t));
329
- }
330
- function x() {
331
- p?.cancel(), p = null, h = "";
332
- let e = s.value?.querySelector("canvas");
333
- e && (e.width = 0, e.height = 0), s.value?.replaceChildren(), ee?.cancel(), ee = null, c.value?.replaceChildren(), j.value = [], l.value?.cleanup();
334
- }
335
- let S, ee = null, te = null;
336
- async function re(e, t) {
337
- let n = i.pdf.pdfjs.value, r = c.value;
338
- if (!n || !r) return;
339
- ee?.cancel(), te ??= await e.getTextContent();
340
- let a = document.createElement("div");
341
- a.className = "textLayer";
342
- let o = new n.TextLayer({
343
- textContentSource: te,
344
- container: a,
345
- viewport: t
346
- });
347
- ee = o;
348
- try {
349
- await o.render();
350
- } catch {
351
- return;
352
- }
353
- ee === o && (r.replaceChildren(a), ie());
354
- }
355
- let T = [], D = (e) => e.replace(/[&<>"]/g, (e) => ({
356
- "&": "&amp;",
357
- "<": "&lt;",
358
- ">": "&gt;",
359
- "\"": "&quot;"
360
- })[e]);
361
- async function ie() {
362
- let e = ee;
363
- if (!e) return;
364
- for (let t of T) e.textDivs[t] && (e.textDivs[t].textContent = e.textContentItemsStr[t] ?? "");
365
- if (T = [], !i.hits.length) return;
366
- let { starts: t } = await i.pdf.pageText(i.page);
367
- if (e !== ee) return;
368
- let n = /* @__PURE__ */ new Map();
369
- for (let r of i.hits) for (let i = 0; i < t.length; i++) {
370
- let a = t[i], o = e.textContentItemsStr[i] ?? "", s = Math.max(r.start, a), c = Math.min(r.end, a + o.length);
371
- if (c > s) {
372
- let e = n.get(i) ?? [];
373
- e.push({
374
- a: s - a,
375
- b: c - a,
376
- current: r.current
377
- }), n.set(i, e);
378
- }
379
- }
380
- let r = null;
381
- for (let [t, i] of n) {
382
- let n = e.textDivs[t], a = e.textContentItemsStr[t] ?? "";
383
- if (!n) continue;
384
- i.sort((e, t) => e.a - t.a);
385
- let o = "", s = 0;
386
- for (let e of i) o += D(a.slice(s, e.a)) + `<span class="m3-pdf-hit${e.current ? " m3-pdf-hit-current" : ""}">${D(a.slice(e.a, e.b))}</span>`, s = e.b;
387
- n.innerHTML = o + D(a.slice(s)), T.push(t), i.some((e) => e.current) && (r ??= n.querySelector(".m3-pdf-hit-current"));
388
- }
389
- ae.value = r;
390
- }
391
- let ae = A(null);
392
- F(() => i.hits, ie);
393
- let j = O([]), M = null;
394
- async function N(e, t) {
395
- M ??= (await e.getAnnotations().catch(() => [])).filter((e) => e.subtype === "Link" && (e.url || e.dest)).map((e) => ({
396
- rect: e.rect,
397
- url: e.url,
398
- dest: e.dest
399
- })), j.value = M.map((e) => {
400
- let [n, r] = t.convertToViewportPoint(e.rect[0], e.rect[1]), [i, a] = t.convertToViewportPoint(e.rect[2], e.rect[3]);
401
- return {
402
- left: Math.min(n, i),
403
- top: Math.min(r, a),
404
- width: Math.abs(i - n),
405
- height: Math.abs(a - r),
406
- url: e.url,
407
- dest: e.dest
408
- };
409
- });
410
- }
411
- let P = m(() => u.value && h ? i.scale / Number(h.split("|")[0]) : 1), oe = (e, t) => u.value ? u.value.convertToViewportPoint(e, t) : [0, 0], I = (e, t) => u.value ? u.value.convertToPdfPoint(e, t) : [0, 0], L = m(() => (i.scale, i.rotation, i.annotations.map((e) => {
412
- if (e.type === "highlight") return {
413
- a: e,
414
- rects: (e.rects ?? []).map(([e, t, n, r]) => {
415
- let [i, a] = oe(e, t), [o, s] = oe(n, r);
416
- return {
417
- x: Math.min(i, o),
418
- y: Math.min(a, s),
419
- w: Math.abs(o - i),
420
- h: Math.abs(s - a)
421
- };
422
- })
423
- };
424
- if (e.type === "ink") return {
425
- a: e,
426
- d: (e.paths ?? []).map((e) => e.map(([e, t], n) => {
427
- let [r, i] = oe(e, t);
428
- return `${n ? "L" : "M"}${r.toFixed(1)},${i.toFixed(1)}`;
429
- }).join("")).join(""),
430
- w: (e.width ?? 2) * i.scale
431
- };
432
- let [t, n] = oe(e.at?.[0] ?? 0, e.at?.[1] ?? 0);
433
- return {
434
- a: e,
435
- x: t,
436
- y: n
437
- };
438
- })));
439
- function se(e, t) {
440
- i.tool === "select" && (e.stopPropagation(), a("select", {
441
- id: t.id,
442
- anchor: e.currentTarget.getBoundingClientRect()
443
- }));
444
- }
445
- let ce = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `a${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`, R = () => (/* @__PURE__ */ new Date()).toISOString();
446
- function z(e) {
447
- let t = o.value.getBoundingClientRect(), n = u.value;
448
- return [(e.clientX - t.left) / (t.width || 1) * n.width, (e.clientY - t.top) / (t.height || 1) * n.height];
449
- }
450
- function B(e) {
451
- if (i.tool !== "note" || !u.value) return;
452
- let [t, n] = I(...z(e));
453
- a("add", {
454
- id: ce(),
455
- type: "note",
456
- page: i.page,
457
- color: i.color,
458
- at: [t, n],
459
- text: "",
460
- createdAt: R()
461
- });
462
- }
463
- let V = O(null), H = O(!1), U = O(null), le = -1, ge = (e) => e.pointerType === "pen" && (e.button === 5 || !!(e.buttons & 32));
464
- function _e(e) {
465
- let t = z(e);
466
- U.value = t;
467
- let [n, r] = I(t[0], t[1]);
468
- a("erase-at", {
469
- x: n,
470
- y: r,
471
- r: J / i.scale
472
- });
473
- }
474
- function Y(e) {
475
- let t = ge(e);
476
- if (!(i.tool !== "ink" && i.tool !== "eraser" && !t || e.button !== 0 && !t || !u.value)) {
477
- e.preventDefault(), le = e.pointerId;
478
- try {
479
- e.currentTarget.setPointerCapture(e.pointerId);
480
- } catch {}
481
- i.tool === "eraser" || t ? (H.value = !0, a("erase-start"), _e(e)) : V.value = [z(e)];
482
- }
483
- }
484
- function ve(e) {
485
- if (i.tool === "eraser" && !H.value && e.pointerType !== "touch" && (U.value = z(e)), e.pointerId !== le) return;
486
- if (H.value) return _e(e);
487
- if (!V.value) return;
488
- let t = z(e), n = V.value[V.value.length - 1];
489
- Math.hypot(t[0] - n[0], t[1] - n[1]) >= 1.5 && (V.value = [...V.value, t]);
490
- }
491
- function ye(e) {
492
- if (e.pointerId !== le) return;
493
- if (le = -1, H.value) {
494
- H.value = !1, e.pointerType === "touch" && (U.value = null);
495
- return;
496
- }
497
- if (!V.value) return;
498
- let t = V.value;
499
- V.value = null, t.length < 2 || a("add", {
500
- id: ce(),
501
- type: "ink",
502
- page: i.page,
503
- color: i.color,
504
- width: i.inkWidth,
505
- paths: [t.map(([e, t]) => I(e, t).map((e) => Math.round(e * 100) / 100))],
506
- createdAt: R()
507
- });
508
- }
509
- let be = m(() => (V.value ?? []).map(([e, t], n) => `${n ? "L" : "M"}${e.toFixed(1)},${t.toFixed(1)}`).join(""));
510
- function xe(e, t) {
511
- let n = u.value;
512
- if (!n || !o.value) return !1;
513
- let r = o.value.getBoundingClientRect(), i = n.width / (r.width || 1), s = n.height / (r.height || 1), c = (e - r.left) * i, l = (t - r.top) * s;
514
- for (let e of [...L.value].reverse()) {
515
- if (!("rects" in e) || !e.rects) continue;
516
- let t = e.rects.find((e) => c >= e.x - 2 && c <= e.x + e.w + 2 && l >= e.y - 2 && l <= e.y + e.h + 2);
517
- if (t) return a("select", {
518
- id: e.a.id,
519
- anchor: new DOMRect(r.left + t.x / i, r.top + t.y / s, t.w / i, t.h / s)
520
- }), !0;
521
- }
522
- return !1;
523
- }
524
- function Se(e) {
525
- let t = e ? {
526
- x: e.clientX,
527
- y: e.clientY
528
- } : null;
529
- setTimeout(() => {
530
- let e = window.getSelection(), n = c.value;
531
- if (!e || e.isCollapsed || !e.rangeCount || !n || !u.value) {
532
- if (t && (i.tool === "select" || i.tool === "highlight") && xe(t.x, t.y)) return;
533
- i.tool === "select" && a("text-selection", null);
534
- return;
535
- }
536
- let r = e.getRangeAt(0);
537
- if (!n.contains(r.commonAncestorContainer)) return;
538
- let s = o.value.getBoundingClientRect(), l = u.value, d = l.width / (s.width || 1), f = l.height / (s.height || 1), p = [];
539
- for (let e of Array.from(r.getClientRects())) {
540
- if (e.width < 1 || e.height < 1) continue;
541
- let [t, n] = I((e.left - s.left) * d, (e.top - s.top) * f), [r, i] = I((e.right - s.left) * d, (e.bottom - s.top) * f);
542
- p.push([
543
- t,
544
- n,
545
- r,
546
- i
547
- ].map((e) => Math.round(e * 100) / 100));
548
- }
549
- if (!p.length) return;
550
- let m = e.toString().replace(/\s+/g, " ").trim();
551
- i.tool === "highlight" ? (a("add", {
552
- id: ce(),
553
- type: "highlight",
554
- page: i.page,
555
- color: i.color,
556
- rects: p,
557
- quote: m,
558
- text: "",
559
- createdAt: R()
560
- }), e.removeAllRanges()) : a("text-selection", {
561
- page: i.page,
562
- rects: p,
563
- quote: m,
564
- anchor: r.getBoundingClientRect()
565
- });
566
- });
567
- }
568
- return F(() => i.active, (e) => e ? y() : x(), { immediate: !0 }), F(() => [i.scale, i.rotation], () => {
569
- l.value && (u.value = d(l.value)), clearTimeout(S), S = setTimeout(y, 140);
570
- }), ne(() => {
571
- clearTimeout(S), x();
572
- }), n({
573
- root: o,
574
- currentHit: ae
575
- }), (n, r) => (E(), _("div", {
576
- ref_key: "root",
577
- ref: o,
578
- class: "m3-pdf-page relative bg-white shadow-elevation-1",
579
- "data-page": e.page,
580
- style: w({
581
- "--scale-factor": e.scale,
582
- "--total-scale-factor": e.scale,
583
- "--user-unit": 1,
584
- "--scale-round-x": "1px",
585
- "--scale-round-y": "1px"
586
- }),
587
- onClick: B
588
- }, [
589
- v("div", {
590
- ref_key: "canvasHost",
591
- ref: s,
592
- class: "absolute inset-0"
593
- }, null, 512),
594
- v("div", {
595
- ref_key: "textHost",
596
- ref: c,
597
- class: C(["absolute inset-0 overflow-hidden", { "pointer-events-none": e.tool === "ink" || e.tool === "note" || e.tool === "eraser" }]),
598
- onPointerup: Se
599
- }, null, 34),
600
- (E(!0), _(f, null, k(j.value, (t, n) => (E(), _("a", {
601
- key: n,
602
- href: t.url ?? "#",
603
- target: t.url ? "_blank" : void 0,
604
- rel: t.url ? "noopener noreferrer" : void 0,
605
- class: C(["absolute rounded-xs hover:bg-primary/12", { "pointer-events-none": e.tool !== "select" }]),
606
- style: w({
607
- left: `${t.left * P.value}px`,
608
- top: `${t.top * P.value}px`,
609
- width: `${t.width * P.value}px`,
610
- height: `${t.height * P.value}px`
611
- }),
612
- onClick: (e) => {
613
- t.url ? a("link", { url: t.url }) : (e.preventDefault(), a("link", { dest: t.dest }));
614
- }
615
- }, null, 14, ue))), 128)),
616
- (E(), _("svg", {
617
- class: C(["absolute inset-0 h-full w-full overflow-visible", e.tool === "ink" ? "cursor-crosshair touch-none" : e.tool === "eraser" ? "cursor-none touch-none" : "pointer-events-none"]),
618
- viewBox: u.value ? `0 0 ${u.value.width} ${u.value.height}` : void 0,
619
- preserveAspectRatio: "none",
620
- onPointerdown: Y,
621
- onPointermove: ve,
622
- onPointerup: ye,
623
- onPointercancel: ye,
624
- onPointerleave: r[0] ||= (e) => U.value = H.value ? U.value : null
625
- }, [
626
- (E(!0), _(f, null, k(L.value, (t) => (E(), _(f, { key: t.a.id }, ["rects" in t ? (E(), _("g", {
627
- key: 0,
628
- class: C(["m3-pdf-highlight", { "m3-pdf-selected": t.a.id === e.selectedId }]),
629
- onClick: (e) => se(e, t.a)
630
- }, [(E(!0), _(f, null, k(t.rects, (e, n) => (E(), _("rect", {
631
- key: n,
632
- x: e.x,
633
- y: e.y,
634
- width: e.w,
635
- height: e.h,
636
- rx: "2",
637
- fill: t.a.color
638
- }, null, 8, pe))), 128))], 10, fe)) : "d" in t ? (E(), _("path", {
639
- key: 1,
640
- d: t.d,
641
- fill: "none",
642
- stroke: t.a.color,
643
- "stroke-width": t.w,
644
- "stroke-linecap": "round",
645
- "stroke-linejoin": "round",
646
- class: C(["m3-pdf-ink", { "m3-pdf-selected": t.a.id === e.selectedId }]),
647
- onClick: (e) => se(e, t.a)
648
- }, null, 10, G)) : g("", !0)], 64))), 128)),
649
- U.value && e.tool === "eraser" ? (E(), _("circle", {
650
- key: 0,
651
- cx: U.value[0],
652
- cy: U.value[1],
653
- r: J,
654
- class: "pointer-events-none fill-surface/40 stroke-on-surface",
655
- "stroke-width": "1.5"
656
- }, null, 8, me)) : g("", !0),
657
- V.value ? (E(), _("path", {
658
- key: 1,
659
- d: be.value,
660
- fill: "none",
661
- stroke: e.color,
662
- "stroke-width": e.inkWidth * e.scale,
663
- "stroke-linecap": "round",
664
- "stroke-linejoin": "round"
665
- }, null, 8, K)) : g("", !0)
666
- ], 42, de)),
667
- (E(!0), _(f, null, k(L.value, (n) => (E(), _(f, { key: `n-${n.a.id}` }, ["x" in n ? (E(), _("button", {
668
- key: 0,
669
- type: "button",
670
- class: C(["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", { "ring-2 ring-primary": n.a.id === e.selectedId }]),
671
- style: w({
672
- left: `${n.x}px`,
673
- top: `${n.y}px`,
674
- backgroundColor: n.a.color
675
- }),
676
- "aria-label": n.a.text || "Note",
677
- onClick: (t) => {
678
- t.stopPropagation(), e.tool === "eraser" ? a("erase", n.a.id) : a("select", {
679
- id: n.a.id,
680
- anchor: t.currentTarget.getBoundingClientRect()
681
- });
682
- }
683
- }, [b(t, {
684
- name: "sticky_note_2",
685
- size: 16,
686
- filled: "",
687
- class: "text-black/70"
688
- })], 14, he)) : g("", !0)], 64))), 128))
689
- ], 12, W));
690
- }
691
- }), _e = ["aria-label"], Y = {
692
- key: 0,
693
- class: "relative z-10 flex h-16 shrink-0 items-center gap-1 bg-surface-container px-1 sm:px-2"
694
- }, ve = { class: "min-w-0 flex-1 truncate px-1 text-title-medium" }, ye = {
695
- key: 0,
696
- class: "flex items-center gap-1 text-body-medium text-on-surface-variant"
697
- }, be = ["aria-label"], xe = { class: "tabular-nums" }, Se = {
698
- key: 1,
699
- class: "mx-1 flex items-center"
700
- }, Ce = ["aria-label"], we = {
701
- key: 0,
702
- class: "m3-pdf-search z-10 flex shrink-0 items-center gap-1 bg-surface-container px-2 pb-2"
703
- }, Te = { class: "flex h-12 min-w-0 flex-1 items-center gap-2 rounded-full bg-surface-container-highest pr-1 pl-4" }, Ee = ["placeholder", "aria-label"], De = {
704
- class: "shrink-0 text-label-medium whitespace-nowrap text-on-surface-variant tabular-nums",
705
- "aria-live": "polite"
706
- }, Oe = { class: "relative flex min-h-0 flex-1" }, ke = { class: "flex shrink-0 gap-1 px-3 pt-1 pb-2" }, Ae = ["disabled", "onClick"], je = { class: "flex flex-col items-center gap-3" }, Me = [
707
- "aria-label",
708
- "aria-current",
709
- "onClick"
710
- ], Ne = ["src"], Pe = ["aria-label"], Fe = ["aria-label", "onClick"], Ie = {
711
- key: 1,
712
- class: "w-8 shrink-0"
713
- }, Le = { class: "min-w-0 flex-1 truncate" }, Re = {
714
- key: 0,
715
- class: "text-label-small text-on-surface-variant tabular-nums"
716
- }, ze = { class: "relative min-w-0 flex-1" }, Be = {
717
- key: 1,
718
- class: "flex h-full items-center justify-center p-6"
719
- }, Ve = { class: "text-title-medium" }, He = {
720
- key: 2,
721
- class: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center text-on-surface-variant"
722
- }, Ue = { class: "text-title-medium text-on-surface" }, We = { class: "text-body-medium" }, Ge = {
723
- key: 3,
724
- class: "flex h-full items-center justify-center"
725
- }, Ke = {
726
- key: 4,
727
- class: "flex h-full items-center justify-center p-6"
728
- }, qe = {
729
- key: 0,
730
- class: "pointer-events-none absolute inset-y-0 right-0 w-full"
731
- }, Je = { class: "rounded-full bg-inverse-surface px-3 py-1 text-label-large text-inverse-on-surface tabular-nums shadow-elevation-1" }, Ye = {
732
- key: 1,
733
- class: "w-3"
734
- }, Xe = ["aria-label"], Ze = {
735
- key: 0,
736
- class: "absolute inset-x-0 bottom-4 z-10 flex justify-center px-2"
737
- }, Qe = ["aria-label"], $e = [
738
- "aria-label",
739
- "aria-pressed",
740
- "onClick"
741
- ], et = [
742
- "aria-label",
743
- "aria-pressed",
744
- "onClick"
745
- ], tt = { class: "flex items-center gap-1 rounded-full bg-surface-container-high p-1 shadow-elevation-2" }, nt = { class: "flex flex-col gap-3 rounded-lg bg-surface-container-high p-3 shadow-elevation-2" }, rt = { class: "flex items-center gap-1" }, it = [
746
- "aria-label",
747
- "aria-pressed",
748
- "onClick"
749
- ];
750
- function at(e, t) {
751
- let { x: n, y: r, r: i } = t;
752
- if (e.type === "note") {
753
- let [t, a] = e.at ?? [0, 0];
754
- return Math.hypot(t - n, a - r) <= i + 10 ? null : e;
755
- }
756
- if (e.type === "highlight") return (e.rects ?? []).some(([e, t, a, o]) => n >= Math.min(e, a) - i && n <= Math.max(e, a) + i && r >= Math.min(t, o) - i && r <= Math.max(t, o) + i) ? null : e;
757
- let a = i + (e.width ?? 2) / 2, o = (e, t) => {
758
- let i = t[0] - e[0], o = t[1] - e[1], s = i * i + o * o, c = s ? Math.max(0, Math.min(1, ((n - e[0]) * i + (r - e[1]) * o) / s)) : 0;
759
- return Math.hypot(e[0] + c * i - n, e[1] + c * o - r) <= a;
760
- }, s = !1, c = [];
761
- for (let t of e.paths ?? []) {
762
- let e = [];
763
- t.forEach((i, l) => {
764
- let u = t[l - 1], d = Math.hypot(i[0] - n, i[1] - r) <= a, f = !!u && e.length > 0 && o(u, i);
765
- d || f ? (s = !0, e.length > 1 && c.push(e), e = d ? [] : [i]) : e.push(i);
766
- }), e.length > 1 && c.push(e);
767
- }
768
- return s ? c.length ? {
769
- ...e,
770
- paths: c
771
- } : null : e;
772
- }
773
- // src/components/MPdfViewer.vue
774
- var ot = /* @__PURE__ */ x({
775
- inheritAttrs: !1,
776
- __name: "MPdfViewer",
777
- props: {
778
- src: { default: null },
779
- title: {},
780
- page: { default: void 0 },
781
- zoom: { default: "fit-width" },
782
- rotation: { default: 0 },
783
- annotations: { default: () => [] },
784
- annotate: {
785
- type: Boolean,
786
- default: !1
787
- },
788
- tool: { default: "select" },
789
- colors: { default: () => [
790
- "#FFE14D",
791
- "#7ED957",
792
- "#5EB8FF",
793
- "#FF7EB6",
794
- "#B388FF",
795
- "#1F1F1F"
796
- ] },
797
- inkWidths: { default: () => [
798
- 1,
799
- 2,
800
- 4,
801
- 8
802
- ] },
803
- author: {},
804
- sidebar: { default: null },
805
- toolbar: {
806
- type: Boolean,
807
- default: !0
808
- },
809
- downloadable: {
810
- type: Boolean,
811
- default: !0
812
- },
813
- fileName: {},
814
- password: {},
815
- workerSrc: {},
816
- minZoom: { default: .25 },
817
- maxZoom: { default: 8 }
818
- },
819
- emits: [
820
- "update:page",
821
- "update:zoom",
822
- "update:rotation",
823
- "update:annotations",
824
- "update:tool",
825
- "update:sidebar",
826
- "loaded",
827
- "error",
828
- "link",
829
- "annotation-click"
830
- ],
831
- setup(o, { expose: l, emit: d }) {
832
- let x = o, S = d, T = e(), M = le(() => x.src, {
833
- password: () => x.password,
834
- workerSrc: x.workerSrc
835
- });
836
- F(M.doc, (e) => {
837
- e && S("loaded", e);
838
- }), F(M.error, (e) => {
839
- e && S("error", e);
840
- });
841
- let P = O(), R = O(), z = O(800), B = O(600), V = O(800), H = m(() => V.value < 600), U = 96 / 72, W = O((x.rotation % 360 + 360) % 360);
842
- F(() => x.rotation, (e) => {
843
- W.value = (e % 360 + 360) % 360;
844
- });
845
- let ue = m(() => {
846
- let e = W.value % 180 != 0;
847
- return M.pageSizes.value.map((t) => e ? {
848
- width: t.height,
849
- height: t.width
850
- } : t);
851
- }), de = O(x.zoom);
852
- F(() => x.zoom, (e) => {
853
- e !== de.value && X(e);
854
- });
855
- let fe = m(() => ue.value[Math.max(0, J.value - 1)] ?? ue.value[0] ?? {
856
- width: 612,
857
- height: 792
858
- });
859
- function pe(e) {
860
- let t = (z.value - 2 * (H.value ? 8 : 16)) / fe.value.width;
861
- return e === "fit-width" ? t : Math.min(t, (B.value - 32) / fe.value.height);
862
- }
863
- let G = m(() => {
864
- let e = de.value, t = typeof e == "number" ? e * U : pe(e);
865
- return Math.max(x.minZoom * U, Math.min(x.maxZoom * U, t || U));
866
- }), me = m(() => Math.round(G.value / U * 100)), K = m(() => {
867
- let e = H.value ? 8 : 16, t = e, n = 0;
868
- return {
869
- boxes: ue.value.map((e) => {
870
- let r = Math.floor(e.width * G.value), i = Math.floor(e.height * G.value), a = {
871
- top: t,
872
- width: r,
873
- height: i
874
- };
875
- return t += i + 8, n = Math.max(n, r), a;
876
- }),
877
- height: t - 8 + e,
878
- width: n + 2 * e,
879
- pad: e
880
- };
881
- }), he = O(0);
882
- function q(e) {
883
- let t = K.value.boxes, n = 0, r = t.length - 1;
884
- for (; n < r;) {
885
- let i = n + r + 1 >> 1;
886
- t[i].top <= e ? n = i : r = i - 1;
887
- }
888
- return n;
889
- }
890
- let J = O(1);
891
- function ot() {
892
- if (!K.value.boxes.length) return;
893
- let e = q(he.value + B.value / 3) + 1;
894
- e !== J.value && (J.value = e, S("update:page", e));
895
- }
896
- let st = m(() => {
897
- if (!K.value.boxes.length) return /* @__PURE__ */ new Set();
898
- let e = q(Math.max(0, he.value - B.value)), t = q(he.value + B.value * 2), n = /* @__PURE__ */ new Set();
899
- for (let r = e; r <= t; r++) n.add(r + 1);
900
- return n;
901
- }), ct, lt = O(!1), ut = null;
902
- function dt() {
903
- let e = R.value;
904
- he.value = e.scrollTop, ot(), ut !== null && Math.abs(e.scrollTop - ut) < 1 ? ut = null : (ut = null, lt.value = !0, clearTimeout(ct), ct = setTimeout(() => lt.value = !1, 1200));
905
- }
906
- function ft(e, t, n = !1) {
907
- let r = R.value, i = K.value.boxes[e - 1];
908
- if (!r || !i) return;
909
- let a = ue.value[e - 1], o = t !== void 0 && W.value === 0 ? Math.max(0, (a.height - t) * G.value) : 0;
910
- r.scrollTo({
911
- top: i.top + o - (o ? 8 : K.value.pad),
912
- behavior: n ? "smooth" : "auto"
913
- }), J.value = e, S("update:page", e);
914
- }
915
- F(() => x.page, (e) => {
916
- e && e !== J.value && ft(e);
917
- });
918
- function X(e, t) {
919
- let n = R.value, r = typeof e == "number" ? Math.max(x.minZoom, Math.min(x.maxZoom, e)) : e;
920
- if (!n || !K.value.boxes.length) {
921
- de.value = r, S("update:zoom", r);
922
- return;
923
- }
924
- let i = n.getBoundingClientRect(), a = t ? t.x - i.left : n.clientWidth / 2, o = t ? t.y - i.top : n.clientHeight / 2, s = n.scrollTop + o, c = q(s), l = K.value.boxes[c], u = (s - l.top) / l.height, d = (Math.max(K.value.width, n.clientWidth) - l.width) / 2, f = (n.scrollLeft + a - d) / l.width;
925
- de.value = r, S("update:zoom", r), te(() => {
926
- let e = K.value.boxes[c], t = Math.max(K.value.width, n.clientWidth);
927
- n.scrollTop = e.top + u * e.height - o, n.scrollLeft = (t - e.width) / 2 + f * e.width - a, dt();
928
- });
929
- }
930
- let pt = (e, t) => X(G.value / U * e, t), mt = [
931
- .5,
932
- .75,
933
- 1,
934
- 1.25,
935
- 1.5,
936
- 2,
937
- 3,
938
- 4
939
- ];
940
- function ht(e) {
941
- let t = G.value / U;
942
- X(e > 0 ? mt.find((e) => e > t + .01) ?? x.maxZoom : [...mt].reverse().find((e) => e < t - .01) ?? x.minZoom);
943
- }
944
- function gt(e) {
945
- (e.ctrlKey || e.metaKey) && (e.preventDefault(), pt(Math.exp(-e.deltaY * (e.deltaMode === 1 ? .05 : .0025)), {
946
- x: e.clientX,
947
- y: e.clientY
948
- }));
949
- }
950
- function _t(e) {
951
- if (x.tool !== "select" || e.target.closest("button, a, input, textarea")) return;
952
- let t = pe("fit-width");
953
- G.value > t * 1.05 ? X("fit-width", {
954
- x: e.clientX,
955
- y: e.clientY
956
- }) : X(Math.min(x.maxZoom, t * 2 / U), {
957
- x: e.clientX,
958
- y: e.clientY
959
- });
960
- }
961
- let vt = null, yt = 0, bt = 1, xt = {
962
- x: 0,
963
- y: 0
964
- };
965
- function St() {
966
- let e = M.pdfjs.value, t = R.value;
967
- e && t && !vt && (vt = new AbortController(), new e.TouchManager({
968
- container: t,
969
- isPinchingDisabled: () => x.tool === "ink",
970
- onPinching: (e, t, n) => {
971
- bt *= n / (t || n), xt = {
972
- x: e[0],
973
- y: e[1]
974
- }, yt ||= requestAnimationFrame(() => {
975
- yt = 0;
976
- let e = bt;
977
- bt = 1, pt(e, xt);
978
- });
979
- },
980
- signal: vt.signal
981
- }));
982
- }
983
- F(() => M.pdfjs.value, St);
984
- let Ct;
985
- F(M.doc, async (e) => {
986
- if (!e) return;
987
- await te();
988
- let t = x.page && x.page <= e.numPages ? x.page : 1;
989
- J.value = t, t > 1 ? ft(t) : R.value && (R.value.scrollTop = 0), St();
990
- });
991
- function wt() {
992
- let e = J.value;
993
- W.value = (W.value + 90) % 360, S("update:rotation", W.value), te(() => ft(e));
994
- }
995
- let Tt = O(!1), Et = O(""), Dt = A([]), Ot = O(-1), kt = O(!1), At = null, jt;
996
- F(Et, (e) => {
997
- clearTimeout(jt), jt = setTimeout(() => Mt(e), 250);
998
- });
999
- async function Mt(e) {
1000
- if (At?.abort(), Dt.value = [], Ot.value = -1, !e.trim() || !M.doc.value) return;
1001
- let t = At = new AbortController();
1002
- kt.value = !0;
1003
- let n = await M.search(e, { signal: t.signal });
1004
- if (t.signal.aborted) return;
1005
- kt.value = !1, Dt.value = n;
1006
- let r = n.findIndex((e) => e.page >= J.value);
1007
- n.length && Nt(r < 0 ? 0 : r);
1008
- }
1009
- function Nt(e) {
1010
- let t = Dt.value.length;
1011
- if (!t) return;
1012
- Ot.value = (e % t + t) % t;
1013
- let n = Dt.value[Ot.value];
1014
- (!st.value.has(n.page) || Math.abs(n.page - J.value) > 0) && ft(n.page), Pt = !0;
1015
- }
1016
- let Pt = !1, Ft = m(() => {
1017
- let e = /* @__PURE__ */ new Map();
1018
- return Dt.value.forEach((t, n) => {
1019
- let r = e.get(t.page) ?? [];
1020
- r.push({
1021
- start: t.start,
1022
- end: t.end,
1023
- current: n === Ot.value
1024
- }), e.set(t.page, r);
1025
- }), e;
1026
- }), It = [], Lt = D(/* @__PURE__ */ new Map());
1027
- function Rt(e, t) {
1028
- t ? Lt.set(e, t) : Lt.delete(e);
1029
- }
1030
- F(() => {
1031
- let e = Dt.value[Ot.value];
1032
- return e ? Lt.get(e.page)?.currentHit : null;
1033
- }, (e) => {
1034
- if (!e || !Pt || !R.value) return;
1035
- Pt = !1;
1036
- let t = e.getBoundingClientRect(), n = R.value.getBoundingClientRect();
1037
- R.value.scrollBy({
1038
- top: t.top - n.top - n.height / 2,
1039
- left: t.left < n.left || t.right > n.right ? t.left - n.left - n.width / 2 : 0
1040
- });
1041
- });
1042
- function zt() {
1043
- Tt.value = !0, te(() => P.value?.querySelector(".m3-pdf-search input")?.focus());
1044
- }
1045
- function Bt() {
1046
- Tt.value = !1, Et.value = "", At?.abort(), Dt.value = [], Ot.value = -1;
1047
- }
1048
- let Vt = m(() => Et.value.trim() ? kt.value ? "…" : Dt.value.length ? T.pdfMatchCount.replace("{current}", String(Ot.value + 1)).replace("{total}", String(Dt.value.length)) : T.pdfNoMatches : ""), Ht = O(x.sidebar);
1049
- F(() => x.sidebar, (e) => {
1050
- Ht.value = e;
1051
- });
1052
- function Ut(e) {
1053
- Ht.value = e, S("update:sidebar", e);
1054
- }
1055
- let Wt = D(/* @__PURE__ */ new Map()), Gt = O(), Kt = null;
1056
- function qt(e, t) {
1057
- e instanceof HTMLElement && (e.dataset.page = String(t), Kt?.observe(e));
1058
- }
1059
- F([Ht, M.doc], async ([e, t]) => {
1060
- Kt?.disconnect(), Wt.clear(), e === "thumbnails" && t && typeof IntersectionObserver < "u" && (await te(), Kt = new IntersectionObserver((e) => {
1061
- for (let t of e) {
1062
- if (!t.isIntersecting) continue;
1063
- let e = Number(t.target.dataset.page);
1064
- Wt.has(e) || (Wt.set(e, ""), M.thumbnail(e, 120).then((t) => Wt.set(e, t), () => {}));
1065
- }
1066
- }, {
1067
- root: Gt.value,
1068
- rootMargin: "200px"
1069
- }), Gt.value?.querySelectorAll("[data-page]").forEach((e) => Kt.observe(e)), Gt.value?.querySelector(`[data-page="${J.value}"]`)?.scrollIntoView({ block: "center" }));
1070
- });
1071
- function Jt(e, t) {
1072
- ft(e, t), H.value && Ut(null);
1073
- }
1074
- let Yt = D(/* @__PURE__ */ new Set()), Xt = m(() => {
1075
- let e = [], t = (n, r, i) => {
1076
- n.forEach((n, a) => {
1077
- let o = `${i}${a}`;
1078
- e.push({
1079
- key: o,
1080
- title: n.title,
1081
- page: n.page,
1082
- top: n.top,
1083
- url: n.url,
1084
- depth: r,
1085
- hasChildren: n.children.length > 0
1086
- }), n.children.length && Yt.has(o) && t(n.children, r + 1, `${o}.`);
1087
- });
1088
- };
1089
- return t(M.outline.value, 0, ""), e;
1090
- });
1091
- function Zt(e) {
1092
- Yt.has(e) ? Yt.delete(e) : Yt.add(e);
1093
- }
1094
- async function Qt(e) {
1095
- if (e.url) {
1096
- S("link", { url: e.url });
1097
- return;
1098
- }
1099
- let t = await M.resolveDest(e.dest);
1100
- t && (ft(t.page, t.top), S("link", { page: t.page }));
1101
- }
1102
- let $t = O(x.tool);
1103
- F(() => x.tool, (e) => {
1104
- $t.value = e;
1105
- });
1106
- function en(e) {
1107
- $t.value = e, S("update:tool", e), $.value = null, Z.value = null;
1108
- }
1109
- let tn = O(x.colors[0]), nn = O(x.inkWidths[1] ?? x.inkWidths[0] ?? 2), rn = O(!1);
1110
- F(() => x.annotate, (e) => {
1111
- e || on();
1112
- });
1113
- function an() {
1114
- rn.value = !0, en("highlight");
1115
- }
1116
- function on() {
1117
- rn.value = !1, en("select");
1118
- }
1119
- let sn = m(() => {
1120
- let e = /* @__PURE__ */ new Map();
1121
- for (let t of x.annotations) {
1122
- let n = e.get(t.page) ?? [];
1123
- n.push(t), e.set(t.page, n);
1124
- }
1125
- return e;
1126
- }), cn = [], ln = [];
1127
- function un(e) {
1128
- ln.push(x.annotations), ln.length > 50 && ln.shift(), dn.value = !0, S("update:annotations", e);
1129
- }
1130
- let dn = O(!1);
1131
- function fn() {
1132
- let e = ln.pop();
1133
- dn.value = ln.length > 0, e && S("update:annotations", e), Z.value = null;
1134
- }
1135
- function pn(e) {
1136
- x.author && (e.author = x.author), un([...x.annotations, e]), e.type === "note" && te(() => bn(e.id));
1137
- }
1138
- function mn(e) {
1139
- un(x.annotations.filter((t) => t.id !== e)), Z.value?.id === e && (Z.value = null);
1140
- }
1141
- function hn() {
1142
- ln.push(x.annotations), ln.length > 50 && ln.shift(), dn.value = !0;
1143
- }
1144
- function gn(e, t) {
1145
- let n = !1, r = [];
1146
- for (let i of x.annotations) {
1147
- let a = i.page === e ? at(i, t) : i;
1148
- a !== i && (n = !0), a && r.push(a);
1149
- }
1150
- n && (Z.value && !r.some((e) => e.id === Z.value.id) && (Z.value = null), S("update:annotations", r));
1151
- }
1152
- function _n(e, t) {
1153
- S("update:annotations", x.annotations.map((n) => n.id === e ? {
1154
- ...n,
1155
- ...t
1156
- } : n));
1157
- }
1158
- let Z = O(null), Q = m(() => x.annotations.find((e) => e.id === Z.value?.id) ?? null);
1159
- function vn(e) {
1160
- let t = P.value.getBoundingClientRect();
1161
- return {
1162
- x: Math.min(Math.max(8, e.left - t.left + e.width / 2), t.width - 8),
1163
- y: e.bottom - t.top + 8
1164
- };
1165
- }
1166
- function yn(e) {
1167
- if (!e) {
1168
- Z.value = null;
1169
- return;
1170
- }
1171
- $.value = null, Z.value = {
1172
- id: e.id,
1173
- ...vn(e.anchor)
1174
- };
1175
- let t = x.annotations.find((t) => t.id === e.id);
1176
- t && S("annotation-click", t);
1177
- }
1178
- function bn(e) {
1179
- let t = P.value?.querySelector(".m3-pdf-note[aria-label]"), n = x.annotations.find((t) => t.id === e);
1180
- if (!n) return;
1181
- let r = [...(Lt.get(n.page)?.root)?.querySelectorAll(".m3-pdf-note") ?? []].pop() ?? t;
1182
- r && (Z.value = {
1183
- id: e,
1184
- ...vn(r.getBoundingClientRect())
1185
- });
1186
- }
1187
- let xn = m(() => {
1188
- let e = Z.value ?? $.value;
1189
- if (!e) return {};
1190
- let t = Math.min(300, V.value - 16);
1191
- return {
1192
- left: `${Math.min(Math.max(8, e.x - t / 2), V.value - t - 8)}px`,
1193
- top: `${e.y}px`,
1194
- width: `${t}px`
1195
- };
1196
- }), $ = O(null);
1197
- function Sn(e) {
1198
- !e || !x.annotate ? $.value = null : (Z.value = null, $.value = {
1199
- page: e.page,
1200
- rects: e.rects,
1201
- quote: e.quote,
1202
- ...vn(e.anchor)
1203
- });
1204
- }
1205
- function Cn() {
1206
- let e = $.value;
1207
- e && (pn({
1208
- id: crypto.randomUUID?.() ?? String(Date.now()),
1209
- type: "highlight",
1210
- page: e.page,
1211
- color: tn.value,
1212
- rects: e.rects,
1213
- quote: e.quote,
1214
- text: "",
1215
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
1216
- }), window.getSelection()?.removeAllRanges(), $.value = null);
1217
- }
1218
- async function wn() {
1219
- let e = $.value;
1220
- e && await navigator.clipboard?.writeText(e.quote).catch(() => {}), window.getSelection()?.removeAllRanges(), $.value = null;
1221
- }
1222
- F(he, () => {
1223
- $.value = null, Q.value?.type !== "note" && (Z.value = null);
1224
- });
1225
- let Tn = typeof window < "u" && !!window.matchMedia?.("(pointer: coarse)").matches, En = m(() => {
1226
- let e = R.value, t = K.value.height - B.value;
1227
- return he.value, e && t > 0 ? he.value / t * (B.value - 48) : 0;
1228
- }), Dn = O(!1);
1229
- function On(e) {
1230
- e.preventDefault(), Dn.value = !0, e.currentTarget.setPointerCapture(e.pointerId);
1231
- let t = e.clientY, n = R.value.scrollTop, r = K.value.height - B.value, i = (e) => {
1232
- R.value.scrollTop = n + (e.clientY - t) / Math.max(1, B.value - 48) * r;
1233
- }, a = () => {
1234
- Dn.value = !1, window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", a);
1235
- };
1236
- window.addEventListener("pointermove", i), window.addEventListener("pointerup", a);
1237
- }
1238
- let kn = O(!1);
1239
- async function An() {
1240
- document.fullscreenElement ? await document.exitFullscreen().catch(() => {}) : await P.value?.requestFullscreen?.().catch(() => {});
1241
- }
1242
- let jn = () => {
1243
- kn.value = document.fullscreenElement === P.value;
1244
- };
1245
- function Mn(e) {
1246
- let t = !!e.target.closest("input, textarea, [contenteditable]"), n = e.ctrlKey || e.metaKey;
1247
- if (n && e.key.toLowerCase() === "f") e.preventDefault(), zt();
1248
- else if (n && (e.key === "=" || e.key === "+")) e.preventDefault(), ht(1);
1249
- else if (n && e.key === "-") e.preventDefault(), ht(-1);
1250
- else if (n && e.key === "0") e.preventDefault(), X("fit-width");
1251
- else if (n && e.key.toLowerCase() === "z" && !t && x.annotate) e.preventDefault(), fn();
1252
- else if (e.key === "Escape") {
1253
- if (Z.value || $.value) Z.value = null, $.value = null;
1254
- else if (Tt.value) Bt();
1255
- else if (rn.value) on();
1256
- else return;
1257
- e.stopPropagation();
1258
- } else !t && (e.key === "Delete" || e.key === "Backspace") && Z.value ? mn(Z.value.id) : t || n || e.key !== "PageDown" && e.key !== "PageUp" || (e.preventDefault(), ft(Math.max(1, Math.min(M.numPages.value, J.value + (e.key === "PageDown" ? 1 : -1)))));
1259
- }
1260
- let Nn = O("");
1261
- F(J, (e) => {
1262
- Nn.value = String(e);
1263
- }, { immediate: !0 });
1264
- function Pn() {
1265
- let e = Math.round(Number(Nn.value));
1266
- e >= 1 && e <= M.numPages.value ? ft(e) : Nn.value = String(J.value);
1267
- }
1268
- let Fn = O("");
1269
- function In() {
1270
- M.submitPassword(Fn.value), Fn.value = "";
1271
- }
1272
- let Ln = m(() => x.title ?? M.metadata.value.title ?? "");
1273
- re(() => {
1274
- let e = R.value;
1275
- e.addEventListener("wheel", gt, { passive: !1 }), Ct = new ResizeObserver(() => {
1276
- let t = K.value.boxes, n = B.value / 3, r = t.length ? q(e.scrollTop + n) : -1, i = r >= 0 ? (e.scrollTop + n - t[r].top) / t[r].height : 0;
1277
- z.value = e.clientWidth, B.value = e.clientHeight, V.value = P.value?.clientWidth ?? V.value, r < 0 || te(() => {
1278
- let t = K.value.boxes[r];
1279
- if (!t) return;
1280
- let a = Math.round(t.top + i * t.height - n);
1281
- Math.abs(a - e.scrollTop) < 1 || (e.scrollTop = a, he.value = e.scrollTop, ot(), ut = e.scrollTop);
1282
- });
1283
- }), Ct.observe(e), Ct.observe(P.value), z.value = e.clientWidth || z.value, B.value = e.clientHeight || B.value, V.value = P.value.clientWidth || V.value, document.addEventListener("fullscreenchange", jn);
1284
- }), ne(() => {
1285
- Ct?.disconnect(), vt?.abort(), Kt?.disconnect(), At?.abort(), cancelAnimationFrame(yt), clearTimeout(ct), clearTimeout(jt), document.removeEventListener("fullscreenchange", jn);
1286
- }), l({
1287
- pdf: M,
1288
- goToPage: (e) => ft(e),
1289
- setZoom: (e) => X(e),
1290
- search: (e) => {
1291
- zt(), Et.value = e;
1292
- },
1293
- undo: fn
1294
- });
1295
- let Rn = m(() => [
1296
- {
1297
- id: "select",
1298
- icon: "arrow_selector_tool",
1299
- label: T.pdfSelect
1300
- },
1301
- {
1302
- id: "highlight",
1303
- icon: "ink_highlighter",
1304
- label: T.pdfHighlight
1305
- },
1306
- {
1307
- id: "note",
1308
- icon: "sticky_note_2",
1309
- label: T.pdfNote
1310
- },
1311
- {
1312
- id: "ink",
1313
- icon: "draw",
1314
- label: T.pdfDraw
1315
- },
1316
- {
1317
- id: "eraser",
1318
- icon: "ink_eraser",
1319
- label: T.pdfEraser
1320
- }
1321
- ]);
1322
- return (e, l) => (E(), _("div", ee({
1323
- ref_key: "root",
1324
- ref: P
1325
- }, e.$attrs, {
1326
- role: "region",
1327
- "aria-label": Ln.value || N(T).pdfViewer,
1328
- class: "m3-pdf bg-surface-container text-on-surface",
1329
- onKeydown: Mn
1330
- }), [
1331
- o.toolbar ? (E(), _("div", Y, [
1332
- b(n, {
1333
- icon: Ht.value ? "left_panel_close" : "left_panel_open",
1334
- label: N(T).pdfThumbnails,
1335
- disabled: !N(M).doc.value,
1336
- onClick: l[0] ||= (e) => Ut(Ht.value ? null : "thumbnails")
1337
- }, null, 8, [
1338
- "icon",
1339
- "label",
1340
- "disabled"
1341
- ]),
1342
- v("p", ve, j(Ln.value), 1),
1343
- N(M).doc.value ? (E(), _(f, { key: 0 }, [
1344
- H.value ? g("", !0) : (E(), _("div", ye, [L(v("input", {
1345
- "onUpdate:modelValue": l[1] ||= (e) => Nn.value = e,
1346
- inputmode: "numeric",
1347
- 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",
1348
- "aria-label": N(T).pdfPage,
1349
- onKeydown: se(Pn, ["enter"]),
1350
- onBlur: Pn
1351
- }, null, 40, be), [[oe, Nn.value]]), v("span", xe, "/ " + j(N(M).numPages.value), 1)])),
1352
- H.value ? g("", !0) : (E(), _("div", Se, [
1353
- b(n, {
1354
- icon: "remove",
1355
- label: N(T).pdfZoomOut,
1356
- size: "xs",
1357
- onClick: l[2] ||= (e) => ht(-1)
1358
- }, null, 8, ["label"]),
1359
- b(r, { align: "right" }, {
1360
- trigger: I(() => [v("button", {
1361
- type: "button",
1362
- class: "h-8 min-w-14 cursor-pointer rounded-full px-2 text-label-large tabular-nums hover:bg-on-surface/8",
1363
- "aria-label": N(T).pdfZoom
1364
- }, j(me.value) + "%", 9, Ce)]),
1365
- default: I(() => [
1366
- b(i, {
1367
- icon: "fit_width",
1368
- selected: de.value === "fit-width",
1369
- onClick: l[3] ||= (e) => X("fit-width")
1370
- }, {
1371
- default: I(() => [y(j(N(T).pdfFitWidth), 1)]),
1372
- _: 1
1373
- }, 8, ["selected"]),
1374
- b(i, {
1375
- icon: "fit_page",
1376
- selected: de.value === "fit-page",
1377
- onClick: l[4] ||= (e) => X("fit-page")
1378
- }, {
1379
- default: I(() => [y(j(N(T).pdfFitPage), 1)]),
1380
- _: 1
1381
- }, 8, ["selected"]),
1382
- (E(), _(f, null, k(mt, (e) => b(i, {
1383
- key: e,
1384
- selected: de.value === e,
1385
- onClick: (t) => X(e)
1386
- }, {
1387
- default: I(() => [y(j(e * 100) + "%", 1)]),
1388
- _: 2
1389
- }, 1032, ["selected", "onClick"])), 64))
1390
- ]),
1391
- _: 1
1392
- }),
1393
- b(n, {
1394
- icon: "add",
1395
- label: N(T).pdfZoomIn,
1396
- size: "xs",
1397
- onClick: l[5] ||= (e) => ht(1)
1398
- }, null, 8, ["label"])
1399
- ])),
1400
- b(n, {
1401
- icon: "search",
1402
- label: N(T).pdfSearch,
1403
- checked: Tt.value,
1404
- "onUpdate:checked": l[6] ||= (e) => e ? zt() : Bt()
1405
- }, null, 8, ["label", "checked"]),
1406
- ie(e.$slots, "actions", { pdf: N(M) }),
1407
- b(r, { align: "right" }, {
1408
- trigger: I(() => [b(n, {
1409
- icon: "more_vert",
1410
- label: N(T).pdfMore
1411
- }, null, 8, ["label"])]),
1412
- default: I(() => [
1413
- H.value ? (E(), _(f, { key: 0 }, [
1414
- b(i, {
1415
- icon: "zoom_in",
1416
- onClick: l[7] ||= (e) => ht(1)
1417
- }, {
1418
- default: I(() => [y(j(N(T).pdfZoomIn), 1)]),
1419
- _: 1
1420
- }),
1421
- b(i, {
1422
- icon: "zoom_out",
1423
- onClick: l[8] ||= (e) => ht(-1)
1424
- }, {
1425
- default: I(() => [y(j(N(T).pdfZoomOut), 1)]),
1426
- _: 1
1427
- }),
1428
- b(i, {
1429
- icon: "fit_width",
1430
- onClick: l[9] ||= (e) => X("fit-width")
1431
- }, {
1432
- default: I(() => [y(j(N(T).pdfFitWidth), 1)]),
1433
- _: 1
1434
- })
1435
- ], 64)) : g("", !0),
1436
- b(i, {
1437
- icon: "list",
1438
- disabled: !N(M).outline.value.length,
1439
- onClick: l[10] ||= (e) => Ut("outline")
1440
- }, {
1441
- default: I(() => [y(j(N(T).pdfOutline), 1)]),
1442
- _: 1
1443
- }, 8, ["disabled"]),
1444
- b(i, {
1445
- icon: "rotate_right",
1446
- onClick: wt
1447
- }, {
1448
- default: I(() => [y(j(N(T).pdfRotate), 1)]),
1449
- _: 1
1450
- }),
1451
- o.downloadable ? (E(), h(i, {
1452
- key: 1,
1453
- icon: "download",
1454
- onClick: l[11] ||= (e) => N(M).download(o.fileName)
1455
- }, {
1456
- default: I(() => [y(j(N(T).pdfDownload), 1)]),
1457
- _: 1
1458
- })) : g("", !0),
1459
- o.downloadable ? (E(), h(i, {
1460
- key: 2,
1461
- icon: "print",
1462
- onClick: l[12] ||= (e) => N(M).print()
1463
- }, {
1464
- default: I(() => [y(j(N(T).pdfPrint), 1)]),
1465
- _: 1
1466
- })) : g("", !0),
1467
- b(i, {
1468
- icon: kn.value ? "fullscreen_exit" : "fullscreen",
1469
- onClick: An
1470
- }, {
1471
- default: I(() => [y(j(kn.value ? N(T).pdfExitFullscreen : N(T).pdfFullscreen), 1)]),
1472
- _: 1
1473
- }, 8, ["icon"])
1474
- ]),
1475
- _: 1
1476
- })
1477
- ], 64)) : g("", !0),
1478
- N(M).loading.value ? (E(), h(a, {
1479
- key: 1,
1480
- value: N(M).progress.value ? N(M).progress.value * 100 : void 0,
1481
- indeterminate: !N(M).progress.value,
1482
- class: "absolute inset-x-0 bottom-0"
1483
- }, null, 8, ["value", "indeterminate"])) : g("", !0)
1484
- ])) : g("", !0),
1485
- b(p, { name: "m3-pdf-drop" }, {
1486
- default: I(() => [Tt.value ? (E(), _("div", we, [v("div", Te, [
1487
- b(t, {
1488
- name: "search",
1489
- size: 20,
1490
- class: "text-on-surface-variant"
1491
- }),
1492
- L(v("input", {
1493
- "onUpdate:modelValue": l[13] ||= (e) => Et.value = e,
1494
- type: "search",
1495
- class: "min-w-0 flex-1 bg-transparent text-body-large outline-none placeholder:text-on-surface-variant",
1496
- placeholder: N(T).pdfSearch,
1497
- "aria-label": N(T).pdfSearch,
1498
- onKeydown: l[14] ||= se(ce((e) => Nt(Ot.value + (e.shiftKey ? -1 : 1)), ["prevent"]), ["enter"])
1499
- }, null, 40, Ee), [[oe, Et.value]]),
1500
- v("span", De, j(Vt.value), 1),
1501
- b(n, {
1502
- icon: "keyboard_arrow_up",
1503
- label: N(T).pdfSearchPrevious,
1504
- size: "xs",
1505
- disabled: !Dt.value.length,
1506
- onClick: l[15] ||= (e) => Nt(Ot.value - 1)
1507
- }, null, 8, ["label", "disabled"]),
1508
- b(n, {
1509
- icon: "keyboard_arrow_down",
1510
- label: N(T).pdfSearchNext,
1511
- size: "xs",
1512
- disabled: !Dt.value.length,
1513
- onClick: l[16] ||= (e) => Nt(Ot.value + 1)
1514
- }, null, 8, ["label", "disabled"])
1515
- ]), b(n, {
1516
- icon: "close",
1517
- label: N(T).close,
1518
- onClick: Bt
1519
- }, null, 8, ["label"])])) : g("", !0)]),
1520
- _: 1
1521
- }),
1522
- v("div", Oe, [
1523
- b(p, { name: "m3-pdf-fade" }, {
1524
- default: I(() => [Ht.value && H.value ? (E(), _("div", {
1525
- key: 0,
1526
- class: "absolute inset-0 z-20 bg-scrim/32",
1527
- onClick: l[17] ||= (e) => Ut(null)
1528
- })) : g("", !0)]),
1529
- _: 1
1530
- }),
1531
- b(p, { name: "m3-pdf-panel" }, {
1532
- default: I(() => [Ht.value && N(M).doc.value ? (E(), _("aside", {
1533
- key: 0,
1534
- class: C(["flex w-56 shrink-0 flex-col bg-surface-container", H.value ? "absolute inset-y-0 left-0 z-30 rounded-r-lg shadow-elevation-2" : "relative"])
1535
- }, [v("div", ke, [(E(), _(f, null, k(["thumbnails", "outline"], (e) => v("button", {
1536
- key: e,
1537
- type: "button",
1538
- class: C(["h-8 flex-1 cursor-pointer rounded-full text-label-large transition-colors", Ht.value === e ? "bg-secondary-container text-on-secondary-container" : "text-on-surface-variant hover:bg-on-surface/8"]),
1539
- disabled: e === "outline" && !N(M).outline.value.length,
1540
- onClick: (t) => Ut(e)
1541
- }, j(e === "thumbnails" ? N(T).pdfThumbnails : N(T).pdfOutline), 11, Ae)), 64))]), Ht.value === "thumbnails" ? (E(), _("div", {
1542
- key: 0,
1543
- ref_key: "thumbList",
1544
- ref: Gt,
1545
- class: "min-h-0 flex-1 overflow-y-auto px-3 pb-3"
1546
- }, [v("div", je, [(E(!0), _(f, null, k(N(M).numPages.value, (e) => (E(), _("button", {
1547
- key: e,
1548
- ref_for: !0,
1549
- ref: (t) => qt(t, e),
1550
- type: "button",
1551
- class: "group flex cursor-pointer flex-col items-center gap-1 outline-none",
1552
- "aria-label": `${N(T).pdfPage} ${e}`,
1553
- "aria-current": e === J.value ? "page" : void 0,
1554
- onClick: (t) => Jt(e)
1555
- }, [v("span", {
1556
- class: C(["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", e === J.value && "ring-3 ring-primary"]),
1557
- style: w({ aspectRatio: `${ue.value[e - 1]?.width ?? 3} / ${ue.value[e - 1]?.height ?? 4}` })
1558
- }, [Wt.get(e) ? (E(), _("img", {
1559
- key: 0,
1560
- src: Wt.get(e),
1561
- alt: "",
1562
- class: "h-full w-full object-contain",
1563
- style: w({ transform: W.value ? `rotate(${W.value}deg)` : void 0 })
1564
- }, null, 12, Ne)) : g("", !0)], 6), v("span", { class: C(["text-label-medium tabular-nums", e === J.value ? "text-primary" : "text-on-surface-variant"]) }, j(e), 3)], 8, Me))), 128))])], 512)) : (E(), _("nav", {
1565
- key: 1,
1566
- class: "min-h-0 flex-1 overflow-y-auto px-2 pb-3",
1567
- "aria-label": N(T).pdfOutline
1568
- }, [(E(!0), _(f, null, k(Xt.value, (e) => (E(), _("div", {
1569
- key: e.key,
1570
- class: "flex items-center",
1571
- style: w({ paddingLeft: `${e.depth * 12}px` })
1572
- }, [e.hasChildren ? (E(), _("button", {
1573
- key: 0,
1574
- type: "button",
1575
- class: "flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-on-surface-variant hover:bg-on-surface/8",
1576
- "aria-label": Yt.has(e.key) ? N(T).collapse : N(T).expand,
1577
- onClick: (t) => Zt(e.key)
1578
- }, [b(t, {
1579
- name: Yt.has(e.key) ? "expand_more" : "chevron_right",
1580
- size: 20
1581
- }, null, 8, ["name"])], 8, Fe)) : (E(), _("span", Ie)), (E(), h(ae(e.url ? "a" : "button"), {
1582
- href: e.url,
1583
- target: e.url ? "_blank" : void 0,
1584
- type: e.url ? void 0 : "button",
1585
- 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",
1586
- onClick: (t) => e.page && Jt(e.page, e.top)
1587
- }, {
1588
- default: I(() => [v("span", Le, j(e.title), 1), e.page ? (E(), _("span", Re, j(e.page), 1)) : g("", !0)]),
1589
- _: 2
1590
- }, 1032, [
1591
- "href",
1592
- "target",
1593
- "type",
1594
- "onClick"
1595
- ]))], 4))), 128))], 8, Pe))], 2)) : g("", !0)]),
1596
- _: 1
1597
- }),
1598
- v("div", ze, [
1599
- v("div", {
1600
- ref_key: "scroller",
1601
- ref: R,
1602
- class: C(["m3-pdf-scroller absolute inset-0 overflow-auto overscroll-contain bg-surface-container-highest outline-none", [$t.value === "select" ? "" : "m3-pdf-annotating", N(Tn) && "scrollbar-none"]]),
1603
- tabindex: "0",
1604
- onScroll: dt,
1605
- onDblclick: _t
1606
- }, [N(M).doc.value ? (E(), _("div", {
1607
- key: 0,
1608
- class: "relative mx-auto",
1609
- style: w({
1610
- width: `${K.value.width}px`,
1611
- height: `${K.value.height}px`
1612
- })
1613
- }, [(E(!0), _(f, null, k(K.value.boxes, (t, n) => (E(), _("div", {
1614
- key: n,
1615
- class: "absolute left-1/2 -translate-x-1/2",
1616
- style: w({
1617
- top: `${t.top}px`,
1618
- width: `${t.width}px`,
1619
- height: `${t.height}px`
1620
- })
1621
- }, [b(ge, {
1622
- ref_for: !0,
1623
- ref: (e) => Rt(n + 1, e),
1624
- pdf: N(M),
1625
- page: n + 1,
1626
- scale: G.value,
1627
- rotation: W.value,
1628
- active: st.value.has(n + 1),
1629
- hits: Ft.value.get(n + 1) ?? It,
1630
- annotations: sn.value.get(n + 1) ?? cn,
1631
- tool: $t.value,
1632
- color: tn.value,
1633
- "ink-width": nn.value,
1634
- "selected-id": Z.value?.id ?? null,
1635
- class: "h-full w-full",
1636
- onLink: Qt,
1637
- onAdd: pn,
1638
- onErase: mn,
1639
- onEraseStart: hn,
1640
- onEraseAt: (e) => gn(n + 1, e),
1641
- onSelect: yn,
1642
- onTextSelection: Sn
1643
- }, null, 8, [
1644
- "pdf",
1645
- "page",
1646
- "scale",
1647
- "rotation",
1648
- "active",
1649
- "hits",
1650
- "annotations",
1651
- "tool",
1652
- "color",
1653
- "ink-width",
1654
- "selected-id",
1655
- "onEraseAt"
1656
- ]), ie(e.$slots, "page", {
1657
- page: n + 1,
1658
- width: t.width,
1659
- height: t.height,
1660
- scale: G.value,
1661
- rotation: W.value,
1662
- size: N(M).pageSizes.value[n]
1663
- })], 4))), 128))], 4)) : N(M).needsPassword.value ? (E(), _("div", Be, [v("form", {
1664
- 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",
1665
- onSubmit: ce(In, ["prevent"])
1666
- }, [
1667
- b(t, {
1668
- name: "lock",
1669
- size: 32,
1670
- class: "text-primary"
1671
- }),
1672
- v("p", Ve, j(N(T).pdfPassword), 1),
1673
- b(s, {
1674
- modelValue: Fn.value,
1675
- "onUpdate:modelValue": l[18] ||= (e) => Fn.value = e,
1676
- type: "password",
1677
- label: N(T).pdfPasswordLabel,
1678
- error: N(M).wrongPassword.value,
1679
- "error-label": N(M).wrongPassword.value ? N(T).pdfWrongPassword : void 0,
1680
- autocomplete: "off",
1681
- class: "w-full"
1682
- }, null, 8, [
1683
- "modelValue",
1684
- "label",
1685
- "error",
1686
- "error-label"
1687
- ]),
1688
- b(c, {
1689
- type: "submit",
1690
- disabled: !Fn.value,
1691
- class: "self-end"
1692
- }, {
1693
- default: I(() => [y(j(N(T).pdfOpen), 1)]),
1694
- _: 1
1695
- }, 8, ["disabled"])
1696
- ], 32)])) : N(M).error.value ? (E(), _("div", He, [
1697
- b(t, {
1698
- name: "error",
1699
- size: 32,
1700
- class: "text-error"
1701
- }),
1702
- v("p", Ue, j(N(T).pdfError), 1),
1703
- v("p", We, j(N(M).error.value.message), 1)
1704
- ])) : N(M).loading.value ? (E(), _("div", Ge, [b(u, { label: N(T).pdfLoading }, null, 8, ["label"])])) : (E(), _("div", Ke, [ie(e.$slots, "empty")]))], 34),
1705
- b(p, { name: "m3-pdf-fade" }, {
1706
- default: I(() => [N(M).doc.value && (lt.value || Dn.value) && N(M).numPages.value > 1 ? (E(), _("div", qe, [v("div", {
1707
- class: "absolute right-1 flex items-center gap-2",
1708
- style: w({ top: `${N(Tn) ? En.value : Math.min(B.value - 40, Math.max(8, En.value))}px` })
1709
- }, [v("span", Je, j(J.value) + " / " + j(N(M).numPages.value), 1), N(Tn) ? (E(), _("span", {
1710
- key: 0,
1711
- class: "pointer-events-auto flex h-12 w-6 touch-none items-center justify-center",
1712
- onPointerdown: On
1713
- }, [...l[23] ||= [v("span", { class: "h-12 w-1.5 rounded-full bg-on-surface-variant" }, null, -1)]], 32)) : (E(), _("span", Ye))], 4)])) : g("", !0)]),
1714
- _: 1
1715
- }),
1716
- b(p, { name: "m3-pdf-fade" }, {
1717
- default: I(() => [o.annotate && N(M).doc.value && !rn.value ? (E(), _("button", {
1718
- key: 0,
1719
- type: "button",
1720
- 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",
1721
- "aria-label": N(T).pdfAnnotate,
1722
- onClick: an
1723
- }, [b(t, {
1724
- name: "edit",
1725
- size: 24
1726
- })], 8, Xe)) : g("", !0)]),
1727
- _: 1
1728
- }),
1729
- b(p, { name: "m3-pdf-rise" }, {
1730
- default: I(() => [o.annotate && rn.value ? (E(), _("div", Ze, [v("div", {
1731
- 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",
1732
- role: "toolbar",
1733
- "aria-label": N(T).pdfAnnotate
1734
- }, [
1735
- (E(!0), _(f, null, k(Rn.value, (e) => (E(), h(n, {
1736
- key: e.id,
1737
- icon: e.icon,
1738
- label: e.label,
1739
- checked: $t.value === e.id,
1740
- variant: "standard",
1741
- "onUpdate:checked": (t) => en(e.id)
1742
- }, null, 8, [
1743
- "icon",
1744
- "label",
1745
- "checked",
1746
- "onUpdate:checked"
1747
- ]))), 128)),
1748
- l[25] ||= v("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1),
1749
- (E(!0), _(f, null, k(o.colors, (e) => (E(), _("button", {
1750
- key: e,
1751
- type: "button",
1752
- class: "flex size-10 shrink-0 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary",
1753
- "aria-label": `${N(T).pdfColor} ${e}`,
1754
- "aria-pressed": tn.value === e,
1755
- onClick: (t) => tn.value = e
1756
- }, [v("span", {
1757
- class: C(["rounded-full border border-outline-variant transition-[width,height] duration-150", tn.value === e ? "size-[30px] ring-2 ring-on-surface ring-offset-2 ring-offset-surface-container-high" : "size-6"]),
1758
- style: w({ backgroundColor: e })
1759
- }, null, 6)], 8, $e))), 128)),
1760
- $t.value === "ink" && o.inkWidths.length > 1 ? (E(), _(f, { key: 0 }, [l[24] ||= v("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1), (E(!0), _(f, null, k(o.inkWidths, (e) => (E(), _("button", {
1761
- key: e,
1762
- type: "button",
1763
- class: C(["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", nn.value === e && "bg-secondary-container"]),
1764
- "aria-label": N(T).pdfInkWidth.replace("{n}", String(e)),
1765
- "aria-pressed": nn.value === e,
1766
- onClick: (t) => nn.value = e
1767
- }, [v("span", {
1768
- class: "rounded-full",
1769
- style: w({
1770
- width: `${Math.min(22, 3 + e * 2)}px`,
1771
- height: `${Math.min(22, 3 + e * 2)}px`,
1772
- backgroundColor: tn.value
1773
- })
1774
- }, null, 4)], 10, et))), 128))], 64)) : g("", !0),
1775
- l[26] ||= v("span", { class: "mx-1 h-6 w-px shrink-0 bg-outline-variant" }, null, -1),
1776
- b(n, {
1777
- icon: "undo",
1778
- label: N(T).pdfUndo,
1779
- disabled: !dn.value,
1780
- onClick: fn
1781
- }, null, 8, ["label", "disabled"]),
1782
- b(n, {
1783
- icon: "close",
1784
- label: N(T).close,
1785
- onClick: on
1786
- }, null, 8, ["label"])
1787
- ], 8, Qe)])) : g("", !0)]),
1788
- _: 1
1789
- })
1790
- ])
1791
- ]),
1792
- $.value ? (E(), _("div", {
1793
- key: 1,
1794
- class: "absolute z-40 flex justify-center",
1795
- style: w(xn.value)
1796
- }, [v("div", tt, [b(c, {
1797
- variant: "text",
1798
- icon: "content_copy",
1799
- size: "sm",
1800
- onClick: wn
1801
- }, {
1802
- default: I(() => [y(j(N(T).pdfCopy), 1)]),
1803
- _: 1
1804
- }), b(c, {
1805
- variant: "text",
1806
- icon: "ink_highlighter",
1807
- size: "sm",
1808
- onClick: Cn
1809
- }, {
1810
- default: I(() => [y(j(N(T).pdfHighlight), 1)]),
1811
- _: 1
1812
- })])], 4)) : g("", !0),
1813
- Z.value && Q.value ? (E(), _("div", {
1814
- key: 2,
1815
- class: "absolute z-40",
1816
- style: w(xn.value),
1817
- onKeydown: l[22] ||= ce((e) => e.key === "Escape" && (Z.value = null), ["stop"])
1818
- }, [v("div", nt, [
1819
- Q.value.quote ? (E(), _("p", {
1820
- key: 0,
1821
- class: "line-clamp-3 border-l-4 pl-2 text-body-medium text-on-surface-variant",
1822
- style: w({ borderColor: Q.value.color })
1823
- }, j(Q.value.quote), 5)) : g("", !0),
1824
- b(s, {
1825
- "model-value": Q.value.text ?? "",
1826
- label: Q.value.type === "note" ? N(T).pdfNotePlaceholder : N(T).pdfAddComment,
1827
- multiline: "",
1828
- "auto-grow": "",
1829
- rows: 2,
1830
- "max-rows": 6,
1831
- variant: "outlined",
1832
- "field-bg": "var(--color-surface-container-high)",
1833
- "onUpdate:modelValue": l[19] ||= (e) => _n(Q.value.id, { text: String(e) })
1834
- }, null, 8, ["model-value", "label"]),
1835
- v("div", rt, [
1836
- (E(!0), _(f, null, k(o.colors, (e) => (E(), _("button", {
1837
- key: e,
1838
- type: "button",
1839
- class: "flex size-8 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary",
1840
- "aria-label": `${N(T).pdfColor} ${e}`,
1841
- "aria-pressed": Q.value.color === e,
1842
- onClick: (t) => _n(Q.value.id, { color: e })
1843
- }, [v("span", {
1844
- class: C(["size-5 rounded-full border border-outline-variant", Q.value.color === e && "ring-2 ring-on-surface ring-offset-1 ring-offset-surface-container-high"]),
1845
- style: w({ backgroundColor: e })
1846
- }, null, 6)], 8, it))), 128)),
1847
- l[27] ||= v("span", { class: "flex-1" }, null, -1),
1848
- b(n, {
1849
- icon: "delete",
1850
- label: N(T).pdfDelete,
1851
- size: "xs",
1852
- onClick: l[20] ||= (e) => mn(Q.value.id)
1853
- }, null, 8, ["label"]),
1854
- b(n, {
1855
- icon: "check",
1856
- label: N(T).close,
1857
- size: "xs",
1858
- onClick: l[21] ||= (e) => Z.value = null
1859
- }, null, 8, ["label"])
1860
- ])
1861
- ])], 36)) : g("", !0)
1862
- ], 16, _e));
1863
- }
1864
- }), st = (e) => (e.required ?? (e.type === "signature" || e.type === "initials")) && !e.value;
1865
- function ct(e, t, n) {
1866
- let r = (n % 360 + 360) % 360, i = e.x, a = e.y + e.height, o, s;
1867
- return r === 90 ? (o = a, s = i) : r === 180 ? (o = t.width - i, s = a) : r === 270 ? (o = t.width - a, s = t.height - i) : (o = i, s = t.height - a), {
1868
- x: t.x + o,
1869
- y: t.y + s,
1870
- rotate: r
1871
- };
1872
- }
1873
- async function lt(e, t, n, r) {
1874
- if (!e.value) return null;
1875
- if ((e.type === "signature" || e.type === "initials") && e.value.startsWith("data:image/png")) return ut(e.value);
1876
- let i = document.createElement("canvas");
1877
- i.width = Math.max(1, Math.round(t * 4)), i.height = Math.max(1, Math.round(n * 4));
1878
- let a = i.getContext("2d");
1879
- if (!a) return null;
1880
- if (a.fillStyle = "#111", a.textBaseline = "middle", e.type === "checkbox") {
1881
- if (e.value !== "true") return null;
1882
- let t = Math.min(i.width, i.height);
1883
- a.lineWidth = t * .12, a.lineCap = "round", a.lineJoin = "round", a.strokeStyle = "#111", a.beginPath(), a.moveTo(t * .2, t * .55), a.lineTo(t * .42, t * .76), a.lineTo(t * .82, t * .26), a.stroke();
1884
- } else {
1885
- let t = i.height * .62;
1886
- for (a.font = `${t}px ${r}`; t > 6 && a.measureText(e.value).width > i.width * .96;) t *= .92, a.font = `${t}px ${r}`;
1887
- a.fillText(e.value, i.width * .02, i.height / 2);
1888
- }
1889
- let o = await new Promise((e) => i.toBlob(e, "image/png"));
1890
- return o ? new Uint8Array(await o.arrayBuffer()) : null;
1891
- }
1892
- function ut(e) {
1893
- let t = e.slice(e.indexOf(",") + 1), n = atob(t), r = new Uint8Array(n.length);
1894
- for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
1895
- return r;
1896
- }
1897
- async function dt(e, t, n = {}) {
1898
- let { PDFDocument: r, degrees: i } = await import("pdf-lib"), a = await r.load(e), o = a.getPages(), s = n.font ?? "system-ui, sans-serif";
1899
- for (let e of t) {
1900
- let t = o[e.page - 1];
1901
- if (!t || !e.value) continue;
1902
- let n = t.getCropBox(), r = t.getRotation().angle, c = (r % 180 + 180) % 180 != 0, l = c ? n.height : n.width, u = c ? n.width : n.height, d = {
1903
- x: e.x * l,
1904
- y: e.y * u,
1905
- width: e.width * l,
1906
- height: e.height * u
1907
- }, f = await lt(e, d.width, d.height, s);
1908
- if (!f) continue;
1909
- let p = await a.embedPng(f), { width: m, height: h } = d, g = 0, _ = 0;
1910
- if (e.type === "signature" || e.type === "initials") {
1911
- let e = Math.min(d.width / p.width, d.height / p.height);
1912
- m = p.width * e, h = p.height * e, g = (d.width - m) / 2, _ = (d.height - h) / 2;
1913
- }
1914
- let v = ct({
1915
- x: d.x + g,
1916
- y: d.y + _,
1917
- width: m,
1918
- height: h
1919
- }, {
1920
- x: n.x,
1921
- y: n.y,
1922
- width: n.width,
1923
- height: n.height
1924
- }, r);
1925
- t.drawImage(p, {
1926
- x: v.x,
1927
- y: v.y,
1928
- width: m,
1929
- height: h,
1930
- rotate: i(v.rotate)
1931
- });
1932
- }
1933
- return n.producer && a.setProducer(n.producer), a.setModificationDate(/* @__PURE__ */ new Date()), a.save();
1934
- }
1935
- // src/components/MPdfSigner.vue?vue&type=script&setup=true&lang.ts
1936
- var ft = { class: "flex shrink-0 flex-wrap items-center gap-2 border-b border-outline-variant bg-surface-container px-3 py-2" }, X = {
1937
- class: "text-body-medium text-on-surface",
1938
- "aria-live": "polite"
1939
- }, pt = { class: "mr-1 text-label-large text-on-surface-variant" }, mt = { class: "pointer-events-none absolute inset-0" }, ht = [
1940
- "id",
1941
- "data-field",
1942
- "data-type",
1943
- "tabindex",
1944
- "aria-label",
1945
- "onClick",
1946
- "onPointerdown",
1947
- "onKeydown"
1948
- ], gt = ["src"], _t = {
1949
- key: 3,
1950
- class: "flex min-w-0 items-center gap-1 truncate px-1 text-label-medium"
1951
- }, vt = { class: "truncate" }, yt = ["onPointerdown"], bt = {
1952
- key: 0,
1953
- class: "flex flex-col gap-4"
1954
- }, xt = "\"Segoe Script\", \"Brush Script MT\", \"Snell Roundhand\", \"URW Chancery L\", cursive", St = /* @__PURE__ */ x({
1955
- inheritAttrs: !1,
1956
- __name: "MPdfSigner",
1957
- props: {
1958
- src: { default: null },
1959
- fields: { default: () => [] },
1960
- mode: { default: "sign" },
1961
- signer: {},
1962
- signerName: {},
1963
- dateFormat: { default: () => ({ dateStyle: "medium" }) },
1964
- types: { default: () => [
1965
- "signature",
1966
- "initials",
1967
- "name",
1968
- "date",
1969
- "text",
1970
- "checkbox"
1971
- ] },
1972
- workerSrc: {}
1973
- },
1974
- emits: [
1975
- "update:fields",
1976
- "complete",
1977
- "finish",
1978
- "loaded"
1979
- ],
1980
- setup(r, { expose: i, emit: a }) {
1981
- let u = r, p = a, x = e(), S = P(), ne = O(), re = {
1982
- signature: {
1983
- icon: "signature",
1984
- key: "pdfSignSignature",
1985
- w: .3,
1986
- h: .06
1987
- },
1988
- initials: {
1989
- icon: "draw",
1990
- key: "pdfSignInitials",
1991
- w: .1,
1992
- h: .05
1993
- },
1994
- name: {
1995
- icon: "badge",
1996
- key: "pdfSignName",
1997
- w: .3,
1998
- h: .035
1999
- },
2000
- date: {
2001
- icon: "calendar_today",
2002
- key: "pdfSignDate",
2003
- w: .2,
2004
- h: .035
2005
- },
2006
- text: {
2007
- icon: "text_fields",
2008
- key: "pdfSignText",
2009
- w: .3,
2010
- h: .035
2011
- },
2012
- checkbox: {
2013
- icon: "check_box",
2014
- key: "pdfSignCheckbox",
2015
- w: .03,
2016
- h: .022
2017
- }
2018
- }, T = (e) => x[re[e].key], D = (e) => !u.signer || !e.signer || e.signer === u.signer, ie = m(() => {
2019
- let e = /* @__PURE__ */ new Map();
2020
- for (let t of u.fields) e.set(t.page, [...e.get(t.page) ?? [], t]);
2021
- return e;
2022
- }), ae = m(() => u.fields.filter((e) => D(e) && (e.required ?? (e.type === "signature" || e.type === "initials")))), A = m(() => ae.value.filter((e) => !st(e)).length), M = m(() => A.value === ae.value.length);
2023
- F(M, (e, t) => {
2024
- e && !t && u.mode === "sign" && p("complete");
2025
- });
2026
- let oe = m(() => x.pdfSignProgress.replace("{done}", String(A.value)).replace("{total}", String(ae.value.length)));
2027
- function L(e, t) {
2028
- p("update:fields", u.fields.map((n) => n.id === e ? {
2029
- ...n,
2030
- ...t
2031
- } : n));
2032
- }
2033
- let R = O({}), z = O(null), B = O(), V = O(!0), H = O(), U = O(400);
2034
- F(() => z.value?.tab, () => te(() => {
2035
- H.value?.clientWidth && (U.value = H.value.clientWidth - 2);
2036
- }));
2037
- function le() {
2038
- return new Intl.DateTimeFormat(void 0, u.dateFormat).format(/* @__PURE__ */ new Date());
2039
- }
2040
- function W(e, t = !1) {
2041
- if (u.mode !== "sign" || !D(e)) return;
2042
- if (e.type === "checkbox") return L(e.id, { value: e.value === "true" ? void 0 : "true" });
2043
- if (e.type === "date" && !e.value) return L(e.id, { value: le() });
2044
- if (e.type === "name" && !e.value && u.signerName) return L(e.id, { value: u.signerName });
2045
- if ((e.type === "signature" || e.type === "initials") && !t) {
2046
- let t = R.value[e.type];
2047
- if (t && !e.value) return L(e.id, { value: t });
2048
- }
2049
- let n = e.type === "initials" ? ue(u.signerName ?? "") : u.signerName ?? "";
2050
- z.value = {
2051
- field: e,
2052
- tab: e.type === "signature" || e.type === "initials" ? "draw" : "type",
2053
- text: e.type === "signature" || e.type === "initials" ? n : e.value ?? (e.type === "name" ? n : "")
2054
- }, V.value = !0;
2055
- }
2056
- let ue = (e) => e.split(/\s+/).filter(Boolean).map((e) => e[0].toUpperCase()).join("");
2057
- function de(e) {
2058
- let t = document.createElement("canvas"), n = t.getContext("2d");
2059
- return n ? (n.font = `96px ${xt}`, t.width = Math.ceil(n.measureText(e).width) + 40, t.height = 96 * 1.6, n.font = `96px ${xt}`, n.fillStyle = "#1a237e", n.textBaseline = "middle", n.fillText(e, 20, t.height / 2), t.toDataURL("image/png")) : "";
2060
- }
2061
- let fe = m(() => z.value?.field.type === "signature" || z.value?.field.type === "initials"), pe = m(() => {
2062
- let e = z.value;
2063
- return e ? fe.value && e.tab === "draw" ? !V.value : e.text.trim() !== "" : !1;
2064
- });
2065
- async function G() {
2066
- let e = z.value;
2067
- if (!e || !pe.value) return;
2068
- let t;
2069
- fe.value ? (t = e.tab === "draw" ? await me(B.value?.toDataURL() ?? "") : de(e.text.trim()), R.value = {
2070
- ...R.value,
2071
- [e.field.type]: t
2072
- }) : t = e.text.trim(), L(e.field.id, { value: t }), z.value = null;
2073
- }
2074
- async function me(e) {
2075
- if (!e || typeof document > "u") return e;
2076
- let t = new Image();
2077
- t.src = e;
2078
- try {
2079
- await t.decode();
2080
- } catch {
2081
- return e;
2082
- }
2083
- if (!t.width) return e;
2084
- let n = document.createElement("canvas");
2085
- n.width = t.width, n.height = t.height;
2086
- let r = n.getContext("2d");
2087
- if (!r) return e;
2088
- r.drawImage(t, 0, 0);
2089
- let { data: i, width: a, height: o } = r.getImageData(0, 0, n.width, n.height), s = a, c = o, l = -1, u = -1;
2090
- for (let e = 0; e < o; e++) for (let t = 0; t < a; t++) i[(e * a + t) * 4 + 3] > 8 && (s = Math.min(s, t), l = Math.max(l, t), c = Math.min(c, e), u = Math.max(u, e));
2091
- if (l < 0) return e;
2092
- s = Math.max(0, s - 8), c = Math.max(0, c - 8), l = Math.min(a - 1, l + 8), u = Math.min(o - 1, u + 8);
2093
- let d = document.createElement("canvas");
2094
- return d.width = l - s + 1, d.height = u - c + 1, d.getContext("2d")?.drawImage(n, s, c, d.width, d.height, 0, 0, d.width, d.height), d.toDataURL("image/png");
2095
- }
2096
- function K() {
2097
- let e = ae.value, t = e.find((e) => st(e)) ?? e[0];
2098
- if (!t) return;
2099
- let n = document.getElementById(he(t));
2100
- n?.scrollIntoView({
2101
- behavior: "smooth",
2102
- block: "center"
2103
- }), n?.focus({ preventScroll: !0 });
2104
- }
2105
- let he = (e) => `${S}-f-${e.id}`, q = O(null), J = 0;
2106
- function ge(e) {
2107
- let t = re[e], n = Ce.value, r = `${e}-${Date.now().toString(36)}-${++J}`, i = {
2108
- id: r,
2109
- type: e,
2110
- page: n,
2111
- x: .5 - t.w / 2,
2112
- y: .45,
2113
- width: t.w,
2114
- height: t.h,
2115
- label: T(e)
2116
- };
2117
- (e === "signature" || e === "initials") && (i.required = !0), p("update:fields", [...u.fields, i]), q.value = r;
2118
- }
2119
- function _e(e) {
2120
- p("update:fields", u.fields.filter((t) => t.id !== e)), q.value === e && (q.value = null);
2121
- }
2122
- let Y = null;
2123
- function ve(e, t, n, r) {
2124
- u.mode === "prepare" && e.button === 0 && (e.preventDefault(), e.stopPropagation(), q.value = t.id, Y = {
2125
- id: t.id,
2126
- kind: n,
2127
- x: e.clientX,
2128
- y: e.clientY,
2129
- start: { ...t },
2130
- w: r.width,
2131
- h: r.height
2132
- }, e.currentTarget.setPointerCapture?.(e.pointerId));
2133
- }
2134
- function ye(e) {
2135
- if (!Y) return;
2136
- let t = (e.clientX - Y.x) / Y.w, n = (e.clientY - Y.y) / Y.h, r = Y.start;
2137
- Y.kind === "move" ? L(Y.id, {
2138
- x: xe(r.x + t, 0, 1 - r.width),
2139
- y: xe(r.y + n, 0, 1 - r.height)
2140
- }) : L(Y.id, {
2141
- width: xe(r.width + t, .02, 1 - r.x),
2142
- height: xe(r.height + n, .015, 1 - r.y)
2143
- });
2144
- }
2145
- function be() {
2146
- Y = null;
2147
- }
2148
- let xe = (e, t, n) => Math.min(Math.max(e, t), n);
2149
- function Se(e, t) {
2150
- if (u.mode === "sign") {
2151
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), W(t));
2152
- return;
2153
- }
2154
- let n = e.shiftKey ? .02 : .005, r = {
2155
- ArrowLeft: [-n, 0],
2156
- ArrowRight: [n, 0],
2157
- ArrowUp: [0, -n],
2158
- ArrowDown: [0, n]
2159
- };
2160
- if (r[e.key]) {
2161
- e.preventDefault();
2162
- let [n, i] = r[e.key];
2163
- L(t.id, {
2164
- x: xe(t.x + n, 0, 1 - t.width),
2165
- y: xe(t.y + i, 0, 1 - t.height)
2166
- });
2167
- } else (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), _e(t.id));
2168
- }
2169
- let Ce = O(1);
2170
- function we(e) {
2171
- let t = e.rotation, n = t % 180 != 0, r = n ? e.height : e.width, i = n ? e.width : e.height, a = t === 90 ? "rotate(90deg) translateY(-100%)" : t === 180 ? "rotate(180deg) translate(-100%, -100%)" : t === 270 ? "rotate(270deg) translateX(-100%)" : void 0;
2172
- return {
2173
- width: `${r}px`,
2174
- height: `${i}px`,
2175
- transform: a,
2176
- transformOrigin: "top left"
2177
- };
2178
- }
2179
- let Te = (e) => ({
2180
- left: `${e.x * 100}%`,
2181
- top: `${e.y * 100}%`,
2182
- width: `${e.width * 100}%`,
2183
- height: `${e.height * 100}%`
2184
- });
2185
- async function Ee(e) {
2186
- if (e instanceof Uint8Array || e instanceof ArrayBuffer) return e;
2187
- if (typeof Blob < "u" && e instanceof Blob) return e.arrayBuffer();
2188
- let t = await fetch(String(e));
2189
- if (!t.ok) throw Error(`PDF ${t.status}`);
2190
- return t.arrayBuffer();
2191
- }
2192
- async function De(e) {
2193
- if (!u.src) throw Error("No PDF");
2194
- return dt(await Ee(u.src), u.fields, e);
2195
- }
2196
- return i({
2197
- save: De,
2198
- next: K,
2199
- complete: M,
2200
- viewer: ne
2201
- }), (e, i) => (E(), _("div", ee({ class: "m3-pdf-signer" }, e.$attrs), [
2202
- v("div", ft, [r.mode === "sign" ? (E(), _(f, { key: 0 }, [
2203
- b(t, {
2204
- name: M.value ? "task_alt" : "edit_document",
2205
- size: 20,
2206
- class: C(M.value ? "text-primary" : "text-on-surface-variant")
2207
- }, null, 8, ["name", "class"]),
2208
- v("span", X, j(M.value ? N(x).pdfSignComplete : oe.value), 1),
2209
- i[12] ||= v("span", { class: "flex-1" }, null, -1),
2210
- M.value ? g("", !0) : (E(), h(c, {
2211
- key: 0,
2212
- variant: "tonal",
2213
- icon: "arrow_downward",
2214
- onClick: K
2215
- }, {
2216
- default: I(() => [y(j(N(x).pdfSignNext), 1)]),
2217
- _: 1
2218
- })),
2219
- b(c, {
2220
- disabled: !M.value,
2221
- icon: "check",
2222
- onClick: i[0] ||= (e) => p("finish")
2223
- }, {
2224
- default: I(() => [y(j(N(x).pdfSignFinish), 1)]),
2225
- _: 1
2226
- }, 8, ["disabled"])
2227
- ], 64)) : (E(), _(f, { key: 1 }, [v("span", pt, j(N(x).pdfSignAddField), 1), (E(!0), _(f, null, k(r.types, (e) => (E(), h(c, {
2228
- key: e,
2229
- variant: "tonal",
2230
- size: "sm",
2231
- icon: re[e].icon,
2232
- "data-add": e,
2233
- onClick: (t) => ge(e)
2234
- }, {
2235
- default: I(() => [y(j(T(e)), 1)]),
2236
- _: 2
2237
- }, 1032, [
2238
- "icon",
2239
- "data-add",
2240
- "onClick"
2241
- ]))), 128))], 64))]),
2242
- b(ot, {
2243
- ref_key: "viewer",
2244
- ref: ne,
2245
- src: r.src,
2246
- "worker-src": r.workerSrc,
2247
- class: "min-h-0 flex-1",
2248
- "onUpdate:page": i[2] ||= (e) => Ce.value = e,
2249
- onLoaded: i[3] ||= (e) => p("loaded", e)
2250
- }, {
2251
- page: I((e) => [v("div", mt, [v("div", {
2252
- class: "absolute left-0 top-0",
2253
- style: w(we(e))
2254
- }, [(E(!0), _(f, null, k(ie.value.get(e.page) ?? [], (a) => (E(), _("div", {
2255
- id: he(a),
2256
- key: a.id,
2257
- class: C(["m3-pdf-sign-field pointer-events-auto absolute flex items-center justify-center rounded-xs outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", [
2258
- r.mode === "prepare" ? "cursor-move" : D(a) ? "cursor-pointer" : "cursor-default opacity-40",
2259
- a.value ? "m3-pdf-sign-filled" : "m3-pdf-sign-empty",
2260
- r.mode === "sign" && D(a) && N(st)(a) ? "m3-pdf-sign-todo" : "",
2261
- q.value === a.id && r.mode === "prepare" ? "m3-pdf-sign-selected" : ""
2262
- ]]),
2263
- style: w(Te(a)),
2264
- "data-field": a.id,
2265
- "data-type": a.type,
2266
- role: "button",
2267
- tabindex: r.mode === "prepare" || D(a) ? 0 : -1,
2268
- "aria-label": `${a.label ?? T(a.type)}${a.value ? "" : a.required ?? (a.type === "signature" || a.type === "initials") ? ` (${N(x).pdfSignRequired})` : ""}`,
2269
- onClick: (e) => r.mode === "sign" ? W(a, !!a.value) : q.value = a.id,
2270
- onPointerdown: (t) => ve(t, a, "move", {
2271
- width: e.rotation % 180 ? e.height : e.width,
2272
- height: e.rotation % 180 ? e.width : e.height
2273
- }),
2274
- onPointermove: ye,
2275
- onPointerup: be,
2276
- onPointercancel: be,
2277
- onKeydown: (e) => Se(e, a)
2278
- }, [a.value && (a.type === "signature" || a.type === "initials") ? (E(), _("img", {
2279
- key: 0,
2280
- src: a.value,
2281
- alt: "",
2282
- class: "h-full w-full object-contain",
2283
- draggable: "false"
2284
- }, null, 8, gt)) : a.type === "checkbox" && a.value === "true" ? (E(), h(t, {
2285
- key: 1,
2286
- name: "check",
2287
- class: "text-on-surface",
2288
- size: Math.max(12, e.height * a.height * .9)
2289
- }, null, 8, ["size"])) : a.value ? (E(), _("span", {
2290
- key: 2,
2291
- class: "m3-pdf-sign-text w-full truncate px-1 text-left",
2292
- style: w({ fontSize: `${Math.max(8, e.height * a.height * .6)}px` })
2293
- }, j(a.value), 5)) : a.type === "checkbox" ? g("", !0) : (E(), _("span", _t, [b(t, {
2294
- name: re[a.type].icon,
2295
- size: 16
2296
- }, null, 8, ["name"]), v("span", vt, j(a.type === "signature" && r.mode === "sign" ? N(x).pdfSignHere : a.label ?? T(a.type)), 1)])), r.mode === "prepare" && q.value === a.id ? (E(), _(f, { key: 4 }, [v("span", {
2297
- class: "absolute -right-1.5 -bottom-1.5 h-3 w-3 cursor-nwse-resize rounded-full border-2 border-surface bg-primary touch-none",
2298
- "aria-hidden": "true",
2299
- onPointerdown: (t) => ve(t, a, "resize", {
2300
- width: e.rotation % 180 ? e.height : e.width,
2301
- height: e.rotation % 180 ? e.width : e.height
2302
- })
2303
- }, null, 40, yt), v("div", {
2304
- class: "absolute -top-11 left-0 flex items-center gap-1 rounded-full bg-surface-container-high px-1 shadow-elevation-2",
2305
- onPointerdown: i[1] ||= ce(() => {}, ["stop"])
2306
- }, [b(c, {
2307
- variant: a.required ?? (a.type === "signature" || a.type === "initials") ? "filled" : "text",
2308
- size: "xs",
2309
- onClick: ce((e) => L(a.id, { required: !(a.required ?? (a.type === "signature" || a.type === "initials")) }), ["stop"])
2310
- }, {
2311
- default: I(() => [y(j(N(x).pdfSignRequired), 1)]),
2312
- _: 1
2313
- }, 8, ["variant", "onClick"]), b(n, {
2314
- icon: "delete",
2315
- size: "xs",
2316
- label: N(x).pdfSignDelete,
2317
- onClick: ce((e) => _e(a.id), ["stop"])
2318
- }, null, 8, ["label", "onClick"])], 32)], 64)) : g("", !0)], 46, ht))), 128))], 4)])]),
2319
- _: 1
2320
- }, 8, ["src", "worker-src"]),
2321
- b(l, {
2322
- "model-value": !!z.value,
2323
- title: z.value ? z.value.field.label ?? T(z.value.field.type) : "",
2324
- "max-width": "560px",
2325
- "onUpdate:modelValue": i[11] ||= (e) => {
2326
- e || (z.value = null);
2327
- }
2328
- }, {
2329
- actions: I(() => [b(c, {
2330
- variant: "text",
2331
- onClick: i[10] ||= (e) => z.value = null
2332
- }, {
2333
- default: I(() => [y(j(N(x).cancel), 1)]),
2334
- _: 1
2335
- }), b(c, {
2336
- disabled: !pe.value,
2337
- onClick: G
2338
- }, {
2339
- default: I(() => [y(j(fe.value ? N(x).pdfSignAdopt : N(x).ok), 1)]),
2340
- _: 1
2341
- }, 8, ["disabled"])]),
2342
- default: I(() => [z.value ? (E(), _("div", bt, [fe.value ? (E(), _(f, { key: 0 }, [b(d, {
2343
- modelValue: z.value.tab,
2344
- "onUpdate:modelValue": i[4] ||= (e) => z.value.tab = e,
2345
- options: [{
2346
- value: "draw",
2347
- label: N(x).pdfSignDraw,
2348
- icon: "draw"
2349
- }, {
2350
- value: "type",
2351
- label: N(x).pdfSignTypeIt,
2352
- icon: "keyboard"
2353
- }],
2354
- density: "compact"
2355
- }, null, 8, ["modelValue", "options"]), z.value.tab === "draw" ? (E(), _("div", {
2356
- key: 0,
2357
- ref_key: "padBox",
2358
- ref: H,
2359
- class: "flex flex-col gap-2"
2360
- }, [(E(), h(o, {
2361
- ref_key: "pad",
2362
- ref: B,
2363
- key: U.value,
2364
- width: U.value,
2365
- height: 180,
2366
- onEnd: i[5] ||= (e) => V.value = !1,
2367
- onChange: i[6] ||= (e) => V.value = !!B.value?.isEmpty()
2368
- }, null, 8, ["width"])), b(c, {
2369
- variant: "text",
2370
- icon: "ink_eraser",
2371
- class: "self-start",
2372
- onClick: i[7] ||= (e) => {
2373
- B.value?.clear(), V.value = !0;
2374
- }
2375
- }, {
2376
- default: I(() => [y(j(N(x).clear), 1)]),
2377
- _: 1
2378
- })], 512)) : (E(), _(f, { key: 1 }, [b(s, {
2379
- modelValue: z.value.text,
2380
- "onUpdate:modelValue": i[8] ||= (e) => z.value.text = e,
2381
- label: T(z.value.field.type),
2382
- autocomplete: "name"
2383
- }, null, 8, ["modelValue", "label"]), v("div", {
2384
- class: "flex h-24 items-center overflow-hidden rounded-lg bg-surface-container-highest px-4 text-[2.5rem] text-[#1a237e] dark:text-[#c5cae9]",
2385
- style: w({ fontFamily: xt })
2386
- }, j(z.value.text), 5)], 64))], 64)) : (E(), h(s, {
2387
- key: 1,
2388
- modelValue: z.value.text,
2389
- "onUpdate:modelValue": i[9] ||= (e) => z.value.text = e,
2390
- label: z.value.field.label ?? T(z.value.field.type),
2391
- onKeydown: se(G, ["enter"])
2392
- }, null, 8, ["modelValue", "label"]))])) : g("", !0)]),
2393
- _: 1
2394
- }, 8, ["model-value", "title"])
2395
- ], 16));
2396
- }
2397
- });
2398
- export { St as MPdfSigner, ot as MPdfViewer, st as fieldMissing, z as setPdfWorker, ct as shownToUser, dt as signPdf, le as usePdf };
2399
-
2400
- //# sourceMappingURL=pdf.js.map
1
+ export { t as MPdfViewer, n as setPdfWorker, r as usePdf } from "./MPdfViewer-B5Q9Xs9d.js";