@m3ui-vue/m3ui-vue 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/API.md +579 -4
  2. package/dist/{MButton-CN3wYwIG.js → MButton-B6eZTfFV.js} +2 -2
  3. package/dist/{MButton-CN3wYwIG.js.map → MButton-B6eZTfFV.js.map} +1 -1
  4. package/dist/{MColorPickerModal-BKM1CHxr.js → MColorPickerModal-Dajjf6tH.js} +4 -4
  5. package/dist/{MColorPickerModal-BKM1CHxr.js.map → MColorPickerModal-Dajjf6tH.js.map} +1 -1
  6. package/dist/{MDialog-1LAk9WAO.js → MDialog-DQvE_JBv.js} +2 -2
  7. package/dist/{MDialog-1LAk9WAO.js.map → MDialog-DQvE_JBv.js.map} +1 -1
  8. package/dist/{MListItem-BU5KDRCB.js → MListItem-DiOAxaN7.js} +102 -102
  9. package/dist/{MListItem-BU5KDRCB.js.map → MListItem-DiOAxaN7.js.map} +1 -1
  10. package/dist/{MLoadingIndicator-RykOo5tf.js → MLoadingIndicator-CuTZYFFj.js} +2 -2
  11. package/dist/{MLoadingIndicator-RykOo5tf.js.map → MLoadingIndicator-CuTZYFFj.js.map} +1 -1
  12. package/dist/MPdfViewer-C5ngKPRM.js +1866 -0
  13. package/dist/MPdfViewer-C5ngKPRM.js.map +1 -0
  14. package/dist/{MSeekBar-B_Y3MpVz.js → MSeekBar-BCDQTx2t.js} +2 -2
  15. package/dist/{MSeekBar-B_Y3MpVz.js.map → MSeekBar-BCDQTx2t.js.map} +1 -1
  16. package/dist/{MSegmentedButton-CiOOY1-N.js → MSegmentedButton-BXzRsg1S.js} +2 -2
  17. package/dist/{MSegmentedButton-CiOOY1-N.js.map → MSegmentedButton-BXzRsg1S.js.map} +1 -1
  18. package/dist/MSignaturePad-CxOtelzE.js +140 -0
  19. package/dist/MSignaturePad-CxOtelzE.js.map +1 -0
  20. package/dist/{MSlider-BCeVIxcq.js → MSlider-D_O8J9YH.js} +3 -3
  21. package/dist/{MSlider-BCeVIxcq.js.map → MSlider-D_O8J9YH.js.map} +1 -1
  22. package/dist/{MSpinner-Cs03qoqE.js → MSpinner-UCdtSOHP.js} +2 -2
  23. package/dist/{MSpinner-Cs03qoqE.js.map → MSpinner-UCdtSOHP.js.map} +1 -1
  24. package/dist/{MTextField-NaFbMkjv.js → MTextField-CYk9yFvi.js} +3 -3
  25. package/dist/{MTextField-NaFbMkjv.js.map → MTextField-CYk9yFvi.js.map} +1 -1
  26. package/dist/{_useFieldValidation-Bz34IAQY.js → _useFieldValidation-B0B44M_t.js} +2 -2
  27. package/dist/{_useFieldValidation-Bz34IAQY.js.map → _useFieldValidation-B0B44M_t.js.map} +1 -1
  28. package/dist/api.json +1 -1
  29. package/dist/code-editor.js +2 -2
  30. package/dist/components/MFormBuilder.vue.d.ts +22 -0
  31. package/dist/components/MFormRenderer.vue.d.ts +151 -0
  32. package/dist/components/MMapRoute.vue.d.ts +13 -5
  33. package/dist/components/MPdfSigner.vue.d.ts +499 -0
  34. package/dist/components/MPdfViewer.vue.d.ts +12 -0
  35. package/dist/components/MPosKeypad.vue.d.ts +1 -1
  36. package/dist/components/MSpreadsheet.vue.d.ts +137 -0
  37. package/dist/components/MStack.vue.d.ts +1 -1
  38. package/dist/composables/pdfSign.d.ts +52 -0
  39. package/dist/composables/spreadsheetFormula.d.ts +55 -0
  40. package/dist/composables/useLocale.d.ts +154 -0
  41. package/dist/draw.js +2 -2
  42. package/dist/flow.js +1 -1
  43. package/dist/gantt.js +2 -2
  44. package/dist/index.d.ts +7 -0
  45. package/dist/locales/index.js +539 -0
  46. package/dist/locales/index.js.map +1 -1
  47. package/dist/m3ui-vue.css +1 -1
  48. package/dist/m3ui.js +16968 -15042
  49. package/dist/m3ui.js.map +1 -1
  50. package/dist/map.js +601 -585
  51. package/dist/map.js.map +1 -1
  52. package/dist/media.js +4 -4
  53. package/dist/pdf-sign.d.ts +3 -0
  54. package/dist/pdf-sign.js +548 -0
  55. package/dist/pdf-sign.js.map +1 -0
  56. package/dist/pdf.js +1 -1859
  57. package/dist/rich-text-editor.js +5 -5
  58. package/dist/styles.css +1 -1
  59. package/dist/{useLocale-Dh1xZZ8i.js → useLocale-DL96OFgr.js} +78 -1
  60. package/dist/useLocale-DL96OFgr.js.map +1 -0
  61. package/package.json +9 -1
  62. package/src/__tests__/MFormRenderer.test.ts +157 -0
  63. package/src/__tests__/MMapRoute.test.ts +34 -0
  64. package/src/__tests__/MPdfSigner.test.ts +175 -0
  65. package/src/__tests__/MSpreadsheet.test.ts +223 -0
  66. package/src/__tests__/spreadsheetFormula.test.ts +77 -0
  67. package/src/__tests__/ssr.test.ts +3 -0
  68. package/src/components/MFormBuilder.vue +417 -0
  69. package/src/components/MFormRenderer.vue +324 -0
  70. package/src/components/MMapRoute.vue +64 -11
  71. package/src/components/MPdfSigner.vue +433 -0
  72. package/src/components/MPdfViewer.vue +12 -0
  73. package/src/components/MSpreadsheet.vue +992 -0
  74. package/src/composables/pdfSign.ts +141 -0
  75. package/src/composables/spreadsheetFormula.ts +459 -0
  76. package/src/composables/useLocale.ts +231 -0
  77. package/src/index.ts +7 -0
  78. package/src/locales/de.ts +77 -0
  79. package/src/locales/es.ts +77 -0
  80. package/src/locales/fr.ts +77 -0
  81. package/src/locales/ja.ts +77 -0
  82. package/src/locales/ko.ts +77 -0
  83. package/src/locales/pt.ts +77 -0
  84. package/src/locales/zh.ts +77 -0
  85. package/src/pdf-sign.ts +5 -0
  86. package/dist/pdf.js.map +0 -1
  87. package/dist/useLocale-Dh1xZZ8i.js.map +0 -1
