@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
package/dist/image.esm.js DELETED
@@ -1,2374 +0,0 @@
1
- import { Fragment, Teleport, Transition, cloneVNode, computed, createVNode, defineComponent, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isRef, isVNode, mergeProps, nextTick, onMounted, onUnmounted, reactive, ref, shallowRef, toRef, toValue, unref, vShow, watch, watchEffect, withDirectives } from "vue";
2
- import { CloseOutlined, EyeOutlined, LeftOutlined, RightOutlined, RotateLeftOutlined, RotateRightOutlined, SwapOutlined, ZoomInOutlined, ZoomOutOutlined } from "@ant-design/icons-vue";
3
- import { FastColor, Keyframe, getTransitionProps, mergeToken, unit, useProStyle, useStyle } from "@gx-design-vue/pro-provider";
4
- typeof process < "u" && process.versions != null && process.versions.node;
5
- function is(e, t) {
6
- return Object.prototype.toString.call(e) === `[object ${t}]`;
7
- }
8
- function isBoolean(e) {
9
- return typeof e == "boolean";
10
- }
11
- function isNumber(e) {
12
- return typeof e == "number";
13
- }
14
- function isArray(e) {
15
- return Array.isArray === void 0 ? Object.prototype.toString.call(e) === "[object Array]" : Array.isArray(e);
16
- }
17
- function isObject$1(e) {
18
- return e !== null && is(e, "Object");
19
- }
20
- function isString(e) {
21
- return typeof e == "string";
22
- }
23
- var isServer = typeof window > "u";
24
- function getPrefixCls({ suffixCls: e, customizePrefixCls: t, isPor: n, className: r }) {
25
- let i = r || (n ? "gx-pro" : "gx");
26
- return t || (e ? `${i}-${e}` : i);
27
- }
28
- var raf = (e) => setTimeout(e, 16), caf = (e) => clearTimeout(e);
29
- typeof window < "u" && "requestAnimationFrame" in window && (raf = (e) => window.requestAnimationFrame(e), caf = (e) => window.cancelAnimationFrame(e));
30
- var rafUUID = 0, rafIds = /* @__PURE__ */ new Map();
31
- function cleanup(e) {
32
- rafIds.delete(e);
33
- }
34
- function wrapperRaf(e, t = 1) {
35
- rafUUID += 1;
36
- let n = rafUUID;
37
- function r(t) {
38
- if (t === 0) cleanup(n), e();
39
- else {
40
- let e = raf(() => {
41
- r(t - 1);
42
- });
43
- rafIds.set(n, e);
44
- }
45
- }
46
- return r(t), n;
47
- }
48
- wrapperRaf.cancel = (e) => {
49
- let t = rafIds.get(e);
50
- return cleanup(t), caf(t);
51
- };
52
- function camelize$1(e) {
53
- return e.replace(/[-_](.)/g, (e, t) => t.toUpperCase());
54
- }
55
- function getStyle(e, t) {
56
- if (isServer || !e || !t) return "";
57
- t = camelize$1(t), t === "float" && (t = "cssFloat");
58
- try {
59
- let n = e.style[t];
60
- if (n) return n;
61
- let r = document?.defaultView?.getComputedStyle(e, "");
62
- return r ? r[t] : "";
63
- } catch {
64
- return e.style[t];
65
- }
66
- }
67
- function isScroll(e, t) {
68
- if (!isServer) return (t == null ? getStyle(e, "overflow") : t ? getStyle(e, "overflow-y") : getStyle(e, "overflow-x")).match(/(scroll|auto|overlay)/);
69
- }
70
- function getScrollContainer(e, t) {
71
- if (isServer) return;
72
- let n = e;
73
- for (; n;) {
74
- if ([
75
- window,
76
- document,
77
- document.documentElement
78
- ].includes(n)) return window;
79
- if (isScroll(n, t)) return n;
80
- n = n.parentNode;
81
- }
82
- return n;
83
- }
84
- function isInContainer(e, t) {
85
- if (isServer || !e || !t) return !1;
86
- let n = e.getBoundingClientRect(), r;
87
- return r = [
88
- window,
89
- document,
90
- document.documentElement,
91
- null,
92
- void 0
93
- ].includes(t) ? {
94
- top: 0,
95
- right: window.innerWidth,
96
- bottom: window.innerHeight,
97
- left: 0
98
- } : t.getBoundingClientRect(), n.top < r.bottom && n.bottom > r.top && n.right > r.left && n.left < r.right;
99
- }
100
- function classNames(...e) {
101
- let t = [];
102
- for (let n = 0; n < e.length; n++) {
103
- let r = e[n];
104
- if (r) {
105
- if (isString(r)) t.push(r);
106
- else if (isArray(r)) for (let e = 0; e < r.length; e++) {
107
- let n = classNames(r[e]);
108
- n && t.push(n);
109
- }
110
- else if (isObject$1(r)) for (let e in r) r[e] && t.push(e);
111
- }
112
- }
113
- return t.filter((e) => e).join(" ");
114
- }
115
- var classNames_default = classNames;
116
- function slotRender({ vnode: e, defaultVNode: t }, ...n) {
117
- return e === !1 ? null : typeof e == "function" ? e?.(...n) : e || t;
118
- }
119
- function getSlot(e, ...t) {
120
- let { slots: n, key: r = "default", render: i, props: a, defaultChildren: o } = e, s, c = a[r], l = n?.[r], u = typeof o == "function" ? o?.() : o;
121
- return s = c === !1 ? !1 : c === !0 ? l ?? u : isObject$1(c) && i ? isVNode(c) ? c : l : c || l, s === !1 ? !1 : i ? slotRender({
122
- vnode: s,
123
- defaultVNode: u
124
- }, ...t) : s;
125
- }
126
- function getSlotVNode(e, ...t) {
127
- let { slots: n, key: r = "default", props: i, defaultChildren: a } = e, o, s = i[r], c = n?.[r]?.(...t), l = typeof a == "function" ? a?.() : a;
128
- return o = s === !1 ? !1 : s === !0 ? c ?? l : isObject$1(s) ? isVNode(s) ? s : c : s || c, o === !1 ? !1 : slotRender({
129
- vnode: o,
130
- defaultVNode: l
131
- }, ...t);
132
- }
133
- function getSlotsProps(e, ...t) {
134
- let { slots: n, props: r, keys: i, render: a, defaultVNodes: o } = e, s = {};
135
- return i.forEach((e, i) => {
136
- let c = o ? o[i] : null, l = a ? getSlotVNode({
137
- slots: n,
138
- props: r,
139
- key: e,
140
- defaultChildren: c
141
- }, ...t) : getSlot({
142
- slots: n,
143
- props: r,
144
- key: e,
145
- render: !1,
146
- defaultChildren: c
147
- }, ...t);
148
- (isBoolean(l) || l) && (s[e] = l);
149
- }), s;
150
- }
151
- var localProvidedStateMap = /* @__PURE__ */ new WeakMap(), injectLocal = (...e) => {
152
- let t = e[0], n = getCurrentInstance()?.proxy ?? getCurrentScope();
153
- if (n == null && !hasInjectionContext()) throw Error("injectLocal must be called in setup");
154
- return n && localProvidedStateMap.has(n) && t in localProvidedStateMap.get(n) ? localProvidedStateMap.get(n)[t] : inject(...e);
155
- }, isClient = typeof window < "u" && typeof document < "u";
156
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
157
- var toString = Object.prototype.toString, isObject = (e) => toString.call(e) === "[object Object]", noop$1 = () => {};
158
- function createFilterWrapper(e, t) {
159
- function n(...n) {
160
- return new Promise((r, i) => {
161
- Promise.resolve(e(() => t.apply(this, n), {
162
- fn: t,
163
- thisArg: this,
164
- args: n
165
- })).then(r).catch(i);
166
- });
167
- }
168
- return n;
169
- }
170
- function throttleFilter(...e) {
171
- let t = 0, n, r = !0, i = noop$1, a, o, s, c, l;
172
- !isRef(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;
173
- let u = () => {
174
- n && (clearTimeout(n), n = void 0, i(), i = noop$1);
175
- };
176
- return (e) => {
177
- let d = toValue(o), f = Date.now() - t, p = () => a = e();
178
- return u(), d <= 0 ? (t = Date.now(), p()) : (f > d ? (t = Date.now(), (c || !r) && p()) : s && (a = new Promise((e, a) => {
179
- i = l ? a : e, n = setTimeout(() => {
180
- t = Date.now(), r = !0, e(p()), u();
181
- }, Math.max(0, d - f));
182
- })), !c && !n && (n = setTimeout(() => r = !0, d)), r = !1, a);
183
- };
184
- }
185
- function pxValue(e) {
186
- return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
187
- }
188
- function toArray(e) {
189
- return Array.isArray(e) ? e : [e];
190
- }
191
- function getLifeCycleTarget(e) {
192
- return e || getCurrentInstance();
193
- }
194
- function useThrottleFn(e, t = 200, n = !1, r = !0, i = !1) {
195
- return createFilterWrapper(throttleFilter(t, n, r, i), e);
196
- }
197
- function tryOnMounted(e, t = !0, n) {
198
- getLifeCycleTarget(n) ? onMounted(e, n) : t ? e() : nextTick(e);
199
- }
200
- function watchImmediate(e, t, n) {
201
- return watch(e, t, {
202
- ...n,
203
- immediate: !0
204
- });
205
- }
206
- var defaultWindow = isClient ? window : void 0;
207
- isClient && window.document, isClient && window.navigator, isClient && window.location;
208
- function unrefElement(e) {
209
- let t = toValue(e);
210
- return t?.$el ?? t;
211
- }
212
- function useEventListener(...e) {
213
- let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = computed(() => {
214
- let t = toArray(toValue(e[0])).filter((e) => e != null);
215
- return t.every((e) => typeof e != "string") ? t : void 0;
216
- });
217
- return watchImmediate(() => [
218
- n.value?.map((e) => unrefElement(e)) ?? [defaultWindow].filter((e) => e != null),
219
- toArray(toValue(n.value ? e[1] : e[0])),
220
- toArray(unref(n.value ? e[2] : e[1])),
221
- toValue(n.value ? e[3] : e[2])
222
- ], ([e, n, r, i], a, o) => {
223
- if (!e?.length || !n?.length || !r?.length) return;
224
- let s = isObject(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
225
- o(() => {
226
- c.forEach((e) => e());
227
- });
228
- }, { flush: "post" });
229
- }
230
- function useMounted() {
231
- let e = shallowRef(!1), t = getCurrentInstance();
232
- return t && onMounted(() => {
233
- e.value = !0;
234
- }, t), e;
235
- }
236
- /* @__NO_SIDE_EFFECTS__ */
237
- function useSupported(e) {
238
- let t = useMounted();
239
- return computed(() => (t.value, !!e()));
240
- }
241
- var ssrWidthSymbol = Symbol("vueuse-ssr-width");
242
- /* @__NO_SIDE_EFFECTS__ */
243
- function useSSRWidth() {
244
- let e = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
245
- return typeof e == "number" ? e : void 0;
246
- }
247
- function useMediaQuery(e, t = {}) {
248
- let { window: n = defaultWindow, ssrWidth: r = /* @__PURE__ */ useSSRWidth() } = t, a = /* @__PURE__ */ useSupported(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), o = shallowRef(typeof r == "number"), s = shallowRef(), c = shallowRef(!1);
249
- return watchEffect(() => {
250
- if (o.value) {
251
- o.value = !a.value, c.value = toValue(e).split(",").some((e) => {
252
- let t = e.includes("not all"), n = e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), i = e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), a = !!(n || i);
253
- return n && a && (a = r >= pxValue(n[1])), i && a && (a = r <= pxValue(i[1])), t ? !a : a;
254
- });
255
- return;
256
- }
257
- a.value && (s.value = n.matchMedia(toValue(e)), c.value = s.value.matches);
258
- }), useEventListener(s, "change", (e) => {
259
- c.value = e.matches;
260
- }, { passive: !0 }), computed(() => c.value);
261
- }
262
- function useWindowSize(e = {}) {
263
- let { window: t = defaultWindow, initialWidth: n = Infinity, initialHeight: r = Infinity, listenOrientation: i = !0, includeScrollbar: a = !0, type: o = "inner" } = e, s = shallowRef(n), c = shallowRef(r), l = () => {
264
- if (t) if (o === "outer") s.value = t.outerWidth, c.value = t.outerHeight;
265
- else if (o === "visual" && t.visualViewport) {
266
- let { width: e, height: n, scale: r } = t.visualViewport;
267
- s.value = Math.round(e * r), c.value = Math.round(n * r);
268
- } else a ? (s.value = t.innerWidth, c.value = t.innerHeight) : (s.value = t.document.documentElement.clientWidth, c.value = t.document.documentElement.clientHeight);
269
- };
270
- l(), tryOnMounted(l);
271
- let u = { passive: !0 };
272
- return useEventListener("resize", l, u), t && o === "visual" && t.visualViewport && useEventListener(t.visualViewport, "resize", l, u), i && watch(useMediaQuery("(orientation: portrait)"), () => l()), {
273
- width: s,
274
- height: c
275
- };
276
- }
277
- function noop() {}
278
- function isPrimitive(e) {
279
- return e == null || typeof e != "object" && typeof e != "function";
280
- }
281
- function isTypedArray(e) {
282
- return ArrayBuffer.isView(e) && !(e instanceof DataView);
283
- }
284
- function getSymbols(e) {
285
- return Object.getOwnPropertySymbols(e).filter((t) => Object.prototype.propertyIsEnumerable.call(e, t));
286
- }
287
- function getTag(e) {
288
- return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
289
- }
290
- var regexpTag = "[object RegExp]", stringTag = "[object String]", numberTag = "[object Number]", booleanTag = "[object Boolean]", argumentsTag = "[object Arguments]", symbolTag = "[object Symbol]", dateTag = "[object Date]", mapTag = "[object Map]", setTag = "[object Set]", arrayTag = "[object Array]", functionTag = "[object Function]", arrayBufferTag = "[object ArrayBuffer]", objectTag = "[object Object]", errorTag = "[object Error]", dataViewTag = "[object DataView]", uint8ArrayTag = "[object Uint8Array]", uint8ClampedArrayTag = "[object Uint8ClampedArray]", uint16ArrayTag = "[object Uint16Array]", uint32ArrayTag = "[object Uint32Array]", bigUint64ArrayTag = "[object BigUint64Array]", int8ArrayTag = "[object Int8Array]", int16ArrayTag = "[object Int16Array]", int32ArrayTag = "[object Int32Array]", bigInt64ArrayTag = "[object BigInt64Array]", float32ArrayTag = "[object Float32Array]", float64ArrayTag = "[object Float64Array]";
291
- function cloneDeepWithImpl(e, t, n, r = /* @__PURE__ */ new Map(), i = void 0) {
292
- let a = i?.(e, t, n, r);
293
- if (a !== void 0) return a;
294
- if (isPrimitive(e)) return e;
295
- if (r.has(e)) return r.get(e);
296
- if (Array.isArray(e)) {
297
- let t = Array(e.length);
298
- r.set(e, t);
299
- for (let a = 0; a < e.length; a++) t[a] = cloneDeepWithImpl(e[a], a, n, r, i);
300
- return Object.hasOwn(e, "index") && (t.index = e.index), Object.hasOwn(e, "input") && (t.input = e.input), t;
301
- }
302
- if (e instanceof Date) return new Date(e.getTime());
303
- if (e instanceof RegExp) {
304
- let t = new RegExp(e.source, e.flags);
305
- return t.lastIndex = e.lastIndex, t;
306
- }
307
- if (e instanceof Map) {
308
- let t = /* @__PURE__ */ new Map();
309
- r.set(e, t);
310
- for (let [a, o] of e) t.set(a, cloneDeepWithImpl(o, a, n, r, i));
311
- return t;
312
- }
313
- if (e instanceof Set) {
314
- let t = /* @__PURE__ */ new Set();
315
- r.set(e, t);
316
- for (let a of e) t.add(cloneDeepWithImpl(a, void 0, n, r, i));
317
- return t;
318
- }
319
- if (typeof Buffer < "u" && Buffer.isBuffer(e)) return e.subarray();
320
- if (isTypedArray(e)) {
321
- let t = new (Object.getPrototypeOf(e)).constructor(e.length);
322
- r.set(e, t);
323
- for (let a = 0; a < e.length; a++) t[a] = cloneDeepWithImpl(e[a], a, n, r, i);
324
- return t;
325
- }
326
- if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return e.slice(0);
327
- if (e instanceof DataView) {
328
- let t = new DataView(e.buffer.slice(0), e.byteOffset, e.byteLength);
329
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
330
- }
331
- if (typeof File < "u" && e instanceof File) {
332
- let t = new File([e], e.name, { type: e.type });
333
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
334
- }
335
- if (typeof Blob < "u" && e instanceof Blob) {
336
- let t = new Blob([e], { type: e.type });
337
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
338
- }
339
- if (e instanceof Error) {
340
- let t = new e.constructor();
341
- return r.set(e, t), t.message = e.message, t.name = e.name, t.stack = e.stack, t.cause = e.cause, copyProperties(t, e, n, r, i), t;
342
- }
343
- if (e instanceof Boolean) {
344
- let t = new Boolean(e.valueOf());
345
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
346
- }
347
- if (e instanceof Number) {
348
- let t = new Number(e.valueOf());
349
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
350
- }
351
- if (e instanceof String) {
352
- let t = new String(e.valueOf());
353
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
354
- }
355
- if (typeof e == "object" && isCloneableObject(e)) {
356
- let t = Object.create(Object.getPrototypeOf(e));
357
- return r.set(e, t), copyProperties(t, e, n, r, i), t;
358
- }
359
- return e;
360
- }
361
- function copyProperties(e, t, n = e, r, i) {
362
- let a = [...Object.keys(t), ...getSymbols(t)];
363
- for (let o = 0; o < a.length; o++) {
364
- let s = a[o], c = Object.getOwnPropertyDescriptor(e, s);
365
- (c == null || c.writable) && (e[s] = cloneDeepWithImpl(t[s], s, n, r, i));
366
- }
367
- }
368
- function isCloneableObject(e) {
369
- switch (getTag(e)) {
370
- case argumentsTag:
371
- case arrayTag:
372
- case arrayBufferTag:
373
- case dataViewTag:
374
- case booleanTag:
375
- case dateTag:
376
- case float32ArrayTag:
377
- case float64ArrayTag:
378
- case int8ArrayTag:
379
- case int16ArrayTag:
380
- case int32ArrayTag:
381
- case mapTag:
382
- case numberTag:
383
- case objectTag:
384
- case regexpTag:
385
- case setTag:
386
- case stringTag:
387
- case symbolTag:
388
- case uint8ArrayTag:
389
- case uint8ClampedArrayTag:
390
- case uint16ArrayTag:
391
- case uint32ArrayTag: return !0;
392
- default: return !1;
393
- }
394
- }
395
- function cloneDeep(e) {
396
- return cloneDeepWithImpl(e, void 0, e, /* @__PURE__ */ new Map(), void 0);
397
- }
398
- function isPlainObject(e) {
399
- if (!e || typeof e != "object") return !1;
400
- let t = Object.getPrototypeOf(e);
401
- return t === null || t === Object.prototype || Object.getPrototypeOf(t) === null ? Object.prototype.toString.call(e) === "[object Object]" : !1;
402
- }
403
- function omit(e, t) {
404
- let n = { ...e };
405
- for (let e = 0; e < t.length; e++) {
406
- let r = t[e];
407
- delete n[r];
408
- }
409
- return n;
410
- }
411
- function isEqualsSameValueZero(e, t) {
412
- return e === t || Number.isNaN(e) && Number.isNaN(t);
413
- }
414
- function isEqualWith(e, t, n) {
415
- return isEqualWithImpl(e, t, void 0, void 0, void 0, void 0, n);
416
- }
417
- function isEqualWithImpl(e, t, n, r, i, a, o) {
418
- let s = o(e, t, n, r, i, a);
419
- if (s !== void 0) return s;
420
- if (typeof e == typeof t) switch (typeof e) {
421
- case "bigint":
422
- case "string":
423
- case "boolean":
424
- case "symbol":
425
- case "undefined": return e === t;
426
- case "number": return e === t || Object.is(e, t);
427
- case "function": return e === t;
428
- case "object": return areObjectsEqual(e, t, a, o);
429
- }
430
- return areObjectsEqual(e, t, a, o);
431
- }
432
- function areObjectsEqual(e, t, n, r) {
433
- if (Object.is(e, t)) return !0;
434
- let i = getTag(e), a = getTag(t);
435
- if (i === "[object Arguments]" && (i = objectTag), a === "[object Arguments]" && (a = objectTag), i !== a) return !1;
436
- switch (i) {
437
- case stringTag: return e.toString() === t.toString();
438
- case numberTag: return isEqualsSameValueZero(e.valueOf(), t.valueOf());
439
- case booleanTag:
440
- case dateTag:
441
- case symbolTag: return Object.is(e.valueOf(), t.valueOf());
442
- case regexpTag: return e.source === t.source && e.flags === t.flags;
443
- case functionTag: return e === t;
444
- }
445
- n ??= /* @__PURE__ */ new Map();
446
- let o = n.get(e), s = n.get(t);
447
- if (o != null && s != null) return o === t;
448
- n.set(e, t), n.set(t, e);
449
- try {
450
- switch (i) {
451
- case mapTag:
452
- if (e.size !== t.size) return !1;
453
- for (let [i, a] of e.entries()) if (!t.has(i) || !isEqualWithImpl(a, t.get(i), i, e, t, n, r)) return !1;
454
- return !0;
455
- case setTag: {
456
- if (e.size !== t.size) return !1;
457
- let i = Array.from(e.values()), a = Array.from(t.values());
458
- for (let o = 0; o < i.length; o++) {
459
- let s = i[o], c = a.findIndex((i) => isEqualWithImpl(s, i, void 0, e, t, n, r));
460
- if (c === -1) return !1;
461
- a.splice(c, 1);
462
- }
463
- return !0;
464
- }
465
- case arrayTag:
466
- case uint8ArrayTag:
467
- case uint8ClampedArrayTag:
468
- case uint16ArrayTag:
469
- case uint32ArrayTag:
470
- case bigUint64ArrayTag:
471
- case int8ArrayTag:
472
- case int16ArrayTag:
473
- case int32ArrayTag:
474
- case bigInt64ArrayTag:
475
- case float32ArrayTag:
476
- case float64ArrayTag:
477
- if (typeof Buffer < "u" && Buffer.isBuffer(e) !== Buffer.isBuffer(t) || e.length !== t.length) return !1;
478
- for (let i = 0; i < e.length; i++) if (!isEqualWithImpl(e[i], t[i], i, e, t, n, r)) return !1;
479
- return !0;
480
- case arrayBufferTag: return e.byteLength === t.byteLength ? areObjectsEqual(new Uint8Array(e), new Uint8Array(t), n, r) : !1;
481
- case dataViewTag: return e.byteLength !== t.byteLength || e.byteOffset !== t.byteOffset ? !1 : areObjectsEqual(new Uint8Array(e), new Uint8Array(t), n, r);
482
- case errorTag: return e.name === t.name && e.message === t.message;
483
- case objectTag: {
484
- if (!(areObjectsEqual(e.constructor, t.constructor, n, r) || isPlainObject(e) && isPlainObject(t))) return !1;
485
- let i = [...Object.keys(e), ...getSymbols(e)], a = [...Object.keys(t), ...getSymbols(t)];
486
- if (i.length !== a.length) return !1;
487
- for (let a = 0; a < i.length; a++) {
488
- let o = i[a], s = e[o];
489
- if (!Object.hasOwn(t, o)) return !1;
490
- let c = t[o];
491
- if (!isEqualWithImpl(s, c, o, e, t, n, r)) return !1;
492
- }
493
- return !0;
494
- }
495
- default: return !1;
496
- }
497
- } finally {
498
- n.delete(e), n.delete(t);
499
- }
500
- }
501
- function isEqual(e, t) {
502
- return isEqualWith(e, t, noop);
503
- }
504
- function useEffect(e, t, n) {
505
- watch(t, (t, r) => {
506
- n ? n(t, r) && e() : e();
507
- }), onMounted(() => {
508
- e();
509
- });
510
- }
511
- var isIos = (typeof window > "u" ? !1 : /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window.MSStream;
512
- typeof window > "u" || isIos || window.safari;
513
- function useState(e) {
514
- let t = ref(typeof e == "function" ? e() : e);
515
- function n(e) {
516
- t.value = e;
517
- }
518
- return [t, n];
519
- }
520
- function useMergedState(e, t) {
521
- let { defaultValue: n, value: r = ref() } = t || {}, i = typeof e == "function" ? e() : e;
522
- r.value !== void 0 && (i = unref(r)), n !== void 0 && (i = typeof n == "function" ? n() : n);
523
- let a = ref(i), o = ref(i), [s, c] = useState([o.value]);
524
- watchEffect(() => {
525
- let e = r.value === void 0 ? a.value : r.value;
526
- t?.postState && (e = t.postState(e, a.value)), o.value = e;
527
- }), watch(s, () => {
528
- let e = s.value[0];
529
- a.value !== e && t?.onChange?.(a.value, e);
530
- }, { deep: !0 });
531
- function l(e) {
532
- a.value = e;
533
- }
534
- function u(e) {
535
- l(e), c([o.value]);
536
- }
537
- return watch(r, () => {
538
- a.value = r.value;
539
- }), [
540
- o,
541
- u,
542
- a
543
- ];
544
- }
545
- var initialTransform = {
546
- x: 0,
547
- y: 0,
548
- rotate: 0,
549
- scale: 1,
550
- flipX: !1,
551
- flipY: !1
552
- };
553
- function useImageTransform(e, t, n, r) {
554
- let i = ref(null), a = ref([]), [o, s] = useState(initialTransform), c = (e) => {
555
- s(initialTransform), isEqual(initialTransform, o.value) || r?.({
556
- transform: initialTransform,
557
- action: e
558
- });
559
- }, l = (e, t) => {
560
- i.value === null && (a.value = [], i.value = wrapperRaf(() => {
561
- let e = cloneDeep(o.value);
562
- a.value.forEach((t) => {
563
- e = {
564
- ...e,
565
- ...t
566
- };
567
- }), i.value = null, r?.({
568
- transform: e,
569
- action: t
570
- }), s(e);
571
- })), a.value.push({
572
- ...o.value,
573
- ...e
574
- });
575
- };
576
- return {
577
- transform: o,
578
- resetTransform: c,
579
- updateTransform: l,
580
- dispatchZoomChange: (r, i, a, s, c) => {
581
- let { width: u, height: d, offsetWidth: f, offsetHeight: p, offsetLeft: m, offsetTop: h } = e.value, g = r, _ = o.value.scale * r;
582
- _ > n.value ? (_ = n.value, g = n.value / o.value.scale) : _ < t.value && (_ = c ? _ : t.value, g = _ / o.value.scale);
583
- let v = a ?? innerWidth / 2, y = s ?? innerHeight / 2, b = g - 1, x = b * u * .5, S = b * d * .5, C = b * (v - o.value.x - m), ee = b * (y - o.value.y - h), w = o.value.x - (C - x), T = o.value.y - (ee - S);
584
- if (r < 1 && _ === 1) {
585
- let e = f * _, t = p * _, { width: n, height: r } = useWindowSize();
586
- e <= n.value && t <= r.value && (w = 0, T = 0);
587
- }
588
- l({
589
- x: w,
590
- y: T,
591
- scale: _
592
- }, i);
593
- }
594
- };
595
- }
596
- var supportsPassive = !1;
597
- try {
598
- let e = Object.defineProperty({}, "passive", { get() {
599
- supportsPassive = !0;
600
- } });
601
- window.addEventListener("testPassive", null, e), window.removeEventListener("testPassive", null, e);
602
- } catch {}
603
- function addEventListenerWrap(e, t, n, r) {
604
- if (e && e.addEventListener) {
605
- let i = r;
606
- i === void 0 && supportsPassive && (t === "touchstart" || t === "touchmove" || t === "wheel") && (i = { passive: !1 }), e.addEventListener(t, n, i);
607
- }
608
- return { remove: () => {
609
- e && e.removeEventListener && e.removeEventListener(t, n);
610
- } };
611
- }
612
- function fixPoint(e, t, n, r) {
613
- let i = t + n, a = (n - r) / 2;
614
- if (n > r) {
615
- if (t > 0) return { [e]: a };
616
- if (t < 0 && i < r) return { [e]: -a };
617
- } else if (t < 0 || i > r) return { [e]: t < 0 ? a : -a };
618
- return {};
619
- }
620
- function getFixScaleEleTransPosition(e, t, n, r) {
621
- let { width: i, height: a } = useWindowSize(), o = null;
622
- return e <= i.value && t <= a.value ? o = {
623
- x: 0,
624
- y: 0
625
- } : (e > i.value || t > a.value) && (o = {
626
- ...fixPoint("x", n, e, i.value),
627
- ...fixPoint("y", r, t, a.value)
628
- }), o;
629
- }
630
- function useMouseEvent(e, t, n, r, i, a, o) {
631
- let [s, c] = useState(!1), l = ref({
632
- diffX: 0,
633
- diffY: 0,
634
- transformX: 0,
635
- transformY: 0
636
- }), u = (e) => {
637
- !t || e.button !== 0 || (e.preventDefault(), e.stopPropagation(), l.value = {
638
- diffX: e.pageX - i.value.x,
639
- diffY: e.pageY - i.value.y,
640
- transformX: i.value.x,
641
- transformY: i.value.y
642
- }, c(!0));
643
- }, d = (e) => {
644
- n && s.value && a({
645
- x: e.pageX - l.value.diffX,
646
- y: e.pageY - l.value.diffY
647
- }, "move");
648
- }, f = () => {
649
- if (n && s.value) {
650
- c(!1);
651
- let { transformX: t, transformY: n } = l.value;
652
- if (!(i.value.x !== t && i.value.y !== n)) return;
653
- let r = e.value.offsetWidth * i.value.scale, o = e.value.offsetHeight * i.value.scale, { left: s, top: u } = e.value.getBoundingClientRect(), d = i.value.rotate % 180 != 0, f = getFixScaleEleTransPosition(d ? o : r, d ? r : o, s, u);
654
- f && a({ ...f }, "dragRebound");
655
- }
656
- };
657
- return useEffect(() => {
658
- let e, n, r, i;
659
- if (t) {
660
- r = addEventListenerWrap(window, "mouseup", f, !1), i = addEventListenerWrap(window, "mousemove", d, !1);
661
- try {
662
- /* istanbul ignore next */
663
- window.top !== window.self && (e = addEventListenerWrap(window.top, "mouseup", f, !1), n = addEventListenerWrap(window.top, "mousemove", d, !1));
664
- } catch (e) {
665
- /* istanbul ignore next */
666
- console.warn(`[rc-image] ${e}`);
667
- }
668
- }
669
- return () => {
670
- /* istanbul ignore next */
671
- r?.remove(), i?.remove(), e?.remove(), n?.remove();
672
- };
673
- }, [
674
- n,
675
- s,
676
- () => i.value.x,
677
- () => i.value.y,
678
- () => i.value.rotate,
679
- t
680
- ]), {
681
- isMoving: s,
682
- onMouseDown: u,
683
- onMouseMove: d,
684
- onMouseUp: f,
685
- onWheel: (e) => {
686
- if (!n || e.deltaY === 0) return;
687
- let t = Math.abs(e.deltaY / 100), i = 1 + Math.min(t, 1) * r.value;
688
- e.deltaY > 0 && (i = 1 / i), o(i, "wheel", e.clientX, e.clientY);
689
- }
690
- };
691
- }
692
- function getDistance(e, t) {
693
- let n = e.x - t.x, r = e.y - t.y;
694
- return Math.hypot(n, r);
695
- }
696
- function getCenter(e, t, n, r) {
697
- let i = getDistance(e, n), a = getDistance(t, r);
698
- if (i === 0 && a === 0) return [e.x, e.y];
699
- let o = i / (i + a);
700
- return [e.x + o * (t.x - e.x), e.y + o * (t.y - e.y)];
701
- }
702
- function useTouchEvent(e, t, n, r, i, a, o) {
703
- let [s, c] = useState(!1), l = ref({
704
- point1: {
705
- x: 0,
706
- y: 0
707
- },
708
- point2: {
709
- x: 0,
710
- y: 0
711
- },
712
- eventType: "none"
713
- }), u = (e) => {
714
- l.value = {
715
- ...l.value,
716
- ...e
717
- };
718
- };
719
- return useEffect(() => {
720
- let e;
721
- return n.value && t.value && (e = addEventListenerWrap(window, "touchmove", (e) => e.preventDefault(), { passive: !1 })), () => {
722
- e?.remove();
723
- };
724
- }, [n, t]), {
725
- isTouching: s,
726
- onTouchStart: (e) => {
727
- if (!t.value) return;
728
- e.stopPropagation(), c(!0);
729
- let { touches: n = [] } = e;
730
- n.length > 1 ? u({
731
- point1: {
732
- x: n[0].clientX,
733
- y: n[0].clientY
734
- },
735
- point2: {
736
- x: n[1].clientX,
737
- y: n[1].clientY
738
- },
739
- eventType: "touchZoom"
740
- }) : u({
741
- point1: {
742
- x: n[0].clientX - i.value.x,
743
- y: n[0].clientY - i.value.y
744
- },
745
- eventType: "move"
746
- });
747
- },
748
- onTouchMove: (e) => {
749
- let { touches: t = [] } = e, { point1: n, point2: r, eventType: i } = l.value;
750
- if (t.length > 1 && i === "touchZoom") {
751
- let e = {
752
- x: t[0].clientX,
753
- y: t[0].clientY
754
- }, i = {
755
- x: t[1].clientX,
756
- y: t[1].clientY
757
- }, [a, s] = getCenter(n, r, e, i);
758
- o(getDistance(e, i) / getDistance(n, r), "touchZoom", a, s, !0), u({
759
- point1: e,
760
- point2: i,
761
- eventType: "touchZoom"
762
- });
763
- } else i === "move" && (a({
764
- x: t[0].clientX - n.x,
765
- y: t[0].clientY - n.y
766
- }, "move"), u({ eventType: "move" }));
767
- },
768
- onTouchEnd: () => {
769
- if (!n.value) return;
770
- if (s && c(!1), u({ eventType: "none" }), r.value > i.value.scale) return a({
771
- x: 0,
772
- y: 0,
773
- scale: r.value
774
- }, "touchZoom");
775
- let t = e.value.offsetWidth * i.value.scale, o = e.value.offsetHeight * i.value.scale, { left: l, top: d } = e.value.getBoundingClientRect(), f = i.value.rotate % 180 != 0, p = getFixScaleEleTransPosition(f ? o : t, f ? t : o, l, d);
776
- p && a({ ...p }, "dragRebound");
777
- }
778
- };
779
- }
780
- const baseProps = {
781
- infinite: {
782
- type: Boolean,
783
- default: !0
784
- },
785
- zIndex: {
786
- type: Number,
787
- default: 2e3
788
- },
789
- current: {
790
- type: Number,
791
- default: 0
792
- },
793
- getContainer: { type: String }
794
- }, imageProps = {
795
- preview: {
796
- type: [Object, Boolean],
797
- default: !0
798
- },
799
- src: {
800
- type: String,
801
- default: ""
802
- },
803
- alt: {
804
- type: String,
805
- default: ""
806
- },
807
- loading: { type: String },
808
- fit: {
809
- type: String,
810
- default: "contain"
811
- },
812
- crossOrigin: { type: String },
813
- lazy: Boolean,
814
- scrollContainer: { type: [String, Object] },
815
- placeholder: {
816
- type: [
817
- Function,
818
- Object,
819
- Boolean
820
- ],
821
- default: () => void 0
822
- },
823
- fallback: {
824
- type: [Function, Object],
825
- default: () => void 0
826
- },
827
- onLoad: { type: Function },
828
- onError: { type: Function },
829
- onClick: { type: Function },
830
- imageStyle: {
831
- type: Object,
832
- default: () => ({})
833
- },
834
- imageClass: String,
835
- size: Number,
836
- width: Number,
837
- height: Number,
838
- zIndex: baseProps.zIndex,
839
- getContainer: baseProps.getContainer
840
- };
841
- var props_default = {
842
- urls: {
843
- type: Array,
844
- default: () => []
845
- },
846
- open: {
847
- type: Boolean,
848
- default: !1
849
- },
850
- scaleStep: {
851
- type: Number,
852
- default: .5
853
- },
854
- minScale: {
855
- type: Number,
856
- default: .32
857
- },
858
- maxScale: {
859
- type: Number,
860
- default: 32
861
- },
862
- movable: {
863
- type: Boolean,
864
- default: !0
865
- },
866
- disabled: Boolean,
867
- zIndex: baseProps.zIndex,
868
- current: baseProps.current,
869
- infinite: baseProps.infinite,
870
- getContainer: baseProps.getContainer,
871
- onHideOnClickModal: {
872
- type: Boolean,
873
- default: !0
874
- },
875
- countRender: [
876
- Function,
877
- Array,
878
- Object
879
- ],
880
- icons: {
881
- type: Object,
882
- default: () => ({})
883
- },
884
- onTransform: Function,
885
- onOpenChange: Function,
886
- "onUpdate:open": Function
887
- }, Operations_default = /* @__PURE__ */ defineComponent({
888
- name: "Operations",
889
- inheritAttrs: !1,
890
- props: {
891
- open: Boolean,
892
- count: {
893
- type: Number,
894
- default: 0
895
- },
896
- current: {
897
- type: Number,
898
- default: 0
899
- },
900
- showSwitch: Boolean,
901
- showProgress: Boolean,
902
- prefixCls: String,
903
- hashId: String,
904
- zIndex: props_default.zIndex,
905
- icons: props_default.icons,
906
- infinite: props_default.infinite,
907
- getContainer: props_default.getContainer,
908
- countRender: props_default.countRender,
909
- tools: Array,
910
- onClose: Function,
911
- onActive: Function
912
- },
913
- setup(i) {
914
- let o = (e, t) => {
915
- e.preventDefault(), e.stopPropagation(), i.onActive?.(t);
916
- };
917
- return () => {
918
- let { prefixCls: s, hashId: c, tools: l } = i, u = getTransitionProps(`${i.prefixCls}-fade`), d = `${s}-operations-operation`, f = `${s}-operations-icon`;
919
- return createVNode(Teleport, { to: i.getContainer || "body" }, { default: () => [createVNode(Transition, u, { default: () => [withDirectives(createVNode("div", {
920
- class: classNames_default(`${s}-operations-wrapper`, c),
921
- style: { zIndex: i.zIndex }
922
- }, [
923
- i.icons?.close === null ? null : createVNode("button", {
924
- class: `${s}-close ${c}`,
925
- onClick: i.onClose
926
- }, [i.icons?.close || createVNode(CloseOutlined, null, null)]),
927
- i.showSwitch && createVNode(Fragment, null, [createVNode("div", {
928
- class: classNames_default(`${s}-switch-left ${c}`, { [`${s}-switch-left-disabled`]: i.infinite ? !1 : i.current === 0 }),
929
- onClick: (e) => o(e, -1)
930
- }, [i.icons?.left || createVNode(LeftOutlined, null, null)]), createVNode("div", {
931
- class: classNames_default(`${s}-switch-right ${c}`, { [`${s}-switch-right-disabled`]: i.infinite ? !1 : i.current === i.count - 1 }),
932
- onClick: (e) => o(e, 1)
933
- }, [i.icons?.right || createVNode(RightOutlined, null, null)])]),
934
- createVNode("div", { class: `${s}-footer ${c}` }, [i.showProgress && createVNode("div", { class: `${s}-progress` }, [i.countRender ? i.countRender(i.current + 1, i.count) : `${i.current + 1} / ${i.count}`]), createVNode("div", { class: `${i.prefixCls}-operations` }, [l?.map(({ icon: e, onClick: t, type: n, disabled: o }) => createVNode("div", {
935
- class: classNames_default(d, { [`${i.prefixCls}-operations-operation-disabled`]: o && o?.value }),
936
- onClick: t,
937
- key: n
938
- }, [cloneVNode(e, { class: f })]))])])
939
- ]), [[vShow, i.open]])] })] });
940
- };
941
- }
942
- });
943
- function bound01(e, t) {
944
- isOnePointZero(e) && (e = "100%");
945
- var n = isPercentage(e);
946
- return e = t === 360 ? e : Math.min(t, Math.max(0, parseFloat(e))), n && (e = parseInt(String(e * t), 10) / 100), Math.abs(e - t) < 1e-6 ? 1 : (e = t === 360 ? (e < 0 ? e % t + t : e % t) / parseFloat(String(t)) : e % t / parseFloat(String(t)), e);
947
- }
948
- function clamp01(e) {
949
- return Math.min(1, Math.max(0, e));
950
- }
951
- function isOnePointZero(e) {
952
- return typeof e == "string" && e.indexOf(".") !== -1 && parseFloat(e) === 1;
953
- }
954
- function isPercentage(e) {
955
- return typeof e == "string" && e.indexOf("%") !== -1;
956
- }
957
- function boundAlpha(e) {
958
- return e = parseFloat(e), (isNaN(e) || e < 0 || e > 1) && (e = 1), e;
959
- }
960
- function convertToPercentage(e) {
961
- return e <= 1 ? `${Number(e) * 100}%` : e;
962
- }
963
- function pad2(e) {
964
- return e.length === 1 ? "0" + e : String(e);
965
- }
966
- function rgbToRgb(e, t, n) {
967
- return {
968
- r: bound01(e, 255) * 255,
969
- g: bound01(t, 255) * 255,
970
- b: bound01(n, 255) * 255
971
- };
972
- }
973
- function rgbToHsl(e, t, n) {
974
- e = bound01(e, 255), t = bound01(t, 255), n = bound01(n, 255);
975
- var r = Math.max(e, t, n), i = Math.min(e, t, n), a = 0, o = 0, s = (r + i) / 2;
976
- if (r === i) o = 0, a = 0;
977
- else {
978
- var c = r - i;
979
- switch (o = s > .5 ? c / (2 - r - i) : c / (r + i), r) {
980
- case e:
981
- a = (t - n) / c + (t < n ? 6 : 0);
982
- break;
983
- case t:
984
- a = (n - e) / c + 2;
985
- break;
986
- case n:
987
- a = (e - t) / c + 4;
988
- break;
989
- default: break;
990
- }
991
- a /= 6;
992
- }
993
- return {
994
- h: a,
995
- s: o,
996
- l: s
997
- };
998
- }
999
- function hue2rgb(e, t, n) {
1000
- return n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * (6 * n) : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e;
1001
- }
1002
- function hslToRgb(e, t, n) {
1003
- var r, i, a;
1004
- if (e = bound01(e, 360), t = bound01(t, 100), n = bound01(n, 100), t === 0) i = n, a = n, r = n;
1005
- else {
1006
- var o = n < .5 ? n * (1 + t) : n + t - n * t, s = 2 * n - o;
1007
- r = hue2rgb(s, o, e + 1 / 3), i = hue2rgb(s, o, e), a = hue2rgb(s, o, e - 1 / 3);
1008
- }
1009
- return {
1010
- r: r * 255,
1011
- g: i * 255,
1012
- b: a * 255
1013
- };
1014
- }
1015
- function rgbToHsv(e, t, n) {
1016
- e = bound01(e, 255), t = bound01(t, 255), n = bound01(n, 255);
1017
- var r = Math.max(e, t, n), i = Math.min(e, t, n), a = 0, o = r, s = r - i, c = r === 0 ? 0 : s / r;
1018
- if (r === i) a = 0;
1019
- else {
1020
- switch (r) {
1021
- case e:
1022
- a = (t - n) / s + (t < n ? 6 : 0);
1023
- break;
1024
- case t:
1025
- a = (n - e) / s + 2;
1026
- break;
1027
- case n:
1028
- a = (e - t) / s + 4;
1029
- break;
1030
- default: break;
1031
- }
1032
- a /= 6;
1033
- }
1034
- return {
1035
- h: a,
1036
- s: c,
1037
- v: o
1038
- };
1039
- }
1040
- function hsvToRgb(e, t, n) {
1041
- e = bound01(e, 360) * 6, t = bound01(t, 100), n = bound01(n, 100);
1042
- var r = Math.floor(e), i = e - r, a = n * (1 - t), o = n * (1 - i * t), s = n * (1 - (1 - i) * t), c = r % 6, l = [
1043
- n,
1044
- o,
1045
- a,
1046
- a,
1047
- s,
1048
- n
1049
- ][c], u = [
1050
- s,
1051
- n,
1052
- n,
1053
- o,
1054
- a,
1055
- a
1056
- ][c], d = [
1057
- a,
1058
- a,
1059
- s,
1060
- n,
1061
- n,
1062
- o
1063
- ][c];
1064
- return {
1065
- r: l * 255,
1066
- g: u * 255,
1067
- b: d * 255
1068
- };
1069
- }
1070
- function rgbToHex(e, t, n, r) {
1071
- var i = [
1072
- pad2(Math.round(e).toString(16)),
1073
- pad2(Math.round(t).toString(16)),
1074
- pad2(Math.round(n).toString(16))
1075
- ];
1076
- return r && i[0].startsWith(i[0].charAt(1)) && i[1].startsWith(i[1].charAt(1)) && i[2].startsWith(i[2].charAt(1)) ? i[0].charAt(0) + i[1].charAt(0) + i[2].charAt(0) : i.join("");
1077
- }
1078
- function rgbaToHex(e, t, n, r, i) {
1079
- var a = [
1080
- pad2(Math.round(e).toString(16)),
1081
- pad2(Math.round(t).toString(16)),
1082
- pad2(Math.round(n).toString(16)),
1083
- pad2(convertDecimalToHex(r))
1084
- ];
1085
- return i && a[0].startsWith(a[0].charAt(1)) && a[1].startsWith(a[1].charAt(1)) && a[2].startsWith(a[2].charAt(1)) && a[3].startsWith(a[3].charAt(1)) ? a[0].charAt(0) + a[1].charAt(0) + a[2].charAt(0) + a[3].charAt(0) : a.join("");
1086
- }
1087
- function convertDecimalToHex(e) {
1088
- return Math.round(parseFloat(e) * 255).toString(16);
1089
- }
1090
- function convertHexToDecimal(e) {
1091
- return parseIntFromHex(e) / 255;
1092
- }
1093
- function parseIntFromHex(e) {
1094
- return parseInt(e, 16);
1095
- }
1096
- function numberInputToObject(e) {
1097
- return {
1098
- r: e >> 16,
1099
- g: (e & 65280) >> 8,
1100
- b: e & 255
1101
- };
1102
- }
1103
- var names = {
1104
- aliceblue: "#f0f8ff",
1105
- antiquewhite: "#faebd7",
1106
- aqua: "#00ffff",
1107
- aquamarine: "#7fffd4",
1108
- azure: "#f0ffff",
1109
- beige: "#f5f5dc",
1110
- bisque: "#ffe4c4",
1111
- black: "#000000",
1112
- blanchedalmond: "#ffebcd",
1113
- blue: "#0000ff",
1114
- blueviolet: "#8a2be2",
1115
- brown: "#a52a2a",
1116
- burlywood: "#deb887",
1117
- cadetblue: "#5f9ea0",
1118
- chartreuse: "#7fff00",
1119
- chocolate: "#d2691e",
1120
- coral: "#ff7f50",
1121
- cornflowerblue: "#6495ed",
1122
- cornsilk: "#fff8dc",
1123
- crimson: "#dc143c",
1124
- cyan: "#00ffff",
1125
- darkblue: "#00008b",
1126
- darkcyan: "#008b8b",
1127
- darkgoldenrod: "#b8860b",
1128
- darkgray: "#a9a9a9",
1129
- darkgreen: "#006400",
1130
- darkgrey: "#a9a9a9",
1131
- darkkhaki: "#bdb76b",
1132
- darkmagenta: "#8b008b",
1133
- darkolivegreen: "#556b2f",
1134
- darkorange: "#ff8c00",
1135
- darkorchid: "#9932cc",
1136
- darkred: "#8b0000",
1137
- darksalmon: "#e9967a",
1138
- darkseagreen: "#8fbc8f",
1139
- darkslateblue: "#483d8b",
1140
- darkslategray: "#2f4f4f",
1141
- darkslategrey: "#2f4f4f",
1142
- darkturquoise: "#00ced1",
1143
- darkviolet: "#9400d3",
1144
- deeppink: "#ff1493",
1145
- deepskyblue: "#00bfff",
1146
- dimgray: "#696969",
1147
- dimgrey: "#696969",
1148
- dodgerblue: "#1e90ff",
1149
- firebrick: "#b22222",
1150
- floralwhite: "#fffaf0",
1151
- forestgreen: "#228b22",
1152
- fuchsia: "#ff00ff",
1153
- gainsboro: "#dcdcdc",
1154
- ghostwhite: "#f8f8ff",
1155
- goldenrod: "#daa520",
1156
- gold: "#ffd700",
1157
- gray: "#808080",
1158
- green: "#008000",
1159
- greenyellow: "#adff2f",
1160
- grey: "#808080",
1161
- honeydew: "#f0fff0",
1162
- hotpink: "#ff69b4",
1163
- indianred: "#cd5c5c",
1164
- indigo: "#4b0082",
1165
- ivory: "#fffff0",
1166
- khaki: "#f0e68c",
1167
- lavenderblush: "#fff0f5",
1168
- lavender: "#e6e6fa",
1169
- lawngreen: "#7cfc00",
1170
- lemonchiffon: "#fffacd",
1171
- lightblue: "#add8e6",
1172
- lightcoral: "#f08080",
1173
- lightcyan: "#e0ffff",
1174
- lightgoldenrodyellow: "#fafad2",
1175
- lightgray: "#d3d3d3",
1176
- lightgreen: "#90ee90",
1177
- lightgrey: "#d3d3d3",
1178
- lightpink: "#ffb6c1",
1179
- lightsalmon: "#ffa07a",
1180
- lightseagreen: "#20b2aa",
1181
- lightskyblue: "#87cefa",
1182
- lightslategray: "#778899",
1183
- lightslategrey: "#778899",
1184
- lightsteelblue: "#b0c4de",
1185
- lightyellow: "#ffffe0",
1186
- lime: "#00ff00",
1187
- limegreen: "#32cd32",
1188
- linen: "#faf0e6",
1189
- magenta: "#ff00ff",
1190
- maroon: "#800000",
1191
- mediumaquamarine: "#66cdaa",
1192
- mediumblue: "#0000cd",
1193
- mediumorchid: "#ba55d3",
1194
- mediumpurple: "#9370db",
1195
- mediumseagreen: "#3cb371",
1196
- mediumslateblue: "#7b68ee",
1197
- mediumspringgreen: "#00fa9a",
1198
- mediumturquoise: "#48d1cc",
1199
- mediumvioletred: "#c71585",
1200
- midnightblue: "#191970",
1201
- mintcream: "#f5fffa",
1202
- mistyrose: "#ffe4e1",
1203
- moccasin: "#ffe4b5",
1204
- navajowhite: "#ffdead",
1205
- navy: "#000080",
1206
- oldlace: "#fdf5e6",
1207
- olive: "#808000",
1208
- olivedrab: "#6b8e23",
1209
- orange: "#ffa500",
1210
- orangered: "#ff4500",
1211
- orchid: "#da70d6",
1212
- palegoldenrod: "#eee8aa",
1213
- palegreen: "#98fb98",
1214
- paleturquoise: "#afeeee",
1215
- palevioletred: "#db7093",
1216
- papayawhip: "#ffefd5",
1217
- peachpuff: "#ffdab9",
1218
- peru: "#cd853f",
1219
- pink: "#ffc0cb",
1220
- plum: "#dda0dd",
1221
- powderblue: "#b0e0e6",
1222
- purple: "#800080",
1223
- rebeccapurple: "#663399",
1224
- red: "#ff0000",
1225
- rosybrown: "#bc8f8f",
1226
- royalblue: "#4169e1",
1227
- saddlebrown: "#8b4513",
1228
- salmon: "#fa8072",
1229
- sandybrown: "#f4a460",
1230
- seagreen: "#2e8b57",
1231
- seashell: "#fff5ee",
1232
- sienna: "#a0522d",
1233
- silver: "#c0c0c0",
1234
- skyblue: "#87ceeb",
1235
- slateblue: "#6a5acd",
1236
- slategray: "#708090",
1237
- slategrey: "#708090",
1238
- snow: "#fffafa",
1239
- springgreen: "#00ff7f",
1240
- steelblue: "#4682b4",
1241
- tan: "#d2b48c",
1242
- teal: "#008080",
1243
- thistle: "#d8bfd8",
1244
- tomato: "#ff6347",
1245
- turquoise: "#40e0d0",
1246
- violet: "#ee82ee",
1247
- wheat: "#f5deb3",
1248
- white: "#ffffff",
1249
- whitesmoke: "#f5f5f5",
1250
- yellow: "#ffff00",
1251
- yellowgreen: "#9acd32"
1252
- };
1253
- function inputToRGB(e) {
1254
- var t = {
1255
- r: 0,
1256
- g: 0,
1257
- b: 0
1258
- }, n = 1, r = null, i = null, a = null, o = !1, s = !1;
1259
- return typeof e == "string" && (e = stringInputToObject(e)), typeof e == "object" && (isValidCSSUnit(e.r) && isValidCSSUnit(e.g) && isValidCSSUnit(e.b) ? (t = rgbToRgb(e.r, e.g, e.b), o = !0, s = String(e.r).substr(-1) === "%" ? "prgb" : "rgb") : isValidCSSUnit(e.h) && isValidCSSUnit(e.s) && isValidCSSUnit(e.v) ? (r = convertToPercentage(e.s), i = convertToPercentage(e.v), t = hsvToRgb(e.h, r, i), o = !0, s = "hsv") : isValidCSSUnit(e.h) && isValidCSSUnit(e.s) && isValidCSSUnit(e.l) && (r = convertToPercentage(e.s), a = convertToPercentage(e.l), t = hslToRgb(e.h, r, a), o = !0, s = "hsl"), Object.prototype.hasOwnProperty.call(e, "a") && (n = e.a)), n = boundAlpha(n), {
1260
- ok: o,
1261
- format: e.format || s,
1262
- r: Math.min(255, Math.max(t.r, 0)),
1263
- g: Math.min(255, Math.max(t.g, 0)),
1264
- b: Math.min(255, Math.max(t.b, 0)),
1265
- a: n
1266
- };
1267
- }
1268
- var CSS_UNIT = "(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)", PERMISSIVE_MATCH3 = `[\\s|\\(]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})\\s*\\)?`, PERMISSIVE_MATCH4 = `[\\s|\\(]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})\\s*\\)?`, matchers = {
1269
- CSS_UNIT: new RegExp(CSS_UNIT),
1270
- rgb: RegExp("rgb" + PERMISSIVE_MATCH3),
1271
- rgba: RegExp("rgba" + PERMISSIVE_MATCH4),
1272
- hsl: RegExp("hsl" + PERMISSIVE_MATCH3),
1273
- hsla: RegExp("hsla" + PERMISSIVE_MATCH4),
1274
- hsv: RegExp("hsv" + PERMISSIVE_MATCH3),
1275
- hsva: RegExp("hsva" + PERMISSIVE_MATCH4),
1276
- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1277
- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1278
- hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1279
- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
1280
- };
1281
- function stringInputToObject(e) {
1282
- if (e = e.trim().toLowerCase(), e.length === 0) return !1;
1283
- var t = !1;
1284
- if (names[e]) e = names[e], t = !0;
1285
- else if (e === "transparent") return {
1286
- r: 0,
1287
- g: 0,
1288
- b: 0,
1289
- a: 0,
1290
- format: "name"
1291
- };
1292
- var n = matchers.rgb.exec(e);
1293
- return n ? {
1294
- r: n[1],
1295
- g: n[2],
1296
- b: n[3]
1297
- } : (n = matchers.rgba.exec(e), n ? {
1298
- r: n[1],
1299
- g: n[2],
1300
- b: n[3],
1301
- a: n[4]
1302
- } : (n = matchers.hsl.exec(e), n ? {
1303
- h: n[1],
1304
- s: n[2],
1305
- l: n[3]
1306
- } : (n = matchers.hsla.exec(e), n ? {
1307
- h: n[1],
1308
- s: n[2],
1309
- l: n[3],
1310
- a: n[4]
1311
- } : (n = matchers.hsv.exec(e), n ? {
1312
- h: n[1],
1313
- s: n[2],
1314
- v: n[3]
1315
- } : (n = matchers.hsva.exec(e), n ? {
1316
- h: n[1],
1317
- s: n[2],
1318
- v: n[3],
1319
- a: n[4]
1320
- } : (n = matchers.hex8.exec(e), n ? {
1321
- r: parseIntFromHex(n[1]),
1322
- g: parseIntFromHex(n[2]),
1323
- b: parseIntFromHex(n[3]),
1324
- a: convertHexToDecimal(n[4]),
1325
- format: t ? "name" : "hex8"
1326
- } : (n = matchers.hex6.exec(e), n ? {
1327
- r: parseIntFromHex(n[1]),
1328
- g: parseIntFromHex(n[2]),
1329
- b: parseIntFromHex(n[3]),
1330
- format: t ? "name" : "hex"
1331
- } : (n = matchers.hex4.exec(e), n ? {
1332
- r: parseIntFromHex(n[1] + n[1]),
1333
- g: parseIntFromHex(n[2] + n[2]),
1334
- b: parseIntFromHex(n[3] + n[3]),
1335
- a: convertHexToDecimal(n[4] + n[4]),
1336
- format: t ? "name" : "hex8"
1337
- } : (n = matchers.hex3.exec(e), n ? {
1338
- r: parseIntFromHex(n[1] + n[1]),
1339
- g: parseIntFromHex(n[2] + n[2]),
1340
- b: parseIntFromHex(n[3] + n[3]),
1341
- format: t ? "name" : "hex"
1342
- } : !1)))))))));
1343
- }
1344
- function isValidCSSUnit(e) {
1345
- return !!matchers.CSS_UNIT.exec(String(e));
1346
- }
1347
- var TinyColor = function() {
1348
- function e(t, n) {
1349
- if (t === void 0 && (t = ""), n === void 0 && (n = {}), t instanceof e) return t;
1350
- typeof t == "number" && (t = numberInputToObject(t)), this.originalInput = t;
1351
- var r = inputToRGB(t);
1352
- this.originalInput = t, this.r = r.r, this.g = r.g, this.b = r.b, this.a = r.a, this.roundA = Math.round(100 * this.a) / 100, this.format = n.format ?? r.format, this.gradientType = n.gradientType, this.r < 1 && (this.r = Math.round(this.r)), this.g < 1 && (this.g = Math.round(this.g)), this.b < 1 && (this.b = Math.round(this.b)), this.isValid = r.ok;
1353
- }
1354
- return e.prototype.isDark = function() {
1355
- return this.getBrightness() < 128;
1356
- }, e.prototype.isLight = function() {
1357
- return !this.isDark();
1358
- }, e.prototype.getBrightness = function() {
1359
- var e = this.toRgb();
1360
- return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
1361
- }, e.prototype.getLuminance = function() {
1362
- var e = this.toRgb(), t, n, r, i = e.r / 255, a = e.g / 255, o = e.b / 255;
1363
- return t = i <= .03928 ? i / 12.92 : ((i + .055) / 1.055) ** 2.4, n = a <= .03928 ? a / 12.92 : ((a + .055) / 1.055) ** 2.4, r = o <= .03928 ? o / 12.92 : ((o + .055) / 1.055) ** 2.4, .2126 * t + .7152 * n + .0722 * r;
1364
- }, e.prototype.getAlpha = function() {
1365
- return this.a;
1366
- }, e.prototype.setAlpha = function(e) {
1367
- return this.a = boundAlpha(e), this.roundA = Math.round(100 * this.a) / 100, this;
1368
- }, e.prototype.isMonochrome = function() {
1369
- return this.toHsl().s === 0;
1370
- }, e.prototype.toHsv = function() {
1371
- var e = rgbToHsv(this.r, this.g, this.b);
1372
- return {
1373
- h: e.h * 360,
1374
- s: e.s,
1375
- v: e.v,
1376
- a: this.a
1377
- };
1378
- }, e.prototype.toHsvString = function() {
1379
- var e = rgbToHsv(this.r, this.g, this.b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), r = Math.round(e.v * 100);
1380
- return this.a === 1 ? `hsv(${t}, ${n}%, ${r}%)` : `hsva(${t}, ${n}%, ${r}%, ${this.roundA})`;
1381
- }, e.prototype.toHsl = function() {
1382
- var e = rgbToHsl(this.r, this.g, this.b);
1383
- return {
1384
- h: e.h * 360,
1385
- s: e.s,
1386
- l: e.l,
1387
- a: this.a
1388
- };
1389
- }, e.prototype.toHslString = function() {
1390
- var e = rgbToHsl(this.r, this.g, this.b), t = Math.round(e.h * 360), n = Math.round(e.s * 100), r = Math.round(e.l * 100);
1391
- return this.a === 1 ? `hsl(${t}, ${n}%, ${r}%)` : `hsla(${t}, ${n}%, ${r}%, ${this.roundA})`;
1392
- }, e.prototype.toHex = function(e) {
1393
- return e === void 0 && (e = !1), rgbToHex(this.r, this.g, this.b, e);
1394
- }, e.prototype.toHexString = function(e) {
1395
- return e === void 0 && (e = !1), "#" + this.toHex(e);
1396
- }, e.prototype.toHex8 = function(e) {
1397
- return e === void 0 && (e = !1), rgbaToHex(this.r, this.g, this.b, this.a, e);
1398
- }, e.prototype.toHex8String = function(e) {
1399
- return e === void 0 && (e = !1), "#" + this.toHex8(e);
1400
- }, e.prototype.toHexShortString = function(e) {
1401
- return e === void 0 && (e = !1), this.a === 1 ? this.toHexString(e) : this.toHex8String(e);
1402
- }, e.prototype.toRgb = function() {
1403
- return {
1404
- r: Math.round(this.r),
1405
- g: Math.round(this.g),
1406
- b: Math.round(this.b),
1407
- a: this.a
1408
- };
1409
- }, e.prototype.toRgbString = function() {
1410
- var e = Math.round(this.r), t = Math.round(this.g), n = Math.round(this.b);
1411
- return this.a === 1 ? `rgb(${e}, ${t}, ${n})` : `rgba(${e}, ${t}, ${n}, ${this.roundA})`;
1412
- }, e.prototype.toPercentageRgb = function() {
1413
- var e = function(e) {
1414
- return `${Math.round(bound01(e, 255) * 100)}%`;
1415
- };
1416
- return {
1417
- r: e(this.r),
1418
- g: e(this.g),
1419
- b: e(this.b),
1420
- a: this.a
1421
- };
1422
- }, e.prototype.toPercentageRgbString = function() {
1423
- var e = function(e) {
1424
- return Math.round(bound01(e, 255) * 100);
1425
- };
1426
- return this.a === 1 ? `rgb(${e(this.r)}%, ${e(this.g)}%, ${e(this.b)}%)` : `rgba(${e(this.r)}%, ${e(this.g)}%, ${e(this.b)}%, ${this.roundA})`;
1427
- }, e.prototype.toName = function() {
1428
- if (this.a === 0) return "transparent";
1429
- if (this.a < 1) return !1;
1430
- for (var e = "#" + rgbToHex(this.r, this.g, this.b, !1), t = 0, n = Object.entries(names); t < n.length; t++) {
1431
- var r = n[t], i = r[0];
1432
- if (e === r[1]) return i;
1433
- }
1434
- return !1;
1435
- }, e.prototype.toString = function(e) {
1436
- var t = !!e;
1437
- e ??= this.format;
1438
- var n = !1, r = this.a < 1 && this.a >= 0;
1439
- return !t && r && (e.startsWith("hex") || e === "name") ? e === "name" && this.a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (n = this.toRgbString()), e === "prgb" && (n = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (n = this.toHexString()), e === "hex3" && (n = this.toHexString(!0)), e === "hex4" && (n = this.toHex8String(!0)), e === "hex8" && (n = this.toHex8String()), e === "name" && (n = this.toName()), e === "hsl" && (n = this.toHslString()), e === "hsv" && (n = this.toHsvString()), n || this.toHexString());
1440
- }, e.prototype.toNumber = function() {
1441
- return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
1442
- }, e.prototype.clone = function() {
1443
- return new e(this.toString());
1444
- }, e.prototype.lighten = function(t) {
1445
- t === void 0 && (t = 10);
1446
- var n = this.toHsl();
1447
- return n.l += t / 100, n.l = clamp01(n.l), new e(n);
1448
- }, e.prototype.brighten = function(t) {
1449
- t === void 0 && (t = 10);
1450
- var n = this.toRgb();
1451
- return n.r = Math.max(0, Math.min(255, n.r - Math.round(255 * -(t / 100)))), n.g = Math.max(0, Math.min(255, n.g - Math.round(255 * -(t / 100)))), n.b = Math.max(0, Math.min(255, n.b - Math.round(255 * -(t / 100)))), new e(n);
1452
- }, e.prototype.darken = function(t) {
1453
- t === void 0 && (t = 10);
1454
- var n = this.toHsl();
1455
- return n.l -= t / 100, n.l = clamp01(n.l), new e(n);
1456
- }, e.prototype.tint = function(e) {
1457
- return e === void 0 && (e = 10), this.mix("white", e);
1458
- }, e.prototype.shade = function(e) {
1459
- return e === void 0 && (e = 10), this.mix("black", e);
1460
- }, e.prototype.desaturate = function(t) {
1461
- t === void 0 && (t = 10);
1462
- var n = this.toHsl();
1463
- return n.s -= t / 100, n.s = clamp01(n.s), new e(n);
1464
- }, e.prototype.saturate = function(t) {
1465
- t === void 0 && (t = 10);
1466
- var n = this.toHsl();
1467
- return n.s += t / 100, n.s = clamp01(n.s), new e(n);
1468
- }, e.prototype.greyscale = function() {
1469
- return this.desaturate(100);
1470
- }, e.prototype.spin = function(t) {
1471
- var n = this.toHsl(), r = (n.h + t) % 360;
1472
- return n.h = r < 0 ? 360 + r : r, new e(n);
1473
- }, e.prototype.mix = function(t, n) {
1474
- n === void 0 && (n = 50);
1475
- var r = this.toRgb(), i = new e(t).toRgb(), a = n / 100;
1476
- return new e({
1477
- r: (i.r - r.r) * a + r.r,
1478
- g: (i.g - r.g) * a + r.g,
1479
- b: (i.b - r.b) * a + r.b,
1480
- a: (i.a - r.a) * a + r.a
1481
- });
1482
- }, e.prototype.analogous = function(t, n) {
1483
- t === void 0 && (t = 6), n === void 0 && (n = 30);
1484
- var r = this.toHsl(), i = 360 / n, a = [this];
1485
- for (r.h = (r.h - (i * t >> 1) + 720) % 360; --t;) r.h = (r.h + i) % 360, a.push(new e(r));
1486
- return a;
1487
- }, e.prototype.complement = function() {
1488
- var t = this.toHsl();
1489
- return t.h = (t.h + 180) % 360, new e(t);
1490
- }, e.prototype.monochromatic = function(t) {
1491
- t === void 0 && (t = 6);
1492
- for (var n = this.toHsv(), r = n.h, i = n.s, a = n.v, o = [], s = 1 / t; t--;) o.push(new e({
1493
- h: r,
1494
- s: i,
1495
- v: a
1496
- })), a = (a + s) % 1;
1497
- return o;
1498
- }, e.prototype.splitcomplement = function() {
1499
- var t = this.toHsl(), n = t.h;
1500
- return [
1501
- this,
1502
- new e({
1503
- h: (n + 72) % 360,
1504
- s: t.s,
1505
- l: t.l
1506
- }),
1507
- new e({
1508
- h: (n + 216) % 360,
1509
- s: t.s,
1510
- l: t.l
1511
- })
1512
- ];
1513
- }, e.prototype.onBackground = function(t) {
1514
- var n = this.toRgb(), r = new e(t).toRgb(), i = n.a + r.a * (1 - n.a);
1515
- return new e({
1516
- r: (n.r * n.a + r.r * r.a * (1 - n.a)) / i,
1517
- g: (n.g * n.a + r.g * r.a * (1 - n.a)) / i,
1518
- b: (n.b * n.a + r.b * r.a * (1 - n.a)) / i,
1519
- a: i
1520
- });
1521
- }, e.prototype.triad = function() {
1522
- return this.polyad(3);
1523
- }, e.prototype.tetrad = function() {
1524
- return this.polyad(4);
1525
- }, e.prototype.polyad = function(t) {
1526
- for (var n = this.toHsl(), r = n.h, i = [this], a = 360 / t, o = 1; o < t; o++) i.push(new e({
1527
- h: (r + o * a) % 360,
1528
- s: n.s,
1529
- l: n.l
1530
- }));
1531
- return i;
1532
- }, e.prototype.equals = function(t) {
1533
- return this.toRgbString() === new e(t).toRgbString();
1534
- }, e;
1535
- }();
1536
- const viewFadeIn = new Keyframe("viewFadeIn", {
1537
- "0%": { opacity: 0 },
1538
- "100%": { opacity: 1 }
1539
- }), viewFadeOut = new Keyframe("viewFadeOut", {
1540
- "0%": { opacity: 1 },
1541
- "100%": { opacity: 0 }
1542
- });
1543
- var viewZoomBadgeIn = new Keyframe("viewZoomBadgeIn", {
1544
- "0%": {
1545
- transform: "scale(0)",
1546
- opacity: 0
1547
- },
1548
- "100%": {
1549
- transform: "scale(1)",
1550
- opacity: 1
1551
- }
1552
- }), viewZoomBadgeOut = new Keyframe("viewZoomBadgeOut", {
1553
- "0%": { transform: "scale(1)" },
1554
- "100%": {
1555
- transform: "scale(0)",
1556
- opacity: 0
1557
- }
1558
- });
1559
- function genBoxStyle$1(e) {
1560
- return {
1561
- position: e || "absolute",
1562
- inset: 0
1563
- };
1564
- }
1565
- function box(e) {
1566
- return {
1567
- position: e,
1568
- top: 0,
1569
- insetInlineEnd: 0,
1570
- bottom: 0,
1571
- insetInlineStart: 0
1572
- };
1573
- }
1574
- function genPreviewOperationsStyle(e) {
1575
- let { previewCls: t, modalMaskBg: n, marginXL: r, margin: i, colorTextLightSolid: a, previewOperationColorDisabled: o, previewOperationHoverColor: s, motionDurationSlow: c, iconCls: l } = e, u = new TinyColor(n).setAlpha(.1), d = u.clone().setAlpha(.2), f = new TinyColor(n).setAlpha(.5), p = new TinyColor(n).setAlpha(.03);
1576
- return {
1577
- [`${t}-footer`]: {
1578
- position: "fixed",
1579
- bottom: r,
1580
- left: {
1581
- _skip_check_: !0,
1582
- value: "50%"
1583
- },
1584
- display: "flex",
1585
- flexDirection: "column",
1586
- alignItems: "center",
1587
- color: e.previewOperationColor,
1588
- transform: "translateX(-50%)"
1589
- },
1590
- [`${t}-progress`]: { marginBottom: i },
1591
- [`${t}-close`]: {
1592
- position: "fixed",
1593
- top: r,
1594
- right: {
1595
- _skip_check_: !0,
1596
- value: r
1597
- },
1598
- display: "flex",
1599
- alignItems: "center",
1600
- justifyContent: "center",
1601
- color: a,
1602
- backgroundColor: u.toRgbString(),
1603
- borderRadius: e.borderRadiusLG,
1604
- backdropFilter: "saturate(180%) blur(10px)",
1605
- width: e.sizeXL,
1606
- height: e.sizeXL,
1607
- outline: 0,
1608
- border: 0,
1609
- cursor: "pointer",
1610
- transition: `all ${c}`,
1611
- "&:hover": { backgroundColor: d.toRgbString() },
1612
- [`& > ${l}`]: { fontSize: e.previewOperationSize }
1613
- },
1614
- [`${t}-operations`]: {
1615
- display: "flex",
1616
- alignItems: "center",
1617
- gap: e.sizeXXS,
1618
- padding: e.paddingXXS,
1619
- border: `1px solid ${e.colorBorderSecondary}`,
1620
- backgroundColor: f.toRgbString(),
1621
- borderRadius: e.borderRadiusLG,
1622
- backdropFilter: "saturate(150%) blur(10px)",
1623
- "&-operation": {
1624
- display: "flex",
1625
- alignItems: "center",
1626
- justifyContent: "center",
1627
- width: e.sizeXL + 4,
1628
- height: e.sizeXL + 4,
1629
- cursor: "pointer",
1630
- color: a,
1631
- borderRadius: e.borderRadiusSM,
1632
- transition: `all ${c}`,
1633
- userSelect: "none",
1634
- [`&:not(${t}-operations-operation-disabled):hover > ${l}`]: { color: s },
1635
- "&:hover": { backgroundColor: p.toRgbString() },
1636
- "&-disabled": {
1637
- color: o,
1638
- cursor: "not-allowed"
1639
- },
1640
- "&:first-of-type": { marginInlineStart: 0 },
1641
- [`& > ${l}`]: { fontSize: e.previewOperationSize }
1642
- }
1643
- }
1644
- };
1645
- }
1646
- function genPreviewSwitchStyle(e) {
1647
- let { modalMaskBg: t, iconCls: n, previewOperationColorDisabled: r, previewCls: i, zIndexPopup: a, motionDurationSlow: o, colorTextLightSolid: s } = e, c = new TinyColor(t).setAlpha(.1), l = c.clone().setAlpha(.2);
1648
- return {
1649
- [`${i}-switch-left, ${i}-switch-right`]: {
1650
- position: "fixed",
1651
- insetBlockStart: "50%",
1652
- zIndex: e.calc(a).add(1).equal(),
1653
- display: "flex",
1654
- alignItems: "center",
1655
- justifyContent: "center",
1656
- borderRadius: e.borderRadius,
1657
- backdropFilter: "saturate(180%) blur(10px)",
1658
- width: e.imagePreviewSwitchSize,
1659
- height: e.imagePreviewSwitchSize,
1660
- marginTop: e.calc(e.imagePreviewSwitchSize).mul(-1).div(2).equal(),
1661
- color: s,
1662
- background: c.toRgbString(),
1663
- transform: "translateY(-50%)",
1664
- cursor: "pointer",
1665
- transition: `all ${o}`,
1666
- userSelect: "none",
1667
- "&:hover": { background: l.toRgbString() },
1668
- "&-disabled": { "&, &:hover": {
1669
- color: r,
1670
- background: "transparent",
1671
- cursor: "not-allowed",
1672
- [`> ${n}`]: { cursor: "not-allowed" }
1673
- } },
1674
- [`> ${n}`]: { fontSize: e.previewOperationSize }
1675
- },
1676
- [`${i}-switch-left`]: { insetInlineStart: e.marginSM },
1677
- [`${i}-switch-right`]: { insetInlineEnd: e.marginSM }
1678
- };
1679
- }
1680
- var genImagePreviewStyle = (e) => {
1681
- let { motionEaseOut: t, motionDurationSlow: n } = e;
1682
- return {
1683
- [e.componentCls]: {
1684
- height: "100%",
1685
- textAlign: "center",
1686
- pointerEvents: "none",
1687
- "&-root": {
1688
- ...box("fixed"),
1689
- zIndex: e.zIndexPopup,
1690
- overflow: "auto",
1691
- outline: 0,
1692
- WebkitOverflowScrolling: "touch"
1693
- },
1694
- "&-wrap": {
1695
- ...box("fixed"),
1696
- zIndex: e.zIndexPopup,
1697
- overflow: "auto",
1698
- outline: 0,
1699
- WebkitOverflowScrolling: "touch"
1700
- },
1701
- "&-mask": {
1702
- ...box("fixed"),
1703
- zIndex: e.zIndexPopupBase,
1704
- height: "100%",
1705
- backgroundColor: e.colorBgMask,
1706
- backdropFilter: "blur(8px)"
1707
- },
1708
- "&-body": {
1709
- ...genBoxStyle$1(),
1710
- overflow: "hidden"
1711
- },
1712
- "&-img": {
1713
- maxWidth: "100%",
1714
- maxHeight: "70%",
1715
- verticalAlign: "middle",
1716
- transform: "scale3d(1, 1, 1)",
1717
- cursor: "grab",
1718
- transition: `transform ${n} ${t} 0s`,
1719
- userSelect: "none",
1720
- "&-wrapper": {
1721
- ...genBoxStyle$1(),
1722
- transition: `transform ${n} ${t} 0s`,
1723
- display: "flex",
1724
- justifyContent: "center",
1725
- alignItems: "center",
1726
- "& > *": { pointerEvents: "auto" },
1727
- "&::before": {
1728
- display: "inline-block",
1729
- width: 1,
1730
- height: "50%",
1731
- marginInlineEnd: -1,
1732
- content: "\"\""
1733
- }
1734
- }
1735
- },
1736
- "&-moving": { [`${e.componentCls}-view-img`]: {
1737
- cursor: "grabbing",
1738
- "&-wrapper": { transitionDuration: "0s" }
1739
- } },
1740
- "&-mask-zoom-appear, &-mask-zoom-enter": {
1741
- animationName: viewFadeIn,
1742
- animationDuration: e.motionDurationSlow,
1743
- animationTimingFunction: "linear",
1744
- userSelect: "none"
1745
- },
1746
- "&-mask-zoom-leave": {
1747
- animationName: viewFadeOut,
1748
- animationDuration: e.motionDurationSlow,
1749
- animationTimingFunction: "linear",
1750
- pointerEvents: "none"
1751
- },
1752
- "&-zoom-appear, &-zoom-enter": {
1753
- animationName: viewZoomBadgeIn,
1754
- opacity: 0,
1755
- animationTimingFunction: e.motionEaseOutCirc,
1756
- animationFillMode: "both",
1757
- transform: "none",
1758
- animationDuration: e.motionDurationMid,
1759
- userSelect: "none"
1760
- },
1761
- "&-zoom-enter-active": { animationPlayState: "running" },
1762
- "&-zoom-leave": {
1763
- animationName: viewZoomBadgeOut,
1764
- animationDuration: e.motionDurationSlow,
1765
- animationTimingFunction: e.motionEaseInOutCirc,
1766
- animationFillMode: "both"
1767
- }
1768
- },
1769
- [`${e.componentCls}-root`]: { [`${e.componentCls}-wrapper`]: { zIndex: e.zIndexPopup } },
1770
- [`${e.componentCls}-operations-wrapper`]: {
1771
- position: "fixed",
1772
- insetBlockStart: 0,
1773
- insetInlineEnd: 0,
1774
- zIndex: e.calc(e.zIndexPopup).add(1).equal(),
1775
- width: "100%"
1776
- },
1777
- "&": [genPreviewOperationsStyle(e), genPreviewSwitchStyle(e)]
1778
- };
1779
- };
1780
- function useStyle$1(e) {
1781
- return useStyle("ImageViewer", (e) => [genImagePreviewStyle(mergeToken(e, {
1782
- zIndexPopup: e.zIndexPopupBase + 80,
1783
- previewOperationColor: new TinyColor(e.colorTextLightSolid).setAlpha(.65).toRgbString(),
1784
- previewOperationHoverColor: new TinyColor(e.colorTextLightSolid).setAlpha(.85).toRgbString(),
1785
- previewOperationColorDisabled: new TinyColor(e.colorTextLightSolid).setAlpha(.25).toRgbString(),
1786
- imagePreviewSwitchSize: e.sizeXL,
1787
- modalMaskBg: new TinyColor("#000").setAlpha(.45).toRgbString(),
1788
- previewOperationSize: e.fontSizeIcon * 1.5,
1789
- iconCls: ".anticon",
1790
- previewCls: e.componentCls
1791
- }))], e);
1792
- }
1793
- var KeyCode = {
1794
- MAC_ENTER: 3,
1795
- BACKSPACE: 8,
1796
- TAB: 9,
1797
- NUM_CENTER: 12,
1798
- ENTER: 13,
1799
- SHIFT: 16,
1800
- CTRL: 17,
1801
- ALT: 18,
1802
- PAUSE: 19,
1803
- CAPS_LOCK: 20,
1804
- ESC: 27,
1805
- SPACE: 32,
1806
- PAGE_UP: 33,
1807
- PAGE_DOWN: 34,
1808
- END: 35,
1809
- HOME: 36,
1810
- LEFT: 37,
1811
- UP: 38,
1812
- RIGHT: 39,
1813
- DOWN: 40,
1814
- PRINT_SCREEN: 44,
1815
- INSERT: 45,
1816
- DELETE: 46,
1817
- ZERO: 48,
1818
- ONE: 49,
1819
- TWO: 50,
1820
- THREE: 51,
1821
- FOUR: 52,
1822
- FIVE: 53,
1823
- SIX: 54,
1824
- SEVEN: 55,
1825
- EIGHT: 56,
1826
- NINE: 57,
1827
- QUESTION_MARK: 63,
1828
- A: 65,
1829
- B: 66,
1830
- C: 67,
1831
- D: 68,
1832
- E: 69,
1833
- F: 70,
1834
- G: 71,
1835
- H: 72,
1836
- I: 73,
1837
- J: 74,
1838
- K: 75,
1839
- L: 76,
1840
- M: 77,
1841
- N: 78,
1842
- O: 79,
1843
- P: 80,
1844
- Q: 81,
1845
- R: 82,
1846
- S: 83,
1847
- T: 84,
1848
- U: 85,
1849
- V: 86,
1850
- W: 87,
1851
- X: 88,
1852
- Y: 89,
1853
- Z: 90,
1854
- META: 91,
1855
- WIN_KEY_RIGHT: 92,
1856
- CONTEXT_MENU: 93,
1857
- NUM_ZERO: 96,
1858
- NUM_ONE: 97,
1859
- NUM_TWO: 98,
1860
- NUM_THREE: 99,
1861
- NUM_FOUR: 100,
1862
- NUM_FIVE: 101,
1863
- NUM_SIX: 102,
1864
- NUM_SEVEN: 103,
1865
- NUM_EIGHT: 104,
1866
- NUM_NINE: 105,
1867
- NUM_MULTIPLY: 106,
1868
- NUM_PLUS: 107,
1869
- NUM_MINUS: 109,
1870
- NUM_PERIOD: 110,
1871
- NUM_DIVISION: 111,
1872
- F1: 112,
1873
- F2: 113,
1874
- F3: 114,
1875
- F4: 115,
1876
- F5: 116,
1877
- F6: 117,
1878
- F7: 118,
1879
- F8: 119,
1880
- F9: 120,
1881
- F10: 121,
1882
- F11: 122,
1883
- F12: 123,
1884
- NUMLOCK: 144,
1885
- SEMICOLON: 186,
1886
- DASH: 189,
1887
- EQUALS: 187,
1888
- COMMA: 188,
1889
- PERIOD: 190,
1890
- SLASH: 191,
1891
- APOSTROPHE: 192,
1892
- SINGLE_QUOTE: 222,
1893
- OPEN_SQUARE_BRACKET: 219,
1894
- BACKSLASH: 220,
1895
- CLOSE_SQUARE_BRACKET: 221,
1896
- WIN_KEY: 224,
1897
- MAC_FF_META: 224,
1898
- WIN_IME: 229,
1899
- isTextModifyingKeyEvent: function(e) {
1900
- let { keyCode: t } = e;
1901
- if (e.altKey && !e.ctrlKey || e.metaKey || t >= KeyCode.F1 && t <= KeyCode.F12) return !1;
1902
- switch (t) {
1903
- case KeyCode.ALT:
1904
- case KeyCode.CAPS_LOCK:
1905
- case KeyCode.CONTEXT_MENU:
1906
- case KeyCode.CTRL:
1907
- case KeyCode.DOWN:
1908
- case KeyCode.END:
1909
- case KeyCode.ESC:
1910
- case KeyCode.HOME:
1911
- case KeyCode.INSERT:
1912
- case KeyCode.LEFT:
1913
- case KeyCode.MAC_FF_META:
1914
- case KeyCode.META:
1915
- case KeyCode.NUMLOCK:
1916
- case KeyCode.NUM_CENTER:
1917
- case KeyCode.PAGE_DOWN:
1918
- case KeyCode.PAGE_UP:
1919
- case KeyCode.PAUSE:
1920
- case KeyCode.PRINT_SCREEN:
1921
- case KeyCode.RIGHT:
1922
- case KeyCode.SHIFT:
1923
- case KeyCode.UP:
1924
- case KeyCode.WIN_KEY:
1925
- case KeyCode.WIN_KEY_RIGHT: return !1;
1926
- default: return !0;
1927
- }
1928
- },
1929
- isCharacterKey: function(e) {
1930
- if (e >= KeyCode.ZERO && e <= KeyCode.NINE || e >= KeyCode.NUM_ZERO && e <= KeyCode.NUM_MULTIPLY || e >= KeyCode.A && e <= KeyCode.Z || window.navigator.userAgent.includes("WebKit") && e === 0) return !0;
1931
- switch (e) {
1932
- case KeyCode.SPACE:
1933
- case KeyCode.QUESTION_MARK:
1934
- case KeyCode.NUM_PLUS:
1935
- case KeyCode.NUM_MINUS:
1936
- case KeyCode.NUM_PERIOD:
1937
- case KeyCode.NUM_DIVISION:
1938
- case KeyCode.SEMICOLON:
1939
- case KeyCode.DASH:
1940
- case KeyCode.EQUALS:
1941
- case KeyCode.COMMA:
1942
- case KeyCode.PERIOD:
1943
- case KeyCode.SLASH:
1944
- case KeyCode.APOSTROPHE:
1945
- case KeyCode.SINGLE_QUOTE:
1946
- case KeyCode.OPEN_SQUARE_BRACKET:
1947
- case KeyCode.BACKSLASH:
1948
- case KeyCode.CLOSE_SQUARE_BRACKET: return !0;
1949
- default: return !1;
1950
- }
1951
- }
1952
- }, defaultIcons = {
1953
- rotateLeft: createVNode(RotateLeftOutlined, null, null),
1954
- rotateRight: createVNode(RotateRightOutlined, null, null),
1955
- zoomIn: createVNode(ZoomInOutlined, null, null),
1956
- zoomOut: createVNode(ZoomOutOutlined, null, null),
1957
- flipX: createVNode(SwapOutlined, null, null),
1958
- flipY: createVNode(SwapOutlined, { rotate: 90 }, null)
1959
- }, GImagePreview = /* @__PURE__ */ defineComponent({
1960
- name: "GImagePreview",
1961
- props: props_default,
1962
- inheritAttrs: !1,
1963
- slots: Object,
1964
- emits: {
1965
- close: () => !0,
1966
- transform: (e) => !0,
1967
- "update:open": (e) => !0
1968
- },
1969
- setup: (r, { emit: o, expose: s, slots: c }) => {
1970
- let l = getPrefixCls({ suffixCls: "image-view" }), { wrapSSR: u, hashId: d } = useStyle$1(l), [f, m, y] = useMergedState(r.open, {
1971
- value: toRef(r, "open"),
1972
- onChange: (e) => {
1973
- r.onOpenChange?.(e), o("update:open", e);
1974
- }
1975
- }), [x, S] = useState(!1), [w, E] = useState(!0), D = ref(), { transform: O, resetTransform: k, updateTransform: A, dispatchZoomChange: j } = useImageTransform(D, toRef(r, "minScale"), toRef(r, "maxScale"), r.onTransform), { isMoving: M, onMouseDown: N, onWheel: P } = useMouseEvent(D, toRef(r, "movable"), y, toRef(r, "scaleStep"), O, A, j), { isTouching: F, onTouchStart: I, onTouchMove: R, onTouchEnd: z } = useTouchEvent(D, toRef(r, "movable"), y, toRef(r, "minScale"), O, A, j);
1976
- useEffect(() => {
1977
- w.value || E(!0);
1978
- }, [w]);
1979
- let B = ref(null), V = ref(r.current), H = reactive(/* @__PURE__ */ new Map()), U = computed(() => new Map(Array.from(H).map(([e, { url: t }]) => [e, t]))), ne = computed(() => U.value.get(V.value)), W = computed(() => U.value.size), G = computed(() => Array.from(U.value.keys())), K = computed(() => G.value.indexOf(V.value)), q = computed(() => W.value > 1), re = computed(() => W.value >= 1);
1980
- watch(y, (e) => {
1981
- e && (x.value = !0);
1982
- });
1983
- let J = (e) => {
1984
- V.value = e;
1985
- };
1986
- watch(() => r.current, (e) => {
1987
- isNumber(e) && J(e);
1988
- });
1989
- function ie(e, t) {
1990
- H.set(e, {
1991
- url: t,
1992
- loading: !0,
1993
- canPreview: !1
1994
- });
1995
- }
1996
- let Y = () => {
1997
- S(!1);
1998
- }, ae = () => {
1999
- k("close"), o("close");
2000
- }, oe = (e) => {
2001
- M.value || B.value === e?.target && Y();
2002
- }, se = () => {
2003
- let e = H.get(V.value);
2004
- e && (e.loading = !1, e.canPreview = !0);
2005
- }, ce = (e) => {
2006
- let t = H.get(V.value);
2007
- t && (t.loading = !1, t.canPreview = !1), e.target.alt = "加载失败";
2008
- }, X = () => {
2009
- if (K.value > 0 || r.infinite) {
2010
- let e = K.value - 1 < 0 ? r.urls.length - 1 : K.value - 1;
2011
- J(G.value[e]), k("prev");
2012
- }
2013
- }, Z = () => {
2014
- if (K.value < W.value - 1 || r.infinite) {
2015
- let e = K.value + 1 > r.urls.length - 1 ? 0 : K.value + 1;
2016
- J(G.value[e]), k("next");
2017
- }
2018
- }, le = () => {
2019
- j(1 + r.scaleStep, "zoomIn");
2020
- }, ue = () => {
2021
- j(1 / (1 + r.scaleStep), "zoomOut");
2022
- }, de = () => {
2023
- A({ rotate: O.value.rotate + 90 }, "rotateRight");
2024
- }, fe = () => {
2025
- A({ rotate: O.value.rotate - 90 }, "rotateLeft");
2026
- }, pe = () => {
2027
- A({ flipX: !O.value.flipX }, "flipX");
2028
- }, me = () => {
2029
- A({ flipY: !O.value.flipY }, "flipY");
2030
- }, Q = () => {
2031
- let e = getSlotsProps({
2032
- slots: c,
2033
- props: r.icons,
2034
- keys: [
2035
- "flipY",
2036
- "flipX",
2037
- "rotateLeft",
2038
- "rotateRight",
2039
- "zoomOut",
2040
- "zoomIn"
2041
- ],
2042
- render: !0,
2043
- defaultVNodes: [
2044
- defaultIcons.flipY,
2045
- defaultIcons.flipX,
2046
- defaultIcons.rotateLeft,
2047
- defaultIcons.rotateRight,
2048
- defaultIcons.zoomOut,
2049
- defaultIcons.zoomIn
2050
- ]
2051
- });
2052
- return [
2053
- {
2054
- icon: e.flipY,
2055
- onClick: me,
2056
- type: "flipY"
2057
- },
2058
- {
2059
- icon: e.flipX,
2060
- onClick: pe,
2061
- type: "flipX"
2062
- },
2063
- {
2064
- icon: e.rotateLeft,
2065
- onClick: fe,
2066
- type: "rotateLeft"
2067
- },
2068
- {
2069
- icon: e.rotateRight,
2070
- onClick: de,
2071
- type: "rotateRight"
2072
- },
2073
- {
2074
- icon: e.zoomOut,
2075
- onClick: () => ue(),
2076
- type: "zoomOut",
2077
- disabled: computed(() => O.value.scale <= r.minScale)
2078
- },
2079
- {
2080
- icon: e.zoomIn,
2081
- onClick: () => le(),
2082
- type: "zoomIn",
2083
- disabled: computed(() => O.value.scale === r.maxScale)
2084
- }
2085
- ];
2086
- }, he = (e) => {
2087
- y.value && (O.value.scale === 1 ? j(1 + r.scaleStep, "doubleClick", e.clientX, e.clientY) : A({
2088
- x: 0,
2089
- y: 0,
2090
- scale: 1
2091
- }, "doubleClick"));
2092
- }, ge = (e) => {
2093
- e.keyCode === KeyCode.ESC && Y(), !(!y.value || !q.value) && (e.keyCode === KeyCode.LEFT ? X() : e.keyCode === KeyCode.RIGHT && Z());
2094
- }, $ = () => {};
2095
- return onMounted(() => {
2096
- watch(() => r.urls, (e) => {
2097
- isArray(e) && e.forEach((e, t) => {
2098
- ie(t, e);
2099
- });
2100
- }, {
2101
- flush: "post",
2102
- immediate: !0
2103
- }), watch([() => y.value, () => M.value], () => {
2104
- $();
2105
- let e = addEventListenerWrap(window, "keydown", ge, !1);
2106
- $ = () => {
2107
- e.remove();
2108
- };
2109
- }, {
2110
- flush: "post",
2111
- immediate: !0
2112
- });
2113
- }), onUnmounted(() => {
2114
- $();
2115
- }), s({ setOpen: (e) => {
2116
- m(e), V.value = r.current;
2117
- } }), () => {
2118
- let i = getTransitionProps(`${l}-mask-zoom`), o = getTransitionProps(`${l}-zoom`), s = {};
2119
- for (let e in r.icons) s[e] = getSlotVNode({
2120
- slots: c,
2121
- props: r.icons,
2122
- key: e
2123
- });
2124
- return u(createVNode(Fragment, null, [createVNode(Teleport, { to: r.getContainer || "body" }, { default: () => [y.value && createVNode(Fragment, null, [createVNode("div", { class: `${l}-root ${d.value}` }, [createVNode(Transition, i, { default: () => [withDirectives(createVNode("div", { class: `${l}-mask ${d.value}` }, null), [[vShow, y.value && x.value]])] }), createVNode("div", {
2125
- ref: B,
2126
- tabindex: -1,
2127
- class: [
2128
- `${l}-wrap`,
2129
- `${d.value}`,
2130
- M.value && `${l}-moving`
2131
- ],
2132
- onClick: (e) => r.onHideOnClickModal && oe(e)
2133
- }, [createVNode(Transition, mergeProps(o, { onAfterLeave: () => ae() }), { default: () => [withDirectives(createVNode("div", {
2134
- role: "dialog",
2135
- class: `${l} ${d.value}`
2136
- }, [createVNode("div", { class: `${l}-content ${d.value}` }, [createVNode("div", { class: `${l}-body ${d.value}` }, [createVNode("div", { class: `${l}-img-wrapper ${d.value}` }, [createVNode("img", {
2137
- ref: D,
2138
- class: `${l}-img ${d.value}`,
2139
- src: ne.value,
2140
- onLoad: () => se(),
2141
- onError: (e) => ce(e),
2142
- style: {
2143
- transform: `translate3d(${O.value.x}px, ${O.value.y}px, 0) scale3d(${O.value.flipX ? "-" : ""}${O.value.scale}, ${O.value.flipY ? "-" : ""}${O.value.scale}, 1) rotate(${O.value.rotate}deg)`,
2144
- transitionDuration: !w.value || F.value ? "0s" : void 0
2145
- },
2146
- onWheel: P,
2147
- onMousedown: N,
2148
- onDblclick: he,
2149
- onTouchstart: I,
2150
- onTouchmove: R,
2151
- onTouchend: z,
2152
- onTouchcancel: z
2153
- }, null)])])])]), [[vShow, y.value && x.value]])] })])])])] }), y.value && x.value && createVNode(Operations_default, {
2154
- open: y.value && x.value,
2155
- hashId: d.value,
2156
- count: r.urls.length,
2157
- current: V.value,
2158
- zIndex: r.zIndex + 1,
2159
- getContainer: r.getContainer,
2160
- prefixCls: l,
2161
- icons: omit(s, Q().map(({ type: e }) => e)),
2162
- tools: Q(),
2163
- infinite: r.infinite,
2164
- countRender: getSlot({
2165
- slots: c,
2166
- props: r,
2167
- key: "countRender"
2168
- }),
2169
- showSwitch: q.value,
2170
- showProgress: re.value,
2171
- onClose: Y,
2172
- onActive: (e) => e > 0 ? Z() : X()
2173
- }, null)]));
2174
- };
2175
- }
2176
- }), fullSize = {
2177
- width: "100%",
2178
- height: "100%"
2179
- }, textEllipsis = {
2180
- overflow: "hidden",
2181
- whiteSpace: "nowrap",
2182
- textOverflow: "ellipsis"
2183
- };
2184
- function genImageMaskStyle(e) {
2185
- let { motionDurationSlow: t, paddingXXS: n, marginXXS: r, colorTextLightSolid: i } = e;
2186
- return {
2187
- position: "absolute",
2188
- inset: 0,
2189
- display: "flex",
2190
- alignItems: "center",
2191
- justifyContent: "center",
2192
- color: i,
2193
- background: new FastColor("#000").setA(.5).toRgbString(),
2194
- cursor: "pointer",
2195
- opacity: 0,
2196
- transition: `opacity ${t}`,
2197
- [`.${e.componentCls}-mask-info`]: {
2198
- ...textEllipsis,
2199
- padding: `0 ${unit(n)}`,
2200
- ".anticon": {
2201
- marginInlineEnd: r,
2202
- svg: { verticalAlign: "baseline" }
2203
- }
2204
- }
2205
- };
2206
- }
2207
- function genBoxStyle(e) {
2208
- return {
2209
- position: e || "absolute",
2210
- inset: 0
2211
- };
2212
- }
2213
- const genImageStyle = (e) => ({ [e.componentCls]: {
2214
- display: "inline-block",
2215
- position: "relative",
2216
- overflow: "hidden",
2217
- [`${e.componentCls}-img`]: {
2218
- ...fullSize,
2219
- verticalAlign: "top",
2220
- opacity: 1,
2221
- [`&${e.componentCls}-img-preview`]: {
2222
- userSelect: "none",
2223
- cursor: "pointer"
2224
- },
2225
- "&-placeholder": {
2226
- ...fullSize,
2227
- backgroundColor: e.colorBgContainerDisabled,
2228
- backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
2229
- backgroundRepeat: "no-repeat",
2230
- backgroundPosition: "center center",
2231
- backgroundSize: "30%"
2232
- }
2233
- },
2234
- [`${e.componentCls}-error`]: {
2235
- ...fullSize,
2236
- display: "flex",
2237
- alignItems: "center",
2238
- justifyContent: "center"
2239
- },
2240
- [`${e.componentCls}-placeholder`]: { ...genBoxStyle() },
2241
- [`${e.componentCls}-mask`]: { ...genImageMaskStyle(e) },
2242
- [`${e.componentCls}-mask:hover`]: { opacity: 1 }
2243
- } });
2244
- function isElement(e) {
2245
- return typeof Element > "u" ? !1 : e instanceof Element;
2246
- }
2247
- var prevOverflow = "";
2248
- function fromPairs(e) {
2249
- let t = {};
2250
- for (let n = 0; n < e.length; n++) {
2251
- let r = e[n];
2252
- t[r[0]] = r[1];
2253
- }
2254
- return t;
2255
- }
2256
- var GImage = /* @__PURE__ */ defineComponent({
2257
- props: imageProps,
2258
- name: "GImage",
2259
- inheritAttrs: !1,
2260
- emits: {
2261
- click: (e) => !0,
2262
- load: (e) => !0,
2263
- error: (e) => !0
2264
- },
2265
- slots: Object,
2266
- setup(t, { slots: n, emit: r, attrs: o }) {
2267
- let s = isClient && "loading" in HTMLImageElement.prototype, c = getPrefixCls({ suffixCls: "image" }), { wrapSSR: l, hashId: u } = useProStyle("Image", [genImageStyle], c), d = ref(), f = ref(), g = ref(!1), _ = ref(!0), y = ref(!1), b = ref(), x = ref(), S, C, T = computed(() => t.loading === "eager" ? !1 : !s && t.loading === "lazy" || t.lazy), E = computed(() => isClient && t.fit ? {
2268
- ...t.imageStyle,
2269
- objectFit: t.fit
2270
- } : t.imageStyle), O = computed(() => typeof t.preview == "object" ? t.preview : {}), k = computed(() => !!t.preview), A = computed(() => {
2271
- let { urls: e = [], current: n = 0 } = O.value;
2272
- if (isNumber(n)) return e.length >= n ? n : 0;
2273
- let r = e.indexOf(t.src);
2274
- return r >= 0 ? r : 0;
2275
- }), j = computed(() => unit(t.width)), M = computed(() => unit(t.height)), N = () => {
2276
- isClient && (_.value = !0, g.value = !1, f.value = t.src);
2277
- };
2278
- function P(e) {
2279
- g.value || (_.value = !1, g.value = !1, r("load", e));
2280
- }
2281
- function F(e) {
2282
- _.value = !1, g.value = !0, r("error", e);
2283
- }
2284
- function I() {
2285
- isInContainer(b.value, x.value) && (N(), V());
2286
- }
2287
- let L = useThrottleFn(I, 200, !0);
2288
- async function R() {
2289
- if (!isClient) return;
2290
- await nextTick();
2291
- let { scrollContainer: e } = t;
2292
- isElement(e) ? x.value = e : isString(e) && e !== "" ? x.value = document.querySelector(e) ?? void 0 : b.value && (x.value = getScrollContainer(b.value)), x.value && (S = useEventListener(x, "scroll", L), setTimeout(() => I(), 100));
2293
- }
2294
- function V() {
2295
- !isClient || !x.value || !L || (S?.(), x.value = void 0);
2296
- }
2297
- function H(e) {
2298
- if (e.ctrlKey && (e.deltaY < 0 || e.deltaY > 0)) return e.preventDefault(), !1;
2299
- }
2300
- let U = () => {
2301
- r("click", _.value ? "loaded" : g.value ? "error" : "success"), !(_.value || g.value) && k.value && (C = useEventListener("wheel", H, { passive: !1 }), prevOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", y.value = !0);
2302
- }, te = () => {
2303
- C?.(), document.body.style.overflow = prevOverflow, y.value = !1;
2304
- };
2305
- return watch(() => t.src, () => {
2306
- T.value ? (_.value = !0, g.value = !1, V(), R()) : N();
2307
- }), watchEffect(() => {
2308
- k.value && y.value ? d.value?.setOpen(!0) : d.value?.setOpen(!1);
2309
- }), onMounted(() => {
2310
- T.value ? R() : N();
2311
- }), () => {
2312
- let r = fromPairs(Object.entries(o).filter(([e]) => /^(?:data-|on[A-Z])/i.test(e) || [
2313
- "id",
2314
- "style",
2315
- "class"
2316
- ].includes(e))), i = omit(o, Object.keys(r)), s = getSlotsProps({
2317
- slots: n,
2318
- props: t,
2319
- keys: [
2320
- "fallback",
2321
- "mask",
2322
- "placeholder"
2323
- ],
2324
- render: !0
2325
- });
2326
- return l(createVNode("div", mergeProps({
2327
- class: {
2328
- [`${u.value}`]: !0,
2329
- [`${c}`]: !0
2330
- },
2331
- ref: b
2332
- }, r, {
2333
- style: {
2334
- width: unit(t.size) || j.value,
2335
- height: unit(t.size) || M.value,
2336
- ...r.style || {}
2337
- },
2338
- onClick: () => {
2339
- g.value && U();
2340
- }
2341
- }), [
2342
- g.value ? createVNode("div", { class: classNames_default(u.value, `${c}-error`) }, [s.fallback]) : createVNode(Fragment, null, [createVNode("img", mergeProps(i, {
2343
- src: f.value,
2344
- loading: t.loading,
2345
- style: E.value,
2346
- class: classNames_default(u.value, t.imageClass, `${c}-img`, {
2347
- [`${c}-img-placeholder`]: t.placeholder === !0,
2348
- [`${c}-img-preview`]: k.value
2349
- }),
2350
- crossorigin: t.crossOrigin,
2351
- width: j.value,
2352
- height: M.value,
2353
- onClick: U,
2354
- onLoad: P,
2355
- onError: F
2356
- }), null), _.value && createVNode("div", {
2357
- class: classNames_default(`${c}-placeholder`, u.value),
2358
- onClick: U
2359
- }, [s.placeholder])]),
2360
- O.value.mask && k.value && createVNode("div", {
2361
- class: classNames_default(`${c}-mask`, O.value.maskClass, u.value),
2362
- style: { display: r.style?.display === "none" ? "none" : void 0 }
2363
- }, [s.mask || createVNode("div", { class: classNames_default(`${c}-mask-info`, u.value) }, [createVNode(EyeOutlined, null, null)])]),
2364
- k.value && createVNode(GImagePreview, mergeProps({ ref: d }, O.value, {
2365
- urls: O.value.urls || [t.src],
2366
- current: A.value,
2367
- onClose: () => te()
2368
- }), n)
2369
- ]));
2370
- };
2371
- }
2372
- });
2373
- GImage.isGImage = !0, GImage.install = (e) => (e.component(GImage.name, GImage), e);
2374
- export { GImage, GImagePreview, baseProps, imageProps };