@gx-design-vue/image 0.2.0-alpha.1 → 0.2.0-alpha.3

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 (69) hide show
  1. package/dist/Image.d.ts +6 -0
  2. package/dist/Image.js +322 -0
  3. package/dist/ImagePreview.d.ts +6 -0
  4. package/dist/ImagePreview.js +593 -0
  5. package/dist/g-image.esm.js +1590 -0
  6. package/dist/g-image.js +1 -0
  7. package/dist/hooks/useImageBoundary.d.ts +15 -0
  8. package/dist/hooks/useImageBoundary.js +24 -0
  9. package/dist/hooks/useImagePreview.d.ts +23 -0
  10. package/dist/hooks/useImagePreview.js +54 -0
  11. package/dist/hooks/useImageTransform.d.ts +23 -0
  12. package/dist/hooks/useImageTransform.js +92 -0
  13. package/dist/hooks/useMouseEvent.d.ts +22 -0
  14. package/dist/hooks/useMouseEvent.js +71 -0
  15. package/dist/hooks/useTouchEvent.d.ts +23 -0
  16. package/dist/{ImagePreview/hooks → hooks}/useTouchEvent.js +31 -32
  17. package/dist/index.d.ts +4 -5
  18. package/dist/index.js +3 -6
  19. package/dist/interface.d.ts +169 -0
  20. package/dist/interface.js +1 -0
  21. package/dist/style/index.d.ts +7 -0
  22. package/dist/{style.js → style/index.js} +19 -26
  23. package/dist/style/preview.d.ts +14 -0
  24. package/dist/style/preview.js +182 -0
  25. package/dist/theme/augment.d.ts +10 -0
  26. package/dist/theme/augment.js +1 -0
  27. package/dist/theme/interface/components.d.ts +10 -0
  28. package/dist/theme/interface/components.js +1 -0
  29. package/package.json +8 -7
  30. package/dist/GImage.d.ts +0 -162
  31. package/dist/GImage.js +0 -221
  32. package/dist/ImagePreview/Operations.d.ts +0 -83
  33. package/dist/ImagePreview/Operations.js +0 -71
  34. package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.d.ts +0 -19
  35. package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.js +0 -40
  36. package/dist/ImagePreview/hooks/useImageTransform.d.ts +0 -39
  37. package/dist/ImagePreview/hooks/useImageTransform.js +0 -105
  38. package/dist/ImagePreview/hooks/useMouseEvent.d.ts +0 -14
  39. package/dist/ImagePreview/hooks/useMouseEvent.js +0 -100
  40. package/dist/ImagePreview/hooks/useTouchEvent.d.ts +0 -12
  41. package/dist/ImagePreview/index.d.ts +0 -162
  42. package/dist/ImagePreview/index.js +0 -303
  43. package/dist/ImagePreview/props.d.ts +0 -88
  44. package/dist/ImagePreview/props.js +0 -53
  45. package/dist/ImagePreview/style.d.ts +0 -30
  46. package/dist/ImagePreview/style.js +0 -286
  47. package/dist/ImagePreview/typings.d.ts +0 -19
  48. package/dist/ImagePreview/typings.js +0 -1
  49. package/dist/ImagePreview/utils/KeyCode.d.ts +0 -438
  50. package/dist/ImagePreview/utils/KeyCode.js +0 -173
  51. package/dist/ImagePreview/utils/addEventListener.d.ts +0 -6
  52. package/dist/ImagePreview/utils/addEventListener.js +0 -22
  53. package/dist/ImagePreview/utils/util.d.ts +0 -7
  54. package/dist/ImagePreview/utils/util.js +0 -8
  55. package/dist/hooks/useFrameSetState.d.ts +0 -5
  56. package/dist/hooks/useFrameSetState.js +0 -33
  57. package/dist/image.esm.js +0 -2374
  58. package/dist/image.js +0 -1
  59. package/dist/props.d.ts +0 -84
  60. package/dist/props.js +0 -66
  61. package/dist/slots.d.ts +0 -6
  62. package/dist/slots.js +0 -21
  63. package/dist/style.d.ts +0 -9
  64. package/dist/typings.d.ts +0 -6
  65. package/dist/typings.js +0 -1
  66. package/dist/utils/aria.d.ts +0 -15
  67. package/dist/utils/aria.js +0 -16
  68. package/dist/utils/util.d.ts +0 -4
  69. package/dist/utils/util.js +0 -8