package/dist/media.js CHANGED
@@ -1,10 +1,10 @@
1
- import { i as e } from "./useLocale-Dh1xZZ8i.js";
2
- import { t } from "./MSeekBar-B_Y3MpVz.js";
1
+ import { i as e } from "./useLocale-DL96OFgr.js";
2
+ import { t } from "./MSeekBar-BCDQTx2t.js";
3
3
  import { t as n } from "./MIconButton-BBggVwBV.js";
4
4
  import { t as r } from "./MIcon-DpajuUTJ.js";
5
- import { t as i } from "./MSlider-BCeVIxcq.js";
5
+ import { t as i } from "./MSlider-D_O8J9YH.js";
6
6
  import { n as a, t as o } from "./MMenuItem-BuxYoASE.js";
7
- import { t as s } from "./MLoadingIndicator-RykOo5tf.js";
7
+ import { t as s } from "./MLoadingIndicator-CuTZYFFj.js";
8
8
  import { Fragment as c, Transition as l, computed as u, createBlock as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createTextVNode as h, createVNode as g, defineComponent as _, getCurrentScope as v, guardReactiveProps as y, mergeProps as b, nextTick as ee, normalizeClass as x, normalizeProps as S, normalizeStyle as te, onBeforeUnmount as ne, onMounted as re, onScopeDispose as C, openBlock as w, ref as T, renderList as E, renderSlot as D, shallowRef as O, toDisplayString as k, toValue as A, unref as j, useSlots as ie, watch as M, withCtx as N, withModifiers as P } from "vue";
9
9
  // src/composables/useMediaPlayer.ts
10
10
  var F = typeof window < "u", I = null;
@@ -0,0 +1,3 @@
1
+ export { default as MPdfSigner } from './components/MPdfSigner.vue';
2
+ export { signPdf, shownToUser, fieldMissing } from './composables/pdfSign';
3
+ export type { PdfSignField, SignPdfOptions } from './composables/pdfSign';
@@ -0,0 +1,548 @@
1
+ import { t as e } from "./MPdfViewer-C5ngKPRM.js";
2
+ import { t } from "./MSignaturePad-CxOtelzE.js";
3
+ import { t as n } from "./MDialog-DQvE_JBv.js";
4
+ import { t as r } from "./MButton-B6eZTfFV.js";
5
+ import { t as i } from "./MIcon-DpajuUTJ.js";
6
+ import { t as a } from "./MIconButton-BBggVwBV.js";
7
+ import { t as o } from "./MSegmentedButton-BXzRsg1S.js";
8
+ import { t as s } from "./MTextField-CYk9yFvi.js";
9
+ import { i as c } from "./useLocale-DL96OFgr.js";
10
+ import { Fragment as l, computed as u, createBlock as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createTextVNode as h, createVNode as g, defineComponent as _, mergeProps as v, nextTick as ee, normalizeClass as te, normalizeStyle as y, openBlock as b, ref as x, renderList as S, toDisplayString as C, unref as w, useId as ne, watch as T, withCtx as E, withKeys as re, withModifiers as D } from "vue";
11
+ // src/composables/pdfSign.ts
12
+ var O = (e) => (e.required ?? (e.type === "signature" || e.type === "initials")) && !e.value;
13
+ function k(e, t, n) {
14
+ let r = (n % 360 + 360) % 360, i = e.x, a = e.y + e.height, o, s;
15
+ 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), {
16
+ x: t.x + o,
17
+ y: t.y + s,
18
+ rotate: r
19
+ };
20
+ }
21
+ async function ie(e, t, n, r) {
22
+ if (!e.value) return null;
23
+ if ((e.type === "signature" || e.type === "initials") && e.value.startsWith("data:image/png")) return A(e.value);
24
+ let i = document.createElement("canvas");
25
+ i.width = Math.max(1, Math.round(t * 4)), i.height = Math.max(1, Math.round(n * 4));
26
+ let a = i.getContext("2d");
27
+ if (!a) return null;
28
+ if (a.fillStyle = "#111", a.textBaseline = "middle", e.type === "checkbox") {
29
+ if (e.value !== "true") return null;
30
+ let t = Math.min(i.width, i.height);
31
+ 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();
32
+ } else {
33
+ let t = i.height * .62;
34
+ for (a.font = `${t}px ${r}`; t > 6 && a.measureText(e.value).width > i.width * .96;) t *= .92, a.font = `${t}px ${r}`;
35
+ a.fillText(e.value, i.width * .02, i.height / 2);
36
+ }
37
+ let o = await new Promise((e) => i.toBlob(e, "image/png"));
38
+ return o ? new Uint8Array(await o.arrayBuffer()) : null;
39
+ }
40
+ function A(e) {
41
+ let t = e.slice(e.indexOf(",") + 1), n = atob(t), r = new Uint8Array(n.length);
42
+ for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
43
+ return r;
44
+ }
45
+ async function ae(e, t, n = {}) {
46
+ let { PDFDocument: r, degrees: i } = await import("pdf-lib"), a = await r.load(e), o = a.getPages(), s = n.font ?? "system-ui, sans-serif";
47
+ for (let e of t) {
48
+ let t = o[e.page - 1];
49
+ if (!t || !e.value) continue;
50
+ 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 = {
51
+ x: e.x * l,
52
+ y: e.y * u,
53
+ width: e.width * l,
54
+ height: e.height * u
55
+ }, f = await ie(e, d.width, d.height, s);
56
+ if (!f) continue;
57
+ let p = await a.embedPng(f), { width: m, height: h } = d, g = 0, _ = 0;
58
+ if (e.type === "signature" || e.type === "initials") {
59
+ let e = Math.min(d.width / p.width, d.height / p.height);
60
+ m = p.width * e, h = p.height * e, g = (d.width - m) / 2, _ = (d.height - h) / 2;
61
+ }
62
+ let v = k({
63
+ x: d.x + g,
64
+ y: d.y + _,
65
+ width: m,
66
+ height: h
67
+ }, {
68
+ x: n.x,
69
+ y: n.y,
70
+ width: n.width,
71
+ height: n.height
72
+ }, r);
73
+ t.drawImage(p, {
74
+ x: v.x,
75
+ y: v.y,
76
+ width: m,
77
+ height: h,
78
+ rotate: i(v.rotate)
79
+ });
80
+ }
81
+ return n.producer && a.setProducer(n.producer), a.setModificationDate(/* @__PURE__ */ new Date()), a.save();
82
+ }
83
+ // src/components/MPdfSigner.vue?vue&type=script&setup=true&lang.ts
84
+ var oe = { class: "flex shrink-0 flex-wrap items-center gap-2 border-b border-outline-variant bg-surface-container px-3 py-2" }, se = {
85
+ class: "text-body-medium text-on-surface",
86
+ "aria-live": "polite"
87
+ }, ce = { class: "mr-1 text-label-large text-on-surface-variant" }, le = { class: "pointer-events-none absolute inset-0" }, ue = [
88
+ "id",
89
+ "data-field",
90
+ "data-type",
91
+ "tabindex",
92
+ "aria-label",
93
+ "onClick",
94
+ "onPointerdown",
95
+ "onKeydown"
96
+ ], de = ["src"], fe = {
97
+ key: 3,
98
+ class: "flex min-w-0 items-center gap-1 truncate px-1 text-label-medium"
99
+ }, pe = { class: "truncate" }, me = ["onPointerdown"], he = {
100
+ key: 0,
101
+ class: "flex flex-col gap-4"
102
+ }, j = "\"Segoe Script\", \"Brush Script MT\", \"Snell Roundhand\", \"URW Chancery L\", cursive", M = /* @__PURE__ */ _({
103
+ inheritAttrs: !1,
104
+ __name: "MPdfSigner",
105
+ props: {
106
+ src: { default: null },
107
+ fields: { default: () => [] },
108
+ mode: { default: "sign" },
109
+ signer: {},
110
+ signerName: {},
111
+ dateFormat: { default: () => ({ dateStyle: "medium" }) },
112
+ types: { default: () => [
113
+ "signature",
114
+ "initials",
115
+ "name",
116
+ "date",
117
+ "text",
118
+ "checkbox"
119
+ ] },
120
+ workerSrc: {}
121
+ },
122
+ emits: [
123
+ "update:fields",
124
+ "complete",
125
+ "finish",
126
+ "loaded"
127
+ ],
128
+ setup(_, { expose: k, emit: ie }) {
129
+ let A = _, M = ie, N = c(), ge = ne(), P = x(), F = {
130
+ signature: {
131
+ icon: "signature",
132
+ key: "pdfSignSignature",
133
+ w: .3,
134
+ h: .06
135
+ },
136
+ initials: {
137
+ icon: "draw",
138
+ key: "pdfSignInitials",
139
+ w: .1,
140
+ h: .05
141
+ },
142
+ name: {
143
+ icon: "badge",
144
+ key: "pdfSignName",
145
+ w: .3,
146
+ h: .035
147
+ },
148
+ date: {
149
+ icon: "calendar_today",
150
+ key: "pdfSignDate",
151
+ w: .2,
152
+ h: .035
153
+ },
154
+ text: {
155
+ icon: "text_fields",
156
+ key: "pdfSignText",
157
+ w: .3,
158
+ h: .035
159
+ },
160
+ checkbox: {
161
+ icon: "check_box",
162
+ key: "pdfSignCheckbox",
163
+ w: .03,
164
+ h: .022
165
+ }
166
+ }, I = (e) => N[F[e].key], L = (e) => !A.signer || !e.signer || e.signer === A.signer, _e = u(() => {
167
+ let e = /* @__PURE__ */ new Map();
168
+ for (let t of A.fields) e.set(t.page, [...e.get(t.page) ?? [], t]);
169
+ return e;
170
+ }), R = u(() => A.fields.filter((e) => L(e) && (e.required ?? (e.type === "signature" || e.type === "initials")))), z = u(() => R.value.filter((e) => !O(e)).length), B = u(() => z.value === R.value.length);
171
+ T(B, (e, t) => {
172
+ e && !t && A.mode === "sign" && M("complete");
173
+ });
174
+ let ve = u(() => N.pdfSignProgress.replace("{done}", String(z.value)).replace("{total}", String(R.value.length)));
175
+ function V(e, t) {
176
+ M("update:fields", A.fields.map((n) => n.id === e ? {
177
+ ...n,
178
+ ...t
179
+ } : n));
180
+ }
181
+ let H = x({}), U = x(null), W = x(), G = x(!0), K = x(), q = x(400);
182
+ T(() => U.value?.tab, () => ee(() => {
183
+ K.value?.clientWidth && (q.value = K.value.clientWidth - 2);
184
+ }));
185
+ function ye() {
186
+ return new Intl.DateTimeFormat(void 0, A.dateFormat).format(/* @__PURE__ */ new Date());
187
+ }
188
+ function J(e, t = !1) {
189
+ if (A.mode !== "sign" || !L(e)) return;
190
+ if (e.type === "checkbox") return V(e.id, { value: e.value === "true" ? void 0 : "true" });
191
+ if (e.type === "date" && !e.value) return V(e.id, { value: ye() });
192
+ if (e.type === "name" && !e.value && A.signerName) return V(e.id, { value: A.signerName });
193
+ if ((e.type === "signature" || e.type === "initials") && !t) {
194
+ let t = H.value[e.type];
195
+ if (t && !e.value) return V(e.id, { value: t });
196
+ }
197
+ let n = e.type === "initials" ? be(A.signerName ?? "") : A.signerName ?? "";
198
+ U.value = {
199
+ field: e,
200
+ tab: e.type === "signature" || e.type === "initials" ? "draw" : "type",
201
+ text: e.type === "signature" || e.type === "initials" ? n : e.value ?? (e.type === "name" ? n : "")
202
+ }, G.value = !0;
203
+ }
204
+ let be = (e) => e.split(/\s+/).filter(Boolean).map((e) => e[0].toUpperCase()).join("");
205
+ function xe(e) {
206
+ let t = document.createElement("canvas"), n = t.getContext("2d");
207
+ return n ? (n.font = `96px ${j}`, t.width = Math.ceil(n.measureText(e).width) + 40, t.height = 96 * 1.6, n.font = `96px ${j}`, n.fillStyle = "#1a237e", n.textBaseline = "middle", n.fillText(e, 20, t.height / 2), t.toDataURL("image/png")) : "";
208
+ }
209
+ let Y = u(() => U.value?.field.type === "signature" || U.value?.field.type === "initials"), Se = u(() => {
210
+ let e = U.value;
211
+ return e ? Y.value && e.tab === "draw" ? !G.value : e.text.trim() !== "" : !1;
212
+ });
213
+ async function Ce() {
214
+ let e = U.value;
215
+ if (!e || !Se.value) return;
216
+ let t;
217
+ Y.value ? (t = e.tab === "draw" ? await we(W.value?.toDataURL() ?? "") : xe(e.text.trim()), H.value = {
218
+ ...H.value,
219
+ [e.field.type]: t
220
+ }) : t = e.text.trim(), V(e.field.id, { value: t }), U.value = null;
221
+ }
222
+ async function we(e) {
223
+ if (!e || typeof document > "u") return e;
224
+ let t = new Image();
225
+ t.src = e;
226
+ try {
227
+ await t.decode();
228
+ } catch {
229
+ return e;
230
+ }
231
+ if (!t.width) return e;
232
+ let n = document.createElement("canvas");
233
+ n.width = t.width, n.height = t.height;
234
+ let r = n.getContext("2d");
235
+ if (!r) return e;
236
+ r.drawImage(t, 0, 0);
237
+ let { data: i, width: a, height: o } = r.getImageData(0, 0, n.width, n.height), s = a, c = o, l = -1, u = -1;
238
+ 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));
239
+ if (l < 0) return e;
240
+ 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);
241
+ let d = document.createElement("canvas");
242
+ 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");
243
+ }
244
+ function Te() {
245
+ let e = R.value, t = e.find((e) => O(e)) ?? e[0];
246
+ if (!t) return;
247
+ let n = document.getElementById(Ee(t));
248
+ n?.scrollIntoView({
249
+ behavior: "smooth",
250
+ block: "center"
251
+ }), n?.focus({ preventScroll: !0 });
252
+ }
253
+ let Ee = (e) => `${ge}-f-${e.id}`, X = x(null), De = 0;
254
+ function Oe(e) {
255
+ let t = F[e], n = $.value, r = `${e}-${Date.now().toString(36)}-${++De}`, i = {
256
+ id: r,
257
+ type: e,
258
+ page: n,
259
+ x: .5 - t.w / 2,
260
+ y: .45,
261
+ width: t.w,
262
+ height: t.h,
263
+ label: I(e)
264
+ };
265
+ (e === "signature" || e === "initials") && (i.required = !0), M("update:fields", [...A.fields, i]), X.value = r;
266
+ }
267
+ function ke(e) {
268
+ M("update:fields", A.fields.filter((t) => t.id !== e)), X.value === e && (X.value = null);
269
+ }
270
+ let Z = null;
271
+ function Ae(e, t, n, r) {
272
+ A.mode === "prepare" && e.button === 0 && (e.preventDefault(), e.stopPropagation(), X.value = t.id, Z = {
273
+ id: t.id,
274
+ kind: n,
275
+ x: e.clientX,
276
+ y: e.clientY,
277
+ start: { ...t },
278
+ w: r.width,
279
+ h: r.height
280
+ }, e.currentTarget.setPointerCapture?.(e.pointerId));
281
+ }
282
+ function je(e) {
283
+ if (!Z) return;
284
+ let t = (e.clientX - Z.x) / Z.w, n = (e.clientY - Z.y) / Z.h, r = Z.start;
285
+ Z.kind === "move" ? V(Z.id, {
286
+ x: Q(r.x + t, 0, 1 - r.width),
287
+ y: Q(r.y + n, 0, 1 - r.height)
288
+ }) : V(Z.id, {
289
+ width: Q(r.width + t, .02, 1 - r.x),
290
+ height: Q(r.height + n, .015, 1 - r.y)
291
+ });
292
+ }
293
+ function Me() {
294
+ Z = null;
295
+ }
296
+ let Q = (e, t, n) => Math.min(Math.max(e, t), n);
297
+ function Ne(e, t) {
298
+ if (A.mode === "sign") {
299
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J(t));
300
+ return;
301
+ }
302
+ let n = e.shiftKey ? .02 : .005, r = {
303
+ ArrowLeft: [-n, 0],
304
+ ArrowRight: [n, 0],
305
+ ArrowUp: [0, -n],
306
+ ArrowDown: [0, n]
307
+ };
308
+ if (r[e.key]) {
309
+ e.preventDefault();
310
+ let [n, i] = r[e.key];
311
+ V(t.id, {
312
+ x: Q(t.x + n, 0, 1 - t.width),
313
+ y: Q(t.y + i, 0, 1 - t.height)
314
+ });
315
+ } else (e.key === "Delete" || e.key === "Backspace") && (e.preventDefault(), ke(t.id));
316
+ }
317
+ let $ = x(1);
318
+ function Pe(e) {
319
+ 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;
320
+ return {
321
+ width: `${r}px`,
322
+ height: `${i}px`,
323
+ transform: a,
324
+ transformOrigin: "top left"
325
+ };
326
+ }
327
+ let Fe = (e) => ({
328
+ left: `${e.x * 100}%`,
329
+ top: `${e.y * 100}%`,
330
+ width: `${e.width * 100}%`,
331
+ height: `${e.height * 100}%`
332
+ });
333
+ async function Ie(e) {
334
+ if (e instanceof Uint8Array || e instanceof ArrayBuffer) return e;
335
+ if (typeof Blob < "u" && e instanceof Blob) return e.arrayBuffer();
336
+ let t = await fetch(String(e));
337
+ if (!t.ok) throw Error(`PDF ${t.status}`);
338
+ return t.arrayBuffer();
339
+ }
340
+ async function Le(e) {
341
+ if (!A.src) throw Error("No PDF");
342
+ return ae(await Ie(A.src), A.fields, e);
343
+ }
344
+ return k({
345
+ save: Le,
346
+ next: Te,
347
+ complete: B,
348
+ viewer: P
349
+ }), (c, u) => (b(), p("div", v({ class: "m3-pdf-signer" }, c.$attrs), [
350
+ m("div", oe, [_.mode === "sign" ? (b(), p(l, { key: 0 }, [
351
+ g(i, {
352
+ name: B.value ? "task_alt" : "edit_document",
353
+ size: 20,
354
+ class: te(B.value ? "text-primary" : "text-on-surface-variant")
355
+ }, null, 8, ["name", "class"]),
356
+ m("span", se, C(B.value ? w(N).pdfSignComplete : ve.value), 1),
357
+ u[12] ||= m("span", { class: "flex-1" }, null, -1),
358
+ B.value ? f("", !0) : (b(), d(r, {
359
+ key: 0,
360
+ variant: "tonal",
361
+ icon: "arrow_downward",
362
+ onClick: Te
363
+ }, {
364
+ default: E(() => [h(C(w(N).pdfSignNext), 1)]),
365
+ _: 1
366
+ })),
367
+ g(r, {
368
+ disabled: !B.value,
369
+ icon: "check",
370
+ onClick: u[0] ||= (e) => M("finish")
371
+ }, {
372
+ default: E(() => [h(C(w(N).pdfSignFinish), 1)]),
373
+ _: 1
374
+ }, 8, ["disabled"])
375
+ ], 64)) : (b(), p(l, { key: 1 }, [m("span", ce, C(w(N).pdfSignAddField), 1), (b(!0), p(l, null, S(_.types, (e) => (b(), d(r, {
376
+ key: e,
377
+ variant: "tonal",
378
+ size: "sm",
379
+ icon: F[e].icon,
380
+ "data-add": e,
381
+ onClick: (t) => Oe(e)
382
+ }, {
383
+ default: E(() => [h(C(I(e)), 1)]),
384
+ _: 2
385
+ }, 1032, [
386
+ "icon",
387
+ "data-add",
388
+ "onClick"
389
+ ]))), 128))], 64))]),
390
+ g(e, {
391
+ ref_key: "viewer",
392
+ ref: P,
393
+ src: _.src,
394
+ "worker-src": _.workerSrc,
395
+ class: "min-h-0 flex-1",
396
+ "onUpdate:page": u[2] ||= (e) => $.value = e,
397
+ onLoaded: u[3] ||= (e) => M("loaded", e)
398
+ }, {
399
+ page: E((e) => [m("div", le, [m("div", {
400
+ class: "absolute left-0 top-0",
401
+ style: y(Pe(e))
402
+ }, [(b(!0), p(l, null, S(_e.value.get(e.page) ?? [], (t) => (b(), p("div", {
403
+ id: Ee(t),
404
+ key: t.id,
405
+ class: te(["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", [
406
+ _.mode === "prepare" ? "cursor-move" : L(t) ? "cursor-pointer" : "cursor-default opacity-40",
407
+ t.value ? "m3-pdf-sign-filled" : "m3-pdf-sign-empty",
408
+ _.mode === "sign" && L(t) && w(O)(t) ? "m3-pdf-sign-todo" : "",
409
+ X.value === t.id && _.mode === "prepare" ? "m3-pdf-sign-selected" : ""
410
+ ]]),
411
+ style: y(Fe(t)),
412
+ "data-field": t.id,
413
+ "data-type": t.type,
414
+ role: "button",
415
+ tabindex: _.mode === "prepare" || L(t) ? 0 : -1,
416
+ "aria-label": `${t.label ?? I(t.type)}${t.value ? "" : t.required ?? (t.type === "signature" || t.type === "initials") ? ` (${w(N).pdfSignRequired})` : ""}`,
417
+ onClick: (e) => _.mode === "sign" ? J(t, !!t.value) : X.value = t.id,
418
+ onPointerdown: (n) => Ae(n, t, "move", {
419
+ width: e.rotation % 180 ? e.height : e.width,
420
+ height: e.rotation % 180 ? e.width : e.height
421
+ }),
422
+ onPointermove: je,
423
+ onPointerup: Me,
424
+ onPointercancel: Me,
425
+ onKeydown: (e) => Ne(e, t)
426
+ }, [t.value && (t.type === "signature" || t.type === "initials") ? (b(), p("img", {
427
+ key: 0,
428
+ src: t.value,
429
+ alt: "",
430
+ class: "h-full w-full object-contain",
431
+ draggable: "false"
432
+ }, null, 8, de)) : t.type === "checkbox" && t.value === "true" ? (b(), d(i, {
433
+ key: 1,
434
+ name: "check",
435
+ class: "text-on-surface",
436
+ size: Math.max(12, e.height * t.height * .9)
437
+ }, null, 8, ["size"])) : t.value ? (b(), p("span", {
438
+ key: 2,
439
+ class: "m3-pdf-sign-text w-full truncate px-1 text-left",
440
+ style: y({ fontSize: `${Math.max(8, e.height * t.height * .6)}px` })
441
+ }, C(t.value), 5)) : t.type === "checkbox" ? f("", !0) : (b(), p("span", fe, [g(i, {
442
+ name: F[t.type].icon,
443
+ size: 16
444
+ }, null, 8, ["name"]), m("span", pe, C(t.type === "signature" && _.mode === "sign" ? w(N).pdfSignHere : t.label ?? I(t.type)), 1)])), _.mode === "prepare" && X.value === t.id ? (b(), p(l, { key: 4 }, [m("span", {
445
+ 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",
446
+ "aria-hidden": "true",
447
+ onPointerdown: (n) => Ae(n, t, "resize", {
448
+ width: e.rotation % 180 ? e.height : e.width,
449
+ height: e.rotation % 180 ? e.width : e.height
450
+ })
451
+ }, null, 40, me), m("div", {
452
+ class: "absolute -top-11 left-0 flex items-center gap-1 rounded-full bg-surface-container-high px-1 shadow-elevation-2",
453
+ onPointerdown: u[1] ||= D(() => {}, ["stop"])
454
+ }, [g(r, {
455
+ variant: t.required ?? (t.type === "signature" || t.type === "initials") ? "filled" : "text",
456
+ size: "xs",
457
+ onClick: D((e) => V(t.id, { required: !(t.required ?? (t.type === "signature" || t.type === "initials")) }), ["stop"])
458
+ }, {
459
+ default: E(() => [h(C(w(N).pdfSignRequired), 1)]),
460
+ _: 1
461
+ }, 8, ["variant", "onClick"]), g(a, {
462
+ icon: "delete",
463
+ size: "xs",
464
+ label: w(N).pdfSignDelete,
465
+ onClick: D((e) => ke(t.id), ["stop"])
466
+ }, null, 8, ["label", "onClick"])], 32)], 64)) : f("", !0)], 46, ue))), 128))], 4)])]),
467
+ _: 1
468
+ }, 8, ["src", "worker-src"]),
469
+ g(n, {
470
+ "model-value": !!U.value,
471
+ title: U.value ? U.value.field.label ?? I(U.value.field.type) : "",
472
+ "max-width": "560px",
473
+ "onUpdate:modelValue": u[11] ||= (e) => {
474
+ e || (U.value = null);
475
+ }
476
+ }, {
477
+ actions: E(() => [g(r, {
478
+ variant: "text",
479
+ onClick: u[10] ||= (e) => U.value = null
480
+ }, {
481
+ default: E(() => [h(C(w(N).cancel), 1)]),
482
+ _: 1
483
+ }), g(r, {
484
+ disabled: !Se.value,
485
+ onClick: Ce
486
+ }, {
487
+ default: E(() => [h(C(Y.value ? w(N).pdfSignAdopt : w(N).ok), 1)]),
488
+ _: 1
489
+ }, 8, ["disabled"])]),
490
+ default: E(() => [U.value ? (b(), p("div", he, [Y.value ? (b(), p(l, { key: 0 }, [g(o, {
491
+ modelValue: U.value.tab,
492
+ "onUpdate:modelValue": u[4] ||= (e) => U.value.tab = e,
493
+ options: [{
494
+ value: "draw",
495
+ label: w(N).pdfSignDraw,
496
+ icon: "draw"
497
+ }, {
498
+ value: "type",
499
+ label: w(N).pdfSignTypeIt,
500
+ icon: "keyboard"
501
+ }],
502
+ density: "compact"
503
+ }, null, 8, ["modelValue", "options"]), U.value.tab === "draw" ? (b(), p("div", {
504
+ key: 0,
505
+ ref_key: "padBox",
506
+ ref: K,
507
+ class: "flex flex-col gap-2"
508
+ }, [(b(), d(t, {
509
+ ref_key: "pad",
510
+ ref: W,
511
+ key: q.value,
512
+ width: q.value,
513
+ height: 180,
514
+ onEnd: u[5] ||= (e) => G.value = !1,
515
+ onChange: u[6] ||= (e) => G.value = !!W.value?.isEmpty()
516
+ }, null, 8, ["width"])), g(r, {
517
+ variant: "text",
518
+ icon: "ink_eraser",
519
+ class: "self-start",
520
+ onClick: u[7] ||= (e) => {
521
+ W.value?.clear(), G.value = !0;
522
+ }
523
+ }, {
524
+ default: E(() => [h(C(w(N).clear), 1)]),
525
+ _: 1
526
+ })], 512)) : (b(), p(l, { key: 1 }, [g(s, {
527
+ modelValue: U.value.text,
528
+ "onUpdate:modelValue": u[8] ||= (e) => U.value.text = e,
529
+ label: I(U.value.field.type),
530
+ autocomplete: "name"
531
+ }, null, 8, ["modelValue", "label"]), m("div", {
532
+ class: "flex h-24 items-center overflow-hidden rounded-lg bg-surface-container-highest px-4 text-[2.5rem] text-[#1a237e] dark:text-[#c5cae9]",
533
+ style: y({ fontFamily: j })
534
+ }, C(U.value.text), 5)], 64))], 64)) : (b(), d(s, {
535
+ key: 1,
536
+ modelValue: U.value.text,
537
+ "onUpdate:modelValue": u[9] ||= (e) => U.value.text = e,
538
+ label: U.value.field.label ?? I(U.value.field.type),
539
+ onKeydown: re(Ce, ["enter"])
540
+ }, null, 8, ["modelValue", "label"]))])) : f("", !0)]),
541
+ _: 1
542
+ }, 8, ["model-value", "title"])
543
+ ], 16));
544
+ }
545
+ });
546
+ export { M as MPdfSigner, O as fieldMissing, k as shownToUser, ae as signPdf };
547
+
548
+ //# sourceMappingURL=pdf-sign.js.map