@@ -0,0 +1,1590 @@
1
+ import { Fragment as e, Teleport as t, Transition as n, computed as r, createVNode as i, customRef as a, defineComponent as o, getCurrentInstance as s, getCurrentScope as c, hasInjectionContext as l, inject as u, isRef as d, isVNode as f, mergeDefaults as p, mergeProps as m, nextTick as h, onMounted as g, onScopeDispose as _, onUnmounted as v, readonly as y, ref as b, shallowRef as x, toRef as S, toValue as C, unref as w, watch as T, watchEffect as E } from "vue";
2
+ import { CloseOutlined as D, CopyOutlined as O, DownloadOutlined as k, EyeOutlined as A, LeftOutlined as ee, LoadingOutlined as te, RightOutlined as ne, RotateLeftOutlined as j, RotateRightOutlined as M, SwapOutlined as N, ZoomInOutlined as P, ZoomOutOutlined as re } from "@antdv-next/icons";
3
+ import { proGenStyleHooks as ie, unit as F } from "@gx-design-vue/pro-provider";
4
+ import { useBaseConfig as ae } from "antdv-next/config-provider/context";
5
+ import oe from "antdv-next/config-provider/hooks/useCSSVarCls";
6
+ import { message as I } from "antdv-next";
7
+ //#region ../pro-utils/dist/is/type.js
8
+ function L(e, t) {
9
+ return Object.prototype.toString.call(e) === `[object ${t}]`;
10
+ }
11
+ function R(e) {
12
+ return typeof e == "boolean";
13
+ }
14
+ function se(e) {
15
+ return typeof e == "number";
16
+ }
17
+ function z(e) {
18
+ return Array.isArray === void 0 ? Object.prototype.toString.call(e) === "[object Array]" : Array.isArray(e);
19
+ }
20
+ function B(e) {
21
+ return e !== null && L(e, "Object");
22
+ }
23
+ function ce(e) {
24
+ return typeof e == "string";
25
+ }
26
+ //#endregion
27
+ //#region ../pro-utils/dist/is/server.js
28
+ var V = typeof window > "u", le = (e) => setTimeout(e, 16), H = (e) => clearTimeout(e);
29
+ typeof window < "u" && "requestAnimationFrame" in window && (le = (e) => window.requestAnimationFrame(e), H = (e) => window.cancelAnimationFrame(e));
30
+ var ue = 0, U = /* @__PURE__ */ new Map();
31
+ function W(e) {
32
+ U.delete(e);
33
+ }
34
+ function de(e, t = 1) {
35
+ ue += 1;
36
+ let n = ue;
37
+ function r(t) {
38
+ if (t === 0) W(n), e();
39
+ else {
40
+ let e = le(() => {
41
+ r(t - 1);
42
+ });
43
+ U.set(n, e);
44
+ }
45
+ }
46
+ return r(t), n;
47
+ }
48
+ de.cancel = (e) => {
49
+ let t = U.get(e);
50
+ return W(t), H(t);
51
+ };
52
+ //#endregion
53
+ //#region ../pro-utils/dist/dom/scroll.js
54
+ function fe(e) {
55
+ return e.replace(/[-_](.)/g, (e, t) => t.toUpperCase());
56
+ }
57
+ function G(e, t) {
58
+ if (V || !e || !t) return "";
59
+ t = fe(t), t === "float" && (t = "cssFloat");
60
+ try {
61
+ let n = e.style[t];
62
+ if (n) return n;
63
+ let r = document?.defaultView?.getComputedStyle(e, "");
64
+ return r ? r[t] : "";
65
+ } catch {
66
+ return e.style[t];
67
+ }
68
+ }
69
+ function pe(e, t) {
70
+ if (!V) return (t == null ? G(e, "overflow") : t ? G(e, "overflow-y") : G(e, "overflow-x")).match(/(scroll|auto|overlay)/);
71
+ }
72
+ function me(e, t) {
73
+ if (V) return;
74
+ let n = e;
75
+ for (; n;) {
76
+ if ([
77
+ window,
78
+ document,
79
+ document.documentElement
80
+ ].includes(n)) return window;
81
+ if (pe(n, t)) return n;
82
+ n = n.parentNode;
83
+ }
84
+ return n;
85
+ }
86
+ //#endregion
87
+ //#region ../pro-utils/dist/object/classNames.js
88
+ function K(...e) {
89
+ let t = [];
90
+ for (let n = 0; n < e.length; n++) {
91
+ let r = e[n];
92
+ if (r) {
93
+ if (ce(r)) t.push(r);
94
+ else if (z(r)) for (let e = 0; e < r.length; e++) {
95
+ let n = K(r[e]);
96
+ n && t.push(n);
97
+ }
98
+ else if (B(r)) for (let e in r) r[e] && t.push(e);
99
+ }
100
+ }
101
+ return t.filter((e) => e).join(" ");
102
+ }
103
+ //#endregion
104
+ //#region ../pro-utils/dist/slots/index.js
105
+ function he({ vnode: e, defaultVNode: t }, ...n) {
106
+ return e === !1 ? null : typeof e == "function" ? e?.(...n) : e || t;
107
+ }
108
+ function ge({ value: e, slotsValue: t, defaultVNode: n, render: r }) {
109
+ return e === !1 ? !1 : e === !0 ? t ?? n : B(e) && r ? f(e) ? e : t : e || t;
110
+ }
111
+ function _e(e, ...t) {
112
+ let { slots: n, key: r = "default", render: i, props: a, defaultChildren: o } = e, s = a[r], c = n?.[r], l = typeof o == "function" ? o?.() : o, u = ge({
113
+ value: s,
114
+ slotsValue: c,
115
+ defaultVNode: l,
116
+ render: i
117
+ });
118
+ return u === !1 ? !1 : i ? he({
119
+ vnode: u,
120
+ defaultVNode: l
121
+ }, ...t) : u;
122
+ }
123
+ function q(e, ...t) {
124
+ let { slots: n, key: r = "default", props: i, defaultChildren: a } = e, o = i[r], s = n?.[r]?.(...t), c = typeof a == "function" ? a?.() : a, l = ge({
125
+ value: o,
126
+ slotsValue: s,
127
+ defaultVNode: c,
128
+ render: !0
129
+ });
130
+ return l === !1 ? !1 : he({
131
+ vnode: l,
132
+ defaultVNode: c
133
+ }, ...t);
134
+ }
135
+ function ve(e, ...t) {
136
+ let { slots: n, props: r, keys: i, render: a, defaultVNodes: o } = e, s = {};
137
+ return i.forEach((e, i) => {
138
+ let c = o ? o[i] : null, l = a ? q({
139
+ slots: n,
140
+ props: r,
141
+ key: e,
142
+ defaultChildren: c
143
+ }, ...t) : _e({
144
+ slots: n,
145
+ props: r,
146
+ key: e,
147
+ render: !1,
148
+ defaultChildren: c
149
+ }, ...t);
150
+ (R(l) || l) && (s[e] = l);
151
+ }), s;
152
+ }
153
+ //#endregion
154
+ //#region ../../node_modules/.pnpm/@vueuse+shared@14.3.0_vue@3.5.27_typescript@6.0.3_/node_modules/@vueuse/shared/dist/index.js
155
+ function ye(e, t) {
156
+ return c() ? (_(e, t), !0) : !1;
157
+ }
158
+ var J = /* @__PURE__ */ new WeakMap(), be = (...e) => {
159
+ let t = e[0], n = s()?.proxy ?? c();
160
+ if (n == null && !l()) throw Error("injectLocal must be called in setup");
161
+ return n && J.has(n) && t in J.get(n) ? J.get(n)[t] : u(...e);
162
+ }, Y = typeof window < "u" && typeof document < "u";
163
+ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
164
+ var xe = Object.prototype.toString, Se = (e) => xe.call(e) === "[object Object]", Ce = () => {}, we = /* @__PURE__ */ Te();
165
+ function Te() {
166
+ var e, t;
167
+ return Y && !!(!((e = window) == null || (e = e.navigator) == null) && e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window) == null || (t = t.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
168
+ }
169
+ function Ee(...e) {
170
+ if (e.length !== 1) return S(...e);
171
+ let t = e[0];
172
+ return typeof t == "function" ? y(a(() => ({
173
+ get: t,
174
+ set: Ce
175
+ }))) : b(t);
176
+ }
177
+ function De(e, t) {
178
+ function n(...n) {
179
+ return new Promise((r, i) => {
180
+ Promise.resolve(e(() => t.apply(this, n), {
181
+ fn: t,
182
+ thisArg: this,
183
+ args: n
184
+ })).then(r).catch(i);
185
+ });
186
+ }
187
+ return n;
188
+ }
189
+ function Oe(...e) {
190
+ let t = 0, n, r = !0, i = Ce, a, o, s, c, l;
191
+ !d(e[0]) && typeof e[0] == "object" ? {delay: o, trailing: s = !0, leading: c = !0, rejectOnCancel: l = !1} = e[0] : [o, s = !0, c = !0, l = !1] = e;
192
+ let u = () => {
193
+ n && (clearTimeout(n), n = void 0, i(), i = Ce);
194
+ };
195
+ return (e) => {
196
+ let d = C(o), f = Date.now() - t, p = () => a = e();
197
+ return u(), d <= 0 ? (t = Date.now(), p()) : (f > d ? (t = Date.now(), (c || !r) && p()) : s && (a = new Promise((e, a) => {
198
+ i = l ? a : e, n = setTimeout(() => {
199
+ t = Date.now(), r = !0, e(p()), u();
200
+ }, Math.max(0, d - f));
201
+ })), !c && !n && (n = setTimeout(() => r = !0, d)), r = !1, a);
202
+ };
203
+ }
204
+ function ke(e) {
205
+ return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
206
+ }
207
+ function Ae(e) {
208
+ return Array.isArray(e) ? e : [e];
209
+ }
210
+ function je(e) {
211
+ return e || s();
212
+ }
213
+ function Me(e, t = 200, n = !1, r = !0, i = !1) {
214
+ return De(Oe(t, n, r, i), e);
215
+ }
216
+ function Ne(e, t = !0, n) {
217
+ je(n) ? g(e, n) : t ? e() : h(e);
218
+ }
219
+ function Pe(e, t, n) {
220
+ return T(e, t, {
221
+ ...n,
222
+ immediate: !0
223
+ });
224
+ }
225
+ //#endregion
226
+ //#region ../../node_modules/.pnpm/@vueuse+core@14.3.0_vue@3.5.27_typescript@6.0.3_/node_modules/@vueuse/core/dist/index.js
227
+ var Fe = Y ? window : void 0;
228
+ Y && window.document, Y && window.navigator, Y && window.location;
229
+ function Ie(e) {
230
+ let t = C(e);
231
+ return t?.$el ?? t;
232
+ }
233
+ function X(...e) {
234
+ let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = r(() => {
235
+ let t = Ae(C(e[0])).filter((e) => e != null);
236
+ return t.every((e) => typeof e != "string") ? t : void 0;
237
+ });
238
+ return Pe(() => [
239
+ n.value?.map((e) => Ie(e)) ?? [Fe].filter((e) => e != null),
240
+ Ae(C(n.value ? e[1] : e[0])),
241
+ Ae(w(n.value ? e[2] : e[1])),
242
+ C(n.value ? e[3] : e[2])
243
+ ], ([e, n, r, i], a, o) => {
244
+ if (!e?.length || !n?.length || !r?.length) return;
245
+ let s = Se(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
246
+ o(() => {
247
+ c.forEach((e) => e());
248
+ });
249
+ }, { flush: "post" });
250
+ }
251
+ function Le() {
252
+ let e = x(!1), t = s();
253
+ return t && g(() => {
254
+ e.value = !0;
255
+ }, t), e;
256
+ }
257
+ /* @__NO_SIDE_EFFECTS__ */
258
+ function Re(e) {
259
+ let t = Le();
260
+ return r(() => (t.value, !!e()));
261
+ }
262
+ var ze = Symbol("vueuse-ssr-width");
263
+ /* @__NO_SIDE_EFFECTS__ */
264
+ function Be() {
265
+ let e = l() ? be(ze, null) : null;
266
+ return typeof e == "number" ? e : void 0;
267
+ }
268
+ function Ve(e, t = {}) {
269
+ let { window: n = Fe, ssrWidth: i = /* @__PURE__ */ Be() } = t, a = /* @__PURE__ */ Re(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), o = x(typeof i == "number"), s = x(), c = x(!1);
270
+ return E(() => {
271
+ if (o.value) {
272
+ o.value = !a.value, c.value = C(e).split(",").some((e) => {
273
+ let t = e.includes("not all"), n = e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), r = e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), a = !!(n || r);
274
+ return n && a && (a = i >= ke(n[1])), r && a && (a = i <= ke(r[1])), t ? !a : a;
275
+ });
276
+ return;
277
+ }
278
+ a.value && (s.value = n.matchMedia(C(e)), c.value = s.value.matches);
279
+ }), X(s, "change", (e) => {
280
+ c.value = e.matches;
281
+ }, { passive: !0 }), r(() => c.value);
282
+ }
283
+ function He(e) {
284
+ return typeof Window < "u" && e instanceof Window ? e.document.documentElement : typeof Document < "u" && e instanceof Document ? e.documentElement : e;
285
+ }
286
+ function Ue(e) {
287
+ let t = window.getComputedStyle(e);
288
+ if (t.overflowX === "scroll" || t.overflowY === "scroll" || t.overflowX === "auto" && e.clientWidth < e.scrollWidth || t.overflowY === "auto" && e.clientHeight < e.scrollHeight) return !0;
289
+ {
290
+ let t = e.parentNode;
291
+ return !t || t.tagName === "BODY" ? !1 : Ue(t);
292
+ }
293
+ }
294
+ function We(e) {
295
+ let t = e || window.event, n = t.target;
296
+ return Ue(n) ? !1 : t.touches.length > 1 ? !0 : (t.preventDefault && t.preventDefault(), !1);
297
+ }
298
+ var Ge = /* @__PURE__ */ new WeakMap();
299
+ function Ke(e, t = !1) {
300
+ let n = x(t), i = null, a = "";
301
+ T(Ee(e), (e) => {
302
+ let t = He(C(e));
303
+ if (t) {
304
+ let e = t;
305
+ if (Ge.get(e) || Ge.set(e, e.style.overflow), e.style.overflow !== "hidden" && (a = e.style.overflow), e.style.overflow === "hidden") return n.value = !0;
306
+ if (n.value) return e.style.overflow = "hidden";
307
+ }
308
+ }, { immediate: !0 });
309
+ let o = () => {
310
+ let t = He(C(e));
311
+ !t || n.value || (we && (i = X(t, "touchmove", (e) => {
312
+ We(e);
313
+ }, { passive: !1 })), t.style.overflow = "hidden", n.value = !0);
314
+ }, s = () => {
315
+ let t = He(C(e));
316
+ !t || !n.value || (we && i?.(), t.style.overflow = a, Ge.delete(t), n.value = !1);
317
+ };
318
+ return ye(s), r({
319
+ get() {
320
+ return n.value;
321
+ },
322
+ set(e) {
323
+ e ? o() : s();
324
+ }
325
+ });
326
+ }
327
+ function qe(e = {}) {
328
+ let { window: t = Fe, initialWidth: n = Infinity, initialHeight: r = Infinity, listenOrientation: i = !0, includeScrollbar: a = !0, type: o = "inner" } = e, s = x(n), c = x(r), l = () => {
329
+ if (t) if (o === "outer") s.value = t.outerWidth, c.value = t.outerHeight;
330
+ else if (o === "visual" && t.visualViewport) {
331
+ let { width: e, height: n, scale: r } = t.visualViewport;
332
+ s.value = Math.round(e * r), c.value = Math.round(n * r);
333
+ } else a ? (s.value = t.innerWidth, c.value = t.innerHeight) : (s.value = t.document.documentElement.clientWidth, c.value = t.document.documentElement.clientHeight);
334
+ };
335
+ l(), Ne(l);
336
+ let u = { passive: !0 };
337
+ return X("resize", l, u), t && o === "visual" && t.visualViewport && X(t.visualViewport, "resize", l, u), i && T(Ve("(orientation: portrait)"), () => l()), {
338
+ width: s,
339
+ height: c
340
+ };
341
+ }
342
+ //#endregion
343
+ //#region src/hooks/useImagePreview.ts
344
+ function Je(e) {
345
+ let { canPreview: t } = e, n = b(!1), r = b(null), i = Ke(document.body, !1), a;
346
+ return _(() => {
347
+ a !== void 0 && (window.cancelAnimationFrame(a), a = void 0), i.value = !1;
348
+ }), X("wheel", (e) => {
349
+ n.value && e.ctrlKey && e.preventDefault();
350
+ }, { passive: !1 }), {
351
+ showViewer: n,
352
+ mousePosition: r,
353
+ openPreview: (e) => {
354
+ t.value && (a !== void 0 && (window.cancelAnimationFrame(a), a = void 0), e ? r.value = {
355
+ x: e.clientX,
356
+ y: e.clientY
357
+ } : r.value = null, n.value = !0, a = window.requestAnimationFrame(() => {
358
+ i.value = !0, a = void 0;
359
+ }));
360
+ },
361
+ closePreview: () => {
362
+ a !== void 0 && (window.cancelAnimationFrame(a), a = void 0), n.value = !1, r.value = null, i.value = !1;
363
+ }
364
+ };
365
+ }
366
+ //#endregion
367
+ //#region ../pro-hooks/dist/core/useIsIos.js
368
+ var Ye = (typeof window > "u" ? !1 : /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window.MSStream;
369
+ typeof window > "u" || Ye || window.safari;
370
+ //#endregion
371
+ //#region ../pro-hooks/dist/core/useState.js
372
+ function Xe(e) {
373
+ let t = b(typeof e == "function" ? e() : e);
374
+ function n(e) {
375
+ t.value = e;
376
+ }
377
+ return [t, n];
378
+ }
379
+ //#endregion
380
+ //#region ../pro-hooks/dist/core/useMergedState.js
381
+ function Ze(e, t) {
382
+ let { defaultValue: n, value: r = b() } = t || {}, i = typeof e == "function" ? e() : e;
383
+ r.value !== void 0 && (i = w(r)), n !== void 0 && (i = typeof n == "function" ? n() : n);
384
+ let a = b(i), o = b(i), [s, c] = Xe([o.value]), l = E(() => {
385
+ let e = r.value === void 0 ? a.value : r.value;
386
+ t?.postState && (e = t.postState(e, a.value)), o.value = e;
387
+ }), u = T(s, () => {
388
+ let e = s.value[0];
389
+ a.value !== e && t?.onChange?.(a.value, e);
390
+ }, { deep: !0 });
391
+ function d(e) {
392
+ a.value = e;
393
+ }
394
+ function f(e) {
395
+ d(e), c([o.value]);
396
+ }
397
+ let p = T(r, () => {
398
+ a.value = r.value;
399
+ });
400
+ return _(() => {
401
+ l(), u(), p();
402
+ }), [
403
+ o,
404
+ f,
405
+ a
406
+ ];
407
+ }
408
+ //#endregion
409
+ //#region src/hooks/useImageTransform.ts
410
+ var Qe = {
411
+ x: 0,
412
+ y: 0,
413
+ rotate: 0,
414
+ scale: 1,
415
+ flipX: !1,
416
+ flipY: !1
417
+ };
418
+ function $e(e) {
419
+ let { imageRef: t, minScale: n, maxScale: r, windowWidth: i, windowHeight: a, onTransform: o } = e, s = b(null), c = b([]), [l, u] = Xe({ ...Qe }), d = (e) => {
420
+ let t = { ...l.value };
421
+ u({ ...Qe }), (t.x !== 0 || t.y !== 0 || t.scale !== 1 || t.rotate !== 0 || t.flipX || t.flipY) && o?.({
422
+ transform: { ...Qe },
423
+ action: e
424
+ });
425
+ }, f = (e, t) => {
426
+ s.value === null && (c.value = [], s.value = de(() => {
427
+ let e = { ...l.value };
428
+ for (let t of c.value) e = {
429
+ ...e,
430
+ ...t
431
+ };
432
+ s.value = null, o?.({
433
+ transform: e,
434
+ action: t
435
+ }), u(e);
436
+ })), c.value.push({
437
+ ...l.value,
438
+ ...e
439
+ });
440
+ };
441
+ return {
442
+ transform: l,
443
+ resetTransform: d,
444
+ updateTransform: f,
445
+ dispatchZoomChange: (e, o, s, c, u) => {
446
+ let d = t.value;
447
+ if (!d) return;
448
+ let { width: p, height: m, offsetWidth: h, offsetHeight: g, offsetLeft: _, offsetTop: v } = d, y = e, b = l.value.scale * e;
449
+ b > r.value ? (b = r.value, y = r.value / l.value.scale) : b < n.value && (b = u ? b : n.value, y = b / l.value.scale);
450
+ let x = s ?? i.value / 2, S = c ?? a.value / 2, C = y - 1, w = C * p * .5, T = C * m * .5, E = C * (x - l.value.x - _), D = C * (S - l.value.y - v), O = l.value.x - (E - w), k = l.value.y - (D - T);
451
+ if (e < 1 && b === 1) {
452
+ let e = h * b, t = g * b;
453
+ e <= i.value && t <= a.value && (O = 0, k = 0);
454
+ }
455
+ f({
456
+ x: O,
457
+ y: k,
458
+ scale: b
459
+ }, o);
460
+ }
461
+ };
462
+ }
463
+ //#endregion
464
+ //#region src/hooks/useImageBoundary.ts
465
+ function et(e, t, n, r) {
466
+ let i = t + n, a = (n - r) / 2;
467
+ if (n > r) {
468
+ if (t > 0) return { [e]: a };
469
+ if (t < 0 && i < r) return { [e]: -a };
470
+ } else if (t < 0 || i > r) return { [e]: t < 0 ? a : -a };
471
+ return {};
472
+ }
473
+ function tt(e) {
474
+ let { imageWidth: t, imageHeight: n, imageLeft: r, imageTop: i, windowWidth: a, windowHeight: o } = e;
475
+ return t <= a && n <= o ? {
476
+ x: 0,
477
+ y: 0
478
+ } : t > a || n > o ? {
479
+ ...et("x", r, t, a),
480
+ ...et("y", i, n, o)
481
+ } : null;
482
+ }
483
+ //#endregion
484
+ //#region src/hooks/useMouseEvent.ts
485
+ var nt = 1, rt = 2;
486
+ function it(e) {
487
+ let { imageRef: t, movable: n, visible: r, scaleStep: i, transform: a, updateTransform: o, dispatchZoomChange: s, windowWidth: c, windowHeight: l } = e, u = b(!1), d = b({
488
+ diffX: 0,
489
+ diffY: 0,
490
+ transformX: 0,
491
+ transformY: 0
492
+ });
493
+ return X(window, "mouseup", () => {
494
+ if (!r.value || !u.value) return;
495
+ u.value = !1;
496
+ let { transformX: e, transformY: n } = d.value;
497
+ if (!(a.value.x !== e && a.value.y !== n)) return;
498
+ let i = t.value;
499
+ if (!i) return;
500
+ let s = i.offsetWidth * a.value.scale, f = i.offsetHeight * a.value.scale, { left: p, top: m } = i.getBoundingClientRect(), h = a.value.rotate % 180 != 0, g = tt({
501
+ imageWidth: h ? f : s,
502
+ imageHeight: h ? s : f,
503
+ imageLeft: p,
504
+ imageTop: m,
505
+ windowWidth: c.value,
506
+ windowHeight: l.value
507
+ });
508
+ g && o({ ...g }, "dragRebound");
509
+ }), X(window, "mousemove", (e) => {
510
+ !r.value || !u.value || o({
511
+ x: e.pageX - d.value.diffX,
512
+ y: e.pageY - d.value.diffY
513
+ }, "move");
514
+ }), {
515
+ isMoving: u,
516
+ onMouseDown: (e) => {
517
+ !n.value || e.button !== 0 || (e.preventDefault(), e.stopPropagation(), d.value = {
518
+ diffX: e.pageX - a.value.x,
519
+ diffY: e.pageY - a.value.y,
520
+ transformX: a.value.x,
521
+ transformY: a.value.y
522
+ }, u.value = !0);
523
+ },
524
+ onWheel: (e) => {
525
+ if (!r.value || e.deltaY === 0) return;
526
+ let t = nt + Math.min(Math.abs(e.deltaY / 100), rt) * i.value;
527
+ e.deltaY > 0 && (t = nt / t), s(t, "wheel", e.clientX, e.clientY);
528
+ }
529
+ };
530
+ }
531
+ //#endregion
532
+ //#region src/hooks/useTouchEvent.ts
533
+ function at(e, t) {
534
+ return Math.hypot(e.x - t.x, e.y - t.y);
535
+ }
536
+ function ot(e, t, n, r) {
537
+ let i = at(e, n), a = at(t, r);
538
+ if (i === 0 && a === 0) return [e.x, e.y];
539
+ let o = i / (i + a);
540
+ return [e.x + o * (t.x - e.x), e.y + o * (t.y - e.y)];
541
+ }
542
+ function st(e) {
543
+ let { imageRef: t, movable: n, visible: r, minScale: i, transform: a, updateTransform: o, dispatchZoomChange: s, windowWidth: c, windowHeight: l } = e, u = b(!1), d = b({
544
+ point1: {
545
+ x: 0,
546
+ y: 0
547
+ },
548
+ point2: {
549
+ x: 0,
550
+ y: 0
551
+ },
552
+ eventType: "none"
553
+ }), f = (e) => {
554
+ d.value = {
555
+ ...d.value,
556
+ ...e
557
+ };
558
+ };
559
+ return X(window, "touchmove", (e) => {
560
+ r.value && n.value && e.preventDefault();
561
+ }, { passive: !1 }), {
562
+ isTouching: u,
563
+ onTouchStart: (e) => {
564
+ if (!n.value) return;
565
+ e.stopPropagation(), u.value = !0;
566
+ let { touches: t = [] } = e;
567
+ t.length > 1 ? f({
568
+ point1: {
569
+ x: t[0].clientX,
570
+ y: t[0].clientY
571
+ },
572
+ point2: {
573
+ x: t[1].clientX,
574
+ y: t[1].clientY
575
+ },
576
+ eventType: "touchZoom"
577
+ }) : f({
578
+ point1: {
579
+ x: t[0].clientX - a.value.x,
580
+ y: t[0].clientY - a.value.y
581
+ },
582
+ eventType: "move"
583
+ });
584
+ },
585
+ onTouchMove: (e) => {
586
+ let { touches: t = [] } = e, { point1: n, point2: r, eventType: i } = d.value;
587
+ if (t.length > 1 && i === "touchZoom") {
588
+ let e = {
589
+ x: t[0].clientX,
590
+ y: t[0].clientY
591
+ }, i = {
592
+ x: t[1].clientX,
593
+ y: t[1].clientY
594
+ }, [a, o] = ot(n, r, e, i);
595
+ s(at(e, i) / at(n, r), "touchZoom", a, o, !0), f({
596
+ point1: e,
597
+ point2: i,
598
+ eventType: "touchZoom"
599
+ });
600
+ } else i === "move" && (o({
601
+ x: t[0].clientX - n.x,
602
+ y: t[0].clientY - n.y
603
+ }, "move"), f({ eventType: "move" }));
604
+ },
605
+ onTouchEnd: () => {
606
+ if (!r.value) return;
607
+ if (u.value &&= !1, f({ eventType: "none" }), i.value > a.value.scale) return o({
608
+ x: 0,
609
+ y: 0,
610
+ scale: i.value
611
+ }, "touchZoom");
612
+ let e = t.value;
613
+ if (!e) return;
614
+ let n = e.offsetWidth * a.value.scale, s = e.offsetHeight * a.value.scale, { left: d, top: p } = e.getBoundingClientRect(), m = a.value.rotate % 180 != 0, h = tt({
615
+ imageWidth: m ? s : n,
616
+ imageHeight: m ? n : s,
617
+ imageLeft: d,
618
+ imageTop: p,
619
+ windowWidth: c.value,
620
+ windowHeight: l.value
621
+ });
622
+ h && o({ ...h }, "dragRebound");
623
+ }
624
+ };
625
+ }
626
+ //#endregion
627
+ //#region src/style/preview.ts
628
+ function ct(e) {
629
+ return {
630
+ zIndexPopup: `calc(${e.zIndexPopupBase} + 80)`,
631
+ previewOperationColor: e.colorTextDescription,
632
+ previewOperationHoverColor: e.colorText,
633
+ previewOperationColorDisabled: e.colorTextDisabled,
634
+ imagePreviewSwitchSize: e.controlHeightLG,
635
+ previewOperationSize: e.fontSizeLG
636
+ };
637
+ }
638
+ var lt = (e) => {
639
+ let t = e.componentCls, { motionEaseOut: n, motionDurationSlow: r, previewOperationSize: i, zIndexPopup: a } = e, o = {
640
+ position: "absolute",
641
+ color: e.previewOperationColor,
642
+ backgroundColor: e.colorBgContainer,
643
+ borderRadius: "50%",
644
+ width: e.controlHeightLG,
645
+ height: e.controlHeightLG,
646
+ padding: 0,
647
+ outline: 0,
648
+ border: 0,
649
+ boxShadow: e.boxShadowTertiary,
650
+ cursor: "pointer",
651
+ transition: `all ${r}`,
652
+ display: "flex",
653
+ alignItems: "center",
654
+ justifyContent: "center",
655
+ fontSize: i,
656
+ "&:hover": {
657
+ color: e.previewOperationHoverColor,
658
+ backgroundColor: e.colorBgContainer
659
+ },
660
+ "&:active": { backgroundColor: e.colorBgContainer },
661
+ svg: { stroke: "currentColor" }
662
+ };
663
+ return { [t]: {
664
+ textAlign: "center",
665
+ inset: 0,
666
+ position: "fixed",
667
+ userSelect: "none",
668
+ zIndex: a,
669
+ [`${t}-mask`]: {
670
+ position: "absolute",
671
+ inset: 0,
672
+ background: `color-mix(in srgb, ${e.colorBgLayout} 90%, transparent)`,
673
+ backdropFilter: "blur(0px)",
674
+ transition: `background-color ${r}, backdrop-filter ${r}`,
675
+ [`&${t}-mask-blur`]: { backdropFilter: "blur(4px)" },
676
+ [`&${t}-mask-hidden`]: { display: "none" }
677
+ },
678
+ [`${t}-body`]: {
679
+ position: "absolute",
680
+ inset: 0,
681
+ overflow: "hidden",
682
+ display: "flex",
683
+ alignItems: "center",
684
+ justifyContent: "center",
685
+ pointerEvents: "none",
686
+ "> *": { pointerEvents: "auto" }
687
+ },
688
+ [`${t}-img`]: {
689
+ maxWidth: "100%",
690
+ maxHeight: "70%",
691
+ verticalAlign: "middle",
692
+ transform: "scale3d(1, 1, 1)",
693
+ transition: `transform ${r} ${n} 0s`,
694
+ userSelect: "none"
695
+ },
696
+ [`&-movable ${t}-img`]: { cursor: "grab" },
697
+ [`&-moving ${t}-img`]: { cursor: "grabbing" },
698
+ [`${t}-close`]: {
699
+ ...o,
700
+ top: e.marginSM,
701
+ insetInlineEnd: e.marginSM
702
+ },
703
+ [`${t}-switch`]: {
704
+ ...o,
705
+ top: "50%",
706
+ transform: "translateY(-50%)",
707
+ "&-disabled": { "&, &:hover, &:active": {
708
+ color: e.previewOperationColorDisabled,
709
+ backgroundColor: e.colorBgContainer,
710
+ cursor: "not-allowed"
711
+ } },
712
+ "&-prev": { insetInlineStart: e.marginSM },
713
+ "&-next": { insetInlineEnd: e.marginSM }
714
+ },
715
+ [`${t}-footer`]: {
716
+ position: "absolute",
717
+ bottom: e.marginXL,
718
+ left: {
719
+ _skip_check_: !0,
720
+ value: "50%"
721
+ },
722
+ display: "flex",
723
+ flexDirection: "column",
724
+ alignItems: "center",
725
+ color: e.previewOperationColor,
726
+ transform: "translateX(-50%)",
727
+ gap: e.marginXS
728
+ },
729
+ [`${t}-progress`]: { color: e.previewOperationColor },
730
+ [`${t}-actions`]: {
731
+ display: "flex",
732
+ alignItems: "center",
733
+ gap: e.marginXXS,
734
+ padding: e.paddingXXS,
735
+ color: e.previewOperationColor,
736
+ backgroundColor: e.colorBgContainer,
737
+ border: `${F(e.lineWidth)} ${e.lineType} ${e.colorFillTertiary}`,
738
+ borderRadius: e.borderRadiusLG,
739
+ fontSize: i,
740
+ "&-action": {
741
+ color: "inherit",
742
+ background: "transparent",
743
+ border: 0,
744
+ font: "inherit",
745
+ lineHeight: 1,
746
+ width: e.controlHeight,
747
+ height: e.controlHeight,
748
+ padding: 0,
749
+ cursor: "pointer",
750
+ transition: `all ${r}`,
751
+ display: "flex",
752
+ alignItems: "center",
753
+ justifyContent: "center",
754
+ borderRadius: e.borderRadius,
755
+ userSelect: "none",
756
+ [`&:not(${t}-actions-action-disabled):hover`]: {
757
+ color: e.colorTextSecondary,
758
+ backgroundColor: e.colorFillTertiary
759
+ },
760
+ [`&:not(${t}-actions-action-disabled):active`]: {
761
+ color: e.colorText,
762
+ backgroundColor: e.colorFillSecondary
763
+ },
764
+ "&-disabled": {
765
+ cursor: "not-allowed",
766
+ opacity: .5
767
+ },
768
+ svg: { stroke: "currentColor" }
769
+ }
770
+ }
771
+ } };
772
+ }, ut = (e) => {
773
+ let t = e.componentCls, { motionDurationSlow: n, motionEaseOut: r } = e;
774
+ return { [`${t}`]: {
775
+ "&-fade-enter-active, &-fade-leave-active": {
776
+ transition: `visibility ${n}`,
777
+ [`${t}-mask`]: { transition: `background-color ${n}, backdrop-filter ${n}` },
778
+ [`${t}-body`]: { transition: `transform ${n} ${r}` },
779
+ [`${t}-close, ${t}-switch, ${t}-footer`]: { transition: `opacity ${n}, all ${n}` }
780
+ },
781
+ "&-fade-enter-from, &-fade-leave-to": {
782
+ visibility: "visible",
783
+ [`${t}-mask`]: {
784
+ backgroundColor: "transparent",
785
+ backdropFilter: "blur(0px)"
786
+ },
787
+ [`${t}-body`]: { transform: "scale(0)" },
788
+ [`${t}-close, ${t}-switch, ${t}-footer`]: { opacity: 0 }
789
+ },
790
+ "&-fade-enter-to, &-fade-leave-from": {
791
+ [`${t}-mask`]: {
792
+ backgroundColor: `color-mix(in srgb, ${e.colorBgLayout} 90%, transparent)`,
793
+ [`&${t}-mask-blur`]: { backdropFilter: "blur(4px)" }
794
+ },
795
+ [`${t}-close, ${t}-switch, ${t}-footer`]: { opacity: 1 }
796
+ }
797
+ } };
798
+ }, dt = ie("GImagePreview", (e) => [lt(e), ut(e)], ct), ft = 1, Z = {
799
+ rotateLeft: i(j, null, null),
800
+ rotateRight: i(M, null, null),
801
+ zoomIn: i(P, null, null),
802
+ zoomOut: i(re, null, null),
803
+ flipX: i(N, null, null),
804
+ flipY: i(N, { rotate: 90 }, null),
805
+ copy: i(O, null, null),
806
+ download: i(k, null, null)
807
+ }, Q = {
808
+ copySuccess: "复制成功",
809
+ copyFailed: "复制失败",
810
+ downloadSuccess: "下载成功",
811
+ downloadFailed: "下载失败"
812
+ };
813
+ function pt(e) {
814
+ try {
815
+ let t = new URL(e, window.location.href).pathname.match(/\/([^/]+)$/)?.[1];
816
+ return t ? decodeURIComponent(t) : "image";
817
+ } catch {
818
+ let t = e.split("?")[0]?.split("#")[0]?.split("/").pop();
819
+ return t ? decodeURIComponent(t) : "image";
820
+ }
821
+ }
822
+ function mt(e) {
823
+ let t = {
824
+ "image/gif": "gif",
825
+ "image/jpg": "jpg",
826
+ "image/jpeg": "jpg",
827
+ "image/png": "png",
828
+ "image/svg+xml": "svg",
829
+ "image/webp": "webp"
830
+ }, n = e?.toLowerCase();
831
+ return t[n] || n?.split("/")[1]?.split("+")[0] || "png";
832
+ }
833
+ async function ht(e) {
834
+ let t = await fetch(e, { mode: "cors" });
835
+ if (!t.ok) throw Error(`Failed to fetch image: ${t.status}`);
836
+ return t.blob();
837
+ }
838
+ async function gt(e) {
839
+ return new Promise((t, n) => {
840
+ let r = new Image(), i = URL.createObjectURL(e);
841
+ r.onload = () => {
842
+ URL.revokeObjectURL(i);
843
+ let e = document.createElement("canvas");
844
+ e.width = r.naturalWidth, e.height = r.naturalHeight;
845
+ let a = e.getContext("2d");
846
+ if (!a) {
847
+ n(/* @__PURE__ */ Error("Canvas context not available"));
848
+ return;
849
+ }
850
+ a.drawImage(r, 0, 0), e.toBlob((e) => {
851
+ e ? t(e) : n(/* @__PURE__ */ Error("Failed to convert to PNG"));
852
+ }, "image/png", 1);
853
+ }, r.onerror = () => {
854
+ URL.revokeObjectURL(i), n(/* @__PURE__ */ Error("Failed to load image for PNG conversion"));
855
+ }, r.src = i;
856
+ });
857
+ }
858
+ async function _t(e) {
859
+ let t = (e.type || "").toLowerCase();
860
+ return t === "image/png" || t === "image/svg+xml" ? { [t]: e } : { "image/png": await gt(e) };
861
+ }
862
+ function vt(e, t) {
863
+ let n = pt(e);
864
+ return n.includes(".") ? n.endsWith(".svg+xml") ? n.replace(/\.svg\+xml$/i, ".svg") : n : `${n}.${mt(t)}`;
865
+ }
866
+ function yt(e, t) {
867
+ let n = URL.createObjectURL(e), r = document.createElement("a");
868
+ r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), r.remove(), URL.revokeObjectURL(n);
869
+ }
870
+ var bt = /* @__PURE__ */ o((a, { emit: o, slots: s, expose: c }) => {
871
+ let { width: l, height: u } = qe(), { prefixCls: d } = ae("pro-image-preview", a), f = oe(d), [p, m] = dt(d, f), [_, y] = Ze(a.open, {
872
+ value: S(a, "open"),
873
+ onChange: (e) => {
874
+ a.onOpenChange?.(e), o("update:open", e);
875
+ }
876
+ }), x = b(!0), C = b(), w = b(), E = b(a.current ?? 0), O = b(!1), k = b(!1), { transform: A, resetTransform: j, updateTransform: M, dispatchZoomChange: N } = $e({
877
+ imageRef: C,
878
+ minScale: S(a, "minScale"),
879
+ maxScale: S(a, "maxScale"),
880
+ windowWidth: l,
881
+ windowHeight: u,
882
+ onTransform: a.onTransform
883
+ }), { isMoving: P, onMouseDown: re, onWheel: ie } = it({
884
+ imageRef: C,
885
+ movable: S(a, "movable"),
886
+ visible: _,
887
+ scaleStep: S(a, "scaleStep"),
888
+ transform: A,
889
+ updateTransform: M,
890
+ dispatchZoomChange: N,
891
+ windowWidth: l,
892
+ windowHeight: u
893
+ }), { isTouching: F, onTouchStart: L, onTouchMove: R, onTouchEnd: se } = st({
894
+ imageRef: C,
895
+ movable: S(a, "movable"),
896
+ visible: _,
897
+ minScale: S(a, "minScale"),
898
+ transform: A,
899
+ updateTransform: M,
900
+ dispatchZoomChange: N,
901
+ windowWidth: l,
902
+ windowHeight: u
903
+ }), z = r(() => a.urls[E.value]), B = r(() => a.urls.length > 1), ce = r(() => a.urls.length >= 1), V = r(() => a.mask === !1 ? {
904
+ visible: !1,
905
+ blur: !1
906
+ } : a.mask && typeof a.mask == "object" && !("type" in a.mask) ? {
907
+ visible: !0,
908
+ blur: a.mask.blur !== !1
909
+ } : {
910
+ visible: !0,
911
+ blur: !0
912
+ }), le = r(() => {
913
+ let e = {};
914
+ return a.mousePosition && (e.transformOrigin = `${a.mousePosition.x}px ${a.mousePosition.y}px`), e;
915
+ });
916
+ T(() => a.current, (e) => {
917
+ e !== void 0 && (E.value = e);
918
+ }), T(() => a.current, (e) => {
919
+ e !== void 0 && (E.value = e);
920
+ });
921
+ let H = () => {
922
+ y(!1), a.onClose?.(), o("close");
923
+ }, ue = () => {
924
+ P.value || H();
925
+ }, U = () => {
926
+ if (E.value > 0 || a.infinite) {
927
+ let e = E.value - 1 < 0 ? a.urls.length - 1 : E.value - 1;
928
+ x.value = !1, E.value = e, j("prev"), h(() => {
929
+ x.value = !0;
930
+ });
931
+ }
932
+ }, W = () => {
933
+ if (E.value < a.urls.length - 1 || a.infinite) {
934
+ let e = E.value + 1 > a.urls.length - 1 ? 0 : E.value + 1;
935
+ x.value = !1, E.value = e, j("next"), h(() => {
936
+ x.value = !0;
937
+ });
938
+ }
939
+ }, de = () => {
940
+ N(ft + (a.scaleStep ?? .5), "zoomIn");
941
+ }, fe = () => {
942
+ N(ft / (ft + (a.scaleStep ?? .5)), "zoomOut");
943
+ }, G = () => {
944
+ M({ rotate: A.value.rotate + 90 }, "rotateRight");
945
+ }, pe = () => {
946
+ M({ rotate: A.value.rotate - 90 }, "rotateLeft");
947
+ }, me = () => {
948
+ M({ flipX: !A.value.flipX }, "flipX");
949
+ }, he = () => {
950
+ M({ flipY: !A.value.flipY }, "flipY");
951
+ }, ge = async () => {
952
+ if (!(!z.value || O.value)) {
953
+ if (!navigator.clipboard || !window.ClipboardItem) {
954
+ I.error(Q.copyFailed);
955
+ return;
956
+ }
957
+ O.value = !0;
958
+ try {
959
+ let e = await _t(await ht(z.value));
960
+ await navigator.clipboard.write([new ClipboardItem(e)]), I.success(Q.copySuccess);
961
+ } catch {
962
+ I.error(Q.copyFailed);
963
+ } finally {
964
+ O.value = !1;
965
+ }
966
+ }
967
+ }, _e = async () => {
968
+ if (!(!z.value || k.value)) {
969
+ k.value = !0;
970
+ try {
971
+ let e = await ht(z.value);
972
+ yt(e, vt(z.value, e.type)), I.success(Q.downloadSuccess);
973
+ } catch {
974
+ I.error(Q.downloadFailed);
975
+ } finally {
976
+ k.value = !1;
977
+ }
978
+ }
979
+ }, ye = (e) => {
980
+ _.value && (A.value.scale === 1 ? N(ft + (a.scaleStep ?? .5), "doubleClick", e.clientX, e.clientY) : M({
981
+ x: 0,
982
+ y: 0,
983
+ scale: 1
984
+ }, "doubleClick"));
985
+ }, J = (e) => {
986
+ if (e.key === "Escape") {
987
+ H();
988
+ return;
989
+ }
990
+ !_.value || !B.value || (e.key === "ArrowLeft" ? U() : e.key === "ArrowRight" && W());
991
+ }, be;
992
+ g(() => {
993
+ let e = (e) => J(e);
994
+ window.addEventListener("keydown", e), be = () => window.removeEventListener("keydown", e);
995
+ }), v(() => {
996
+ be?.();
997
+ }), c({ setOpen: (e) => {
998
+ y(e), E.value = a.current ?? 0;
999
+ } });
1000
+ let Y = () => ve({
1001
+ slots: s,
1002
+ props: { ...a.icons },
1003
+ keys: [
1004
+ "flipY",
1005
+ "flipX",
1006
+ "rotateLeft",
1007
+ "rotateRight",
1008
+ "zoomOut",
1009
+ "zoomIn",
1010
+ "copy",
1011
+ "download"
1012
+ ],
1013
+ render: !0,
1014
+ defaultVNodes: [
1015
+ Z.flipY,
1016
+ Z.flipX,
1017
+ Z.rotateLeft,
1018
+ Z.rotateRight,
1019
+ Z.zoomOut,
1020
+ Z.zoomIn,
1021
+ Z.copy,
1022
+ Z.download
1023
+ ]
1024
+ }), xe = () => {
1025
+ let e = Y();
1026
+ return [
1027
+ {
1028
+ icon: e.flipY,
1029
+ onClick: he,
1030
+ type: "flipY"
1031
+ },
1032
+ {
1033
+ icon: e.flipX,
1034
+ onClick: me,
1035
+ type: "flipX"
1036
+ },
1037
+ {
1038
+ icon: e.rotateLeft,
1039
+ onClick: pe,
1040
+ type: "rotateLeft"
1041
+ },
1042
+ {
1043
+ icon: e.rotateRight,
1044
+ onClick: G,
1045
+ type: "rotateRight"
1046
+ },
1047
+ {
1048
+ icon: e.zoomOut,
1049
+ onClick: fe,
1050
+ type: "zoomOut",
1051
+ disabled: r(() => A.value.scale <= (a.minScale ?? 1))
1052
+ },
1053
+ {
1054
+ icon: e.zoomIn,
1055
+ onClick: de,
1056
+ type: "zoomIn",
1057
+ disabled: r(() => A.value.scale === (a.maxScale ?? 50))
1058
+ },
1059
+ {
1060
+ icon: O.value ? i(te, { spin: !0 }, null) : e.copy,
1061
+ onClick: ge,
1062
+ type: "copy",
1063
+ disabled: r(() => O.value)
1064
+ },
1065
+ {
1066
+ icon: k.value ? i(te, { spin: !0 }, null) : e.download,
1067
+ onClick: _e,
1068
+ type: "download",
1069
+ disabled: r(() => k.value)
1070
+ }
1071
+ ];
1072
+ };
1073
+ return () => {
1074
+ let r = {
1075
+ transform: `translate3d(${A.value.x}px, ${A.value.y}px, 0) scale3d(${A.value.flipX ? "-" : ""}${A.value.scale}, ${A.value.flipY ? "-" : ""}${A.value.scale}, 1) rotate(${A.value.rotate}deg)`,
1076
+ transitionDuration: !x.value || F.value ? "0s" : void 0
1077
+ }, o = q({
1078
+ slots: s,
1079
+ props: { close: a.icons?.close },
1080
+ key: "close"
1081
+ }), c = q({
1082
+ slots: s,
1083
+ props: { left: a.icons?.left },
1084
+ key: "left"
1085
+ }), l = q({
1086
+ slots: s,
1087
+ props: { right: a.icons?.right },
1088
+ key: "right"
1089
+ }), u = `${d.value}-actions-action`, h = xe();
1090
+ return i(t, { to: a.getContainer || "body" }, { default: () => [i(n, {
1091
+ name: `${d.value}-fade`,
1092
+ appear: !0,
1093
+ onAfterLeave: () => j("close")
1094
+ }, { default: () => [_.value && i("div", {
1095
+ ref: w,
1096
+ class: K(d.value, p.value, m.value, f.value, {
1097
+ [`${d.value}-movable`]: a.movable,
1098
+ [`${d.value}-moving`]: P.value
1099
+ }),
1100
+ style: { zIndex: a.zIndex },
1101
+ role: "dialog",
1102
+ "aria-modal": "true",
1103
+ "aria-label": "Image",
1104
+ tabindex: -1
1105
+ }, [
1106
+ V.value.visible && i("div", {
1107
+ class: K(`${d.value}-mask`, a.maskClass, { [`${d.value}-mask-blur`]: V.value.blur }),
1108
+ onClick: a.onHideOnClickModal ? ue : void 0
1109
+ }, null),
1110
+ i("div", {
1111
+ class: `${d.value}-body`,
1112
+ style: le.value
1113
+ }, [i("img", {
1114
+ ref: C,
1115
+ class: `${d.value}-img`,
1116
+ src: z.value,
1117
+ alt: "Image",
1118
+ loading: "eager",
1119
+ decoding: "sync",
1120
+ style: r,
1121
+ onWheel: ie,
1122
+ onMousedown: re,
1123
+ onDblclick: ye,
1124
+ onTouchstart: L,
1125
+ onTouchmove: R,
1126
+ onTouchend: se,
1127
+ onTouchcancel: se
1128
+ }, null)]),
1129
+ i("button", {
1130
+ type: "button",
1131
+ class: `${d.value}-close`,
1132
+ onClick: H
1133
+ }, [o || i(D, null, null)]),
1134
+ B.value && i(e, null, [i("button", {
1135
+ type: "button",
1136
+ class: K(`${d.value}-switch`, `${d.value}-switch-prev`, { [`${d.value}-switch-disabled`]: !a.infinite && E.value === 0 }),
1137
+ onClick: (e) => {
1138
+ e.preventDefault(), e.stopPropagation(), U();
1139
+ }
1140
+ }, [c || i(ee, null, null)]), i("button", {
1141
+ type: "button",
1142
+ class: K(`${d.value}-switch`, `${d.value}-switch-next`, { [`${d.value}-switch-disabled`]: !a.infinite && E.value === a.urls.length - 1 }),
1143
+ onClick: (e) => {
1144
+ e.preventDefault(), e.stopPropagation(), W();
1145
+ }
1146
+ }, [l || i(ne, null, null)])]),
1147
+ i("div", { class: `${d.value}-footer` }, [ce.value && i("div", { class: `${d.value}-progress` }, [a.countRender ? a.countRender(E.value + 1, a.urls.length) : `${E.value + 1} / ${a.urls.length}`]), i("div", { class: `${d.value}-actions` }, [h.map(({ icon: e, onClick: t, type: n, disabled: r }) => i("button", {
1148
+ type: "button",
1149
+ class: K(u, `${u}-${n}`, { [`${u}-disabled`]: r && r.value }),
1150
+ onClick: () => {
1151
+ r?.value || t();
1152
+ },
1153
+ disabled: r ? r.value : !1,
1154
+ "aria-label": n,
1155
+ key: n
1156
+ }, [e]))])])
1157
+ ])] })] });
1158
+ };
1159
+ }, {
1160
+ props: /* @__PURE__ */ p({
1161
+ class: {
1162
+ type: String,
1163
+ required: !1
1164
+ },
1165
+ style: {
1166
+ type: Object,
1167
+ required: !1
1168
+ },
1169
+ rootClass: {
1170
+ type: String,
1171
+ required: !1
1172
+ },
1173
+ prefixCls: {
1174
+ type: String,
1175
+ required: !1
1176
+ },
1177
+ urls: {
1178
+ type: Array,
1179
+ required: !0
1180
+ },
1181
+ open: {
1182
+ type: Boolean,
1183
+ required: !1,
1184
+ default: void 0
1185
+ },
1186
+ scaleStep: {
1187
+ type: Number,
1188
+ required: !1
1189
+ },
1190
+ minScale: {
1191
+ type: Number,
1192
+ required: !1
1193
+ },
1194
+ maxScale: {
1195
+ type: Number,
1196
+ required: !1
1197
+ },
1198
+ movable: {
1199
+ type: Boolean,
1200
+ required: !1,
1201
+ default: void 0
1202
+ },
1203
+ disabled: {
1204
+ type: Boolean,
1205
+ required: !1,
1206
+ default: void 0
1207
+ },
1208
+ zIndex: {
1209
+ type: Number,
1210
+ required: !1
1211
+ },
1212
+ current: {
1213
+ type: Number,
1214
+ required: !1
1215
+ },
1216
+ infinite: {
1217
+ type: Boolean,
1218
+ required: !1,
1219
+ default: void 0
1220
+ },
1221
+ getContainer: {
1222
+ type: String,
1223
+ required: !1
1224
+ },
1225
+ onHideOnClickModal: {
1226
+ type: Boolean,
1227
+ required: !1,
1228
+ default: void 0
1229
+ },
1230
+ mask: {
1231
+ type: [Object, Boolean],
1232
+ required: !1,
1233
+ default: void 0
1234
+ },
1235
+ maskClass: {
1236
+ type: String,
1237
+ required: !1
1238
+ },
1239
+ mousePosition: {
1240
+ type: [Object, null],
1241
+ required: !1
1242
+ },
1243
+ countRender: {
1244
+ type: [Function, Boolean],
1245
+ required: !1,
1246
+ default: void 0
1247
+ },
1248
+ icons: {
1249
+ type: Object,
1250
+ required: !1
1251
+ },
1252
+ onClose: {
1253
+ type: Function,
1254
+ required: !1
1255
+ },
1256
+ onTransform: {
1257
+ type: Function,
1258
+ required: !1
1259
+ },
1260
+ onOpenChange: {
1261
+ type: Function,
1262
+ required: !1
1263
+ },
1264
+ "onUpdate:open": {
1265
+ type: Function,
1266
+ required: !1
1267
+ }
1268
+ }, {
1269
+ open: !1,
1270
+ scaleStep: .5,
1271
+ minScale: 1,
1272
+ maxScale: 50,
1273
+ movable: !0,
1274
+ zIndex: 2e3,
1275
+ current: 0,
1276
+ infinite: !0,
1277
+ onHideOnClickModal: !0,
1278
+ urls: [],
1279
+ icons: {}
1280
+ }),
1281
+ emits: [
1282
+ "close",
1283
+ "transform",
1284
+ "update:open"
1285
+ ],
1286
+ name: "GImagePreview",
1287
+ inheritAttrs: !1
1288
+ }), xt = (e) => {
1289
+ let { motionDurationSlow: t, paddingXXS: n, marginXXS: r, colorTextLightSolid: i } = e;
1290
+ return {
1291
+ position: "absolute",
1292
+ inset: 0,
1293
+ display: "flex",
1294
+ alignItems: "center",
1295
+ justifyContent: "center",
1296
+ color: i,
1297
+ background: "rgba(0, 0, 0, 0.5)",
1298
+ cursor: "pointer",
1299
+ opacity: 0,
1300
+ transition: `opacity ${t}`,
1301
+ [`.${e.componentCls}-mask-info`]: {
1302
+ overflow: "hidden",
1303
+ whiteSpace: "nowrap",
1304
+ textOverflow: "ellipsis",
1305
+ padding: `0 ${F(n)}`,
1306
+ ".anticon": {
1307
+ marginInlineEnd: r,
1308
+ svg: { verticalAlign: "baseline" }
1309
+ }
1310
+ }
1311
+ };
1312
+ }, St = (e) => {
1313
+ let t = {
1314
+ width: "100%",
1315
+ height: "100%"
1316
+ };
1317
+ return { [e.componentCls]: {
1318
+ display: "inline-block",
1319
+ position: "relative",
1320
+ overflow: "hidden",
1321
+ [`${e.componentCls}-img`]: {
1322
+ ...t,
1323
+ verticalAlign: "top",
1324
+ opacity: 1,
1325
+ [`&${e.componentCls}-img-preview`]: {
1326
+ userSelect: "none",
1327
+ cursor: "pointer"
1328
+ },
1329
+ "&-placeholder": {
1330
+ ...t,
1331
+ backgroundColor: e.colorBgContainerDisabled,
1332
+ backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
1333
+ backgroundRepeat: "no-repeat",
1334
+ backgroundPosition: "center center",
1335
+ backgroundSize: "30%"
1336
+ }
1337
+ },
1338
+ [`${e.componentCls}-error`]: {
1339
+ ...t,
1340
+ display: "flex",
1341
+ alignItems: "center",
1342
+ justifyContent: "center"
1343
+ },
1344
+ [`${e.componentCls}-placeholder`]: {
1345
+ position: "absolute",
1346
+ inset: 0
1347
+ },
1348
+ [`${e.componentCls}-mask`]: { ...xt(e) },
1349
+ [`${e.componentCls}-mask:hover`]: { opacity: 1 }
1350
+ } };
1351
+ }, Ct = ie("GImage", (e) => [St(e)]), wt = {
1352
+ src: "",
1353
+ alt: "",
1354
+ fit: "contain",
1355
+ preview: !0,
1356
+ loading: "eager"
1357
+ };
1358
+ function Tt(e) {
1359
+ return e && e.nodeType === 1;
1360
+ }
1361
+ var $ = /* @__PURE__ */ o((t, { emit: n, slots: a, expose: o, attrs: s }) => {
1362
+ let c = Y && "loading" in HTMLImageElement.prototype, { prefixCls: l } = ae("pro-image", t), u = oe(l), [d, f] = Ct(l, u), p = b(), _ = b(!1), v = b(!0), y = b(), x = b(), S, C = r(() => t.loading === "eager" ? !1 : !c && t.loading === "lazy" || t.lazy), w = r(() => Y && t.fit ? {
1363
+ ...t.imageStyle,
1364
+ objectFit: t.fit
1365
+ } : { ...t.imageStyle }), E = r(() => typeof t.preview == "object" ? t.preview : {}), D = r(() => !!t.preview), O = r(() => {
1366
+ let { urls: e = [], current: n = 0 } = E.value;
1367
+ if (se(n)) return e.length >= n ? n : 0;
1368
+ let r = e.indexOf(t.src ?? "");
1369
+ return r >= 0 ? r : 0;
1370
+ }), k = r(() => F(t.width)), ee = r(() => F(t.height)), { showViewer: te, mousePosition: ne, openPreview: j, closePreview: M } = Je({ canPreview: D }), N = () => {
1371
+ Y && (v.value = !0, _.value = !1, p.value = t.src);
1372
+ }, P = (e) => {
1373
+ _.value || (v.value = !1, _.value = !1, t.onLoad?.(e), n("load", e));
1374
+ }, re = (e) => {
1375
+ v.value = !1, _.value = !0, t.onError?.(e), n("error", e);
1376
+ }, ie = () => {
1377
+ if (!y.value || !x.value) return !1;
1378
+ let e = y.value.getBoundingClientRect(), t = x.value.getBoundingClientRect ? x.value.getBoundingClientRect() : {
1379
+ top: 0,
1380
+ bottom: x.value.innerHeight ?? 0,
1381
+ left: 0,
1382
+ right: x.value.innerWidth ?? 0
1383
+ };
1384
+ return e.top < t.bottom && e.bottom > t.top && e.left < t.right && e.right > t.left;
1385
+ }, I = Me(() => {
1386
+ ie() && (N(), S?.(), S = void 0);
1387
+ }, 200, !0), L = async () => {
1388
+ if (!Y) return;
1389
+ await h();
1390
+ let { scrollContainer: e } = t;
1391
+ Tt(e) ? x.value = e : ce(e) && e !== "" ? x.value = document.querySelector(e) ?? void 0 : y.value && (x.value = me(y.value)), x.value && (S = X(x.value, "scroll", I), setTimeout(I, 100));
1392
+ }, R = (e) => {
1393
+ let r = v.value ? "loaded" : _.value ? "error" : "success";
1394
+ if (t.onClick?.(r), n("click", r), !(v.value || _.value) && D.value) {
1395
+ let t = e.currentTarget?.getBoundingClientRect();
1396
+ j(t ? {
1397
+ ...e,
1398
+ clientX: t.x + t.width / 2,
1399
+ clientY: t.y + t.height / 2
1400
+ } : e);
1401
+ }
1402
+ };
1403
+ return T(() => t.src, () => {
1404
+ C.value ? (v.value = !0, _.value = !1, S?.(), L()) : N();
1405
+ }), g(() => {
1406
+ C.value ? L() : N();
1407
+ }), o({ setOpen: (e) => {
1408
+ e ? j() : M();
1409
+ } }), () => {
1410
+ let n = {}, r = {};
1411
+ for (let [e, t] of Object.entries(s)) /^(?:data-|on[A-Z])/i.test(e) || [
1412
+ "id",
1413
+ "style",
1414
+ "class"
1415
+ ].includes(e) ? n[e] = t : r[e] = t;
1416
+ let o = ve({
1417
+ slots: a,
1418
+ props: t,
1419
+ keys: [
1420
+ "fallback",
1421
+ "mask",
1422
+ "placeholder"
1423
+ ],
1424
+ render: !0
1425
+ });
1426
+ return i("div", m({
1427
+ class: K(l.value, d.value, f.value, u.value, t.class),
1428
+ ref: y
1429
+ }, n, {
1430
+ style: {
1431
+ width: F(t.size) || k.value,
1432
+ height: F(t.size) || ee.value,
1433
+ ...n.style || {}
1434
+ },
1435
+ onClick: (e) => {
1436
+ _.value && R(e);
1437
+ }
1438
+ }), [
1439
+ _.value ? i("div", { class: K(`${l.value}-error`) }, [o.fallback]) : i(e, null, [i("img", m(r, {
1440
+ src: p.value,
1441
+ loading: t.loading,
1442
+ style: w.value,
1443
+ class: K(t.imageClass, `${l.value}-img`, {
1444
+ [`${l.value}-img-placeholder`]: t.placeholder === !0,
1445
+ [`${l.value}-img-preview`]: D.value
1446
+ }),
1447
+ crossorigin: t.crossOrigin,
1448
+ width: k.value,
1449
+ height: ee.value,
1450
+ onClick: R,
1451
+ onLoad: P,
1452
+ onError: re
1453
+ }), null), v.value && i("div", {
1454
+ class: K(`${l.value}-placeholder`),
1455
+ onClick: R
1456
+ }, [o.placeholder])]),
1457
+ E.value.mask && D.value && i("div", {
1458
+ class: K(`${l.value}-mask`, E.value.maskClass),
1459
+ style: { display: n.style?.display === "none" ? "none" : void 0 }
1460
+ }, [o.mask || i("div", { class: K(`${l.value}-mask-info`) }, [i(A, null, null)])]),
1461
+ D.value && i(bt, m(E.value, {
1462
+ urls: E.value.urls || (t.src ? [t.src] : []),
1463
+ current: O.value,
1464
+ zIndex: t.zIndex ?? E.value.zIndex,
1465
+ open: te.value,
1466
+ mousePosition: ne.value,
1467
+ onClose: () => M()
1468
+ }), a)
1469
+ ]);
1470
+ };
1471
+ }, {
1472
+ props: /* @__PURE__ */ p({
1473
+ rootClass: {
1474
+ type: String,
1475
+ required: !1
1476
+ },
1477
+ prefixCls: {
1478
+ type: String,
1479
+ required: !1
1480
+ },
1481
+ src: {
1482
+ type: String,
1483
+ required: !1
1484
+ },
1485
+ alt: {
1486
+ type: String,
1487
+ required: !1
1488
+ },
1489
+ width: {
1490
+ type: Number,
1491
+ required: !1
1492
+ },
1493
+ height: {
1494
+ type: Number,
1495
+ required: !1
1496
+ },
1497
+ size: {
1498
+ type: Number,
1499
+ required: !1
1500
+ },
1501
+ fit: {
1502
+ type: String,
1503
+ required: !1
1504
+ },
1505
+ loading: {
1506
+ type: String,
1507
+ required: !1
1508
+ },
1509
+ crossOrigin: {
1510
+ type: String,
1511
+ required: !1
1512
+ },
1513
+ imageStyle: {
1514
+ type: Object,
1515
+ required: !1
1516
+ },
1517
+ imageClass: {
1518
+ type: String,
1519
+ required: !1
1520
+ },
1521
+ preview: {
1522
+ type: [Boolean, Object],
1523
+ required: !1,
1524
+ default: void 0
1525
+ },
1526
+ zIndex: {
1527
+ type: Number,
1528
+ required: !1
1529
+ },
1530
+ lazy: {
1531
+ type: Boolean,
1532
+ required: !1,
1533
+ default: void 0
1534
+ },
1535
+ scrollContainer: { required: !1 },
1536
+ placeholder: {
1537
+ type: [
1538
+ Function,
1539
+ Object,
1540
+ String,
1541
+ Number,
1542
+ Boolean,
1543
+ null,
1544
+ Array
1545
+ ],
1546
+ required: !1,
1547
+ default: void 0
1548
+ },
1549
+ fallback: {
1550
+ type: [
1551
+ Function,
1552
+ Object,
1553
+ String,
1554
+ Number,
1555
+ Boolean,
1556
+ null,
1557
+ Array
1558
+ ],
1559
+ required: !1,
1560
+ default: void 0
1561
+ },
1562
+ onLoad: {
1563
+ type: Function,
1564
+ required: !1
1565
+ },
1566
+ onError: {
1567
+ type: Function,
1568
+ required: !1
1569
+ },
1570
+ onClick: {
1571
+ type: Function,
1572
+ required: !1
1573
+ },
1574
+ "onUpdate:open": {
1575
+ type: Function,
1576
+ required: !1
1577
+ }
1578
+ }, wt),
1579
+ emits: [
1580
+ "click",
1581
+ "load",
1582
+ "error"
1583
+ ],
1584
+ name: "GImage",
1585
+ inheritAttrs: !1
1586
+ });
1587
+ $.isGImage = !0, $.install = (e) => (e.component($.name, $), e);
1588
+ var Et = $;
1589
+ //#endregion
1590
+ export { Et as GImage, bt as GImagePreview };